histoire 0.17.16 → 0.17.17
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/client.d.ts +5 -5
- package/client.js +2 -2
- package/dist/node/alias.js +1 -1
- package/dist/node/bin.js +1 -1
- package/dist/node/build-serialize.d.ts +1 -1
- package/dist/node/build.d.ts +1 -1
- package/dist/node/build.js +2 -2
- package/dist/node/builtin-plugins/pinceau-tokens.d.ts +1 -1
- package/dist/node/builtin-plugins/pinceau-tokens.js +4 -4
- package/dist/node/builtin-plugins/tailwind-tokens.js +3 -1
- package/dist/node/builtin-plugins/vanilla-support/MountStory.d.ts +1 -1
- package/dist/node/builtin-plugins/vanilla-support/MountStory.js +1 -1
- package/dist/node/builtin-plugins/vanilla-support/RenderStory.d.ts +1 -1
- package/dist/node/builtin-plugins/vanilla-support/RenderStory.js +1 -2
- package/dist/node/builtin-plugins/vanilla-support/plugin.js +1 -1
- package/dist/node/builtin-plugins/vanilla-support/types.d.ts +1 -1
- package/dist/node/collect/index.js +2 -2
- package/dist/node/collect/worker.d.ts +1 -1
- package/dist/node/collect/worker.js +2 -2
- package/dist/node/colors.js +4 -4
- package/dist/node/config.d.ts +1 -1
- package/dist/node/config.js +8 -8
- package/dist/node/context.d.ts +2 -2
- package/dist/node/dom/env.js +6 -6
- package/dist/node/dom/util.js +8 -12
- package/dist/node/markdown.js +3 -3
- package/dist/node/plugin.d.ts +1 -1
- package/dist/node/plugin.js +0 -1
- package/dist/node/search.d.ts +1 -1
- package/dist/node/server.d.ts +1 -1
- package/dist/node/server.js +2 -2
- package/dist/node/stories.d.ts +1 -1
- package/dist/node/stories.js +3 -3
- package/dist/node/tree.d.ts +1 -1
- package/dist/node/tree.js +1 -1
- package/dist/node/util/find-up.js +1 -1
- package/dist/node/util/slugify.d.ts +1 -1
- package/dist/node/util/slugify.js +3 -3
- package/dist/node/virtual/index.d.ts +11 -11
- package/dist/node/virtual/markdown.d.ts +1 -1
- package/dist/node/virtual/markdown.js +2 -2
- package/dist/node/virtual/resolved-commands.d.ts +1 -1
- package/dist/node/virtual/resolved-commands.js +2 -2
- package/dist/node/virtual/resolved-config.d.ts +1 -1
- package/dist/node/virtual/resolved-config.js +2 -2
- package/dist/node/virtual/resolved-generated-global-setup.d.ts +1 -1
- package/dist/node/virtual/resolved-generated-global-setup.js +3 -3
- package/dist/node/virtual/resolved-generated-setup-code.d.ts +1 -1
- package/dist/node/virtual/resolved-generated-setup-code.js +2 -2
- package/dist/node/virtual/resolved-markdown-files.d.ts +1 -1
- package/dist/node/virtual/resolved-markdown-files.js +2 -2
- package/dist/node/virtual/resolved-stories.d.ts +1 -1
- package/dist/node/virtual/resolved-stories.js +3 -3
- package/dist/node/virtual/resolved-support-plugins-client.d.ts +1 -1
- package/dist/node/virtual/resolved-support-plugins-client.js +2 -2
- package/dist/node/virtual/resolved-support-plugins-collect.d.ts +1 -1
- package/dist/node/virtual/resolved-support-plugins-collect.js +2 -2
- package/dist/node/virtual/resolved-theme.d.ts +1 -1
- package/dist/node/virtual/resolved-theme.js +2 -2
- package/dist/node/virtual/story-source.d.ts +1 -1
- package/dist/node/virtual/story-source.js +2 -2
- package/dist/node/virtual/story.d.ts +1 -1
- package/dist/node/virtual/story.js +2 -2
- package/dist/node/virtual/vite-plugin.d.ts +1 -1
- package/dist/node/virtual/vite-plugin.js +122 -120
- package/dist/node/vite.d.ts +2 -2
- package/dist/node/vite.js +6 -8
- package/package.json +11 -11
- package/plugin.d.ts +2 -2
- package/plugin.js +2 -2
- package/src/node/__tests__/markdown.spec.ts +11 -9
- package/src/node/__tests__/tree.spec.ts +6 -6
- package/src/node/alias.ts +1 -1
- package/src/node/bin.ts +1 -1
- package/src/node/build-serialize.ts +7 -7
- package/src/node/build.ts +17 -15
- package/src/node/builtin-plugins/pinceau-tokens.ts +9 -9
- package/src/node/builtin-plugins/tailwind-tokens.ts +10 -7
- package/src/node/builtin-plugins/vanilla-support/MountStory.ts +6 -7
- package/src/node/builtin-plugins/vanilla-support/RenderStory.ts +9 -10
- package/src/node/builtin-plugins/vanilla-support/client.ts +1 -1
- package/src/node/builtin-plugins/vanilla-support/collect.ts +3 -2
- package/src/node/builtin-plugins/vanilla-support/plugin.ts +3 -3
- package/src/node/builtin-plugins/vanilla-support/types.ts +2 -2
- package/src/node/collect/index.ts +12 -10
- package/src/node/collect/run.ts +1 -1
- package/src/node/collect/worker.ts +5 -5
- package/src/node/colors.ts +5 -5
- package/src/node/commands/build.ts +1 -1
- package/src/node/commands/dev.ts +3 -3
- package/src/node/commands/preview.ts +1 -1
- package/src/node/config.ts +25 -21
- package/src/node/context.ts +6 -5
- package/src/node/dom/env.ts +9 -9
- package/src/node/dom/util.ts +13 -13
- package/src/node/load.ts +6 -5
- package/src/node/markdown.ts +21 -17
- package/src/node/plugin.ts +18 -19
- package/src/node/preview.ts +6 -4
- package/src/node/search.ts +9 -9
- package/src/node/server.ts +14 -11
- package/src/node/stories.ts +12 -12
- package/src/node/tree.ts +20 -15
- package/src/node/util/find-up.ts +2 -2
- package/src/node/util/log.ts +3 -2
- package/src/node/util/slugify.ts +2 -2
- package/src/node/util/vendors.ts +1 -1
- package/src/node/virtual/markdown.ts +1 -1
- package/src/node/virtual/resolved-commands.ts +4 -3
- package/src/node/virtual/resolved-config.ts +1 -1
- package/src/node/virtual/resolved-generated-global-setup.ts +4 -3
- package/src/node/virtual/resolved-generated-setup-code.ts +1 -1
- package/src/node/virtual/resolved-markdown-files.ts +1 -1
- package/src/node/virtual/resolved-stories.ts +2 -2
- package/src/node/virtual/resolved-support-plugins-client.ts +1 -1
- package/src/node/virtual/resolved-support-plugins-collect.ts +1 -1
- package/src/node/virtual/resolved-theme.ts +1 -1
- package/src/node/virtual/story-source.ts +3 -2
- package/src/node/virtual/story.ts +1 -1
- package/src/node/virtual/vite-plugin.ts +134 -130
- package/src/node/vite.ts +33 -30
- package/tsconfig.json +19 -19
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const serializedFields = ['id', 'label', 'prompts', 'icon', 'searchText'];
|
|
2
|
-
export
|
|
2
|
+
export function resolvedCommands(ctx) {
|
|
3
3
|
const imports = [];
|
|
4
4
|
const commands = [];
|
|
5
5
|
for (const command of ctx.registeredCommands) {
|
|
@@ -9,7 +9,7 @@ export const resolvedCommands = (ctx) => {
|
|
|
9
9
|
return `${imports.join('\n')}
|
|
10
10
|
export const registeredCommands = [${commands.join(', ')}]
|
|
11
11
|
`;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
function getCommandFields(command, imports) {
|
|
14
14
|
const fields = [];
|
|
15
15
|
for (const field of serializedFields) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Context } from '../context.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function resolvedConfig(ctx: Context): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export function resolvedConfig(ctx) {
|
|
2
2
|
let js = `export const config = ${JSON.stringify(ctx.config)}\n`;
|
|
3
3
|
if (ctx.config.theme?.logo) {
|
|
4
4
|
for (const key in ctx.config.theme.logo) {
|
|
@@ -7,4 +7,4 @@ export const resolvedConfig = (ctx) => {
|
|
|
7
7
|
}
|
|
8
8
|
js += `export const logos = {${Object.keys(ctx.config.theme?.logo ?? {}).map(key => `${key}: Logo_${key}`).join(', ')}}\n`;
|
|
9
9
|
return js;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Context } from '../context.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function resolvedGeneratedGlobalSetup(ctx: Context): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GENERATED_SETUP_CODE } from './index.js';
|
|
2
1
|
import { ID_SEPARATOR } from './util.js';
|
|
3
|
-
|
|
2
|
+
import { GENERATED_SETUP_CODE } from './index.js';
|
|
3
|
+
export function resolvedGeneratedGlobalSetup(ctx) {
|
|
4
4
|
if (ctx.config.setupCode) {
|
|
5
5
|
return [
|
|
6
6
|
// Import
|
|
@@ -20,4 +20,4 @@ export const resolvedGeneratedGlobalSetup = (ctx) => {
|
|
|
20
20
|
else {
|
|
21
21
|
return '';
|
|
22
22
|
}
|
|
23
|
-
}
|
|
23
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Context } from '../context.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function resolvedGeneratedSetupCode(ctx: Context, id: string): any;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Context } from '../context.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function resolvedMarkdownFiles(ctx: Context): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getInjectedImport } from '../util/vendors.js';
|
|
2
|
-
export
|
|
2
|
+
export function resolvedMarkdownFiles(ctx) {
|
|
3
3
|
const filesJs = ctx.markdownFiles.map(f => `${JSON.stringify(f.relativePath)}: () => import(${JSON.stringify(`virtual:md:${f.id}`)})`).join(',');
|
|
4
4
|
return `import { reactive } from ${process.env.HISTOIRE_DEV ? `'vue'` : getInjectedImport('@histoire/vendors/vue')}
|
|
5
5
|
export const markdownFiles = reactive({${filesJs}})
|
|
@@ -14,4 +14,4 @@ if (import.meta.hot) {
|
|
|
14
14
|
Object.assign(markdownFiles, newModule.markdownFiles)
|
|
15
15
|
})
|
|
16
16
|
}`;
|
|
17
|
-
}
|
|
17
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Context } from '../context.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function resolvedStories(ctx: Context): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { makeTree } from '../tree.js';
|
|
2
|
-
export
|
|
2
|
+
export function resolvedStories(ctx) {
|
|
3
3
|
const resolvedStories = ctx.storyFiles.filter(s => !!s.story);
|
|
4
4
|
const files = resolvedStories.map((file, index) => {
|
|
5
5
|
return {
|
|
@@ -23,7 +23,7 @@ ${resolvedStories.map((file, index) => {
|
|
|
23
23
|
}
|
|
24
24
|
return supportPlugin.importStoryComponent(file, index);
|
|
25
25
|
}).filter(Boolean).join('\n')}
|
|
26
|
-
export let files = [${files.map(
|
|
26
|
+
export let files = [${files.map(file => `{${JSON.stringify(file).slice(1, -1)}, component: Comp${file.index}, source: () => import('virtual:story-source:${file.story.id}')}`).join(',\n')}]
|
|
27
27
|
export let tree = ${JSON.stringify(makeTree(ctx.config, resolvedStories))}
|
|
28
28
|
const handlers = []
|
|
29
29
|
export function onUpdate (cb) {
|
|
@@ -39,4 +39,4 @@ if (import.meta.hot) {
|
|
|
39
39
|
})
|
|
40
40
|
})
|
|
41
41
|
}`;
|
|
42
|
-
}
|
|
42
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Context } from '../context.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function resolvedSupportPluginsClient(ctx: Context): string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import { PLUGINS_HAVE_DEV } from './util.js';
|
|
3
3
|
const require = createRequire(import.meta.url);
|
|
4
|
-
export
|
|
4
|
+
export function resolvedSupportPluginsClient(ctx) {
|
|
5
5
|
const plugins = ctx.supportPlugins.map(p => `'${p.id}': () => import(${JSON.stringify(require.resolve(`${p.moduleName}/client${process.env.HISTOIRE_DEV && PLUGINS_HAVE_DEV.includes(p.moduleName) ? '-dev' : ''}`, {
|
|
6
6
|
paths: [ctx.root, import.meta.url],
|
|
7
7
|
}))})`);
|
|
8
8
|
return `export const clientSupportPlugins = {
|
|
9
9
|
${plugins.join(',\n ')}
|
|
10
10
|
}`;
|
|
11
|
-
}
|
|
11
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Context } from '../context.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function resolvedSupportPluginsCollect(ctx: Context): string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import { PLUGINS_HAVE_DEV } from './util.js';
|
|
3
3
|
const require = createRequire(import.meta.url);
|
|
4
|
-
export
|
|
4
|
+
export function resolvedSupportPluginsCollect(ctx) {
|
|
5
5
|
const plugins = ctx.supportPlugins.map(p => `'${p.id}': () => import(${JSON.stringify(require.resolve(`${p.moduleName}/collect${process.env.HISTOIRE_DEV && PLUGINS_HAVE_DEV.includes(p.moduleName) ? '-dev' : ''}`, {
|
|
6
6
|
paths: [ctx.root, import.meta.url],
|
|
7
7
|
}))})`);
|
|
8
8
|
return `export const collectSupportPlugins = {
|
|
9
9
|
${plugins.join(',\n ')}
|
|
10
10
|
}`;
|
|
11
|
-
}
|
|
11
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Context } from '../context.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function resolvedTheme(ctx: Context): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseColor } from '../colors.js';
|
|
2
|
-
export
|
|
2
|
+
export function resolvedTheme(ctx) {
|
|
3
3
|
let css = '*, ::before, ::after {';
|
|
4
4
|
// Colors
|
|
5
5
|
for (const color in ctx.config.theme?.colors ?? {}) {
|
|
@@ -9,4 +9,4 @@ export const resolvedTheme = (ctx) => {
|
|
|
9
9
|
}
|
|
10
10
|
css += '}';
|
|
11
11
|
return css;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Context } from '../context.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function storySource(ctx: Context, id: string): Promise<string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import { resolve } from 'pathe';
|
|
3
|
-
export
|
|
3
|
+
export async function storySource(ctx, id) {
|
|
4
4
|
const storyId = id.slice('/__resolved__virtual:story-source:'.length);
|
|
5
5
|
const storyFile = ctx.storyFiles.find(f => f.story?.id === storyId);
|
|
6
6
|
if (storyFile) {
|
|
@@ -13,4 +13,4 @@ export const storySource = async (ctx, id) => {
|
|
|
13
13
|
}
|
|
14
14
|
return `export default ${JSON.stringify(source)}`;
|
|
15
15
|
}
|
|
16
|
-
}
|
|
16
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Context } from '../context.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function story(ctx: Context, id: string): string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Plugin as VitePlugin } from 'vite';
|
|
2
2
|
import type { Context } from '../context.js';
|
|
3
|
-
export declare
|
|
3
|
+
export declare function createVirtualFilesPlugin(ctx: Context, isServer: boolean): VitePlugin<any>;
|
|
@@ -1,124 +1,126 @@
|
|
|
1
1
|
import { resolve } from 'pathe';
|
|
2
|
-
import * as VirtualFiles from './index.js';
|
|
3
|
-
import { ID_SEPARATOR } from './util.js';
|
|
4
2
|
import { generateDocSearchData, generateTitleSearchData, getSearchDataJS } from '../search.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
3
|
+
import { ID_SEPARATOR } from './util.js';
|
|
4
|
+
import * as VirtualFiles from './index.js';
|
|
5
|
+
export function createVirtualFilesPlugin(ctx, isServer) {
|
|
6
|
+
return {
|
|
7
|
+
name: 'histoire-virtual-files',
|
|
8
|
+
async resolveId(id, importer) {
|
|
9
|
+
if (id.startsWith(VirtualFiles.STORIES_ID)) {
|
|
10
|
+
return VirtualFiles.RESOLVED_STORIES_ID;
|
|
11
|
+
}
|
|
12
|
+
if (id.startsWith(VirtualFiles.SETUP_ID)) {
|
|
13
|
+
const setupFileConfig = ctx.config.setupFile;
|
|
14
|
+
if (setupFileConfig) {
|
|
15
|
+
let file;
|
|
16
|
+
if (typeof setupFileConfig === 'string') {
|
|
17
|
+
file = setupFileConfig;
|
|
18
|
+
}
|
|
19
|
+
else if (isServer && 'server' in setupFileConfig) {
|
|
20
|
+
file = setupFileConfig.server;
|
|
21
|
+
}
|
|
22
|
+
else if (!isServer && 'browser' in setupFileConfig) {
|
|
23
|
+
file = setupFileConfig.browser;
|
|
24
|
+
}
|
|
25
|
+
if (file) {
|
|
26
|
+
return this.resolve(resolve(ctx.root, file), importer, {
|
|
27
|
+
skipSelf: true,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
28
30
|
}
|
|
31
|
+
return VirtualFiles.NOOP_ID;
|
|
32
|
+
}
|
|
33
|
+
if (id.startsWith(VirtualFiles.CONFIG_ID)) {
|
|
34
|
+
return VirtualFiles.RESOLVED_CONFIG_ID;
|
|
35
|
+
}
|
|
36
|
+
if (id.startsWith(VirtualFiles.THEME_ID)) {
|
|
37
|
+
return VirtualFiles.RESOLVED_THEME_ID;
|
|
38
|
+
}
|
|
39
|
+
if (id.startsWith(VirtualFiles.SEARCH_TITLE_DATA_ID)) {
|
|
40
|
+
return VirtualFiles.RESOLVED_SEARCH_TITLE_DATA_ID;
|
|
41
|
+
}
|
|
42
|
+
if (id.startsWith(VirtualFiles.SEARCH_DOCS_DATA_ID)) {
|
|
43
|
+
return VirtualFiles.RESOLVED_SEARCH_DOCS_DATA_ID;
|
|
44
|
+
}
|
|
45
|
+
if (id.startsWith(VirtualFiles.GENERATED_GLOBAL_SETUP)) {
|
|
46
|
+
return VirtualFiles.RESOLVED_GENERATED_GLOBAL_SETUP;
|
|
47
|
+
}
|
|
48
|
+
if (id.startsWith(VirtualFiles.GENERATED_SETUP_CODE)) {
|
|
49
|
+
const [, index] = id.split(ID_SEPARATOR);
|
|
50
|
+
return `${VirtualFiles.RESOLVED_GENERATED_SETUP_CODE}${ID_SEPARATOR}${index}`;
|
|
51
|
+
}
|
|
52
|
+
if (id.startsWith(VirtualFiles.SUPPORT_PLUGINS_CLIENT)) {
|
|
53
|
+
return VirtualFiles.RESOLVED_SUPPORT_PLUGINS_CLIENT;
|
|
54
|
+
}
|
|
55
|
+
if (id.startsWith(VirtualFiles.SUPPORT_PLUGINS_COLLECT)) {
|
|
56
|
+
return VirtualFiles.RESOLVED_SUPPORT_PLUGINS_COLLECT;
|
|
57
|
+
}
|
|
58
|
+
if (id.startsWith(VirtualFiles.MARKDOWN_FILES)) {
|
|
59
|
+
return VirtualFiles.RESOLVED_MARKDOWN_FILES;
|
|
60
|
+
}
|
|
61
|
+
if (id.startsWith(VirtualFiles.COMMANDS)) {
|
|
62
|
+
return VirtualFiles.RESOLVED_COMMANDS;
|
|
63
|
+
}
|
|
64
|
+
if (id.startsWith('virtual:story:')) {
|
|
65
|
+
return `\0${id}`;
|
|
66
|
+
}
|
|
67
|
+
if (id.startsWith('virtual:story-source:')) {
|
|
68
|
+
return `/__resolved__${id}`;
|
|
69
|
+
// @TODO
|
|
70
|
+
// return `\0${id}`
|
|
71
|
+
}
|
|
72
|
+
if (id.startsWith('virtual:md:')) {
|
|
73
|
+
return `/__resolved__${id}`;
|
|
74
|
+
// @TODO
|
|
75
|
+
// return `\0${id}`
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
async load(id) {
|
|
79
|
+
if (id === VirtualFiles.RESOLVED_STORIES_ID) {
|
|
80
|
+
return VirtualFiles.resolvedStories(ctx);
|
|
81
|
+
}
|
|
82
|
+
if (id === VirtualFiles.NOOP_ID) {
|
|
83
|
+
return VirtualFiles.noop();
|
|
84
|
+
}
|
|
85
|
+
if (id === VirtualFiles.RESOLVED_CONFIG_ID) {
|
|
86
|
+
return VirtualFiles.resolvedConfig(ctx);
|
|
87
|
+
}
|
|
88
|
+
if (id === VirtualFiles.RESOLVED_THEME_ID) {
|
|
89
|
+
return VirtualFiles.resolvedTheme(ctx);
|
|
90
|
+
}
|
|
91
|
+
if (id === VirtualFiles.RESOLVED_SEARCH_TITLE_DATA_ID) {
|
|
92
|
+
return getSearchDataJS(await generateTitleSearchData(ctx));
|
|
93
|
+
}
|
|
94
|
+
if (id === VirtualFiles.RESOLVED_SEARCH_DOCS_DATA_ID) {
|
|
95
|
+
return getSearchDataJS(await generateDocSearchData(ctx));
|
|
96
|
+
}
|
|
97
|
+
if (id === VirtualFiles.RESOLVED_GENERATED_GLOBAL_SETUP) {
|
|
98
|
+
return VirtualFiles.resolvedGeneratedGlobalSetup(ctx);
|
|
99
|
+
}
|
|
100
|
+
if (id.startsWith(VirtualFiles.RESOLVED_GENERATED_SETUP_CODE)) {
|
|
101
|
+
return VirtualFiles.resolvedGeneratedSetupCode(ctx, id);
|
|
102
|
+
}
|
|
103
|
+
if (id === VirtualFiles.RESOLVED_SUPPORT_PLUGINS_CLIENT) {
|
|
104
|
+
return VirtualFiles.resolvedSupportPluginsClient(ctx);
|
|
105
|
+
}
|
|
106
|
+
if (id === VirtualFiles.RESOLVED_SUPPORT_PLUGINS_COLLECT) {
|
|
107
|
+
return VirtualFiles.resolvedSupportPluginsCollect(ctx);
|
|
108
|
+
}
|
|
109
|
+
if (id === VirtualFiles.RESOLVED_MARKDOWN_FILES) {
|
|
110
|
+
return VirtualFiles.resolvedMarkdownFiles(ctx);
|
|
111
|
+
}
|
|
112
|
+
if (id === VirtualFiles.RESOLVED_COMMANDS) {
|
|
113
|
+
return VirtualFiles.resolvedCommands(ctx);
|
|
114
|
+
}
|
|
115
|
+
if (id.startsWith('\0virtual:story:')) {
|
|
116
|
+
return VirtualFiles.story(ctx, id);
|
|
117
|
+
}
|
|
118
|
+
if (id.startsWith('/__resolved__virtual:story-source:')) {
|
|
119
|
+
return VirtualFiles.storySource(ctx, id);
|
|
120
|
+
}
|
|
121
|
+
if (id.startsWith('/__resolved__virtual:md:')) {
|
|
122
|
+
return VirtualFiles.markdown(ctx, id);
|
|
29
123
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return VirtualFiles.RESOLVED_CONFIG_ID;
|
|
34
|
-
}
|
|
35
|
-
if (id.startsWith(VirtualFiles.THEME_ID)) {
|
|
36
|
-
return VirtualFiles.RESOLVED_THEME_ID;
|
|
37
|
-
}
|
|
38
|
-
if (id.startsWith(VirtualFiles.SEARCH_TITLE_DATA_ID)) {
|
|
39
|
-
return VirtualFiles.RESOLVED_SEARCH_TITLE_DATA_ID;
|
|
40
|
-
}
|
|
41
|
-
if (id.startsWith(VirtualFiles.SEARCH_DOCS_DATA_ID)) {
|
|
42
|
-
return VirtualFiles.RESOLVED_SEARCH_DOCS_DATA_ID;
|
|
43
|
-
}
|
|
44
|
-
if (id.startsWith(VirtualFiles.GENERATED_GLOBAL_SETUP)) {
|
|
45
|
-
return VirtualFiles.RESOLVED_GENERATED_GLOBAL_SETUP;
|
|
46
|
-
}
|
|
47
|
-
if (id.startsWith(VirtualFiles.GENERATED_SETUP_CODE)) {
|
|
48
|
-
const [, index] = id.split(ID_SEPARATOR);
|
|
49
|
-
return `${VirtualFiles.RESOLVED_GENERATED_SETUP_CODE}${ID_SEPARATOR}${index}`;
|
|
50
|
-
}
|
|
51
|
-
if (id.startsWith(VirtualFiles.SUPPORT_PLUGINS_CLIENT)) {
|
|
52
|
-
return VirtualFiles.RESOLVED_SUPPORT_PLUGINS_CLIENT;
|
|
53
|
-
}
|
|
54
|
-
if (id.startsWith(VirtualFiles.SUPPORT_PLUGINS_COLLECT)) {
|
|
55
|
-
return VirtualFiles.RESOLVED_SUPPORT_PLUGINS_COLLECT;
|
|
56
|
-
}
|
|
57
|
-
if (id.startsWith(VirtualFiles.MARKDOWN_FILES)) {
|
|
58
|
-
return VirtualFiles.RESOLVED_MARKDOWN_FILES;
|
|
59
|
-
}
|
|
60
|
-
if (id.startsWith(VirtualFiles.COMMANDS)) {
|
|
61
|
-
return VirtualFiles.RESOLVED_COMMANDS;
|
|
62
|
-
}
|
|
63
|
-
if (id.startsWith('virtual:story:')) {
|
|
64
|
-
return `\0${id}`;
|
|
65
|
-
}
|
|
66
|
-
if (id.startsWith('virtual:story-source:')) {
|
|
67
|
-
return `/__resolved__${id}`;
|
|
68
|
-
// @TODO
|
|
69
|
-
// return `\0${id}`
|
|
70
|
-
}
|
|
71
|
-
if (id.startsWith('virtual:md:')) {
|
|
72
|
-
return `/__resolved__${id}`;
|
|
73
|
-
// @TODO
|
|
74
|
-
// return `\0${id}`
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
async load(id) {
|
|
78
|
-
if (id === VirtualFiles.RESOLVED_STORIES_ID) {
|
|
79
|
-
return VirtualFiles.resolvedStories(ctx);
|
|
80
|
-
}
|
|
81
|
-
if (id === VirtualFiles.NOOP_ID) {
|
|
82
|
-
return VirtualFiles.noop();
|
|
83
|
-
}
|
|
84
|
-
if (id === VirtualFiles.RESOLVED_CONFIG_ID) {
|
|
85
|
-
return VirtualFiles.resolvedConfig(ctx);
|
|
86
|
-
}
|
|
87
|
-
if (id === VirtualFiles.RESOLVED_THEME_ID) {
|
|
88
|
-
return VirtualFiles.resolvedTheme(ctx);
|
|
89
|
-
}
|
|
90
|
-
if (id === VirtualFiles.RESOLVED_SEARCH_TITLE_DATA_ID) {
|
|
91
|
-
return getSearchDataJS(await generateTitleSearchData(ctx));
|
|
92
|
-
}
|
|
93
|
-
if (id === VirtualFiles.RESOLVED_SEARCH_DOCS_DATA_ID) {
|
|
94
|
-
return getSearchDataJS(await generateDocSearchData(ctx));
|
|
95
|
-
}
|
|
96
|
-
if (id === VirtualFiles.RESOLVED_GENERATED_GLOBAL_SETUP) {
|
|
97
|
-
return VirtualFiles.resolvedGeneratedGlobalSetup(ctx);
|
|
98
|
-
}
|
|
99
|
-
if (id.startsWith(VirtualFiles.RESOLVED_GENERATED_SETUP_CODE)) {
|
|
100
|
-
return VirtualFiles.resolvedGeneratedSetupCode(ctx, id);
|
|
101
|
-
}
|
|
102
|
-
if (id === VirtualFiles.RESOLVED_SUPPORT_PLUGINS_CLIENT) {
|
|
103
|
-
return VirtualFiles.resolvedSupportPluginsClient(ctx);
|
|
104
|
-
}
|
|
105
|
-
if (id === VirtualFiles.RESOLVED_SUPPORT_PLUGINS_COLLECT) {
|
|
106
|
-
return VirtualFiles.resolvedSupportPluginsCollect(ctx);
|
|
107
|
-
}
|
|
108
|
-
if (id === VirtualFiles.RESOLVED_MARKDOWN_FILES) {
|
|
109
|
-
return VirtualFiles.resolvedMarkdownFiles(ctx);
|
|
110
|
-
}
|
|
111
|
-
if (id === VirtualFiles.RESOLVED_COMMANDS) {
|
|
112
|
-
return VirtualFiles.resolvedCommands(ctx);
|
|
113
|
-
}
|
|
114
|
-
if (id.startsWith('\0virtual:story:')) {
|
|
115
|
-
return VirtualFiles.story(ctx, id);
|
|
116
|
-
}
|
|
117
|
-
if (id.startsWith('/__resolved__virtual:story-source:')) {
|
|
118
|
-
return VirtualFiles.storySource(ctx, id);
|
|
119
|
-
}
|
|
120
|
-
if (id.startsWith('/__resolved__virtual:md:')) {
|
|
121
|
-
return VirtualFiles.markdown(ctx, id);
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
});
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
package/dist/node/vite.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InlineConfig } from 'vite';
|
|
2
|
-
import { Context } from './context.js';
|
|
1
|
+
import type { InlineConfig } from 'vite';
|
|
2
|
+
import type { Context } from './context.js';
|
|
3
3
|
export declare function mergeHistoireViteConfig(viteConfig: InlineConfig, ctx: Context): Promise<InlineConfig>;
|
|
4
4
|
export interface ViteConfigWithPlugins {
|
|
5
5
|
viteConfig: InlineConfig;
|
package/dist/node/vite.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { dirname, join, relative } from 'pathe';
|
|
3
|
+
import { loadConfigFromFile as loadViteConfigFromFile, mergeConfig as mergeViteConfig, } from 'vite';
|
|
4
4
|
import { lookup as lookupMime } from 'mrmime';
|
|
5
5
|
import { APP_PATH, TEMP_PATH } from './alias.js';
|
|
6
6
|
import { notifyStoryChange } from './stories.js';
|
|
@@ -113,7 +113,7 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
113
113
|
},
|
|
114
114
|
define: {
|
|
115
115
|
// We need to force this to be able to use `devtoolsRawSetupState`
|
|
116
|
-
__VUE_PROD_DEVTOOLS__: 'true',
|
|
116
|
+
'__VUE_PROD_DEVTOOLS__': 'true',
|
|
117
117
|
// Disable warnings
|
|
118
118
|
'process.env.NODE_ENV': JSON.stringify(isServer ? 'production' : process.env.NODE_ENV ?? 'development'),
|
|
119
119
|
...!isServer
|
|
@@ -122,13 +122,12 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
122
122
|
'process.env.HST_COLLECT': 'false',
|
|
123
123
|
}
|
|
124
124
|
: {},
|
|
125
|
-
__HST_COLLECT__: isServer,
|
|
125
|
+
'__HST_COLLECT__': isServer,
|
|
126
126
|
},
|
|
127
127
|
cacheDir: isServer ? 'node_modules/.hst-vite-server' : 'node_modules/.hst-vite',
|
|
128
128
|
};
|
|
129
129
|
},
|
|
130
130
|
options() {
|
|
131
|
-
// @ts-ignore
|
|
132
131
|
this.meta.histoire = {
|
|
133
132
|
isCollecting: isServer,
|
|
134
133
|
};
|
|
@@ -219,7 +218,7 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
219
218
|
// Replace dev flag
|
|
220
219
|
const flags = {
|
|
221
220
|
'_ctx.__HISTOIRE_DEV__': JSON.stringify(ctx.mode === 'dev'),
|
|
222
|
-
__HISTOIRE_DEV__: JSON.stringify(ctx.mode === 'dev'),
|
|
221
|
+
'__HISTOIRE_DEV__': JSON.stringify(ctx.mode === 'dev'),
|
|
223
222
|
};
|
|
224
223
|
plugins.push({
|
|
225
224
|
name: 'histoire:flags',
|
|
@@ -230,9 +229,8 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
230
229
|
for (const flag in flags) {
|
|
231
230
|
code = code.replace(new RegExp(flag, 'g'), flags[flag]);
|
|
232
231
|
}
|
|
233
|
-
if (original !== code)
|
|
232
|
+
if (original !== code)
|
|
234
233
|
return code;
|
|
235
|
-
}
|
|
236
234
|
}
|
|
237
235
|
},
|
|
238
236
|
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "histoire",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.17.17",
|
|
4
5
|
"description": "A fast story book powered by Vite",
|
|
5
|
-
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Guillaume Chau"
|
|
8
8
|
},
|
|
9
|
+
"license": "MIT",
|
|
9
10
|
"repository": {
|
|
10
11
|
"url": "https://github.com/Akryum/histoire.git",
|
|
11
12
|
"type": "git",
|
|
@@ -14,7 +15,6 @@
|
|
|
14
15
|
"publishConfig": {
|
|
15
16
|
"access": "public"
|
|
16
17
|
},
|
|
17
|
-
"type": "module",
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
20
|
"types": "./dist/node/index.d.ts",
|
|
@@ -36,6 +36,9 @@
|
|
|
36
36
|
"bin": {
|
|
37
37
|
"histoire": "./bin.mjs"
|
|
38
38
|
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"vite": "^2.9.0 || ^3.0.0 || ^4.0.0 || ^5.0.0"
|
|
41
|
+
},
|
|
39
42
|
"dependencies": {
|
|
40
43
|
"@akryum/tinypool": "^0.3.1",
|
|
41
44
|
"@types/flexsearch": "^0.7.6",
|
|
@@ -64,13 +67,10 @@
|
|
|
64
67
|
"shiki-es": "^0.2.0",
|
|
65
68
|
"sirv": "^2.0.3",
|
|
66
69
|
"vite-node": "^0.34.6",
|
|
67
|
-
"@histoire/app": "^0.17.
|
|
68
|
-
"@histoire/controls": "^0.17.
|
|
69
|
-
"@histoire/shared": "^0.17.
|
|
70
|
-
"@histoire/vendors": "^0.17.
|
|
71
|
-
},
|
|
72
|
-
"peerDependencies": {
|
|
73
|
-
"vite": "^2.9.0 || ^3.0.0 || ^4.0.0 || ^5.0.0"
|
|
70
|
+
"@histoire/app": "^0.17.17",
|
|
71
|
+
"@histoire/controls": "^0.17.17",
|
|
72
|
+
"@histoire/shared": "^0.17.17",
|
|
73
|
+
"@histoire/vendors": "^0.17.17"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/fs-extra": "^9.0.13",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@types/node": "^18.11.9",
|
|
80
80
|
"esbuild": "^0.18.20",
|
|
81
81
|
"rollup": "^4.8.0",
|
|
82
|
-
"typescript": "^4.
|
|
82
|
+
"typescript": "^5.4.4",
|
|
83
83
|
"vite": "^5.0.11",
|
|
84
84
|
"vitest": "^0.34.6"
|
|
85
85
|
},
|
package/plugin.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function sendEvent
|
|
1
|
+
export function sendEvent(event: string, payload?: any): Promise<any>
|
|
2
2
|
|
|
3
|
-
export function openStory
|
|
3
|
+
export function openStory(storyId: string): void
|
package/plugin.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export function sendEvent
|
|
1
|
+
export function sendEvent(event, payload) {
|
|
2
2
|
if (window.__HST_PLUGIN_API__) {
|
|
3
3
|
return window.__HST_PLUGIN_API__.sendEvent(event, payload)
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export function openStory
|
|
7
|
+
export function openStory(storyId) {
|
|
8
8
|
if (window.__HST_PLUGIN_API__) {
|
|
9
9
|
return window.__HST_PLUGIN_API__.openStory(storyId)
|
|
10
10
|
}
|