histoire 0.10.0 → 0.10.1
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/builtin-plugins/tailwind-tokens.js +3 -7
- package/dist/node/util/deps.d.ts +1 -0
- package/dist/node/util/deps.js +9 -0
- package/dist/node/vite.js +3 -2
- package/package.json +5 -5
- package/src/node/builtin-plugins/tailwind-tokens.ts +3 -9
- package/src/node/util/deps.ts +12 -0
- package/src/node/vite.ts +3 -2
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getInjectedImport } from '../util/deps.js';
|
|
2
2
|
import { findUp } from '../util/find-up.js';
|
|
3
|
-
const require = createRequire(import.meta.url);
|
|
4
|
-
function resolveImport(request) {
|
|
5
|
-
return JSON.stringify(require.resolve(request));
|
|
6
|
-
}
|
|
7
3
|
export function tailwindTokens(options = {}) {
|
|
8
4
|
const tailwindConfigFile = options.configFile ?? findUp(process.cwd(), [
|
|
9
5
|
'tailwind.config.js',
|
|
@@ -77,7 +73,7 @@ export function tailwindTokens(options = {}) {
|
|
|
77
73
|
}
|
|
78
74
|
const storyTemplate = (tailwindConfig) => `import 'histoire-style'
|
|
79
75
|
import './style.css'
|
|
80
|
-
import { createApp, h, markRaw, ref } from ${
|
|
76
|
+
import { createApp, h, markRaw, ref } from ${getInjectedImport('@histoire/vendors/vue')}
|
|
81
77
|
import {
|
|
82
78
|
HstColorShades,
|
|
83
79
|
HstTokenList,
|
|
@@ -85,7 +81,7 @@ import {
|
|
|
85
81
|
HstText,
|
|
86
82
|
HstTextarea,
|
|
87
83
|
HstNumber,
|
|
88
|
-
} from ${
|
|
84
|
+
} from ${getInjectedImport('@histoire/controls')}
|
|
89
85
|
|
|
90
86
|
const config = markRaw(${JSON.stringify(tailwindConfig, null, 2)})
|
|
91
87
|
const search = ref('')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getInjectedImport(request: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { dirname, join } from 'pathe';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { createRequire } from 'module';
|
|
4
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
const isInHistoireMonorepo = __dirname.includes(join('packages', 'histoire', 'dist'));
|
|
7
|
+
export function getInjectedImport(request) {
|
|
8
|
+
return JSON.stringify(isInHistoireMonorepo ? require.resolve(request) : request);
|
|
9
|
+
}
|
package/dist/node/vite.js
CHANGED
|
@@ -8,6 +8,7 @@ import { makeTree } from './tree.js';
|
|
|
8
8
|
import { parseColor } from './colors.js';
|
|
9
9
|
import { createMarkdownPlugins } from './markdown.js';
|
|
10
10
|
import { getSearchDataJS, generateDocSearchData, generateTitleSearchData } from './search.js';
|
|
11
|
+
import { getInjectedImport } from './util/deps.js';
|
|
11
12
|
const require = createRequire(import.meta.url);
|
|
12
13
|
export const STORIES_ID = '$histoire-stories';
|
|
13
14
|
export const RESOLVED_STORIES_ID = `/${STORIES_ID}-resolved`;
|
|
@@ -96,7 +97,7 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
96
97
|
]),
|
|
97
98
|
exclude: [
|
|
98
99
|
'histoire',
|
|
99
|
-
'@histoire',
|
|
100
|
+
'@histoire/vendors',
|
|
100
101
|
],
|
|
101
102
|
},
|
|
102
103
|
server: {
|
|
@@ -280,7 +281,7 @@ if (import.meta.hot) {
|
|
|
280
281
|
}
|
|
281
282
|
if (id === RESOLVED_MARKDOWN_FILES) {
|
|
282
283
|
const filesJs = ctx.markdownFiles.map(f => `${JSON.stringify(f.relativePath)}: () => import(${JSON.stringify(`./${f.relativePath}`)})`).join(',');
|
|
283
|
-
return `import { reactive } from ${
|
|
284
|
+
return `import { reactive } from ${getInjectedImport('@histoire/vendors/vue')}
|
|
284
285
|
export const markdownFiles = reactive({${filesJs}})
|
|
285
286
|
if (import.meta.hot) {
|
|
286
287
|
window.__hst_md_hmr = (newModule) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "histoire",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "A fast story book powered by Vite",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"histoire": "./bin.mjs"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@histoire/app": "^0.10.
|
|
33
|
-
"@histoire/controls": "^0.10.
|
|
34
|
-
"@histoire/shared": "^0.10.
|
|
35
|
-
"@histoire/vendors": "^0.10.
|
|
32
|
+
"@histoire/app": "^0.10.1",
|
|
33
|
+
"@histoire/controls": "^0.10.1",
|
|
34
|
+
"@histoire/shared": "^0.10.1",
|
|
35
|
+
"@histoire/vendors": "^0.10.1",
|
|
36
36
|
"@types/flexsearch": "^0.7.3",
|
|
37
37
|
"@types/markdown-it": "^12.2.3",
|
|
38
38
|
"birpc": "^0.1.1",
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { createRequire } from 'module'
|
|
2
1
|
import { BasePluginApi, Plugin } from '../plugin.js'
|
|
2
|
+
import { getInjectedImport } from '../util/deps.js'
|
|
3
3
|
import { findUp } from '../util/find-up.js'
|
|
4
4
|
|
|
5
|
-
const require = createRequire(import.meta.url)
|
|
6
|
-
|
|
7
|
-
function resolveImport (request) {
|
|
8
|
-
return JSON.stringify(require.resolve(request))
|
|
9
|
-
}
|
|
10
|
-
|
|
11
5
|
export interface TailwindTokensOptions {
|
|
12
6
|
configFile?: string
|
|
13
7
|
}
|
|
@@ -90,7 +84,7 @@ export function tailwindTokens (options: TailwindTokensOptions = {}): Plugin {
|
|
|
90
84
|
|
|
91
85
|
const storyTemplate = (tailwindConfig: any) => `import 'histoire-style'
|
|
92
86
|
import './style.css'
|
|
93
|
-
import { createApp, h, markRaw, ref } from ${
|
|
87
|
+
import { createApp, h, markRaw, ref } from ${getInjectedImport('@histoire/vendors/vue')}
|
|
94
88
|
import {
|
|
95
89
|
HstColorShades,
|
|
96
90
|
HstTokenList,
|
|
@@ -98,7 +92,7 @@ import {
|
|
|
98
92
|
HstText,
|
|
99
93
|
HstTextarea,
|
|
100
94
|
HstNumber,
|
|
101
|
-
} from ${
|
|
95
|
+
} from ${getInjectedImport('@histoire/controls')}
|
|
102
96
|
|
|
103
97
|
const config = markRaw(${JSON.stringify(tailwindConfig, null, 2)})
|
|
104
98
|
const search = ref('')
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { dirname, join } from 'pathe'
|
|
2
|
+
import { fileURLToPath } from 'url'
|
|
3
|
+
import { createRequire } from 'module'
|
|
4
|
+
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
6
|
+
const require = createRequire(import.meta.url)
|
|
7
|
+
|
|
8
|
+
const isInHistoireMonorepo = __dirname.includes(join('packages', 'histoire', 'dist'))
|
|
9
|
+
|
|
10
|
+
export function getInjectedImport (request: string) {
|
|
11
|
+
return JSON.stringify(isInHistoireMonorepo ? require.resolve(request) : request)
|
|
12
|
+
}
|
package/src/node/vite.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { makeTree } from './tree.js'
|
|
|
17
17
|
import { parseColor } from './colors.js'
|
|
18
18
|
import { createMarkdownPlugins } from './markdown.js'
|
|
19
19
|
import { getSearchDataJS, generateDocSearchData, generateTitleSearchData } from './search.js'
|
|
20
|
+
import { getInjectedImport } from './util/deps.js'
|
|
20
21
|
|
|
21
22
|
const require = createRequire(import.meta.url)
|
|
22
23
|
|
|
@@ -114,7 +115,7 @@ export async function getViteConfigWithPlugins (isServer: boolean, ctx: Context)
|
|
|
114
115
|
]),
|
|
115
116
|
exclude: [
|
|
116
117
|
'histoire',
|
|
117
|
-
'@histoire',
|
|
118
|
+
'@histoire/vendors',
|
|
118
119
|
],
|
|
119
120
|
},
|
|
120
121
|
server: {
|
|
@@ -308,7 +309,7 @@ if (import.meta.hot) {
|
|
|
308
309
|
|
|
309
310
|
if (id === RESOLVED_MARKDOWN_FILES) {
|
|
310
311
|
const filesJs = ctx.markdownFiles.map(f => `${JSON.stringify(f.relativePath)}: () => import(${JSON.stringify(`./${f.relativePath}`)})`).join(',')
|
|
311
|
-
return `import { reactive } from ${
|
|
312
|
+
return `import { reactive } from ${getInjectedImport('@histoire/vendors/vue')}
|
|
312
313
|
export const markdownFiles = reactive({${filesJs}})
|
|
313
314
|
if (import.meta.hot) {
|
|
314
315
|
window.__hst_md_hmr = (newModule) => {
|