@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
|
@@ -15,19 +15,27 @@ const props = defineProps<{
|
|
|
15
15
|
}>()
|
|
16
16
|
const store = useMarketplaceStore()
|
|
17
17
|
/** Prefer the compatible installed update over the latest catalog release. */
|
|
18
|
-
const target = computed(() => props.plugin.installed?.update ?? props.plugin.latest)
|
|
18
|
+
const target = computed(() => props.plugin.installed?.update ?? props.plugin.installVersion ?? props.plugin.latest)
|
|
19
19
|
/** Main action reflects installation state and its exact target version. */
|
|
20
20
|
const label = computed(() => props.plugin.installed ? props.plugin.installed.update ? `Update to ${target.value}` : `Installed ${props.plugin.installed.version}` : 'Install')
|
|
21
|
-
/** Installed packages without
|
|
22
|
-
const
|
|
21
|
+
/** Installed packages without a suggested update retain their existing management actions. */
|
|
22
|
+
const installedWithoutUpdate = computed(() => Boolean(props.plugin.installed && !props.plugin.installed.update))
|
|
23
|
+
const disabled = computed(() => installedWithoutUpdate.value || Boolean(versionReason(target.value)))
|
|
24
|
+
const menuDisabled = computed(() => installedWithoutUpdate.value || (disabled.value && props.plugin.versions.every(version => reason(version))))
|
|
23
25
|
|
|
24
26
|
/** Show the server's version-specific incompatibility in disabled menu items. */
|
|
25
27
|
function reason(version: PluginDetail['versions'][number]): string | undefined {
|
|
26
28
|
return version.compatible ? undefined : incompatibleReason(version.reason)
|
|
27
29
|
}
|
|
30
|
+
/** Resolve a suggested target independently of the listing's compatibility verdict. */
|
|
31
|
+
function versionReason(version: string): string | undefined {
|
|
32
|
+
if (version === props.plugin.latest && !props.plugin.compatible.ok) return incompatibleReason(props.plugin.compatible.reason)
|
|
33
|
+
const row = props.plugin.versions.find(item => item.version === version)
|
|
34
|
+
return row ? reason(row) : undefined
|
|
35
|
+
}
|
|
28
36
|
/** Start a wizard only; project changes still require the later review action. */
|
|
29
37
|
function install(version = target.value): void {
|
|
30
|
-
if (
|
|
38
|
+
if (installedWithoutUpdate.value || versionReason(version)) return
|
|
31
39
|
store.startInstall({ id: props.plugin.id, kind: props.plugin.installed ? 'update' : 'install', version, prefs: { ...store.prefs.value, skippedVersions: { ...store.prefs.value.skippedVersions } } })
|
|
32
40
|
}
|
|
33
41
|
|
|
@@ -67,7 +75,7 @@ function browseCategory(): void {
|
|
|
67
75
|
Installed {{ plugin.installed.version }}
|
|
68
76
|
</p>
|
|
69
77
|
</div>
|
|
70
|
-
<WorkbenchPanelAction icon="add-alt" :label="label" :disabled="disabled" menu-label="Choose version" :menu-width="280" @click="install()">
|
|
78
|
+
<WorkbenchPanelAction icon="add-alt" :label="label" :disabled="disabled" :menu-disabled="menuDisabled" menu-label="Choose version" :menu-width="280" @click="install()">
|
|
71
79
|
<template v-if="plugin.versions.length" #menu="{ close }">
|
|
72
80
|
<MenuItem v-for="version in plugin.versions" :key="version.version" :label="version.version" :disabled="reason(version)" @click="install(version.version); close()" />
|
|
73
81
|
</template>
|
|
@@ -50,11 +50,16 @@ export function useInstallWizard() {
|
|
|
50
50
|
detail.value = undefined
|
|
51
51
|
error.value = undefined
|
|
52
52
|
try {
|
|
53
|
-
const
|
|
53
|
+
const options = { signal: current.signal, version: change.version }
|
|
54
|
+
let result = await store.client.detail(change.id, change.prefs, options)
|
|
55
|
+
if (!change.version && change.kind === 'install' && result.installVersion) {
|
|
56
|
+
result = await store.client.detail(change.id, change.prefs, { ...options, version: result.installVersion })
|
|
57
|
+
}
|
|
54
58
|
if (current.signal.aborted) return
|
|
55
59
|
values.value = Object.fromEntries((result.manifest.config.options ?? []).filter(field => field.default !== undefined).map(field => [field.key, structuredClone(field.default!)]))
|
|
56
60
|
Object.assign(values.value, change.options)
|
|
57
|
-
|
|
61
|
+
const version = change.version ?? (change.kind === 'install' ? result.latest : undefined)
|
|
62
|
+
intent.value = { ...change, ...(version ? { version } : {}), prefs: { ...change.prefs } }
|
|
58
63
|
detail.value = result
|
|
59
64
|
}
|
|
60
65
|
catch (cause) {
|
|
@@ -96,7 +96,7 @@ onBeforeUnmount(() => document.removeEventListener('pointerdown', outside, true)
|
|
|
96
96
|
|
|
97
97
|
<template>
|
|
98
98
|
<Teleport :to="overlay">
|
|
99
|
-
<div v-if="target && actions.length" ref="menu" class="histoire-context-menu histoire-control-popover htw:fixed htw:z-60 htw:w-[264px] htw:max-w-[calc(100vw-16px)] htw:max-h-[calc(100vh-16px)] htw:p-[5px]" role="menu" :aria-label="label" :style="{ left: `${position.left}px`, top: `${position.top}px` }" @keydown="keyboard">
|
|
99
|
+
<div v-if="target && actions.length" ref="menu" class="histoire-context-menu histoire-control-popover htw:fixed htw:z-60 htw:w-[264px] htw:max-w-[calc(100vw-16px)] htw:max-h-[calc(100vh-16px)] htw:p-[5px] htw:menu-rows" role="menu" :aria-label="label" :style="{ left: `${position.left}px`, top: `${position.top}px` }" @keydown="keyboard">
|
|
100
100
|
<p class="htw:mt-[7px] htw:mx-[9px] htw:mb-[9px] htw:truncate htw:text-muted htw:text-[11px] htw:font-bold">
|
|
101
101
|
{{ label }}
|
|
102
102
|
</p>
|
|
@@ -41,7 +41,7 @@ function keyboard(event: KeyboardEvent) {
|
|
|
41
41
|
<template>
|
|
42
42
|
<div ref="root">
|
|
43
43
|
<MenuItem :label="action.label" :icon="action.icon" submenu :ai="action.group === 'ai'" :aria-expanded="open" @click="show" @keydown.right.prevent.stop="show" />
|
|
44
|
-
<div v-if="open" ref="menu" class="histoire-submenu-panel histoire-control-popover htw:fixed htw:z-[61] htw:w-60 htw:max-w-[calc(100vw-16px)] htw:p-[5px]" role="menu" :aria-label="action.label" :style="{ left: `${position.left}px`, top: `${position.top}px` }" @keydown="keyboard">
|
|
44
|
+
<div v-if="open" ref="menu" class="histoire-submenu-panel histoire-control-popover htw:fixed htw:z-[61] htw:w-60 htw:max-w-[calc(100vw-16px)] htw:p-[5px] htw:menu-rows" role="menu" :aria-label="action.label" :style="{ left: `${position.left}px`, top: `${position.top}px` }" @keydown="keyboard">
|
|
45
45
|
<MenuItem v-for="item in items" :key="item.id" :label="item.label" :icon="item.icon" :disabled="item.disabled?.(target)" :shortcut="item.shortcut ? shortcuts?.hint(item.shortcut) : undefined" :ai="item.group === 'ai'" @click="emit('action', item)" />
|
|
46
46
|
</div>
|
|
47
47
|
</div>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { InstalledPlugin } from './plugins/types.js'
|
|
3
3
|
import { BuiltinIcon, HstButton, HstPulsatingDisc } from '@histoire/controls/vue'
|
|
4
4
|
import { installedPlugins } from 'virtual:$histoire-config'
|
|
5
|
+
import { onMounted } from 'vue'
|
|
5
6
|
import { useContributionLookup } from '../../../composables/shell-extensions.js'
|
|
6
7
|
import { useMarketplaceStore } from '../../../stores/marketplace.js'
|
|
7
8
|
import WorkbenchEmptyState from '../../shell/WorkbenchEmptyState.vue'
|
|
@@ -18,6 +19,9 @@ const props = withDefaults(defineProps<{
|
|
|
18
19
|
const dev = props.dev
|
|
19
20
|
const store = useMarketplaceStore()
|
|
20
21
|
const updates = store.updates
|
|
22
|
+
onMounted(() => {
|
|
23
|
+
void updates.refresh()
|
|
24
|
+
})
|
|
21
25
|
const jobs = store.settingsJobs
|
|
22
26
|
const manager = usePackageManager(store, dev)
|
|
23
27
|
const sections = useContributionLookup('settings.section')
|
|
@@ -15,7 +15,7 @@ export function createPluginUpdates(store: MarketplaceServiceOwner, dev: boolean
|
|
|
15
15
|
catch { /* Receipt acknowledgement is optional when storage is blocked. */ }
|
|
16
16
|
let connected = false
|
|
17
17
|
let disposed = false
|
|
18
|
-
let cached: string | undefined
|
|
18
|
+
let cached: { key: string, refreshedAt: number } | undefined
|
|
19
19
|
let controller: AbortController | undefined
|
|
20
20
|
const available = computed(() => entries.value.filter(item => store.prefs.value.skippedVersions[item.id] !== item.to))
|
|
21
21
|
const count = computed(() => available.value.length)
|
|
@@ -30,7 +30,7 @@ export function createPluginUpdates(store: MarketplaceServiceOwner, dev: boolean
|
|
|
30
30
|
async function refresh(force = false): Promise<void> {
|
|
31
31
|
if (!connected || disposed || !dev) return
|
|
32
32
|
const key = preferenceKey.value
|
|
33
|
-
if (!force && (cached === key
|
|
33
|
+
if (!force && (loading.value || (cached?.key === key && Date.now() - cached.refreshedAt < 3_600_000))) return
|
|
34
34
|
controller?.abort()
|
|
35
35
|
const current = controller = new AbortController()
|
|
36
36
|
loading.value = true
|
|
@@ -39,7 +39,7 @@ export function createPluginUpdates(store: MarketplaceServiceOwner, dev: boolean
|
|
|
39
39
|
const value = await store.client.updates(store.prefs.value, { signal: current.signal })
|
|
40
40
|
if (!current.signal.aborted) {
|
|
41
41
|
entries.value = value
|
|
42
|
-
cached = key
|
|
42
|
+
cached = { key, refreshedAt: Date.now() }
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
catch (cause) {
|
|
@@ -116,7 +116,7 @@ function setSelectedSession(session: HistoireSession | undefined): void {
|
|
|
116
116
|
<template #main>
|
|
117
117
|
<SettingsPage v-if="route.name === 'settings'" :section="typeof route.params.section === 'string' ? route.params.section : undefined" :build-info="buildInfo" @section="workbench.navigate('settings', $event)" />
|
|
118
118
|
<MarkdownPage v-else-if="route.name === 'story' && markdown" :anchor="route.hash" @select="shell.closePanelAfterSelection" @error="emit('error', $event)" />
|
|
119
|
-
<CanvasViewport v-else-if="route.name === 'story'" ref="canvas" :preview-base="previewBase" :frame-budget="histoireConfig.ui?.frameBudget ?? 6" :arrange="arrange" :base-arrange="baseArrange" :arrangement-override="arrangementOverride" :highlighted-targets="highlighted" :search-active="searchActive" :comment-mode="dev?.commentMode.value" :ui-hidden="shell.uiHidden.value" :inspector-width="!shell.uiHidden.value && shell.inspectorOpen.value && !shell.narrow.value ? shell.inspectorWidth.value + 24 : 0" @selected-session="setSelectedSession" @frame-pointer="dev?.pickComment($event)" @error="emit('error', $event)">
|
|
119
|
+
<CanvasViewport v-else-if="route.name === 'story'" ref="canvas" :preview-base="previewBase" :frame-budget="histoireConfig.ui?.frameBudget ?? 6" :frame-padding="histoireConfig.ui?.framePadding" :arrange="arrange" :base-arrange="baseArrange" :arrangement-override="arrangementOverride" :highlighted-targets="highlighted" :search-active="searchActive" :comment-mode="dev?.commentMode.value" :ui-hidden="shell.uiHidden.value" :inspector-width="!shell.uiHidden.value && shell.inspectorOpen.value && !shell.narrow.value ? shell.inspectorWidth.value + 24 : 0" @selected-session="setSelectedSession" @frame-pointer="dev?.pickComment($event)" @error="emit('error', $event)">
|
|
120
120
|
<template #toolbar>
|
|
121
121
|
<CanvasToolbar :arrange="arrange" :match-count="searchMatches.count.value" :match-position="searchMatches.position.value" @previous-match="workbench.previousMatch" @next-match="workbench.nextMatch" @arrange="workbench.setArrange" @edit-presets="workbench.navigate('settings', 'viewports')" @error="emit('error', $event)">
|
|
122
122
|
<template #screenshot="slot">
|
|
@@ -137,7 +137,7 @@ function setSelectedSession(session: HistoireSession | undefined): void {
|
|
|
137
137
|
</CanvasToolbar>
|
|
138
138
|
</template>
|
|
139
139
|
<template #matrix="slot">
|
|
140
|
-
<MatrixView :rows="rows" :cols="cols" :preview-base="previewBase" :size="slot.size" :content-insets="slot.contentInsets" :ui-hidden="shell.uiHidden.value" :discovery-failed="slot.discoveryFailed" @axes="workbench.setAxes" @add-axis="revealMatrixProps" @error="emit('error', $event)" />
|
|
140
|
+
<MatrixView :rows="rows" :cols="cols" :preview-base="previewBase" :size="slot.size" :padding="slot.padding" :content-insets="slot.contentInsets" :ui-hidden="shell.uiHidden.value" :discovery-failed="slot.discoveryFailed" @axes="workbench.setAxes" @add-axis="revealMatrixProps" @error="emit('error', $event)" />
|
|
141
141
|
</template>
|
|
142
142
|
<template #overlays>
|
|
143
143
|
<CommentsCanvasOverlay v-if="CommentsCanvasOverlay && dev" ref="commentOverlay" :model="dev.threads" :agents="dev.commentAgents.value" :active="dev.commentMode.value" @setup-agent="dev.setupAgents" />
|
|
@@ -4,18 +4,20 @@ import { computed, ref, shallowRef } from 'vue'
|
|
|
4
4
|
import BasePopover from '../base/popover/BasePopover.vue'
|
|
5
5
|
import { useMenuKeyboard } from '../base/use-menu-keyboard.js'
|
|
6
6
|
|
|
7
|
-
const props = defineProps<{
|
|
7
|
+
const props = withDefaults(defineProps<{
|
|
8
8
|
/** Offline Carbon glyph name shown before label. */
|
|
9
9
|
icon: string
|
|
10
10
|
/** Short visible action label. */
|
|
11
11
|
label: string
|
|
12
12
|
/** Disables main action and options trigger. */
|
|
13
13
|
disabled?: boolean
|
|
14
|
+
/** Override menu availability when the main action is disabled. */
|
|
15
|
+
menuDisabled?: boolean
|
|
14
16
|
/** Accessible name of options trigger and its menu. */
|
|
15
17
|
menuLabel?: string
|
|
16
18
|
/** Options menu width in pixels. */
|
|
17
19
|
menuWidth?: number
|
|
18
|
-
}>()
|
|
20
|
+
}>(), { menuDisabled: undefined })
|
|
19
21
|
const emit = defineEmits<{
|
|
20
22
|
/** Main action activated. */
|
|
21
23
|
click: [event: MouseEvent]
|
|
@@ -43,7 +45,7 @@ const { focusLast, openMenu, navigate } = useMenuKeyboard({ open, anchor: () =>
|
|
|
43
45
|
<BuiltinIcon :icon="icon" :size="16" />{{ label }}
|
|
44
46
|
</HstButton>
|
|
45
47
|
<template v-if="$slots.menu">
|
|
46
|
-
<HstButton ref="chevron" color="primary" type="button" class="htw:rounded-s-none" icon-only :aria-label="resolvedMenuLabel" aria-haspopup="menu" :aria-expanded="open" :disabled="disabled" @click="focusLast = false; open = !open" @keydown="openMenu">
|
|
48
|
+
<HstButton ref="chevron" color="primary" type="button" class="htw:rounded-s-none" icon-only :aria-label="resolvedMenuLabel" aria-haspopup="menu" :aria-expanded="open" :disabled="menuDisabled ?? disabled" @click="focusLast = false; open = !open" @keydown="openMenu">
|
|
47
49
|
<BuiltinIcon icon="chevron-down" :size="16" />
|
|
48
50
|
</HstButton>
|
|
49
51
|
<BasePopover v-if="open" v-model:open="open" :anchor="anchor" :label="resolvedMenuLabel" role="menu" :width="menuWidth ?? 160" :focus-last="focusLast" @keydown="navigate">
|
|
@@ -4,6 +4,7 @@ import type { CanvasFrameState } from '../components/canvas/frame-state.js'
|
|
|
4
4
|
import type { CanvasPoint, CanvasRect } from '../components/canvas/pan/usePanZoom.js'
|
|
5
5
|
import type { usePointerPan } from '../components/canvas/pan/usePointerPan.js'
|
|
6
6
|
import type { CanvasStore } from '../stores/canvas.js'
|
|
7
|
+
import { STORY_REMOUNT } from '@histoire/shared'
|
|
7
8
|
import { useHistoireSnapshot } from '@histoire/vue'
|
|
8
9
|
import { computed, inject, provide, shallowReactive } from 'vue'
|
|
9
10
|
|
|
@@ -27,12 +28,30 @@ export interface CanvasFrameRegistration {
|
|
|
27
28
|
session?: HistoireSession
|
|
28
29
|
/** Complete displayed matrix props; capture snapshots these without canonical mutation. */
|
|
29
30
|
propsOverride?: Record<string, unknown>
|
|
31
|
+
/** Remount requests delivered to this frame, so chrome can acknowledge each one. */
|
|
32
|
+
remounts?: number
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
/** Registry is independent per mounted canvas, including multiple native hosts. */
|
|
33
36
|
export function createCanvasFrames(store: CanvasStore) {
|
|
34
37
|
const frames = shallowReactive(new Map<string, CanvasFrameRegistration>())
|
|
35
|
-
|
|
38
|
+
/** Finite additive preview requests stay pinned to current same-origin document. */
|
|
39
|
+
function postToFrame(id: string, payload: Record<string, unknown>): boolean {
|
|
40
|
+
const frame = frames.get(id)
|
|
41
|
+
if (!frame?.iframe?.contentWindow || !frame.documentId) return false
|
|
42
|
+
const window = frame.iframe.ownerDocument.defaultView
|
|
43
|
+
if (!window) return false
|
|
44
|
+
frame.iframe.contentWindow.postMessage({ ...payload, __histoire: true, documentId: frame.documentId }, window.location.origin)
|
|
45
|
+
return true
|
|
46
|
+
}
|
|
47
|
+
/** Replay the rendered variant's mount lifecycle without reloading its document. */
|
|
48
|
+
function remountFrame(id: string): boolean {
|
|
49
|
+
const frame = frames.get(id)
|
|
50
|
+
if (!frame || !postToFrame(id, { type: STORY_REMOUNT, storyId: frame.storyId, variantId: frame.variantId })) return false
|
|
51
|
+
frame.remounts = (frame.remounts ?? 0) + 1
|
|
52
|
+
return true
|
|
53
|
+
}
|
|
54
|
+
return { frames, postToFrame, remountFrame,
|
|
36
55
|
/** Replacement cleanup cannot remove its successor registration. */
|
|
37
56
|
registerFrame(frame: CanvasFrameRegistration) {
|
|
38
57
|
const record = shallowReactive(frame)
|
|
@@ -57,14 +76,9 @@ export function createCanvasFrames(store: CanvasStore) {
|
|
|
57
76
|
if (!frame || !rect) return null
|
|
58
77
|
return { x: rect.left + point.x * rect.width / frame.rect.width, y: rect.top + point.y * rect.height / frame.rect.height }
|
|
59
78
|
},
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (!frame?.iframe?.contentWindow || !frame.documentId) return false
|
|
64
|
-
const window = frame.iframe.ownerDocument.defaultView
|
|
65
|
-
if (!window) return false
|
|
66
|
-
frame.iframe.contentWindow.postMessage({ ...payload, __histoire: true, documentId: frame.documentId }, window.location.origin)
|
|
67
|
-
return true
|
|
79
|
+
/** Remount every running frame in the same task so their animations start together. */
|
|
80
|
+
remountAll(): number {
|
|
81
|
+
return [...frames.keys()].filter(remountFrame).length
|
|
68
82
|
},
|
|
69
83
|
/** Canvas scale exposed for overlay helpers without leaking root DOM. */
|
|
70
84
|
get zoom() { return store.effectiveZoom } }
|
|
@@ -76,6 +76,7 @@ export function useWorkbench(props: WorkbenchProps, error: (error: unknown) => v
|
|
|
76
76
|
},
|
|
77
77
|
frameSession: target => canvas.value?.registry.getFrame(target.frameKey)?.session ?? null,
|
|
78
78
|
frameRegistration: target => canvas.value?.registry.getFrame(target.frameKey) ?? null,
|
|
79
|
+
remountFrame: target => canvas.value?.registry.remountFrame(target.frameKey) ?? false,
|
|
79
80
|
runTests: target => projectTests.run(target),
|
|
80
81
|
error,
|
|
81
82
|
})
|
|
@@ -135,6 +136,7 @@ export function useWorkbench(props: WorkbenchProps, error: (error: unknown) => v
|
|
|
135
136
|
// Plugin commands, shortcuts and menu entries join the registries above (toolbar reads the host).
|
|
136
137
|
useWorkbenchPluginActions(extensions, { commands: props.commands, shortcuts, actions, menu, error, frameSession: target => canvas.value?.registry.getFrame(target.frameKey)?.session ?? props.session })
|
|
137
138
|
useHistoireResource(shortcuts.bind('global.search', () => openSearch(), { allowInput: true }))
|
|
139
|
+
useHistoireResource(shortcuts.bind('canvas.remount', () => canvas.value?.registry.remountAll(), { enabled: () => [...canvas.value?.registry.frames.values() ?? []].some(frame => frame.documentId) }))
|
|
138
140
|
if (dev) {
|
|
139
141
|
useHistoireResource(shortcuts.bind('canvas.comment', () => {
|
|
140
142
|
dev.commentMode.value = true
|
package/src/app/stores/canvas.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HistoireStoryFrame } from '@histoire/protocol'
|
|
1
2
|
import type { CanvasFrameLayout } from '../components/canvas/frame-layout.js'
|
|
2
3
|
import type { CanvasMeasureState } from '../components/canvas/measure-controller.js'
|
|
3
4
|
import type { CanvasPoint, CanvasSize } from '../components/canvas/pan/usePanZoom.js'
|
|
@@ -6,7 +7,7 @@ import type { SingleZoomListener } from '../components/canvas/single-zoom.js'
|
|
|
6
7
|
import type { CanvasBackground } from '../util/background.js'
|
|
7
8
|
import type { CanvasArrangement } from './canvas-arrangement.js'
|
|
8
9
|
import type { CanvasContentInsets, CanvasFitTarget, CanvasPreferences, CanvasStorage, CanvasViewSnapshot, CanvasZoom } from './canvas-types.js'
|
|
9
|
-
import { reactive } from 'vue'
|
|
10
|
+
import { computed, reactive, type Ref, ref } from 'vue'
|
|
10
11
|
import { createCanvasContentSizes } from '../components/canvas/content-sizes.js'
|
|
11
12
|
import { canvasContentRect, clampZoom, fitCanvas, zoomAroundPoint } from '../components/canvas/pan/usePanZoom.js'
|
|
12
13
|
import { fitSingleViewport } from '../components/canvas/single-zoom.js'
|
|
@@ -17,13 +18,46 @@ export { getCanvasStorage } from './canvas-preferences.js'
|
|
|
17
18
|
export type { BuiltinCanvasTool, CanvasContentInsets, CanvasFitTarget, CanvasPreferences, CanvasStorage, CanvasTool, CanvasViewSnapshot, CanvasZoom, CanvasZoomByArrange } from './canvas-types.js'
|
|
18
19
|
|
|
19
20
|
/** Create independent canvas state; nearest shell provides instance to its tools. */
|
|
20
|
-
export function createCanvasStore(options: {
|
|
21
|
+
export function createCanvasStore(options: {
|
|
22
|
+
/** Browser persistence for toolbar and canvas preferences. */
|
|
23
|
+
storage?: CanvasStorage
|
|
24
|
+
/** Workbench-owned Single viewport sizing intent. */
|
|
25
|
+
singleViewport?: SingleViewportState
|
|
26
|
+
/** Workbench-owned Auto fit preference that survives canvas remounts. */
|
|
27
|
+
autoFitPreference?: Ref<boolean | undefined>
|
|
28
|
+
/** Authored size of the active story when From code applies. */
|
|
29
|
+
frameSizeFromCode?: () => Pick<HistoireStoryFrame, 'width' | 'height'> | undefined
|
|
30
|
+
} = {}) {
|
|
21
31
|
const preferences = readCanvasPreferences(options.storage)
|
|
22
|
-
const
|
|
32
|
+
const autoFitPreference = options.autoFitPreference ?? ref<boolean>()
|
|
33
|
+
autoFitPreference.value ??= preferences.autoFitContent
|
|
34
|
+
const frameSizeFromCode = computed(() => options.frameSizeFromCode?.())
|
|
35
|
+
const state = reactive({
|
|
36
|
+
...preferences,
|
|
37
|
+
frameSizeFromCode,
|
|
38
|
+
autoFitContent: computed(() => autoFitPreference.value === true && !frameSizeFromCode.value),
|
|
39
|
+
singleViewport: options.singleViewport ?? { mode: 'responsive' as const },
|
|
40
|
+
singleViewportSize: { width: 1, height: 1 },
|
|
41
|
+
singleViewportDraft: null as CanvasSize | null,
|
|
42
|
+
arrangement: 'grid' as CanvasArrangement,
|
|
43
|
+
zoom: preferences.zoomByArrange.grid,
|
|
44
|
+
effectiveZoom: typeof preferences.zoomByArrange.grid === 'number' ? preferences.zoomByArrange.grid : 1,
|
|
45
|
+
panOffset: { x: 32, y: 32 },
|
|
46
|
+
selectedFrame: null as string | null,
|
|
47
|
+
viewport: { width: 0, height: 0 },
|
|
48
|
+
bounds: { x: 0, y: 0, width: 0, height: 0 },
|
|
49
|
+
inspectorWidth: 0,
|
|
50
|
+
contentInsets: { topInset: 0, bottomInset: 0 },
|
|
51
|
+
frameBackgrounds: {} as Record<string, CanvasBackground>,
|
|
52
|
+
panning: false,
|
|
53
|
+
measure: null as CanvasMeasureState | null,
|
|
54
|
+
})
|
|
23
55
|
let selectionBounds: CanvasFitTarget | undefined
|
|
24
56
|
// Absent while the active view has no layout (plugin views may opt out of fitting).
|
|
25
57
|
let fitBounds: CanvasFitTarget | undefined = state.bounds
|
|
26
58
|
let singleArea: CanvasSize = { width: 0, height: 0 }
|
|
59
|
+
/** Story gutter around the Single variant; Fit keeps it in view. */
|
|
60
|
+
let singlePadding = 0
|
|
27
61
|
const singleZoomListeners = new Set<SingleZoomListener>()
|
|
28
62
|
/** Notify native scroll ownership before replacing the rendered scale. */
|
|
29
63
|
function applySingleZoom(zoom: number, point?: CanvasPoint, fit = false) {
|
|
@@ -35,7 +69,12 @@ export function createCanvasStore(options: { storage?: CanvasStorage, singleView
|
|
|
35
69
|
return canvasContentRect(state.viewport, { inspectorWidth: state.inspectorWidth, ...state.contentInsets })
|
|
36
70
|
}
|
|
37
71
|
/** Persist only contract preferences; failures leave usable current-session state. */
|
|
38
|
-
const save = () => saveCanvasPreferences(options.storage,
|
|
72
|
+
const save = () => saveCanvasPreferences(options.storage, {
|
|
73
|
+
zoomByArrange: state.zoomByArrange,
|
|
74
|
+
tool: state.tool,
|
|
75
|
+
frameBackground: state.frameBackground,
|
|
76
|
+
autoFitContent: autoFitPreference.value === true,
|
|
77
|
+
})
|
|
39
78
|
/** Updates active arrangement preference without mutating another view's scale. */
|
|
40
79
|
function setActiveZoom(zoom: CanvasZoom) {
|
|
41
80
|
state.zoom = zoom
|
|
@@ -57,7 +96,7 @@ export function createCanvasStore(options: { storage?: CanvasStorage, singleView
|
|
|
57
96
|
function fit() {
|
|
58
97
|
setActiveZoom('fit')
|
|
59
98
|
if (state.arrangement === 'single') {
|
|
60
|
-
if (singleArea.width && singleArea.height) applySingleZoom(fitSingleViewport(singleArea, state.singleViewportSize), undefined, true)
|
|
99
|
+
if (singleArea.width && singleArea.height) applySingleZoom(fitSingleViewport(singleArea, { width: state.singleViewportSize.width + singlePadding * 2, height: state.singleViewportSize.height + singlePadding * 2 }), undefined, true)
|
|
61
100
|
return save()
|
|
62
101
|
}
|
|
63
102
|
// Setup runs before ResizeObserver measures; fitting an empty viewport would lock at 10%.
|
|
@@ -85,8 +124,9 @@ export function createCanvasStore(options: { storage?: CanvasStorage, singleView
|
|
|
85
124
|
save()
|
|
86
125
|
}
|
|
87
126
|
/** Publish unscaled Single geometry; numeric zoom stays fixed during resizing. */
|
|
88
|
-
function setSingleGeometry(area: CanvasSize, size: CanvasSize) {
|
|
127
|
+
function setSingleGeometry(area: CanvasSize, size: CanvasSize, padding = 0) {
|
|
89
128
|
singleArea = area
|
|
129
|
+
singlePadding = padding
|
|
90
130
|
state.singleViewportSize = size
|
|
91
131
|
if (state.arrangement === 'single' && state.zoom === 'fit') fit()
|
|
92
132
|
}
|
|
@@ -223,7 +263,7 @@ export function createCanvasStore(options: { storage?: CanvasStorage, singleView
|
|
|
223
263
|
return Object.assign(state, { setZoom, setArrangement, fit, resetZoom, setGeometry, setSingleGeometry, panBy, setPanOffset, snapshotView, restoreView, revealFrame, selectFrame, focusFrame, zoomToFrame, zoomToSelection, contentSizes: createCanvasContentSizes(),
|
|
224
264
|
/** Select sizing without modifying manual dimensions or camera intent. */
|
|
225
265
|
setAutoFitContent(value: boolean) {
|
|
226
|
-
|
|
266
|
+
autoFitPreference.value = value
|
|
227
267
|
save()
|
|
228
268
|
},
|
|
229
269
|
/** Switch Single sizing intent and retire any transient direct-resize draft. */
|
|
@@ -131,6 +131,7 @@ export function createMarketplaceStore(options: MarketplaceStoreOptions) {
|
|
|
131
131
|
if (!open.value) {
|
|
132
132
|
const active = target ?? (typeof document !== 'undefined' && document.activeElement instanceof HTMLElement ? document.activeElement : undefined)
|
|
133
133
|
opener.value = active ? markRaw(active) : undefined
|
|
134
|
+
void updates.refresh()
|
|
134
135
|
}
|
|
135
136
|
setView(value)
|
|
136
137
|
open.value = true
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { InjectionKey } from 'vue'
|
|
1
|
+
import type { InjectionKey, Ref } from 'vue'
|
|
2
2
|
import type { CanvasViewSnapshot } from './canvas.js'
|
|
3
3
|
import { inject, provide, shallowReactive, shallowRef } from 'vue'
|
|
4
4
|
|
|
5
5
|
/** Workbench-local owner for story views and the optional shared view. */
|
|
6
6
|
export interface StoryCanvasViews {
|
|
7
|
+
/** Toolbar Auto fit preference, initialized on the first canvas mount. */
|
|
8
|
+
autoFitPreference: Ref<boolean | undefined>
|
|
7
9
|
/** Read one story view as a detached snapshot. */
|
|
8
10
|
getStory: (storyId: string) => CanvasViewSnapshot | undefined
|
|
9
11
|
/** Replace one story view with an isolated copy. */
|
|
@@ -12,6 +14,10 @@ export interface StoryCanvasViews {
|
|
|
12
14
|
getShared: () => CanvasViewSnapshot | undefined
|
|
13
15
|
/** Replace the shared Sync zoom view with an isolated copy. */
|
|
14
16
|
saveShared: (snapshot: CanvasViewSnapshot) => void
|
|
17
|
+
/** Whether this story uses toolbar sizing for the current session. */
|
|
18
|
+
usesToolbarViewport: (storyId: string) => boolean
|
|
19
|
+
/** Switch between the authored dimensions and toolbar sizing for one story. */
|
|
20
|
+
setStorySizeFromCode: (storyId: string, fromCode: boolean) => void
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
const storyCanvasViewsKey: InjectionKey<StoryCanvasViews> = Symbol('histoire-story-canvas-views')
|
|
@@ -21,11 +27,13 @@ function copyView(snapshot: CanvasViewSnapshot): CanvasViewSnapshot {
|
|
|
21
27
|
return { arrangement: snapshot.arrangement, zoomByArrange: { ...snapshot.zoomByArrange }, panOffset: { ...snapshot.panOffset } }
|
|
22
28
|
}
|
|
23
29
|
|
|
24
|
-
/** Creates state scoped to one workbench provider
|
|
30
|
+
/** Creates view state scoped to one workbench provider. */
|
|
25
31
|
export function createStoryCanvasViews(): StoryCanvasViews {
|
|
26
32
|
const stories = shallowReactive(new Map<string, CanvasViewSnapshot>())
|
|
27
33
|
const shared = shallowRef<CanvasViewSnapshot>()
|
|
34
|
+
const toolbarSizedStories = shallowReactive(new Set<string>())
|
|
28
35
|
return {
|
|
36
|
+
autoFitPreference: shallowRef<boolean>(),
|
|
29
37
|
getStory: (storyId) => {
|
|
30
38
|
const view = stories.get(storyId)
|
|
31
39
|
return view ? copyView(view) : undefined
|
|
@@ -33,6 +41,11 @@ export function createStoryCanvasViews(): StoryCanvasViews {
|
|
|
33
41
|
saveStory: (storyId, snapshot) => stories.set(storyId, copyView(snapshot)),
|
|
34
42
|
getShared: () => shared.value ? copyView(shared.value) : undefined,
|
|
35
43
|
saveShared: snapshot => shared.value = copyView(snapshot),
|
|
44
|
+
usesToolbarViewport: storyId => toolbarSizedStories.has(storyId),
|
|
45
|
+
setStorySizeFromCode(storyId, fromCode) {
|
|
46
|
+
if (fromCode) toolbarSizedStories.delete(storyId)
|
|
47
|
+
else toolbarSizedStories.add(storyId)
|
|
48
|
+
},
|
|
36
49
|
}
|
|
37
50
|
}
|
|
38
51
|
|
package/src/app/style/theme.css
CHANGED
|
@@ -67,6 +67,14 @@
|
|
|
67
67
|
50% { opacity: 1; }
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/* Keep menu items at their intrinsic heights when a panel has to scroll. */
|
|
71
|
+
@utility menu-rows {
|
|
72
|
+
display: grid;
|
|
73
|
+
grid-template-columns: minmax(0, 1fr);
|
|
74
|
+
align-content: start;
|
|
75
|
+
row-gap: 1px;
|
|
76
|
+
}
|
|
77
|
+
|
|
70
78
|
/* Keep the existing markdown contract while typography supplies structural defaults. */
|
|
71
79
|
@utility prose {
|
|
72
80
|
--tw-prose-invert-quote-borders: rgb(var(--_histoire-color-gray-800) / var(--_histoire-color-gray-800-alpha, 1));
|
|
@@ -31,6 +31,13 @@ export function getBackgroundPreset(settings: CanvasBackground): string {
|
|
|
31
31
|
return settings.checkerboard ? checkerboards[settings.checkerboardTheme ?? 'light'].color : settings.backgroundColor
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/** Readable color on a painted background; transparency shows the workbench, so it has none. */
|
|
35
|
+
export function getBackgroundContrastColor(settings: CanvasBackground, presets: readonly BackgroundPreset[]): string | undefined {
|
|
36
|
+
if (!settings.checkerboard && settings.backgroundColor === 'transparent') return undefined
|
|
37
|
+
const color = getBackgroundPreset(settings)
|
|
38
|
+
return withCheckerboardPresets(presets).find(preset => preset.color === color)?.contrastColor
|
|
39
|
+
}
|
|
40
|
+
|
|
34
41
|
/** Paint inspection tiles at displayed scale; transparency reveals canvas backing. */
|
|
35
42
|
export function getBackgroundStyle(settings: CanvasBackground): CSSProperties {
|
|
36
43
|
if (!settings.checkerboard) return { backgroundColor: settings.backgroundColor, backgroundImage: 'none', backgroundSize: undefined }
|
|
@@ -54,6 +54,8 @@ export interface FrameActionOptions {
|
|
|
54
54
|
frameSession?: (target: FrameActionTarget) => HistoireSession | null
|
|
55
55
|
/** Logical activation invalidates pending actions even when a document is reused. */
|
|
56
56
|
frameRegistration?: (target: FrameActionTarget) => CanvasFrameRegistration | null
|
|
57
|
+
/** Remount the rendered variant inside its live document; false when none is mounted. */
|
|
58
|
+
remountFrame?: (target: FrameActionTarget) => boolean
|
|
57
59
|
/** Clipboard abstraction used by behavior tests and native host. */
|
|
58
60
|
copy?: (text: string) => Promise<void>
|
|
59
61
|
/** Workbench tests owner runs exact target so inspector and test panes observe its results. */
|
|
@@ -124,6 +126,9 @@ export function createFrameActions(options: FrameActionOptions) {
|
|
|
124
126
|
/** Caller closes manual recovery after copying or selecting text. */
|
|
125
127
|
dismissCopy(): void { manualCopy.value = null } }
|
|
126
128
|
const actions: FrameAction[] = [
|
|
129
|
+
{ id: 'remount', label: 'Remount', icon: 'renew', group: 'run', shortcut: 'frame.remount', available: () => !!options.remountFrame, disabled: target => options.frameRegistration?.(target)?.documentId ? undefined : 'Variant is not running', run(target) {
|
|
130
|
+
if (!options.remountFrame?.(target)) throw new Error('Variant unavailable.')
|
|
131
|
+
} },
|
|
127
132
|
{ id: 'open-isolated', label: 'Open isolated', icon: 'launch', group: 'open', shortcut: 'frame.isolated', run(target) {
|
|
128
133
|
const source = options.session.getSnapshot().source
|
|
129
134
|
if (!source) return
|
|
@@ -167,6 +172,7 @@ export function registerFrameAction(registry: ReturnType<typeof createFrameActio
|
|
|
167
172
|
/** Menu hints and native frame shortcuts share action IDs and live capability gates. */
|
|
168
173
|
export function registerFrameShortcuts(shortcuts: ReturnType<typeof createShortcutRegistry>, actions: ReturnType<typeof createFrameActions>, target: (event?: KeyboardEvent) => FrameActionTarget | null): () => void {
|
|
169
174
|
const definitions = [
|
|
175
|
+
{ action: 'remount', id: 'frame.remount' },
|
|
170
176
|
{ action: 'open-isolated', id: 'frame.isolated' },
|
|
171
177
|
{ action: 'open-editor', id: 'frame.editor' },
|
|
172
178
|
{ action: 'copy-source', id: 'frame.source' },
|
|
@@ -131,8 +131,11 @@ export function createMarketplaceClient(options: MarketplaceClientOptions = {})
|
|
|
131
131
|
return staticPage(entries, query)
|
|
132
132
|
},
|
|
133
133
|
/** Read declarative plugin details. */
|
|
134
|
-
detail(id: string, prefs: MarketplacePrefs, requestOptions?: MarketplaceRequestOptions
|
|
135
|
-
|
|
134
|
+
detail(id: string, prefs: MarketplacePrefs, requestOptions?: MarketplaceRequestOptions & {
|
|
135
|
+
/** Exact published release for install options. */ version?: string
|
|
136
|
+
}): Promise<PluginDetail> {
|
|
137
|
+
const version = requestOptions?.version
|
|
138
|
+
return transport.available() ? request('histoire:ui:marketplace-detail', 'histoire:ui:marketplace-detail-result', 'detail', { id, prefs, ...(version ? { version } : {}) }, requestOptions) : offlineDetail(id, requestOptions)
|
|
136
139
|
},
|
|
137
140
|
/** Read compatible target notes and migrations from the development server. */
|
|
138
141
|
updateDetail(id: string, prefs: MarketplacePrefs, requestOptions?: MarketplaceRequestOptions): Promise<PluginDetail> {
|
|
@@ -18,7 +18,7 @@ const emit = defineEmits<{ error: [error: unknown] }>()
|
|
|
18
18
|
|
|
19
19
|
<template>
|
|
20
20
|
<HistoireProvider v-if="session && options && !error" :session="session" @error="emit('error', $event)">
|
|
21
|
-
<HistoireEmbed :scope="options.variantId === undefined ? 'story' : 'variant'" :panels="options.panels" @error="emit('error', $event)" />
|
|
21
|
+
<HistoireEmbed :scope="options.variantId === undefined ? 'story' : 'variant'" :panels="options.panels" :padding="options.padding" @error="emit('error', $event)" />
|
|
22
22
|
</HistoireProvider>
|
|
23
23
|
<div v-else class="htw:flex htw:items-center htw:justify-center htw:size-full htw:[font-family:system-ui,sans-serif] htw:text-[var(--histoire-text,#18181b)]">
|
|
24
24
|
<WorkbenchEmptyState v-if="error" icon="warning-alt" title="Unable to load embed">
|
|
@@ -27,14 +27,14 @@ export function createExplorerViewSession(context: EmbedSurfaceContext) {
|
|
|
27
27
|
if (primary && snapshot.selection?.variantId != null) selected = new Promise<void>(resolve => settleSelection = resolve)
|
|
28
28
|
else selected = Promise.resolve()
|
|
29
29
|
})
|
|
30
|
-
const session: HistoireSession = { ...context.session, mount(container, { surface }) {
|
|
30
|
+
const session: HistoireSession = { ...context.session, mount(container, { surface, padding }) {
|
|
31
31
|
if (!active) throw new HistoireSdkError('DISPOSED', 'Explorer detached')
|
|
32
32
|
const isPrimary = surface === 'preview'
|
|
33
33
|
if (surface === 'explorer' || (isPrimary && primary)) throw new HistoireSdkError('RUNTIME_IN_USE', 'Explorer already owns primary runtime')
|
|
34
34
|
const owner = context.bridge.getOwner()
|
|
35
35
|
const snapshot = session.getSnapshot()
|
|
36
36
|
const mountId = isPrimary ? owner.mountId : `${owner.mountId}:child:${++counter}`
|
|
37
|
-
const transport = mountLocalHistoireSurface({ session, sessionId: owner.sessionId, mountId, surface, hidden: false, container, target: snapshot.selection, settings: snapshot.settings, source: { id: owner.connectionId, descriptor: context.descriptor, request: async () => {
|
|
37
|
+
const transport = mountLocalHistoireSurface({ session, sessionId: owner.sessionId, mountId, surface, padding, hidden: false, container, target: snapshot.selection, settings: snapshot.settings, source: { id: owner.connectionId, descriptor: context.descriptor, request: async () => {
|
|
38
38
|
throw new HistoireSdkError('CAPABILITY_UNAVAILABLE', 'Use canonical parent data session')
|
|
39
39
|
}, subscribe: () => () => {}, close: () => {} } }, context.sourceBase ?? new URL('./', window.location.href).href)
|
|
40
40
|
if (isPrimary) {
|
|
@@ -34,7 +34,7 @@ export function createEmbedExplorerView(context: EmbedSurfaceContext) {
|
|
|
34
34
|
void ready.catch(() => {})
|
|
35
35
|
const app = createApp({ render: () => h(HistoireProvider, { session: owner.session, extensions: extensions?.host, onError: reject }, {
|
|
36
36
|
default: () => context.presentation
|
|
37
|
-
? h(HistoireEmbed, { scope: context.presentation.scope, panels: context.presentation.panels, onReady: () => resolve(owner.runtime()), onError: reject })
|
|
37
|
+
? h(HistoireEmbed, { scope: context.presentation.scope, panels: context.presentation.panels, padding: context.padding, onReady: () => resolve(owner.runtime()), onError: reject })
|
|
38
38
|
: h(HistoireExplorer, { onReady: () => resolve(owner.runtime()), onError: reject }),
|
|
39
39
|
}) })
|
|
40
40
|
let closing: Promise<void> | undefined
|
|
@@ -53,7 +53,7 @@ export function mountLocalHistoireSurface(context: HistoireMountContext, sourceB
|
|
|
53
53
|
// controls can request replica-only UI before first render.
|
|
54
54
|
acquired = Promise.resolve().then(() => {
|
|
55
55
|
abort.signal.throwIfAborted()
|
|
56
|
-
instance = mountEmbedSurface(context.surface, { container: root, session: context.session, bridge: child, descriptor, signal: abort.signal, sourceBase, controlsCustomOnly: customOnly, standalone, presentation: context.presentation })
|
|
56
|
+
instance = mountEmbedSurface(context.surface, { container: root, session: context.session, bridge: child, descriptor, signal: abort.signal, sourceBase, controlsCustomOnly: customOnly, standalone, presentation: context.presentation, padding: context.padding })
|
|
57
57
|
return instance
|
|
58
58
|
})
|
|
59
59
|
const ready = acquired.then(async (view) => {
|
|
@@ -152,6 +152,11 @@ export function createEmbedRuntimeFrame(context: EmbedSurfaceContext) {
|
|
|
152
152
|
if (status === 'absent') selected = null
|
|
153
153
|
if (publishNow) publish(status)
|
|
154
154
|
}
|
|
155
|
+
/** Mount override first, then the story layout, then the project default; embeds draw no aligners. */
|
|
156
|
+
function embedPadding(target: HistoireTarget): number {
|
|
157
|
+
const story = context.session.getSnapshot().catalog.stories.find(item => item.id === target.storyId)
|
|
158
|
+
return context.padding ?? story?.layout?.padding ?? context.descriptor.framePadding ?? 0
|
|
159
|
+
}
|
|
155
160
|
/** New document minted before assigning src; WindowProxy equality cannot resurrect predecessor. */
|
|
156
161
|
function navigate(target: HistoireTarget) {
|
|
157
162
|
requests.invalidate()
|
|
@@ -165,7 +170,7 @@ export function createEmbedRuntimeFrame(context: EmbedSurfaceContext) {
|
|
|
165
170
|
viewports = []
|
|
166
171
|
sandboxViewports = []
|
|
167
172
|
mounting()
|
|
168
|
-
iframe.src = createRuntimeFrameUrl(base, { target, documentId: owner.id!, selectionVersion: owner.selectionVersion, standalone: context.standalone })
|
|
173
|
+
iframe.src = createRuntimeFrameUrl(base, { target, documentId: owner.id!, selectionVersion: owner.selectionVersion, standalone: context.standalone, padding: embedPadding(target) })
|
|
169
174
|
if (!iframe.isConnected) context.container.append(iframe)
|
|
170
175
|
settings()
|
|
171
176
|
}
|
|
@@ -11,6 +11,8 @@ export interface RuntimeFrameUrlOptions {
|
|
|
11
11
|
selectionVersion: number
|
|
12
12
|
/** Standalone workbench host, which forwards its own base presentation flags. */
|
|
13
13
|
standalone?: boolean
|
|
14
|
+
/** Embed gutter in CSS pixels; the canvas draws its own, so standalone hosts never pass it. */
|
|
15
|
+
padding?: number
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
/** Base sandbox URL carrying the exact target identities; every caller holds a selected variant. */
|
|
@@ -32,6 +34,7 @@ export function createRuntimeFrameUrl(base: URL, options: RuntimeFrameUrlOptions
|
|
|
32
34
|
url.searchParams.set('selectionVersion', String(options.selectionVersion))
|
|
33
35
|
url.searchParams.set('embed', 'true')
|
|
34
36
|
if (options.standalone) url.searchParams.set('standalone', 'true')
|
|
37
|
+
else if (options.padding) url.searchParams.set('padding', String(options.padding))
|
|
35
38
|
if (options.standalone && base.searchParams.get('nativeScroll') === 'true') url.searchParams.set('nativeScroll', 'true')
|
|
36
39
|
if (options.standalone && base.searchParams.get('matrix') === 'true') url.searchParams.set('matrix', 'true')
|
|
37
40
|
return url.href
|