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,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device-Archetype Preset Bar & Viewport Style Resolver (SMR-12 · DoD-SMR-12-03)
|
|
3
|
+
* Canonical Path: src/components/studio/views/cardViewlets/webapp/WebappDevicePresetBar.tsx
|
|
4
|
+
*
|
|
5
|
+
* Extracted from WebappZenViewlet.tsx to preserve INV-304-11 (<=150 LOC thin membrane).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import type { ViewportMode } from './types';
|
|
10
|
+
import {
|
|
11
|
+
DEVICE_CLASSES,
|
|
12
|
+
DEVICE_PRESETS,
|
|
13
|
+
getPreset,
|
|
14
|
+
} from '../../../../../core/viewport/deviceArchetypeRegistry';
|
|
15
|
+
|
|
16
|
+
const FRAMED_SHADOW = '0 0 24px rgba(0, 0, 0, 0.6)';
|
|
17
|
+
const MOBILE_SHADOW = '0 0 28px rgba(0, 0, 0, 0.7)';
|
|
18
|
+
const FRAMED_BORDER = '1px solid #3c3c3c';
|
|
19
|
+
|
|
20
|
+
export function resolveWebappViewportStyles(
|
|
21
|
+
presetId: string | null,
|
|
22
|
+
viewportMode: ViewportMode,
|
|
23
|
+
): React.CSSProperties {
|
|
24
|
+
const preset = presetId ? getPreset(presetId) : undefined;
|
|
25
|
+
if (preset) {
|
|
26
|
+
if (preset.deviceClass === 'desktop') {
|
|
27
|
+
return { width: '100%', height: '100%' };
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
width: `${preset.width}px`,
|
|
31
|
+
maxWidth: '100%',
|
|
32
|
+
height: '100%',
|
|
33
|
+
margin: '0 auto',
|
|
34
|
+
boxShadow: FRAMED_SHADOW,
|
|
35
|
+
borderLeft: FRAMED_BORDER,
|
|
36
|
+
borderRight: FRAMED_BORDER,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
switch (viewportMode) {
|
|
40
|
+
case 'tablet':
|
|
41
|
+
return {
|
|
42
|
+
width: '768px',
|
|
43
|
+
maxWidth: '100%',
|
|
44
|
+
height: '100%',
|
|
45
|
+
margin: '0 auto',
|
|
46
|
+
boxShadow: FRAMED_SHADOW,
|
|
47
|
+
borderLeft: FRAMED_BORDER,
|
|
48
|
+
borderRight: FRAMED_BORDER,
|
|
49
|
+
};
|
|
50
|
+
case 'mobile':
|
|
51
|
+
return {
|
|
52
|
+
width: '375px',
|
|
53
|
+
maxWidth: '100%',
|
|
54
|
+
height: '100%',
|
|
55
|
+
margin: '0 auto',
|
|
56
|
+
boxShadow: MOBILE_SHADOW,
|
|
57
|
+
borderLeft: FRAMED_BORDER,
|
|
58
|
+
borderRight: FRAMED_BORDER,
|
|
59
|
+
};
|
|
60
|
+
case 'desktop':
|
|
61
|
+
default:
|
|
62
|
+
return { width: '100%', height: '100%' };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface WebappDevicePresetBarProps {
|
|
67
|
+
presetId: string | null;
|
|
68
|
+
setPresetId: (presetId: string | null) => void;
|
|
69
|
+
targetUrl: string;
|
|
70
|
+
useProxy: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const WebappDevicePresetBar: React.FC<WebappDevicePresetBarProps> = ({
|
|
74
|
+
presetId,
|
|
75
|
+
setPresetId,
|
|
76
|
+
targetUrl,
|
|
77
|
+
useProxy,
|
|
78
|
+
}) => {
|
|
79
|
+
const openResponsiveLab = () => {
|
|
80
|
+
window.dispatchEvent(
|
|
81
|
+
new CustomEvent('clm:open-responsive-lab', {
|
|
82
|
+
detail: { url: targetUrl, presetId, useProxy },
|
|
83
|
+
}),
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div className="webapp-viewport-presets" data-role="viewport-presets">
|
|
89
|
+
<label htmlFor="webapp-device-preset">Device</label>
|
|
90
|
+
<select
|
|
91
|
+
id="webapp-device-preset"
|
|
92
|
+
data-role="device-preset"
|
|
93
|
+
value={presetId ?? ''}
|
|
94
|
+
onChange={(e) => setPresetId(e.target.value || null)}
|
|
95
|
+
>
|
|
96
|
+
<option value="">Address-bar mode</option>
|
|
97
|
+
{DEVICE_PRESETS.map((p) => (
|
|
98
|
+
<option key={p.id} value={p.id}>
|
|
99
|
+
{DEVICE_CLASSES[p.deviceClass].label} · {p.label} {p.width}×{p.height}
|
|
100
|
+
</option>
|
|
101
|
+
))}
|
|
102
|
+
</select>
|
|
103
|
+
<button type="button" data-role="open-responsive-lab" onClick={openResponsiveLab}>
|
|
104
|
+
Open in Responsive Lab
|
|
105
|
+
</button>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
@@ -16,12 +16,14 @@ import { FullscreenIframeModal } from '../FullscreenIframeModal';
|
|
|
16
16
|
import { WebappAddressBar } from './WebappAddressBar';
|
|
17
17
|
import { ProxyAdvisoryBanner } from './ProxyAdvisoryBanner';
|
|
18
18
|
import { WebappCanvas } from './WebappCanvas';
|
|
19
|
+
import { WebappDevicePresetBar, resolveWebappViewportStyles } from './WebappDevicePresetBar';
|
|
19
20
|
import { useWebappSecurityProbe } from './hooks/useWebappSecurityProbe';
|
|
20
21
|
import { useZenAudioTeardown } from './hooks/useZenAudioTeardown';
|
|
21
22
|
|
|
22
23
|
export const WebappZenViewlet: React.FC<CardViewletProps> = ({ mcard }) => {
|
|
23
24
|
const [isZenOpen, setIsZenOpen] = useState(false);
|
|
24
25
|
const [viewportMode, setViewportMode] = useState<ViewportMode>('desktop');
|
|
26
|
+
const [presetId, setPresetId] = useState<string | null>(null);
|
|
25
27
|
const [isLoading, setIsLoading] = useState(true);
|
|
26
28
|
const [iframeKey, setIframeKey] = useState(0);
|
|
27
29
|
const [copied, setCopied] = useState(false);
|
|
@@ -29,35 +31,24 @@ export const WebappZenViewlet: React.FC<CardViewletProps> = ({ mcard }) => {
|
|
|
29
31
|
// Cordis Rule 3: Clean WebAudio and animation loop teardown on unmount
|
|
30
32
|
useZenAudioTeardown();
|
|
31
33
|
|
|
32
|
-
const targetUrl = useMemo(
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
const targetUrl = useMemo(
|
|
35
|
+
() => extractWebappUrl(mcard.content, mcard.path, mcard.name),
|
|
36
|
+
[mcard.content, mcard.path, mcard.name],
|
|
37
|
+
);
|
|
35
38
|
|
|
36
39
|
const {
|
|
37
|
-
probeData,
|
|
38
|
-
|
|
39
|
-
setUseProxy,
|
|
40
|
-
hasShieldError,
|
|
41
|
-
setHasShieldError,
|
|
42
|
-
isAdvisoryDismissed,
|
|
43
|
-
setIsAdvisoryDismissed,
|
|
44
|
-
forceDirectEmbed,
|
|
45
|
-
setForceDirectEmbed,
|
|
46
|
-
activeSrc,
|
|
40
|
+
probeData, useProxy, setUseProxy, hasShieldError, setHasShieldError,
|
|
41
|
+
isAdvisoryDismissed, setIsAdvisoryDismissed, forceDirectEmbed, setForceDirectEmbed, activeSrc,
|
|
47
42
|
} = useWebappSecurityProbe(targetUrl);
|
|
48
43
|
|
|
49
44
|
// SV-08: Auto-enable proxy shield on fullscreen split request
|
|
50
45
|
React.useEffect(() => {
|
|
51
46
|
const handleSplitReq = (e: Event) => {
|
|
52
47
|
const detail = (e as CustomEvent<{ targetUrl?: string; useProxy?: boolean }>).detail;
|
|
53
|
-
if (detail?.useProxy || probeData?.shouldBlockEmbed)
|
|
54
|
-
setUseProxy(true);
|
|
55
|
-
}
|
|
48
|
+
if (detail?.useProxy || probeData?.shouldBlockEmbed) setUseProxy(true);
|
|
56
49
|
};
|
|
57
50
|
window.addEventListener('clm:fullscreen-split-requested', handleSplitReq);
|
|
58
|
-
return () =>
|
|
59
|
-
window.removeEventListener('clm:fullscreen-split-requested', handleSplitReq);
|
|
60
|
-
};
|
|
51
|
+
return () => window.removeEventListener('clm:fullscreen-split-requested', handleSplitReq);
|
|
61
52
|
}, [probeData?.shouldBlockEmbed, setUseProxy]);
|
|
62
53
|
|
|
63
54
|
const handleCopyUrl = async () => {
|
|
@@ -75,17 +66,12 @@ export const WebappZenViewlet: React.FC<CardViewletProps> = ({ mcard }) => {
|
|
|
75
66
|
setIframeKey((k) => k + 1);
|
|
76
67
|
};
|
|
77
68
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
case 'desktop':
|
|
85
|
-
default:
|
|
86
|
-
return { width: '100%', height: '100%' };
|
|
87
|
-
}
|
|
88
|
-
}, [viewportMode]);
|
|
69
|
+
// SMR-12: an explicit device-archetype preset takes precedence over the coarse
|
|
70
|
+
// address-bar mode; the address bar keeps working when no preset is chosen.
|
|
71
|
+
const viewportStyles = useMemo<React.CSSProperties>(
|
|
72
|
+
() => resolveWebappViewportStyles(presetId, viewportMode),
|
|
73
|
+
[presetId, viewportMode],
|
|
74
|
+
);
|
|
89
75
|
|
|
90
76
|
return (
|
|
91
77
|
<div className="webapp-zen-viewlet" style={{ display: 'flex', flexDirection: 'column', height: '100%', width: '100%', backgroundColor: '#181818', color: '#cccccc', position: 'relative', overflow: 'hidden' }}>
|
|
@@ -115,6 +101,13 @@ export const WebappZenViewlet: React.FC<CardViewletProps> = ({ mcard }) => {
|
|
|
115
101
|
targetUrl={targetUrl}
|
|
116
102
|
/>
|
|
117
103
|
|
|
104
|
+
<WebappDevicePresetBar
|
|
105
|
+
presetId={presetId}
|
|
106
|
+
setPresetId={setPresetId}
|
|
107
|
+
targetUrl={targetUrl}
|
|
108
|
+
useProxy={useProxy}
|
|
109
|
+
/>
|
|
110
|
+
|
|
118
111
|
<WebappCanvas
|
|
119
112
|
appName={mcard.name}
|
|
120
113
|
viewportStyles={viewportStyles}
|
|
@@ -34,8 +34,8 @@ export const MCardFileTree: React.FC = () => {
|
|
|
34
34
|
const { draggedItem, dragOverPath, setDraggedItem, setDragOverPath, handleDrop, handleDragOver, handleDragLeave } = useDragAndDrop();
|
|
35
35
|
const { handleUploadFile, handleForkDirectory } = useFileTreeTransactions({ onRefresh: handleRefresh });
|
|
36
36
|
|
|
37
|
-
const { filteredTrees, matchCounts, itemCounts, totalMatches, autoExpandedDirs, isFiltering } = usePartitionedTrees(treeMap, query);
|
|
38
|
-
const { sections, expanded, toggleSection } = useSectionAccordion(activeMCard?.handle || activeMCard?.path || null, isFiltering, matchCounts);
|
|
37
|
+
const { sections: dynamicSections, filteredTrees, matchCounts, itemCounts, totalMatches, autoExpandedDirs, isFiltering } = usePartitionedTrees(treeMap, query);
|
|
38
|
+
const { sections, expanded, toggleSection } = useSectionAccordion(activeMCard?.handle || activeMCard?.path || null, isFiltering, matchCounts, dynamicSections);
|
|
39
39
|
|
|
40
40
|
const toggleCollapse = useCallback((dirPath: string) => {
|
|
41
41
|
setCollapsedDirs((prev) => ({ ...prev, [dirPath]: !prev[dirPath] }));
|
|
@@ -48,63 +48,80 @@ export const MCardFileTree: React.FC = () => {
|
|
|
48
48
|
return copy;
|
|
49
49
|
}, [collapsedDirs, autoExpandedDirs, isFiltering]);
|
|
50
50
|
|
|
51
|
+
const rwSections = useMemo(() => sections.filter((s) => s.mode === 'read-write'), [sections]);
|
|
52
|
+
const roSections = useMemo(() => sections.filter((s) => s.mode === 'read-only'), [sections]);
|
|
53
|
+
|
|
54
|
+
const renderSection = (sec: (typeof sections)[number]) => (
|
|
55
|
+
<ExplorerSection
|
|
56
|
+
key={sec.id}
|
|
57
|
+
id={sec.id}
|
|
58
|
+
title={sec.title}
|
|
59
|
+
mode={sec.mode}
|
|
60
|
+
icon={sec.mode === 'read-only' ? <LockIcon size={12} /> : undefined}
|
|
61
|
+
isExpanded={expanded[sec.id] ?? false}
|
|
62
|
+
itemCount={itemCounts[sec.id] || 0}
|
|
63
|
+
matchCount={isFiltering ? matchCounts[sec.id] : undefined}
|
|
64
|
+
onToggle={() => toggleSection(sec.id)}
|
|
65
|
+
actions={
|
|
66
|
+
sec.mode === 'read-write' ? (
|
|
67
|
+
<>
|
|
68
|
+
<button type="button" data-testid="section-new-card-btn" title="New Card" onClick={() => startCardInsertion(resolveTargetFolder())} className="explorer-section-action-btn">+</button>
|
|
69
|
+
<button type="button" data-testid="section-new-folder-btn" title="New Folder" onClick={() => startFolderInsertion(resolveTargetFolder())} className="explorer-section-action-btn">📁</button>
|
|
70
|
+
<button type="button" data-testid="section-refresh-btn" title="Refresh" onClick={handleRefresh} className="explorer-section-action-btn">🔄</button>
|
|
71
|
+
</>
|
|
72
|
+
) : (
|
|
73
|
+
<button type="button" data-testid={`section-${sec.id}-fork-btn`} title="Fork to Workspace" onClick={handleForkDirectory} className="explorer-section-action-btn-fork">Fork</button>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
>
|
|
77
|
+
<div
|
|
78
|
+
data-testid={`section-${sec.id}-drop-zone`}
|
|
79
|
+
onDragOver={(e) => sec.mode === 'read-write' && handleDragOver(e, '__root__')}
|
|
80
|
+
onDragLeave={(e) => sec.mode === 'read-write' && handleDragLeave(e, '__root__')}
|
|
81
|
+
onDrop={(e) => sec.mode === 'read-write' && handleDrop(e, '')}
|
|
82
|
+
className={`explorer-section-drop-zone ${dragOverPath === '__root__' && sec.mode === 'read-write' ? 'drag-active' : ''}`}
|
|
83
|
+
>
|
|
84
|
+
<FileTreeNode
|
|
85
|
+
nodes={filteredTrees[sec.id] || {}}
|
|
86
|
+
collapsedDirs={effectiveCollapsedDirs}
|
|
87
|
+
toggleCollapse={toggleCollapse}
|
|
88
|
+
activeMCard={activeMCard}
|
|
89
|
+
editingPath={editingPath}
|
|
90
|
+
editingValue={editingValue}
|
|
91
|
+
setEditingValue={setEditingValue}
|
|
92
|
+
startRename={startRename}
|
|
93
|
+
cancelRename={cancelRename}
|
|
94
|
+
commitRename={commitRename}
|
|
95
|
+
draggedItem={draggedItem}
|
|
96
|
+
dragOverPath={dragOverPath}
|
|
97
|
+
setDraggedItem={setDraggedItem}
|
|
98
|
+
setDragOverPath={setDragOverPath}
|
|
99
|
+
onDropItem={handleDrop}
|
|
100
|
+
onSelectDir={setSelectedDirPath}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
</ExplorerSection>
|
|
104
|
+
);
|
|
105
|
+
|
|
51
106
|
return (
|
|
52
107
|
<div className="mcard-file-tree">
|
|
53
108
|
<ExplorerSearchField totalMatches={isFiltering ? totalMatches : undefined} />
|
|
54
109
|
<ExplorerActionBar onUploadFile={handleUploadFile} />
|
|
55
|
-
<div className="mcard-file-tree-scroll">
|
|
56
|
-
{
|
|
57
|
-
<ExplorerSection
|
|
58
|
-
key={sec.id}
|
|
59
|
-
id={sec.id}
|
|
60
|
-
title={sec.title}
|
|
61
|
-
mode={sec.mode}
|
|
62
|
-
icon={sec.mode === 'read-only' ? <LockIcon size={12} /> : undefined}
|
|
63
|
-
isExpanded={expanded[sec.id] ?? false}
|
|
64
|
-
itemCount={itemCounts[sec.id] || 0}
|
|
65
|
-
matchCount={isFiltering ? matchCounts[sec.id] : undefined}
|
|
66
|
-
onToggle={() => toggleSection(sec.id)}
|
|
67
|
-
actions={
|
|
68
|
-
sec.id === WS_DIR ? (
|
|
69
|
-
<>
|
|
70
|
-
<button type="button" data-testid="section-new-card-btn" title="New Card" onClick={() => startCardInsertion(resolveTargetFolder())} className="explorer-section-action-btn">+</button>
|
|
71
|
-
<button type="button" data-testid="section-new-folder-btn" title="New Folder" onClick={() => startFolderInsertion(resolveTargetFolder())} className="explorer-section-action-btn">📁</button>
|
|
72
|
-
<button type="button" data-testid="section-refresh-btn" title="Refresh" onClick={handleRefresh} className="explorer-section-action-btn">🔄</button>
|
|
73
|
-
</>
|
|
74
|
-
) : (
|
|
75
|
-
<button type="button" data-testid={`section-${sec.id}-fork-btn`} title="Fork to Workspace" onClick={handleForkDirectory} className="explorer-section-action-btn-fork">Fork</button>
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
>
|
|
79
|
-
<div
|
|
80
|
-
data-testid={`section-${sec.id}-drop-zone`}
|
|
81
|
-
onDragOver={(e) => sec.id === WS_DIR && handleDragOver(e, '__root__')}
|
|
82
|
-
onDragLeave={(e) => sec.id === WS_DIR && handleDragLeave(e, '__root__')}
|
|
83
|
-
onDrop={(e) => sec.id === WS_DIR && handleDrop(e, '')}
|
|
84
|
-
className={`explorer-section-drop-zone ${dragOverPath === '__root__' && sec.id === WS_DIR ? 'drag-active' : ''}`}
|
|
85
|
-
>
|
|
86
|
-
<FileTreeNode
|
|
87
|
-
nodes={filteredTrees[sec.id] || {}}
|
|
88
|
-
collapsedDirs={effectiveCollapsedDirs}
|
|
89
|
-
toggleCollapse={toggleCollapse}
|
|
90
|
-
activeMCard={activeMCard}
|
|
91
|
-
editingPath={editingPath}
|
|
92
|
-
editingValue={editingValue}
|
|
93
|
-
setEditingValue={setEditingValue}
|
|
94
|
-
startRename={startRename}
|
|
95
|
-
cancelRename={cancelRename}
|
|
96
|
-
commitRename={commitRename}
|
|
97
|
-
draggedItem={draggedItem}
|
|
98
|
-
dragOverPath={dragOverPath}
|
|
99
|
-
setDraggedItem={setDraggedItem}
|
|
100
|
-
setDragOverPath={setDragOverPath}
|
|
101
|
-
onDropItem={handleDrop}
|
|
102
|
-
onSelectDir={setSelectedDirPath}
|
|
103
|
-
/>
|
|
104
|
-
</div>
|
|
105
|
-
</ExplorerSection>
|
|
106
|
-
))}
|
|
110
|
+
<div className="mcard-file-tree-scroll mcard-file-tree-rw-scroll">
|
|
111
|
+
{rwSections.map(renderSection)}
|
|
107
112
|
</div>
|
|
113
|
+
{roSections.length > 0 && (
|
|
114
|
+
<>
|
|
115
|
+
<div className="mcard-file-tree-gap-divider" data-testid="explorer-sections-gap">
|
|
116
|
+
<div className="mcard-file-tree-gap-line" />
|
|
117
|
+
<span className="mcard-file-tree-gap-label">Read-Only Projections</span>
|
|
118
|
+
<div className="mcard-file-tree-gap-line" />
|
|
119
|
+
</div>
|
|
120
|
+
<div className="mcard-file-tree-ro-scroll">
|
|
121
|
+
{roSections.map(renderSection)}
|
|
122
|
+
</div>
|
|
123
|
+
</>
|
|
124
|
+
)}
|
|
108
125
|
</div>
|
|
109
126
|
);
|
|
110
127
|
};
|
|
@@ -8,7 +8,7 @@ import { useMemo } from 'react';
|
|
|
8
8
|
import type { MCardFileNode } from '@/types/mcard';
|
|
9
9
|
import type { TreeNode } from '../FileTreeNode';
|
|
10
10
|
import { filterSectionTree } from './useTreeSearchFilter';
|
|
11
|
-
import { EXPLORER_SECTIONS, WS_DIR, ASSETS_DIR, CK_DIR, PUBLIC_DIR } from './useSectionAccordion';
|
|
11
|
+
import { EXPLORER_SECTIONS, WS_DIR, ASSETS_DIR, CK_DIR, PUBLIC_DIR, type SectionConfig } from './useSectionAccordion';
|
|
12
12
|
|
|
13
13
|
function buildSectionTree(files: { relPath: string; file: MCardFileNode }[]): Record<string, TreeNode> {
|
|
14
14
|
const tree: Record<string, TreeNode> = {};
|
|
@@ -37,29 +37,73 @@ function buildSectionTree(files: { relPath: string; file: MCardFileNode }[]): Re
|
|
|
37
37
|
|
|
38
38
|
export function usePartitionedTrees(treeMap: Record<string, MCardFileNode>, query: string) {
|
|
39
39
|
return useMemo(() => {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
const files = Object.values(treeMap);
|
|
41
|
+
const isStandard = files.some((f) =>
|
|
42
|
+
f.path.startsWith(`${ASSETS_DIR}/`) ||
|
|
43
|
+
f.path.startsWith(`${CK_DIR}/`) ||
|
|
44
|
+
f.path.startsWith(`${PUBLIC_DIR}/`)
|
|
45
|
+
);
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
const pubPrefix = `${PUBLIC_DIR}/`;
|
|
50
|
-
const wsPrefix = `${WS_DIR}/`;
|
|
47
|
+
let sections: SectionConfig[];
|
|
48
|
+
const partitionedFiles: Record<string, { relPath: string; file: MCardFileNode }[]> = {};
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
50
|
+
if (isStandard || files.length === 0) {
|
|
51
|
+
sections = EXPLORER_SECTIONS;
|
|
52
|
+
for (const s of sections) partitionedFiles[s.id] = [];
|
|
53
|
+
const assetsPrefix = `${ASSETS_DIR}/`;
|
|
54
|
+
const ckPrefix = `${CK_DIR}/`;
|
|
55
|
+
const pubPrefix = `${PUBLIC_DIR}/`;
|
|
56
|
+
const wsPrefix = `${WS_DIR}/`;
|
|
57
|
+
for (const file of files) {
|
|
58
|
+
const p = file.path;
|
|
59
|
+
if (p.startsWith(assetsPrefix)) {
|
|
60
|
+
partitionedFiles[ASSETS_DIR].push({ relPath: p.slice(assetsPrefix.length), file });
|
|
61
|
+
} else if (p.startsWith(ckPrefix)) {
|
|
62
|
+
partitionedFiles[CK_DIR].push({ relPath: p.slice(ckPrefix.length), file });
|
|
63
|
+
} else if (p.startsWith(pubPrefix)) {
|
|
64
|
+
partitionedFiles[PUBLIC_DIR].push({ relPath: p.slice(pubPrefix.length), file });
|
|
65
|
+
} else {
|
|
66
|
+
const rel = p.startsWith(wsPrefix) ? p.slice(wsPrefix.length) : p;
|
|
67
|
+
partitionedFiles[WS_DIR].push({ relPath: rel, file });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
const topDirs = new Set<string>();
|
|
72
|
+
let hasRootFiles = false;
|
|
73
|
+
for (const file of files) {
|
|
74
|
+
const slashIdx = file.path.indexOf('/');
|
|
75
|
+
if (slashIdx > 0) {
|
|
76
|
+
topDirs.add(file.path.slice(0, slashIdx));
|
|
77
|
+
} else {
|
|
78
|
+
hasRootFiles = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const sortedDirs = Array.from(topDirs).sort();
|
|
82
|
+
sections = sortedDirs.map((dir) => ({
|
|
83
|
+
id: dir,
|
|
84
|
+
title: dir,
|
|
85
|
+
mode: 'read-write' as const,
|
|
86
|
+
prefix: `${dir}/`,
|
|
87
|
+
}));
|
|
88
|
+
if (hasRootFiles) {
|
|
89
|
+
sections.push({
|
|
90
|
+
id: '__root__',
|
|
91
|
+
title: 'Files',
|
|
92
|
+
mode: 'read-write' as const,
|
|
93
|
+
prefix: '',
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
for (const s of sections) partitionedFiles[s.id] = [];
|
|
97
|
+
for (const file of files) {
|
|
98
|
+
const slashIdx = file.path.indexOf('/');
|
|
99
|
+
if (slashIdx > 0) {
|
|
100
|
+
const dir = file.path.slice(0, slashIdx);
|
|
101
|
+
if (partitionedFiles[dir]) {
|
|
102
|
+
partitionedFiles[dir].push({ relPath: file.path.slice(slashIdx + 1), file });
|
|
103
|
+
}
|
|
104
|
+
} else if (partitionedFiles['__root__']) {
|
|
105
|
+
partitionedFiles['__root__'].push({ relPath: file.path, file });
|
|
106
|
+
}
|
|
63
107
|
}
|
|
64
108
|
}
|
|
65
109
|
|
|
@@ -70,7 +114,7 @@ export function usePartitionedTrees(treeMap: Record<string, MCardFileNode>, quer
|
|
|
70
114
|
const autoExpandedDirs = new Set<string>();
|
|
71
115
|
let totalMatches = 0;
|
|
72
116
|
|
|
73
|
-
for (const sec of
|
|
117
|
+
for (const sec of sections) {
|
|
74
118
|
const list = partitionedFiles[sec.id] || [];
|
|
75
119
|
itemCounts[sec.id] = list.length;
|
|
76
120
|
const tree = buildSectionTree(list);
|
|
@@ -84,6 +128,7 @@ export function usePartitionedTrees(treeMap: Record<string, MCardFileNode>, quer
|
|
|
84
128
|
}
|
|
85
129
|
|
|
86
130
|
return {
|
|
131
|
+
sections,
|
|
87
132
|
rawTrees,
|
|
88
133
|
filteredTrees,
|
|
89
134
|
matchCounts,
|
|
@@ -28,20 +28,30 @@ export const EXPLORER_SECTIONS: SectionConfig[] = [
|
|
|
28
28
|
{ id: PUBLIC_DIR, title: 'READ-ONLY: Public Assets', mode: 'read-only', prefix: PUBLIC_DIR },
|
|
29
29
|
];
|
|
30
30
|
|
|
31
|
-
function getInitialState(): Record<string, boolean> {
|
|
31
|
+
function getInitialState(secList: SectionConfig[]): Record<string, boolean> {
|
|
32
|
+
const defaults: Record<string, boolean> = {};
|
|
33
|
+
const isCustom = secList !== EXPLORER_SECTIONS;
|
|
34
|
+
for (let i = 0; i < secList.length; i++) {
|
|
35
|
+
defaults[secList[i].id] = isCustom ? true : i === 0;
|
|
36
|
+
}
|
|
32
37
|
try {
|
|
33
38
|
const raw = typeof localStorage !== 'undefined' ? localStorage.getItem(STORAGE_KEY) : null;
|
|
34
|
-
if (raw) return JSON.parse(raw);
|
|
39
|
+
if (raw) return { ...defaults, ...JSON.parse(raw) };
|
|
35
40
|
} catch {}
|
|
36
|
-
return
|
|
41
|
+
return defaults;
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
export function useSectionAccordion(
|
|
40
45
|
activeHandle: string | null | undefined,
|
|
41
46
|
isFiltering: boolean,
|
|
42
|
-
matchCounts: Record<string, number
|
|
47
|
+
matchCounts: Record<string, number>,
|
|
48
|
+
customSections?: SectionConfig[]
|
|
43
49
|
) {
|
|
44
|
-
const
|
|
50
|
+
const sections = useMemo(
|
|
51
|
+
() => (customSections && customSections.length > 0 ? customSections : EXPLORER_SECTIONS),
|
|
52
|
+
[customSections]
|
|
53
|
+
);
|
|
54
|
+
const [expanded, setExpanded] = useState<Record<string, boolean>>(() => getInitialState(sections));
|
|
45
55
|
|
|
46
56
|
const toggleSection = useCallback((id: string) => {
|
|
47
57
|
setExpanded((prev) => {
|
|
@@ -64,22 +74,22 @@ export function useSectionAccordion(
|
|
|
64
74
|
: '';
|
|
65
75
|
if (!handleStr || typeof handleStr.toLowerCase !== 'function') return;
|
|
66
76
|
const lower = handleStr.toLowerCase();
|
|
67
|
-
for (const sec of
|
|
68
|
-
if (lower.startsWith(sec.prefix)) {
|
|
77
|
+
for (const sec of sections) {
|
|
78
|
+
if (sec.prefix && lower.startsWith(sec.prefix.toLowerCase())) {
|
|
69
79
|
setExpanded((prev) => (prev[sec.id] ? prev : { ...prev, [sec.id]: true }));
|
|
70
80
|
break;
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
|
-
}, [activeHandle]);
|
|
83
|
+
}, [activeHandle, sections]);
|
|
74
84
|
|
|
75
85
|
const effectiveExpanded = useMemo(() => {
|
|
76
86
|
if (!isFiltering) return expanded;
|
|
77
87
|
const copy = { ...expanded };
|
|
78
|
-
for (const sec of
|
|
88
|
+
for (const sec of sections) {
|
|
79
89
|
if ((matchCounts[sec.id] || 0) > 0) copy[sec.id] = true;
|
|
80
90
|
}
|
|
81
91
|
return copy;
|
|
82
|
-
}, [expanded, isFiltering, matchCounts]);
|
|
92
|
+
}, [expanded, isFiltering, matchCounts, sections]);
|
|
83
93
|
|
|
84
|
-
return { sections
|
|
94
|
+
return { sections, expanded: effectiveExpanded, toggleSection };
|
|
85
95
|
}
|