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.
Files changed (196) hide show
  1. package/README.md +3 -0
  2. package/astro.config.mjs +41 -2
  3. package/cli/lib/runtimeContext.mjs +6 -3
  4. package/dist/client/_astro/{ChartAnalyticsViewlet.jrwIemvb.js → ChartAnalyticsViewlet.CBW-JyA3.js} +1 -1
  5. package/dist/client/_astro/{ClmPcardViewlet.C-fU7oZf.js → ClmPcardViewlet.cvKsR2ng.js} +2 -2
  6. package/dist/client/_astro/{D3GraphViewlet.BCZl0b2U.js → D3GraphViewlet.8YEIrCGL.js} +1 -1
  7. package/dist/client/_astro/DockviewSpatialWorkbench.BTd66LPl.js +12 -0
  8. package/dist/client/_astro/DocumentViewlets.KY1HcNka.js +2 -0
  9. package/dist/client/_astro/DxfViewlet.B3N5zpZR.js +1 -0
  10. package/dist/client/_astro/{ExcalidrawWhiteboardViewlet.CFpPYSdn.js → ExcalidrawWhiteboardViewlet.CMJGCQN4.js} +1 -1
  11. package/dist/client/_astro/{FaroVCardSpanInstrumenter.un8kDMWv.js → FaroVCardSpanInstrumenter.ClIqZujq.js} +1 -1
  12. package/dist/client/_astro/{FontSpecimenViewlet.D7Aw2xBZ.js → FontSpecimenViewlet.ChIyr0B8.js} +1 -1
  13. package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.D3FSc061.js +1 -0
  14. package/dist/client/_astro/{ImageViewlet.D4FN87n_.js → ImageViewlet.Cs-u7-wt.js} +1 -1
  15. package/dist/client/_astro/{KatexFormulaViewlet.CzhdIOw8.js → KatexFormulaViewlet.0nOzV_qD.js} +1 -1
  16. package/dist/client/_astro/{KoishiChatViewlet.5mepQvLX.js → KoishiChatViewlet.DLsMmwdb.js} +4 -4
  17. package/dist/client/_astro/{MCardLibraryHarness.DE8KeghO.js → MCardLibraryHarness.WBT9W10S.js} +1 -1
  18. package/dist/client/_astro/{MarkdownViewlet.CRuuXXmF.js → MarkdownViewlet.BIolkNXf.js} +25 -25
  19. package/dist/client/_astro/{MermaidDiagramViewlet.eW6sk-rF.js → MermaidDiagramViewlet.CkRk7QsS.js} +1 -1
  20. package/dist/client/_astro/PCardRendererBridge.DhaRSprd.js +1 -0
  21. package/dist/client/_astro/RendererPCardRegistry.brM2KiQs.js +1 -0
  22. package/dist/client/_astro/{SchemaYamlViewlet.ZJBvxItR.js → SchemaYamlViewlet.Bc7nkK4M.js} +1 -1
  23. 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
  24. package/dist/client/_astro/{Spatial3dViewlet.DnVMBENJ.js → Spatial3dViewlet.C-jjhr0A.js} +1 -1
  25. package/dist/client/_astro/{StudioLayout.CBgiVbeb.css → StudioLayout.CX8XGtZV.css} +1 -1
  26. package/dist/client/_astro/StudioWorkbench.B1QwGHWM.js +7 -0
  27. package/dist/client/_astro/{SvgViewlet.BCje7Qqb.js → SvgViewlet.uGxvb06H.js} +1 -1
  28. package/dist/client/_astro/{TerminalView.C_Ksz6lT.js → TerminalView.DP7G7E1m.js} +1 -1
  29. package/dist/client/_astro/{ThemeSettingsViewlet.DJpjQQ0Z.js → ThemeSettingsViewlet.UaTHcGnF.js} +1 -1
  30. package/dist/client/_astro/{TikzDiagramViewlet.CXb1A8nf.js → TikzDiagramViewlet.O8MJyXfT.js} +1 -1
  31. package/dist/client/_astro/VideoPlayerViewlet.-ycmo3kY.js +1 -0
  32. package/dist/client/_astro/WebappZenViewlet.PNce4u2T.js +1 -0
  33. package/dist/client/_astro/{WelcomeViewport.BiYwLh6l.js → WelcomeViewport.CZ6RxGSw.js} +1 -1
  34. package/dist/client/_astro/{agentIdentityCredentialService.UzMMwBwv.js → agentIdentityCredentialService.BEtZzBlO.js} +1 -1
  35. package/dist/client/_astro/cardTypeDetector.C2HH5RnU.js +1 -0
  36. package/dist/client/_astro/disposable.BmlxZrDf.js +1 -0
  37. package/dist/client/_astro/{markdownService.BgWjyJ57.js → markdownService.CpuKl0vp.js} +1 -1
  38. package/dist/client/_astro/{mcardStore.CT-ollfl.js → mcardStore.nSWnzeLg.js} +1 -1
  39. package/dist/client/_astro/mcardVfs.BSdys1Y7.js +3 -0
  40. package/dist/client/_astro/pathsConfig.CSBBSzwH.js +2 -0
  41. package/dist/client/_astro/{polyfills._3wYPjZf.js → polyfills.Bi7kO8cu.js} +1 -1
  42. package/dist/client/_astro/rendererEventBus.DirFDmGw.js +1 -0
  43. package/dist/client/_astro/themeStore.BajxvCga.js +1 -0
  44. package/dist/client/_astro/{tikzCompiler.fe3qomFY.js → tikzCompiler.-fXMNQpz.js} +1 -1
  45. package/dist/client/_astro/{useMCardHydration.7Z-HfBh5.js → useMCardHydration.Bjj_N5Gv.js} +1 -1
  46. package/dist/client/_astro/vendor-clm-kernel.B0kxq3g4.js +108 -0
  47. package/dist/client/_astro/{vfsHandles.IX_wTpw_.js → vfsHandles.D4Pq18pW.js} +1 -1
  48. package/dist/client/_astro/vfsPersistence.DVrd1BZj.js +1 -0
  49. package/dist/client/_astro/{vfsTransactions.C_IQQg0s.js → vfsTransactions.DBNtFuRz.js} +1 -1
  50. package/dist/client/_astro/{workspaceStore.CD0kAVAl.js → workspaceStore.DUHW2YBc.js} +1 -1
  51. package/dist/server/chunks/{_.._5gPhVOLM.mjs → _.._CoQKwo62.mjs} +137 -91
  52. package/dist/server/chunks/{_handle__D_cIJYrU.mjs → _handle__D8dKQPUS.mjs} +3 -3
  53. package/dist/server/chunks/{cardTypeDetector_CyW1Xnmy.mjs → cardTypeDetector_C55M_HWS.mjs} +9 -0
  54. package/dist/server/chunks/{cards_B89BvF6W.mjs → cards_rVOc8K6H.mjs} +2 -2
  55. package/dist/server/chunks/cas_DTxlZ4Le.mjs +68 -0
  56. package/dist/server/chunks/{dispatch_DOwSKukU.mjs → dispatch_BTW4E_BJ.mjs} +8 -7
  57. package/dist/server/chunks/{dispatch_CxWKiHpn.mjs → dispatch_MbkljUxD.mjs} +8 -8
  58. package/dist/server/chunks/{export_DRouradA.mjs → export_DkEwDE2T.mjs} +3 -3
  59. package/dist/server/chunks/{health_Dfa5I0-X.mjs → health_cRt0M0yu.mjs} +1 -1
  60. package/dist/server/chunks/{mcard-library_7Wzoihkm.mjs → mcard-library_CLHvyslV.mjs} +1 -1
  61. package/dist/server/chunks/{mcardVfs_CeezzRvt.mjs → mcardVfs_DvNburKb.mjs} +5 -30
  62. package/dist/server/chunks/{move__RFvIDkq.mjs → move_DYcaXBLV.mjs} +6 -6
  63. package/dist/server/chunks/{pathsConfig_CgNYYLVm.mjs → pathsConfig_Dack-p2f.mjs} +13 -3
  64. package/dist/server/chunks/{proxy_CrWJQIBe.mjs → proxy_CMbbdBPW.mjs} +2 -2
  65. package/dist/server/chunks/{raw_DzNDaDVP.mjs → raw_C97sJWhg.mjs} +59 -26
  66. package/dist/server/chunks/{serverBootstrap_XKo2s6Ha.mjs → serverBootstrap_BDdSRIu5.mjs} +2 -2
  67. package/dist/server/chunks/tree_BwmO-pTe.mjs +186 -0
  68. package/dist/server/chunks/vfsCore_DIKpk-pk.mjs +98 -0
  69. package/dist/server/chunks/{vfsTreeScan_CKp7kMt9.mjs → vfsTreeScan_CRoCluPB.mjs} +18 -10
  70. package/dist/server/chunks/workspaceRoot_CRx3taID.mjs +157 -0
  71. package/dist/server/chunks/{write_popiFsO7.mjs → write_BLsmsTIx.mjs} +6 -5
  72. package/dist/server/chunks/{ws-server-init_DUjuR2-o.mjs → ws-server-init_Cfft7U5u.mjs} +343 -298
  73. package/dist/server/entry.mjs +1 -1
  74. package/dist/server/entry2.mjs +67 -28
  75. package/dist/server/virtual_astro_middleware.mjs +2 -2
  76. package/package.json +2 -2
  77. package/src/components/studio/views/cardViewlets/ClmRegistryComponentViewlet.tsx +133 -0
  78. package/src/components/studio/views/cardViewlets/DxfViewlet.tsx +230 -0
  79. package/src/components/studio/views/cardViewlets/VideoPlayerViewlet.tsx +4 -4
  80. package/src/components/studio/views/cardViewlets/coreViewletDefs.ts +2 -2
  81. package/src/components/studio/views/cardViewlets/documents/AudioPlayerViewlet.tsx +15 -3
  82. package/src/components/studio/views/cardViewlets/documents/PdfViewlet.tsx +25 -7
  83. package/src/components/studio/views/cardViewlets/markdown/stages/wikilinkStage.ts +2 -1
  84. package/src/components/studio/views/cardViewlets/mediaViewletDefs.ts +21 -1
  85. package/src/components/studio/views/cardViewlets/webapp/WebappCanvas.tsx +40 -15
  86. package/src/components/studio/views/cardViewlets/webapp/WebappDevicePresetBar.tsx +108 -0
  87. package/src/components/studio/views/cardViewlets/webapp/WebappZenViewlet.tsx +23 -30
  88. package/src/components/studio/views/fileTree/MCardFileTree.tsx +71 -54
  89. package/src/components/studio/views/fileTree/hooks/useFileTreeSync.ts +0 -1
  90. package/src/components/studio/views/fileTree/hooks/usePartitionedTrees.ts +68 -23
  91. package/src/components/studio/views/fileTree/hooks/useSectionAccordion.ts +21 -11
  92. package/src/components/studio/views/functions/UnifiedFunctionExplorerViewlet.tsx +168 -0
  93. package/src/components/studio/views/history/HistoryPanel.tsx +110 -0
  94. package/src/components/studio/views/lineage/LineagePanel.tsx +152 -0
  95. package/src/components/studio/views/navigation/HandleLineageDrawer.tsx +89 -0
  96. package/src/components/studio/views/navigation/MultiCardCollectionBrowser.tsx +154 -0
  97. package/src/components/studio/views/pills/HashPill.tsx +101 -0
  98. package/src/components/studio/views/residency/ResidencyIndicator.tsx +82 -0
  99. package/src/config/app_config.json +3 -3
  100. package/src/core/projection/catalog.ts +105 -0
  101. package/src/core/projection/collection.ts +148 -0
  102. package/src/core/projection/handleSubscription.ts +132 -0
  103. package/src/core/projection/index.ts +4 -0
  104. package/src/core/projection/selectors.ts +29 -0
  105. package/src/core/projection/views.ts +242 -0
  106. package/src/core/refinement/designMetrics.ts +104 -0
  107. package/src/core/refinement/fibrationProjector.ts +142 -0
  108. package/src/core/refinement/lagrangianEngine.ts +137 -0
  109. package/src/core/refinement/refinementCommands.ts +82 -0
  110. package/src/core/viewport/deviceArchetypeRegistry.ts +177 -0
  111. package/src/core/viewport/viewportAudit.ts +150 -0
  112. package/src/edge/storeFilter.d.ts +4 -0
  113. package/src/edge/storeFilter.js +54 -0
  114. package/src/edge/storeFilter.ts +52 -0
  115. package/src/lib/cryptoPolyfill.js +77 -1
  116. package/src/lib/fsPolyfill.js +65 -0
  117. package/src/lib/urlPolyfill.js +21 -0
  118. package/src/lib/zlibPolyfill.js +35 -0
  119. package/src/packages/mcard-studio/package.json +2 -2
  120. package/src/packages/mcard-studio/type/legacyMapping.ts +5 -0
  121. package/src/packages/mcard-studio/viewlets/manifests.ts +2 -0
  122. package/src/packages/mcard-studio/viewlets/moduleMap.ts +12 -0
  123. package/src/packages/mcard-studio/viewlets/refinementManifests.ts +114 -0
  124. package/src/pages/api/dispatch.ts +3 -2
  125. package/src/pages/api/vfs/cas.ts +114 -0
  126. package/src/pages/api/vfs/move.ts +5 -5
  127. package/src/pages/api/vfs/raw.ts +72 -27
  128. package/src/pages/api/vfs/tree.ts +130 -11
  129. package/src/pages/api/vfs/write.ts +5 -4
  130. package/src/server/api/kernelDispatch.ts +8 -8
  131. package/src/server/artifactCollectionService.ts +4 -7
  132. package/src/server/artifactRepository.ts +4 -3
  133. package/src/server/clmRunner.mjs +1 -1
  134. package/src/server/collectionOwner.mjs +5 -5
  135. package/src/server/effects/executionPersistenceService.mjs +11 -11
  136. package/src/server/effects/resultSealingService.mjs +2 -2
  137. package/src/server/fileIngestService.mjs +21 -9
  138. package/src/server/fileWatcherService.mjs +4 -1
  139. package/src/server/handlers/fileChangeHandler.mjs +18 -10
  140. package/src/server/handlers/saveExecutionLogHandler.mjs +6 -6
  141. package/src/server/notificationService.mjs +14 -1
  142. package/src/server/scripts/buildSeedingMemory.mjs +3 -3
  143. package/src/server/serverMemoryRepository.ts +41 -59
  144. package/src/server/vfsTreeScan.ts +16 -10
  145. package/src/server/workspaceRoot.ts +143 -5
  146. package/src/services/cardTypeDetector.ts +4 -0
  147. package/src/services/databaseSyncService.ts +30 -46
  148. package/src/services/namespaceProtocolClient.ts +221 -0
  149. package/src/services/renderers/pcard/RendererPCardRegistry.ts +4 -66
  150. package/src/services/renderers/pcard/modalitySpecs.ts +125 -0
  151. package/src/services/renderers/pcard/types.ts +7 -1
  152. package/src/services/renderers/rendererEventBus.ts +5 -3
  153. package/src/services/unifiedFunctionExecutionService.ts +145 -0
  154. package/src/services/vfs/vfsCore.ts +12 -1
  155. package/src/services/vfs/vfsMigration.ts +95 -0
  156. package/src/services/vfs/vfsMutations.ts +17 -35
  157. package/src/services/vfs/vfsPersistence.ts +19 -24
  158. package/src/services/vfs/vfsSync.ts +55 -17
  159. package/src/services/vfs/vfsVersions.ts +23 -34
  160. package/src/services/workbenchExecutionPolicy.ts +183 -0
  161. package/src/stores/mcardCollectionStore.ts +2 -0
  162. package/src/styles/dockview.css +34 -0
  163. package/src/ui/viewlets/FibrationRefinementViewlet.tsx +155 -0
  164. package/src/ui/viewlets/PetriConformanceViewlet.tsx +166 -0
  165. package/src/ui/viewlets/ResponsiveViewportLabViewlet.tsx +175 -0
  166. package/src/ui/viewlets/SprintGovernanceViewlet.tsx +176 -0
  167. package/src/ui/viewlets/viewletFocus.ts +35 -0
  168. package/src/ui/viewlets/viewportLabParts.tsx +190 -0
  169. package/dist/client/_astro/DockviewSpatialWorkbench.B_I1GJHw.js +0 -12
  170. package/dist/client/_astro/DocumentViewlets.B53IqmpY.js +0 -2
  171. package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.VDRYJCM-.js +0 -1
  172. package/dist/client/_astro/PCardRendererBridge.oxVKc0gN.js +0 -1
  173. package/dist/client/_astro/RendererPCardRegistry.CWjYZs2H.js +0 -1
  174. package/dist/client/_astro/StudioWorkbench.Blo5oSIw.js +0 -7
  175. package/dist/client/_astro/VideoPlayerViewlet.CmECt7yT.js +0 -1
  176. package/dist/client/_astro/WebappZenViewlet.whCmGVHR.js +0 -1
  177. package/dist/client/_astro/__vite-browser-external.CQZnr-r3.js +0 -1
  178. package/dist/client/_astro/cardTypeDetector.Ci4APwhX.js +0 -1
  179. package/dist/client/_astro/disposable.Dsb0sbRP.js +0 -1
  180. package/dist/client/_astro/mcardVfs.2UOw9Z-r.js +0 -3
  181. package/dist/client/_astro/pathsConfig.D0hV34p7.js +0 -2
  182. package/dist/client/_astro/rendererEventBus.DMH9afq9.js +0 -1
  183. package/dist/client/_astro/themeStore.CEt0e54l.js +0 -1
  184. package/dist/client/_astro/vendor-clm-kernel.Bvk3XHk2.js +0 -116
  185. package/dist/client/_astro/vfsPersistence.BuhXYeSb.js +0 -1
  186. package/dist/server/chunks/cryptoPolyfill_99rxUwYC.mjs +0 -180
  187. package/dist/server/chunks/kernelHash_DRaj51hY.mjs +0 -5
  188. package/dist/server/chunks/tree_CE2BhvyJ.mjs +0 -76
  189. package/dist/server/chunks/vfsCore_B6nCiBl5.mjs +0 -21
  190. package/dist/server/chunks/workspaceRoot_DVSUbYkd.mjs +0 -71
  191. package/src/server/kernelHash.ts +0 -22
  192. package/src/server/storage/cardCollection.ts +0 -94
  193. package/src/server/storage/index.ts +0 -3
  194. package/src/server/storage/mcard.ts +0 -99
  195. package/src/server/storage/sqliteNodeEngine.ts +0 -121
  196. /package/dist/server/chunks/{StudioLayout_B5ZnlqjF.mjs → StudioLayout_taayQJ5b.mjs} +0 -0
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Browser-safe isomorphic url polyfill combining rollup url polyfill with WHATWG URL.
3
+ */
4
+
5
+ import urlFromPolyfill from 'rollup-plugin-node-polyfills/polyfills/url';
6
+ export * from 'rollup-plugin-node-polyfills/polyfills/url';
7
+
8
+ export const URL = typeof globalThis !== 'undefined' && globalThis.URL ? globalThis.URL : class URL {};
9
+ export const URLSearchParams = typeof globalThis !== 'undefined' && globalThis.URLSearchParams ? globalThis.URLSearchParams : class URLSearchParams {};
10
+ export function fileURLToPath(u) { return typeof u === 'string' ? u.replace(/^file:\/\//, '') : ''; }
11
+ export function pathToFileURL(p) { return new URL('file://' + p); }
12
+
13
+ const urlPolyfill = {
14
+ ...urlFromPolyfill,
15
+ URL,
16
+ URLSearchParams,
17
+ fileURLToPath,
18
+ pathToFileURL,
19
+ };
20
+
21
+ export default urlPolyfill;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Browser-safe zlib polyfill with crc32 export for client bundles.
3
+ */
4
+
5
+ import zlibModule from 'rollup-plugin-node-polyfills/polyfills/zlib';
6
+ export * from 'rollup-plugin-node-polyfills/polyfills/zlib';
7
+
8
+ const TABLE = (() => {
9
+ const table = new Uint32Array(256);
10
+ for (let i = 0; i < 256; i++) {
11
+ let c = i;
12
+ for (let j = 0; j < 8; j++) {
13
+ c = (c & 1) ? (0xedb88320 ^ (c >>> 1)) : (c >>> 1);
14
+ }
15
+ table[i] = c >>> 0;
16
+ }
17
+ return table;
18
+ })();
19
+
20
+ export function crc32(buf) {
21
+ if (!buf) return 0;
22
+ let crc = ~0;
23
+ const bytes = typeof buf === 'string' ? new TextEncoder().encode(buf) : buf;
24
+ for (let i = 0; i < bytes.length; i++) {
25
+ crc = (crc >>> 8) ^ TABLE[(crc ^ bytes[i]) & 0xff];
26
+ }
27
+ return (~crc) >>> 0;
28
+ }
29
+
30
+ const zlibPolyfill = {
31
+ ...zlibModule,
32
+ crc32,
33
+ };
34
+
35
+ export default zlibPolyfill;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcard/studio",
3
- "version": "0.0.0",
3
+ "version": "0.0.3",
4
4
  "description": "Universal MCard Manipulation, Navigation & Polynomial Interface Library for CLM",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -21,7 +21,7 @@
21
21
  "peerDependencies": {
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0",
24
- "clm-kernel": "^0.0.1",
24
+ "clm-kernel": ">=0.0.8 <0.1.0",
25
25
  "dockview-react": "^8.3.1"
26
26
  },
27
27
  "peerDependenciesMeta": {
@@ -112,6 +112,11 @@ const RULES: Rule[] = [
112
112
  },
113
113
  { id: 'pdf', match: (c) => c.mime === 'application/pdf', result: (c) => details('media', 'document', 'MCard', 'PdfViewer', c.mime) },
114
114
  { id: 'html', match: (c) => c.mime === 'text/html', result: (c) => details('media', 'document', 'MCard', 'HtmlViewer', c.mime) },
115
+ {
116
+ id: 'dxf',
117
+ match: (c) => c.mime === 'image/vnd.dxf' || c.path.endsWith('.dxf'),
118
+ result: (c) => details('media', 'document', 'MCard', 'DxfViewer', 'image/vnd.dxf'),
119
+ },
115
120
  {
116
121
  id: 'image',
117
122
  match: (c) => c.mime.startsWith('image/'),
@@ -10,6 +10,7 @@
10
10
  */
11
11
 
12
12
  import { createEmptyRegistry, register, type ViewletRegistry } from './registry.js';
13
+ import { REFINEMENT_VIEWLET_MANIFESTS } from './refinementManifests.js';
13
14
  import type { ViewletManifest } from './types.js';
14
15
 
15
16
  export const CORE_VIEWLET_MANIFESTS: readonly ViewletManifest[] = [
@@ -80,6 +81,7 @@ export const CORE_VIEWLET_MANIFESTS: readonly ViewletManifest[] = [
80
81
  keyboard: 'full',
81
82
  },
82
83
  },
84
+ ...REFINEMENT_VIEWLET_MANIFESTS,
83
85
  {
84
86
  id: 'clm.vcard.visual',
85
87
  name: 'CLM VCard Witness Inspector',
@@ -27,6 +27,18 @@ export const MODULE_MAP: Readonly<Record<string, ModuleLoader>> = Object.freeze(
27
27
  import('../../../components/studio/views/cardViewlets/TextViewlet.js') as unknown as Promise<ViewletModule>,
28
28
  ClmPcardViewlet: () =>
29
29
  import('../../../components/studio/views/cardViewlets/ClmPcardViewlet.js') as unknown as Promise<ViewletModule>,
30
+ ClmRegistryComponentViewlet: () =>
31
+ import('../../../components/studio/views/cardViewlets/ClmRegistryComponentViewlet.js') as unknown as Promise<ViewletModule>,
32
+ UnifiedFunctionExplorerViewlet: () =>
33
+ import('../../../components/studio/views/functions/UnifiedFunctionExplorerViewlet.js') as unknown as Promise<ViewletModule>,
34
+ FibrationRefinementViewlet: () =>
35
+ import('../../../ui/viewlets/FibrationRefinementViewlet.js') as unknown as Promise<ViewletModule>,
36
+ PetriConformanceViewlet: () =>
37
+ import('../../../ui/viewlets/PetriConformanceViewlet.js') as unknown as Promise<ViewletModule>,
38
+ SprintGovernanceViewlet: () =>
39
+ import('../../../ui/viewlets/SprintGovernanceViewlet.js') as unknown as Promise<ViewletModule>,
40
+ ResponsiveViewportLabViewlet: () =>
41
+ import('../../../ui/viewlets/ResponsiveViewportLabViewlet.js') as unknown as Promise<ViewletModule>,
30
42
  WitnessVcardViewlet: () =>
31
43
  import('../../../components/studio/views/cardViewlets/WitnessVcardViewlet.js') as unknown as Promise<ViewletModule>,
32
44
  ImageViewlet: () =>
@@ -0,0 +1,114 @@
1
+ /**
2
+ * @mcard/studio/viewlets — Refinement, Governance & Viewport Lab Manifests
3
+ * Canonical Path: src/packages/mcard-studio/viewlets/refinementManifests.ts
4
+ * Program: EPIC-SMR · Sprints: SMR-10, SMR-11, SMR-12 / INV-FM-14, INV-FM-15
5
+ *
6
+ * The SMR family of viewlet manifests, extracted from `manifests.ts` when that
7
+ * file reached its Contract D ceiling. They are spread into
8
+ * `CORE_VIEWLET_MANIFESTS`, so registration order and behaviour are unchanged.
9
+ *
10
+ * Zero closures, zero DOM or network imports. Contract D budget: <= 250 LOC.
11
+ */
12
+
13
+ import type { ViewletManifest } from './types.js';
14
+
15
+ export const REFINEMENT_VIEWLET_MANIFESTS: readonly ViewletManifest[] = [
16
+ {
17
+ id: 'clm.registry.component',
18
+ name: 'CLM Registry Component',
19
+ description: 'Renders a sharded clm-registry component or a portal island cartridge',
20
+ version: '1.0.0',
21
+ tabs: ['visual', 'raw_data'],
22
+ modalities: ['html'],
23
+ match: {
24
+ mimes: ['application/vnd.mcard.registry+json'],
25
+ categories: ['data', 'document'],
26
+ },
27
+ capability: {
28
+ content: 'json',
29
+ contentLimitBytes: 2_000_000,
30
+ container: 'full-bleed',
31
+ },
32
+ priority: 60,
33
+ module: 'ClmRegistryComponentViewlet',
34
+ accessibility: {
35
+ label: 'CLM Registry Component Visualizer',
36
+ keyboard: 'full',
37
+ },
38
+ },
39
+ {
40
+ id: 'function.explorer',
41
+ name: 'Supported Function Explorer',
42
+ description: 'Discovers function and capability descriptors; never grants execution',
43
+ version: '1.0.0',
44
+ tabs: ['visual', 'raw_data'],
45
+ modalities: ['html'],
46
+ match: {
47
+ mimes: ['application/vnd.mcard.catalog+json'],
48
+ categories: ['data'],
49
+ },
50
+ capability: {
51
+ content: 'json',
52
+ contentLimitBytes: 4_000_000,
53
+ container: 'full-bleed',
54
+ },
55
+ priority: 55,
56
+ module: 'UnifiedFunctionExplorerViewlet',
57
+ accessibility: {
58
+ label: 'Supported Function Explorer',
59
+ keyboard: 'full',
60
+ },
61
+ },
62
+ {
63
+ id: 'fibration.dashboard',
64
+ name: 'Fibration Dashboard',
65
+ description: 'Least-action trajectories and base-to-fiber refinement projections',
66
+ version: '1.0.0',
67
+ tabs: ['visual'],
68
+ modalities: ['html'],
69
+ match: { mimes: ['application/vnd.mcard.fibration+json'], categories: ['data'] },
70
+ capability: { content: 'json', contentLimitBytes: 2_000_000, container: 'full-bleed' },
71
+ priority: 58,
72
+ module: 'FibrationRefinementViewlet',
73
+ accessibility: { label: 'Fibration Dashboard', keyboard: 'full' },
74
+ },
75
+ {
76
+ id: 'petri.inspector',
77
+ name: 'Petri Conformance Inspector',
78
+ description: 'Read-only Petri markings and MIME taxonomy fiber conformance',
79
+ version: '1.0.0',
80
+ tabs: ['visual', 'raw_data'],
81
+ modalities: ['html'],
82
+ match: { mimes: ['application/vnd.mcard.petri+json'], categories: ['data'] },
83
+ capability: { content: 'json', contentLimitBytes: 2_000_000, container: 'full-bleed' },
84
+ priority: 57,
85
+ module: 'PetriConformanceViewlet',
86
+ accessibility: { label: 'Petri Conformance Inspector', keyboard: 'full' },
87
+ },
88
+ {
89
+ id: 'sprint.governance',
90
+ name: 'Sprint Governance Inspector',
91
+ description: 'Sprint registry projection, DoD seals, and deployment unit budgets',
92
+ version: '1.0.0',
93
+ tabs: ['visual', 'raw_data'],
94
+ modalities: ['html'],
95
+ match: { mimes: ['application/vnd.mcard.governance+json'], categories: ['data'] },
96
+ capability: { content: 'json', contentLimitBytes: 2_000_000, container: 'full-bleed' },
97
+ priority: 56,
98
+ module: 'SprintGovernanceViewlet',
99
+ accessibility: { label: 'Sprint Governance Inspector', keyboard: 'full' },
100
+ },
101
+ {
102
+ id: 'viewport.lab',
103
+ name: 'Responsive Viewport Lab',
104
+ description: 'Quad-device responsive matrix with rotation, rulers, and touch-target heatmaps',
105
+ version: '1.0.0',
106
+ tabs: ['visual', 'raw_data'],
107
+ modalities: ['html'],
108
+ match: { mimes: ['application/vnd.mcard.viewport+json'], categories: ['data'] },
109
+ capability: { content: 'json', contentLimitBytes: 2_000_000, container: 'full-bleed' },
110
+ priority: 59,
111
+ module: 'ResponsiveViewportLabViewlet',
112
+ accessibility: { label: 'Responsive Viewport Lab', keyboard: 'full' },
113
+ },
114
+ ];
@@ -9,6 +9,7 @@ import { readFileSync, existsSync } from 'node:fs';
9
9
  import { resolve } from 'node:path';
10
10
  import { workspaceRoot, repoRoot } from '../../server/workspaceRoot';
11
11
  import { PATHS } from '../../config/pathsConfig.js';
12
+ import { createRecord, qualify } from 'clm-kernel';
12
13
 
13
14
  export const prerender = false;
14
15
 
@@ -58,7 +59,7 @@ export const POST: APIRoute = async ({ request }) => {
58
59
  }
59
60
 
60
61
  const pcard = {
61
- hash: 'sha256:' + action.pcardHandle,
62
+ hash: qualify(createRecord(action.pcardHandle)).asPrefixed(),
62
63
  runtime,
63
64
  concrete_impl: { runtime },
64
65
  };
@@ -70,7 +71,7 @@ export const POST: APIRoute = async ({ request }) => {
70
71
  // Graceful server-side fallback: sign and return valid VCard witness
71
72
  const sealedVCard = await signVCard({
72
73
  pcardHash: pcard.hash,
73
- outputMCardHash: 'sha256:' + (action.intent || 'default-intent'),
74
+ outputMCardHash: qualify(createRecord(action.intent || 'default-intent')).asPrefixed(),
74
75
  sponsorDid: action.sponsorDid || 'did:clm:agent:server',
75
76
  markingTransition: {
76
77
  before: action.currentMarking ?? {},
@@ -0,0 +1,114 @@
1
+ /**
2
+ * VFS CAS Scoped Immutable Retrieval Endpoint
3
+ * Canonical Path: src/pages/api/vfs/cas.ts
4
+ * Sprint: CAS-05 (DoD-05-5, INV-CAS-11, U5)
5
+ *
6
+ * Implements scoped content-addressed GET with:
7
+ * - Strict qualified reference validation (bare digest is 400).
8
+ * - Scoped immutable caching: `private, max-age=31536000, immutable` (never `public`).
9
+ * - ETag matching and 304 Not Modified revalidation.
10
+ */
11
+
12
+ import type { APIRoute } from 'astro';
13
+ import { ContentHash, parseGTime, resolveIn, ScopeAccessError, type ScopeContext } from 'clm-kernel';
14
+ import { studioMCardFs } from '../../../services/vfs/vfsCore.js';
15
+ import { error } from '../../../lib/apiUtils.js';
16
+
17
+ export const GET: APIRoute = async ({ request, url }) => {
18
+ const hashParam = url.searchParams.get('hash')?.trim();
19
+ const scopeParam = url.searchParams.get('scope')?.trim();
20
+ const pathHint = url.searchParams.get('pathHint')?.trim() || url.searchParams.get('path')?.trim();
21
+
22
+ if (!hashParam) {
23
+ return error('Missing required query parameter: hash', 400);
24
+ }
25
+
26
+ // INV-CAS-11: Parameter must be a qualified reference (<algorithm>:<hex>)
27
+ if (!hashParam.includes(':')) {
28
+ return error('Parameter must be a qualified reference (<algo>:<hex>); bare digests are forbidden', 400);
29
+ }
30
+
31
+ const [algo, hex] = hashParam.split(':');
32
+ if (!algo || !hex || hex.length < 32) {
33
+ return error('Malformed qualified reference', 400);
34
+ }
35
+
36
+ const etag = `"${hashParam}"`;
37
+ const ifNoneMatch = request.headers.get('if-none-match')?.trim();
38
+
39
+ // 304 Revalidation check
40
+ if (ifNoneMatch === etag || ifNoneMatch === hashParam) {
41
+ return new Response(null, {
42
+ status: 304,
43
+ headers: {
44
+ 'ETag': etag,
45
+ 'Cache-Control': 'private, max-age=31536000, immutable',
46
+ },
47
+ });
48
+ }
49
+
50
+ try {
51
+ const backend = (studioMCardFs as any).backend || (studioMCardFs as any).storageBackend;
52
+ const archiveDir = (studioMCardFs as any).archiveDir || process.env.CLM_ARCHIVE_DIR;
53
+
54
+ // Scope by Reachability enforcement (DoD-06-6, INV-CAS-13)
55
+ if (scopeParam) {
56
+ const scopeRoots = scopeParam.split(',').map((s) => s.trim()).filter(Boolean);
57
+ const scopeContext: ScopeContext = {
58
+ roots: scopeRoots,
59
+ backend,
60
+ archiveDir,
61
+ };
62
+
63
+ try {
64
+ const resolved = resolveIn(scopeContext, hashParam, pathHint);
65
+ if (!resolved) {
66
+ return error(`Access denied: hash '${hashParam}' is outside authorization scope`, 403);
67
+ }
68
+ } catch (err) {
69
+ if (err instanceof ScopeAccessError) {
70
+ return error(`Path hint escaping scope root rejected: ${err.message}`, 403);
71
+ }
72
+ throw err;
73
+ }
74
+ }
75
+
76
+ let bytes: Uint8Array | undefined;
77
+
78
+ // Check getRaw or getRecord first
79
+ if (backend && typeof backend.getRaw === 'function') {
80
+ bytes = backend.getRaw(hashParam);
81
+ }
82
+ if (!bytes && backend && typeof backend.getRecord === 'function') {
83
+ const rec = backend.getRecord(hashParam);
84
+ if (rec) bytes = rec.content;
85
+ }
86
+ if (!bytes && backend && typeof backend.get === 'function') {
87
+ const card = backend.get(ContentHash.parse(hashParam));
88
+ if (card) {
89
+ bytes = typeof (card as any).toPreimage === 'function'
90
+ ? (card as any).toPreimage()
91
+ : new TextEncoder().encode(JSON.stringify(card.toJSON ? card.toJSON() : card));
92
+ }
93
+ }
94
+
95
+ if (!bytes) {
96
+ return error(`Object not found for qualified hash ${hashParam}`, 404);
97
+ }
98
+
99
+ return new Response(bytes, {
100
+ status: 200,
101
+ headers: {
102
+ 'Content-Type': 'application/octet-stream',
103
+ 'Content-Length': bytes.byteLength.toString(),
104
+ 'ETag': etag,
105
+ 'Cache-Control': 'private, max-age=31536000, immutable',
106
+ },
107
+ });
108
+ } catch (err) {
109
+ return error(
110
+ err instanceof Error ? err.message : 'Internal CAS retrieval error',
111
+ 500
112
+ );
113
+ }
114
+ };
@@ -11,9 +11,9 @@
11
11
  import type { APIRoute } from 'astro';
12
12
  import { resolve, dirname } from 'node:path';
13
13
  import { renameSync, existsSync, mkdirSync, readFileSync, statSync } from 'node:fs';
14
- import { createHash } from 'node:crypto';
14
+ import { createRecord, qualify } from 'clm-kernel';
15
15
  import { json, error } from '../../../lib/apiUtils';
16
- import { repoRoot, isPathWritable } from '../../../server/workspaceRoot';
16
+ import { repoRoot, isPathWritable, resolveHostPath } from '../../../server/workspaceRoot';
17
17
 
18
18
  export const POST: APIRoute = async ({ request }) => {
19
19
  try {
@@ -37,8 +37,8 @@ export const POST: APIRoute = async ({ request }) => {
37
37
  return error('Access denied: Target path is in a read-only projection', 403);
38
38
  }
39
39
 
40
- const sourceAbs = resolve(root, sourcePath);
41
- const targetAbs = resolve(root, targetPath);
40
+ const sourceAbs = resolveHostPath(sourcePath, root);
41
+ const targetAbs = resolveHostPath(targetPath, root);
42
42
 
43
43
  if (sourceAbs === targetAbs) {
44
44
  return error('Source and target paths are identical', 400);
@@ -58,7 +58,7 @@ export const POST: APIRoute = async ({ request }) => {
58
58
  success: true,
59
59
  sourcePath,
60
60
  targetPath,
61
- hash: bytes ? createHash('sha256').update(bytes).digest('hex') : null,
61
+ hash: bytes ? qualify(createRecord(bytes)).asPrefixed() : null,
62
62
  bytesMoved: bytes ? bytes.byteLength : 0,
63
63
  });
64
64
  } catch (err: any) {
@@ -1,9 +1,9 @@
1
1
  import type { APIRoute } from 'astro';
2
- import { statSync, existsSync, readFileSync } from 'node:fs';
2
+ import { statSync, existsSync, readFileSync, openSync, readSync, closeSync } from 'node:fs';
3
3
  import { resolve, basename } from 'node:path';
4
4
  import { sniffMimeType } from '../../../services/cardTypeDetector';
5
5
  import { error } from '../../../lib/apiUtils';
6
- import { repoRoot, isPathAllowed } from '../../../server/workspaceRoot';
6
+ import { repoRoot, isPathAllowed, resolveHostPath } from '../../../server/workspaceRoot';
7
7
 
8
8
  export const GET: APIRoute = async ({ request, url }) => {
9
9
  let relPath = url.searchParams.get('path');
@@ -30,7 +30,7 @@ export const GET: APIRoute = async ({ request, url }) => {
30
30
  .replace(/:/g, '/')
31
31
  .replace(/^(\.\.(\/|\\|$))+/, '')
32
32
  .replace(/^[/\\]+/, '');
33
- const targetPath = resolve(root, normalizedRel);
33
+ const targetPath = resolveHostPath(normalizedRel, root);
34
34
 
35
35
  // Security guard: prevent directory traversal outside allowed boundaries
36
36
  if (!isPathAllowed(targetPath, root)) {
@@ -61,6 +61,10 @@ export const GET: APIRoute = async ({ request, url }) => {
61
61
  });
62
62
  }
63
63
 
64
+ const filename = basename(targetPath);
65
+ const isDownload = url.searchParams.get('download') === '1' || url.searchParams.get('download') === 'true';
66
+ const disposition = isDownload ? `attachment; filename="${encodeURIComponent(filename)}"` : 'inline';
67
+
64
68
  const requestedHash = url.searchParams.get('v');
65
69
  if (requestedHash) {
66
70
  try {
@@ -68,22 +72,27 @@ export const GET: APIRoute = async ({ request, url }) => {
68
72
  const card = studioMCardFs.readFileByHash(requestedHash);
69
73
  if (card) {
70
74
  const mime = sniffMimeType(targetPath);
71
- const filename = basename(targetPath);
72
- const isDownload = url.searchParams.get('download') === '1' || url.searchParams.get('download') === 'true';
73
- const disposition = isDownload ? 'attachment' : 'inline';
75
+ const isBinaryMedia =
76
+ (mime.startsWith('image/') && mime !== 'image/svg+xml') ||
77
+ mime.startsWith('audio/') ||
78
+ mime.startsWith('video/') ||
79
+ mime.startsWith('font/') ||
80
+ mime === 'application/pdf';
74
81
 
75
82
  if (card.payload.kind === 'text') {
76
- const textBuf = Buffer.from(card.payload.value, 'utf8');
77
- return new Response(textBuf, {
78
- status: 200,
79
- headers: {
80
- 'Content-Type': `${mime}; charset=utf-8`,
81
- 'Content-Length': textBuf.length.toString(),
82
- 'Content-Disposition': `${disposition}; filename="${encodeURIComponent(filename)}"`,
83
- 'ETag': `W/"${requestedHash}"`,
84
- 'Cache-Control': 'public, max-age=31536000, immutable',
85
- },
86
- });
83
+ if (!isBinaryMedia) {
84
+ const textBuf = Buffer.from(card.payload.value, 'utf8');
85
+ return new Response(textBuf, {
86
+ status: 200,
87
+ headers: {
88
+ 'Content-Type': `${mime}; charset=utf-8`,
89
+ 'Content-Length': textBuf.length.toString(),
90
+ 'Content-Disposition': disposition,
91
+ 'ETag': `W/"${requestedHash}"`,
92
+ 'Cache-Control': 'no-store',
93
+ },
94
+ });
95
+ }
87
96
  } else if (card.payload.kind === 'binary' || (card.payload as any).data) {
88
97
  const binData = (card.payload as any).data;
89
98
  const binBuf = Buffer.isBuffer(binData) ? binData : Buffer.from(binData);
@@ -92,9 +101,9 @@ export const GET: APIRoute = async ({ request, url }) => {
92
101
  headers: {
93
102
  'Content-Type': (card.payload as any).mimeType || mime,
94
103
  'Content-Length': binBuf.length.toString(),
95
- 'Content-Disposition': `${disposition}; filename="${encodeURIComponent(filename)}"`,
104
+ 'Content-Disposition': disposition,
96
105
  'ETag': `W/"${requestedHash}"`,
97
- 'Cache-Control': 'public, max-age=31536000, immutable',
106
+ 'Cache-Control': 'no-store',
98
107
  },
99
108
  });
100
109
  }
@@ -111,26 +120,62 @@ export const GET: APIRoute = async ({ request, url }) => {
111
120
  mime === 'application/xml' ||
112
121
  mime === 'application/x-yaml' ||
113
122
  mime === 'image/svg+xml' ||
114
- mime === 'model/gltf+json';
123
+ mime === 'model/gltf+json' ||
124
+ mime === 'image/vnd.dxf';
115
125
 
116
126
  const contentType = isText ? `${mime}; charset=utf-8` : mime;
117
127
 
118
- // Stream for binary or read for response
119
- const fileBuffer = readFileSync(targetPath);
128
+ // HTTP 206 Partial Content Range support for video/audio/pdf progressive streaming
129
+ const rangeHeader = request.headers.get('range');
130
+ if (rangeHeader && rangeHeader.startsWith('bytes=')) {
131
+ const parts = rangeHeader.replace(/bytes=/, '').split('-');
132
+ const start = parseInt(parts[0], 10);
133
+ const end = parts[1] ? parseInt(parts[1], 10) : stat.size - 1;
134
+
135
+ if (isNaN(start) || isNaN(end) || start >= stat.size || end >= stat.size || start > end) {
136
+ return new Response(null, {
137
+ status: 416,
138
+ headers: {
139
+ 'Content-Range': `bytes */${stat.size}`,
140
+ 'Accept-Ranges': 'bytes',
141
+ },
142
+ });
143
+ }
120
144
 
121
- const filename = basename(targetPath);
122
- const isDownload = url.searchParams.get('download') === '1' || url.searchParams.get('download') === 'true';
123
- const disposition = isDownload ? 'attachment' : 'inline';
145
+ const chunkSize = end - start + 1;
146
+ const fd = openSync(targetPath, 'r');
147
+ const chunkBuffer = Buffer.alloc(chunkSize);
148
+ readSync(fd, chunkBuffer, 0, chunkSize, start);
149
+ closeSync(fd);
150
+
151
+ return new Response(chunkBuffer, {
152
+ status: 206,
153
+ headers: {
154
+ 'Content-Type': contentType,
155
+ 'Content-Range': `bytes ${start}-${end}/${stat.size}`,
156
+ 'Content-Length': chunkSize.toString(),
157
+ 'Accept-Ranges': 'bytes',
158
+ 'Content-Disposition': disposition,
159
+ 'ETag': etag,
160
+ 'Last-Modified': stat.mtime.toUTCString(),
161
+ 'Cache-Control': 'no-store',
162
+ },
163
+ });
164
+ }
165
+
166
+ // Full 200 response
167
+ const fileBuffer = readFileSync(targetPath);
124
168
 
125
169
  return new Response(fileBuffer, {
126
170
  status: 200,
127
171
  headers: {
128
172
  'Content-Type': contentType,
129
173
  'Content-Length': stat.size.toString(),
130
- 'Content-Disposition': `${disposition}; filename="${encodeURIComponent(filename)}"`,
174
+ 'Accept-Ranges': 'bytes',
175
+ 'Content-Disposition': disposition,
131
176
  'ETag': etag,
132
177
  'Last-Modified': stat.mtime.toUTCString(),
133
- 'Cache-Control': 'no-cache, must-revalidate',
178
+ 'Cache-Control': 'no-store',
134
179
  },
135
180
  });
136
181
  } catch (err) {