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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime_8H4AJuhK.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { a as resolveHostPath, i as repoRoot, r as isPathWritable } from "./workspaceRoot_CRx3taID.mjs";
|
|
3
3
|
import { r as json, t as error } from "./apiUtils_B3BX89fM.mjs";
|
|
4
|
-
import { t as createHash } from "./cryptoPolyfill_99rxUwYC.mjs";
|
|
5
4
|
import { existsSync, mkdirSync, readFileSync, renameSync, statSync } from "node:fs";
|
|
6
|
-
import { dirname
|
|
5
|
+
import { dirname } from "node:path";
|
|
6
|
+
import { createRecord, qualify } from "clm-kernel";
|
|
7
7
|
//#region src/pages/api/vfs/move.ts
|
|
8
8
|
var move_exports = /* @__PURE__ */ __exportAll({ POST: () => POST });
|
|
9
9
|
var POST = async ({ request }) => {
|
|
@@ -17,8 +17,8 @@ var POST = async ({ request }) => {
|
|
|
17
17
|
const root = repoRoot();
|
|
18
18
|
if (!isPathWritable(sourcePath, root)) return error("Access denied: Source path is in a read-only projection", 403);
|
|
19
19
|
if (!isPathWritable(targetPath, root)) return error("Access denied: Target path is in a read-only projection", 403);
|
|
20
|
-
const sourceAbs =
|
|
21
|
-
const targetAbs =
|
|
20
|
+
const sourceAbs = resolveHostPath(sourcePath, root);
|
|
21
|
+
const targetAbs = resolveHostPath(targetPath, root);
|
|
22
22
|
if (sourceAbs === targetAbs) return error("Source and target paths are identical", 400);
|
|
23
23
|
if (!existsSync(sourceAbs)) return error(`Source path does not exist: ${sourcePath}`, 404);
|
|
24
24
|
if (existsSync(targetAbs) && !overwrite) return error(`Target path already exists: ${targetPath}`, 409);
|
|
@@ -29,7 +29,7 @@ var POST = async ({ request }) => {
|
|
|
29
29
|
success: true,
|
|
30
30
|
sourcePath,
|
|
31
31
|
targetPath,
|
|
32
|
-
hash: bytes ?
|
|
32
|
+
hash: bytes ? qualify(createRecord(bytes)).asPrefixed() : null,
|
|
33
33
|
bytesMoved: bytes ? bytes.byteLength : 0
|
|
34
34
|
});
|
|
35
35
|
} catch (err) {
|
|
@@ -73,7 +73,12 @@ var app_config_default = {
|
|
|
73
73
|
".git",
|
|
74
74
|
"__pycache__",
|
|
75
75
|
"node_modules",
|
|
76
|
-
".DS_Store"
|
|
76
|
+
".DS_Store",
|
|
77
|
+
"-wal",
|
|
78
|
+
"-shm",
|
|
79
|
+
"-journal",
|
|
80
|
+
"servermemory.db",
|
|
81
|
+
"server_log.db"
|
|
77
82
|
],
|
|
78
83
|
"filenames": ["__init__.py"],
|
|
79
84
|
"skip_dotfiles": true
|
|
@@ -121,7 +126,11 @@ var app_config_default = {
|
|
|
121
126
|
"extra_ignore_paths": [
|
|
122
127
|
"dist",
|
|
123
128
|
".turbo",
|
|
124
|
-
"dev-dist"
|
|
129
|
+
"dev-dist",
|
|
130
|
+
"servermemory.db",
|
|
131
|
+
"servermemory.db-wal",
|
|
132
|
+
"servermemory.db-shm",
|
|
133
|
+
"server_log.db"
|
|
125
134
|
],
|
|
126
135
|
"hash_max_bytes": 1048576,
|
|
127
136
|
"inline_max_bytes": 262144,
|
|
@@ -147,7 +156,8 @@ var app_config_default = {
|
|
|
147
156
|
".tikz",
|
|
148
157
|
".tikzcd",
|
|
149
158
|
".tikz-cd",
|
|
150
|
-
".tex"
|
|
159
|
+
".tex",
|
|
160
|
+
".dxf"
|
|
151
161
|
],
|
|
152
162
|
"default_tabs": ["clm", "workspace"]
|
|
153
163
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime_8H4AJuhK.mjs";
|
|
2
2
|
import { t as error } from "./apiUtils_B3BX89fM.mjs";
|
|
3
|
-
import { t as studioMCardFs } from "./
|
|
4
|
-
import "./
|
|
3
|
+
import { t as studioMCardFs } from "./vfsCore_DIKpk-pk.mjs";
|
|
4
|
+
import "./mcardVfs_DvNburKb.mjs";
|
|
5
5
|
import { routeHandle } from "clm-kernel";
|
|
6
6
|
//#region src/pages/api/vfs/proxy.ts
|
|
7
7
|
var proxy_exports = /* @__PURE__ */ __exportAll({ GET: () => GET });
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime_8H4AJuhK.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { a as resolveHostPath, i as repoRoot, n as isPathAllowed } from "./workspaceRoot_CRx3taID.mjs";
|
|
3
3
|
import { t as error } from "./apiUtils_B3BX89fM.mjs";
|
|
4
|
-
import { n as sniffMimeType } from "./
|
|
5
|
-
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
6
|
-
import { basename
|
|
4
|
+
import { n as sniffMimeType } from "./cardTypeDetector_C55M_HWS.mjs";
|
|
5
|
+
import { closeSync, existsSync, openSync, readFileSync, readSync, statSync } from "node:fs";
|
|
6
|
+
import { basename } from "node:path";
|
|
7
7
|
//#region src/pages/api/vfs/raw.ts
|
|
8
8
|
var raw_exports = /* @__PURE__ */ __exportAll({
|
|
9
9
|
GET: () => GET,
|
|
@@ -22,7 +22,7 @@ var GET = async ({ request, url }) => {
|
|
|
22
22
|
let cleanRel = relPath.trim();
|
|
23
23
|
if (cleanRel.startsWith("mcard://")) cleanRel = cleanRel.replace(/^mcard:\/\//, "");
|
|
24
24
|
const normalizedRel = cleanRel.replace(/:/g, "/").replace(/^(\.\.(\/|\\|$))+/, "").replace(/^[/\\]+/, "");
|
|
25
|
-
const targetPath =
|
|
25
|
+
const targetPath = resolveHostPath(normalizedRel, root);
|
|
26
26
|
if (!isPathAllowed(targetPath, root)) return error("Access denied: path outside allowed boundaries", 403);
|
|
27
27
|
if (!existsSync(targetPath)) return error(`File not found: ${normalizedRel}`, 404);
|
|
28
28
|
try {
|
|
@@ -38,26 +38,29 @@ var GET = async ({ request, url }) => {
|
|
|
38
38
|
"Cache-Control": "no-cache, must-revalidate"
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
|
+
const filename = basename(targetPath);
|
|
42
|
+
const disposition = url.searchParams.get("download") === "1" || url.searchParams.get("download") === "true" ? `attachment; filename="${encodeURIComponent(filename)}"` : "inline";
|
|
41
43
|
const requestedHash = url.searchParams.get("v");
|
|
42
44
|
if (requestedHash) try {
|
|
43
|
-
const { studioMCardFs } = await import("./
|
|
45
|
+
const { studioMCardFs } = await import("./vfsCore_DIKpk-pk.mjs").then((n) => n.n);
|
|
44
46
|
const card = studioMCardFs.readFileByHash(requestedHash);
|
|
45
47
|
if (card) {
|
|
46
48
|
const mime = sniffMimeType(targetPath);
|
|
47
|
-
const
|
|
48
|
-
const disposition = url.searchParams.get("download") === "1" || url.searchParams.get("download") === "true" ? "attachment" : "inline";
|
|
49
|
+
const isBinaryMedia = mime.startsWith("image/") && mime !== "image/svg+xml" || mime.startsWith("audio/") || mime.startsWith("video/") || mime.startsWith("font/") || mime === "application/pdf";
|
|
49
50
|
if (card.payload.kind === "text") {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
if (!isBinaryMedia) {
|
|
52
|
+
const textBuf = Buffer.from(card.payload.value, "utf8");
|
|
53
|
+
return new Response(textBuf, {
|
|
54
|
+
status: 200,
|
|
55
|
+
headers: {
|
|
56
|
+
"Content-Type": `${mime}; charset=utf-8`,
|
|
57
|
+
"Content-Length": textBuf.length.toString(),
|
|
58
|
+
"Content-Disposition": disposition,
|
|
59
|
+
"ETag": `W/"${requestedHash}"`,
|
|
60
|
+
"Cache-Control": "no-store"
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
61
64
|
} else if (card.payload.kind === "binary" || card.payload.data) {
|
|
62
65
|
const binData = card.payload.data;
|
|
63
66
|
const binBuf = Buffer.isBuffer(binData) ? binData : Buffer.from(binData);
|
|
@@ -66,28 +69,58 @@ var GET = async ({ request, url }) => {
|
|
|
66
69
|
headers: {
|
|
67
70
|
"Content-Type": card.payload.mimeType || mime,
|
|
68
71
|
"Content-Length": binBuf.length.toString(),
|
|
69
|
-
"Content-Disposition":
|
|
72
|
+
"Content-Disposition": disposition,
|
|
70
73
|
"ETag": `W/"${requestedHash}"`,
|
|
71
|
-
"Cache-Control": "
|
|
74
|
+
"Cache-Control": "no-store"
|
|
72
75
|
}
|
|
73
76
|
});
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
} catch {}
|
|
77
80
|
const mime = sniffMimeType(targetPath);
|
|
78
|
-
const contentType = mime.startsWith("text/") || mime === "application/json" || mime === "application/xml" || mime === "application/x-yaml" || mime === "image/svg+xml" || mime === "model/gltf+json" ? `${mime}; charset=utf-8` : mime;
|
|
81
|
+
const contentType = mime.startsWith("text/") || mime === "application/json" || mime === "application/xml" || mime === "application/x-yaml" || mime === "image/svg+xml" || mime === "model/gltf+json" || mime === "image/vnd.dxf" ? `${mime}; charset=utf-8` : mime;
|
|
82
|
+
const rangeHeader = request.headers.get("range");
|
|
83
|
+
if (rangeHeader && rangeHeader.startsWith("bytes=")) {
|
|
84
|
+
const parts = rangeHeader.replace(/bytes=/, "").split("-");
|
|
85
|
+
const start = parseInt(parts[0], 10);
|
|
86
|
+
const end = parts[1] ? parseInt(parts[1], 10) : stat.size - 1;
|
|
87
|
+
if (isNaN(start) || isNaN(end) || start >= stat.size || end >= stat.size || start > end) return new Response(null, {
|
|
88
|
+
status: 416,
|
|
89
|
+
headers: {
|
|
90
|
+
"Content-Range": `bytes */${stat.size}`,
|
|
91
|
+
"Accept-Ranges": "bytes"
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const chunkSize = end - start + 1;
|
|
95
|
+
const fd = openSync(targetPath, "r");
|
|
96
|
+
const chunkBuffer = Buffer.alloc(chunkSize);
|
|
97
|
+
readSync(fd, chunkBuffer, 0, chunkSize, start);
|
|
98
|
+
closeSync(fd);
|
|
99
|
+
return new Response(chunkBuffer, {
|
|
100
|
+
status: 206,
|
|
101
|
+
headers: {
|
|
102
|
+
"Content-Type": contentType,
|
|
103
|
+
"Content-Range": `bytes ${start}-${end}/${stat.size}`,
|
|
104
|
+
"Content-Length": chunkSize.toString(),
|
|
105
|
+
"Accept-Ranges": "bytes",
|
|
106
|
+
"Content-Disposition": disposition,
|
|
107
|
+
"ETag": etag,
|
|
108
|
+
"Last-Modified": stat.mtime.toUTCString(),
|
|
109
|
+
"Cache-Control": "no-store"
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
79
113
|
const fileBuffer = readFileSync(targetPath);
|
|
80
|
-
const filename = basename(targetPath);
|
|
81
|
-
const disposition = url.searchParams.get("download") === "1" || url.searchParams.get("download") === "true" ? "attachment" : "inline";
|
|
82
114
|
return new Response(fileBuffer, {
|
|
83
115
|
status: 200,
|
|
84
116
|
headers: {
|
|
85
117
|
"Content-Type": contentType,
|
|
86
118
|
"Content-Length": stat.size.toString(),
|
|
87
|
-
"
|
|
119
|
+
"Accept-Ranges": "bytes",
|
|
120
|
+
"Content-Disposition": disposition,
|
|
88
121
|
"ETag": etag,
|
|
89
122
|
"Last-Modified": stat.mtime.toUTCString(),
|
|
90
|
-
"Cache-Control": "no-
|
|
123
|
+
"Cache-Control": "no-store"
|
|
91
124
|
}
|
|
92
125
|
});
|
|
93
126
|
} catch (err) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as app_config_default, t as PATHS } from "./
|
|
2
|
-
import {
|
|
1
|
+
import { i as app_config_default, t as PATHS } from "./pathsConfig_Dack-p2f.mjs";
|
|
2
|
+
import { i as repoRoot } from "./workspaceRoot_CRx3taID.mjs";
|
|
3
3
|
import { Context } from "cordis";
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import path from "path";
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime_8H4AJuhK.mjs";
|
|
2
|
+
import { n as getWhitelistedDirectoryProjections, t as PATHS } from "./pathsConfig_Dack-p2f.mjs";
|
|
3
|
+
import { i as repoRoot, o as workspaceRoot, t as dataRoot } from "./workspaceRoot_CRx3taID.mjs";
|
|
4
|
+
import { r as json, t as error } from "./apiUtils_B3BX89fM.mjs";
|
|
5
|
+
import { n as toTreeFiles, t as scanRoots } from "./vfsTreeScan_CRoCluPB.mjs";
|
|
6
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { ContentHash, buildMerkleTreeFromEntries } from "clm-kernel";
|
|
9
|
+
//#region src/pages/api/vfs/tree.ts
|
|
10
|
+
var tree_exports = /* @__PURE__ */ __exportAll({ GET: () => GET });
|
|
11
|
+
function scanSubdirEntries(dir, rel = "") {
|
|
12
|
+
let entries = [];
|
|
13
|
+
for (const item of readdirSync(dir, { withFileTypes: true })) {
|
|
14
|
+
const full = join(dir, item.name);
|
|
15
|
+
const sub = rel ? `${rel}/${item.name}` : item.name;
|
|
16
|
+
if (item.isDirectory()) entries.push(...scanSubdirEntries(full, sub));
|
|
17
|
+
else entries.push({
|
|
18
|
+
path: sub,
|
|
19
|
+
data: readFileSync(full)
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return entries;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* VFS tree federation endpoint.
|
|
26
|
+
* Supports:
|
|
27
|
+
* - ?handle=<collection>: returns manifest of that collection (children with hashes and sizes) lazily (DoD-06-4).
|
|
28
|
+
* - ?scope=<id>: returns strictly bounded read-only subtrees (INV-WS-02).
|
|
29
|
+
*/
|
|
30
|
+
var GET = async (context) => {
|
|
31
|
+
try {
|
|
32
|
+
const searchParams = context?.url?.searchParams ?? (context?.request ? new URL(context.request.url).searchParams : null);
|
|
33
|
+
const handleParam = searchParams?.get("handle")?.trim();
|
|
34
|
+
const scope = searchParams?.get("scope") ?? null;
|
|
35
|
+
const dRoot = dataRoot();
|
|
36
|
+
if (handleParam && dRoot) {
|
|
37
|
+
const cleanHandle = handleParam.replace(/^mcard:/, "").replace(/^\/+/, "").replace(/\/+$/, "");
|
|
38
|
+
const targetDir = cleanHandle ? join(dRoot, cleanHandle) : dRoot;
|
|
39
|
+
if (!existsSync(targetDir) || !statSync(targetDir).isDirectory()) return error(`Collection handle not found: ${handleParam}`, 404);
|
|
40
|
+
const entries = readdirSync(targetDir, { withFileTypes: true }).map((item) => {
|
|
41
|
+
const itemRel = cleanHandle ? `${cleanHandle}/${item.name}` : item.name;
|
|
42
|
+
const itemFull = join(targetDir, item.name);
|
|
43
|
+
const isDir = item.isDirectory();
|
|
44
|
+
let sizeBytes = 0;
|
|
45
|
+
let qualifiedHash = "";
|
|
46
|
+
if (isDir) {
|
|
47
|
+
const sub = scanSubdirEntries(itemFull, itemRel);
|
|
48
|
+
const subTree = buildMerkleTreeFromEntries(sub);
|
|
49
|
+
qualifiedHash = subTree.hash.asPrefixed();
|
|
50
|
+
sizeBytes = subTree.sizeBytes;
|
|
51
|
+
} else {
|
|
52
|
+
const data = readFileSync(itemFull);
|
|
53
|
+
qualifiedHash = ContentHash.compute(data).asPrefixed();
|
|
54
|
+
sizeBytes = data.byteLength;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
name: item.name,
|
|
58
|
+
path: itemRel,
|
|
59
|
+
hash: qualifiedHash,
|
|
60
|
+
isDirectory: isDir,
|
|
61
|
+
sizeBytes
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
65
|
+
const manifestLines = entries.map((e) => `${e.name}:${e.hash}:${e.isDirectory ? "dir" : "file"}:${e.sizeBytes}`);
|
|
66
|
+
const manifestBytes = new TextEncoder().encode(manifestLines.join("\n") + (manifestLines.length > 0 ? "\n" : ""));
|
|
67
|
+
const manifestHash = ContentHash.compute(manifestBytes).asPrefixed();
|
|
68
|
+
return json({
|
|
69
|
+
success: true,
|
|
70
|
+
handle: handleParam,
|
|
71
|
+
manifestHash,
|
|
72
|
+
entries,
|
|
73
|
+
scannedAt: Date.now()
|
|
74
|
+
}, 200, {
|
|
75
|
+
"Cache-Control": "private, max-age=31536000, immutable",
|
|
76
|
+
"ETag": `"${manifestHash}"`
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (dRoot) {
|
|
80
|
+
if (scope && scope.trim() !== "") {
|
|
81
|
+
const roots = [{
|
|
82
|
+
dir: join(dRoot, scope),
|
|
83
|
+
baseDir: dRoot
|
|
84
|
+
}];
|
|
85
|
+
const files = toTreeFiles(scanRoots(roots)).map((file) => ({
|
|
86
|
+
...file,
|
|
87
|
+
scope,
|
|
88
|
+
readOnly: false
|
|
89
|
+
}));
|
|
90
|
+
return json({
|
|
91
|
+
success: true,
|
|
92
|
+
scope,
|
|
93
|
+
readOnly: false,
|
|
94
|
+
files,
|
|
95
|
+
scannedAt: Date.now()
|
|
96
|
+
}, 200, {
|
|
97
|
+
"Cache-Control": "no-cache, no-store, must-revalidate",
|
|
98
|
+
"Pragma": "no-cache",
|
|
99
|
+
"Expires": "0"
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const files = toTreeFiles(scanRoots([{
|
|
103
|
+
dir: dRoot,
|
|
104
|
+
baseDir: dRoot
|
|
105
|
+
}])).map((file) => {
|
|
106
|
+
const parts = file.path.split("/");
|
|
107
|
+
const fileScope = parts.length > 1 ? parts[0] : "root";
|
|
108
|
+
return {
|
|
109
|
+
...file,
|
|
110
|
+
scope: fileScope,
|
|
111
|
+
readOnly: false
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
return json({
|
|
115
|
+
success: true,
|
|
116
|
+
readOnly: false,
|
|
117
|
+
files,
|
|
118
|
+
scannedAt: Date.now()
|
|
119
|
+
}, 200, {
|
|
120
|
+
"Cache-Control": "no-cache, no-store, must-revalidate",
|
|
121
|
+
"Pragma": "no-cache",
|
|
122
|
+
"Expires": "0"
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const root = repoRoot();
|
|
126
|
+
const projections = getWhitelistedDirectoryProjections();
|
|
127
|
+
const allowedScopes = projections.map((p) => p.id);
|
|
128
|
+
if (scope && scope.trim() !== "") {
|
|
129
|
+
const projection = projections.find((p) => p.id === scope);
|
|
130
|
+
if (!projection) return error(`Invalid directory projection scope: '${scope}'. Allowed scopes: ${allowedScopes.join(", ")}`, 400);
|
|
131
|
+
const isWs = projection.id === PATHS.paths.workspace_dirname;
|
|
132
|
+
const roots = [{
|
|
133
|
+
dir: isWs ? workspaceRoot() : join(root, projection.path),
|
|
134
|
+
baseDir: isWs ? dirname(workspaceRoot()) : root
|
|
135
|
+
}];
|
|
136
|
+
const files = toTreeFiles(scanRoots(roots)).map((file) => ({
|
|
137
|
+
...file,
|
|
138
|
+
scope: projection.id,
|
|
139
|
+
readOnly: true
|
|
140
|
+
}));
|
|
141
|
+
return json({
|
|
142
|
+
success: true,
|
|
143
|
+
scope: projection.id,
|
|
144
|
+
readOnly: true,
|
|
145
|
+
files,
|
|
146
|
+
scannedAt: Date.now()
|
|
147
|
+
}, 200, {
|
|
148
|
+
"Cache-Control": "no-cache, no-store, must-revalidate",
|
|
149
|
+
"Pragma": "no-cache",
|
|
150
|
+
"Expires": "0"
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const roots = PATHS.vfs.scan_roots.map((scanRoot) => scanRoot === PATHS.paths.workspace_dirname ? {
|
|
154
|
+
dir: workspaceRoot(),
|
|
155
|
+
baseDir: dirname(workspaceRoot())
|
|
156
|
+
} : {
|
|
157
|
+
dir: join(root, scanRoot),
|
|
158
|
+
baseDir: root
|
|
159
|
+
});
|
|
160
|
+
const files = toTreeFiles(scanRoots(roots)).map((file) => {
|
|
161
|
+
const matched = projections.find((p) => file.path.startsWith(p.path + "/") || file.path === p.path);
|
|
162
|
+
return {
|
|
163
|
+
...file,
|
|
164
|
+
scope: matched?.id || projections[0]?.id || PATHS.paths.assets_dirname,
|
|
165
|
+
readOnly: true
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
return json({
|
|
169
|
+
success: true,
|
|
170
|
+
readOnly: true,
|
|
171
|
+
files,
|
|
172
|
+
scannedAt: Date.now()
|
|
173
|
+
}, 200, {
|
|
174
|
+
"Cache-Control": "no-cache, no-store, must-revalidate",
|
|
175
|
+
"Pragma": "no-cache",
|
|
176
|
+
"Expires": "0"
|
|
177
|
+
});
|
|
178
|
+
} catch (err) {
|
|
179
|
+
return error(err instanceof Error ? err.message : "Failed to scan VFS", 500, { success: false });
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region \0virtual:astro:page:src/pages/api/vfs/tree@_@ts
|
|
184
|
+
var page = () => tree_exports;
|
|
185
|
+
//#endregion
|
|
186
|
+
export { page };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime_8H4AJuhK.mjs";
|
|
2
|
+
import { ContentHash, MCardFileSystem, registerIndexedDbPlugin } from "clm-kernel";
|
|
3
|
+
//#region src/services/vfs/vfsMigration.ts
|
|
4
|
+
/**
|
|
5
|
+
* VFS Migration — One-time retirement migration for legacy clm_workbench_db (DoD-05-3, D7, R7)
|
|
6
|
+
* Canonical Path: src/services/vfs/vfsMigration.ts
|
|
7
|
+
* NOTE: Migration file scheduled for deletion after replica retirement.
|
|
8
|
+
*
|
|
9
|
+
* Reads legacy clm_cas_blobs, clm_handle_registry, clm_handle_history and clm_sqlite_snapshots
|
|
10
|
+
* into kernel-owned CAS driver, then deletes clm_workbench_db.
|
|
11
|
+
*/
|
|
12
|
+
var DB_NAME = "clm_workbench_db";
|
|
13
|
+
var DB_VERSION = 2;
|
|
14
|
+
var STORE_CAS = "clm_cas_blobs";
|
|
15
|
+
var STORE_HANDLES = "clm_handle_registry";
|
|
16
|
+
var STORE_HISTORY = "clm_handle_history";
|
|
17
|
+
var STORE_SNAPSHOTS = "clm_sqlite_snapshots";
|
|
18
|
+
var STORE_LEGACY = "clm_content_memory_db";
|
|
19
|
+
/**
|
|
20
|
+
* Migration-only IndexedDB opener.
|
|
21
|
+
* Scheduled for deletion once all client replicas migrate to kernel CAS driver.
|
|
22
|
+
*/
|
|
23
|
+
function openMigrationIndexedDb() {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
if (typeof window === "undefined" || !window.indexedDB) return reject(/* @__PURE__ */ new Error("IndexedDB not available"));
|
|
26
|
+
const req = window.indexedDB.open(DB_NAME, DB_VERSION);
|
|
27
|
+
req.onupgradeneeded = () => {
|
|
28
|
+
const db = req.result;
|
|
29
|
+
if (!db.objectStoreNames.contains("clm_cas_blobs")) db.createObjectStore(STORE_CAS, { keyPath: "hash" });
|
|
30
|
+
if (!db.objectStoreNames.contains("clm_handle_registry")) db.createObjectStore(STORE_HANDLES, { keyPath: "handle" });
|
|
31
|
+
if (!db.objectStoreNames.contains("clm_handle_history")) db.createObjectStore(STORE_HISTORY, {
|
|
32
|
+
keyPath: "id",
|
|
33
|
+
autoIncrement: true
|
|
34
|
+
});
|
|
35
|
+
if (!db.objectStoreNames.contains("clm_sqlite_snapshots")) db.createObjectStore(STORE_SNAPSHOTS, { keyPath: "id" });
|
|
36
|
+
if (!db.objectStoreNames.contains("clm_content_memory_db")) db.createObjectStore(STORE_LEGACY);
|
|
37
|
+
};
|
|
38
|
+
req.onsuccess = () => resolve(req.result);
|
|
39
|
+
req.onerror = () => reject(req.error);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Executes one-time migration from legacy clm_workbench_db to kernel driver, then deletes database.
|
|
44
|
+
*/
|
|
45
|
+
async function migrateAndRetireLegacyIndexedDb(targetFs) {
|
|
46
|
+
if (typeof window === "undefined" || !window.indexedDB) return false;
|
|
47
|
+
try {
|
|
48
|
+
const db = await openMigrationIndexedDb();
|
|
49
|
+
if (Array.from(db.objectStoreNames).includes("clm_cas_blobs")) {
|
|
50
|
+
const req = db.transaction([STORE_CAS], "readonly").objectStore(STORE_CAS).getAll();
|
|
51
|
+
await new Promise((resolve) => {
|
|
52
|
+
req.onsuccess = () => {
|
|
53
|
+
const items = req.result || [];
|
|
54
|
+
for (const item of items) if (item.hash && item.content) try {
|
|
55
|
+
ContentHash.parse(item.hash);
|
|
56
|
+
const bytes = typeof item.content === "string" ? new TextEncoder().encode(item.content) : item.content instanceof Uint8Array ? item.content : new Uint8Array(item.content);
|
|
57
|
+
if (targetFs && typeof targetFs.writeFile === "function") targetFs.writeFile(item.handle || item.hash, bytes);
|
|
58
|
+
} catch {}
|
|
59
|
+
resolve();
|
|
60
|
+
};
|
|
61
|
+
req.onerror = () => resolve();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
db.close();
|
|
65
|
+
await new Promise((resolve, reject) => {
|
|
66
|
+
const delReq = window.indexedDB.deleteDatabase(DB_NAME);
|
|
67
|
+
delReq.onsuccess = () => resolve();
|
|
68
|
+
delReq.onerror = () => reject(delReq.error);
|
|
69
|
+
delReq.onblocked = () => resolve();
|
|
70
|
+
});
|
|
71
|
+
return true;
|
|
72
|
+
} catch (err) {
|
|
73
|
+
console.warn("[VFS Migration] Migration completed or database already retired:", err);
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/services/vfs/vfsCore.ts
|
|
79
|
+
/**
|
|
80
|
+
* VFS Core — CAS Singleton (SSOT)
|
|
81
|
+
* Canonical Path: src/services/vfs/vfsCore.ts
|
|
82
|
+
* Deliverable: DEL-294-01 / DEL-294-04 (Sprint 294)
|
|
83
|
+
*
|
|
84
|
+
* Owns the single MCardFileSystem instance for the Studio Workbench
|
|
85
|
+
* (INV-294-03 SSOT Singleton Singularity). Every other VFS module
|
|
86
|
+
* consumes this instance via import; callers outside the VFS tree
|
|
87
|
+
* consume it via the mcardVfs facade re-export.
|
|
88
|
+
*/
|
|
89
|
+
var vfsCore_exports = /* @__PURE__ */ __exportAll({ studioMCardFs: () => studioMCardFs });
|
|
90
|
+
if (typeof window !== "undefined") registerIndexedDbPlugin();
|
|
91
|
+
/**
|
|
92
|
+
* Universal Content-Addressable MCard Virtual Filesystem for Studio Workbench (INV-04, INV-05, INV-09).
|
|
93
|
+
* Instantiates the optimal storage backend across server (NodeSqliteBackend) and browser environments.
|
|
94
|
+
*/
|
|
95
|
+
var studioMCardFs = MCardFileSystem.createOptimal({ dbPath: ".clm/content_memory.db" });
|
|
96
|
+
if (typeof window !== "undefined") migrateAndRetireLegacyIndexedDb(studioMCardFs).catch(() => {});
|
|
97
|
+
//#endregion
|
|
98
|
+
export { STORE_HISTORY as a, openMigrationIndexedDb as c, STORE_HANDLES as i, vfsCore_exports as n, STORE_LEGACY as o, STORE_CAS as r, STORE_SNAPSHOTS as s, studioMCardFs as t };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { r as resolveEpistemicStatus, t as PATHS } from "./
|
|
2
|
-
import { n as sniffMimeType, t as detectCardType } from "./
|
|
3
|
-
import { t as createHash } from "./cryptoPolyfill_99rxUwYC.mjs";
|
|
1
|
+
import { r as resolveEpistemicStatus, t as PATHS } from "./pathsConfig_Dack-p2f.mjs";
|
|
2
|
+
import { n as sniffMimeType, t as detectCardType } from "./cardTypeDetector_C55M_HWS.mjs";
|
|
4
3
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
5
4
|
import { join, relative } from "node:path";
|
|
6
|
-
import { detectEpistemicStatus } from "clm-kernel";
|
|
5
|
+
import { createRecord, detectEpistemicStatus, qualify } from "clm-kernel";
|
|
7
6
|
//#region src/server/vfsTreeScan.ts
|
|
8
7
|
/**
|
|
9
8
|
* VFS Tree Scanner — Config-Driven Server-to-Browser Federation Scan
|
|
@@ -21,8 +20,10 @@ import { detectEpistemicStatus } from "clm-kernel";
|
|
|
21
20
|
/** Unified ignore semantics: `ingest.ignore.patterns` + `vfs.extra_ignore_paths` (INV-PC-03). */
|
|
22
21
|
function shouldIgnorePath(relPath, name, config = PATHS) {
|
|
23
22
|
if (config.ingest.ignore.skip_dotfiles && name.startsWith(".")) return true;
|
|
23
|
+
if (name.endsWith("-wal") || name.endsWith("-shm") || name.endsWith("-journal")) return true;
|
|
24
|
+
if (config.stores && Object.values(config.stores).includes(name)) return true;
|
|
24
25
|
const ignored = [...config.ingest.ignore.patterns, ...config.vfs.extra_ignore_paths];
|
|
25
|
-
for (const ign of ignored) if (relPath === ign || relPath.startsWith(ign + "/") || name === ign) return true;
|
|
26
|
+
for (const ign of ignored) if (relPath === ign || relPath.startsWith(ign + "/") || name === ign || name.includes(ign)) return true;
|
|
26
27
|
return false;
|
|
27
28
|
}
|
|
28
29
|
/** Recursively scan a directory, honouring configured thresholds and text extensions. */
|
|
@@ -38,25 +39,31 @@ function scanDir(dir, baseDir, config = PATHS) {
|
|
|
38
39
|
if (f.isDirectory()) entries.push(...scanDir(fullPath, baseDir, config));
|
|
39
40
|
else if (f.isFile()) try {
|
|
40
41
|
const stat = statSync(fullPath);
|
|
41
|
-
let hash;
|
|
42
|
+
let hash = void 0;
|
|
43
|
+
let hashDeferred = void 0;
|
|
42
44
|
let content;
|
|
43
45
|
if (stat.size <= config.vfs.hash_max_bytes) try {
|
|
44
46
|
const buf = readFileSync(fullPath);
|
|
45
|
-
|
|
47
|
+
const record = createRecord(buf);
|
|
48
|
+
hash = qualify(record).asPrefixed();
|
|
46
49
|
const ext = "." + (f.name.split(".").pop() || "").toLowerCase();
|
|
47
50
|
const isTextExt = textExts.has(ext) || f.name.toLowerCase().endsWith(".tikz-cd");
|
|
48
51
|
const mime = sniffMimeType(relPath);
|
|
49
52
|
if (stat.size <= config.vfs.inline_max_bytes && (isTextExt || mime.startsWith("text/"))) content = buf.toString("utf8");
|
|
50
53
|
} catch {
|
|
51
|
-
hash =
|
|
54
|
+
hash = void 0;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
hash = void 0;
|
|
58
|
+
hashDeferred = true;
|
|
52
59
|
}
|
|
53
|
-
else hash = createHash("sha256").update(`${relPath}:${stat.size}:${stat.mtimeMs}`).digest("hex");
|
|
54
60
|
entries.push({
|
|
55
61
|
path: relPath,
|
|
56
62
|
name: f.name,
|
|
57
63
|
size: stat.size,
|
|
58
64
|
mtime: stat.mtimeMs,
|
|
59
65
|
hash,
|
|
66
|
+
hashDeferred,
|
|
60
67
|
content
|
|
61
68
|
});
|
|
62
69
|
} catch {}
|
|
@@ -99,7 +106,8 @@ function toTreeFiles(entries, config = PATHS) {
|
|
|
99
106
|
});
|
|
100
107
|
return {
|
|
101
108
|
handle: entry.path.replace(/\//g, separator),
|
|
102
|
-
hash: entry.hash,
|
|
109
|
+
hash: entry.hash ?? "",
|
|
110
|
+
hashDeferred: entry.hashDeferred,
|
|
103
111
|
path: entry.path,
|
|
104
112
|
name: entry.name,
|
|
105
113
|
mimeType: mime,
|