@workbench-kit/react 0.0.1-prototype.0 → 0.0.2-prototype.0.1.1

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 (155) hide show
  1. package/package.json +33 -9
  2. package/src/index.ts +545 -43
  3. package/src/jdw/JdwPreview.tsx +38 -0
  4. package/src/jdw/JsonCodeEditorPane.tsx +274 -0
  5. package/src/jdw/builtins/renderBuiltinWidgetLeaf.tsx +29 -0
  6. package/src/jdw/builtins/renderBuiltinWidgetNode.tsx +126 -0
  7. package/src/jdw/createBuiltinJdwRegistry.ts +111 -0
  8. package/src/jdw/cssRenderBackend.tsx +134 -0
  9. package/src/jdw/document.ts +38 -0
  10. package/src/jdw/fixtures/jdw-fixtures.ts +52 -0
  11. package/src/jdw/fixtures/jdw-sample-screens.ts +522 -0
  12. package/src/jdw/index.ts +45 -0
  13. package/src/jdw/parse.ts +1 -0
  14. package/src/jdw/renderJdw.tsx +32 -0
  15. package/src/json-config/JsonConfigWorkbench.tsx +316 -0
  16. package/src/json-config/index.ts +6 -0
  17. package/src/json-config/json-config-editor-state.ts +42 -0
  18. package/src/layout/Panel.tsx +146 -1
  19. package/src/layout/SideBarViewFrame.tsx +367 -328
  20. package/src/layout/WorkbenchCanvas.tsx +849 -0
  21. package/src/layout/WorkbenchFullscreen.tsx +368 -0
  22. package/src/layout/WorkbenchLayout.tsx +5 -0
  23. package/src/layout/WorkbenchLayoutBase.tsx +294 -0
  24. package/src/layout/WorkbenchPropertyPanel.tsx +497 -0
  25. package/src/layout/WorkbenchSidebarActions.tsx +274 -0
  26. package/src/layout/WorkbenchTree.tsx +351 -0
  27. package/src/layout/layoutHelpers.ts +25 -0
  28. package/src/modal/ConfirmDialog.tsx +61 -53
  29. package/src/modal/Modal.tsx +295 -35
  30. package/src/overlay/ContextMenu.tsx +146 -145
  31. package/src/primitives/AbsoluteBox.tsx +46 -0
  32. package/src/primitives/Badge.tsx +12 -12
  33. package/src/primitives/Button.tsx +44 -14
  34. package/src/primitives/Checkbox.tsx +11 -5
  35. package/src/primitives/EmptyState.tsx +27 -26
  36. package/src/primitives/Field.tsx +38 -38
  37. package/src/primitives/IconButton.tsx +5 -2
  38. package/src/primitives/List.tsx +111 -0
  39. package/src/primitives/NumberInput.tsx +38 -0
  40. package/src/primitives/ScrollArea.tsx +42 -0
  41. package/src/primitives/Select.tsx +1 -12
  42. package/src/primitives/StatusBar.tsx +46 -0
  43. package/src/primitives/TextArea.tsx +36 -0
  44. package/src/primitives/TextInput.tsx +11 -2
  45. package/src/primitives/WorkbenchChrome.tsx +424 -0
  46. package/src/primitives/WorkbenchEditor.tsx +394 -0
  47. package/src/primitives/index.ts +105 -0
  48. package/src/primitives/select/Select.tsx +266 -0
  49. package/src/primitives/select/index.ts +2 -0
  50. package/src/primitives/select/options.ts +38 -0
  51. package/src/primitives/select/overlay.ts +63 -0
  52. package/src/primitives/select/select.app.css +9 -0
  53. package/src/primitives/select/select.css +140 -0
  54. package/src/primitives/select/types.ts +18 -0
  55. package/src/primitives/styles.css +955 -0
  56. package/src/scrollbars.css +69 -0
  57. package/src/styles.css +7738 -1762
  58. package/src/utils/codicon.ts +17 -0
  59. package/src/widget-asset/WidgetAssetEditor.tsx +140 -0
  60. package/src/widget-asset/WidgetAssetMetadataForm.tsx +82 -0
  61. package/src/widget-asset/WidgetAssetModeControls.tsx +42 -0
  62. package/src/widget-asset/WidgetAssetSourceEditor.tsx +50 -0
  63. package/src/widget-asset/WidgetAssetWorkbench.tsx +112 -0
  64. package/src/widget-asset/index.ts +17 -0
  65. package/src/widget-asset/widget-asset-document.ts +37 -0
  66. package/src/widget-asset/widget-asset-mode.ts +3 -0
  67. package/src/widget-studio/builtin-widget-asset-catalog.ts +12 -0
  68. package/src/widget-studio/create-widget-studio-workspace-editor.tsx +79 -0
  69. package/src/widget-studio/index.ts +7 -0
  70. package/src/widget-studio/resolve-widget-studio-asset-catalog.ts +26 -0
  71. package/src/widget-tree/WidgetAssetPalette.tsx +77 -0
  72. package/src/widget-tree/WidgetInspectorPanel.tsx +266 -0
  73. package/src/widget-tree/WidgetSourceEditor.tsx +56 -0
  74. package/src/widget-tree/WidgetTreeLab.tsx +272 -0
  75. package/src/widget-tree/WidgetTreeModeControls.tsx +44 -0
  76. package/src/widget-tree/WidgetTreeSidePanel.tsx +49 -0
  77. package/src/widget-tree/WidgetTreeView.tsx +97 -0
  78. package/src/widget-tree/WidgetTreeWorkbench.tsx +111 -0
  79. package/src/widget-tree/WidgetTreeWorkspaceShell.tsx +154 -0
  80. package/src/widget-tree/demo-registry.ts +32 -0
  81. package/src/widget-tree/demo-widget-assets.ts +4 -0
  82. package/src/widget-tree/index.ts +27 -0
  83. package/src/widget-tree/widget-tree-document.ts +20 -0
  84. package/src/widget-tree/widget-tree-layout.ts +31 -0
  85. package/src/widget-tree/widget-tree-mode.ts +7 -0
  86. package/src/widget-tree/widget-tree-play-helpers.ts +74 -0
  87. package/src/workbench/ActivityBar.tsx +52 -52
  88. package/src/workbench/ArtifactShell.tsx +397 -0
  89. package/src/workbench/CommandPalette.tsx +819 -0
  90. package/src/workbench/ConfirmationFlow.tsx +245 -0
  91. package/src/workbench/MarkdownPreview.tsx +151 -0
  92. package/src/workbench/ShortcutCommandBridge.tsx +368 -0
  93. package/src/workbench/SplitView.tsx +136 -136
  94. package/src/workbench/StatusBar.tsx +178 -123
  95. package/src/workbench/StructuredArtifactEditor.tsx +205 -0
  96. package/src/workbench/Timeline.tsx +302 -0
  97. package/src/workbench/WorkbenchCanvasShell.tsx +941 -0
  98. package/src/workbench/WorkbenchShell.tsx +74 -70
  99. package/src/workbench/WorkbenchStandaloneShell.tsx +318 -291
  100. package/src/workbench/auth/WorkbenchAuthGate.tsx +61 -0
  101. package/src/workbench/auth/WorkbenchLoginView.tsx +635 -0
  102. package/src/workbench/auth/index.ts +19 -0
  103. package/src/workbench/chat/ChatComposer.tsx +165 -148
  104. package/src/workbench/chat/ChatMessageItem.tsx +10 -1
  105. package/src/workbench/chat/index.ts +9 -0
  106. package/src/workbench/chat/slashCommand.ts +28 -0
  107. package/src/workbench/chat/useChatRuntimeState.ts +76 -0
  108. package/src/workbench/chat/useSlashCommandSuggest.ts +101 -0
  109. package/src/workbench/commands.ts +520 -490
  110. package/src/workbench/index.ts +443 -98
  111. package/src/workbench/keyboard.ts +53 -0
  112. package/src/workbench/schema/index.ts +48 -0
  113. package/src/workbench/schema/workbenchDocument.ts +31 -0
  114. package/src/workbench/schema/workbenchDocumentActions.ts +6 -0
  115. package/src/workbench/schema/workbenchDocumentAdapter.ts +9 -0
  116. package/src/workbench/schema/workbenchDocumentPatch.ts +13 -0
  117. package/src/workbench/schema/workbenchDocumentRenderer.tsx +702 -0
  118. package/src/workbench/settings/NavigationPanel.tsx +47 -0
  119. package/src/workbench/settings/SchemaForm.tsx +420 -0
  120. package/src/workbench/settings/SectionedPanel.tsx +415 -0
  121. package/src/workbench/settings/StructuredDataForm.tsx +539 -0
  122. package/src/workbench/settings/StructuredDataSchemaPanel.tsx +559 -0
  123. package/src/workbench/settings/StructuredDataSchemaPanelEmbed.tsx +21 -0
  124. package/src/workbench/settings/StructuredDataSchemaPanelFrame.tsx +76 -0
  125. package/src/workbench/settings/StructuredDataTableView.tsx +127 -0
  126. package/src/workbench/settings/WorkbenchPanelRegion.tsx +46 -0
  127. package/src/workbench/settings/WorkbenchSettingsModal.tsx +21 -12
  128. package/src/workbench/settings/WorkbenchSettingsNav.tsx +38 -22
  129. package/src/workbench/settings/index.ts +135 -0
  130. package/src/workbench/settings/panel-region.css +21 -0
  131. package/src/workbench/settings/sectionedPanelScrollSpy.ts +143 -0
  132. package/src/workbench/settings/structured-data-schema-panel.css +330 -0
  133. package/src/workbench/settings/structured-data-table-view.css +85 -0
  134. package/src/workbench/settings/structuredDataSchema.ts +886 -0
  135. package/src/workbench/shell.ts +15 -0
  136. package/src/workbench/shellState.ts +203 -203
  137. package/src/workbench/standalone.ts +101 -94
  138. package/src/workbench/status.ts +129 -0
  139. package/src/workbench/theme.ts +44 -0
  140. package/src/workbench/workspace/MultiProviderExplorer.tsx +625 -0
  141. package/src/workbench/workspace/WorkspaceDraftsContext.tsx +111 -0
  142. package/src/workbench/workspace/WorkspaceEditor.tsx +47 -12
  143. package/src/workbench/workspace/WorkspaceEditorPanel.tsx +334 -353
  144. package/src/workbench/workspace/WorkspaceExplorer.tsx +532 -524
  145. package/src/workbench/workspace/WorkspaceFileIcon.tsx +32 -2
  146. package/src/workbench/workspace/WorkspaceSearchPanel.tsx +113 -113
  147. package/src/workbench/workspace/WorkspaceSearchResults.tsx +47 -47
  148. package/src/workbench/workspace/index.ts +156 -98
  149. package/src/workbench/workspace/mimeType.ts +45 -0
  150. package/src/workbench/workspace/path.ts +10 -10
  151. package/src/workbench/workspace/search.ts +6 -6
  152. package/src/workbench/workspace/tree.ts +1 -1
  153. package/src/workbench/workspace/types.ts +10 -10
  154. package/src/workbench/workspace/useVirtualWorkspace.ts +111 -98
  155. package/src/workbench/workspace/workspaceJsonDiagnostics.ts +83 -0
@@ -0,0 +1,45 @@
1
+ import { extensionOfPath } from './path';
2
+ import {
3
+ JDW_SCHEMA_DOCUMENT_FILE_EXTENSION,
4
+ JDW_SCHEMA_DOCUMENT_MIME,
5
+ JDW_WIDGET_DOCUMENT_FILE_EXTENSION,
6
+ JDW_WIDGET_DOCUMENT_MIME,
7
+ } from '../../jdw/document';
8
+
9
+ const EXTENSION_MIME: Record<string, string> = {
10
+ css: 'text/css',
11
+ gif: 'image/gif',
12
+ html: 'text/html',
13
+ jpeg: 'image/jpeg',
14
+ jpg: 'image/jpeg',
15
+ js: 'text/javascript',
16
+ json: 'application/json',
17
+ jsx: 'text/javascript',
18
+ md: 'text/markdown',
19
+ mjs: 'text/javascript',
20
+ png: 'image/png',
21
+ sql: 'text/x-sql',
22
+ svg: 'image/svg+xml',
23
+ ts: 'text/typescript',
24
+ tsx: 'text/typescript',
25
+ txt: 'text/plain',
26
+ vue: 'text/html',
27
+ xml: 'application/xml',
28
+ yaml: 'text/yaml',
29
+ yml: 'text/yaml',
30
+ zip: 'application/zip',
31
+ };
32
+
33
+ export function mimeTypeForPath(path: string): string {
34
+ const lowerPath = path.toLowerCase();
35
+
36
+ if (lowerPath.endsWith(JDW_SCHEMA_DOCUMENT_FILE_EXTENSION)) {
37
+ return JDW_SCHEMA_DOCUMENT_MIME;
38
+ }
39
+
40
+ if (lowerPath.endsWith(JDW_WIDGET_DOCUMENT_FILE_EXTENSION)) {
41
+ return JDW_WIDGET_DOCUMENT_MIME;
42
+ }
43
+
44
+ return EXTENSION_MIME[extensionOfPath(path)] ?? 'text/plain';
45
+ }
@@ -1,10 +1,10 @@
1
- export {
2
- extensionOfPath,
3
- fileNameOfPath,
4
- isSimpleWorkspaceName,
5
- joinWorkspacePath,
6
- normalizeWorkspacePath,
7
- parentPathOf,
8
- parentPathsOf,
9
- workspacePathSegments,
10
- } from '@workbench-kit/workspace';
1
+ export {
2
+ extensionOfPath,
3
+ fileNameOfPath,
4
+ isSimpleWorkspaceName,
5
+ joinWorkspacePath,
6
+ normalizeWorkspacePath,
7
+ parentPathOf,
8
+ parentPathsOf,
9
+ workspacePathSegments,
10
+ } from '@workbench-kit/workspace';
@@ -1,6 +1,6 @@
1
- export {
2
- compactText,
3
- createContentPreview,
4
- highlightText,
5
- searchWorkspaceFiles,
6
- } from '@workbench-kit/workspace';
1
+ export {
2
+ compactText,
3
+ createContentPreview,
4
+ highlightText,
5
+ searchWorkspaceFiles,
6
+ } from '@workbench-kit/workspace';
@@ -1 +1 @@
1
- export { buildWorkspaceTree, flattenWorkspaceTree } from '@workbench-kit/workspace';
1
+ export { buildWorkspaceTree, flattenWorkspaceTree } from '@workbench-kit/workspace';
@@ -1,10 +1,10 @@
1
- export type {
2
- VisibleWorkspaceNode,
3
- WorkspaceFile,
4
- WorkspaceFileSource,
5
- WorkspaceHighlightPart,
6
- WorkspaceNodeType,
7
- WorkspaceSearchMatchKind,
8
- WorkspaceSearchResult,
9
- WorkspaceTreeNode,
10
- } from '@workbench-kit/workspace';
1
+ export type {
2
+ VisibleWorkspaceNode,
3
+ WorkspaceFile,
4
+ WorkspaceFileSource,
5
+ WorkspaceHighlightPart,
6
+ WorkspaceNodeType,
7
+ WorkspaceSearchMatchKind,
8
+ WorkspaceSearchResult,
9
+ WorkspaceTreeNode,
10
+ } from '@workbench-kit/workspace';
@@ -1,98 +1,111 @@
1
- import { useMemo, useReducer } from 'react';
2
- import {
3
- buildWorkspaceTree,
4
- getAvailableWorkspaceEntryName,
5
- getWorkspaceFileMovePlan,
6
- initializeVirtualWorkspaceState,
7
- isWorkspaceEntryPathAvailable,
8
- searchWorkspaceFiles,
9
- virtualWorkspaceReducer,
10
- type CreateWorkspaceFileInput,
11
- type VirtualWorkspaceAction,
12
- type VirtualWorkspaceInitialState,
13
- type VirtualWorkspaceState,
14
- type WorkspaceEntryNameSuggestionInput,
15
- type WorkspaceEntryPathAvailabilityInput,
16
- type WorkspaceFileMove,
17
- type WorkspaceFileMovePlan,
18
- type WorkspaceFileMovePlanInput,
19
- type WorkspaceSearchResult,
20
- type WorkspaceTreeNode,
21
- type WriteWorkspaceFileInput,
22
- } from '@workbench-kit/workspace';
23
-
24
- export interface VirtualWorkspaceApi extends VirtualWorkspaceState {
25
- closeAll: () => void;
26
- closeOthers: (path: string) => void;
27
- closePath: (path: string) => void;
28
- createFile: (file: CreateWorkspaceFileInput) => void;
29
- createFolder: (path: string) => void;
30
- deleteFile: (path: string) => void;
31
- deleteFolder: (path: string) => void;
32
- moveFile: (sourcePath: string, targetFolderPath: string) => void;
33
- openFile: (path: string) => void;
34
- renameFile: (path: string, name: string, mimeType?: string) => void;
35
- renameFolder: (path: string, name: string) => void;
36
- saveFile: (path: string, file: WriteWorkspaceFileInput) => void;
37
- searchResults: WorkspaceSearchResult[];
38
- setSearchQuery: (query: string) => void;
39
- toggleFolder: (path: string) => void;
40
- workspaceTree: WorkspaceTreeNode[];
41
- }
42
-
43
- export function useVirtualWorkspace(
44
- initialState: VirtualWorkspaceInitialState,
45
- ): VirtualWorkspaceApi {
46
- const [state, dispatch] = useReducer(
47
- virtualWorkspaceReducer,
48
- initialState,
49
- initializeVirtualWorkspaceState,
50
- );
51
- const workspaceTree = useMemo(
52
- () => buildWorkspaceTree(state.folders, state.files),
53
- [state.files, state.folders],
54
- );
55
- const searchResults = useMemo(
56
- () => searchWorkspaceFiles(state.files, state.searchQuery),
57
- [state.files, state.searchQuery],
58
- );
59
-
60
- return {
61
- ...state,
62
- closeAll: () => dispatch({ type: 'close-all' }),
63
- closeOthers: (path) => dispatch({ path, type: 'close-others' }),
64
- closePath: (path) => dispatch({ path, type: 'close-path' }),
65
- createFile: (file) => dispatch({ file, type: 'create-file' }),
66
- createFolder: (path) => dispatch({ path, type: 'create-folder' }),
67
- deleteFile: (path) => dispatch({ path, type: 'delete-file' }),
68
- deleteFolder: (path) => dispatch({ path, type: 'delete-folder' }),
69
- moveFile: (sourcePath, targetFolderPath) =>
70
- dispatch({ sourcePath, targetFolderPath, type: 'move-file' }),
71
- openFile: (path) => dispatch({ path, type: 'open-file' }),
72
- renameFile: (path, name, mimeType) => dispatch({ mimeType, name, path, type: 'rename-file' }),
73
- renameFolder: (path, name) => dispatch({ name, path, type: 'rename-folder' }),
74
- saveFile: (path, file) => dispatch({ file, path, type: 'save-file' }),
75
- searchResults,
76
- setSearchQuery: (query) => dispatch({ query, type: 'set-search-query' }),
77
- toggleFolder: (path) => dispatch({ path, type: 'toggle-folder' }),
78
- workspaceTree,
79
- };
80
- }
81
-
82
- export {
83
- getAvailableWorkspaceEntryName,
84
- getWorkspaceFileMovePlan,
85
- initializeVirtualWorkspaceState,
86
- isWorkspaceEntryPathAvailable,
87
- virtualWorkspaceReducer,
88
- type CreateWorkspaceFileInput,
89
- type VirtualWorkspaceAction,
90
- type VirtualWorkspaceInitialState,
91
- type VirtualWorkspaceState,
92
- type WorkspaceEntryNameSuggestionInput,
93
- type WorkspaceEntryPathAvailabilityInput,
94
- type WorkspaceFileMove,
95
- type WorkspaceFileMovePlan,
96
- type WorkspaceFileMovePlanInput,
97
- type WriteWorkspaceFileInput,
98
- };
1
+ import { useMemo, useReducer } from 'react';
2
+ import {
3
+ buildWorkspaceTree,
4
+ getAvailableWorkspaceEntryName,
5
+ getWorkspaceEntryMovePlan,
6
+ getWorkspaceFileMovePlan,
7
+ initializeVirtualWorkspaceState,
8
+ isWorkspaceEntryPathAvailable,
9
+ searchWorkspaceFiles,
10
+ virtualWorkspaceReducer,
11
+ type CreateWorkspaceFileInput,
12
+ type VirtualWorkspaceAction,
13
+ type VirtualWorkspaceInitialState,
14
+ type VirtualWorkspaceState,
15
+ type WorkspaceEntryNameSuggestionInput,
16
+ type WorkspaceEntryMove,
17
+ type WorkspaceEntryMoveKind,
18
+ type WorkspaceEntryMovePlan,
19
+ type WorkspaceEntryMovePlanInput,
20
+ type WorkspaceEntryPathAvailabilityInput,
21
+ type WorkspaceFileMove,
22
+ type WorkspaceFileMovePlan,
23
+ type WorkspaceFileMovePlanInput,
24
+ type WorkspaceSearchResult,
25
+ type WorkspaceTreeNode,
26
+ type WriteWorkspaceFileInput,
27
+ } from '@workbench-kit/workspace';
28
+
29
+ export interface VirtualWorkspaceApi extends VirtualWorkspaceState {
30
+ closeAll: () => void;
31
+ closeOthers: (path: string) => void;
32
+ closePath: (path: string) => void;
33
+ createFile: (file: CreateWorkspaceFileInput) => void;
34
+ createFolder: (path: string) => void;
35
+ deleteFile: (path: string) => void;
36
+ deleteFolder: (path: string) => void;
37
+ moveFile: (sourcePath: string, targetFolderPath: string) => void;
38
+ moveFolder: (sourcePath: string, targetFolderPath: string) => void;
39
+ openFile: (path: string) => void;
40
+ renameFile: (path: string, name: string, mimeType?: string) => void;
41
+ renameFolder: (path: string, name: string) => void;
42
+ saveFile: (path: string, file: WriteWorkspaceFileInput) => void;
43
+ searchResults: WorkspaceSearchResult[];
44
+ setSearchQuery: (query: string) => void;
45
+ toggleFolder: (path: string) => void;
46
+ workspaceTree: WorkspaceTreeNode[];
47
+ }
48
+
49
+ export function useVirtualWorkspace(
50
+ initialState: VirtualWorkspaceInitialState,
51
+ ): VirtualWorkspaceApi {
52
+ const [state, dispatch] = useReducer(
53
+ virtualWorkspaceReducer,
54
+ initialState,
55
+ initializeVirtualWorkspaceState,
56
+ );
57
+ const workspaceTree = useMemo(
58
+ () => buildWorkspaceTree(state.folders, state.files),
59
+ [state.files, state.folders],
60
+ );
61
+ const searchResults = useMemo(
62
+ () => searchWorkspaceFiles(state.files, state.searchQuery),
63
+ [state.files, state.searchQuery],
64
+ );
65
+
66
+ return {
67
+ ...state,
68
+ closeAll: () => dispatch({ type: 'close-all' }),
69
+ closeOthers: (path) => dispatch({ path, type: 'close-others' }),
70
+ closePath: (path) => dispatch({ path, type: 'close-path' }),
71
+ createFile: (file) => dispatch({ file, type: 'create-file' }),
72
+ createFolder: (path) => dispatch({ path, type: 'create-folder' }),
73
+ deleteFile: (path) => dispatch({ path, type: 'delete-file' }),
74
+ deleteFolder: (path) => dispatch({ path, type: 'delete-folder' }),
75
+ moveFile: (sourcePath, targetFolderPath) =>
76
+ dispatch({ sourcePath, targetFolderPath, type: 'move-file' }),
77
+ moveFolder: (sourcePath, targetFolderPath) =>
78
+ dispatch({ sourcePath, targetFolderPath, type: 'move-folder' }),
79
+ openFile: (path) => dispatch({ path, type: 'open-file' }),
80
+ renameFile: (path, name, mimeType) => dispatch({ mimeType, name, path, type: 'rename-file' }),
81
+ renameFolder: (path, name) => dispatch({ name, path, type: 'rename-folder' }),
82
+ saveFile: (path, file) => dispatch({ file, path, type: 'save-file' }),
83
+ searchResults,
84
+ setSearchQuery: (query) => dispatch({ query, type: 'set-search-query' }),
85
+ toggleFolder: (path) => dispatch({ path, type: 'toggle-folder' }),
86
+ workspaceTree,
87
+ };
88
+ }
89
+
90
+ export {
91
+ getAvailableWorkspaceEntryName,
92
+ getWorkspaceEntryMovePlan,
93
+ getWorkspaceFileMovePlan,
94
+ initializeVirtualWorkspaceState,
95
+ isWorkspaceEntryPathAvailable,
96
+ virtualWorkspaceReducer,
97
+ type CreateWorkspaceFileInput,
98
+ type VirtualWorkspaceAction,
99
+ type VirtualWorkspaceInitialState,
100
+ type VirtualWorkspaceState,
101
+ type WorkspaceEntryNameSuggestionInput,
102
+ type WorkspaceEntryMove,
103
+ type WorkspaceEntryMoveKind,
104
+ type WorkspaceEntryMovePlan,
105
+ type WorkspaceEntryMovePlanInput,
106
+ type WorkspaceEntryPathAvailabilityInput,
107
+ type WorkspaceFileMove,
108
+ type WorkspaceFileMovePlan,
109
+ type WorkspaceFileMovePlanInput,
110
+ type WriteWorkspaceFileInput,
111
+ };
@@ -0,0 +1,83 @@
1
+ import type * as Monaco from 'monaco-editor';
2
+ import jdwNodeSchemaJson from '@workbench-kit/jdw/schemas/jdw-node.jdw.schema.json';
3
+ import widgetDocumentSchemaJson from '@workbench-kit/jdw/schemas/widget-document.v1.jdw.schema.json';
4
+ import { formatWorkspaceResourceUri, type WorkspaceFile } from '@workbench-kit/workspace';
5
+ import { isJdwDocument } from '../../jdw/document';
6
+
7
+ export const JDW_WIDGET_DOCUMENT_SCHEMA_URI =
8
+ 'https://workbench-kit.dev/schemas/widget-document.v1.jdw.schema.json';
9
+ export const JDW_NODE_SCHEMA_URI = 'https://workbench-kit.dev/schemas/jdw-node.jdw.schema.json';
10
+
11
+ const WORKSPACE_URI_PATTERN = /^[a-z][a-z\d+\-.]*:/i;
12
+ const WORKSPACE_JDW_WIDGET_DOCUMENT_SCHEMA_PATH = 'schemas/widget-document.v1.jdw.schema.json';
13
+ const WORKSPACE_JDW_NODE_SCHEMA_PATH = 'schemas/jdw-node.jdw.schema.json';
14
+
15
+ interface WorkspaceEditorJsonDiagnosticsSchema {
16
+ readonly fileMatch?: readonly string[];
17
+ readonly schema: unknown;
18
+ readonly uri: string;
19
+ }
20
+
21
+ export function monacoModelPathForWorkspaceFile(path: string): string {
22
+ if (WORKSPACE_URI_PATTERN.test(path)) {
23
+ return path;
24
+ }
25
+
26
+ return formatWorkspaceResourceUri({ kind: 'file', path });
27
+ }
28
+
29
+ export function getWorkspaceEditorJsonDiagnosticsSchemas(
30
+ file: WorkspaceFile,
31
+ ): readonly WorkspaceEditorJsonDiagnosticsSchema[] {
32
+ if (!isJdwDocument(file)) {
33
+ return [];
34
+ }
35
+
36
+ const modelPath = monacoModelPathForWorkspaceFile(file.path);
37
+ const fileMatch = [modelPath, file.path];
38
+
39
+ return [
40
+ {
41
+ schema: jdwNodeSchemaJson,
42
+ uri: JDW_NODE_SCHEMA_URI,
43
+ },
44
+ {
45
+ schema: jdwNodeSchemaJson,
46
+ uri: formatWorkspaceResourceUri({ kind: 'file', path: WORKSPACE_JDW_NODE_SCHEMA_PATH }),
47
+ },
48
+ {
49
+ fileMatch,
50
+ schema: widgetDocumentSchemaJson,
51
+ uri: JDW_WIDGET_DOCUMENT_SCHEMA_URI,
52
+ },
53
+ {
54
+ fileMatch,
55
+ schema: widgetDocumentSchemaJson,
56
+ uri: formatWorkspaceResourceUri({
57
+ kind: 'file',
58
+ path: WORKSPACE_JDW_WIDGET_DOCUMENT_SCHEMA_PATH,
59
+ }),
60
+ },
61
+ ];
62
+ }
63
+
64
+ export function configureWorkspaceEditorJsonDiagnostics(
65
+ monacoInstance: typeof Monaco,
66
+ file: WorkspaceFile,
67
+ ): void {
68
+ const schemas = getWorkspaceEditorJsonDiagnosticsSchemas(file);
69
+ if (schemas.length === 0) return;
70
+
71
+ const jsonDefaults = (
72
+ monacoInstance.languages.json as unknown as {
73
+ jsonDefaults?: { setDiagnosticsOptions: (options: unknown) => void };
74
+ }
75
+ ).jsonDefaults;
76
+ if (!jsonDefaults) return;
77
+
78
+ jsonDefaults.setDiagnosticsOptions({
79
+ validate: true,
80
+ enableSchemaRequest: true,
81
+ schemas,
82
+ });
83
+ }