poveste 0.1.0 → 0.1.2
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/node/alias.d.ts.map +1 -1
- package/dist/node/alias.js +2 -2
- package/dist/node/bin.js +1 -1
- package/dist/node/build.js +4 -4
- package/dist/node/builtin-plugins/pinceau-tokens.js +1 -1
- package/dist/node/builtin-plugins/tailwind-tokens.js +1 -1
- package/dist/node/builtin-plugins/vanilla-support/RenderStory.js +2 -2
- package/dist/node/collect/index.d.ts.map +1 -1
- package/dist/node/collect/index.js +10 -4
- package/dist/node/collect/run.js +1 -1
- package/dist/node/config.js +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/markdown.js +2 -2
- package/dist/node/server.js +4 -4
- package/dist/node/tree.js +1 -1
- package/dist/node/virtual/index.d.ts +24 -24
- package/dist/node/virtual/index.d.ts.map +1 -1
- package/dist/node/virtual/index.js +13 -13
- package/dist/node/virtual/resolved-markdown-files.js +1 -1
- package/dist/node/virtual/resolved-support-plugins-client.js +1 -1
- package/dist/node/virtual/resolved-support-plugins-collect.js +1 -1
- package/dist/node/virtual/resolved-theme.js +1 -1
- package/dist/node/virtual/vite-plugin.js +1 -1
- package/dist/node/vite.js +17 -17
- package/package.json +5 -5
- package/src/node/alias.ts +2 -2
- package/src/node/bin.ts +1 -1
- package/src/node/build.ts +4 -4
- package/src/node/builtin-plugins/pinceau-tokens.ts +1 -1
- package/src/node/builtin-plugins/tailwind-tokens.ts +1 -1
- package/src/node/builtin-plugins/vanilla-support/RenderStory.ts +2 -2
- package/src/node/collect/index.ts +10 -4
- package/src/node/collect/run.ts +1 -1
- package/src/node/config.ts +1 -1
- package/src/node/index.ts +1 -1
- package/src/node/markdown.ts +2 -2
- package/src/node/server.ts +4 -4
- package/src/node/tree.ts +1 -1
- package/src/node/virtual/index.ts +13 -13
- package/src/node/virtual/resolved-markdown-files.ts +1 -1
- 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/vite-plugin.ts +1 -1
- package/src/node/vite.ts +17 -17
package/dist/node/alias.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alias.d.ts","sourceRoot":"","sources":["../../src/node/alias.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"alias.d.ts","sourceRoot":"","sources":["../../src/node/alias.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,QAAQ,QAAkH,CAAA;AAEvI,eAAO,MAAM,SAAS,QAAuD,CAAA"}
|
package/dist/node/alias.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import path from 'pathe';
|
|
3
3
|
const require = createRequire(import.meta.url);
|
|
4
|
-
export const APP_PATH = path.join(path.dirname(require.resolve('@poveste/app/package.json')), process.env.
|
|
5
|
-
export const TEMP_PATH = path.join(process.cwd(), 'node_modules', '.
|
|
4
|
+
export const APP_PATH = path.join(path.dirname(require.resolve('@poveste/app/package.json')), process.env.POVESTE_DEV ? 'src' : 'dist');
|
|
5
|
+
export const TEMP_PATH = path.join(process.cwd(), 'node_modules', '.poveste');
|
package/dist/node/bin.js
CHANGED
|
@@ -19,7 +19,7 @@ program.command('dev')
|
|
|
19
19
|
return devCommand(options);
|
|
20
20
|
});
|
|
21
21
|
program.command('build')
|
|
22
|
-
.describe('build the
|
|
22
|
+
.describe('build the poveste final app you can deploy')
|
|
23
23
|
.option('-c, --config <file>', `[string] use specified config file`)
|
|
24
24
|
.action(async (options) => {
|
|
25
25
|
const { buildCommand } = await import('./commands/build.js');
|
package/dist/node/build.js
CHANGED
|
@@ -72,7 +72,7 @@ export async function build(ctx) {
|
|
|
72
72
|
],
|
|
73
73
|
plugins: [
|
|
74
74
|
{
|
|
75
|
-
name: '
|
|
75
|
+
name: 'poveste-build-rollup-options-override',
|
|
76
76
|
enforce: 'post',
|
|
77
77
|
options(options) {
|
|
78
78
|
// Don't externalize
|
|
@@ -88,7 +88,7 @@ export async function build(ctx) {
|
|
|
88
88
|
// (so that we no longer need defineExpose)
|
|
89
89
|
// Nuxt: replaces the Nuxt vite dev server
|
|
90
90
|
buildViteConfig.plugins.push({
|
|
91
|
-
name: '
|
|
91
|
+
name: 'poveste-vue-plugin-override',
|
|
92
92
|
config(config) {
|
|
93
93
|
const vuePlugin = config.plugins.find((p) => p.name === 'vite:vue');
|
|
94
94
|
if (vuePlugin) {
|
|
@@ -112,7 +112,7 @@ export async function build(ctx) {
|
|
|
112
112
|
},
|
|
113
113
|
});
|
|
114
114
|
buildViteConfig.plugins.push({
|
|
115
|
-
name: '
|
|
115
|
+
name: 'poveste-build-config-override',
|
|
116
116
|
enforce: 'post',
|
|
117
117
|
config(config) {
|
|
118
118
|
// Don't externalize
|
|
@@ -166,7 +166,7 @@ export async function build(ctx) {
|
|
|
166
166
|
const sandboxOutput = result.output.find(o => o.name === 'bundle-sandbox' && o.type === 'chunk');
|
|
167
167
|
const sandboxHtml = generateEntryHtml(sandboxOutput.fileName, styleOutput.fileName, {}, ctx);
|
|
168
168
|
await writeFile('__sandbox.html', sandboxHtml, ctx);
|
|
169
|
-
await writeFile('
|
|
169
|
+
await writeFile('poveste.json', JSON.stringify(getSerializedStoryData(ctx), null, 2), ctx);
|
|
170
170
|
const duration = performance.now() - startTime;
|
|
171
171
|
if (emptyStoryCount) {
|
|
172
172
|
console.warn(pc.yellow(`⚠️ ${emptyStoryCount} empty story file${emptyStoryCount === 1 ? '' : 's'}`));
|
|
@@ -56,7 +56,7 @@ export function pinceauTokens(_options = {}) {
|
|
|
56
56
|
}
|
|
57
57
|
function storyTemplate(pinceauConfig) {
|
|
58
58
|
pinceauConfig = pinceauConfig?.theme || pinceauConfig?.default?.theme || {};
|
|
59
|
-
return `import '
|
|
59
|
+
return `import 'poveste-style'
|
|
60
60
|
import './style.css'
|
|
61
61
|
import { createApp, h, markRaw, ref } from ${getInjectedImport('@poveste/vendors/vue')}
|
|
62
62
|
import {
|
|
@@ -73,7 +73,7 @@ export function tailwindTokens(options = {}) {
|
|
|
73
73
|
}
|
|
74
74
|
function storyTemplate(tailwindConfig) {
|
|
75
75
|
return `
|
|
76
|
-
import '
|
|
76
|
+
import 'poveste-style'
|
|
77
77
|
import './style.css'
|
|
78
78
|
import { createApp, h, markRaw, ref } from ${getInjectedImport('@poveste/vendors/vue')}
|
|
79
79
|
import {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineComponent as _defineComponent, h as _h, onBeforeUnmount as _onBeforeUnmount, onMounted as _onMounted, ref as _ref, watch as _watch, } from '@poveste/vendors/vue';
|
|
2
2
|
// @ts-expect-error virtual module id
|
|
3
|
-
import * as generatedSetup from 'virtual:$
|
|
3
|
+
import * as generatedSetup from 'virtual:$poveste-generated-global-setup';
|
|
4
4
|
// @ts-expect-error virtual module id
|
|
5
|
-
import * as setup from 'virtual:$
|
|
5
|
+
import * as setup from 'virtual:$poveste-setup';
|
|
6
6
|
export default _defineComponent({
|
|
7
7
|
name: 'RenderStory',
|
|
8
8
|
props: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/collect/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAa5C,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,aAAa,CAAA;IACrB,UAAU,CAAC,EAAE,aAAa,CAAA;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,EAAE,GAAG,EAAE,OAAO;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/collect/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAa5C,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,aAAa,CAAA;IACrB,UAAU,CAAC,EAAE,aAAa,CAAA;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,EAAE,GAAG,EAAE,OAAO;;kCAgFpC,eAAe;;EA+D3D"}
|
|
@@ -13,10 +13,16 @@ export function useCollectStories(options, ctx) {
|
|
|
13
13
|
const node = new ViteNodeServer(server, {
|
|
14
14
|
deps: {
|
|
15
15
|
inline: [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
// Published layout: `poveste` and scoped `@poveste/*` packages. These
|
|
17
|
+
// MUST be inlined so vite-node transforms them and resolves their
|
|
18
|
+
// `virtual:` imports; otherwise they're loaded via native Node ESM,
|
|
19
|
+
// which throws ERR_UNSUPPORTED_ESM_URL_SCHEME on `virtual:` and breaks
|
|
20
|
+
// story collection for any fresh npm install.
|
|
21
|
+
/\/poveste\/dist/,
|
|
22
|
+
/\/poveste\/client/,
|
|
23
|
+
/@poveste\/[\w-]+\/dist/,
|
|
24
|
+
// Workspace layout: packages/poveste-<name>/dist (dev / monorepo).
|
|
25
|
+
/poveste-[\w-]+\/dist/,
|
|
20
26
|
/@vue\/devtools-api/,
|
|
21
27
|
/vuetify/,
|
|
22
28
|
// @TODO temporary fix for https://github.com/histoire-dev/histoire/issues/409
|
package/dist/node/collect/run.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-expect-error virtual module
|
|
2
|
-
import { collectSupportPlugins } from 'virtual:$
|
|
2
|
+
import { collectSupportPlugins } from 'virtual:$poveste-support-plugins-collect';
|
|
3
3
|
export async function run(payload) {
|
|
4
4
|
const { run } = await collectSupportPlugins[payload.file.supportPluginId]();
|
|
5
5
|
const result = await run(payload);
|
package/dist/node/config.js
CHANGED
package/dist/node/index.d.ts
CHANGED
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAE/B,OAAO,QAAQ,QAAQ,CAAC;IACtB,UAAU,iBAAiB;QACzB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAE/B,OAAO,QAAQ,QAAQ,CAAC;IACtB,UAAU,iBAAiB;QACzB,OAAO,EAAE;YACP,YAAY,EAAE,OAAO,CAAA;SACtB,CAAA;KACF;CACF"}
|
package/dist/node/markdown.js
CHANGED
|
@@ -27,7 +27,7 @@ export async function createMarkdownRenderer(ctx) {
|
|
|
27
27
|
langs: Object.keys(bundledLanguages), // not ideal but markdown-it does not provide async highlight
|
|
28
28
|
});
|
|
29
29
|
const md = new MarkdownIt({
|
|
30
|
-
highlight: (code, lang) => `<div class="htw-relative htw-not-prose __histoire-code"><div class="htw-absolute htw-top-0 htw-right-0 htw-text-xs htw-text-white/40">${lang}</div>${highlighter.codeToHtml(code, { theme: 'github-dark', lang })}</div>`,
|
|
30
|
+
highlight: (code, lang) => `<div class="htw-relative htw-not-prose __poveste-code __histoire-code"><div class="htw-absolute htw-top-0 htw-right-0 htw-text-xs htw-text-white/40">${lang}</div>${highlighter.codeToHtml(code, { theme: 'github-dark', lang })}</div>`,
|
|
31
31
|
linkify: true,
|
|
32
32
|
html: true,
|
|
33
33
|
breaks: false,
|
|
@@ -97,7 +97,7 @@ export async function createMarkdownPlugins(ctx) {
|
|
|
97
97
|
const md = await createMarkdownRendererWithPlugins(ctx);
|
|
98
98
|
// @TODO extract
|
|
99
99
|
plugins.push({
|
|
100
|
-
name: '
|
|
100
|
+
name: 'poveste-vue-docs-block',
|
|
101
101
|
transform(code, id) {
|
|
102
102
|
if (!id.includes('?vue&type=docs'))
|
|
103
103
|
return;
|
package/dist/node/server.js
CHANGED
|
@@ -48,13 +48,13 @@ export async function createServer(ctx, options = {}) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
// Custom dev events
|
|
51
|
-
server.ws.on(`
|
|
51
|
+
server.ws.on(`poveste:dev-event`, async ({ event, payload }) => {
|
|
52
52
|
for (const plugin of ctx.config.plugins) {
|
|
53
53
|
if (plugin.onDevEvent) {
|
|
54
54
|
const api = new DevEventPluginApi(ctx, plugin, moduleLoader, event, payload);
|
|
55
55
|
const result = await plugin.onDevEvent(api);
|
|
56
56
|
if (!event.startsWith('on') && result !== undefined) {
|
|
57
|
-
server.ws.send(`
|
|
57
|
+
server.ws.send(`poveste:dev-event-result`, { event, result });
|
|
58
58
|
break;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -142,7 +142,7 @@ export async function createServer(ctx, options = {}) {
|
|
|
142
142
|
const fileCount = ctx.storyFiles.length;
|
|
143
143
|
let loadedFilesCount = 0;
|
|
144
144
|
const sendProgress = () => {
|
|
145
|
-
server.ws.send('
|
|
145
|
+
server.ws.send('poveste:stories-loading-progress', {
|
|
146
146
|
loadedFileCount: loadedFilesCount,
|
|
147
147
|
totalFileCount: fileCount,
|
|
148
148
|
});
|
|
@@ -154,7 +154,7 @@ export async function createServer(ctx, options = {}) {
|
|
|
154
154
|
sendProgress();
|
|
155
155
|
}));
|
|
156
156
|
didAllStoriesYet = true;
|
|
157
|
-
server.ws.send('
|
|
157
|
+
server.ws.send('poveste:all-stories-loaded', {});
|
|
158
158
|
}
|
|
159
159
|
console.log(`Collect stories end ${pc.bold(pc.blue(Math.round(performance.now() - time)))}ms`);
|
|
160
160
|
invalidateModule(VirtualFiles.RESOLVED_STORIES_ID);
|
package/dist/node/tree.js
CHANGED
|
@@ -6,7 +6,7 @@ export function createPath(config, file) {
|
|
|
6
6
|
if (config.tree.file === 'path') {
|
|
7
7
|
const paths = file.path.split('/').slice(0, -1);
|
|
8
8
|
// check if tree file path is a plugin
|
|
9
|
-
const index = paths.findIndex(p => p.includes('.
|
|
9
|
+
const index = paths.findIndex(p => p.includes('.poveste'));
|
|
10
10
|
if (index !== -1) {
|
|
11
11
|
return ['plugins', file.title];
|
|
12
12
|
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
export declare const STORIES_ID = "virtual:$
|
|
2
|
-
export declare const RESOLVED_STORIES_ID = "/__resolved__virtual:$
|
|
3
|
-
export declare const SETUP_ID = "virtual:$
|
|
4
|
-
export declare const NOOP_ID = "virtual:$
|
|
5
|
-
export declare const CONFIG_ID = "virtual:$
|
|
6
|
-
export declare const RESOLVED_CONFIG_ID = "\0virtual:$
|
|
7
|
-
export declare const THEME_ID = "virtual:$
|
|
8
|
-
export declare const RESOLVED_THEME_ID = "\0virtual:$
|
|
9
|
-
export declare const SEARCH_TITLE_DATA_ID = "virtual:$
|
|
10
|
-
export declare const RESOLVED_SEARCH_TITLE_DATA_ID = "\0virtual:$
|
|
11
|
-
export declare const SEARCH_DOCS_DATA_ID = "virtual:$
|
|
12
|
-
export declare const RESOLVED_SEARCH_DOCS_DATA_ID = "\0virtual:$
|
|
13
|
-
export declare const GENERATED_GLOBAL_SETUP = "virtual:$
|
|
14
|
-
export declare const RESOLVED_GENERATED_GLOBAL_SETUP = "\0virtual:$
|
|
15
|
-
export declare const GENERATED_SETUP_CODE = "virtual:$
|
|
16
|
-
export declare const RESOLVED_GENERATED_SETUP_CODE = "\0virtual:$
|
|
17
|
-
export declare const SUPPORT_PLUGINS_CLIENT = "virtual:$
|
|
18
|
-
export declare const RESOLVED_SUPPORT_PLUGINS_CLIENT = "\0virtual:$
|
|
19
|
-
export declare const SUPPORT_PLUGINS_COLLECT = "virtual:$
|
|
20
|
-
export declare const RESOLVED_SUPPORT_PLUGINS_COLLECT = "\0virtual:$
|
|
21
|
-
export declare const MARKDOWN_FILES = "virtual:$
|
|
22
|
-
export declare const RESOLVED_MARKDOWN_FILES = "\0virtual:$
|
|
23
|
-
export declare const COMMANDS = "virtual:$
|
|
24
|
-
export declare const RESOLVED_COMMANDS = "/__resolved__virtual:$
|
|
1
|
+
export declare const STORIES_ID = "virtual:$poveste-stories";
|
|
2
|
+
export declare const RESOLVED_STORIES_ID = "/__resolved__virtual:$poveste-stories";
|
|
3
|
+
export declare const SETUP_ID = "virtual:$poveste-setup";
|
|
4
|
+
export declare const NOOP_ID = "virtual:$poveste-noop";
|
|
5
|
+
export declare const CONFIG_ID = "virtual:$poveste-config";
|
|
6
|
+
export declare const RESOLVED_CONFIG_ID = "\0virtual:$poveste-config";
|
|
7
|
+
export declare const THEME_ID = "virtual:$poveste-theme";
|
|
8
|
+
export declare const RESOLVED_THEME_ID = "\0virtual:$poveste-theme.css";
|
|
9
|
+
export declare const SEARCH_TITLE_DATA_ID = "virtual:$poveste-search-title-data";
|
|
10
|
+
export declare const RESOLVED_SEARCH_TITLE_DATA_ID = "\0virtual:$poveste-search-title-data";
|
|
11
|
+
export declare const SEARCH_DOCS_DATA_ID = "virtual:$poveste-search-docs-data";
|
|
12
|
+
export declare const RESOLVED_SEARCH_DOCS_DATA_ID = "\0virtual:$poveste-search-docs-data";
|
|
13
|
+
export declare const GENERATED_GLOBAL_SETUP = "virtual:$poveste-generated-global-setup";
|
|
14
|
+
export declare const RESOLVED_GENERATED_GLOBAL_SETUP = "\0virtual:$poveste-generated-global-setup";
|
|
15
|
+
export declare const GENERATED_SETUP_CODE = "virtual:$poveste-generated-setup-code";
|
|
16
|
+
export declare const RESOLVED_GENERATED_SETUP_CODE = "\0virtual:$poveste-generated-setup-code";
|
|
17
|
+
export declare const SUPPORT_PLUGINS_CLIENT = "virtual:$poveste-support-plugins-client";
|
|
18
|
+
export declare const RESOLVED_SUPPORT_PLUGINS_CLIENT = "\0virtual:$poveste-support-plugins-client";
|
|
19
|
+
export declare const SUPPORT_PLUGINS_COLLECT = "virtual:$poveste-support-plugins-collect";
|
|
20
|
+
export declare const RESOLVED_SUPPORT_PLUGINS_COLLECT = "\0virtual:$poveste-support-plugins-collect";
|
|
21
|
+
export declare const MARKDOWN_FILES = "virtual:$poveste-markdown-files";
|
|
22
|
+
export declare const RESOLVED_MARKDOWN_FILES = "\0virtual:$poveste-markdown-files";
|
|
23
|
+
export declare const COMMANDS = "virtual:$poveste-commands";
|
|
24
|
+
export declare const RESOLVED_COMMANDS = "/__resolved__virtual:$poveste-commands";
|
|
25
25
|
export * from './markdown.js';
|
|
26
26
|
export * from './noop.js';
|
|
27
27
|
export * from './resolved-commands.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/virtual/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/virtual/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,6BAA6B,CAAA;AACpD,eAAO,MAAM,mBAAmB,0CAA+B,CAAA;AAE/D,eAAO,MAAM,QAAQ,2BAA2B,CAAA;AAChD,eAAO,MAAM,OAAO,0BAA0B,CAAA;AAC9C,eAAO,MAAM,SAAS,4BAA4B,CAAA;AAElD,eAAO,MAAM,kBAAkB,8BAAmB,CAAA;AAClD,eAAO,MAAM,QAAQ,2BAA2B,CAAA;AAEhD,eAAO,MAAM,iBAAiB,iCAAsB,CAAA;AACpD,eAAO,MAAM,oBAAoB,uCAAuC,CAAA;AAExE,eAAO,MAAM,6BAA6B,yCAA8B,CAAA;AACxE,eAAO,MAAM,mBAAmB,sCAAsC,CAAA;AAEtE,eAAO,MAAM,4BAA4B,wCAA6B,CAAA;AACtE,eAAO,MAAM,sBAAsB,4CAA4C,CAAA;AAE/E,eAAO,MAAM,+BAA+B,8CAAgC,CAAA;AAC5E,eAAO,MAAM,oBAAoB,0CAA0C,CAAA;AAE3E,eAAO,MAAM,6BAA6B,4CAA8B,CAAA;AACxE,eAAO,MAAM,sBAAsB,4CAA4C,CAAA;AAE/E,eAAO,MAAM,+BAA+B,8CAAgC,CAAA;AAC5E,eAAO,MAAM,uBAAuB,6CAA6C,CAAA;AAEjF,eAAO,MAAM,gCAAgC,+CAAiC,CAAA;AAC9E,eAAO,MAAM,cAAc,oCAAoC,CAAA;AAE/D,eAAO,MAAM,uBAAuB,sCAAwB,CAAA;AAC5D,eAAO,MAAM,QAAQ,8BAA8B,CAAA;AACnD,eAAO,MAAM,iBAAiB,2CAA6B,CAAA;AAE3D,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sCAAsC,CAAA;AACpD,cAAc,oCAAoC,CAAA;AAClD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,uBAAuB,CAAA;AACrC,cAAc,sCAAsC,CAAA;AACpD,cAAc,uCAAuC,CAAA;AACrD,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA"}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
// @TODO wait for virtual modules HMR to work in vite to use `virtual:` and `\0` prefix
|
|
2
2
|
// https://github.com/vitejs/vite/pull/10313
|
|
3
|
-
export const STORIES_ID = 'virtual:$
|
|
3
|
+
export const STORIES_ID = 'virtual:$poveste-stories';
|
|
4
4
|
export const RESOLVED_STORIES_ID = `/__resolved__${STORIES_ID}`;
|
|
5
5
|
// export const RESOLVED_STORIES_ID = `\0${STORIES_ID}`
|
|
6
|
-
export const SETUP_ID = 'virtual:$
|
|
7
|
-
export const NOOP_ID = 'virtual:$
|
|
8
|
-
export const CONFIG_ID = 'virtual:$
|
|
6
|
+
export const SETUP_ID = 'virtual:$poveste-setup';
|
|
7
|
+
export const NOOP_ID = 'virtual:$poveste-noop';
|
|
8
|
+
export const CONFIG_ID = 'virtual:$poveste-config';
|
|
9
9
|
// export const RESOLVED_CONFIG_ID = `/__resolved__${CONFIG_ID}`
|
|
10
10
|
export const RESOLVED_CONFIG_ID = `\0${CONFIG_ID}`;
|
|
11
|
-
export const THEME_ID = 'virtual:$
|
|
11
|
+
export const THEME_ID = 'virtual:$poveste-theme';
|
|
12
12
|
// export const RESOLVED_THEME_ID = `/__resolved__${THEME_ID}.css`
|
|
13
13
|
export const RESOLVED_THEME_ID = `\0${THEME_ID}.css`;
|
|
14
|
-
export const SEARCH_TITLE_DATA_ID = 'virtual:$
|
|
14
|
+
export const SEARCH_TITLE_DATA_ID = 'virtual:$poveste-search-title-data';
|
|
15
15
|
// export const RESOLVED_SEARCH_TITLE_DATA_ID = `/__resolved__${SEARCH_TITLE_DATA_ID}`
|
|
16
16
|
export const RESOLVED_SEARCH_TITLE_DATA_ID = `\0${SEARCH_TITLE_DATA_ID}`;
|
|
17
|
-
export const SEARCH_DOCS_DATA_ID = 'virtual:$
|
|
17
|
+
export const SEARCH_DOCS_DATA_ID = 'virtual:$poveste-search-docs-data';
|
|
18
18
|
// export const RESOLVED_SEARCH_DOCS_DATA_ID = `/__resolved__${SEARCH_DOCS_DATA_ID}`
|
|
19
19
|
export const RESOLVED_SEARCH_DOCS_DATA_ID = `\0${SEARCH_DOCS_DATA_ID}`;
|
|
20
|
-
export const GENERATED_GLOBAL_SETUP = 'virtual:$
|
|
20
|
+
export const GENERATED_GLOBAL_SETUP = 'virtual:$poveste-generated-global-setup';
|
|
21
21
|
// export const RESOLVED_GENERATED_GLOBAL_SETUP = `/__resolved__${GENERATED_GLOBAL_SETUP}`
|
|
22
22
|
export const RESOLVED_GENERATED_GLOBAL_SETUP = `\0${GENERATED_GLOBAL_SETUP}`;
|
|
23
|
-
export const GENERATED_SETUP_CODE = 'virtual:$
|
|
23
|
+
export const GENERATED_SETUP_CODE = 'virtual:$poveste-generated-setup-code';
|
|
24
24
|
// export const RESOLVED_GENERATED_SETUP_CODE = `/__resolved__${GENERATED_SETUP_CODE}`
|
|
25
25
|
export const RESOLVED_GENERATED_SETUP_CODE = `\0${GENERATED_SETUP_CODE}`;
|
|
26
|
-
export const SUPPORT_PLUGINS_CLIENT = 'virtual:$
|
|
26
|
+
export const SUPPORT_PLUGINS_CLIENT = 'virtual:$poveste-support-plugins-client';
|
|
27
27
|
// export const RESOLVED_SUPPORT_PLUGINS_CLIENT = `/__resolved__${SUPPORT_PLUGINS_CLIENT}`
|
|
28
28
|
export const RESOLVED_SUPPORT_PLUGINS_CLIENT = `\0${SUPPORT_PLUGINS_CLIENT}`;
|
|
29
|
-
export const SUPPORT_PLUGINS_COLLECT = 'virtual:$
|
|
29
|
+
export const SUPPORT_PLUGINS_COLLECT = 'virtual:$poveste-support-plugins-collect';
|
|
30
30
|
// export const RESOLVED_SUPPORT_PLUGINS_COLLECT = `/__resolved__${SUPPORT_PLUGINS_COLLECT}`
|
|
31
31
|
export const RESOLVED_SUPPORT_PLUGINS_COLLECT = `\0${SUPPORT_PLUGINS_COLLECT}`;
|
|
32
|
-
export const MARKDOWN_FILES = 'virtual:$
|
|
32
|
+
export const MARKDOWN_FILES = 'virtual:$poveste-markdown-files';
|
|
33
33
|
// export const RESOLVED_MARKDOWN_FILES = `/__resolved__${MARKDOWN_FILES}`
|
|
34
34
|
export const RESOLVED_MARKDOWN_FILES = `\0${MARKDOWN_FILES}`;
|
|
35
|
-
export const COMMANDS = 'virtual:$
|
|
35
|
+
export const COMMANDS = 'virtual:$poveste-commands';
|
|
36
36
|
export const RESOLVED_COMMANDS = `/__resolved__${COMMANDS}`;
|
|
37
37
|
export * from './markdown.js';
|
|
38
38
|
export * from './noop.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getInjectedImport } from '../util/vendors.js';
|
|
2
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
|
-
return `import { reactive } from ${process.env.
|
|
4
|
+
return `import { reactive } from ${process.env.POVESTE_DEV ? `'vue'` : getInjectedImport('@poveste/vendors/vue')}
|
|
5
5
|
export const markdownFiles = reactive({${filesJs}})
|
|
6
6
|
if (import.meta.hot) {
|
|
7
7
|
if (!window.__hst_md_hmr) {
|
|
@@ -2,7 +2,7 @@ import { createRequire } from 'node:module';
|
|
|
2
2
|
import { PLUGINS_HAVE_DEV } from './util.js';
|
|
3
3
|
const require = createRequire(import.meta.url);
|
|
4
4
|
export function resolvedSupportPluginsClient(ctx) {
|
|
5
|
-
const plugins = ctx.supportPlugins.map(p => `'${p.id}': () => import(${JSON.stringify(require.resolve(`${p.moduleName}/client${process.env.
|
|
5
|
+
const plugins = ctx.supportPlugins.map(p => `'${p.id}': () => import(${JSON.stringify(require.resolve(`${p.moduleName}/client${process.env.POVESTE_DEV && PLUGINS_HAVE_DEV.includes(p.moduleName) ? '-dev' : ''}`, {
|
|
6
6
|
paths: [ctx.root, import.meta.url],
|
|
7
7
|
}))})`);
|
|
8
8
|
return `export const clientSupportPlugins = {
|
|
@@ -2,7 +2,7 @@ import { createRequire } from 'node:module';
|
|
|
2
2
|
import { PLUGINS_HAVE_DEV } from './util.js';
|
|
3
3
|
const require = createRequire(import.meta.url);
|
|
4
4
|
export function resolvedSupportPluginsCollect(ctx) {
|
|
5
|
-
const plugins = ctx.supportPlugins.map(p => `'${p.id}': () => import(${JSON.stringify(require.resolve(`${p.moduleName}/collect${process.env.
|
|
5
|
+
const plugins = ctx.supportPlugins.map(p => `'${p.id}': () => import(${JSON.stringify(require.resolve(`${p.moduleName}/collect${process.env.POVESTE_DEV && PLUGINS_HAVE_DEV.includes(p.moduleName) ? '-dev' : ''}`, {
|
|
6
6
|
paths: [ctx.root, import.meta.url],
|
|
7
7
|
}))})`);
|
|
8
8
|
return `export const collectSupportPlugins = {
|
|
@@ -4,7 +4,7 @@ export function resolvedTheme(ctx) {
|
|
|
4
4
|
// Colors
|
|
5
5
|
for (const color in ctx.config.theme?.colors ?? {}) {
|
|
6
6
|
for (const key in ctx.config.theme.colors[color]) {
|
|
7
|
-
css += `--
|
|
7
|
+
css += `--_poveste-color-${color}-${key}: ${parseColor(ctx.config.theme.colors[color][key]).color.join(' ')};`;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
css += '}';
|
|
@@ -4,7 +4,7 @@ import * as VirtualFiles from './index.js';
|
|
|
4
4
|
import { ID_SEPARATOR } from './util.js';
|
|
5
5
|
export function createVirtualFilesPlugin(ctx, isServer) {
|
|
6
6
|
return {
|
|
7
|
-
name: '
|
|
7
|
+
name: 'poveste-virtual-files',
|
|
8
8
|
async resolveId(id, importer) {
|
|
9
9
|
if (id.startsWith(VirtualFiles.STORIES_ID)) {
|
|
10
10
|
return VirtualFiles.RESOLVED_STORIES_ID;
|
package/dist/node/vite.js
CHANGED
|
@@ -74,7 +74,7 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
74
74
|
return result;
|
|
75
75
|
}
|
|
76
76
|
plugins.push({
|
|
77
|
-
name: '
|
|
77
|
+
name: 'poveste-vite-plugin',
|
|
78
78
|
config(_, { command }) {
|
|
79
79
|
return {
|
|
80
80
|
resolve: {
|
|
@@ -82,7 +82,7 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
82
82
|
'vue',
|
|
83
83
|
],
|
|
84
84
|
alias: {
|
|
85
|
-
'
|
|
85
|
+
'poveste-style': join(APP_PATH, process.env.POVESTE_DEV ? 'app/style/main.pcss' : 'style.css'),
|
|
86
86
|
},
|
|
87
87
|
...(isServer
|
|
88
88
|
? {
|
|
@@ -116,15 +116,15 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
116
116
|
ctx.resolvedViteConfig.root,
|
|
117
117
|
process.cwd(),
|
|
118
118
|
...supportPluginAllowPaths,
|
|
119
|
-
...process.env.
|
|
119
|
+
...process.env.POVESTE_DEV
|
|
120
120
|
? [
|
|
121
|
-
'../../packages/
|
|
121
|
+
'../../packages/poveste-vendors',
|
|
122
122
|
]
|
|
123
123
|
: [],
|
|
124
124
|
],
|
|
125
125
|
},
|
|
126
126
|
watch: {
|
|
127
|
-
ignored: [`!**/node_modules/.
|
|
127
|
+
ignored: [`!**/node_modules/.poveste/**`, '**/vite.config.*'],
|
|
128
128
|
},
|
|
129
129
|
hmr: command === 'build' ? false : !isServer,
|
|
130
130
|
},
|
|
@@ -145,7 +145,7 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
145
145
|
};
|
|
146
146
|
},
|
|
147
147
|
options() {
|
|
148
|
-
this.meta.
|
|
148
|
+
this.meta.poveste = {
|
|
149
149
|
isCollecting: isServer,
|
|
150
150
|
};
|
|
151
151
|
},
|
|
@@ -157,7 +157,7 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
157
157
|
},
|
|
158
158
|
configureServer(server) {
|
|
159
159
|
let firstMount = true;
|
|
160
|
-
server.ws.on('
|
|
160
|
+
server.ws.on('poveste:mount', () => {
|
|
161
161
|
if (!firstMount) {
|
|
162
162
|
notifyStoryChange();
|
|
163
163
|
}
|
|
@@ -186,7 +186,7 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
</script>
|
|
189
|
-
<script type="module" src="/@fs/${APP_PATH}/bundle-sandbox${process.env.
|
|
189
|
+
<script type="module" src="/@fs/${APP_PATH}/bundle-sandbox${process.env.POVESTE_DEV ? '-dev' : ''}.js"></script>
|
|
190
190
|
</body>
|
|
191
191
|
</html>`;
|
|
192
192
|
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
|
@@ -216,7 +216,7 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
216
216
|
</head>
|
|
217
217
|
<body>
|
|
218
218
|
<div id="app"></div>
|
|
219
|
-
<script type="module" src="/@fs/${APP_PATH}/bundle-main${process.env.
|
|
219
|
+
<script type="module" src="/@fs/${APP_PATH}/bundle-main${process.env.POVESTE_DEV ? '-dev' : ''}.js"></script>
|
|
220
220
|
</body>
|
|
221
221
|
</html>`;
|
|
222
222
|
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
|
@@ -234,11 +234,11 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
234
234
|
plugins.push(createVirtualFilesPlugin(ctx, isServer));
|
|
235
235
|
// Replace dev flag
|
|
236
236
|
const flags = {
|
|
237
|
-
'_ctx.
|
|
238
|
-
'
|
|
237
|
+
'_ctx.__POVESTE_DEV__': JSON.stringify(ctx.mode === 'dev'),
|
|
238
|
+
'__POVESTE_DEV__': JSON.stringify(ctx.mode === 'dev'),
|
|
239
239
|
};
|
|
240
240
|
plugins.push({
|
|
241
|
-
name: '
|
|
241
|
+
name: 'poveste:flags',
|
|
242
242
|
enforce: 'pre',
|
|
243
243
|
transform(code, id) {
|
|
244
244
|
if (id.match(/\.(vue|js)($|\?)/)) {
|
|
@@ -254,9 +254,9 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
254
254
|
if (ctx.mode === 'dev') {
|
|
255
255
|
// Dev commands
|
|
256
256
|
plugins.push({
|
|
257
|
-
name: '
|
|
257
|
+
name: 'poveste:dev-commands',
|
|
258
258
|
configureServer(server) {
|
|
259
|
-
server.ws.on('
|
|
259
|
+
server.ws.on('poveste:dev-command', ({ id, params }) => {
|
|
260
260
|
const command = ctx.registeredCommands.find(c => c.id === id);
|
|
261
261
|
if (command?.serverAction) {
|
|
262
262
|
command.serverAction(params);
|
|
@@ -272,7 +272,7 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
272
272
|
const include = [/\.vue$/];
|
|
273
273
|
const exclude = [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/];
|
|
274
274
|
plugins.push({
|
|
275
|
-
name: '
|
|
275
|
+
name: 'poveste-file-name-plugin',
|
|
276
276
|
enforce: 'post',
|
|
277
277
|
transform(code, id) {
|
|
278
278
|
if (exclude.some(r => r.test(id)))
|
|
@@ -286,9 +286,9 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
286
286
|
},
|
|
287
287
|
});
|
|
288
288
|
}
|
|
289
|
-
if (process.env.
|
|
289
|
+
if (process.env.POVESTE_DEV && !isServer) {
|
|
290
290
|
plugins.push({
|
|
291
|
-
name: '
|
|
291
|
+
name: 'poveste-dev-plugin',
|
|
292
292
|
config() {
|
|
293
293
|
// Examples context
|
|
294
294
|
return {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poveste",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"description": "A fast story book powered by Vite",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Sorin Gitlan"
|
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
"shiki": "^3.0.0",
|
|
67
67
|
"sirv": "^3.0.0",
|
|
68
68
|
"vite-node": "3.2.4",
|
|
69
|
-
"@poveste/
|
|
70
|
-
"@poveste/
|
|
71
|
-
"@poveste/
|
|
72
|
-
"@poveste/
|
|
69
|
+
"@poveste/controls": "^0.1.2",
|
|
70
|
+
"@poveste/vendors": "^0.1.2",
|
|
71
|
+
"@poveste/app": "^0.1.2",
|
|
72
|
+
"@poveste/shared": "^0.1.2"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@types/fs-extra": "^11.0.4",
|
package/src/node/alias.ts
CHANGED
|
@@ -3,6 +3,6 @@ import path from 'pathe'
|
|
|
3
3
|
|
|
4
4
|
const require = createRequire(import.meta.url)
|
|
5
5
|
|
|
6
|
-
export const APP_PATH = path.join(path.dirname(require.resolve('@poveste/app/package.json')), process.env.
|
|
6
|
+
export const APP_PATH = path.join(path.dirname(require.resolve('@poveste/app/package.json')), process.env.POVESTE_DEV ? 'src' : 'dist')
|
|
7
7
|
|
|
8
|
-
export const TEMP_PATH = path.join(process.cwd(), 'node_modules', '.
|
|
8
|
+
export const TEMP_PATH = path.join(process.cwd(), 'node_modules', '.poveste')
|
package/src/node/bin.ts
CHANGED
|
@@ -25,7 +25,7 @@ program.command('dev')
|
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
program.command('build')
|
|
28
|
-
.describe('build the
|
|
28
|
+
.describe('build the poveste final app you can deploy')
|
|
29
29
|
.option('-c, --config <file>', `[string] use specified config file`)
|
|
30
30
|
.action(async (options) => {
|
|
31
31
|
const { buildCommand } = await import('./commands/build.js')
|
package/src/node/build.ts
CHANGED
|
@@ -98,7 +98,7 @@ export async function build(ctx: Context) {
|
|
|
98
98
|
],
|
|
99
99
|
plugins: [
|
|
100
100
|
{
|
|
101
|
-
name: '
|
|
101
|
+
name: 'poveste-build-rollup-options-override',
|
|
102
102
|
enforce: 'post',
|
|
103
103
|
options(options) {
|
|
104
104
|
// Don't externalize
|
|
@@ -115,7 +115,7 @@ export async function build(ctx: Context) {
|
|
|
115
115
|
// (so that we no longer need defineExpose)
|
|
116
116
|
// Nuxt: replaces the Nuxt vite dev server
|
|
117
117
|
buildViteConfig.plugins.push({
|
|
118
|
-
name: '
|
|
118
|
+
name: 'poveste-vue-plugin-override',
|
|
119
119
|
config(config) {
|
|
120
120
|
const vuePlugin = config.plugins.find((p: any) => p.name === 'vite:vue') as VitePlugin
|
|
121
121
|
if (vuePlugin) {
|
|
@@ -140,7 +140,7 @@ export async function build(ctx: Context) {
|
|
|
140
140
|
})
|
|
141
141
|
|
|
142
142
|
buildViteConfig.plugins.push({
|
|
143
|
-
name: '
|
|
143
|
+
name: 'poveste-build-config-override',
|
|
144
144
|
enforce: 'post',
|
|
145
145
|
config(config) {
|
|
146
146
|
// Don't externalize
|
|
@@ -209,7 +209,7 @@ export async function build(ctx: Context) {
|
|
|
209
209
|
const sandboxHtml = generateEntryHtml(sandboxOutput.fileName, styleOutput.fileName, {}, ctx)
|
|
210
210
|
await writeFile('__sandbox.html', sandboxHtml, ctx)
|
|
211
211
|
|
|
212
|
-
await writeFile('
|
|
212
|
+
await writeFile('poveste.json', JSON.stringify(getSerializedStoryData(ctx), null, 2), ctx)
|
|
213
213
|
|
|
214
214
|
const duration = performance.now() - startTime
|
|
215
215
|
if (emptyStoryCount) {
|
|
@@ -71,7 +71,7 @@ export function pinceauTokens(_options: PinceauTokensOptions = {}): Plugin {
|
|
|
71
71
|
function storyTemplate(pinceauConfig: any) {
|
|
72
72
|
pinceauConfig = pinceauConfig?.theme || pinceauConfig?.default?.theme || {}
|
|
73
73
|
|
|
74
|
-
return `import '
|
|
74
|
+
return `import 'poveste-style'
|
|
75
75
|
import './style.css'
|
|
76
76
|
import { createApp, h, markRaw, ref } from ${getInjectedImport('@poveste/vendors/vue')}
|
|
77
77
|
import {
|
|
@@ -85,7 +85,7 @@ export function tailwindTokens(options: TailwindTokensOptions = {}): Plugin {
|
|
|
85
85
|
|
|
86
86
|
function storyTemplate(tailwindConfig: any) {
|
|
87
87
|
return `
|
|
88
|
-
import '
|
|
88
|
+
import 'poveste-style'
|
|
89
89
|
import './style.css'
|
|
90
90
|
import { createApp, h, markRaw, ref } from ${getInjectedImport('@poveste/vendors/vue')}
|
|
91
91
|
import {
|
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
watch as _watch,
|
|
11
11
|
} from '@poveste/vendors/vue'
|
|
12
12
|
// @ts-expect-error virtual module id
|
|
13
|
-
import * as generatedSetup from 'virtual:$
|
|
13
|
+
import * as generatedSetup from 'virtual:$poveste-generated-global-setup'
|
|
14
14
|
// @ts-expect-error virtual module id
|
|
15
|
-
import * as setup from 'virtual:$
|
|
15
|
+
import * as setup from 'virtual:$poveste-setup'
|
|
16
16
|
|
|
17
17
|
export default _defineComponent({
|
|
18
18
|
name: 'RenderStory',
|
|
@@ -26,10 +26,16 @@ export function useCollectStories(options: UseCollectStoriesOptions, ctx: Contex
|
|
|
26
26
|
const node = new ViteNodeServer(server as any, {
|
|
27
27
|
deps: {
|
|
28
28
|
inline: [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
// Published layout: `poveste` and scoped `@poveste/*` packages. These
|
|
30
|
+
// MUST be inlined so vite-node transforms them and resolves their
|
|
31
|
+
// `virtual:` imports; otherwise they're loaded via native Node ESM,
|
|
32
|
+
// which throws ERR_UNSUPPORTED_ESM_URL_SCHEME on `virtual:` and breaks
|
|
33
|
+
// story collection for any fresh npm install.
|
|
34
|
+
/\/poveste\/dist/,
|
|
35
|
+
/\/poveste\/client/,
|
|
36
|
+
/@poveste\/[\w-]+\/dist/,
|
|
37
|
+
// Workspace layout: packages/poveste-<name>/dist (dev / monorepo).
|
|
38
|
+
/poveste-[\w-]+\/dist/,
|
|
33
39
|
/@vue\/devtools-api/,
|
|
34
40
|
/vuetify/,
|
|
35
41
|
// @TODO temporary fix for https://github.com/histoire-dev/histoire/issues/409
|
package/src/node/collect/run.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ServerRunPayload } from '@poveste/shared'
|
|
2
2
|
// @ts-expect-error virtual module
|
|
3
|
-
import { collectSupportPlugins } from 'virtual:$
|
|
3
|
+
import { collectSupportPlugins } from 'virtual:$poveste-support-plugins-collect'
|
|
4
4
|
|
|
5
5
|
export async function run(payload: ServerRunPayload) {
|
|
6
6
|
const { run } = await collectSupportPlugins[payload.file.supportPluginId]()
|
package/src/node/config.ts
CHANGED
package/src/node/index.ts
CHANGED
package/src/node/markdown.ts
CHANGED
|
@@ -35,7 +35,7 @@ export async function createMarkdownRenderer(ctx: Context) {
|
|
|
35
35
|
})
|
|
36
36
|
|
|
37
37
|
const md = new MarkdownIt({
|
|
38
|
-
highlight: (code, lang) => `<div class="htw-relative htw-not-prose __histoire-code"><div class="htw-absolute htw-top-0 htw-right-0 htw-text-xs htw-text-white/40">${lang}</div>${highlighter.codeToHtml(code, { theme: 'github-dark', lang })}</div>`,
|
|
38
|
+
highlight: (code, lang) => `<div class="htw-relative htw-not-prose __poveste-code __histoire-code"><div class="htw-absolute htw-top-0 htw-right-0 htw-text-xs htw-text-white/40">${lang}</div>${highlighter.codeToHtml(code, { theme: 'github-dark', lang })}</div>`,
|
|
39
39
|
linkify: true,
|
|
40
40
|
html: true,
|
|
41
41
|
breaks: false,
|
|
@@ -117,7 +117,7 @@ export async function createMarkdownPlugins(ctx: Context) {
|
|
|
117
117
|
|
|
118
118
|
// @TODO extract
|
|
119
119
|
plugins.push({
|
|
120
|
-
name: '
|
|
120
|
+
name: 'poveste-vue-docs-block',
|
|
121
121
|
transform(code, id) {
|
|
122
122
|
if (!id.includes('?vue&type=docs')) return
|
|
123
123
|
if (!id.includes('lang.md')) return
|
package/src/node/server.ts
CHANGED
|
@@ -66,13 +66,13 @@ export async function createServer(ctx: Context, options: CreateServerOptions =
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// Custom dev events
|
|
69
|
-
server.ws.on(`
|
|
69
|
+
server.ws.on(`poveste:dev-event`, async ({ event, payload }) => {
|
|
70
70
|
for (const plugin of ctx.config.plugins) {
|
|
71
71
|
if (plugin.onDevEvent) {
|
|
72
72
|
const api = new DevEventPluginApi(ctx, plugin, moduleLoader, event, payload)
|
|
73
73
|
const result = await plugin.onDevEvent(api)
|
|
74
74
|
if (!event.startsWith('on') && result !== undefined) {
|
|
75
|
-
server.ws.send(`
|
|
75
|
+
server.ws.send(`poveste:dev-event-result`, { event, result })
|
|
76
76
|
break
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -177,7 +177,7 @@ export async function createServer(ctx: Context, options: CreateServerOptions =
|
|
|
177
177
|
const fileCount = ctx.storyFiles.length
|
|
178
178
|
let loadedFilesCount = 0
|
|
179
179
|
const sendProgress = () => {
|
|
180
|
-
server.ws.send('
|
|
180
|
+
server.ws.send('poveste:stories-loading-progress', {
|
|
181
181
|
loadedFileCount: loadedFilesCount,
|
|
182
182
|
totalFileCount: fileCount,
|
|
183
183
|
})
|
|
@@ -192,7 +192,7 @@ export async function createServer(ctx: Context, options: CreateServerOptions =
|
|
|
192
192
|
}))
|
|
193
193
|
|
|
194
194
|
didAllStoriesYet = true
|
|
195
|
-
server.ws.send('
|
|
195
|
+
server.ws.send('poveste:all-stories-loaded', {})
|
|
196
196
|
}
|
|
197
197
|
console.log(`Collect stories end ${pc.bold(pc.blue(Math.round(performance.now() - time)))}ms`)
|
|
198
198
|
|
package/src/node/tree.ts
CHANGED
|
@@ -16,7 +16,7 @@ export function createPath(config: PovesteConfig, file: ServerTreeFile) {
|
|
|
16
16
|
const paths = file.path.split('/').slice(0, -1)
|
|
17
17
|
|
|
18
18
|
// check if tree file path is a plugin
|
|
19
|
-
const index = paths.findIndex(p => p.includes('.
|
|
19
|
+
const index = paths.findIndex(p => p.includes('.poveste'))
|
|
20
20
|
|
|
21
21
|
if (index !== -1) {
|
|
22
22
|
return ['plugins', file.title]
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
// @TODO wait for virtual modules HMR to work in vite to use `virtual:` and `\0` prefix
|
|
2
2
|
// https://github.com/vitejs/vite/pull/10313
|
|
3
|
-
export const STORIES_ID = 'virtual:$
|
|
3
|
+
export const STORIES_ID = 'virtual:$poveste-stories'
|
|
4
4
|
export const RESOLVED_STORIES_ID = `/__resolved__${STORIES_ID}`
|
|
5
5
|
// export const RESOLVED_STORIES_ID = `\0${STORIES_ID}`
|
|
6
|
-
export const SETUP_ID = 'virtual:$
|
|
7
|
-
export const NOOP_ID = 'virtual:$
|
|
8
|
-
export const CONFIG_ID = 'virtual:$
|
|
6
|
+
export const SETUP_ID = 'virtual:$poveste-setup'
|
|
7
|
+
export const NOOP_ID = 'virtual:$poveste-noop'
|
|
8
|
+
export const CONFIG_ID = 'virtual:$poveste-config'
|
|
9
9
|
// export const RESOLVED_CONFIG_ID = `/__resolved__${CONFIG_ID}`
|
|
10
10
|
export const RESOLVED_CONFIG_ID = `\0${CONFIG_ID}`
|
|
11
|
-
export const THEME_ID = 'virtual:$
|
|
11
|
+
export const THEME_ID = 'virtual:$poveste-theme'
|
|
12
12
|
// export const RESOLVED_THEME_ID = `/__resolved__${THEME_ID}.css`
|
|
13
13
|
export const RESOLVED_THEME_ID = `\0${THEME_ID}.css`
|
|
14
|
-
export const SEARCH_TITLE_DATA_ID = 'virtual:$
|
|
14
|
+
export const SEARCH_TITLE_DATA_ID = 'virtual:$poveste-search-title-data'
|
|
15
15
|
// export const RESOLVED_SEARCH_TITLE_DATA_ID = `/__resolved__${SEARCH_TITLE_DATA_ID}`
|
|
16
16
|
export const RESOLVED_SEARCH_TITLE_DATA_ID = `\0${SEARCH_TITLE_DATA_ID}`
|
|
17
|
-
export const SEARCH_DOCS_DATA_ID = 'virtual:$
|
|
17
|
+
export const SEARCH_DOCS_DATA_ID = 'virtual:$poveste-search-docs-data'
|
|
18
18
|
// export const RESOLVED_SEARCH_DOCS_DATA_ID = `/__resolved__${SEARCH_DOCS_DATA_ID}`
|
|
19
19
|
export const RESOLVED_SEARCH_DOCS_DATA_ID = `\0${SEARCH_DOCS_DATA_ID}`
|
|
20
|
-
export const GENERATED_GLOBAL_SETUP = 'virtual:$
|
|
20
|
+
export const GENERATED_GLOBAL_SETUP = 'virtual:$poveste-generated-global-setup'
|
|
21
21
|
// export const RESOLVED_GENERATED_GLOBAL_SETUP = `/__resolved__${GENERATED_GLOBAL_SETUP}`
|
|
22
22
|
export const RESOLVED_GENERATED_GLOBAL_SETUP = `\0${GENERATED_GLOBAL_SETUP}`
|
|
23
|
-
export const GENERATED_SETUP_CODE = 'virtual:$
|
|
23
|
+
export const GENERATED_SETUP_CODE = 'virtual:$poveste-generated-setup-code'
|
|
24
24
|
// export const RESOLVED_GENERATED_SETUP_CODE = `/__resolved__${GENERATED_SETUP_CODE}`
|
|
25
25
|
export const RESOLVED_GENERATED_SETUP_CODE = `\0${GENERATED_SETUP_CODE}`
|
|
26
|
-
export const SUPPORT_PLUGINS_CLIENT = 'virtual:$
|
|
26
|
+
export const SUPPORT_PLUGINS_CLIENT = 'virtual:$poveste-support-plugins-client'
|
|
27
27
|
// export const RESOLVED_SUPPORT_PLUGINS_CLIENT = `/__resolved__${SUPPORT_PLUGINS_CLIENT}`
|
|
28
28
|
export const RESOLVED_SUPPORT_PLUGINS_CLIENT = `\0${SUPPORT_PLUGINS_CLIENT}`
|
|
29
|
-
export const SUPPORT_PLUGINS_COLLECT = 'virtual:$
|
|
29
|
+
export const SUPPORT_PLUGINS_COLLECT = 'virtual:$poveste-support-plugins-collect'
|
|
30
30
|
// export const RESOLVED_SUPPORT_PLUGINS_COLLECT = `/__resolved__${SUPPORT_PLUGINS_COLLECT}`
|
|
31
31
|
export const RESOLVED_SUPPORT_PLUGINS_COLLECT = `\0${SUPPORT_PLUGINS_COLLECT}`
|
|
32
|
-
export const MARKDOWN_FILES = 'virtual:$
|
|
32
|
+
export const MARKDOWN_FILES = 'virtual:$poveste-markdown-files'
|
|
33
33
|
// export const RESOLVED_MARKDOWN_FILES = `/__resolved__${MARKDOWN_FILES}`
|
|
34
34
|
export const RESOLVED_MARKDOWN_FILES = `\0${MARKDOWN_FILES}`
|
|
35
|
-
export const COMMANDS = 'virtual:$
|
|
35
|
+
export const COMMANDS = 'virtual:$poveste-commands'
|
|
36
36
|
export const RESOLVED_COMMANDS = `/__resolved__${COMMANDS}`
|
|
37
37
|
|
|
38
38
|
export * from './markdown.js'
|
|
@@ -3,7 +3,7 @@ import { getInjectedImport } from '../util/vendors.js'
|
|
|
3
3
|
|
|
4
4
|
export function resolvedMarkdownFiles(ctx: Context) {
|
|
5
5
|
const filesJs = ctx.markdownFiles.map(f => `${JSON.stringify(f.relativePath)}: () => import(${JSON.stringify(`virtual:md:${f.id}`)})`).join(',')
|
|
6
|
-
return `import { reactive } from ${process.env.
|
|
6
|
+
return `import { reactive } from ${process.env.POVESTE_DEV ? `'vue'` : getInjectedImport('@poveste/vendors/vue')}
|
|
7
7
|
export const markdownFiles = reactive({${filesJs}})
|
|
8
8
|
if (import.meta.hot) {
|
|
9
9
|
if (!window.__hst_md_hmr) {
|
|
@@ -5,7 +5,7 @@ import { PLUGINS_HAVE_DEV } from './util.js'
|
|
|
5
5
|
const require = createRequire(import.meta.url)
|
|
6
6
|
|
|
7
7
|
export function resolvedSupportPluginsClient(ctx: Context) {
|
|
8
|
-
const plugins = ctx.supportPlugins.map(p => `'${p.id}': () => import(${JSON.stringify(require.resolve(`${p.moduleName}/client${process.env.
|
|
8
|
+
const plugins = ctx.supportPlugins.map(p => `'${p.id}': () => import(${JSON.stringify(require.resolve(`${p.moduleName}/client${process.env.POVESTE_DEV && PLUGINS_HAVE_DEV.includes(p.moduleName) ? '-dev' : ''}`, {
|
|
9
9
|
paths: [ctx.root, import.meta.url],
|
|
10
10
|
}))})`)
|
|
11
11
|
return `export const clientSupportPlugins = {
|
|
@@ -5,7 +5,7 @@ import { PLUGINS_HAVE_DEV } from './util.js'
|
|
|
5
5
|
const require = createRequire(import.meta.url)
|
|
6
6
|
|
|
7
7
|
export function resolvedSupportPluginsCollect(ctx: Context) {
|
|
8
|
-
const plugins = ctx.supportPlugins.map(p => `'${p.id}': () => import(${JSON.stringify(require.resolve(`${p.moduleName}/collect${process.env.
|
|
8
|
+
const plugins = ctx.supportPlugins.map(p => `'${p.id}': () => import(${JSON.stringify(require.resolve(`${p.moduleName}/collect${process.env.POVESTE_DEV && PLUGINS_HAVE_DEV.includes(p.moduleName) ? '-dev' : ''}`, {
|
|
9
9
|
paths: [ctx.root, import.meta.url],
|
|
10
10
|
}))})`)
|
|
11
11
|
return `export const collectSupportPlugins = {
|
|
@@ -6,7 +6,7 @@ export function resolvedTheme(ctx: Context) {
|
|
|
6
6
|
// Colors
|
|
7
7
|
for (const color in ctx.config.theme?.colors ?? {}) {
|
|
8
8
|
for (const key in ctx.config.theme.colors[color]) {
|
|
9
|
-
css += `--
|
|
9
|
+
css += `--_poveste-color-${color}-${key}: ${parseColor(ctx.config.theme.colors[color][key]).color.join(' ')};`
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
css += '}'
|
|
@@ -7,7 +7,7 @@ import { ID_SEPARATOR } from './util.js'
|
|
|
7
7
|
|
|
8
8
|
export function createVirtualFilesPlugin(ctx: Context, isServer: boolean) {
|
|
9
9
|
return {
|
|
10
|
-
name: '
|
|
10
|
+
name: 'poveste-virtual-files',
|
|
11
11
|
|
|
12
12
|
async resolveId(id, importer) {
|
|
13
13
|
if (id.startsWith(VirtualFiles.STORIES_ID)) {
|
package/src/node/vite.ts
CHANGED
|
@@ -100,7 +100,7 @@ export async function getViteConfigWithPlugins(isServer: boolean, ctx: Context):
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
plugins.push({
|
|
103
|
-
name: '
|
|
103
|
+
name: 'poveste-vite-plugin',
|
|
104
104
|
|
|
105
105
|
config(_, { command }) {
|
|
106
106
|
return {
|
|
@@ -109,7 +109,7 @@ export async function getViteConfigWithPlugins(isServer: boolean, ctx: Context):
|
|
|
109
109
|
'vue',
|
|
110
110
|
],
|
|
111
111
|
alias: {
|
|
112
|
-
'
|
|
112
|
+
'poveste-style': join(APP_PATH, process.env.POVESTE_DEV ? 'app/style/main.pcss' : 'style.css'),
|
|
113
113
|
},
|
|
114
114
|
...(isServer
|
|
115
115
|
? {
|
|
@@ -143,15 +143,15 @@ export async function getViteConfigWithPlugins(isServer: boolean, ctx: Context):
|
|
|
143
143
|
ctx.resolvedViteConfig.root,
|
|
144
144
|
process.cwd(),
|
|
145
145
|
...supportPluginAllowPaths,
|
|
146
|
-
...process.env.
|
|
146
|
+
...process.env.POVESTE_DEV
|
|
147
147
|
? [
|
|
148
|
-
'../../packages/
|
|
148
|
+
'../../packages/poveste-vendors',
|
|
149
149
|
]
|
|
150
150
|
: [],
|
|
151
151
|
],
|
|
152
152
|
},
|
|
153
153
|
watch: {
|
|
154
|
-
ignored: [`!**/node_modules/.
|
|
154
|
+
ignored: [`!**/node_modules/.poveste/**`, '**/vite.config.*'],
|
|
155
155
|
},
|
|
156
156
|
hmr: command === 'build' ? false : !isServer,
|
|
157
157
|
},
|
|
@@ -173,7 +173,7 @@ export async function getViteConfigWithPlugins(isServer: boolean, ctx: Context):
|
|
|
173
173
|
},
|
|
174
174
|
|
|
175
175
|
options() {
|
|
176
|
-
(this.meta as any).
|
|
176
|
+
(this.meta as any).poveste = {
|
|
177
177
|
isCollecting: isServer,
|
|
178
178
|
}
|
|
179
179
|
},
|
|
@@ -187,7 +187,7 @@ export async function getViteConfigWithPlugins(isServer: boolean, ctx: Context):
|
|
|
187
187
|
|
|
188
188
|
configureServer(server) {
|
|
189
189
|
let firstMount = true
|
|
190
|
-
server.ws.on('
|
|
190
|
+
server.ws.on('poveste:mount', () => {
|
|
191
191
|
if (!firstMount) {
|
|
192
192
|
notifyStoryChange()
|
|
193
193
|
}
|
|
@@ -217,7 +217,7 @@ export async function getViteConfigWithPlugins(isServer: boolean, ctx: Context):
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
</script>
|
|
220
|
-
<script type="module" src="/@fs/${APP_PATH}/bundle-sandbox${process.env.
|
|
220
|
+
<script type="module" src="/@fs/${APP_PATH}/bundle-sandbox${process.env.POVESTE_DEV ? '-dev' : ''}.js"></script>
|
|
221
221
|
</body>
|
|
222
222
|
</html>`
|
|
223
223
|
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
|
@@ -249,7 +249,7 @@ export async function getViteConfigWithPlugins(isServer: boolean, ctx: Context):
|
|
|
249
249
|
</head>
|
|
250
250
|
<body>
|
|
251
251
|
<div id="app"></div>
|
|
252
|
-
<script type="module" src="/@fs/${APP_PATH}/bundle-main${process.env.
|
|
252
|
+
<script type="module" src="/@fs/${APP_PATH}/bundle-main${process.env.POVESTE_DEV ? '-dev' : ''}.js"></script>
|
|
253
253
|
</body>
|
|
254
254
|
</html>`
|
|
255
255
|
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
|
@@ -269,11 +269,11 @@ export async function getViteConfigWithPlugins(isServer: boolean, ctx: Context):
|
|
|
269
269
|
|
|
270
270
|
// Replace dev flag
|
|
271
271
|
const flags = {
|
|
272
|
-
'_ctx.
|
|
273
|
-
'
|
|
272
|
+
'_ctx.__POVESTE_DEV__': JSON.stringify(ctx.mode === 'dev'),
|
|
273
|
+
'__POVESTE_DEV__': JSON.stringify(ctx.mode === 'dev'),
|
|
274
274
|
}
|
|
275
275
|
plugins.push({
|
|
276
|
-
name: '
|
|
276
|
+
name: 'poveste:flags',
|
|
277
277
|
enforce: 'pre',
|
|
278
278
|
transform(code, id) {
|
|
279
279
|
if (id.match(/\.(vue|js)($|\?)/)) {
|
|
@@ -289,9 +289,9 @@ export async function getViteConfigWithPlugins(isServer: boolean, ctx: Context):
|
|
|
289
289
|
if (ctx.mode === 'dev') {
|
|
290
290
|
// Dev commands
|
|
291
291
|
plugins.push({
|
|
292
|
-
name: '
|
|
292
|
+
name: 'poveste:dev-commands',
|
|
293
293
|
configureServer(server) {
|
|
294
|
-
server.ws.on('
|
|
294
|
+
server.ws.on('poveste:dev-command', ({ id, params }) => {
|
|
295
295
|
const command = ctx.registeredCommands.find(c => c.id === id)
|
|
296
296
|
if (command?.serverAction) {
|
|
297
297
|
command.serverAction(params)
|
|
@@ -309,7 +309,7 @@ export async function getViteConfigWithPlugins(isServer: boolean, ctx: Context):
|
|
|
309
309
|
const include = [/\.vue$/]
|
|
310
310
|
const exclude = [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/]
|
|
311
311
|
plugins.push({
|
|
312
|
-
name: '
|
|
312
|
+
name: 'poveste-file-name-plugin',
|
|
313
313
|
enforce: 'post',
|
|
314
314
|
|
|
315
315
|
transform(code, id) {
|
|
@@ -324,9 +324,9 @@ export async function getViteConfigWithPlugins(isServer: boolean, ctx: Context):
|
|
|
324
324
|
})
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
-
if (process.env.
|
|
327
|
+
if (process.env.POVESTE_DEV && !isServer) {
|
|
328
328
|
plugins.push({
|
|
329
|
-
name: '
|
|
329
|
+
name: 'poveste-dev-plugin',
|
|
330
330
|
config() {
|
|
331
331
|
// Examples context
|
|
332
332
|
return {
|