histoire 0.1.0 → 0.1.3
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/client/app/components/story/StoryResponsivePreview.vue +43 -2
- package/dist/client/app/components/story/StoryVariantSingleView.vue +1 -1
- package/dist/node/build.js +7 -0
- package/dist/node/plugin.js +8 -4
- package/dist/style.css +0 -6
- package/package.json +3 -4
- package/src/client/app/components/story/StoryResponsivePreview.vue +43 -2
- package/src/client/app/components/story/StoryVariantSingleView.vue +1 -1
- package/src/node/build.ts +7 -0
- package/src/node/plugin.ts +9 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed, Ref, ref, toRaw,
|
|
2
|
+
import { computed, Ref, ref, toRaw, watch } from 'vue'
|
|
3
3
|
import { useEventListener } from '@vueuse/core'
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
5
|
import { STATE_SYNC, PREVIEW_SETTINGS_SYNC, SANDBOX_READY } from '../../util/const'
|
|
@@ -8,6 +8,7 @@ import type { Story, Variant } from '../../types'
|
|
|
8
8
|
import HatchedPattern from '../misc/HatchedPattern.vue'
|
|
9
9
|
import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
|
|
10
10
|
import { toRawDeep } from '../../util/reactivity'
|
|
11
|
+
import { Settings } from 'http2'
|
|
11
12
|
|
|
12
13
|
const props = defineProps<{
|
|
13
14
|
story: Story
|
|
@@ -15,6 +16,10 @@ const props = defineProps<{
|
|
|
15
16
|
settings: PreviewSettings
|
|
16
17
|
}>()
|
|
17
18
|
|
|
19
|
+
const emit = defineEmits({
|
|
20
|
+
'update:settings': (settings: PreviewSettings) => true,
|
|
21
|
+
})
|
|
22
|
+
|
|
18
23
|
// Iframe
|
|
19
24
|
|
|
20
25
|
const iframe = ref<HTMLIFrameElement>()
|
|
@@ -120,7 +125,43 @@ function useDragger (el: Ref<HTMLDivElement>, value: Ref<number>, min: number, m
|
|
|
120
125
|
useEventListener(el, 'mousedown', onMouseDown)
|
|
121
126
|
}
|
|
122
127
|
|
|
123
|
-
|
|
128
|
+
// Optimize by batching settings updates to the next frame
|
|
129
|
+
// Prevents sync issues with `useStorage`
|
|
130
|
+
let settingsUpdate: Partial<Settings> = {}
|
|
131
|
+
let settingsUpdateQueued = false
|
|
132
|
+
|
|
133
|
+
function updateSettings (settings: Partial<PreviewSettings>) {
|
|
134
|
+
Object.assign(settingsUpdate, settings)
|
|
135
|
+
|
|
136
|
+
if (!settingsUpdateQueued) {
|
|
137
|
+
settingsUpdateQueued = true
|
|
138
|
+
requestAnimationFrame(() => {
|
|
139
|
+
emit('update:settings', {
|
|
140
|
+
...props.settings,
|
|
141
|
+
...settingsUpdate,
|
|
142
|
+
})
|
|
143
|
+
settingsUpdate = {}
|
|
144
|
+
settingsUpdateQueued = false
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const responsiveWidth = computed({
|
|
150
|
+
get: () => props.settings[props.settings.rotate ? 'responsiveHeight' : 'responsiveWidth'],
|
|
151
|
+
set: (value) => {
|
|
152
|
+
updateSettings({
|
|
153
|
+
[props.settings.rotate ? 'responsiveHeight' : 'responsiveWidth']: value,
|
|
154
|
+
})
|
|
155
|
+
},
|
|
156
|
+
})
|
|
157
|
+
const responsiveHeight = computed({
|
|
158
|
+
get: () => props.settings[props.settings.rotate ? 'responsiveWidth' : 'responsiveHeight'],
|
|
159
|
+
set: (value) => {
|
|
160
|
+
updateSettings({
|
|
161
|
+
[props.settings.rotate ? 'responsiveWidth' : 'responsiveHeight']: value,
|
|
162
|
+
})
|
|
163
|
+
},
|
|
164
|
+
})
|
|
124
165
|
|
|
125
166
|
const horizontalDragger = ref<HTMLDivElement>()
|
|
126
167
|
const verticalDragger = ref<HTMLDivElement>()
|
package/dist/node/build.js
CHANGED
|
@@ -44,6 +44,13 @@ export async function build(ctx) {
|
|
|
44
44
|
join(APP_PATH, 'index.ts'),
|
|
45
45
|
join(APP_PATH, 'sandbox.ts'),
|
|
46
46
|
],
|
|
47
|
+
output: {
|
|
48
|
+
manualChunks(id) {
|
|
49
|
+
if (!id.includes('histoire/dist/client') && id.includes('node_modules')) {
|
|
50
|
+
return 'vendor';
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
},
|
|
47
54
|
},
|
|
48
55
|
outDir: ctx.config.outDir,
|
|
49
56
|
emptyOutDir: true,
|
package/dist/node/plugin.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { relative, dirname } from 'pathe';
|
|
2
3
|
import { resolveConfig as resolveViteConfig } from 'vite';
|
|
3
4
|
import { lookup as lookupMime } from 'mrmime';
|
|
4
5
|
import { APP_PATH, DIST_CLIENT_PATH } from './alias.js';
|
|
@@ -6,6 +7,7 @@ import { notifyStoryChange } from './stories.js';
|
|
|
6
7
|
import { makeTree } from './tree.js';
|
|
7
8
|
import { parseColor } from './colors.js';
|
|
8
9
|
import { createMarkdownRenderer } from './markdown.js';
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
9
11
|
export const STORIES_ID = '$histoire-stories';
|
|
10
12
|
export const RESOLVED_STORIES_ID = `/${STORIES_ID}-resolved`;
|
|
11
13
|
export const SETUP_ID = '$histoire-setup';
|
|
@@ -37,9 +39,11 @@ export async function createVitePlugins(ctx) {
|
|
|
37
39
|
// force include vue to avoid duplicated copies when linked + optimized
|
|
38
40
|
include: [
|
|
39
41
|
'vue',
|
|
40
|
-
'@vue/runtime-core',
|
|
41
|
-
'shiki',
|
|
42
|
-
'
|
|
42
|
+
dirname(require.resolve('@vue/runtime-core/package.json')),
|
|
43
|
+
dirname(require.resolve('shiki/package.json')),
|
|
44
|
+
dirname(require.resolve('vscode-textmate/package.json')),
|
|
45
|
+
dirname(require.resolve('vscode-oniguruma/package.json')),
|
|
46
|
+
dirname(require.resolve('case/package.json')),
|
|
43
47
|
],
|
|
44
48
|
},
|
|
45
49
|
server: {
|
package/dist/style.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "histoire",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "A fast story book powered by Vite",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@iconify/vue": "^3.1.3",
|
|
37
|
-
"@histoire/controls": "^0.1.
|
|
37
|
+
"@histoire/controls": "^0.1.3",
|
|
38
38
|
"@vitejs/plugin-vue": "^2.2.0",
|
|
39
|
-
"@vueuse/core": "^
|
|
39
|
+
"@vueuse/core": "^8.1.1",
|
|
40
40
|
"case": "^1.6.3",
|
|
41
41
|
"chokidar": "^3.5.3",
|
|
42
42
|
"defu": "^5.0.1",
|
|
@@ -60,7 +60,6 @@
|
|
|
60
60
|
"vue-router": "^4.0.12"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@vue/runtime-core": "^3.2.31",
|
|
64
63
|
"vite": "^2.8.3",
|
|
65
64
|
"vue": "^3.2.31"
|
|
66
65
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed, Ref, ref, toRaw,
|
|
2
|
+
import { computed, Ref, ref, toRaw, watch } from 'vue'
|
|
3
3
|
import { useEventListener } from '@vueuse/core'
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
5
|
import { STATE_SYNC, PREVIEW_SETTINGS_SYNC, SANDBOX_READY } from '../../util/const'
|
|
@@ -8,6 +8,7 @@ import type { Story, Variant } from '../../types'
|
|
|
8
8
|
import HatchedPattern from '../misc/HatchedPattern.vue'
|
|
9
9
|
import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
|
|
10
10
|
import { toRawDeep } from '../../util/reactivity'
|
|
11
|
+
import { Settings } from 'http2'
|
|
11
12
|
|
|
12
13
|
const props = defineProps<{
|
|
13
14
|
story: Story
|
|
@@ -15,6 +16,10 @@ const props = defineProps<{
|
|
|
15
16
|
settings: PreviewSettings
|
|
16
17
|
}>()
|
|
17
18
|
|
|
19
|
+
const emit = defineEmits({
|
|
20
|
+
'update:settings': (settings: PreviewSettings) => true,
|
|
21
|
+
})
|
|
22
|
+
|
|
18
23
|
// Iframe
|
|
19
24
|
|
|
20
25
|
const iframe = ref<HTMLIFrameElement>()
|
|
@@ -120,7 +125,43 @@ function useDragger (el: Ref<HTMLDivElement>, value: Ref<number>, min: number, m
|
|
|
120
125
|
useEventListener(el, 'mousedown', onMouseDown)
|
|
121
126
|
}
|
|
122
127
|
|
|
123
|
-
|
|
128
|
+
// Optimize by batching settings updates to the next frame
|
|
129
|
+
// Prevents sync issues with `useStorage`
|
|
130
|
+
let settingsUpdate: Partial<Settings> = {}
|
|
131
|
+
let settingsUpdateQueued = false
|
|
132
|
+
|
|
133
|
+
function updateSettings (settings: Partial<PreviewSettings>) {
|
|
134
|
+
Object.assign(settingsUpdate, settings)
|
|
135
|
+
|
|
136
|
+
if (!settingsUpdateQueued) {
|
|
137
|
+
settingsUpdateQueued = true
|
|
138
|
+
requestAnimationFrame(() => {
|
|
139
|
+
emit('update:settings', {
|
|
140
|
+
...props.settings,
|
|
141
|
+
...settingsUpdate,
|
|
142
|
+
})
|
|
143
|
+
settingsUpdate = {}
|
|
144
|
+
settingsUpdateQueued = false
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const responsiveWidth = computed({
|
|
150
|
+
get: () => props.settings[props.settings.rotate ? 'responsiveHeight' : 'responsiveWidth'],
|
|
151
|
+
set: (value) => {
|
|
152
|
+
updateSettings({
|
|
153
|
+
[props.settings.rotate ? 'responsiveHeight' : 'responsiveWidth']: value,
|
|
154
|
+
})
|
|
155
|
+
},
|
|
156
|
+
})
|
|
157
|
+
const responsiveHeight = computed({
|
|
158
|
+
get: () => props.settings[props.settings.rotate ? 'responsiveWidth' : 'responsiveHeight'],
|
|
159
|
+
set: (value) => {
|
|
160
|
+
updateSettings({
|
|
161
|
+
[props.settings.rotate ? 'responsiveWidth' : 'responsiveHeight']: value,
|
|
162
|
+
})
|
|
163
|
+
},
|
|
164
|
+
})
|
|
124
165
|
|
|
125
166
|
const horizontalDragger = ref<HTMLDivElement>()
|
|
126
167
|
const verticalDragger = ref<HTMLDivElement>()
|
package/src/node/build.ts
CHANGED
|
@@ -52,6 +52,13 @@ export async function build (ctx: Context) {
|
|
|
52
52
|
join(APP_PATH, 'index.ts'),
|
|
53
53
|
join(APP_PATH, 'sandbox.ts'),
|
|
54
54
|
],
|
|
55
|
+
output: {
|
|
56
|
+
manualChunks (id) {
|
|
57
|
+
if (!id.includes('histoire/dist/client') && id.includes('node_modules')) {
|
|
58
|
+
return 'vendor'
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
},
|
|
55
62
|
},
|
|
56
63
|
outDir: ctx.config.outDir,
|
|
57
64
|
emptyOutDir: true,
|
package/src/node/plugin.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from 'module'
|
|
2
|
+
import { relative, dirname } from 'pathe'
|
|
2
3
|
import { resolveConfig as resolveViteConfig, Plugin as VitePlugin } from 'vite'
|
|
3
4
|
import { lookup as lookupMime } from 'mrmime'
|
|
4
5
|
import { APP_PATH, DIST_CLIENT_PATH } from './alias.js'
|
|
@@ -8,6 +9,8 @@ import { makeTree } from './tree.js'
|
|
|
8
9
|
import { parseColor } from './colors.js'
|
|
9
10
|
import { createMarkdownRenderer } from './markdown.js'
|
|
10
11
|
|
|
12
|
+
const require = createRequire(import.meta.url)
|
|
13
|
+
|
|
11
14
|
export const STORIES_ID = '$histoire-stories'
|
|
12
15
|
export const RESOLVED_STORIES_ID = `/${STORIES_ID}-resolved`
|
|
13
16
|
export const SETUP_ID = '$histoire-setup'
|
|
@@ -45,9 +48,11 @@ export async function createVitePlugins (ctx: Context): Promise<VitePlugin[]> {
|
|
|
45
48
|
// force include vue to avoid duplicated copies when linked + optimized
|
|
46
49
|
include: [
|
|
47
50
|
'vue',
|
|
48
|
-
'@vue/runtime-core',
|
|
49
|
-
'shiki',
|
|
50
|
-
'
|
|
51
|
+
dirname(require.resolve('@vue/runtime-core/package.json')),
|
|
52
|
+
dirname(require.resolve('shiki/package.json')),
|
|
53
|
+
dirname(require.resolve('vscode-textmate/package.json')),
|
|
54
|
+
dirname(require.resolve('vscode-oniguruma/package.json')),
|
|
55
|
+
dirname(require.resolve('case/package.json')),
|
|
51
56
|
],
|
|
52
57
|
},
|
|
53
58
|
server: {
|