@puredesktop/puredesktop-ui-bridge 2.1.4 → 2.1.6
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/package.json +19 -1
- package/src/agents/runtime/mapAgentSnapshot.test.ts +1 -3
- package/src/agents/runtime/mapAgentSnapshot.ts +8 -4
- package/src/agents/runtime/mergeUsageTurn.ts +1 -2
- package/src/agents/runtime/pendingToolCalls.test.ts +1 -3
- package/src/agents/runtime/unresolvedToolCalls.ts +1 -2
- package/src/bridge/agentModelTiers.ts +9 -4
- package/src/bridge/agents.mjs +3 -1
- package/src/bridge/calendarDraftIntent.ts +12 -4
- package/src/bridge/calendarInviteIntent.ts +18 -5
- package/src/bridge/client.mjs +45 -45
- package/src/bridge/dialog.d.mts +8 -8
- package/src/bridge/dialog.mjs +40 -40
- package/src/bridge/dialog.test.ts +73 -73
- package/src/bridge/fs.d.mts +41 -41
- package/src/bridge/fs.mjs +56 -56
- package/src/bridge/fs.test.ts +83 -83
- package/src/bridge/fs.ts +28 -28
- package/src/bridge/googleAuth.ts +3 -1
- package/src/bridge/methods.d.mts +6 -0
- package/src/bridge/methods.mjs +7 -0
- package/src/bridge/network.d.mts +17 -17
- package/src/bridge/network.mjs +22 -22
- package/src/bridge/pureRender/base.css +324 -76
- package/src/bridge/pureRender/compiler.ts +1 -1
- package/src/bridge/pureRender/document.test.ts +2 -2
- package/src/bridge/pureRender/extraction.test.ts +24 -12
- package/src/bridge/pureRender/extraction.ts +10 -7
- package/src/bridge/pureRender/flow.css +17 -3
- package/src/bridge/pureRender/normalize.ts +28 -26
- package/src/bridge/pureRender/presets.ts +7 -7
- package/src/bridge/pureRender/profiles/book.css +122 -19
- package/src/bridge/pureRender/profiles/manuscript.css +57 -11
- package/src/bridge/pureRender/profiles/writer.css +48 -10
- package/src/bridge/pureRender/reset.css +20 -5
- package/src/bridge/pureRender/theme.ts +37 -9
- package/src/bridge/pureRender/tokens/default.css +45 -33
- package/src/bridge/react/usePlatformAgentRunLiveState.tsx +4 -1
- package/src/bridge/react/usePlatformAgentSessionDrive.tsx +13 -4
- package/src/bridge/screenAnnotation.test.ts +4 -1
- package/src/bridge/screenAnnotation.ts +6 -2
- package/src/bridge/storage.d.mts +27 -27
- package/src/bridge/storage.mjs +18 -18
- package/src/bridge/storage.test.ts +49 -49
- package/src/bridge/types.ts +62 -58
- package/src/bridge/window.d.mts +3 -1
- package/src/bridge/workspace.d.mts +7 -0
- package/src/bridge/workspace.mjs +8 -0
- package/src/bridge/workspace.ts +1 -0
- package/src/commitments/commitments.test.ts +10 -3
- package/src/commitments/commitments.ts +18 -4
- package/src/components/accessibility/AccessibilityReviewDialog.tsx +7 -2
- package/src/components/accessibility/accessibilityReview.test.ts +11 -4
- package/src/components/accessibility/accessibilityReview.ts +18 -10
- package/src/components/agent-feedback/ScreenAnnotationAgentDialog.tsx +9 -2
- package/src/components/agents/AgentContextUsageBar.tsx +5 -3
- package/src/components/agents/AgentDrawerPanel.test.tsx +15 -3
- package/src/components/agents/AgentMessageBubble.tsx +1 -3
- package/src/components/agents/AgentQuestionPromptList.tsx +3 -3
- package/src/components/agents/AgentToolApprovalActions.tsx +1 -3
- package/src/components/agents/agentPanelStyles.ts +1 -1
- package/src/components/agents/agentToolDisplay.ts +4 -1
- package/src/components/assets/asset-library/AssetLibraryDialog.tsx +2 -0
- package/src/components/assets/asset-library/AssetLibraryWorkspace.tsx +2 -0
- package/src/components/assets/asset-library/detail/AssetLibraryDetailHeader.test.tsx +40 -0
- package/src/components/assets/asset-library/detail/AssetLibraryDetailHeader.tsx +7 -3
- package/src/components/assets/asset-library/detail/AssetLibraryDetailPreview.tsx +8 -8
- package/src/components/assets/asset-library/hooks/useAssetLibraryDialog.ts +13 -2
- package/src/components/assets/asset-library/hooks/useAssetLibraryMutations.ts +18 -1
- package/src/components/assets/asset-library/sidebar/AssetLibraryListRow.tsx +9 -6
- package/src/components/assets/asset-library/sidebar/AssetLibrarySidebarToolbar.tsx +3 -1
- package/src/components/assets/asset-library/sidebar/AssetListThumbnail.tsx +1 -1
- package/src/components/assets/asset-library/types.ts +6 -0
- package/src/components/chrome/OverlayActionCapsule.tsx +2 -2
- package/src/components/chrome/PanelTabStrip.tsx +3 -2
- package/src/components/chrome/PureAppWordmark.tsx +15 -15
- package/src/components/chrome/WorkspaceTabStrip.tsx +19 -14
- package/src/components/chrome/documentChromePolicy.test.ts +34 -0
- package/src/components/chrome/documentChromePolicy.ts +15 -0
- package/src/components/chrome/index.ts +4 -0
- package/src/components/chrome/workspaceTabTypes.ts +2 -0
- package/src/components/common/buttons/Button.tsx +60 -10
- package/src/components/common/buttons/ChoiceChip.tsx +2 -2
- package/src/components/common/buttons/IconButton.tsx +26 -0
- package/src/components/common/buttons/SegmentedControl.tsx +23 -7
- package/src/components/common/canvas/CanvasElementFrame.tsx +37 -28
- package/src/components/common/canvas/canvasGeometry.test.ts +4 -5
- package/src/components/common/canvas/canvasGeometry.ts +1 -4
- package/src/components/common/canvas/useCanvasDragResize.test.tsx +10 -10
- package/src/components/common/canvas/useCanvasDragResize.ts +1 -4
- package/src/components/common/cards/OpenReviewCard.tsx +6 -6
- package/src/components/common/chat/ChatBox.test.tsx +9 -1
- package/src/components/common/chat/ChatBox.tsx +3 -4
- package/src/components/common/chat/ChatMarkdown.tsx +1 -1
- package/src/components/common/chat/ChatModelMenu.tsx +1 -1
- package/src/components/common/chat/ChatThinkingIndicator.tsx +1 -1
- package/src/components/common/chat/ChatThread.tsx +2 -1
- package/src/components/common/chat/ChatToolRow.tsx +2 -2
- package/src/components/common/chat/ChatUserBubble.tsx +1 -1
- package/src/components/common/connections/ConnectionSetup.tsx +6 -6
- package/src/components/common/containers/AppFrame.test.tsx +37 -36
- package/src/components/common/containers/AppFrame.tsx +15 -0
- package/src/components/common/containers/AppHeader.tsx +6 -3
- package/src/components/common/containers/SurfacePanel.tsx +1 -0
- package/src/components/common/containers/useOpacityPresence.ts +10 -15
- package/src/components/common/context/ContextSelector.tsx +10 -10
- package/src/components/common/desk/CreationDesk.tsx +23 -11
- package/src/components/common/desk/DailyBrief.tsx +18 -7
- package/src/components/common/desk/DeskCard.tsx +11 -6
- package/src/components/common/dropdown/MenuButtonDropdown.tsx +58 -6
- package/src/components/common/dropdown/MenuDropdownItem.tsx +23 -3
- package/src/components/common/dropdown/MenuPanel.tsx +8 -8
- package/src/components/common/dropdown/SelectMenu.tsx +8 -3
- package/src/components/common/dropdown/menuTypes.ts +2 -1
- package/src/components/common/evidence/StructuredEvidenceView.tsx +9 -5
- package/src/components/common/feedback/Badge.tsx +19 -5
- package/src/components/common/feedback/CapabilityPills.tsx +1 -1
- package/src/components/common/feedback/InfoHint.tsx +2 -2
- package/src/components/common/feedback/PlatformChip.tsx +9 -9
- package/src/components/common/feedback/QuietPill.tsx +5 -8
- package/src/components/common/feedback/WorkProgressPanel.tsx +14 -14
- package/src/components/common/files/FileTable.tsx +8 -2
- package/src/components/common/inputs/Checkbox.tsx +1 -1
- package/src/components/common/inputs/EditableSecretField.tsx +1 -3
- package/src/components/common/inputs/InlineComposer.tsx +2 -2
- package/src/components/common/inputs/PaletteDropdown.tsx +33 -23
- package/src/components/common/inputs/SurfacePalettePicker.tsx +1 -1
- package/src/components/common/inputs/ToggleSwitch.tsx +2 -2
- package/src/components/common/inputs/WorkspacePicker.tsx +3 -3
- package/src/components/common/lists/listRowStyles.ts +4 -2
- package/src/components/common/lists/quiet-ledger/index.ts +1 -4
- package/src/components/common/lists/reorderable/DragHandle.tsx +1 -1
- package/src/components/common/lists/reorderable/ReorderableSections.tsx +2 -1
- package/src/components/common/media/ImageReferencePicker.tsx +22 -14
- package/src/components/common/narrative/NarrativeMention.tsx +15 -9
- package/src/components/common/navigation/NavigationCardRow.tsx +2 -2
- package/src/components/common/navigation/UnderlineTabs.tsx +1 -0
- package/src/components/common/overlays/Modal.tsx +52 -3
- package/src/components/common/overlays/ObjectActionStrip.tsx +2 -2
- package/src/components/common/people/AutoUpdateReviewList.tsx +2 -2
- package/src/components/common/people/EntityList.tsx +7 -3
- package/src/components/common/people/EntityPortrait.tsx +6 -1
- package/src/components/common/people/LinkedDossierList.tsx +3 -1
- package/src/components/common/people/RelationshipMap.tsx +3 -9
- package/src/components/common/research/EvidenceDossier.tsx +24 -20
- package/src/components/common/tiles/CatalogCard.tsx +1 -1
- package/src/components/credentials/CredentialsPanel.tsx +2 -6
- package/src/components/data/DataChart.tsx +119 -94
- package/src/components/data/dataTable.ts +4 -1
- package/src/components/editor/DocumentAppChrome.tsx +172 -0
- package/src/components/editor/EditorCommentPromptDialog.tsx +1 -1
- package/src/components/editor/EditorLinkPromptDialog.tsx +1 -1
- package/src/components/print-design/PrintDesignPanel.test.tsx +8 -6
- package/src/components/print-design/PrintDesignPanel.tsx +18 -25
- package/src/components/proofing/PagedProofDialog.tsx +17 -4
- package/src/editor/EditorViewModeToggle.tsx +6 -2
- package/src/editor/index.ts +6 -0
- package/src/theme/ThemeProvider.tsx +5 -2
- package/src/theme/appAccents.test.ts +51 -0
- package/src/theme/appAccents.ts +151 -88
- package/src/theme/appIdentityCss.mjs +256 -0
- package/src/theme/appIdentityCss.ts +256 -0
- package/src/theme/composePlatformTheme.test.ts +43 -14
- package/src/theme/platformFont.d.mts +2 -2
- package/src/theme/platformFont.mjs +4 -3
- package/src/theme/reportsShellChromeSelectors.ts +14 -132
- package/src/theme/surfaceCss.mjs +37 -0
- package/src/theme/surfaceCss.ts +37 -0
- package/src/theme/surfacePalettes.ts +120 -79
- package/src/theme/surfaceRoleSelectors.ts +135 -71
- package/src/theme/themes/dark.ts +44 -43
- package/src/theme/themes/light.ts +40 -38
- package/src/theme/themes/palette.ts +32 -30
- package/src/theme/themes/shared.ts +17 -17
- package/src/theme/utils/GlobalStyles.ts +10 -6
- package/src/theme/utils/appFrameDocumentStyles.mjs +6 -1
- package/src/theme/utils/cssVariables.ts +169 -0
- package/src/writing/DraftAssistantDialog.tsx +85 -85
- package/src/writing/WritingStyleManager.tsx +6 -3
- package/src/writing/draftTextWithAgent.ts +47 -50
- package/src/writing/styleStore.ts +4 -3
- package/src/writing/writingStyle.test.ts +8 -2
- package/src/writing/writingStyle.ts +19 -8
package/src/bridge/fs.d.mts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
PlatformFileCreateFolderResult,
|
|
3
|
-
PlatformFileDeleteResult,
|
|
4
|
-
PlatformFileListResult,
|
|
5
|
-
PlatformFilePreviewUrlResult,
|
|
6
|
-
PlatformFileReadBinaryResult,
|
|
7
|
-
PlatformFileReadPreviewResult,
|
|
8
|
-
PlatformFileRenameResult,
|
|
9
|
-
PlatformFileWriteResult,
|
|
10
|
-
} from './types.js'
|
|
1
|
+
import type {
|
|
2
|
+
PlatformFileCreateFolderResult,
|
|
3
|
+
PlatformFileDeleteResult,
|
|
4
|
+
PlatformFileListResult,
|
|
5
|
+
PlatformFilePreviewUrlResult,
|
|
6
|
+
PlatformFileReadBinaryResult,
|
|
7
|
+
PlatformFileReadPreviewResult,
|
|
8
|
+
PlatformFileRenameResult,
|
|
9
|
+
PlatformFileWriteResult,
|
|
10
|
+
} from './types.js'
|
|
11
11
|
|
|
12
|
-
export declare const PLATFORM_FILE_TEXT_PREVIEW_MAX_BYTES: number
|
|
13
|
-
export declare const PLATFORM_FILE_BINARY_PREVIEW_MAX_BYTES: number
|
|
14
|
-
|
|
15
|
-
export declare function listPlatformFiles(
|
|
16
|
-
rootPath: string,
|
|
17
|
-
): Promise<PlatformFileListResult>
|
|
18
|
-
|
|
19
|
-
export declare function readPlatformTextFile(path: string): Promise<string>
|
|
20
|
-
|
|
21
|
-
export declare function writePlatformTextFile(
|
|
22
|
-
path: string,
|
|
23
|
-
content: string,
|
|
24
|
-
): Promise<PlatformFileWriteResult>
|
|
25
|
-
|
|
26
|
-
export declare function readPlatformFilePreview(
|
|
27
|
-
path: string,
|
|
28
|
-
maxBytes?: number,
|
|
12
|
+
export declare const PLATFORM_FILE_TEXT_PREVIEW_MAX_BYTES: number
|
|
13
|
+
export declare const PLATFORM_FILE_BINARY_PREVIEW_MAX_BYTES: number
|
|
14
|
+
|
|
15
|
+
export declare function listPlatformFiles(
|
|
16
|
+
rootPath: string,
|
|
17
|
+
): Promise<PlatformFileListResult>
|
|
18
|
+
|
|
19
|
+
export declare function readPlatformTextFile(path: string): Promise<string>
|
|
20
|
+
|
|
21
|
+
export declare function writePlatformTextFile(
|
|
22
|
+
path: string,
|
|
23
|
+
content: string,
|
|
24
|
+
): Promise<PlatformFileWriteResult>
|
|
25
|
+
|
|
26
|
+
export declare function readPlatformFilePreview(
|
|
27
|
+
path: string,
|
|
28
|
+
maxBytes?: number,
|
|
29
29
|
): Promise<PlatformFileReadPreviewResult>
|
|
30
30
|
|
|
31
31
|
export declare function readPlatformFileBinary(
|
|
@@ -51,17 +51,17 @@ export declare function writePlatformFileBinary(
|
|
|
51
51
|
base64: string,
|
|
52
52
|
): Promise<{ ok: true }>
|
|
53
53
|
|
|
54
|
-
export declare function createPlatformFolder(
|
|
55
|
-
parentPath: string,
|
|
56
|
-
name: string,
|
|
57
|
-
): Promise<PlatformFileCreateFolderResult>
|
|
58
|
-
|
|
59
|
-
export declare function renamePlatformFile(
|
|
60
|
-
path: string,
|
|
61
|
-
name: string,
|
|
62
|
-
): Promise<PlatformFileRenameResult>
|
|
63
|
-
|
|
64
|
-
export declare function deletePlatformFile(
|
|
65
|
-
path: string,
|
|
66
|
-
recursive?: boolean,
|
|
67
|
-
): Promise<PlatformFileDeleteResult>
|
|
54
|
+
export declare function createPlatformFolder(
|
|
55
|
+
parentPath: string,
|
|
56
|
+
name: string,
|
|
57
|
+
): Promise<PlatformFileCreateFolderResult>
|
|
58
|
+
|
|
59
|
+
export declare function renamePlatformFile(
|
|
60
|
+
path: string,
|
|
61
|
+
name: string,
|
|
62
|
+
): Promise<PlatformFileRenameResult>
|
|
63
|
+
|
|
64
|
+
export declare function deletePlatformFile(
|
|
65
|
+
path: string,
|
|
66
|
+
recursive?: boolean,
|
|
67
|
+
): Promise<PlatformFileDeleteResult>
|
package/src/bridge/fs.mjs
CHANGED
|
@@ -5,38 +5,38 @@ import { PLATFORM_BRIDGE_METHODS } from './methods.mjs'
|
|
|
5
5
|
export const PLATFORM_FILE_TEXT_PREVIEW_MAX_BYTES = 64 * 1024
|
|
6
6
|
|
|
7
7
|
/** Default binary preview cap for legacy inline image reads. Prefer `fs.previewUrl`. */
|
|
8
|
-
export const PLATFORM_FILE_BINARY_PREVIEW_MAX_BYTES = 5 * 1024 * 1024
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @param {string} rootPath
|
|
12
|
-
* @returns {Promise<import('./types.ts').PlatformFileListResult>}
|
|
13
|
-
*/
|
|
14
|
-
export async function listPlatformFiles(rootPath) {
|
|
15
|
-
return bridge.call(PLATFORM_BRIDGE_METHODS.FS_LIST, [{ rootPath }])
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @param {string} path
|
|
20
|
-
* @returns {Promise<string>}
|
|
21
|
-
*/
|
|
22
|
-
export async function readPlatformTextFile(path) {
|
|
23
|
-
return bridge.call(PLATFORM_BRIDGE_METHODS.FS_READ, [path])
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @param {string} path
|
|
28
|
-
* @param {string} content
|
|
29
|
-
* @returns {Promise<import('./types.ts').PlatformFileWriteResult>}
|
|
30
|
-
*/
|
|
31
|
-
export async function writePlatformTextFile(path, content) {
|
|
32
|
-
return bridge.call(PLATFORM_BRIDGE_METHODS.FS_WRITE, [path, content])
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @param {string} path
|
|
37
|
-
* @returns {Promise<import('./types.ts').PlatformFilePreviewUrlResult>}
|
|
38
|
-
*/
|
|
39
|
-
export async function readPlatformFilePreviewUrl(path) {
|
|
8
|
+
export const PLATFORM_FILE_BINARY_PREVIEW_MAX_BYTES = 5 * 1024 * 1024
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {string} rootPath
|
|
12
|
+
* @returns {Promise<import('./types.ts').PlatformFileListResult>}
|
|
13
|
+
*/
|
|
14
|
+
export async function listPlatformFiles(rootPath) {
|
|
15
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.FS_LIST, [{ rootPath }])
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} path
|
|
20
|
+
* @returns {Promise<string>}
|
|
21
|
+
*/
|
|
22
|
+
export async function readPlatformTextFile(path) {
|
|
23
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.FS_READ, [path])
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {string} path
|
|
28
|
+
* @param {string} content
|
|
29
|
+
* @returns {Promise<import('./types.ts').PlatformFileWriteResult>}
|
|
30
|
+
*/
|
|
31
|
+
export async function writePlatformTextFile(path, content) {
|
|
32
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.FS_WRITE, [path, content])
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param {string} path
|
|
37
|
+
* @returns {Promise<import('./types.ts').PlatformFilePreviewUrlResult>}
|
|
38
|
+
*/
|
|
39
|
+
export async function readPlatformFilePreviewUrl(path) {
|
|
40
40
|
return bridge.call(PLATFORM_BRIDGE_METHODS.FS_PREVIEW_URL, [{ path }])
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -100,27 +100,27 @@ export async function writePlatformFileBinary(path, base64) {
|
|
|
100
100
|
* @param {string} name
|
|
101
101
|
* @returns {Promise<{ path: string }>}
|
|
102
102
|
*/
|
|
103
|
-
export async function createPlatformFolder(parentPath, name) {
|
|
104
|
-
return bridge.call(PLATFORM_BRIDGE_METHODS.FS_CREATE_FOLDER, [
|
|
105
|
-
{ parentPath, name },
|
|
106
|
-
])
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @param {string} path
|
|
111
|
-
* @param {string} name
|
|
112
|
-
* @returns {Promise<import('./types.ts').PlatformFileRenameResult>}
|
|
113
|
-
*/
|
|
114
|
-
export async function renamePlatformFile(path, name) {
|
|
115
|
-
return bridge.call(PLATFORM_BRIDGE_METHODS.FS_RENAME, [{ path, name }])
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @param {string} path
|
|
120
|
-
* @param {boolean | undefined} recursive
|
|
121
|
-
* @returns {Promise<import('./types.ts').PlatformFileDeleteResult>}
|
|
122
|
-
*/
|
|
123
|
-
export async function deletePlatformFile(path, recursive) {
|
|
124
|
-
const request = recursive === undefined ? { path } : { path, recursive }
|
|
125
|
-
return bridge.call(PLATFORM_BRIDGE_METHODS.FS_DELETE, [request])
|
|
126
|
-
}
|
|
103
|
+
export async function createPlatformFolder(parentPath, name) {
|
|
104
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.FS_CREATE_FOLDER, [
|
|
105
|
+
{ parentPath, name },
|
|
106
|
+
])
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @param {string} path
|
|
111
|
+
* @param {string} name
|
|
112
|
+
* @returns {Promise<import('./types.ts').PlatformFileRenameResult>}
|
|
113
|
+
*/
|
|
114
|
+
export async function renamePlatformFile(path, name) {
|
|
115
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.FS_RENAME, [{ path, name }])
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @param {string} path
|
|
120
|
+
* @param {boolean | undefined} recursive
|
|
121
|
+
* @returns {Promise<import('./types.ts').PlatformFileDeleteResult>}
|
|
122
|
+
*/
|
|
123
|
+
export async function deletePlatformFile(path, recursive) {
|
|
124
|
+
const request = recursive === undefined ? { path } : { path, recursive }
|
|
125
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.FS_DELETE, [request])
|
|
126
|
+
}
|
package/src/bridge/fs.test.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
-
import { PLATFORM_BRIDGE_METHODS } from './methods.mjs'
|
|
3
|
-
|
|
4
|
-
const bridgeCall = vi.hoisted(() => vi.fn())
|
|
5
|
-
|
|
6
|
-
vi.mock('./client.mjs', () => ({
|
|
7
|
-
bridge: {
|
|
8
|
-
call: bridgeCall,
|
|
9
|
-
},
|
|
10
|
-
}))
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
dataUrlFromFileBinary,
|
|
14
|
-
deletePlatformFile,
|
|
15
|
-
listPlatformFiles,
|
|
16
|
-
readPlatformTextFile,
|
|
17
|
-
renamePlatformFile,
|
|
18
|
-
writePlatformTextFile,
|
|
19
|
-
} from './fs.mjs'
|
|
20
|
-
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
bridgeCall.mockReset()
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
describe('dataUrlFromFileBinary', () => {
|
|
26
|
-
it('builds a data URL from bridge binary result', () => {
|
|
27
|
-
expect(
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { PLATFORM_BRIDGE_METHODS } from './methods.mjs'
|
|
3
|
+
|
|
4
|
+
const bridgeCall = vi.hoisted(() => vi.fn())
|
|
5
|
+
|
|
6
|
+
vi.mock('./client.mjs', () => ({
|
|
7
|
+
bridge: {
|
|
8
|
+
call: bridgeCall,
|
|
9
|
+
},
|
|
10
|
+
}))
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
dataUrlFromFileBinary,
|
|
14
|
+
deletePlatformFile,
|
|
15
|
+
listPlatformFiles,
|
|
16
|
+
readPlatformTextFile,
|
|
17
|
+
renamePlatformFile,
|
|
18
|
+
writePlatformTextFile,
|
|
19
|
+
} from './fs.mjs'
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
bridgeCall.mockReset()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
describe('dataUrlFromFileBinary', () => {
|
|
26
|
+
it('builds a data URL from bridge binary result', () => {
|
|
27
|
+
expect(
|
|
28
28
|
dataUrlFromFileBinary({
|
|
29
29
|
path: '/tmp/image.png',
|
|
30
30
|
mimeType: 'image/png',
|
|
@@ -32,59 +32,59 @@ describe('dataUrlFromFileBinary', () => {
|
|
|
32
32
|
truncated: false,
|
|
33
33
|
byteLength: 3,
|
|
34
34
|
}),
|
|
35
|
-
).toBe('data:image/png;base64,abc123')
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
describe('filesystem bridge helpers', () => {
|
|
40
|
-
it('lists files using the shell request object shape', async () => {
|
|
41
|
-
bridgeCall.mockResolvedValue({ entries: [] })
|
|
42
|
-
|
|
43
|
-
await listPlatformFiles('/tmp')
|
|
44
|
-
|
|
45
|
-
expect(bridgeCall).toHaveBeenCalledWith(PLATFORM_BRIDGE_METHODS.FS_LIST, [
|
|
46
|
-
{ rootPath: '/tmp' },
|
|
47
|
-
])
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('reads text files using the shell path argument shape', async () => {
|
|
51
|
-
bridgeCall.mockResolvedValue('hello')
|
|
52
|
-
|
|
53
|
-
await readPlatformTextFile('/tmp/a.md')
|
|
54
|
-
|
|
55
|
-
expect(bridgeCall).toHaveBeenCalledWith(PLATFORM_BRIDGE_METHODS.FS_READ, [
|
|
56
|
-
'/tmp/a.md',
|
|
57
|
-
])
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('writes text files using the shell path and content argument shape', async () => {
|
|
61
|
-
bridgeCall.mockResolvedValue({ ok: true })
|
|
62
|
-
|
|
63
|
-
await writePlatformTextFile('/tmp/a.md', 'hello')
|
|
64
|
-
|
|
65
|
-
expect(bridgeCall).toHaveBeenCalledWith(PLATFORM_BRIDGE_METHODS.FS_WRITE, [
|
|
66
|
-
'/tmp/a.md',
|
|
67
|
-
'hello',
|
|
68
|
-
])
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it('renames files using the shell request object shape', async () => {
|
|
72
|
-
bridgeCall.mockResolvedValue({ path: '/tmp/b.md' })
|
|
73
|
-
|
|
74
|
-
await renamePlatformFile('/tmp/a.md', 'b.md')
|
|
75
|
-
|
|
76
|
-
expect(bridgeCall).toHaveBeenCalledWith(PLATFORM_BRIDGE_METHODS.FS_RENAME, [
|
|
77
|
-
{ path: '/tmp/a.md', name: 'b.md' },
|
|
78
|
-
])
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
it('deletes files using the shell request object shape', async () => {
|
|
82
|
-
bridgeCall.mockResolvedValue({ ok: true })
|
|
83
|
-
|
|
84
|
-
await deletePlatformFile('/tmp/a.md', true)
|
|
85
|
-
|
|
86
|
-
expect(bridgeCall).toHaveBeenCalledWith(PLATFORM_BRIDGE_METHODS.FS_DELETE, [
|
|
87
|
-
{ path: '/tmp/a.md', recursive: true },
|
|
88
|
-
])
|
|
89
|
-
})
|
|
90
|
-
})
|
|
35
|
+
).toBe('data:image/png;base64,abc123')
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
describe('filesystem bridge helpers', () => {
|
|
40
|
+
it('lists files using the shell request object shape', async () => {
|
|
41
|
+
bridgeCall.mockResolvedValue({ entries: [] })
|
|
42
|
+
|
|
43
|
+
await listPlatformFiles('/tmp')
|
|
44
|
+
|
|
45
|
+
expect(bridgeCall).toHaveBeenCalledWith(PLATFORM_BRIDGE_METHODS.FS_LIST, [
|
|
46
|
+
{ rootPath: '/tmp' },
|
|
47
|
+
])
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('reads text files using the shell path argument shape', async () => {
|
|
51
|
+
bridgeCall.mockResolvedValue('hello')
|
|
52
|
+
|
|
53
|
+
await readPlatformTextFile('/tmp/a.md')
|
|
54
|
+
|
|
55
|
+
expect(bridgeCall).toHaveBeenCalledWith(PLATFORM_BRIDGE_METHODS.FS_READ, [
|
|
56
|
+
'/tmp/a.md',
|
|
57
|
+
])
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('writes text files using the shell path and content argument shape', async () => {
|
|
61
|
+
bridgeCall.mockResolvedValue({ ok: true })
|
|
62
|
+
|
|
63
|
+
await writePlatformTextFile('/tmp/a.md', 'hello')
|
|
64
|
+
|
|
65
|
+
expect(bridgeCall).toHaveBeenCalledWith(PLATFORM_BRIDGE_METHODS.FS_WRITE, [
|
|
66
|
+
'/tmp/a.md',
|
|
67
|
+
'hello',
|
|
68
|
+
])
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('renames files using the shell request object shape', async () => {
|
|
72
|
+
bridgeCall.mockResolvedValue({ path: '/tmp/b.md' })
|
|
73
|
+
|
|
74
|
+
await renamePlatformFile('/tmp/a.md', 'b.md')
|
|
75
|
+
|
|
76
|
+
expect(bridgeCall).toHaveBeenCalledWith(PLATFORM_BRIDGE_METHODS.FS_RENAME, [
|
|
77
|
+
{ path: '/tmp/a.md', name: 'b.md' },
|
|
78
|
+
])
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('deletes files using the shell request object shape', async () => {
|
|
82
|
+
bridgeCall.mockResolvedValue({ ok: true })
|
|
83
|
+
|
|
84
|
+
await deletePlatformFile('/tmp/a.md', true)
|
|
85
|
+
|
|
86
|
+
expect(bridgeCall).toHaveBeenCalledWith(PLATFORM_BRIDGE_METHODS.FS_DELETE, [
|
|
87
|
+
{ path: '/tmp/a.md', recursive: true },
|
|
88
|
+
])
|
|
89
|
+
})
|
|
90
|
+
})
|
package/src/bridge/fs.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export {
|
|
2
|
-
createPlatformFolder,
|
|
3
|
-
dataUrlFromFileBinary,
|
|
4
|
-
deletePlatformFile,
|
|
5
|
-
listPlatformFiles,
|
|
6
|
-
readPlatformFileBinary,
|
|
7
|
-
readPlatformFileBinaryDataUrl,
|
|
8
|
-
readPlatformFilePreview,
|
|
9
|
-
readPlatformFilePreviewUrl,
|
|
10
|
-
readPlatformTextFile,
|
|
11
|
-
renamePlatformFile,
|
|
12
|
-
writePlatformFileBinary,
|
|
13
|
-
writePlatformTextFile,
|
|
14
|
-
PLATFORM_FILE_BINARY_PREVIEW_MAX_BYTES,
|
|
15
|
-
PLATFORM_FILE_TEXT_PREVIEW_MAX_BYTES,
|
|
16
|
-
} from './fs.mjs'
|
|
17
|
-
|
|
18
|
-
export type {
|
|
19
|
-
PlatformFileCreateFolderResult,
|
|
20
|
-
PlatformFileDeleteResult,
|
|
21
|
-
PlatformFileEntry,
|
|
22
|
-
PlatformFileListResult,
|
|
23
|
-
PlatformFilePreviewUrlResult,
|
|
24
|
-
PlatformFileReadBinaryResult,
|
|
25
|
-
PlatformFileReadPreviewResult,
|
|
26
|
-
PlatformFileRenameResult,
|
|
27
|
-
PlatformFileWriteResult,
|
|
28
|
-
} from './types.js'
|
|
1
|
+
export {
|
|
2
|
+
createPlatformFolder,
|
|
3
|
+
dataUrlFromFileBinary,
|
|
4
|
+
deletePlatformFile,
|
|
5
|
+
listPlatformFiles,
|
|
6
|
+
readPlatformFileBinary,
|
|
7
|
+
readPlatformFileBinaryDataUrl,
|
|
8
|
+
readPlatformFilePreview,
|
|
9
|
+
readPlatformFilePreviewUrl,
|
|
10
|
+
readPlatformTextFile,
|
|
11
|
+
renamePlatformFile,
|
|
12
|
+
writePlatformFileBinary,
|
|
13
|
+
writePlatformTextFile,
|
|
14
|
+
PLATFORM_FILE_BINARY_PREVIEW_MAX_BYTES,
|
|
15
|
+
PLATFORM_FILE_TEXT_PREVIEW_MAX_BYTES,
|
|
16
|
+
} from './fs.mjs'
|
|
17
|
+
|
|
18
|
+
export type {
|
|
19
|
+
PlatformFileCreateFolderResult,
|
|
20
|
+
PlatformFileDeleteResult,
|
|
21
|
+
PlatformFileEntry,
|
|
22
|
+
PlatformFileListResult,
|
|
23
|
+
PlatformFilePreviewUrlResult,
|
|
24
|
+
PlatformFileReadBinaryResult,
|
|
25
|
+
PlatformFileReadPreviewResult,
|
|
26
|
+
PlatformFileRenameResult,
|
|
27
|
+
PlatformFileWriteResult,
|
|
28
|
+
} from './types.js'
|
package/src/bridge/googleAuth.ts
CHANGED
|
@@ -127,7 +127,9 @@ export async function exchangeCodeForTokens(
|
|
|
127
127
|
`Google token exchange failed (${response.status}): ${response.body}`,
|
|
128
128
|
)
|
|
129
129
|
}
|
|
130
|
-
return tokensFromTokenResponse(
|
|
130
|
+
return tokensFromTokenResponse(
|
|
131
|
+
JSON.parse(response.body) as GoogleTokenResponse,
|
|
132
|
+
)
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
export interface TokenRefreshInput {
|
package/src/bridge/methods.d.mts
CHANGED
|
@@ -7,6 +7,7 @@ export declare const PLATFORM_BRIDGE_METHODS: {
|
|
|
7
7
|
readonly CATALOG_OPEN: 'catalog.open'
|
|
8
8
|
readonly WORKSPACE_OPEN_APP: 'workspace.openApp'
|
|
9
9
|
readonly WORKSPACE_OPEN_PALETTE: 'workspace.openPalette'
|
|
10
|
+
readonly WORKSPACE_UPDATE_CURRENT_TAB: 'workspace.updateCurrentTab'
|
|
10
11
|
readonly SCHEDULER_REGISTER: 'scheduler.register'
|
|
11
12
|
readonly SCHEDULER_UNREGISTER: 'scheduler.unregister'
|
|
12
13
|
readonly CATALOG_CONSUME_PENDING_OPEN: 'catalog.consumePendingOpen'
|
|
@@ -32,9 +33,12 @@ export declare const PLATFORM_BRIDGE_METHODS: {
|
|
|
32
33
|
readonly DIALOG_SAVE_FOLDER: 'dialog.saveFolder'
|
|
33
34
|
readonly DIALOG_OPEN_IMAGE: 'dialog.openImage'
|
|
34
35
|
readonly DIALOG_OPEN_FILE: 'dialog.openFile'
|
|
36
|
+
readonly DIALOG_SAVE_FILE: 'dialog.saveFile'
|
|
35
37
|
readonly OS_REVEAL: 'os.reveal'
|
|
36
38
|
readonly OS_OPEN_PATH: 'os.openPath'
|
|
37
39
|
readonly OS_TRASH: 'os.trash'
|
|
40
|
+
readonly CLIPBOARD_READ: 'clipboard.read'
|
|
41
|
+
readonly CLIPBOARD_WRITE: 'clipboard.write'
|
|
38
42
|
readonly RENDER_PRINT_HTML: 'render.printHtml'
|
|
39
43
|
readonly RENDER_PREPARE_PAGED_PREVIEW: 'render.preparePagedPreview'
|
|
40
44
|
readonly RENDER_CAPTURE_PAGED_SNAPSHOT: 'render.capturePagedSnapshot'
|
|
@@ -102,6 +106,7 @@ export declare const PLATFORM_BRIDGE_METHODS: {
|
|
|
102
106
|
|
|
103
107
|
export declare const PLATFORM_BRIDGE_METHOD_PREFIXES: {
|
|
104
108
|
readonly RUNTIME: 'runtime.'
|
|
109
|
+
readonly WORKSPACE: 'workspace.'
|
|
105
110
|
readonly THEME: 'theme.'
|
|
106
111
|
readonly WINDOW: 'window.'
|
|
107
112
|
readonly SETTINGS: 'settings.'
|
|
@@ -109,6 +114,7 @@ export declare const PLATFORM_BRIDGE_METHOD_PREFIXES: {
|
|
|
109
114
|
readonly FS: 'fs.'
|
|
110
115
|
readonly DIALOG: 'dialog.'
|
|
111
116
|
readonly OS: 'os.'
|
|
117
|
+
readonly CLIPBOARD: 'clipboard.'
|
|
112
118
|
readonly RENDER: 'render.'
|
|
113
119
|
readonly WATCH: 'watch.'
|
|
114
120
|
readonly ASSETS: 'assets.'
|
package/src/bridge/methods.mjs
CHANGED
|
@@ -10,6 +10,7 @@ export const PLATFORM_BRIDGE_METHODS = {
|
|
|
10
10
|
CATALOG_OPEN: 'catalog.open',
|
|
11
11
|
WORKSPACE_OPEN_APP: 'workspace.openApp',
|
|
12
12
|
WORKSPACE_OPEN_PALETTE: 'workspace.openPalette',
|
|
13
|
+
WORKSPACE_UPDATE_CURRENT_TAB: 'workspace.updateCurrentTab',
|
|
13
14
|
SCHEDULER_REGISTER: 'scheduler.register',
|
|
14
15
|
SCHEDULER_UNREGISTER: 'scheduler.unregister',
|
|
15
16
|
CATALOG_CONSUME_PENDING_OPEN: 'catalog.consumePendingOpen',
|
|
@@ -41,11 +42,15 @@ export const PLATFORM_BRIDGE_METHODS = {
|
|
|
41
42
|
DIALOG_SAVE_FOLDER: 'dialog.saveFolder',
|
|
42
43
|
DIALOG_OPEN_IMAGE: 'dialog.openImage',
|
|
43
44
|
DIALOG_OPEN_FILE: 'dialog.openFile',
|
|
45
|
+
DIALOG_SAVE_FILE: 'dialog.saveFile',
|
|
44
46
|
|
|
45
47
|
OS_REVEAL: 'os.reveal',
|
|
46
48
|
OS_OPEN_PATH: 'os.openPath',
|
|
47
49
|
OS_TRASH: 'os.trash',
|
|
48
50
|
|
|
51
|
+
CLIPBOARD_READ: 'clipboard.read',
|
|
52
|
+
CLIPBOARD_WRITE: 'clipboard.write',
|
|
53
|
+
|
|
49
54
|
RENDER_PRINT_HTML: 'render.printHtml',
|
|
50
55
|
RENDER_PREPARE_PAGED_PREVIEW: 'render.preparePagedPreview',
|
|
51
56
|
RENDER_CAPTURE_PAGED_SNAPSHOT: 'render.capturePagedSnapshot',
|
|
@@ -123,6 +128,7 @@ export const PLATFORM_BRIDGE_METHODS = {
|
|
|
123
128
|
|
|
124
129
|
export const PLATFORM_BRIDGE_METHOD_PREFIXES = {
|
|
125
130
|
RUNTIME: 'runtime.',
|
|
131
|
+
WORKSPACE: 'workspace.',
|
|
126
132
|
THEME: 'theme.',
|
|
127
133
|
WINDOW: 'window.',
|
|
128
134
|
SETTINGS: 'settings.',
|
|
@@ -130,6 +136,7 @@ export const PLATFORM_BRIDGE_METHOD_PREFIXES = {
|
|
|
130
136
|
FS: 'fs.',
|
|
131
137
|
DIALOG: 'dialog.',
|
|
132
138
|
OS: 'os.',
|
|
139
|
+
CLIPBOARD: 'clipboard.',
|
|
133
140
|
RENDER: 'render.',
|
|
134
141
|
WATCH: 'watch.',
|
|
135
142
|
ASSETS: 'assets.',
|
package/src/bridge/network.d.mts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export interface PlatformNetworkFetchRequest {
|
|
2
|
-
url: string
|
|
3
|
-
method?: string
|
|
4
|
-
headers?: Record<string, string>
|
|
5
|
-
body?: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface PlatformNetworkFetchResponse {
|
|
9
|
-
status: number
|
|
10
|
-
ok: boolean
|
|
11
|
-
headers: Record<string, string>
|
|
12
|
-
body: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export declare function networkFetch(
|
|
16
|
-
request: PlatformNetworkFetchRequest,
|
|
17
|
-
): Promise<PlatformNetworkFetchResponse>
|
|
1
|
+
export interface PlatformNetworkFetchRequest {
|
|
2
|
+
url: string
|
|
3
|
+
method?: string
|
|
4
|
+
headers?: Record<string, string>
|
|
5
|
+
body?: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface PlatformNetworkFetchResponse {
|
|
9
|
+
status: number
|
|
10
|
+
ok: boolean
|
|
11
|
+
headers: Record<string, string>
|
|
12
|
+
body: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare function networkFetch(
|
|
16
|
+
request: PlatformNetworkFetchRequest,
|
|
17
|
+
): Promise<PlatformNetworkFetchResponse>
|
package/src/bridge/network.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { bridge } from './client.mjs'
|
|
2
|
-
import { PLATFORM_BRIDGE_METHODS } from './methods.mjs'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Fetch an HTTP(S) resource through the shell network bridge.
|
|
6
|
-
*
|
|
7
|
-
* @param {{
|
|
8
|
-
* url: string,
|
|
9
|
-
* method?: string,
|
|
10
|
-
* headers?: Record<string, string>,
|
|
11
|
-
* body?: string,
|
|
12
|
-
* }} request
|
|
13
|
-
* @returns {Promise<{
|
|
14
|
-
* status: number,
|
|
15
|
-
* ok: boolean,
|
|
16
|
-
* headers: Record<string, string>,
|
|
17
|
-
* body: string,
|
|
18
|
-
* }>}
|
|
19
|
-
*/
|
|
20
|
-
export async function networkFetch(request) {
|
|
21
|
-
return bridge.call(PLATFORM_BRIDGE_METHODS.NETWORK_FETCH, [request])
|
|
22
|
-
}
|
|
1
|
+
import { bridge } from './client.mjs'
|
|
2
|
+
import { PLATFORM_BRIDGE_METHODS } from './methods.mjs'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Fetch an HTTP(S) resource through the shell network bridge.
|
|
6
|
+
*
|
|
7
|
+
* @param {{
|
|
8
|
+
* url: string,
|
|
9
|
+
* method?: string,
|
|
10
|
+
* headers?: Record<string, string>,
|
|
11
|
+
* body?: string,
|
|
12
|
+
* }} request
|
|
13
|
+
* @returns {Promise<{
|
|
14
|
+
* status: number,
|
|
15
|
+
* ok: boolean,
|
|
16
|
+
* headers: Record<string, string>,
|
|
17
|
+
* body: string,
|
|
18
|
+
* }>}
|
|
19
|
+
*/
|
|
20
|
+
export async function networkFetch(request) {
|
|
21
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.NETWORK_FETCH, [request])
|
|
22
|
+
}
|