poveste 0.1.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/LICENSE +22 -0
- package/README.md +11 -0
- package/bin.mjs +4 -0
- package/client.d.ts +19 -0
- package/client.js +15 -0
- package/dist/controls.d.ts +2 -0
- package/dist/controls.d.ts.map +1 -0
- package/dist/controls.js +1 -0
- package/dist/node/alias.d.ts +3 -0
- package/dist/node/alias.d.ts.map +1 -0
- package/dist/node/alias.js +5 -0
- package/dist/node/bin.d.ts +2 -0
- package/dist/node/bin.d.ts.map +1 -0
- package/dist/node/bin.js +35 -0
- package/dist/node/build-serialize.d.ts +22 -0
- package/dist/node/build-serialize.d.ts.map +1 -0
- package/dist/node/build-serialize.js +36 -0
- package/dist/node/build.d.ts +3 -0
- package/dist/node/build.d.ts.map +1 -0
- package/dist/node/build.js +228 -0
- package/dist/node/builtin-plugins/pinceau-tokens.d.ts +7 -0
- package/dist/node/builtin-plugins/pinceau-tokens.d.ts.map +1 -0
- package/dist/node/builtin-plugins/pinceau-tokens.js +505 -0
- package/dist/node/builtin-plugins/tailwind-tokens.d.ts +6 -0
- package/dist/node/builtin-plugins/tailwind-tokens.d.ts.map +1 -0
- package/dist/node/builtin-plugins/tailwind-tokens.js +523 -0
- package/dist/node/builtin-plugins/vanilla-support/MountStory.d.ts +15 -0
- package/dist/node/builtin-plugins/vanilla-support/MountStory.d.ts.map +1 -0
- package/dist/node/builtin-plugins/vanilla-support/MountStory.js +39 -0
- package/dist/node/builtin-plugins/vanilla-support/RenderStory.d.ts +39 -0
- package/dist/node/builtin-plugins/vanilla-support/RenderStory.d.ts.map +1 -0
- package/dist/node/builtin-plugins/vanilla-support/RenderStory.js +129 -0
- package/dist/node/builtin-plugins/vanilla-support/client.d.ts +4 -0
- package/dist/node/builtin-plugins/vanilla-support/client.d.ts.map +1 -0
- package/dist/node/builtin-plugins/vanilla-support/client.js +5 -0
- package/dist/node/builtin-plugins/vanilla-support/collect.d.ts +3 -0
- package/dist/node/builtin-plugins/vanilla-support/collect.d.ts.map +1 -0
- package/dist/node/builtin-plugins/vanilla-support/collect.js +33 -0
- package/dist/node/builtin-plugins/vanilla-support/plugin.d.ts +3 -0
- package/dist/node/builtin-plugins/vanilla-support/plugin.d.ts.map +1 -0
- package/dist/node/builtin-plugins/vanilla-support/plugin.js +29 -0
- package/dist/node/builtin-plugins/vanilla-support/types.d.ts +36 -0
- package/dist/node/builtin-plugins/vanilla-support/types.d.ts.map +1 -0
- package/dist/node/builtin-plugins/vanilla-support/types.js +3 -0
- package/dist/node/builtin-plugins/vanilla-support/vanilla.story.d.ts +4 -0
- package/dist/node/builtin-plugins/vanilla-support/vanilla.story.d.ts.map +1 -0
- package/dist/node/builtin-plugins/vanilla-support/vanilla.story.js +55 -0
- package/dist/node/collect/index.d.ts +14 -0
- package/dist/node/collect/index.d.ts.map +1 -0
- package/dist/node/collect/index.js +129 -0
- package/dist/node/collect/run.d.ts +3 -0
- package/dist/node/collect/run.d.ts.map +1 -0
- package/dist/node/collect/run.js +7 -0
- package/dist/node/collect/worker.d.ts +14 -0
- package/dist/node/collect/worker.d.ts.map +1 -0
- package/dist/node/collect/worker.js +64 -0
- package/dist/node/colors.d.ts +287 -0
- package/dist/node/colors.d.ts.map +1 -0
- package/dist/node/colors.js +324 -0
- package/dist/node/commands/build.d.ts +5 -0
- package/dist/node/commands/build.d.ts.map +1 -0
- package/dist/node/commands/build.js +9 -0
- package/dist/node/commands/dev.d.ts +8 -0
- package/dist/node/commands/dev.d.ts.map +1 -0
- package/dist/node/commands/dev.js +52 -0
- package/dist/node/commands/preview.d.ts +5 -0
- package/dist/node/commands/preview.d.ts.map +1 -0
- package/dist/node/commands/preview.js +15 -0
- package/dist/node/config.d.ts +40 -0
- package/dist/node/config.d.ts.map +1 -0
- package/dist/node/config.js +330 -0
- package/dist/node/context.d.ts +18 -0
- package/dist/node/context.d.ts.map +1 -0
- package/dist/node/context.js +28 -0
- package/dist/node/dom/dom-keys.d.ts +5 -0
- package/dist/node/dom/dom-keys.d.ts.map +1 -0
- package/dist/node/dom/dom-keys.js +233 -0
- package/dist/node/dom/env.d.ts +5 -0
- package/dist/node/dom/env.d.ts.map +1 -0
- package/dist/node/dom/env.js +47 -0
- package/dist/node/dom/util.d.ts +11 -0
- package/dist/node/dom/util.d.ts.map +1 -0
- package/dist/node/dom/util.js +65 -0
- package/dist/node/index.d.ts +12 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +4 -0
- package/dist/node/load.d.ts +9 -0
- package/dist/node/load.d.ts.map +1 -0
- package/dist/node/load.js +42 -0
- package/dist/node/markdown.d.ts +11 -0
- package/dist/node/markdown.d.ts.map +1 -0
- package/dist/node/markdown.js +228 -0
- package/dist/node/plugin.d.ts +42 -0
- package/dist/node/plugin.d.ts.map +1 -0
- package/dist/node/plugin.js +67 -0
- package/dist/node/preview.d.ts +8 -0
- package/dist/node/preview.d.ts.map +1 -0
- package/dist/node/preview.js +41 -0
- package/dist/node/search.d.ts +17 -0
- package/dist/node/search.d.ts.map +1 -0
- package/dist/node/search.js +72 -0
- package/dist/node/server.d.ts +12 -0
- package/dist/node/server.d.ts.map +1 -0
- package/dist/node/server.js +189 -0
- package/dist/node/stories.d.ts +22 -0
- package/dist/node/stories.d.ts.map +1 -0
- package/dist/node/stories.js +125 -0
- package/dist/node/tree.d.ts +4 -0
- package/dist/node/tree.d.ts.map +1 -0
- package/dist/node/tree.js +117 -0
- package/dist/node/util/find-up.d.ts +2 -0
- package/dist/node/util/find-up.d.ts.map +1 -0
- package/dist/node/util/find-up.js +20 -0
- package/dist/node/util/fs.d.ts +2 -0
- package/dist/node/util/fs.d.ts.map +1 -0
- package/dist/node/util/fs.js +1 -0
- package/dist/node/util/log.d.ts +2 -0
- package/dist/node/util/log.d.ts.map +1 -0
- package/dist/node/util/log.js +9 -0
- package/dist/node/util/slugify.d.ts +2 -0
- package/dist/node/util/slugify.d.ts.map +1 -0
- package/dist/node/util/slugify.js +22 -0
- package/dist/node/util/vendors.d.ts +3 -0
- package/dist/node/util/vendors.d.ts.map +1 -0
- package/dist/node/util/vendors.js +22 -0
- package/dist/node/vendors/controls.d.ts +2 -0
- package/dist/node/vendors/controls.d.ts.map +1 -0
- package/dist/node/vendors/controls.js +1 -0
- package/dist/node/vendors/vue.d.ts +2 -0
- package/dist/node/vendors/vue.d.ts.map +1 -0
- package/dist/node/vendors/vue.js +1 -0
- package/dist/node/virtual/index.d.ts +38 -0
- package/dist/node/virtual/index.d.ts.map +1 -0
- package/dist/node/virtual/index.js +49 -0
- package/dist/node/virtual/markdown.d.ts +3 -0
- package/dist/node/virtual/markdown.d.ts.map +1 -0
- package/dist/node/virtual/markdown.js +19 -0
- package/dist/node/virtual/noop.d.ts +2 -0
- package/dist/node/virtual/noop.d.ts.map +1 -0
- package/dist/node/virtual/noop.js +1 -0
- package/dist/node/virtual/resolved-commands.d.ts +3 -0
- package/dist/node/virtual/resolved-commands.d.ts.map +1 -0
- package/dist/node/virtual/resolved-commands.js +32 -0
- package/dist/node/virtual/resolved-config.d.ts +3 -0
- package/dist/node/virtual/resolved-config.d.ts.map +1 -0
- package/dist/node/virtual/resolved-config.js +10 -0
- package/dist/node/virtual/resolved-generated-global-setup.d.ts +3 -0
- package/dist/node/virtual/resolved-generated-global-setup.d.ts.map +1 -0
- package/dist/node/virtual/resolved-generated-global-setup.js +23 -0
- package/dist/node/virtual/resolved-generated-setup-code.d.ts +3 -0
- package/dist/node/virtual/resolved-generated-setup-code.d.ts.map +1 -0
- package/dist/node/virtual/resolved-generated-setup-code.js +5 -0
- package/dist/node/virtual/resolved-markdown-files.d.ts +3 -0
- package/dist/node/virtual/resolved-markdown-files.d.ts.map +1 -0
- package/dist/node/virtual/resolved-markdown-files.js +17 -0
- package/dist/node/virtual/resolved-stories.d.ts +3 -0
- package/dist/node/virtual/resolved-stories.d.ts.map +1 -0
- package/dist/node/virtual/resolved-stories.js +42 -0
- package/dist/node/virtual/resolved-support-plugins-client.d.ts +3 -0
- package/dist/node/virtual/resolved-support-plugins-client.d.ts.map +1 -0
- package/dist/node/virtual/resolved-support-plugins-client.js +11 -0
- package/dist/node/virtual/resolved-support-plugins-collect.d.ts +3 -0
- package/dist/node/virtual/resolved-support-plugins-collect.d.ts.map +1 -0
- package/dist/node/virtual/resolved-support-plugins-collect.js +11 -0
- package/dist/node/virtual/resolved-theme.d.ts +3 -0
- package/dist/node/virtual/resolved-theme.d.ts.map +1 -0
- package/dist/node/virtual/resolved-theme.js +12 -0
- package/dist/node/virtual/story-source.d.ts +3 -0
- package/dist/node/virtual/story-source.d.ts.map +1 -0
- package/dist/node/virtual/story-source.js +16 -0
- package/dist/node/virtual/story.d.ts +3 -0
- package/dist/node/virtual/story.d.ts.map +1 -0
- package/dist/node/virtual/story.js +7 -0
- package/dist/node/virtual/util.d.ts +3 -0
- package/dist/node/virtual/util.d.ts.map +1 -0
- package/dist/node/virtual/util.js +4 -0
- package/dist/node/virtual/vite-plugin.d.ts +4 -0
- package/dist/node/virtual/vite-plugin.d.ts.map +1 -0
- package/dist/node/virtual/vite-plugin.js +126 -0
- package/dist/node/vite.d.ts +9 -0
- package/dist/node/vite.d.ts.map +1 -0
- package/dist/node/vite.js +337 -0
- package/index.d.ts +1 -0
- package/package.json +89 -0
- package/plugin.d.ts +3 -0
- package/plugin.js +11 -0
- package/src/controls.ts +1 -0
- package/src/node/__tests__/markdown/test1.story.md +7 -0
- package/src/node/__tests__/markdown/test2.story.md +5 -0
- package/src/node/__tests__/markdown.spec.ts +61 -0
- package/src/node/__tests__/tree.spec.ts +109 -0
- package/src/node/alias.ts +8 -0
- package/src/node/bin.ts +43 -0
- package/src/node/build-serialize.ts +62 -0
- package/src/node/build.ts +283 -0
- package/src/node/builtin-plugins/pinceau-tokens.ts +521 -0
- package/src/node/builtin-plugins/tailwind-tokens.ts +536 -0
- package/src/node/builtin-plugins/vanilla-support/MountStory.ts +49 -0
- package/src/node/builtin-plugins/vanilla-support/RenderStory.ts +164 -0
- package/src/node/builtin-plugins/vanilla-support/client.ts +6 -0
- package/src/node/builtin-plugins/vanilla-support/collect.ts +43 -0
- package/src/node/builtin-plugins/vanilla-support/plugin.ts +35 -0
- package/src/node/builtin-plugins/vanilla-support/types.ts +40 -0
- package/src/node/builtin-plugins/vanilla-support/vanilla.story.ts +63 -0
- package/src/node/collect/index.ts +160 -0
- package/src/node/collect/run.ts +9 -0
- package/src/node/collect/worker.ts +97 -0
- package/src/node/colors.ts +340 -0
- package/src/node/commands/build.ts +14 -0
- package/src/node/commands/dev.ts +67 -0
- package/src/node/commands/preview.ts +22 -0
- package/src/node/config.ts +385 -0
- package/src/node/context.ts +60 -0
- package/src/node/dom/dom-keys.ts +238 -0
- package/src/node/dom/env.ts +60 -0
- package/src/node/dom/util.ts +83 -0
- package/src/node/index.ts +12 -0
- package/src/node/load.ts +59 -0
- package/src/node/markdown.ts +267 -0
- package/src/node/plugin.ts +95 -0
- package/src/node/preview.ts +57 -0
- package/src/node/search.ts +84 -0
- package/src/node/server.ts +235 -0
- package/src/node/stories.ts +154 -0
- package/src/node/tree.ts +158 -0
- package/src/node/util/find-up.ts +24 -0
- package/src/node/util/fs.ts +1 -0
- package/src/node/util/log.ts +10 -0
- package/src/node/util/slugify.ts +26 -0
- package/src/node/util/vendors.ts +27 -0
- package/src/node/vendors/controls.ts +1 -0
- package/src/node/vendors/vue.ts +1 -0
- package/src/node/virtual/index.ts +50 -0
- package/src/node/virtual/markdown.ts +21 -0
- package/src/node/virtual/noop.ts +1 -0
- package/src/node/virtual/resolved-commands.ts +42 -0
- package/src/node/virtual/resolved-config.ts +12 -0
- package/src/node/virtual/resolved-generated-global-setup.ts +25 -0
- package/src/node/virtual/resolved-generated-setup-code.ts +7 -0
- package/src/node/virtual/resolved-markdown-files.ts +19 -0
- package/src/node/virtual/resolved-stories.ts +44 -0
- package/src/node/virtual/resolved-support-plugins-client.ts +14 -0
- package/src/node/virtual/resolved-support-plugins-collect.ts +14 -0
- package/src/node/virtual/resolved-theme.ts +14 -0
- package/src/node/virtual/story-source.ts +18 -0
- package/src/node/virtual/story.ts +9 -0
- package/src/node/virtual/util.ts +5 -0
- package/src/node/virtual/vite-plugin.ts +146 -0
- package/src/node/vite.ts +379 -0
- package/tsconfig.json +44 -0
- package/vitest.config.ts +10 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Guillaume Chau (original "histoire" project)
|
|
4
|
+
Copyright (c) 2026 Sorin Gitlan (poveste fork)
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
package/bin.mjs
ADDED
package/client.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated
|
|
3
|
+
*/
|
|
4
|
+
export function hstEvent(name: string, argument): void
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Logs an event to the 'Events' sidepane.
|
|
8
|
+
* @param name Event name
|
|
9
|
+
* @param argument Additional log data displayed when inspecting the event.
|
|
10
|
+
*/
|
|
11
|
+
export function logEvent(name: string, argument): void
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Returns `true` when in the NodeJS server while collecting stories.
|
|
15
|
+
*/
|
|
16
|
+
export function isCollecting(): boolean
|
|
17
|
+
|
|
18
|
+
export function toggleDark(value?: boolean): boolean
|
|
19
|
+
export function isDark(): boolean
|
package/client.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { logEvent } from '@poveste/app'
|
|
2
|
+
|
|
3
|
+
export * from '@poveste/app'
|
|
4
|
+
|
|
5
|
+
export function isCollecting() {
|
|
6
|
+
return process.env.HST_COLLECT === 'true'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated
|
|
11
|
+
*/
|
|
12
|
+
export function hstEvent(...args) {
|
|
13
|
+
console.warn(`'hstEvent' is deprecated. Use 'logEvent' instead.`)
|
|
14
|
+
return logEvent(...args)
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../src/controls.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
package/dist/controls.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@poveste/controls';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alias.d.ts","sourceRoot":"","sources":["../../src/node/alias.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,QAAQ,QAAmH,CAAA;AAExI,eAAO,MAAM,SAAS,QAAwD,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import path from 'pathe';
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
export const APP_PATH = path.join(path.dirname(require.resolve('@poveste/app/package.json')), process.env.HISTOIRE_DEV ? 'src' : 'dist');
|
|
5
|
+
export const TEMP_PATH = path.join(process.cwd(), 'node_modules', '.histoire');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../src/node/bin.ts"],"names":[],"mappings":""}
|
package/dist/node/bin.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname, resolve } from 'pathe';
|
|
4
|
+
import sade from 'sade';
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const { version } = JSON.parse(fs.readFileSync(resolve(__dirname, '../../package.json'), 'utf8'));
|
|
7
|
+
process.env.NODE_ENV = 'development';
|
|
8
|
+
process.env.HISTOIRE = 'true';
|
|
9
|
+
const program = sade('poveste');
|
|
10
|
+
program.version(version);
|
|
11
|
+
program.command('dev')
|
|
12
|
+
.describe('open the stories in your browser for development')
|
|
13
|
+
.option('-p, --port <port>', 'Listening port of the server')
|
|
14
|
+
.option('-c, --config <file>', `[string] use specified config file`)
|
|
15
|
+
.option('--open', 'Open in your default browser')
|
|
16
|
+
.option('--host <host>', '[string] specify hostname')
|
|
17
|
+
.action(async (options) => {
|
|
18
|
+
const { devCommand } = await import('./commands/dev.js');
|
|
19
|
+
return devCommand(options);
|
|
20
|
+
});
|
|
21
|
+
program.command('build')
|
|
22
|
+
.describe('build the histoire final app you can deploy')
|
|
23
|
+
.option('-c, --config <file>', `[string] use specified config file`)
|
|
24
|
+
.action(async (options) => {
|
|
25
|
+
const { buildCommand } = await import('./commands/build.js');
|
|
26
|
+
return buildCommand(options);
|
|
27
|
+
});
|
|
28
|
+
program.command('preview')
|
|
29
|
+
.describe('preview the built directory')
|
|
30
|
+
.option('-p, --port <port>', 'Listening port of the server')
|
|
31
|
+
.action(async (options) => {
|
|
32
|
+
const { previewCommand } = await import('./commands/preview.js');
|
|
33
|
+
return previewCommand(options);
|
|
34
|
+
});
|
|
35
|
+
program.parse(process.argv);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ServerStory } from '@poveste/shared';
|
|
2
|
+
import type { Context } from './context.js';
|
|
3
|
+
interface SerializedStory extends Omit<ServerStory, 'docsText'> {
|
|
4
|
+
relativePath: string;
|
|
5
|
+
supportPluginId: string;
|
|
6
|
+
treePath?: string[];
|
|
7
|
+
virtual?: boolean;
|
|
8
|
+
markdownFile?: SerializedMarkdownFile;
|
|
9
|
+
}
|
|
10
|
+
interface SerializedMarkdownFile {
|
|
11
|
+
id: string;
|
|
12
|
+
relativePath: string;
|
|
13
|
+
isRelatedToStory: boolean;
|
|
14
|
+
frontmatter?: any;
|
|
15
|
+
}
|
|
16
|
+
interface SerializedStoryData {
|
|
17
|
+
stories: SerializedStory[];
|
|
18
|
+
markdownFiles: SerializedMarkdownFile[];
|
|
19
|
+
}
|
|
20
|
+
export declare function getSerializedStoryData(ctx: Context): SerializedStoryData;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=build-serialize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-serialize.d.ts","sourceRoot":"","sources":["../../src/node/build-serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C,UAAU,eAAgB,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC;IAC7D,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,YAAY,CAAC,EAAE,sBAAsB,CAAA;CACtC;AAED,UAAU,sBAAsB;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB,EAAE,OAAO,CAAA;IACzB,WAAW,CAAC,EAAE,GAAG,CAAA;CAClB;AAED,UAAU,mBAAmB;IAC3B,OAAO,EAAE,eAAe,EAAE,CAAA;IAC1B,aAAa,EAAE,sBAAsB,EAAE,CAAA;CACxC;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,mBAAmB,CAsCxE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function getSerializedStoryData(ctx) {
|
|
2
|
+
const data = {
|
|
3
|
+
stories: [],
|
|
4
|
+
markdownFiles: [],
|
|
5
|
+
};
|
|
6
|
+
for (const storyFile of ctx.storyFiles) {
|
|
7
|
+
if (storyFile.story) {
|
|
8
|
+
data.stories.push({
|
|
9
|
+
...Object.assign({}, storyFile.story, {
|
|
10
|
+
docsText: undefined,
|
|
11
|
+
}),
|
|
12
|
+
relativePath: storyFile.relativePath,
|
|
13
|
+
supportPluginId: storyFile.supportPluginId,
|
|
14
|
+
treePath: storyFile.treePath,
|
|
15
|
+
virtual: storyFile.virtual,
|
|
16
|
+
markdownFile: storyFile.markdownFile
|
|
17
|
+
? {
|
|
18
|
+
id: storyFile.markdownFile.id,
|
|
19
|
+
relativePath: storyFile.markdownFile.relativePath,
|
|
20
|
+
isRelatedToStory: storyFile.markdownFile.isRelatedToStory,
|
|
21
|
+
frontmatter: storyFile.markdownFile.frontmatter,
|
|
22
|
+
}
|
|
23
|
+
: null,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
for (const markdownFile of ctx.markdownFiles) {
|
|
28
|
+
data.markdownFiles.push({
|
|
29
|
+
id: markdownFile.id,
|
|
30
|
+
relativePath: markdownFile.relativePath,
|
|
31
|
+
isRelatedToStory: markdownFile.isRelatedToStory,
|
|
32
|
+
frontmatter: markdownFile.frontmatter,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/node/build.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AA+B3C,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,iBA8MvC"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { performance } from 'node:perf_hooks';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import { lookup as lookupMime } from 'mrmime';
|
|
4
|
+
import { join } from 'pathe';
|
|
5
|
+
import pc from 'picocolors';
|
|
6
|
+
import { createServer as createViteServer, mergeConfig as mergeViteConfig, build as viteBuild, } from 'vite';
|
|
7
|
+
import { APP_PATH } from './alias.js';
|
|
8
|
+
import { getSerializedStoryData } from './build-serialize.js';
|
|
9
|
+
import { useCollectStories } from './collect/index.js';
|
|
10
|
+
import { useModuleLoader } from './load.js';
|
|
11
|
+
import { createMarkdownFilesWatcher } from './markdown.js';
|
|
12
|
+
import { BuildPluginApi } from './plugin.js';
|
|
13
|
+
import { startPreview } from './preview.js';
|
|
14
|
+
import { findAllStories } from './stories.js';
|
|
15
|
+
import { getViteConfigWithPlugins } from './vite.js';
|
|
16
|
+
const PRELOAD_MODULES = [
|
|
17
|
+
'vendor',
|
|
18
|
+
];
|
|
19
|
+
const PREFETCHED_MODULES = [
|
|
20
|
+
'StoryView',
|
|
21
|
+
'reactivity',
|
|
22
|
+
'global-components',
|
|
23
|
+
];
|
|
24
|
+
export async function build(ctx) {
|
|
25
|
+
const startTime = performance.now();
|
|
26
|
+
await findAllStories(ctx);
|
|
27
|
+
// Scan for markdown files
|
|
28
|
+
{
|
|
29
|
+
const { stop } = await createMarkdownFilesWatcher(ctx);
|
|
30
|
+
await stop();
|
|
31
|
+
}
|
|
32
|
+
const { viteConfig } = await getViteConfigWithPlugins(true, ctx);
|
|
33
|
+
const server = await createViteServer(mergeViteConfig(viteConfig, {
|
|
34
|
+
optimizeDeps: { include: [], noDiscovery: true },
|
|
35
|
+
}));
|
|
36
|
+
await server.pluginContainer.buildStart({});
|
|
37
|
+
const moduleLoader = useModuleLoader({
|
|
38
|
+
server,
|
|
39
|
+
throws: true,
|
|
40
|
+
});
|
|
41
|
+
const changeViteConfigCallbacks = [];
|
|
42
|
+
const buildEndCallbacks = [];
|
|
43
|
+
const previewStoryCallbacks = [];
|
|
44
|
+
for (const plugin of ctx.config.plugins) {
|
|
45
|
+
if (plugin.onBuild) {
|
|
46
|
+
const api = new BuildPluginApi(ctx, plugin, moduleLoader);
|
|
47
|
+
await plugin.onBuild(api);
|
|
48
|
+
changeViteConfigCallbacks.push(...api.changeViteConfigCallbacks);
|
|
49
|
+
buildEndCallbacks.push(...api.buildEndCallbacks);
|
|
50
|
+
previewStoryCallbacks.push(...api.previewStoryCallbacks);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Collect story data
|
|
54
|
+
const { executeStoryFile, destroy: destroyCollectStories } = useCollectStories({
|
|
55
|
+
server,
|
|
56
|
+
throws: true,
|
|
57
|
+
}, ctx);
|
|
58
|
+
await Promise.all(ctx.storyFiles.map(storyFile => executeStoryFile(storyFile)));
|
|
59
|
+
await destroyCollectStories();
|
|
60
|
+
const storyCount = ctx.storyFiles.reduce((sum, file) => sum + (file.story?.variants.length ? 1 : 0), 0);
|
|
61
|
+
const variantCount = ctx.storyFiles.reduce((sum, file) => sum + (file.story?.variants.length ?? 0), 0);
|
|
62
|
+
const emptyStoryCount = ctx.storyFiles.length - storyCount;
|
|
63
|
+
const { viteConfig: buildViteConfigRaw } = await getViteConfigWithPlugins(false, ctx);
|
|
64
|
+
const buildViteConfig = mergeViteConfig(buildViteConfigRaw, {
|
|
65
|
+
mode: 'development',
|
|
66
|
+
build: {
|
|
67
|
+
lib: false,
|
|
68
|
+
rollupOptions: {
|
|
69
|
+
input: [
|
|
70
|
+
join(APP_PATH, 'bundle-main.js'),
|
|
71
|
+
join(APP_PATH, 'bundle-sandbox.js'),
|
|
72
|
+
],
|
|
73
|
+
plugins: [
|
|
74
|
+
{
|
|
75
|
+
name: 'histoire-build-rollup-options-override',
|
|
76
|
+
enforce: 'post',
|
|
77
|
+
options(options) {
|
|
78
|
+
// Don't externalize
|
|
79
|
+
options.external = [];
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
// For @vite/plugin-vue: Always put our vite server
|
|
87
|
+
// Disable template inlining
|
|
88
|
+
// (so that we no longer need defineExpose)
|
|
89
|
+
// Nuxt: replaces the Nuxt vite dev server
|
|
90
|
+
buildViteConfig.plugins.push({
|
|
91
|
+
name: 'histoire-vue-plugin-override',
|
|
92
|
+
config(config) {
|
|
93
|
+
const vuePlugin = config.plugins.find((p) => p.name === 'vite:vue');
|
|
94
|
+
if (vuePlugin) {
|
|
95
|
+
// @ts-expect-error vue plugin use function form
|
|
96
|
+
const original = vuePlugin.configureServer.bind(vuePlugin);
|
|
97
|
+
vuePlugin.configureServer = () => {
|
|
98
|
+
original({
|
|
99
|
+
...server,
|
|
100
|
+
config: {
|
|
101
|
+
...server.config,
|
|
102
|
+
server: {
|
|
103
|
+
...server.config.server,
|
|
104
|
+
hmr: false,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
// @ts-expect-error vue plugin use function form
|
|
110
|
+
vuePlugin.configureServer(server);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
buildViteConfig.plugins.push({
|
|
115
|
+
name: 'histoire-build-config-override',
|
|
116
|
+
enforce: 'post',
|
|
117
|
+
config(config) {
|
|
118
|
+
// Don't externalize
|
|
119
|
+
config.build.rollupOptions.external = [];
|
|
120
|
+
// Force chunk strategy
|
|
121
|
+
config.build.rollupOptions.output = {
|
|
122
|
+
manualChunks(id) {
|
|
123
|
+
if (!id.includes('@poveste/app') && id.includes('node_modules')) {
|
|
124
|
+
for (const test of ctx.config.build?.excludeFromVendorsChunk ?? []) {
|
|
125
|
+
if ((typeof test === 'string' && id.includes(test)) || (test instanceof RegExp && test.test(id))) {
|
|
126
|
+
// Excluded from vendor chunk
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return 'vendor';
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
// Force vite build options
|
|
135
|
+
Object.assign(config.build, {
|
|
136
|
+
outDir: ctx.config.outDir,
|
|
137
|
+
emptyOutDir: true,
|
|
138
|
+
cssCodeSplit: false,
|
|
139
|
+
minify: false,
|
|
140
|
+
// Don't build in SSR mode
|
|
141
|
+
ssr: false,
|
|
142
|
+
});
|
|
143
|
+
config.define.__HST_COLLECT__ = false;
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
for (const cb of changeViteConfigCallbacks) {
|
|
147
|
+
console.log('vite config hook', cb);
|
|
148
|
+
await cb(buildViteConfig);
|
|
149
|
+
}
|
|
150
|
+
const results = await viteBuild(buildViteConfig);
|
|
151
|
+
const result = Array.isArray(results) ? results[0] : results;
|
|
152
|
+
const styleOutput = result.output.find(o => o.name === 'style.css' && o.type === 'asset');
|
|
153
|
+
// Preload
|
|
154
|
+
const preloadOutputs = result.output.filter(o => PRELOAD_MODULES.includes(o.name) && o.type === 'chunk');
|
|
155
|
+
const preloadHtml = generateScriptLinks(preloadOutputs.map(o => o.fileName), 'preload', ctx);
|
|
156
|
+
// Prefetch
|
|
157
|
+
const prefetchOutputs = result.output.filter(o => PREFETCHED_MODULES.includes(o.name) && o.type === 'chunk');
|
|
158
|
+
const prefetchHtml = generateScriptLinks(prefetchOutputs.map(o => o.fileName), 'prefetch', ctx);
|
|
159
|
+
// Index
|
|
160
|
+
const indexOutput = result.output.find(o => o.name === 'bundle-main' && o.type === 'chunk');
|
|
161
|
+
const indexHtml = generateEntryHtml(indexOutput.fileName, styleOutput.fileName, {
|
|
162
|
+
HEAD: `${preloadHtml}${prefetchHtml}`,
|
|
163
|
+
}, ctx);
|
|
164
|
+
await writeFile('index.html', indexHtml, ctx);
|
|
165
|
+
// Sandbox
|
|
166
|
+
const sandboxOutput = result.output.find(o => o.name === 'bundle-sandbox' && o.type === 'chunk');
|
|
167
|
+
const sandboxHtml = generateEntryHtml(sandboxOutput.fileName, styleOutput.fileName, {}, ctx);
|
|
168
|
+
await writeFile('__sandbox.html', sandboxHtml, ctx);
|
|
169
|
+
await writeFile('histoire.json', JSON.stringify(getSerializedStoryData(ctx), null, 2), ctx);
|
|
170
|
+
const duration = performance.now() - startTime;
|
|
171
|
+
if (emptyStoryCount) {
|
|
172
|
+
console.warn(pc.yellow(`⚠️ ${emptyStoryCount} empty story file${emptyStoryCount === 1 ? '' : 's'}`));
|
|
173
|
+
}
|
|
174
|
+
console.log(pc.green(`✅ Built ${storyCount} stor${storyCount === 1 ? 'y' : 'ies'} (${variantCount} variant${variantCount === 1 ? '' : 's'}) in ${Math.round(duration / 1000 * 100) / 100}s`));
|
|
175
|
+
// Render
|
|
176
|
+
if (previewStoryCallbacks.length) {
|
|
177
|
+
const { baseUrl, close } = await startPreview(null, ctx);
|
|
178
|
+
for (const storyFile of ctx.storyFiles) {
|
|
179
|
+
const story = storyFile.story;
|
|
180
|
+
for (const variant of story.variants) {
|
|
181
|
+
const query = new URLSearchParams();
|
|
182
|
+
query.append('storyId', story.id);
|
|
183
|
+
query.append('variantId', variant.id);
|
|
184
|
+
const url = `${baseUrl}__sandbox.html?${query.toString()}`;
|
|
185
|
+
for (const fn of previewStoryCallbacks) {
|
|
186
|
+
await fn({
|
|
187
|
+
file: storyFile.path,
|
|
188
|
+
story,
|
|
189
|
+
variant,
|
|
190
|
+
url,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
await close();
|
|
196
|
+
}
|
|
197
|
+
await server.close();
|
|
198
|
+
for (const fn of buildEndCallbacks) {
|
|
199
|
+
await fn();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function generateBaseHtml(head, body, ctx) {
|
|
203
|
+
return `<!DOCTYPE html>
|
|
204
|
+
<html>
|
|
205
|
+
<head>
|
|
206
|
+
<title>${ctx.config.theme.title}</title>
|
|
207
|
+
<meta charset="utf-8">
|
|
208
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
209
|
+
<meta name="description" content="">
|
|
210
|
+
${head}
|
|
211
|
+
</head>
|
|
212
|
+
<body>
|
|
213
|
+
${body}
|
|
214
|
+
</body>
|
|
215
|
+
</html>`;
|
|
216
|
+
}
|
|
217
|
+
function generateEntryHtml(jsEntryFile, cssEntryFile, variables, ctx) {
|
|
218
|
+
return generateBaseHtml(`<link rel="stylesheet" href="${ctx.resolvedViteConfig.base}${cssEntryFile}">
|
|
219
|
+
${ctx.config.theme?.favicon ? `<link rel="icon" type="${lookupMime(ctx.config.theme.favicon)}" href="${ctx.resolvedViteConfig.base}${ctx.config.theme.favicon}"/>` : ''}
|
|
220
|
+
${variables.HEAD ?? ''}`, `<div id="app"></div>
|
|
221
|
+
<script type="module" src="${ctx.resolvedViteConfig.base}${jsEntryFile}"></script>`, ctx);
|
|
222
|
+
}
|
|
223
|
+
async function writeFile(fileName, content, ctx) {
|
|
224
|
+
await fs.writeFile(join(ctx.config.outDir, fileName), content, 'utf8');
|
|
225
|
+
}
|
|
226
|
+
function generateScriptLinks(prefetchScripts, rel, ctx) {
|
|
227
|
+
return prefetchScripts.map(s => `<link rel="${rel}" href="${ctx.resolvedViteConfig.base}${s}" as="script" crossOrigin="anonymous">`).join('');
|
|
228
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Plugin } from '@poveste/shared';
|
|
2
|
+
export interface PinceauTokensOptions {
|
|
3
|
+
configOrPaths?: string | string[];
|
|
4
|
+
configFileName?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function pinceauTokens(_options?: PinceauTokensOptions): Plugin;
|
|
7
|
+
//# sourceMappingURL=pinceau-tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pinceau-tokens.d.ts","sourceRoot":"","sources":["../../../src/node/builtin-plugins/pinceau-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,iBAAiB,CAAA;AAI5D,MAAM,WAAW,oBAAoB;IACnC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACjC,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,wBAAgB,aAAa,CAAC,QAAQ,GAAE,oBAAyB,GAAG,MAAM,CA2DzE"}
|