mcard-studio 0.0.2 → 0.0.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/README.md +3 -0
- package/astro.config.mjs +41 -2
- package/cli/lib/runtimeContext.mjs +6 -3
- package/dist/client/_astro/{ChartAnalyticsViewlet.jrwIemvb.js → ChartAnalyticsViewlet.CBW-JyA3.js} +1 -1
- package/dist/client/_astro/{ClmPcardViewlet.C-fU7oZf.js → ClmPcardViewlet.cvKsR2ng.js} +2 -2
- package/dist/client/_astro/{D3GraphViewlet.BCZl0b2U.js → D3GraphViewlet.8YEIrCGL.js} +1 -1
- package/dist/client/_astro/DockviewSpatialWorkbench.BTd66LPl.js +12 -0
- package/dist/client/_astro/DocumentViewlets.KY1HcNka.js +2 -0
- package/dist/client/_astro/DxfViewlet.B3N5zpZR.js +1 -0
- package/dist/client/_astro/{ExcalidrawWhiteboardViewlet.CFpPYSdn.js → ExcalidrawWhiteboardViewlet.CMJGCQN4.js} +1 -1
- package/dist/client/_astro/{FaroVCardSpanInstrumenter.un8kDMWv.js → FaroVCardSpanInstrumenter.ClIqZujq.js} +1 -1
- package/dist/client/_astro/{FontSpecimenViewlet.D7Aw2xBZ.js → FontSpecimenViewlet.ChIyr0B8.js} +1 -1
- package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.D3FSc061.js +1 -0
- package/dist/client/_astro/{ImageViewlet.D4FN87n_.js → ImageViewlet.Cs-u7-wt.js} +1 -1
- package/dist/client/_astro/{KatexFormulaViewlet.CzhdIOw8.js → KatexFormulaViewlet.0nOzV_qD.js} +1 -1
- package/dist/client/_astro/{KoishiChatViewlet.5mepQvLX.js → KoishiChatViewlet.DLsMmwdb.js} +4 -4
- package/dist/client/_astro/{MCardLibraryHarness.DE8KeghO.js → MCardLibraryHarness.WBT9W10S.js} +1 -1
- package/dist/client/_astro/{MarkdownViewlet.CRuuXXmF.js → MarkdownViewlet.BIolkNXf.js} +25 -25
- package/dist/client/_astro/{MermaidDiagramViewlet.eW6sk-rF.js → MermaidDiagramViewlet.CkRk7QsS.js} +1 -1
- package/dist/client/_astro/PCardRendererBridge.DhaRSprd.js +1 -0
- package/dist/client/_astro/RendererPCardRegistry.brM2KiQs.js +1 -0
- package/dist/client/_astro/{SchemaYamlViewlet.ZJBvxItR.js → SchemaYamlViewlet.Bc7nkK4M.js} +1 -1
- package/dist/client/_astro/{ShellContainer.astro_astro_type_script_index_0_lang.j_ELcN5d.js → ShellContainer.astro_astro_type_script_index_0_lang.5q1gCLvf.js} +1 -1
- package/dist/client/_astro/{Spatial3dViewlet.DnVMBENJ.js → Spatial3dViewlet.C-jjhr0A.js} +1 -1
- package/dist/client/_astro/{StudioLayout.CBgiVbeb.css → StudioLayout.CX8XGtZV.css} +1 -1
- package/dist/client/_astro/StudioWorkbench.B1QwGHWM.js +7 -0
- package/dist/client/_astro/{SvgViewlet.BCje7Qqb.js → SvgViewlet.uGxvb06H.js} +1 -1
- package/dist/client/_astro/{TerminalView.C_Ksz6lT.js → TerminalView.DP7G7E1m.js} +1 -1
- package/dist/client/_astro/{ThemeSettingsViewlet.DJpjQQ0Z.js → ThemeSettingsViewlet.UaTHcGnF.js} +1 -1
- package/dist/client/_astro/{TikzDiagramViewlet.CXb1A8nf.js → TikzDiagramViewlet.O8MJyXfT.js} +1 -1
- package/dist/client/_astro/VideoPlayerViewlet.-ycmo3kY.js +1 -0
- package/dist/client/_astro/WebappZenViewlet.PNce4u2T.js +1 -0
- package/dist/client/_astro/{WelcomeViewport.BiYwLh6l.js → WelcomeViewport.CZ6RxGSw.js} +1 -1
- package/dist/client/_astro/{agentIdentityCredentialService.UzMMwBwv.js → agentIdentityCredentialService.BEtZzBlO.js} +1 -1
- package/dist/client/_astro/cardTypeDetector.C2HH5RnU.js +1 -0
- package/dist/client/_astro/disposable.BmlxZrDf.js +1 -0
- package/dist/client/_astro/{markdownService.BgWjyJ57.js → markdownService.CpuKl0vp.js} +1 -1
- package/dist/client/_astro/{mcardStore.CT-ollfl.js → mcardStore.nSWnzeLg.js} +1 -1
- package/dist/client/_astro/mcardVfs.BSdys1Y7.js +3 -0
- package/dist/client/_astro/pathsConfig.CSBBSzwH.js +2 -0
- package/dist/client/_astro/{polyfills._3wYPjZf.js → polyfills.Bi7kO8cu.js} +1 -1
- package/dist/client/_astro/rendererEventBus.DirFDmGw.js +1 -0
- package/dist/client/_astro/themeStore.BajxvCga.js +1 -0
- package/dist/client/_astro/{tikzCompiler.fe3qomFY.js → tikzCompiler.-fXMNQpz.js} +1 -1
- package/dist/client/_astro/{useMCardHydration.7Z-HfBh5.js → useMCardHydration.Bjj_N5Gv.js} +1 -1
- package/dist/client/_astro/vendor-clm-kernel.B0kxq3g4.js +108 -0
- package/dist/client/_astro/{vfsHandles.IX_wTpw_.js → vfsHandles.D4Pq18pW.js} +1 -1
- package/dist/client/_astro/vfsPersistence.DVrd1BZj.js +1 -0
- package/dist/client/_astro/{vfsTransactions.C_IQQg0s.js → vfsTransactions.DBNtFuRz.js} +1 -1
- package/dist/client/_astro/{workspaceStore.CD0kAVAl.js → workspaceStore.DUHW2YBc.js} +1 -1
- package/dist/server/chunks/{_.._5gPhVOLM.mjs → _.._CoQKwo62.mjs} +137 -91
- package/dist/server/chunks/{_handle__D_cIJYrU.mjs → _handle__D8dKQPUS.mjs} +3 -3
- package/dist/server/chunks/{cardTypeDetector_CyW1Xnmy.mjs → cardTypeDetector_C55M_HWS.mjs} +9 -0
- package/dist/server/chunks/{cards_B89BvF6W.mjs → cards_rVOc8K6H.mjs} +2 -2
- package/dist/server/chunks/cas_DTxlZ4Le.mjs +68 -0
- package/dist/server/chunks/{dispatch_DOwSKukU.mjs → dispatch_BTW4E_BJ.mjs} +8 -7
- package/dist/server/chunks/{dispatch_CxWKiHpn.mjs → dispatch_MbkljUxD.mjs} +8 -8
- package/dist/server/chunks/{export_DRouradA.mjs → export_DkEwDE2T.mjs} +3 -3
- package/dist/server/chunks/{health_Dfa5I0-X.mjs → health_cRt0M0yu.mjs} +1 -1
- package/dist/server/chunks/{mcard-library_7Wzoihkm.mjs → mcard-library_CLHvyslV.mjs} +1 -1
- package/dist/server/chunks/{mcardVfs_CeezzRvt.mjs → mcardVfs_DvNburKb.mjs} +5 -30
- package/dist/server/chunks/{move__RFvIDkq.mjs → move_DYcaXBLV.mjs} +6 -6
- package/dist/server/chunks/{pathsConfig_CgNYYLVm.mjs → pathsConfig_Dack-p2f.mjs} +13 -3
- package/dist/server/chunks/{proxy_CrWJQIBe.mjs → proxy_CMbbdBPW.mjs} +2 -2
- package/dist/server/chunks/{raw_DzNDaDVP.mjs → raw_C97sJWhg.mjs} +59 -26
- package/dist/server/chunks/{serverBootstrap_XKo2s6Ha.mjs → serverBootstrap_BDdSRIu5.mjs} +2 -2
- package/dist/server/chunks/tree_BwmO-pTe.mjs +186 -0
- package/dist/server/chunks/vfsCore_DIKpk-pk.mjs +98 -0
- package/dist/server/chunks/{vfsTreeScan_CKp7kMt9.mjs → vfsTreeScan_CRoCluPB.mjs} +18 -10
- package/dist/server/chunks/workspaceRoot_CRx3taID.mjs +157 -0
- package/dist/server/chunks/{write_popiFsO7.mjs → write_BLsmsTIx.mjs} +6 -5
- package/dist/server/chunks/{ws-server-init_DUjuR2-o.mjs → ws-server-init_Cfft7U5u.mjs} +343 -298
- package/dist/server/entry.mjs +1 -1
- package/dist/server/entry2.mjs +67 -28
- package/dist/server/virtual_astro_middleware.mjs +2 -2
- package/package.json +2 -2
- package/src/components/studio/views/cardViewlets/ClmRegistryComponentViewlet.tsx +133 -0
- package/src/components/studio/views/cardViewlets/DxfViewlet.tsx +230 -0
- package/src/components/studio/views/cardViewlets/VideoPlayerViewlet.tsx +4 -4
- package/src/components/studio/views/cardViewlets/coreViewletDefs.ts +2 -2
- package/src/components/studio/views/cardViewlets/documents/AudioPlayerViewlet.tsx +15 -3
- package/src/components/studio/views/cardViewlets/documents/PdfViewlet.tsx +25 -7
- package/src/components/studio/views/cardViewlets/markdown/stages/wikilinkStage.ts +2 -1
- package/src/components/studio/views/cardViewlets/mediaViewletDefs.ts +21 -1
- package/src/components/studio/views/cardViewlets/webapp/WebappCanvas.tsx +40 -15
- package/src/components/studio/views/cardViewlets/webapp/WebappDevicePresetBar.tsx +108 -0
- package/src/components/studio/views/cardViewlets/webapp/WebappZenViewlet.tsx +23 -30
- package/src/components/studio/views/fileTree/MCardFileTree.tsx +71 -54
- package/src/components/studio/views/fileTree/hooks/useFileTreeSync.ts +0 -1
- package/src/components/studio/views/fileTree/hooks/usePartitionedTrees.ts +68 -23
- package/src/components/studio/views/fileTree/hooks/useSectionAccordion.ts +21 -11
- package/src/components/studio/views/functions/UnifiedFunctionExplorerViewlet.tsx +168 -0
- package/src/components/studio/views/history/HistoryPanel.tsx +110 -0
- package/src/components/studio/views/lineage/LineagePanel.tsx +152 -0
- package/src/components/studio/views/navigation/HandleLineageDrawer.tsx +89 -0
- package/src/components/studio/views/navigation/MultiCardCollectionBrowser.tsx +154 -0
- package/src/components/studio/views/pills/HashPill.tsx +101 -0
- package/src/components/studio/views/residency/ResidencyIndicator.tsx +82 -0
- package/src/config/app_config.json +3 -3
- package/src/core/projection/catalog.ts +105 -0
- package/src/core/projection/collection.ts +148 -0
- package/src/core/projection/handleSubscription.ts +132 -0
- package/src/core/projection/index.ts +4 -0
- package/src/core/projection/selectors.ts +29 -0
- package/src/core/projection/views.ts +242 -0
- package/src/core/refinement/designMetrics.ts +104 -0
- package/src/core/refinement/fibrationProjector.ts +142 -0
- package/src/core/refinement/lagrangianEngine.ts +137 -0
- package/src/core/refinement/refinementCommands.ts +82 -0
- package/src/core/viewport/deviceArchetypeRegistry.ts +177 -0
- package/src/core/viewport/viewportAudit.ts +150 -0
- package/src/edge/storeFilter.d.ts +4 -0
- package/src/edge/storeFilter.js +54 -0
- package/src/edge/storeFilter.ts +52 -0
- package/src/lib/cryptoPolyfill.js +77 -1
- package/src/lib/fsPolyfill.js +65 -0
- package/src/lib/urlPolyfill.js +21 -0
- package/src/lib/zlibPolyfill.js +35 -0
- package/src/packages/mcard-studio/package.json +2 -2
- package/src/packages/mcard-studio/type/legacyMapping.ts +5 -0
- package/src/packages/mcard-studio/viewlets/manifests.ts +2 -0
- package/src/packages/mcard-studio/viewlets/moduleMap.ts +12 -0
- package/src/packages/mcard-studio/viewlets/refinementManifests.ts +114 -0
- package/src/pages/api/dispatch.ts +3 -2
- package/src/pages/api/vfs/cas.ts +114 -0
- package/src/pages/api/vfs/move.ts +5 -5
- package/src/pages/api/vfs/raw.ts +72 -27
- package/src/pages/api/vfs/tree.ts +130 -11
- package/src/pages/api/vfs/write.ts +5 -4
- package/src/server/api/kernelDispatch.ts +8 -8
- package/src/server/artifactCollectionService.ts +4 -7
- package/src/server/artifactRepository.ts +4 -3
- package/src/server/clmRunner.mjs +1 -1
- package/src/server/collectionOwner.mjs +5 -5
- package/src/server/effects/executionPersistenceService.mjs +11 -11
- package/src/server/effects/resultSealingService.mjs +2 -2
- package/src/server/fileIngestService.mjs +21 -9
- package/src/server/fileWatcherService.mjs +4 -1
- package/src/server/handlers/fileChangeHandler.mjs +18 -10
- package/src/server/handlers/saveExecutionLogHandler.mjs +6 -6
- package/src/server/notificationService.mjs +14 -1
- package/src/server/scripts/buildSeedingMemory.mjs +3 -3
- package/src/server/serverMemoryRepository.ts +41 -59
- package/src/server/vfsTreeScan.ts +16 -10
- package/src/server/workspaceRoot.ts +143 -5
- package/src/services/cardTypeDetector.ts +4 -0
- package/src/services/databaseSyncService.ts +30 -46
- package/src/services/namespaceProtocolClient.ts +221 -0
- package/src/services/renderers/pcard/RendererPCardRegistry.ts +4 -66
- package/src/services/renderers/pcard/modalitySpecs.ts +125 -0
- package/src/services/renderers/pcard/types.ts +7 -1
- package/src/services/renderers/rendererEventBus.ts +5 -3
- package/src/services/unifiedFunctionExecutionService.ts +145 -0
- package/src/services/vfs/vfsCore.ts +12 -1
- package/src/services/vfs/vfsMigration.ts +95 -0
- package/src/services/vfs/vfsMutations.ts +17 -35
- package/src/services/vfs/vfsPersistence.ts +19 -24
- package/src/services/vfs/vfsSync.ts +55 -17
- package/src/services/vfs/vfsVersions.ts +23 -34
- package/src/services/workbenchExecutionPolicy.ts +183 -0
- package/src/stores/mcardCollectionStore.ts +2 -0
- package/src/styles/dockview.css +34 -0
- package/src/ui/viewlets/FibrationRefinementViewlet.tsx +155 -0
- package/src/ui/viewlets/PetriConformanceViewlet.tsx +166 -0
- package/src/ui/viewlets/ResponsiveViewportLabViewlet.tsx +175 -0
- package/src/ui/viewlets/SprintGovernanceViewlet.tsx +176 -0
- package/src/ui/viewlets/viewletFocus.ts +35 -0
- package/src/ui/viewlets/viewportLabParts.tsx +190 -0
- package/dist/client/_astro/DockviewSpatialWorkbench.B_I1GJHw.js +0 -12
- package/dist/client/_astro/DocumentViewlets.B53IqmpY.js +0 -2
- package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.VDRYJCM-.js +0 -1
- package/dist/client/_astro/PCardRendererBridge.oxVKc0gN.js +0 -1
- package/dist/client/_astro/RendererPCardRegistry.CWjYZs2H.js +0 -1
- package/dist/client/_astro/StudioWorkbench.Blo5oSIw.js +0 -7
- package/dist/client/_astro/VideoPlayerViewlet.CmECt7yT.js +0 -1
- package/dist/client/_astro/WebappZenViewlet.whCmGVHR.js +0 -1
- package/dist/client/_astro/__vite-browser-external.CQZnr-r3.js +0 -1
- package/dist/client/_astro/cardTypeDetector.Ci4APwhX.js +0 -1
- package/dist/client/_astro/disposable.Dsb0sbRP.js +0 -1
- package/dist/client/_astro/mcardVfs.2UOw9Z-r.js +0 -3
- package/dist/client/_astro/pathsConfig.D0hV34p7.js +0 -2
- package/dist/client/_astro/rendererEventBus.DMH9afq9.js +0 -1
- package/dist/client/_astro/themeStore.CEt0e54l.js +0 -1
- package/dist/client/_astro/vendor-clm-kernel.Bvk3XHk2.js +0 -116
- package/dist/client/_astro/vfsPersistence.BuhXYeSb.js +0 -1
- package/dist/server/chunks/cryptoPolyfill_99rxUwYC.mjs +0 -180
- package/dist/server/chunks/kernelHash_DRaj51hY.mjs +0 -5
- package/dist/server/chunks/tree_CE2BhvyJ.mjs +0 -76
- package/dist/server/chunks/vfsCore_B6nCiBl5.mjs +0 -21
- package/dist/server/chunks/workspaceRoot_DVSUbYkd.mjs +0 -71
- package/src/server/kernelHash.ts +0 -22
- package/src/server/storage/cardCollection.ts +0 -94
- package/src/server/storage/index.ts +0 -3
- package/src/server/storage/mcard.ts +0 -99
- package/src/server/storage/sqliteNodeEngine.ts +0 -121
- /package/dist/server/chunks/{StudioLayout_B5ZnlqjF.mjs → StudioLayout_taayQJ5b.mjs} +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UnifiedFunctionExplorerViewlet — Supported Function & Capability Explorer
|
|
3
|
+
* (SMR-10 · DoD-SMR-10-04 / 10-05 / 10-06).
|
|
4
|
+
*
|
|
5
|
+
* Lists descriptors from the built catalog (741 Layer 0 PCards plus the declared
|
|
6
|
+
* registry components, fiber adapters, and portal islands), searchable by handle,
|
|
7
|
+
* submodule, runtime, and correctness grade. Discovery is read-only: the execute
|
|
8
|
+
* control is visibly disabled and says why, and "open in split" reuses the existing
|
|
9
|
+
* SV-07 dual-spatial-split lifecycle rather than inventing a second one.
|
|
10
|
+
*
|
|
11
|
+
* Registered as `pcard:render/function-explorer` and as module
|
|
12
|
+
* `UnifiedFunctionExplorerViewlet` in the viewlet module map.
|
|
13
|
+
*
|
|
14
|
+
* Contract D budget: <= 250 LOC.
|
|
15
|
+
*/
|
|
16
|
+
import React, { useMemo, useState } from 'react';
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
catalogFacets,
|
|
20
|
+
catalogSummary,
|
|
21
|
+
filterDescriptors,
|
|
22
|
+
type CatalogFilter,
|
|
23
|
+
type SupportedFunctionCatalog,
|
|
24
|
+
} from '@/core/projection/catalog';
|
|
25
|
+
import type { ExecutionCapability } from '@/services/unifiedFunctionExecutionService';
|
|
26
|
+
|
|
27
|
+
export const SPLIT_REQUEST_EVENT = 'clm:fullscreen-split-requested';
|
|
28
|
+
|
|
29
|
+
/** Requests a Dockview dual-spatial split through the existing SV-07 lifecycle. */
|
|
30
|
+
export function requestDualSplit(targetUrl: string): boolean {
|
|
31
|
+
if (typeof window === 'undefined' || typeof window.dispatchEvent !== 'function') return false;
|
|
32
|
+
window.dispatchEvent(
|
|
33
|
+
new CustomEvent(SPLIT_REQUEST_EVENT, { detail: { targetUrl } }),
|
|
34
|
+
);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface UnifiedFunctionExplorerViewletProps {
|
|
39
|
+
readonly catalog: SupportedFunctionCatalog;
|
|
40
|
+
readonly capability?: ExecutionCapability;
|
|
41
|
+
readonly onSelect?: (handle: string) => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const UnifiedFunctionExplorerViewlet: React.FC<UnifiedFunctionExplorerViewletProps> = ({
|
|
45
|
+
catalog,
|
|
46
|
+
capability,
|
|
47
|
+
onSelect,
|
|
48
|
+
}) => {
|
|
49
|
+
const [filter, setFilter] = useState<CatalogFilter>({});
|
|
50
|
+
const facets = useMemo(() => catalogFacets(catalog), [catalog]);
|
|
51
|
+
const visible = useMemo(() => filterDescriptors(catalog.descriptors, filter), [catalog, filter]);
|
|
52
|
+
const disabledReason = capability?.reason ?? 'Execution capability is not configured.';
|
|
53
|
+
|
|
54
|
+
const update = (patch: Partial<CatalogFilter>) => setFilter((current) => ({ ...current, ...patch }));
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<section className="function-explorer" aria-label="Supported function and capability explorer">
|
|
58
|
+
<header className="function-explorer-header">
|
|
59
|
+
<h3>Supported Functions & Capabilities</h3>
|
|
60
|
+
<p className="function-explorer-summary" data-role="catalog-summary">
|
|
61
|
+
{catalogSummary(catalog)}
|
|
62
|
+
</p>
|
|
63
|
+
<p className="function-explorer-note">
|
|
64
|
+
Discovery only — browsing a descriptor is not execution authority.
|
|
65
|
+
</p>
|
|
66
|
+
</header>
|
|
67
|
+
|
|
68
|
+
<div className="function-explorer-filters">
|
|
69
|
+
<label>
|
|
70
|
+
<span className="visually-hidden">Search functions</span>
|
|
71
|
+
<input
|
|
72
|
+
type="search"
|
|
73
|
+
aria-label="Search functions"
|
|
74
|
+
placeholder="Search handle, operation, or submodule"
|
|
75
|
+
value={filter.query ?? ''}
|
|
76
|
+
onChange={(event) => update({ query: event.target.value })}
|
|
77
|
+
/>
|
|
78
|
+
</label>
|
|
79
|
+
<label>
|
|
80
|
+
<span className="visually-hidden">Submodule</span>
|
|
81
|
+
<select
|
|
82
|
+
aria-label="Submodule"
|
|
83
|
+
value={filter.source ?? ''}
|
|
84
|
+
onChange={(event) => update({ source: event.target.value || null })}
|
|
85
|
+
>
|
|
86
|
+
<option value="">All sources</option>
|
|
87
|
+
{facets.sources.map((source) => (
|
|
88
|
+
<option key={source} value={source}>
|
|
89
|
+
{source}
|
|
90
|
+
</option>
|
|
91
|
+
))}
|
|
92
|
+
</select>
|
|
93
|
+
</label>
|
|
94
|
+
<label>
|
|
95
|
+
<span className="visually-hidden">Runtime</span>
|
|
96
|
+
<select
|
|
97
|
+
aria-label="Runtime"
|
|
98
|
+
value={filter.runtime ?? ''}
|
|
99
|
+
onChange={(event) => update({ runtime: event.target.value || null })}
|
|
100
|
+
>
|
|
101
|
+
<option value="">All runtimes</option>
|
|
102
|
+
{facets.runtimes.map((runtime) => (
|
|
103
|
+
<option key={runtime} value={runtime}>
|
|
104
|
+
{runtime}
|
|
105
|
+
</option>
|
|
106
|
+
))}
|
|
107
|
+
</select>
|
|
108
|
+
</label>
|
|
109
|
+
<label>
|
|
110
|
+
<span className="visually-hidden">Correctness grade</span>
|
|
111
|
+
<select
|
|
112
|
+
aria-label="Correctness grade"
|
|
113
|
+
value={filter.grade ?? ''}
|
|
114
|
+
onChange={(event) => update({ grade: event.target.value || null })}
|
|
115
|
+
>
|
|
116
|
+
<option value="">All grades</option>
|
|
117
|
+
{facets.grades.map((grade) => (
|
|
118
|
+
<option key={grade} value={grade}>
|
|
119
|
+
{grade}
|
|
120
|
+
</option>
|
|
121
|
+
))}
|
|
122
|
+
</select>
|
|
123
|
+
</label>
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
<p className="function-explorer-count" data-role="descriptor-count">
|
|
127
|
+
{visible.length} of {catalog.descriptors.length} descriptor(s)
|
|
128
|
+
</p>
|
|
129
|
+
|
|
130
|
+
<ul className="function-explorer-list">
|
|
131
|
+
{visible.map((descriptor) => (
|
|
132
|
+
<li key={descriptor.handle} data-role="descriptor">
|
|
133
|
+
<button type="button" onClick={() => onSelect?.(descriptor.handle)}>
|
|
134
|
+
<span className="function-explorer-handle">{descriptor.handle}</span>
|
|
135
|
+
<span className="function-explorer-kind">{descriptor.kind}</span>
|
|
136
|
+
<span className="function-explorer-runtime">
|
|
137
|
+
{descriptor.runtimes.length ? descriptor.runtimes.join(', ') : 'no runtime binding'}
|
|
138
|
+
</span>
|
|
139
|
+
<span className="function-explorer-grade">{descriptor.correctness_grade ?? '—'}</span>
|
|
140
|
+
</button>
|
|
141
|
+
<button
|
|
142
|
+
type="button"
|
|
143
|
+
className="function-explorer-split"
|
|
144
|
+
title="Open this descriptor beside the current tab in Dockview split mode"
|
|
145
|
+
onClick={() => requestDualSplit(`./?card=${encodeURIComponent(descriptor.handle)}`)}
|
|
146
|
+
>
|
|
147
|
+
Split
|
|
148
|
+
</button>
|
|
149
|
+
</li>
|
|
150
|
+
))}
|
|
151
|
+
</ul>
|
|
152
|
+
|
|
153
|
+
<footer className="function-explorer-actions">
|
|
154
|
+
<button type="button" disabled title={disabledReason} aria-disabled="true">
|
|
155
|
+
Execute
|
|
156
|
+
</button>
|
|
157
|
+
<button type="button" disabled title={disabledReason} aria-disabled="true">
|
|
158
|
+
Reload
|
|
159
|
+
</button>
|
|
160
|
+
<span className="function-explorer-disabled-reason" data-role="execution-reason">
|
|
161
|
+
{disabledReason}
|
|
162
|
+
</span>
|
|
163
|
+
</footer>
|
|
164
|
+
</section>
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export default UnifiedFunctionExplorerViewlet;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/components/studio/views/history/HistoryPanel.tsx
|
|
3
|
+
*
|
|
4
|
+
* MCard Studio History Panel (Sprint CAS-08 / DoD-08-3).
|
|
5
|
+
* Lists transitions(handle) with kind badges (UPDATE, RELOCATE, TOMBSTONE) and conflict markers.
|
|
6
|
+
* Contract D budget: <= 250 LOC.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import React, { FC } from 'react';
|
|
10
|
+
|
|
11
|
+
export interface TransitionItem {
|
|
12
|
+
readonly hash?: string;
|
|
13
|
+
readonly handle?: string;
|
|
14
|
+
readonly kind?: 'CREATE' | 'UPDATE' | 'RELOCATE' | 'TOMBSTONE' | string;
|
|
15
|
+
readonly from?: string | null;
|
|
16
|
+
readonly to?: string | null;
|
|
17
|
+
readonly author?: string;
|
|
18
|
+
readonly conflict?: boolean;
|
|
19
|
+
readonly clock?: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface HistoryPanelProps {
|
|
23
|
+
readonly handle: string;
|
|
24
|
+
readonly transitions: readonly TransitionItem[];
|
|
25
|
+
readonly onSelectTransition?: (transition: TransitionItem) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const HistoryPanel: FC<HistoryPanelProps> = ({
|
|
29
|
+
handle,
|
|
30
|
+
transitions,
|
|
31
|
+
onSelectTransition,
|
|
32
|
+
}) => {
|
|
33
|
+
return (
|
|
34
|
+
<div data-testid="history-panel" className="history-panel p-4 flex flex-col gap-3 font-mono text-xs">
|
|
35
|
+
<div className="flex items-center justify-between border-b pb-2">
|
|
36
|
+
<span className="font-semibold text-sm text-foreground">History: {handle}</span>
|
|
37
|
+
<span className="text-muted-foreground">{transitions.length} transition(s)</span>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
{transitions.length === 0 ? (
|
|
41
|
+
<div data-testid="empty-history" className="text-muted-foreground py-4">
|
|
42
|
+
No transitions recorded for this handle.
|
|
43
|
+
</div>
|
|
44
|
+
) : (
|
|
45
|
+
<ul className="flex flex-col gap-2 list-none p-0 m-0">
|
|
46
|
+
{transitions.map((t, idx) => {
|
|
47
|
+
const kind = t.kind || 'UPDATE';
|
|
48
|
+
const isConflict = Boolean(t.conflict);
|
|
49
|
+
const toHash = t.to || t.hash || '—';
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<li
|
|
53
|
+
key={`${t.hash || idx}-${idx}`}
|
|
54
|
+
data-testid={`transition-item-${idx}`}
|
|
55
|
+
onClick={() => onSelectTransition?.(t)}
|
|
56
|
+
className={`p-2 rounded border border-border flex flex-col gap-1 transition-colors ${
|
|
57
|
+
onSelectTransition ? 'cursor-pointer hover:bg-muted/40' : ''
|
|
58
|
+
}`}
|
|
59
|
+
>
|
|
60
|
+
<div className="flex items-center justify-between">
|
|
61
|
+
<div className="flex items-center gap-2">
|
|
62
|
+
<span
|
|
63
|
+
data-testid={`kind-badge-${idx}`}
|
|
64
|
+
className={`px-1.5 py-0.5 rounded text-[10px] font-bold uppercase ${
|
|
65
|
+
kind === 'TOMBSTONE'
|
|
66
|
+
? 'bg-destructive/20 text-destructive'
|
|
67
|
+
: kind === 'RELOCATE'
|
|
68
|
+
? 'bg-amber-500/20 text-amber-500'
|
|
69
|
+
: 'bg-primary/20 text-primary'
|
|
70
|
+
}`}
|
|
71
|
+
>
|
|
72
|
+
{kind}
|
|
73
|
+
</span>
|
|
74
|
+
{isConflict && (
|
|
75
|
+
<span
|
|
76
|
+
data-testid={`conflict-marker-${idx}`}
|
|
77
|
+
className="px-1.5 py-0.5 rounded text-[10px] font-bold bg-amber-600 text-white"
|
|
78
|
+
>
|
|
79
|
+
[CONFLICT]
|
|
80
|
+
</span>
|
|
81
|
+
)}
|
|
82
|
+
</div>
|
|
83
|
+
{t.author && (
|
|
84
|
+
<span data-testid={`author-${idx}`} className="text-muted-foreground text-[10px]">
|
|
85
|
+
{t.author}
|
|
86
|
+
</span>
|
|
87
|
+
)}
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div className="text-[11px] truncate">
|
|
91
|
+
<span className="text-muted-foreground">Target: </span>
|
|
92
|
+
<span className="text-foreground">{toHash}</span>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
{t.from && (
|
|
96
|
+
<div className="text-[10px] text-muted-foreground truncate">
|
|
97
|
+
<span>From: </span>
|
|
98
|
+
<span>{t.from}</span>
|
|
99
|
+
</div>
|
|
100
|
+
)}
|
|
101
|
+
</li>
|
|
102
|
+
);
|
|
103
|
+
})}
|
|
104
|
+
</ul>
|
|
105
|
+
)}
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default HistoryPanel;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/components/studio/views/lineage/LineagePanel.tsx
|
|
3
|
+
*
|
|
4
|
+
* MCard Studio Lineage & Anchor Panel (Sprint CAS-08 / DoD-08-3, DoD-08-6).
|
|
5
|
+
* Renders the anchor chain from newest to genesis with actor DID, reason, pruned count,
|
|
6
|
+
* container ref, and reimport successors. Includes "Find this hash" resolution.
|
|
7
|
+
*
|
|
8
|
+
* Contract D budget: <= 250 LOC.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React, { FC, useState } from 'react';
|
|
12
|
+
import type {
|
|
13
|
+
LineageAnchorViewModel,
|
|
14
|
+
LineageResolutionResult,
|
|
15
|
+
} from '../../../../core/projection/views';
|
|
16
|
+
|
|
17
|
+
export interface LineagePanelProps {
|
|
18
|
+
readonly anchors: readonly LineageAnchorViewModel[];
|
|
19
|
+
readonly onFindHash?: (query: string) => LineageResolutionResult;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const LineagePanel: FC<LineagePanelProps> = ({ anchors, onFindHash }) => {
|
|
23
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
24
|
+
const [searchResult, setSearchResult] = useState<LineageResolutionResult | null>(null);
|
|
25
|
+
|
|
26
|
+
const handleSearch = (e: React.FormEvent) => {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
if (!searchQuery.trim() || !onFindHash) return;
|
|
29
|
+
const res = onFindHash(searchQuery.trim());
|
|
30
|
+
setSearchResult(res);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div data-testid="lineage-panel" className="lineage-panel p-4 flex flex-col gap-4 font-mono text-xs">
|
|
35
|
+
<div className="flex items-center justify-between border-b pb-2">
|
|
36
|
+
<span className="font-semibold text-sm text-foreground">Lineage Chain & Anchors</span>
|
|
37
|
+
<span className="text-muted-foreground">{anchors.length} anchor(s)</span>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
{/* 1. Find This Hash Search */}
|
|
41
|
+
<form onSubmit={handleSearch} className="flex gap-2">
|
|
42
|
+
<input
|
|
43
|
+
data-testid="find-hash-input"
|
|
44
|
+
type="text"
|
|
45
|
+
value={searchQuery}
|
|
46
|
+
onChange={(e) => setSearchQuery(e.target.value)}
|
|
47
|
+
placeholder="Find this hash in lineage..."
|
|
48
|
+
className="flex-1 px-2.5 py-1.5 rounded border border-border bg-background text-foreground text-xs font-mono"
|
|
49
|
+
/>
|
|
50
|
+
<button
|
|
51
|
+
data-testid="find-hash-btn"
|
|
52
|
+
type="submit"
|
|
53
|
+
className="px-3 py-1.5 rounded bg-primary text-primary-foreground font-semibold text-xs cursor-pointer hover:opacity-90"
|
|
54
|
+
>
|
|
55
|
+
Find
|
|
56
|
+
</button>
|
|
57
|
+
</form>
|
|
58
|
+
|
|
59
|
+
{/* Search Result */}
|
|
60
|
+
{searchResult && (
|
|
61
|
+
<div data-testid="search-result-box" className="p-3 rounded border border-border bg-card/60 flex flex-col gap-1">
|
|
62
|
+
<div className="flex items-center gap-2">
|
|
63
|
+
<span className="text-muted-foreground">Location:</span>
|
|
64
|
+
<span
|
|
65
|
+
data-testid="search-location"
|
|
66
|
+
className={`font-bold px-1.5 py-0.5 rounded text-[11px] ${
|
|
67
|
+
searchResult.location === 'working'
|
|
68
|
+
? 'bg-emerald-500/20 text-emerald-600'
|
|
69
|
+
: searchResult.location === 'archive'
|
|
70
|
+
? 'bg-blue-500/20 text-blue-600'
|
|
71
|
+
: 'bg-destructive/20 text-destructive'
|
|
72
|
+
}`}
|
|
73
|
+
>
|
|
74
|
+
{searchResult.location}
|
|
75
|
+
</span>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
{searchResult.containerRef && (
|
|
79
|
+
<div className="text-[11px] truncate">
|
|
80
|
+
<span className="text-muted-foreground">Archive container: </span>
|
|
81
|
+
<span data-testid="search-container">{searchResult.containerRef}</span>
|
|
82
|
+
</div>
|
|
83
|
+
)}
|
|
84
|
+
|
|
85
|
+
{searchResult.anchorHash && (
|
|
86
|
+
<div className="text-[11px] truncate">
|
|
87
|
+
<span className="text-muted-foreground">Pinned by anchor: </span>
|
|
88
|
+
<span data-testid="search-anchor">{searchResult.anchorHash}</span>
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
|
|
92
|
+
{searchResult.isReimported && searchResult.archivedOriginal && (
|
|
93
|
+
<div data-testid="reimported-original-box" className="text-[11px] text-amber-600 pt-1 border-t border-border/50">
|
|
94
|
+
<span>Reimported record. Archived original available: </span>
|
|
95
|
+
<span data-testid="archived-original" className="font-semibold">{searchResult.archivedOriginal}</span>
|
|
96
|
+
</div>
|
|
97
|
+
)}
|
|
98
|
+
</div>
|
|
99
|
+
)}
|
|
100
|
+
|
|
101
|
+
{/* 2. Anchor Chain List */}
|
|
102
|
+
{anchors.length === 0 ? (
|
|
103
|
+
<div data-testid="empty-anchors" className="text-muted-foreground py-4">
|
|
104
|
+
No lineage anchors in working tape.
|
|
105
|
+
</div>
|
|
106
|
+
) : (
|
|
107
|
+
<div className="flex flex-col gap-3">
|
|
108
|
+
{anchors.map((a, idx) => (
|
|
109
|
+
<div
|
|
110
|
+
key={a.hash}
|
|
111
|
+
data-testid={`anchor-card-${idx}`}
|
|
112
|
+
className="p-3 rounded border border-border bg-card/40 flex flex-col gap-1.5"
|
|
113
|
+
>
|
|
114
|
+
<div className="flex items-center justify-between">
|
|
115
|
+
<span className="font-semibold text-foreground text-[11px]">
|
|
116
|
+
Anchor #{anchors.length - idx}: {a.hash.slice(0, 12)}...
|
|
117
|
+
</span>
|
|
118
|
+
<span className="text-muted-foreground text-[10px]">{a.reason}</span>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<div className="flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground">
|
|
122
|
+
{a.actor && <span data-testid={`actor-${idx}`}>actor: {a.actor}</span>}
|
|
123
|
+
<span data-testid={`sig-status-${idx}`}>sig: {a.signatureStatus}</span>
|
|
124
|
+
<span data-testid={`pruned-count-${idx}`}>pruned: {a.prunedCount} card(s)</span>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<div className="text-[10px] text-muted-foreground truncate">
|
|
128
|
+
<span>archive: {a.archiveRef}</span>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
{a.successors && a.successors.length > 0 && (
|
|
132
|
+
<div data-testid={`successors-${idx}`} className="text-[10px] pt-1 border-t border-border/40">
|
|
133
|
+
<span className="font-semibold text-foreground">Reimport successors ({a.successors.length}):</span>
|
|
134
|
+
<ul className="list-disc pl-4 mt-0.5 space-y-0.5">
|
|
135
|
+
{a.successors.slice(0, 5).map((s) => (
|
|
136
|
+
<li key={s.old} className="truncate">
|
|
137
|
+
{s.old.slice(0, 10)}... → {s.next.slice(0, 10)}...
|
|
138
|
+
</li>
|
|
139
|
+
))}
|
|
140
|
+
{a.successors.length > 5 && <li>+{a.successors.length - 5} more</li>}
|
|
141
|
+
</ul>
|
|
142
|
+
</div>
|
|
143
|
+
)}
|
|
144
|
+
</div>
|
|
145
|
+
))}
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
148
|
+
</div>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export default LineagePanel;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HandleLineageDrawer — the interactive `handle_history` lineage viewer
|
|
3
|
+
* (SMR-10 · DoD-SMR-10-02).
|
|
4
|
+
*
|
|
5
|
+
* Shows a handle's revision chain and can restore a prior revision as HEAD. The
|
|
6
|
+
* comparison and restore target are computed by the pure projection module
|
|
7
|
+
* `@/core/projection/collection`; this component only renders and raises intents —
|
|
8
|
+
* it never writes to the store itself.
|
|
9
|
+
*
|
|
10
|
+
* Contract D budget: <= 200 LOC.
|
|
11
|
+
*/
|
|
12
|
+
import React from 'react';
|
|
13
|
+
|
|
14
|
+
import type { HandleLineageViewModel } from '@/core/projection/collection';
|
|
15
|
+
|
|
16
|
+
export interface HandleLineageDrawerProps {
|
|
17
|
+
readonly lineage: HandleLineageViewModel;
|
|
18
|
+
readonly onRestore?: (hash: string) => void;
|
|
19
|
+
readonly onClose?: () => void;
|
|
20
|
+
readonly busy?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const HandleLineageDrawer: React.FC<HandleLineageDrawerProps> = ({
|
|
24
|
+
lineage,
|
|
25
|
+
onRestore,
|
|
26
|
+
onClose,
|
|
27
|
+
busy = false,
|
|
28
|
+
}) => {
|
|
29
|
+
const { handle, currentHash, revisions, revisionCount, restorable, restoreTarget } = lineage;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<aside className="mcard-lineage-drawer" aria-label={`Handle lineage for ${handle}`}>
|
|
33
|
+
<header className="mcard-lineage-header">
|
|
34
|
+
<h3>{handle}</h3>
|
|
35
|
+
{onClose && (
|
|
36
|
+
<button type="button" onClick={onClose} aria-label="Close lineage drawer">
|
|
37
|
+
✕
|
|
38
|
+
</button>
|
|
39
|
+
)}
|
|
40
|
+
</header>
|
|
41
|
+
|
|
42
|
+
<dl className="mcard-lineage-current">
|
|
43
|
+
<dt>Current (HEAD)</dt>
|
|
44
|
+
<dd>
|
|
45
|
+
<code>{currentHash}</code>
|
|
46
|
+
</dd>
|
|
47
|
+
<dt>Revisions</dt>
|
|
48
|
+
<dd data-role="revision-count">{revisionCount}</dd>
|
|
49
|
+
</dl>
|
|
50
|
+
|
|
51
|
+
{revisions.length === 0 ? (
|
|
52
|
+
<p className="mcard-lineage-empty">
|
|
53
|
+
No prior revisions recorded. The handle has never been re-bound.
|
|
54
|
+
</p>
|
|
55
|
+
) : (
|
|
56
|
+
<ol className="mcard-lineage-revisions">
|
|
57
|
+
{revisions.map((revision) => {
|
|
58
|
+
const isRestoreTarget = revision.previousHash === restoreTarget;
|
|
59
|
+
return (
|
|
60
|
+
<li key={`${revision.previousHash}-${revision.changedAt}`} data-role="revision">
|
|
61
|
+
<code>{revision.previousHash}</code>
|
|
62
|
+
<time dateTime={revision.changedAt}>{revision.changedAt}</time>
|
|
63
|
+
{isRestoreTarget && <span className="mcard-lineage-marker">previous</span>}
|
|
64
|
+
</li>
|
|
65
|
+
);
|
|
66
|
+
})}
|
|
67
|
+
</ol>
|
|
68
|
+
)}
|
|
69
|
+
|
|
70
|
+
<footer className="mcard-lineage-actions">
|
|
71
|
+
<button
|
|
72
|
+
type="button"
|
|
73
|
+
disabled={!restorable || busy || !onRestore}
|
|
74
|
+
title={
|
|
75
|
+
restorable
|
|
76
|
+
? 'Re-bind the preceding revision as HEAD; the current hash is retained in handle_history'
|
|
77
|
+
: 'Nothing to restore: this handle has a single revision'
|
|
78
|
+
}
|
|
79
|
+
onClick={() => restorable && restoreTarget && onRestore?.(restoreTarget)}
|
|
80
|
+
>
|
|
81
|
+
Restore previous revision
|
|
82
|
+
</button>
|
|
83
|
+
{!restorable && <span className="mcard-lineage-hint">Single revision — restore unavailable.</span>}
|
|
84
|
+
</footer>
|
|
85
|
+
</aside>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default HandleLineageDrawer;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MultiCardCollectionBrowser — absorbs LandingPage's multi-card collection
|
|
3
|
+
* management into the Studio (SMR-10 · DoD-SMR-10-02).
|
|
4
|
+
*
|
|
5
|
+
* Multi-card search, MIME and handle filtering, duplicate-handle cleanup, and
|
|
6
|
+
* multi-dataset mounting. All selection logic lives in the pure projection module
|
|
7
|
+
* `@/core/projection/collection`; this component only renders it and raises intents.
|
|
8
|
+
*
|
|
9
|
+
* Contract D budget: <= 250 LOC.
|
|
10
|
+
*/
|
|
11
|
+
import React, { useMemo, useState } from 'react';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
collectionMimeTypes,
|
|
15
|
+
filterCollectionCards,
|
|
16
|
+
summarizeCleanup,
|
|
17
|
+
type CollectionCard,
|
|
18
|
+
type CollectionFilter,
|
|
19
|
+
type DuplicateGroup,
|
|
20
|
+
} from '@/core/projection/collection';
|
|
21
|
+
|
|
22
|
+
export interface MountedSource {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly label: string;
|
|
25
|
+
readonly cardCount: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface MultiCardCollectionBrowserProps {
|
|
29
|
+
readonly cards: readonly CollectionCard[];
|
|
30
|
+
readonly duplicates?: readonly DuplicateGroup[];
|
|
31
|
+
readonly sources?: readonly MountedSource[];
|
|
32
|
+
readonly onSelect?: (card: CollectionCard) => void;
|
|
33
|
+
readonly onCleanupDuplicates?: (groups: readonly DuplicateGroup[]) => void;
|
|
34
|
+
readonly onMountSource?: (sourceId: string) => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const MultiCardCollectionBrowser: React.FC<MultiCardCollectionBrowserProps> = ({
|
|
38
|
+
cards,
|
|
39
|
+
duplicates = [],
|
|
40
|
+
sources = [],
|
|
41
|
+
onSelect,
|
|
42
|
+
onCleanupDuplicates,
|
|
43
|
+
onMountSource,
|
|
44
|
+
}) => {
|
|
45
|
+
const [filter, setFilter] = useState<CollectionFilter>({ sort: 'newest' });
|
|
46
|
+
|
|
47
|
+
const mimeTypes = useMemo(() => collectionMimeTypes(cards), [cards]);
|
|
48
|
+
const visible = useMemo(() => filterCollectionCards(cards, filter), [cards, filter]);
|
|
49
|
+
const cleanup = useMemo(() => summarizeCleanup(duplicates), [duplicates]);
|
|
50
|
+
|
|
51
|
+
const update = (patch: Partial<CollectionFilter>) => setFilter((current) => ({ ...current, ...patch }));
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<section className="mcard-collection-browser" aria-label="Multi-card collection browser">
|
|
55
|
+
<header className="mcard-collection-toolbar">
|
|
56
|
+
<label className="mcard-collection-field">
|
|
57
|
+
<span className="visually-hidden">Search cards</span>
|
|
58
|
+
<input
|
|
59
|
+
type="search"
|
|
60
|
+
placeholder="Search handle, hash, or MIME"
|
|
61
|
+
aria-label="Search cards"
|
|
62
|
+
value={filter.query ?? ''}
|
|
63
|
+
onChange={(event) => update({ query: event.target.value })}
|
|
64
|
+
/>
|
|
65
|
+
</label>
|
|
66
|
+
|
|
67
|
+
<label className="mcard-collection-field">
|
|
68
|
+
<span className="visually-hidden">Filter by MIME type</span>
|
|
69
|
+
<select
|
|
70
|
+
aria-label="Filter by MIME type"
|
|
71
|
+
value={filter.mime ?? ''}
|
|
72
|
+
onChange={(event) => update({ mime: event.target.value || null })}
|
|
73
|
+
>
|
|
74
|
+
<option value="">All MIME types</option>
|
|
75
|
+
{mimeTypes.map((mime) => (
|
|
76
|
+
<option key={mime} value={mime}>
|
|
77
|
+
{mime}
|
|
78
|
+
</option>
|
|
79
|
+
))}
|
|
80
|
+
</select>
|
|
81
|
+
</label>
|
|
82
|
+
|
|
83
|
+
<label className="mcard-collection-field">
|
|
84
|
+
<span className="visually-hidden">Filter by handle prefix</span>
|
|
85
|
+
<input
|
|
86
|
+
type="text"
|
|
87
|
+
placeholder="urn:mcard:…"
|
|
88
|
+
aria-label="Filter by handle prefix"
|
|
89
|
+
value={filter.handlePrefix ?? ''}
|
|
90
|
+
onChange={(event) => update({ handlePrefix: event.target.value || null })}
|
|
91
|
+
/>
|
|
92
|
+
</label>
|
|
93
|
+
|
|
94
|
+
<label className="mcard-collection-field">
|
|
95
|
+
<span className="visually-hidden">Sort order</span>
|
|
96
|
+
<select
|
|
97
|
+
aria-label="Sort order"
|
|
98
|
+
value={filter.sort ?? 'newest'}
|
|
99
|
+
onChange={(event) => update({ sort: event.target.value as CollectionFilter['sort'] })}
|
|
100
|
+
>
|
|
101
|
+
<option value="newest">Newest first</option>
|
|
102
|
+
<option value="oldest">Oldest first</option>
|
|
103
|
+
<option value="handle">By handle</option>
|
|
104
|
+
</select>
|
|
105
|
+
</label>
|
|
106
|
+
</header>
|
|
107
|
+
|
|
108
|
+
{duplicates.length > 0 && (
|
|
109
|
+
<aside className="mcard-collection-duplicates" role="alert">
|
|
110
|
+
<p>
|
|
111
|
+
{cleanup.handles} handle(s) reach more than one hash — {cleanup.released} stale binding(s) can be
|
|
112
|
+
released.
|
|
113
|
+
</p>
|
|
114
|
+
<button type="button" onClick={() => onCleanupDuplicates?.(duplicates)}>
|
|
115
|
+
Release stale bindings
|
|
116
|
+
</button>
|
|
117
|
+
</aside>
|
|
118
|
+
)}
|
|
119
|
+
|
|
120
|
+
{sources.length > 0 && (
|
|
121
|
+
<nav className="mcard-collection-sources" aria-label="Mounted datasets">
|
|
122
|
+
{sources.map((source) => (
|
|
123
|
+
<button
|
|
124
|
+
key={source.id}
|
|
125
|
+
type="button"
|
|
126
|
+
aria-pressed={false}
|
|
127
|
+
onClick={() => onMountSource?.(source.id)}
|
|
128
|
+
>
|
|
129
|
+
{source.label} ({source.cardCount})
|
|
130
|
+
</button>
|
|
131
|
+
))}
|
|
132
|
+
</nav>
|
|
133
|
+
)}
|
|
134
|
+
|
|
135
|
+
<p className="mcard-collection-count" data-role="result-count">
|
|
136
|
+
{visible.length} of {cards.length} card(s)
|
|
137
|
+
</p>
|
|
138
|
+
|
|
139
|
+
<ul className="mcard-collection-list" aria-label="Cards">
|
|
140
|
+
{visible.map((card) => (
|
|
141
|
+
<li key={card.hash}>
|
|
142
|
+
<button type="button" onClick={() => onSelect?.(card)}>
|
|
143
|
+
<span className="mcard-collection-handle">{card.handle ?? '(unbound)'}</span>
|
|
144
|
+
<code className="mcard-collection-hash">{card.hash.slice(0, 12)}…</code>
|
|
145
|
+
<span className="mcard-collection-mime">{card.mimeType ?? 'unknown'}</span>
|
|
146
|
+
</button>
|
|
147
|
+
</li>
|
|
148
|
+
))}
|
|
149
|
+
</ul>
|
|
150
|
+
</section>
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export default MultiCardCollectionBrowser;
|