@histoire/app 1.0.0-beta.2 → 1.0.0-beta.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/app/style/theme.css +8 -0
- package/dist/bundled/app.css +2 -2
- package/dist/bundled/chunks/{AboutSection-D3IIVsiV.js → AboutSection-mX7J6xrz.js} +2 -2
- package/dist/bundled/chunks/{AgentCursor-Cg5SLa2H.js → AgentCursor-DcVxonMC.js} +2 -2
- package/dist/bundled/chunks/{AgentPlanApproval-D4hnGlYs.js → AgentPlanApproval-22I_Lbhn.js} +1 -1
- package/dist/bundled/chunks/{AgentsSection-CJGS9C2q.js → AgentsSection-DWmUKCX-.js} +1 -1
- package/dist/bundled/chunks/{AiPanel-B9QWRuSg.js → AiPanel-BICtbtCE.js} +4 -4
- package/dist/bundled/chunks/{AppearanceSection-DMjmDr1Y.js → AppearanceSection-maVgcfMk.js} +6 -6
- package/dist/bundled/chunks/{BasePopover-CQQ8wKev.js → BasePopover-B3Y5H1gd.js} +1 -1
- package/dist/bundled/chunks/{CommentsCanvasOverlay-UX-oYgnx.js → CommentsCanvasOverlay-DhqtbJNX.js} +5 -5
- package/dist/bundled/chunks/{DevBrowseStatus-D2rIG8uC.js → DevBrowseStatus-B6cLRu19.js} +2 -2
- package/dist/bundled/chunks/{DocsTab-BR3BktyF.js → DocsTab-PpFKAC6Q.js} +4 -4
- package/dist/bundled/chunks/{EventsTab-BP0hCGqL.js → EventsTab-DLVYcX1N.js} +3 -3
- package/dist/bundled/chunks/{GeneralSection-CT_-32qT.js → GeneralSection-dvmJUgqN.js} +1 -1
- package/dist/bundled/chunks/{InspectionPanel-C6kUdJj9.js → InspectionPanel-DDuT3guJ.js} +2 -2
- package/dist/bundled/chunks/{InspectorGuideLink-Bqlz1aaY.js → InspectorGuideLink-7Ui_Y2Wd.js} +1 -1
- package/dist/bundled/chunks/{MarkdownPage-DD7XyGkq.js → MarkdownPage-D_LpsCvG.js} +3 -3
- package/dist/bundled/chunks/{MarketplaceUpdateBody-B1cn_zeo.js → MarketplaceUpdateBody-BtLPpA7F.js} +2 -2
- package/dist/bundled/chunks/{MarketplaceView-eDPLtc_x.js → MarketplaceView-C1sVFRsq.js} +39 -10
- package/dist/bundled/chunks/{MatrixInspector-eIr_N5eH.js → MatrixInspector-wqkJJnuf.js} +3 -3
- package/dist/bundled/chunks/{MatrixView-CDmN-Kl9.js → MatrixView-D-Snu47M.js} +82 -40
- package/dist/bundled/chunks/{MatrixVisualActions-Cx3QzDTD.js → MatrixVisualActions-D3b-cp7N.js} +2 -2
- package/dist/bundled/chunks/{McpActivity-CiK3jUTY.js → McpActivity-r2CFr-ny.js} +1 -1
- package/dist/bundled/chunks/{McpSection-DRGzPGXO.js → McpSection-swh7qlM0.js} +1 -1
- package/dist/bundled/chunks/{NeedsAttention-C5zjd6RT.js → NeedsAttention-Cf6ihlT0.js} +2 -2
- package/dist/bundled/chunks/{PermissionPrompt-i5VbZCCJ.js → PermissionPrompt-CXTPfiIu.js} +1 -1
- package/dist/bundled/chunks/{PluginsSection-B3ZWAjrk.js → PluginsSection-Dhv2haa3.js} +6 -3
- package/dist/bundled/chunks/{ScreenshotPopover-DWcV_NAf.js → ScreenshotPopover-BZ37-dfK.js} +4 -4
- package/dist/bundled/chunks/{SettingsPage-BvT1FOl7.js → SettingsPage-D6ZOAgS9.js} +11 -11
- package/dist/bundled/chunks/{ShortcutsSection-D3-4e5Ug.js → ShortcutsSection-EK2-e56v.js} +1 -1
- package/dist/bundled/chunks/{StoryInspector-BJKzoeHc.js → StoryInspector-DCNgw0x8.js} +14 -11
- package/dist/bundled/chunks/{TestsPanel-CpBld3wM.js → TestsPanel-D1USqA8I.js} +5 -5
- package/dist/bundled/chunks/{TestsSection-CEXW49Ge.js → TestsSection-CIkkHlyK.js} +1 -1
- package/dist/bundled/chunks/{TestsTab-B-ZNDgGi.js → TestsTab-ykf9zwmG.js} +3 -3
- package/dist/bundled/chunks/{ThreadMessage-CPRLVXXQ.js → ThreadMessage-DxrvoIea.js} +5 -5
- package/dist/bundled/chunks/{ToolbarPopover-Nd-us4Fg.js → ToolbarPopover-CXizdbQq.js} +3 -3
- package/dist/bundled/chunks/{ViewportsSection-3EWu6WSc.js → ViewportsSection-D6mpKTSM.js} +1 -1
- package/dist/bundled/chunks/{VisualViewer-DV5mNFT8.js → VisualViewer-BQqfw1ov.js} +2 -2
- package/dist/bundled/chunks/{WorkbenchPanelAction-Cl68QrDs.js → WorkbenchPanelAction-SLby10Vh.js} +6 -2
- package/dist/bundled/chunks/{WorkbenchVirtualList-CUTamRgO.js → WorkbenchVirtualList-HCZiNo7p.js} +1 -1
- package/dist/bundled/chunks/{background-CG5-SPiv.js → background-CUUIkZVL.js} +7 -1
- package/dist/bundled/chunks/{canvas-settings-EP62RnvB.js → canvas-settings-Cw7AXzFG.js} +31 -13
- package/dist/bundled/chunks/{capture-SFV9pF9b.js → capture-DxD6llwl.js} +1 -1
- package/dist/bundled/chunks/{color-scheme-mhmCnofm.js → color-scheme-zLURTKoT.js} +1 -0
- package/dist/bundled/chunks/{content-view-Bpn8As7f.js → content-view-ChEpdsxh.js} +2 -2
- package/dist/bundled/chunks/{controls-view-COcHf8Pm.js → controls-view-CtDADD0e.js} +3 -3
- package/dist/bundled/chunks/{explorer-view-5gTgnjcf.js → explorer-view-B717fDtg.js} +6 -4
- package/dist/bundled/chunks/{extensions-DUXM9uEy.js → extensions-BtOjYv3e.js} +11 -2
- package/dist/bundled/chunks/{frame-ledger-BHZ0nJjD.js → frame-ledger-C67dpCuY.js} +160 -45
- package/dist/bundled/chunks/{frame-screenshot-D9R_xDns.js → frame-screenshot-IEmQR7TR.js} +1 -1
- package/dist/bundled/chunks/{icons-Bd36WZPu.js → icons-DoUVE4X3.js} +2 -2
- package/dist/bundled/chunks/{local-mount-CCa2jcqi.js → local-mount-CQ14I_16.js} +2 -1
- package/dist/bundled/chunks/{marketplace-DKeNfni-.js → marketplace-BE5IMmf3.js} +9 -3
- package/dist/bundled/chunks/{measurement-DfNeNMZe.js → measurement-BPE7RMeb.js} +1 -1
- package/dist/bundled/chunks/{model-DhvdMZzS.js → model-CIFxQfDH.js} +1 -1
- package/dist/bundled/chunks/{navigation-view-GU5-aPWL.js → navigation-view-Co43QbrR.js} +2 -2
- package/dist/bundled/chunks/{ownership-004rrffQ.js → ownership-BVQ3d672.js} +1 -1
- package/dist/bundled/chunks/{selection-DQJWdqhl.js → selection-BTc1fRMu.js} +1 -1
- package/dist/bundled/chunks/{settings-DC0gilMg.js → settings-BbefKI5N.js} +1 -1
- package/dist/bundled/chunks/{src-BazVZNon.js → src-CDZfcmuw.js} +7 -1
- package/dist/bundled/chunks/{tests-view-B9J9Gvpt.js → tests-view-RYpujVD_.js} +2 -2
- package/dist/bundled/chunks/{use-install-plan-ChZg4Xyq.js → use-install-plan-D0tiW2wu.js} +1 -1
- package/dist/bundled/chunks/{visual-CId9zv09.js → visual-nnXRPOP8.js} +1 -1
- package/dist/bundled/index.js +580 -313
- package/dist/embed/EmbedDocument.vue_vue_type_script_setup_true_lang.js +6 -1
- package/dist/embed/adapters/explorer-session.js +2 -1
- package/dist/embed/adapters/explorer-view.js +1 -0
- package/dist/embed/adapters/local-mount.js +2 -1
- package/dist/embed/adapters/runtime-frame.js +7 -1
- package/dist/embed/adapters/sandbox-urls.d.ts +2 -0
- package/dist/embed/adapters/sandbox-urls.js +1 -0
- package/dist/embed/app.css +2 -2
- package/dist/embed/handshake.js +5 -2
- package/dist/embed/packages/histoire-vue/src/components/embed/HistoireEmbed.js +6 -0
- package/dist/embed/packages/histoire-vue/src/components/preview/surface.js +11 -2
- package/dist/embed/surfaces.d.ts +2 -0
- package/dist/style.css +57 -13
- package/package.json +8 -8
- package/src/app/components/base/overflow/BaseOverflowToolbar.vue +1 -1
- package/src/app/components/base/overflow/BaseOverflowToolbarItem.vue +1 -1
- package/src/app/components/base/popover/BasePopover.vue +1 -1
- package/src/app/components/canvas/CanvasFrame.vue +47 -8
- package/src/app/components/canvas/CanvasReplicaPreview.vue +3 -1
- package/src/app/components/canvas/CanvasSingleVariant.vue +10 -5
- package/src/app/components/canvas/CanvasStatus.vue +6 -2
- package/src/app/components/canvas/CanvasViewport.vue +29 -10
- package/src/app/components/canvas/FramePaddingAligners.vue +44 -0
- package/src/app/components/canvas/SingleVariantResizeHandles.vue +3 -0
- package/src/app/components/canvas/frame-layout.ts +44 -23
- package/src/app/components/canvas/frame-props-override.ts +16 -2
- package/src/app/components/canvas/matrix/MatrixCell.vue +19 -6
- package/src/app/components/canvas/matrix/MatrixView.vue +10 -8
- package/src/app/components/canvas/matrix/matrix-layout.ts +32 -14
- package/src/app/components/canvas/matrix/matrix-registration.ts +4 -4
- package/src/app/components/canvas/single-resize.ts +4 -2
- package/src/app/components/canvas/single-viewport.ts +5 -0
- package/src/app/components/canvas/story-frame-size.ts +15 -0
- package/src/app/components/canvas/toolbar/ArrangeSwitch.vue +1 -1
- package/src/app/components/canvas/toolbar/CanvasToolbar.vue +1 -1
- package/src/app/components/canvas/toolbar/SearchMatchStepper.vue +1 -1
- package/src/app/components/canvas/toolbar/ToolSwitch.vue +1 -1
- package/src/app/components/canvas/toolbar/ViewportMenu.vue +46 -16
- package/src/app/components/canvas/toolbar/ZoomMenu.vue +13 -11
- package/src/app/components/canvas/toolbar/viewport-size.ts +14 -0
- package/src/app/components/canvas/useCanvasVariantSize.ts +24 -6
- package/src/app/components/canvas/useSingleVariantGeometry.ts +7 -4
- package/src/app/components/comments/prompt/AttachMenuPanel.vue +1 -1
- package/src/app/components/comments/prompt/PromptSuggestions.vue +1 -1
- package/src/app/components/embed/EmbedMenu.vue +8 -6
- package/src/app/components/inspector/InspectorTabs.vue +1 -1
- package/src/app/components/inspector/inspection/plugin.ts +1 -1
- package/src/app/components/marketplace/browse/CatalogState.vue +3 -0
- package/src/app/components/marketplace/detail/DetailHeader.vue +13 -5
- package/src/app/components/marketplace/install/use-install-wizard.ts +7 -2
- package/src/app/components/menu/ContextMenu.vue +1 -1
- package/src/app/components/menu/SubMenu.vue +1 -1
- package/src/app/components/pages/settings/PluginsSection.vue +4 -0
- package/src/app/components/pages/settings/plugins/use-plugin-updates.ts +3 -3
- package/src/app/components/shell/WorkbenchApp.vue +2 -2
- package/src/app/components/shell/WorkbenchPanelAction.vue +5 -3
- package/src/app/composables/canvas-settings.ts +23 -9
- package/src/app/standalone/workbench.ts +2 -0
- package/src/app/stores/canvas.ts +47 -7
- package/src/app/stores/marketplace.ts +1 -0
- package/src/app/stores/story-canvas-views.ts +15 -2
- package/src/app/style/theme.css +8 -0
- package/src/app/util/background.ts +7 -0
- package/src/app/util/frame-actions.ts +6 -0
- package/src/app/util/marketplace-client.ts +5 -2
- package/src/embed/EmbedDocument.vue +1 -1
- package/src/embed/adapters/explorer-session.ts +2 -2
- package/src/embed/adapters/explorer-view.ts +1 -1
- package/src/embed/adapters/local-mount.ts +1 -1
- package/src/embed/adapters/runtime-frame.ts +6 -1
- package/src/embed/adapters/sandbox-urls.ts +3 -0
- package/src/embed/handshake.ts +4 -2
- package/src/embed/surfaces.ts +2 -0
|
@@ -6,6 +6,7 @@ import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
|
6
6
|
import { useCanvasFrameBackground, useCanvasFrames, useCanvasStore } from '../../composables/canvas-settings.js'
|
|
7
7
|
import { useContextMenu } from '../../composables/context-menu.js'
|
|
8
8
|
import { getBackgroundStyle } from '../../util/background.js'
|
|
9
|
+
import { useFrameActions } from '../../util/frame-actions.js'
|
|
9
10
|
import { useWorkbenchTestsModel } from '../panes/tests/model.js'
|
|
10
11
|
import { getActiveCanvasTool } from './active-tool.js'
|
|
11
12
|
|
|
@@ -14,6 +15,7 @@ import CanvasReplicaPreview from './CanvasReplicaPreview.vue'
|
|
|
14
15
|
import { useFrameBadges } from './frame-badges.js'
|
|
15
16
|
import { CANVAS_FRAME_LABEL_HEIGHT, type CanvasFrameLayout } from './frame-layout.js'
|
|
16
17
|
import { isFrameMenuShortcut, openFrameMenu } from './frame-menu.js'
|
|
18
|
+
import FramePaddingAligners from './FramePaddingAligners.vue'
|
|
17
19
|
|
|
18
20
|
const props = defineProps<{
|
|
19
21
|
/** Complete canvas target and logical bounds. */
|
|
@@ -33,6 +35,10 @@ const props = defineProps<{
|
|
|
33
35
|
/** Preview logical dimensions before canvas scaling. */
|
|
34
36
|
width: number
|
|
35
37
|
height: number
|
|
38
|
+
/** Story-declared gutter around the variant, in logical pixels. */
|
|
39
|
+
padding?: number
|
|
40
|
+
/** Story declares the variant size, so the document gets it instead of viewport settings. */
|
|
41
|
+
fixedSize?: boolean
|
|
36
42
|
/** Known collection failure keeps existing preview visible but inactive. */
|
|
37
43
|
stale?: boolean
|
|
38
44
|
/** Exact search match highlight. */
|
|
@@ -47,6 +53,7 @@ const canvas = useCanvasStore()
|
|
|
47
53
|
const registry = useCanvasFrames()
|
|
48
54
|
const menu = useContextMenu()
|
|
49
55
|
const tests = useWorkbenchTestsModel()
|
|
56
|
+
const frameActions = useFrameActions()
|
|
50
57
|
const test = computed(() => tests?.rows.value.find(row => row.target.storyId === props.frame.storyId && row.target.variantId === props.frame.variantId))
|
|
51
58
|
const testIcon = computed(() => test.value?.failed || test.value?.error ? 'error-filled' : test.value?.stale ? 'warning-alt-filled' : test.value?.summary ? 'checkmark-filled' : props.variant.hasTests ? 'subtract' : null)
|
|
52
59
|
/** Plugin badges of this frame's header. */
|
|
@@ -62,22 +69,25 @@ const single = computed(() => props.presentation === 'single')
|
|
|
62
69
|
/** Snapshots need the title row to tell they aren't live yet; Single has none. */
|
|
63
70
|
const showSnapshot = computed(() => snapshotShown.value && !single.value)
|
|
64
71
|
const scale = computed(() => canvas.effectiveZoom)
|
|
72
|
+
const padding = computed(() => props.padding ?? 0)
|
|
65
73
|
const position = computed(() => ({
|
|
66
74
|
'left': single.value ? undefined : `${props.frame.x * canvas.effectiveZoom + canvas.panOffset.x}px`,
|
|
67
75
|
'top': single.value ? undefined : `${props.frame.y * canvas.effectiveZoom + canvas.panOffset.y}px`,
|
|
68
|
-
'width': `${props.width * scale.value}px`,
|
|
76
|
+
'width': `${(single.value ? props.width + padding.value * 2 : props.frame.width) * scale.value}px`,
|
|
69
77
|
'--histoire-frame-label-height': `${CANVAS_FRAME_LABEL_HEIGHT}px`,
|
|
70
78
|
}))
|
|
71
|
-
const previewStyle = computed(() => ({ width: `${props.width}px`, height: `${props.height}px`, transform: `scale(${scale.value})` }))
|
|
79
|
+
const previewStyle = computed(() => ({ width: `${props.width}px`, height: `${props.height}px`, transform: `translate(${padding.value * scale.value}px, ${padding.value * scale.value}px) scale(${scale.value})` }))
|
|
72
80
|
const background = useCanvasFrameBackground(() => props.frame.id)
|
|
81
|
+
/** Grid can extend the card beyond the intrinsic sandbox. */
|
|
82
|
+
const bodyStyle = computed(() => ({ height: `${(props.frame.bodyHeight ?? (props.height + padding.value * 2)) * scale.value}px`, ...getBackgroundStyle(background.value) }))
|
|
73
83
|
const canSelect = computed(() => !props.stale)
|
|
74
84
|
let unregister = () => {}
|
|
75
85
|
|
|
76
86
|
/** Returns logical preview coordinates beneath frame title chrome. */
|
|
77
87
|
function previewRect() {
|
|
78
88
|
return {
|
|
79
|
-
x: props.frame.x,
|
|
80
|
-
y: props.frame.y + (single.value ? 0 : CANVAS_FRAME_LABEL_HEIGHT / scale.value),
|
|
89
|
+
x: props.frame.x + padding.value,
|
|
90
|
+
y: props.frame.y + padding.value + (single.value ? 0 : CANVAS_FRAME_LABEL_HEIGHT / scale.value),
|
|
81
91
|
width: props.width,
|
|
82
92
|
height: props.height,
|
|
83
93
|
}
|
|
@@ -95,7 +105,7 @@ watch(() => props.frame.id, () => {
|
|
|
95
105
|
error.value = undefined
|
|
96
106
|
register()
|
|
97
107
|
}, { flush: 'sync' })
|
|
98
|
-
watch(() => [props.frame, props.width, props.height, canvas.effectiveZoom], () => {
|
|
108
|
+
watch(() => [props.frame, props.width, props.height, padding.value, canvas.effectiveZoom], () => {
|
|
99
109
|
const existing = registry.getFrame(props.frame.id)
|
|
100
110
|
if (existing) existing.rect = previewRect()
|
|
101
111
|
})
|
|
@@ -131,6 +141,28 @@ function onKeyDown(event: KeyboardEvent) {
|
|
|
131
141
|
}
|
|
132
142
|
}
|
|
133
143
|
|
|
144
|
+
/** Frame action keeps label chrome, menu and shortcut on one remount path. */
|
|
145
|
+
const remountAction = computed(() => frameActions?.entries.get('remount'))
|
|
146
|
+
/** Label reserves room for Remount on every live frame, so badges never shift when it appears. */
|
|
147
|
+
const remountSlot = computed(() => props.live && !props.stale && !!remountAction.value)
|
|
148
|
+
const canRemount = computed(() => remountSlot.value && status.value === 'ready')
|
|
149
|
+
/** Each remount turns the icon once counterclockwise, following its arrows, from the button, menu or shortcut alike. */
|
|
150
|
+
const remounts = computed(() => registry.getFrame(props.frame.id)?.remounts ?? 0)
|
|
151
|
+
/** Keeps the button visible while it turns, e.g. after Remount all. */
|
|
152
|
+
const remounting = ref(false)
|
|
153
|
+
let remountingTimer: ReturnType<typeof setTimeout> | undefined
|
|
154
|
+
watch(remounts, () => {
|
|
155
|
+
remounting.value = true
|
|
156
|
+
clearTimeout(remountingTimer)
|
|
157
|
+
remountingTimer = setTimeout(() => remounting.value = false, 600)
|
|
158
|
+
})
|
|
159
|
+
onBeforeUnmount(() => clearTimeout(remountingTimer))
|
|
160
|
+
|
|
161
|
+
/** Replay the variant's mount lifecycle, e.g. to watch an enter animation again. */
|
|
162
|
+
function remount() {
|
|
163
|
+
if (remountAction.value) void frameActions?.run(remountAction.value, { storyId: props.frame.storyId, variantId: props.frame.variantId, frameKey: props.frame.id })
|
|
164
|
+
}
|
|
165
|
+
|
|
134
166
|
/** Captured menu target does not mutate URL variant selection. */
|
|
135
167
|
function openMenu(event: MouseEvent | KeyboardEvent) {
|
|
136
168
|
if (props.stale) return
|
|
@@ -142,13 +174,20 @@ function openMenu(event: MouseEvent | KeyboardEvent) {
|
|
|
142
174
|
<template>
|
|
143
175
|
<!-- Unscaled frame chrome owns selection; group state never restarts its runtime. -->
|
|
144
176
|
<section class="histoire-canvas-frame htw:group/frame htw:absolute htw:min-w-0 htw:pointer-events-auto htw:data-[single=true]:relative htw:data-[single=true]:overflow-hidden htw:data-[single=true]:rounded-[7px] htw:data-[dimmed=true]:data-[selected=false]:opacity-35" :class="{ 'is-selected': selected }" :data-single="single" :data-selected="selected" :data-highlighted="highlighted ?? false" :data-dimmed="dimmed ?? false" :data-stale="stale ?? false" :style="position" :data-frame-id="frame.id" @contextmenu="openMenu">
|
|
145
|
-
<button v-if="!single" type="button" class="histoire-frame-label htw:box-border htw:w-full htw:min-w-0 htw:h-(--histoire-frame-label-height) htw:flex htw:items-center htw:justify-between htw:gap-2 htw:m-0 htw:pt-0 htw:px-0 htw:pb-2 htw:border-0 htw:bg-transparent htw:text-muted htw:[font-family:inherit] htw:text-[13px] htw:leading-5 htw:text-left htw:cursor-pointer htw:group-data-[selected=false]/frame:group-data-[highlighted=false]/frame:enabled:hover:text-text htw:focus-visible:outline-2 htw:focus-visible:outline-solid htw:focus-visible:outline-accent htw:focus-visible:outline-offset-2 htw:disabled:opacity-45 htw:disabled:cursor-default htw:group-data-[selected=true]/frame:text-accent htw:group-data-[selected=true]/frame:font-bold htw:group-data-[highlighted=true]/frame:text-accent" data-canvas-overlay-occluder :aria-pressed="selected" :disabled="!canSelect" @click="select" @keydown="onKeyDown">
|
|
177
|
+
<button v-if="!single" type="button" class="histoire-frame-label htw:box-border htw:w-full htw:min-w-0 htw:data-[remount=true]:pe-6 htw:h-(--histoire-frame-label-height) htw:flex htw:items-center htw:justify-between htw:gap-2 htw:m-0 htw:pt-0 htw:px-0 htw:pb-2 htw:border-0 htw:bg-transparent htw:text-muted htw:[font-family:inherit] htw:text-[13px] htw:leading-5 htw:text-left htw:cursor-pointer htw:group-data-[selected=false]/frame:group-data-[highlighted=false]/frame:enabled:hover:text-text htw:focus-visible:outline-2 htw:focus-visible:outline-solid htw:focus-visible:outline-accent htw:focus-visible:outline-offset-2 htw:disabled:opacity-45 htw:disabled:cursor-default htw:group-data-[selected=true]/frame:text-accent htw:group-data-[selected=true]/frame:font-bold htw:group-data-[highlighted=true]/frame:text-accent" data-canvas-overlay-occluder :data-remount="remountSlot" :aria-pressed="selected" :disabled="!canSelect" @click="select" @keydown="onKeyDown">
|
|
146
178
|
<span class="histoire-frame-title htw:flex-1 htw:min-w-0 htw:overflow-hidden htw:text-ellipsis htw:whitespace-nowrap" :title="variant.title">{{ variant.title }}</span><span v-for="badge in badges" :key="badge.id" class="histoire-frame-badge htw:flex-none htw:min-w-[18px] htw:h-[18px] htw:px-[5px] htw:box-border htw:inline-flex htw:items-center htw:justify-center htw:rounded-full htw:text-[11px] htw:font-semibold htw:leading-none htw:tabular-nums htw:data-[tone=neutral]:bg-chip htw:data-[tone=neutral]:text-muted htw:data-[tone=accent]:bg-accent-soft htw:data-[tone=accent]:text-accent-text htw:data-[tone=warning]:bg-warn/20 htw:data-[tone=warning]:text-warn htw:data-[tone=danger]:bg-danger-soft htw:data-[tone=danger]:text-danger-text" :data-tone="badge.tone" :title="badge.label"><span :aria-hidden="badge.label ? 'true' : undefined">{{ badge.text }}</span><span v-if="badge.label" class="htw:sr-only">{{ badge.label }}</span></span><BuiltinIcon v-if="status === 'error'" icon="error-filled" :size="16" class="htw:flex-none htw:text-danger" /><HstPulsatingDisc v-else-if="testRunningVisible || (showSnapshot && loadingVisible)" immediate :size="14" class="htw:flex-none htw:mx-px htw:text-muted" /><BuiltinIcon v-else-if="testIcon" :icon="testIcon" :size="16" class="htw:flex-none" :class="test?.failed || test?.error ? 'htw:text-danger' : 'htw:text-accent'" />
|
|
147
179
|
</button>
|
|
148
|
-
|
|
180
|
+
<!-- Wrapped so the label stays the frame's only direct button child. -->
|
|
181
|
+
<span v-if="!single && canRemount" class="htw:absolute htw:top-0 htw:end-0 htw:flex" data-canvas-overlay-occluder>
|
|
182
|
+
<button type="button" class="histoire-frame-remount htw:flex-none htw:box-border htw:h-(--histoire-frame-label-height) htw:flex htw:items-center htw:m-0 htw:pt-0 htw:px-0.5 htw:pb-2 htw:border-0 htw:bg-transparent htw:text-muted htw:cursor-pointer htw:opacity-0 htw:group-hover/frame:opacity-100 htw:group-data-[selected=true]/frame:opacity-100 htw:focus-visible:opacity-100 htw:data-[remounting=true]:opacity-100 htw:data-[remounting=true]:text-accent htw:hover:text-accent htw:focus-visible:outline-2 htw:focus-visible:outline-solid htw:focus-visible:outline-accent htw:focus-visible:outline-offset-2" :aria-label="`Remount ${variant.title}`" title="Remount" :data-remounting="remounting" @click="remount">
|
|
183
|
+
<BuiltinIcon icon="renew" :size="14" class="htw:transition-transform htw:duration-500 htw:ease-out htw:motion-reduce:transition-none" :style="{ transform: `rotate(${remounts * -360}deg)` }" />
|
|
184
|
+
</button>
|
|
185
|
+
</span>
|
|
186
|
+
<div class="htw:relative htw:w-full htw:overflow-hidden htw:border htw:border-solid htw:border-border htw:rounded-[7px] htw:bg-white htw:group-data-[single=true]/frame:border-0 htw:group-data-[selected=true]/frame:border-accent htw:group-data-[highlighted=true]/frame:border-accent htw:group-data-[selected=true]/frame:after:content-[''] htw:after:hidden htw:group-data-[selected=true]/frame:after:block htw:after:absolute htw:after:inset-0 htw:after:rounded-[inherit] htw:after:pointer-events-none htw:after:z-[3] htw:after:shadow-[inset_0_0_0_1px_var(--histoire-accent)] htw:group-data-[single=true]/frame:after:shadow-[inset_0_0_0_1px_var(--histoire-border)]" data-test-id="responsive-preview-bg" :style="bodyStyle" @click="selectFromBody">
|
|
149
187
|
<div class="histoire-frame-content htw:origin-top-left htw:group-data-[dimmed=true]/frame:group-data-[selected=true]/frame:opacity-35 htw:group-data-[stale=true]/frame:opacity-40 htw:group-data-[stale=true]/frame:pointer-events-none" :style="previewStyle" :aria-busy="status !== 'ready'" :inert="status !== 'ready' || stale ? true : undefined">
|
|
150
|
-
<CanvasReplicaPreview v-if="live" ref="replica" :interactive="!dragging" :frame-id="frame.id" :story-id="frame.storyId" :variant-id="frame.variantId" :preview-base="previewBase" :viewport="single ? { width, height } : undefined" @status="updateStatus" @snapshot="snapshotShown = $event" />
|
|
188
|
+
<CanvasReplicaPreview v-if="live" ref="replica" :interactive="!dragging" :frame-id="frame.id" :story-id="frame.storyId" :variant-id="frame.variantId" :preview-base="previewBase" :viewport="single ? { width, height } : undefined" :declared-size="fixedSize ? { width, height } : undefined" @status="updateStatus" @snapshot="snapshotShown = $event" />
|
|
151
189
|
</div>
|
|
190
|
+
<FramePaddingAligners v-if="padding > 0" :width="width * scale" :height="height * scale" :padding="padding * scale" :background="background" />
|
|
152
191
|
<div v-if="!live" class="htw:absolute htw:inset-0 htw:flex htw:flex-col htw:items-center htw:justify-center htw:gap-3 htw:p-4 htw:text-[12px] htw:text-center htw:text-muted htw:bg-input">
|
|
153
192
|
{{ variant.title }}
|
|
154
193
|
</div>
|
|
@@ -22,6 +22,8 @@ const props = defineProps<{
|
|
|
22
22
|
previewBase: string
|
|
23
23
|
/** Native Single dimensions, already resolved for orientation. */
|
|
24
24
|
viewport?: { width: number, height: number }
|
|
25
|
+
/** Story-declared variant size; sizes the document without changing how its frame scrolls or starts. */
|
|
26
|
+
declaredSize?: { width: number, height: number }
|
|
25
27
|
/** Matrix cell prop projection; never writes into canonical session. */
|
|
26
28
|
propsOverride?: Record<string, unknown>
|
|
27
29
|
}>()
|
|
@@ -60,7 +62,7 @@ const frame = acquireStoryFrame({
|
|
|
60
62
|
function settings() {
|
|
61
63
|
const value = snapshot.value.settings
|
|
62
64
|
const background = store.frameBackgrounds[props.frameId]
|
|
63
|
-
const viewport = contentSizing.size.value ?? props.viewport
|
|
65
|
+
const viewport = props.declaredSize ?? contentSizing.size.value ?? props.viewport
|
|
64
66
|
return { ...value, ...(background ?? {}), ...(viewport ? { responsiveWidth: viewport.width, responsiveHeight: viewport.height, rotate: false } : {}) }
|
|
65
67
|
}
|
|
66
68
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { HistoireCatalogVariant } from '@histoire/sdk'
|
|
3
3
|
import type { CanvasFrameLayout } from './frame-layout.js'
|
|
4
4
|
import type { CanvasRect } from './pan/usePanZoom.js'
|
|
5
|
-
import { onBeforeUnmount, ref } from 'vue'
|
|
5
|
+
import { computed, onBeforeUnmount, ref } from 'vue'
|
|
6
6
|
import { useCanvasStore } from '../../composables/canvas-settings.js'
|
|
7
7
|
import WorkbenchEmptyState from '../shell/WorkbenchEmptyState.vue'
|
|
8
8
|
import CanvasFrame from './CanvasFrame.vue'
|
|
@@ -23,14 +23,19 @@ const props = defineProps<{
|
|
|
23
23
|
stale: boolean
|
|
24
24
|
/** Workbench chrome and selected variant allow direct frame sizing. */
|
|
25
25
|
resizable: boolean
|
|
26
|
+
/** Story gutter around the variant, in logical pixels. */
|
|
27
|
+
padding?: number
|
|
26
28
|
}>()
|
|
27
29
|
const emit = defineEmits<{ contextmenu: [event: MouseEvent | KeyboardEvent, frame: CanvasFrameLayout], resize: [size: { width: number, height: number }] }>()
|
|
28
30
|
const surface = ref<HTMLElement>()
|
|
29
31
|
const frameShell = ref<HTMLElement>()
|
|
30
32
|
const resizing = ref(false)
|
|
31
33
|
const canvas = useCanvasStore()
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
const gutter = computed(() => props.padding ?? 0)
|
|
35
|
+
/** Zoom and pan own the whole frame, gutter included. */
|
|
36
|
+
const outerSize = computed(() => props.frame && { width: props.frame.width + gutter.value * 2, height: props.frame.height + gutter.value * 2 })
|
|
37
|
+
useSingleVariantZoom(canvas, surface, { area: () => props.area, size: () => outerSize.value, frameId: () => props.frame?.id })
|
|
38
|
+
const pan = useSingleVariantPan(surface, { area: () => props.area, size: () => outerSize.value, zoom: () => canvas.effectiveZoom, resizing: () => resizing.value })
|
|
34
39
|
defineExpose(pan)
|
|
35
40
|
|
|
36
41
|
/** Freeze Responsive and Fit only after one effective direct-resize change. */
|
|
@@ -60,11 +65,11 @@ onBeforeUnmount(() => canvas.setSingleViewportDraft(null))
|
|
|
60
65
|
<div class="htw:absolute htw:overflow-clip htw:[overflow-clip-margin:13px]" :style="{ left: `${area.x}px`, top: `${area.y}px`, width: `${area.width}px`, height: `${area.height}px` }">
|
|
61
66
|
<div ref="surface" class="histoire-single-variant htw:absolute htw:inset-0 htw:overflow-auto htw:touch-auto">
|
|
62
67
|
<div v-if="frame && variant" ref="frameShell" class="histoire-single-frame-shell htw:relative htw:w-fit htw:mx-auto">
|
|
63
|
-
<CanvasFrame :key="JSON.stringify([previewBase, frame.storyId])" presentation="single" :dragging="resizing" :frame="frame" :variant="variant" :live="true" :selected="true" :preview-base="previewBase" :width="frame.width" :height="frame.height" :stale="stale" @contextmenu="(event, target) => emit('contextmenu', event, target)" />
|
|
68
|
+
<CanvasFrame :key="JSON.stringify([previewBase, frame.storyId])" presentation="single" :dragging="resizing" :frame="frame" :variant="variant" :live="true" :selected="true" :preview-base="previewBase" :width="frame.width" :height="frame.height" :padding="gutter" :stale="stale" @contextmenu="(event, target) => emit('contextmenu', event, target)" />
|
|
64
69
|
</div>
|
|
65
70
|
<WorkbenchEmptyState v-else icon="document" title="Select a variant" />
|
|
66
71
|
</div>
|
|
67
72
|
<!-- Outside hit areas must stay out of native scroll content. -->
|
|
68
|
-
<SingleVariantResizeHandles v-if="resizable && frame && variant" :surface="surface" :frame="frameShell" :size="frame" :zoom="canvas.effectiveZoom" @update:active="resizing = $event" @start="startResize" @resize="resize" @commit="commit" />
|
|
73
|
+
<SingleVariantResizeHandles v-if="resizable && frame && variant" :surface="surface" :frame="frameShell" :size="frame" :inset="gutter" :zoom="canvas.effectiveZoom" @update:active="resizing = $event" @start="startResize" @resize="resize" @commit="commit" />
|
|
69
74
|
</div>
|
|
70
75
|
</template>
|
|
@@ -16,7 +16,11 @@ defineProps<{
|
|
|
16
16
|
const snapshot = useHistoireSnapshot()
|
|
17
17
|
const canvas = useCanvasStore()
|
|
18
18
|
const dimensions = useCanvasViewportDimensions()
|
|
19
|
-
const size = computed(() =>
|
|
19
|
+
const size = computed(() => {
|
|
20
|
+
const width = canvas.frameSizeFromCode?.width ?? dimensions.value.width
|
|
21
|
+
const height = canvas.frameSizeFromCode?.height ?? dimensions.value.height
|
|
22
|
+
return `${width} × ${height ?? 'Auto'}`
|
|
23
|
+
})
|
|
20
24
|
</script>
|
|
21
25
|
|
|
22
26
|
<template>
|
|
@@ -44,6 +48,6 @@ const size = computed(() => `${dimensions.value.width} × ${dimensions.value.hei
|
|
|
44
48
|
</CanvasHintBar>
|
|
45
49
|
</div>
|
|
46
50
|
<div v-else class="histoire-canvas-status htw:[line-height:normal] htw:flex htw:w-full htw:items-center htw:justify-end htw:gap-2 htw:min-w-0 htw:font-mono htw:text-[11px] htw:text-muted">
|
|
47
|
-
<BuiltinIcon class="htw:flex-none" icon="laptop" :size="14" /><span class="htw:overflow-hidden htw:text-ellipsis htw:whitespace-nowrap">{{ size }} · {{ Math.round(canvas.effectiveZoom * 100) }}% · {{ snapshot.settings.backgroundColor }}</span>
|
|
51
|
+
<BuiltinIcon class="htw:flex-none" :icon="canvas.frameSizeFromCode ? 'code' : 'laptop'" :size="14" /><span class="htw:overflow-hidden htw:text-ellipsis htw:whitespace-nowrap">{{ size }} · {{ Math.round(canvas.effectiveZoom * 100) }}% · {{ snapshot.settings.backgroundColor }}</span>
|
|
48
52
|
</div>
|
|
49
53
|
</template>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { HistoireCatalogStory, HistoireSession } from '@histoire/sdk'
|
|
3
|
-
import type { CanvasArrangement } from '../../stores/canvas-arrangement.js'
|
|
4
3
|
import { useHistoireSession, useHistoireSnapshot } from '@histoire/vue'
|
|
5
4
|
import { useHistoireContext } from '@histoire/vue/internal'
|
|
6
5
|
import { computed, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue'
|
|
7
6
|
import { createCanvasFrames, provideCanvas, provideCanvasPointerPan } from '../../composables/canvas-settings.js'
|
|
8
7
|
import { useContextMenu } from '../../composables/context-menu.js'
|
|
8
|
+
import { type CanvasArrangement, isBuiltinCanvasArrangement } from '../../stores/canvas-arrangement.js'
|
|
9
9
|
import { createCanvasStore, getCanvasStorage } from '../../stores/canvas.js'
|
|
10
10
|
import { useUiSettingsStore } from '../../stores/settings.js'
|
|
11
11
|
import { useStoryCanvasViews } from '../../stores/story-canvas-views.js'
|
|
@@ -31,6 +31,7 @@ import { useViewportFrames } from './frames/viewport-frames.js'
|
|
|
31
31
|
import CanvasPluginLayers from './overlays/CanvasPluginLayers.vue'
|
|
32
32
|
import { type CanvasSize, clientToCanvas } from './pan/usePanZoom.js'
|
|
33
33
|
import { selectedSingleFrame, singleViewportSettings } from './single-viewport.js'
|
|
34
|
+
import { storyFrameSize } from './story-frame-size.js'
|
|
34
35
|
import { bindStoryCanvasView } from './story-view-binding.js'
|
|
35
36
|
import { useCanvasGeometry } from './useCanvasGeometry.js'
|
|
36
37
|
import { useCanvasHeaderOcclusion } from './useCanvasHeaderOcclusion.js'
|
|
@@ -46,6 +47,8 @@ const props = withDefaults(defineProps<{
|
|
|
46
47
|
previewBase: string
|
|
47
48
|
/** Approved maximum live frames, including selected frame. */
|
|
48
49
|
frameBudget: number
|
|
50
|
+
/** Project gutter for stories whose layout sets no padding. */
|
|
51
|
+
framePadding?: number
|
|
49
52
|
/** URL arrangement provided by narrow standalone navigation adapter. */
|
|
50
53
|
arrange?: CanvasArrangement
|
|
51
54
|
/** Arrangement resolved without an explicit URL override. */
|
|
@@ -81,10 +84,16 @@ const currentStory = computed(() => catalog.value.stories.find(story => story.id
|
|
|
81
84
|
const diagnostics = computed(() => catalog.value.diagnostics.filter(error => error.code === 'COLLECTION_FAILED' && (error.storyId === (currentStory.value?.id ?? cachedStory.value?.id) || error.relativePath === (currentStory.value?.relativePath ?? cachedStory.value?.relativePath))))
|
|
82
85
|
const story = computed(() => currentStory.value ?? (diagnostics.value.length ? cachedStory.value : undefined))
|
|
83
86
|
const settings = useUiSettingsStore()
|
|
84
|
-
const
|
|
87
|
+
const renderedArrange = computed(() => props.arrange)
|
|
88
|
+
const views = useStoryCanvasViews()
|
|
89
|
+
const canvas = createCanvasStore({
|
|
90
|
+
singleViewport: settings?.singleViewport,
|
|
91
|
+
autoFitPreference: views.autoFitPreference,
|
|
92
|
+
storage: getCanvasStorage(typeof window === 'undefined' ? undefined : window),
|
|
93
|
+
frameSizeFromCode: () => renderedArrange.value !== 'single' && isBuiltinCanvasArrangement(renderedArrange.value) ? storyFrameSize(views, story.value) : undefined,
|
|
94
|
+
})
|
|
85
95
|
const registry = createCanvasFrames(canvas)
|
|
86
96
|
const frameState = createCanvasFrameState(session)
|
|
87
|
-
const renderedArrange = computed(() => props.arrange)
|
|
88
97
|
const activeView = useCanvasViewDescriptor(() => renderedArrange.value)
|
|
89
98
|
/** Failure belongs to the hidden runtime; usable axes still take precedence in Matrix. */
|
|
90
99
|
const matrixDiscoveryFailed = ref(false)
|
|
@@ -97,10 +106,20 @@ const viewBinding = bindStoryCanvasView({
|
|
|
97
106
|
hasArrangementOverride: () => props.arrangementOverride,
|
|
98
107
|
getSyncZoom: () => settings?.state.syncZoom ?? false,
|
|
99
108
|
canvas,
|
|
100
|
-
views
|
|
109
|
+
views,
|
|
101
110
|
})
|
|
102
|
-
const { size, frameContentSize } = useCanvasVariantSize(canvas)
|
|
103
|
-
|
|
111
|
+
const { size, frameContentSize, viewportContentSize } = useCanvasVariantSize(canvas)
|
|
112
|
+
/** Story gutter around each frame, else the project one; unusable values leave none. */
|
|
113
|
+
const framePadding = computed(() => {
|
|
114
|
+
const value = story.value?.layout?.padding ?? props.framePadding
|
|
115
|
+
return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : 0
|
|
116
|
+
})
|
|
117
|
+
/** Frame chrome includes the gutter on both sides of the variant. */
|
|
118
|
+
function paddedFrameSize(variantId: string) {
|
|
119
|
+
const content = frameContentSize(variantId)
|
|
120
|
+
return { width: content.width + framePadding.value * 2, height: content.height + framePadding.value * 2 }
|
|
121
|
+
}
|
|
122
|
+
const { area: singleArea, size: singleSize, measure: measureSingle } = useSingleVariantGeometry(canvas, { settings: () => snapshot.value.settings, inspectorWidth: () => props.inspectorWidth, hidden: () => props.uiHidden, contentSize: () => canvas.autoFitContent ? viewportContentSize(selectedVariantId.value) : undefined, padding: () => framePadding.value })
|
|
104
123
|
/** Reuse arrangement geometry for rendering and target-zoom selection fitting; custom views lay out their own leases. */
|
|
105
124
|
function layoutFrames(zoom = canvas.effectiveZoom) {
|
|
106
125
|
if (activeView.id.value) return []
|
|
@@ -108,7 +127,7 @@ function layoutFrames(zoom = canvas.effectiveZoom) {
|
|
|
108
127
|
const variantId = selectedVariantId.value ?? (diagnostics.value.length ? cachedVariantId.value : null)
|
|
109
128
|
return selectedSingleFrame(story.value, variantId, singleSize.value)
|
|
110
129
|
}
|
|
111
|
-
return story.value ? layoutCanvasFrames(story.value.id, story.value.variants.map(variant => variant.id),
|
|
130
|
+
return story.value ? layoutCanvasFrames(story.value.id, story.value.variants.map(variant => variant.id), paddedFrameSize, renderedArrange.value === 'list' ? 'list' : 'grid', 3, zoom) : []
|
|
112
131
|
}
|
|
113
132
|
/** Resolve selection-fit geometry by stable target after visible-frame filtering. */
|
|
114
133
|
function fitBoundsForFrame(frame: CanvasFrameLayout, zoom: number): CanvasFrameLayout {
|
|
@@ -260,12 +279,12 @@ defineExpose({ canvas, registry, getFrameLayout: (id: string) => frames.value.fi
|
|
|
260
279
|
<CanvasHeader :story="story" :can-open-in-editor="canOpenInEditor" @open-in-editor="openInEditor" />
|
|
261
280
|
</slot>
|
|
262
281
|
</div>
|
|
263
|
-
<CanvasSingleVariant v-if="renderedArrange === 'single' && story" ref="singleVariant" :area="singleArea" :frame="selectedFrame" :variant="selectedVariant" :preview-base="previewBase" :stale="diagnostics.length > 0" :resizable="singleResizable" @resize="resizeSingleViewport" @contextmenu="(event, target) => emit('contextmenu', event, target)" />
|
|
282
|
+
<CanvasSingleVariant v-if="renderedArrange === 'single' && story" ref="singleVariant" :area="singleArea" :frame="selectedFrame" :variant="selectedVariant" :preview-base="previewBase" :stale="diagnostics.length > 0" :resizable="singleResizable" :padding="framePadding" @resize="resizeSingleViewport" @contextmenu="(event, target) => emit('contextmenu', event, target)" />
|
|
264
283
|
<PluginCanvasView v-else-if="activeView.id.value" :key="activeView.id.value" :view="activeView.view.value" :presence="activeView.presence.value" :context="viewContext" :workbench="activeView.workbench" />
|
|
265
|
-
<slot v-else-if="renderedArrange === 'matrix'" name="matrix" :canvas="canvas" :frames="registry" :size="size" :content-insets="contentInsets" :preview-base="previewBase" :discovery-failed="matrixDiscoveryFailed" />
|
|
284
|
+
<slot v-else-if="renderedArrange === 'matrix'" name="matrix" :canvas="canvas" :frames="registry" :size="size" :padding="framePadding" :content-insets="contentInsets" :preview-base="previewBase" :discovery-failed="matrixDiscoveryFailed" />
|
|
266
285
|
<component :is="renderedArrange === 'list' ? FrameList : FrameGrid" v-else :frames="renderedFrames">
|
|
267
286
|
<template #default="{ frame }">
|
|
268
|
-
<CanvasFrame :frame="frame" :fit-bounds="zoom => fitBoundsForFrame(frame, zoom)" :variant="variantsById.get(frame.variantId)!" :selected="frame.id === selectedFrame?.id" :live="live.has(frame.id)" :preview-base="previewBase" :
|
|
287
|
+
<CanvasFrame :frame="frame" :fit-bounds="zoom => fitBoundsForFrame(frame, zoom)" :variant="variantsById.get(frame.variantId)!" :selected="frame.id === selectedFrame?.id" :live="live.has(frame.id)" :preview-base="previewBase" :padding="framePadding" :fixed-size="!!canvas.frameSizeFromCode" :stale="diagnostics.length > 0" v-bind="{ ...frameContentSize(frame.variantId), ...getSearchFrameState(frame.id, !!searchActive, highlightedTargets) }" @select="selectVariant" @contextmenu="(event, target) => emit('contextmenu', event, target)" />
|
|
269
288
|
</template>
|
|
270
289
|
</component>
|
|
271
290
|
<CanvasMatrixPrimary :active="renderedArrange === 'matrix'" :preview-base="previewBase" :width="size.width" :height="size.height" @status="matrixDiscoveryFailed = $event === 'error'" @error="emit('error', $event)" />
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { CanvasBackground } from '../../util/background.js'
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import { usePresetConfigStore } from '../../stores/presets-config.js'
|
|
5
|
+
import { getBackgroundContrastColor } from '../../util/background.js'
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{
|
|
8
|
+
/** Variant width in screen pixels. */
|
|
9
|
+
width: number
|
|
10
|
+
/** Variant height in screen pixels. */
|
|
11
|
+
height: number
|
|
12
|
+
/** Gutter around the variant in screen pixels. */
|
|
13
|
+
padding: number
|
|
14
|
+
/** Frame background; its contrast color tints the marks, else the workbench text color. */
|
|
15
|
+
background: CanvasBackground
|
|
16
|
+
}>()
|
|
17
|
+
|
|
18
|
+
const presets = usePresetConfigStore()
|
|
19
|
+
const color = computed(() => getBackgroundContrastColor(props.background, presets?.backgroundPresets.value ?? []))
|
|
20
|
+
|
|
21
|
+
/** Distance between a mark and the variant edge it extends. */
|
|
22
|
+
const GAP = 6
|
|
23
|
+
/** Longest mark, kept inside the gutter. */
|
|
24
|
+
const MAX_LENGTH = 4
|
|
25
|
+
|
|
26
|
+
/** Crop marks extend each variant corner outward, horizontally and vertically. */
|
|
27
|
+
const path = computed(() => {
|
|
28
|
+
const length = Math.min(MAX_LENGTH, props.padding - GAP * 2)
|
|
29
|
+
if (length < 2) return ''
|
|
30
|
+
const left = Math.round(props.padding) + 0.5
|
|
31
|
+
const top = left
|
|
32
|
+
const right = Math.round(props.padding + props.width) - 0.5
|
|
33
|
+
const bottom = Math.round(props.padding + props.height) - 0.5
|
|
34
|
+
return ([[left, top, -1, -1], [right, top, 1, -1], [left, bottom, -1, 1], [right, bottom, 1, 1]] as const)
|
|
35
|
+
.map(([x, y, dx, dy]) => `M${x + dx * GAP} ${y}h${dx * length}M${x} ${y + dy * GAP}v${dy * length}`)
|
|
36
|
+
.join('')
|
|
37
|
+
})
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<svg v-if="path" class="histoire-frame-aligners htw:absolute htw:inset-0 htw:size-full htw:pointer-events-none htw:text-text htw:opacity-15 htw:z-[1]" :style="{ color }" aria-hidden="true">
|
|
42
|
+
<path :d="path" fill="none" stroke="currentColor" stroke-width="1" shape-rendering="crispEdges" />
|
|
43
|
+
</svg>
|
|
44
|
+
</template>
|
|
@@ -15,6 +15,8 @@ const props = defineProps<{
|
|
|
15
15
|
size: SingleResizeSize
|
|
16
16
|
/** Current fixed display scale. */
|
|
17
17
|
zoom: number
|
|
18
|
+
/** Story gutter between frame edge and viewport, in logical pixels. */
|
|
19
|
+
inset?: number
|
|
18
20
|
}>()
|
|
19
21
|
|
|
20
22
|
const emit = defineEmits<{
|
|
@@ -46,6 +48,7 @@ watch([surfaceBounds.left, surfaceBounds.top, surfaceBounds.width, surfaceBounds
|
|
|
46
48
|
|
|
47
49
|
const controller = createSingleResizeController({
|
|
48
50
|
getSize: () => props.size,
|
|
51
|
+
getInset: () => props.inset ?? 0,
|
|
49
52
|
getGeometry: () => {
|
|
50
53
|
if (!props.surface || !props.frame) return
|
|
51
54
|
const surface = props.surface.getBoundingClientRect()
|
|
@@ -13,8 +13,10 @@ const LIST_FRAME_GAP = GRID_FRAME_GAP + 64
|
|
|
13
13
|
|
|
14
14
|
/** Canvas identity stays stable when mounted frames change. */
|
|
15
15
|
export interface CanvasFrameLayout extends CanvasRect {
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/** Logical card body height before adding the Grid or List title reserve. */
|
|
17
|
+
bodyHeight?: number
|
|
18
|
+
/** Individual frame bounds for live document admission and startup priority. */
|
|
19
|
+
runtimeBounds?: CanvasRect
|
|
18
20
|
/** Stable key scoped to story and variant. */
|
|
19
21
|
id: string
|
|
20
22
|
/** Collected story identity. */
|
|
@@ -33,7 +35,10 @@ export function keepFrameLayouts(previous: CanvasFrameLayout[] | undefined, next
|
|
|
33
35
|
for (let index = 0; index < next.length; index++) {
|
|
34
36
|
const a = previous[index]
|
|
35
37
|
const b = next[index]
|
|
36
|
-
if (a.id !== b.id || a.x !== b.x || a.y !== b.y || a.width !== b.width || a.height !== b.height || a.
|
|
38
|
+
if (a.id !== b.id || a.x !== b.x || a.y !== b.y || a.width !== b.width || a.height !== b.height || a.bodyHeight !== b.bodyHeight || a.storyId !== b.storyId || a.variantId !== b.variantId) return next
|
|
39
|
+
const first = a.runtimeBounds
|
|
40
|
+
const second = b.runtimeBounds
|
|
41
|
+
if (first?.x !== second?.x || first?.y !== second?.y || first?.width !== second?.width || first?.height !== second?.height) return next
|
|
37
42
|
}
|
|
38
43
|
return previous
|
|
39
44
|
}
|
|
@@ -51,20 +56,31 @@ export function layoutCanvasFrames(storyId: string, variantIds: readonly string[
|
|
|
51
56
|
const heights = Array.from({ length: Math.ceil(variantIds.length / count) }, () => 0)
|
|
52
57
|
sizes.forEach((size, index) => {
|
|
53
58
|
widths[index % count] = Math.max(widths[index % count], size.width)
|
|
54
|
-
|
|
59
|
+
const row = Math.floor(index / count)
|
|
60
|
+
heights[row] = Math.max(heights[row], size.height)
|
|
55
61
|
})
|
|
56
62
|
const xs = canvasTrackOffsets(widths, GRID_FRAME_GAP / scale)
|
|
57
|
-
const ys = canvasTrackOffsets(heights, gap)
|
|
58
|
-
return variantIds.map((variantId, index) =>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
width:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
const ys = canvasTrackOffsets(heights, labelHeight + gap)
|
|
64
|
+
return variantIds.map((variantId, index) => {
|
|
65
|
+
const column = index % count
|
|
66
|
+
const row = Math.floor(index / count)
|
|
67
|
+
const x = xs[column]
|
|
68
|
+
const y = ys[row]
|
|
69
|
+
const { width, height } = sizes[index]
|
|
70
|
+
const cardWidth = list ? width : widths[column]
|
|
71
|
+
const bodyHeight = heights[row]
|
|
72
|
+
return {
|
|
73
|
+
id: getHistoireTargetKey({ storyId, variantId }),
|
|
74
|
+
storyId,
|
|
75
|
+
variantId,
|
|
76
|
+
x,
|
|
77
|
+
y,
|
|
78
|
+
width: cardWidth,
|
|
79
|
+
height: bodyHeight + labelHeight,
|
|
80
|
+
bodyHeight,
|
|
81
|
+
runtimeBounds: cardWidth === width && bodyHeight === height ? undefined : { x, y, width, height: height + labelHeight },
|
|
82
|
+
}
|
|
83
|
+
})
|
|
68
84
|
}
|
|
69
85
|
|
|
70
86
|
/** Accumulate unequal tracks once rather than summing preceding sizes for every cell. */
|
|
@@ -96,7 +112,7 @@ export function visibleCanvasFrames(frames: readonly CanvasFrameLayout[], viewpo
|
|
|
96
112
|
let high = frames.length
|
|
97
113
|
while (low < high) {
|
|
98
114
|
const middle = Math.floor((low + high) / 2)
|
|
99
|
-
if (
|
|
115
|
+
if (frames[middle].y + frames[middle].height <= viewport.y) low = middle + 1
|
|
100
116
|
else high = middle
|
|
101
117
|
}
|
|
102
118
|
const start = low
|
|
@@ -119,15 +135,18 @@ function visibleArea(frame: CanvasRect, viewport: CanvasRect): number {
|
|
|
119
135
|
return width * height
|
|
120
136
|
}
|
|
121
137
|
|
|
122
|
-
/** Admit selected frame first, then
|
|
138
|
+
/** Admit selected frame first, then by visible content area, up to the live budget. */
|
|
123
139
|
export function liveCanvasFrames(frames: readonly CanvasFrameLayout[], viewport: CanvasRect, budget: number, selected: string | null, margin = 160): Set<string> {
|
|
124
140
|
const limit = Math.max(1, Math.floor(Number.isFinite(budget) ? budget : 1))
|
|
125
141
|
const selectedFrame = frames.find(frame => frame.id === selected)
|
|
126
142
|
const intersectsMargin = (frame: CanvasRect) => frame.x + frame.width >= viewport.x - margin && frame.x <= viewport.x + viewport.width + margin
|
|
127
143
|
&& frame.y + frame.height >= viewport.y - margin && frame.y <= viewport.y + viewport.height + margin
|
|
128
144
|
const candidates = frames
|
|
129
|
-
.
|
|
130
|
-
|
|
145
|
+
.flatMap((frame, index) => {
|
|
146
|
+
const bounds = frame.runtimeBounds ?? frame
|
|
147
|
+
if (frame === selectedFrame || !intersectsMargin(bounds)) return []
|
|
148
|
+
return [{ frame, index, area: visibleArea(bounds, viewport) }]
|
|
149
|
+
})
|
|
131
150
|
// Layout order makes ties deterministic and lets margin-only frames prefetch predictably.
|
|
132
151
|
.sort((first, second) => second.area - first.area || first.index - second.index)
|
|
133
152
|
return new Set([...(selectedFrame ? [selectedFrame] : []), ...candidates.map(candidate => candidate.frame)].slice(0, limit).map(frame => frame.id))
|
|
@@ -143,12 +162,14 @@ export function rankCanvasStartupFrames(frames: readonly CanvasFrameLayout[], ad
|
|
|
143
162
|
// Without a selection, admission order already encodes visible-area and layout priority.
|
|
144
163
|
const anchorId = selectedFrameId && admitted.includes(selectedFrameId) ? selectedFrameId : admitted[0]
|
|
145
164
|
const anchor = byId.get(anchorId)!
|
|
146
|
-
const
|
|
147
|
-
const
|
|
165
|
+
const anchorBounds = anchor.runtimeBounds ?? anchor
|
|
166
|
+
const centerX = anchorBounds.x + anchorBounds.width / 2
|
|
167
|
+
const centerY = anchorBounds.y + anchorBounds.height / 2
|
|
148
168
|
const distances = new Map<string, number>(admitted.map((id): [string, number] => {
|
|
149
169
|
const frame = byId.get(id)!
|
|
150
|
-
const
|
|
151
|
-
const
|
|
170
|
+
const bounds = frame.runtimeBounds ?? frame
|
|
171
|
+
const dx = bounds.x + bounds.width / 2 - centerX
|
|
172
|
+
const dy = bounds.y + bounds.height / 2 - centerY
|
|
152
173
|
return [id, dx * dx + dy * dy]
|
|
153
174
|
}))
|
|
154
175
|
|
|
@@ -21,7 +21,7 @@ export interface CanvasPropsOverrideController {
|
|
|
21
21
|
receive: (event: MessageEvent) => void
|
|
22
22
|
/** Send current complete override set, replacing any prior pending request. */
|
|
23
23
|
update: () => void
|
|
24
|
-
/** Wait for the
|
|
24
|
+
/** Wait for the latest override acknowledgement, following superseding requests. */
|
|
25
25
|
wait: () => Promise<void>
|
|
26
26
|
/** Clear its timeout and reject any pending wait during component teardown. */
|
|
27
27
|
dispose: () => void
|
|
@@ -79,6 +79,20 @@ export function createCanvasPropsOverrideController(options: CanvasPropsOverride
|
|
|
79
79
|
}, 3000)
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/** Startup may resend a projection while content sizing is already waiting. */
|
|
83
|
+
async function wait(): Promise<void> {
|
|
84
|
+
let pending: Promise<void>
|
|
85
|
+
do {
|
|
86
|
+
pending = readiness
|
|
87
|
+
try {
|
|
88
|
+
await pending
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
if (pending === readiness) throw error
|
|
92
|
+
}
|
|
93
|
+
} while (pending !== readiness)
|
|
94
|
+
}
|
|
95
|
+
|
|
82
96
|
/** Reject a pending source read when its owning component retires. */
|
|
83
97
|
function dispose(): void {
|
|
84
98
|
clearTimeout(timeout)
|
|
@@ -88,7 +102,7 @@ export function createCanvasPropsOverrideController(options: CanvasPropsOverride
|
|
|
88
102
|
return {
|
|
89
103
|
receive,
|
|
90
104
|
update,
|
|
91
|
-
wait
|
|
105
|
+
wait,
|
|
92
106
|
dispose,
|
|
93
107
|
}
|
|
94
108
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { MatrixCellData } from '../../../util/matrix.js'
|
|
3
|
-
import type { CanvasFrameLayout } from '../frame-layout.js'
|
|
4
3
|
import type { CanvasRect } from '../pan/usePanZoom.js'
|
|
4
|
+
import type { MatrixFrameLayout } from './matrix-layout.js'
|
|
5
5
|
import { HstButton, useLoadingDelay } from '@histoire/controls/vue'
|
|
6
6
|
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
|
7
7
|
import { useCanvasFrameBackground, useCanvasFrames, useCanvasStore } from '../../../composables/canvas-settings.js'
|
|
@@ -12,13 +12,14 @@ import { formatMatrixValue } from '../../../util/matrix-values.js'
|
|
|
12
12
|
import CanvasLoadingIndicator from '../CanvasLoadingIndicator.vue'
|
|
13
13
|
import CanvasReplicaPreview from '../CanvasReplicaPreview.vue'
|
|
14
14
|
import { isFrameMenuShortcut, openFrameMenu } from '../frame-menu.js'
|
|
15
|
+
import FramePaddingAligners from '../FramePaddingAligners.vue'
|
|
15
16
|
import { watchMatrixFrameRegistration } from './matrix-registration.js'
|
|
16
17
|
|
|
17
18
|
const props = defineProps<{
|
|
18
19
|
/** Local Cartesian data and merged override set. */
|
|
19
20
|
cell: MatrixCellData
|
|
20
|
-
/**
|
|
21
|
-
frame:
|
|
21
|
+
/** Track-sized card and intrinsic sandbox bounds. */
|
|
22
|
+
frame: MatrixFrameLayout
|
|
22
23
|
/** Cell coordinates at selection's candidate zoom, preserving fixed matrix gaps. */
|
|
23
24
|
fitBounds?: (zoom: number) => CanvasRect
|
|
24
25
|
/** Whether budget admits a passive preview document. */
|
|
@@ -27,6 +28,10 @@ const props = defineProps<{
|
|
|
27
28
|
variantId: string
|
|
28
29
|
/** Absolute first-party source URL. */
|
|
29
30
|
previewBase: string
|
|
31
|
+
/** Gutter around the variant inside the cell, in logical pixels. */
|
|
32
|
+
padding?: number
|
|
33
|
+
/** Story declares the variant size, so the document gets it instead of viewport settings. */
|
|
34
|
+
fixedSize?: boolean
|
|
30
35
|
}>()
|
|
31
36
|
const canvas = useCanvasStore()
|
|
32
37
|
const background = useCanvasFrameBackground(() => props.frame.id)
|
|
@@ -38,7 +43,14 @@ const status = ref<'loading' | 'ready' | 'error'>('loading')
|
|
|
38
43
|
const loadingVisible = useLoadingDelay(() => status.value === 'loading', () => props.frame.id)
|
|
39
44
|
const error = ref<unknown>()
|
|
40
45
|
const position = computed(() => ({ left: `${props.frame.x * canvas.effectiveZoom + canvas.panOffset.x}px`, top: `${props.frame.y * canvas.effectiveZoom + canvas.panOffset.y}px`, width: `${props.frame.width * canvas.effectiveZoom}px`, height: `${props.frame.height * canvas.effectiveZoom}px` }))
|
|
41
|
-
const
|
|
46
|
+
const gutter = computed(() => props.padding ?? 0)
|
|
47
|
+
/** Variant bounds inside the gutter; measuring and comments target these. */
|
|
48
|
+
const inner = computed(() => props.frame.contentRect)
|
|
49
|
+
const contentStyle = computed(() => ({
|
|
50
|
+
width: `${inner.value.width}px`,
|
|
51
|
+
height: `${inner.value.height}px`,
|
|
52
|
+
transform: `translate(${gutter.value * canvas.effectiveZoom}px, ${gutter.value * canvas.effectiveZoom}px) scale(${canvas.effectiveZoom})`,
|
|
53
|
+
}))
|
|
42
54
|
let releaseSource = () => {}
|
|
43
55
|
const unregister = watchMatrixFrameRegistration({ registry, getFrame: () => props.frame, getFitBounds: zoom => props.fitBounds?.(zoom) ?? props.frame, getVariantId: () => props.variantId, getPropsOverride: () => props.cell.props, onTargetChange: () => {
|
|
44
56
|
releaseSource()
|
|
@@ -82,9 +94,10 @@ onBeforeUnmount(() => {
|
|
|
82
94
|
|
|
83
95
|
<template>
|
|
84
96
|
<section class="histoire-matrix-cell htw:absolute htw:overflow-hidden htw:border htw:border-solid htw:border-border htw:rounded-[7px] htw:bg-white htw:pointer-events-auto htw:data-[selected=true]:outline-2 htw:data-[selected=true]:outline-solid htw:data-[selected=true]:outline-accent htw:data-[selected=true]:-outline-offset-1" :style="{ ...position, ...getBackgroundStyle(background) }" :data-frame-id="frame.id" :data-selected="matrix.selectedCell.value?.key === cell.key" @contextmenu="openMenu">
|
|
85
|
-
<div class="histoire-matrix-cell-content htw:origin-top-left" :style="
|
|
86
|
-
<CanvasReplicaPreview v-if="live" :key="variantId" ref="preview" :frame-id="frame.id" :story-id="frame.storyId" :variant-id="variantId" :preview-base="previewBase" :props-override="cell.props" @status="updateStatus" />
|
|
97
|
+
<div class="histoire-matrix-cell-content htw:origin-top-left" :style="contentStyle">
|
|
98
|
+
<CanvasReplicaPreview v-if="live" :key="variantId" ref="preview" :frame-id="frame.id" :story-id="frame.storyId" :variant-id="variantId" :preview-base="previewBase" :props-override="cell.props" :declared-size="fixedSize ? { width: inner.width, height: inner.height } : undefined" @status="updateStatus" />
|
|
87
99
|
</div>
|
|
100
|
+
<FramePaddingAligners v-if="gutter > 0" :width="inner.width * canvas.effectiveZoom" :height="inner.height * canvas.effectiveZoom" :padding="gutter * canvas.effectiveZoom" :background="background" />
|
|
88
101
|
<button class="histoire-matrix-cell-select htw:absolute htw:inset-0 htw:w-full htw:m-0 htw:p-0 htw:border-0 htw:rounded-[inherit] htw:bg-transparent htw:cursor-pointer htw:[appearance:none] htw:focus-visible:outline-2 htw:focus-visible:outline-solid htw:focus-visible:outline-accent htw:focus-visible:-outline-offset-[3px]" type="button" :aria-label="`Select matrix cell ${formatMatrixValue(cell.row)} · ${formatMatrixValue(cell.col)}`" :aria-pressed="matrix.selectedCell.value?.key === cell.key" @click="matrix.selectCell(cell.key)" @keydown="onKeyDown" />
|
|
89
102
|
<span v-if="!live" class="htw:absolute htw:inset-0 htw:grid htw:[place-content:center] htw:gap-2 htw:p-3 htw:text-muted htw:bg-input htw:text-[11px] htw:text-center htw:pointer-events-none">Not rendered</span>
|
|
90
103
|
<div v-else-if="loadingVisible" class="histoire-matrix-cell-loading htw:absolute htw:inset-0 htw:grid htw:[place-content:center] htw:gap-2 htw:p-3 htw:text-muted htw:bg-input htw:text-[11px] htw:text-center htw:pointer-events-none" role="status" aria-label="Loading variant">
|