@benz-ai-x/dsh-md-preview 0.2.7 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/lib/client.js +117 -23
- package/lib/index.js +91 -12
- package/lib/typert/remote-client.js +119 -70
- package/lib/types/client/PreviewOverlay.d.ts +11 -8
- package/lib/types/client/WorkspaceBrowser.d.ts +23 -0
- package/lib/types/client/locale.d.ts +7 -0
- package/lib/types/client/preview-session.d.ts +96 -0
- package/lib/types/client/preview-state.d.ts +2 -0
- package/lib/types/client/use-preview-session.d.ts +36 -0
- package/lib/types/config.d.ts +4 -1
- package/lib/types/constants.d.ts +2 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/protocol.d.ts +16 -0
- package/lib/types/remote.d.ts +23 -1
- package/lib/types/typert/remote-client.d.ts +3 -1
- package/package.json +1 -1
package/lib/types/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { Context } from '@deepseek-ai/cordis';
|
|
|
7
7
|
import { type Config as ConfigType } from './config.ts';
|
|
8
8
|
export { Config } from './config.ts';
|
|
9
9
|
export type { Config as ConfigInterface } from './config.ts';
|
|
10
|
-
export { DEFAULT_ALLOWED_EXTENSIONS, DEFAULT_MAX_BYTES } from './constants.ts';
|
|
10
|
+
export { DEFAULT_ALLOWED_EXTENSIONS, DEFAULT_MAX_BYTES, DEFAULT_PREVIEW_EXTENSIONS } from './constants.ts';
|
|
11
11
|
export { isAllowedExtension, MdPreviewService } from './remote.ts';
|
|
12
12
|
export type { MdPreviewFile, MdPreviewFailureCode, MdPreviewReadRequest } from './protocol.ts';
|
|
13
13
|
export { MD_PREVIEW_FAILURE_CODES } from './protocol.ts';
|
package/lib/types/protocol.d.ts
CHANGED
|
@@ -16,6 +16,22 @@ export interface MdPreviewWriteResult {
|
|
|
16
16
|
/** Freshness token of the file after the write; guards the next save. */
|
|
17
17
|
readonly fingerprint: string;
|
|
18
18
|
}
|
|
19
|
+
/** One directory entry of the workspace browser tree. */
|
|
20
|
+
export interface MdPreviewEntry {
|
|
21
|
+
/** Entry basename as the fs layer reports it. */
|
|
22
|
+
readonly name: string;
|
|
23
|
+
/** Regular file, directory, or anything else. */
|
|
24
|
+
readonly type: 'file' | 'directory' | 'other';
|
|
25
|
+
/** Workspace-relative path of the entry (the tree's node identity). */
|
|
26
|
+
readonly path: string;
|
|
27
|
+
}
|
|
28
|
+
/** One workspace directory listing. */
|
|
29
|
+
export interface MdPreviewListResult {
|
|
30
|
+
/** The requested path as the caller spelled it (blank = workspace root). */
|
|
31
|
+
readonly path: string;
|
|
32
|
+
/** Directory entries, folders first then alphabetical. */
|
|
33
|
+
readonly entries: readonly MdPreviewEntry[];
|
|
34
|
+
}
|
|
19
35
|
/** Stable failure codes carried by `RemoteError` across the wire. */
|
|
20
36
|
export declare const MD_PREVIEW_FAILURE_CODES: readonly ["md-preview/bad-request", "md-preview/unknown-session", "md-preview/no-workspace", "md-preview/unsupported-extension", "md-preview/forbidden", "md-preview/not-found", "md-preview/too-large", "md-preview/conflict", "md-preview/unavailable"];
|
|
21
37
|
/** One stable MdPreview failure code. */
|
package/lib/types/remote.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { Context } from '@deepseek-ai/cordis';
|
|
|
8
8
|
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
9
9
|
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
10
10
|
import type { Config } from './config.ts';
|
|
11
|
-
import type { MdPreviewFile, MdPreviewWriteResult } from './protocol.ts';
|
|
11
|
+
import type { MdPreviewFile, MdPreviewListResult, MdPreviewWriteResult } from './protocol.ts';
|
|
12
12
|
/** Whether a candidate extension passes the configured allowlist. */
|
|
13
13
|
export declare function isAllowedExtension(path: string, allowedExtensions: readonly string[]): boolean;
|
|
14
14
|
/**
|
|
@@ -50,6 +50,16 @@ export declare class MdPreviewService extends TypertRemoteService {
|
|
|
50
50
|
* @throws RemoteError with a stable MdPreview failure code.
|
|
51
51
|
*/
|
|
52
52
|
write(sessionId: SessionId, path: string, content: string, fingerprint: string | undefined, force: boolean, signal: AbortSignal): Promise<MdPreviewWriteResult>;
|
|
53
|
+
/**
|
|
54
|
+
* List one workspace directory for the browser face; folders sort first,
|
|
55
|
+
* then entries alphabetize by name. A blank path lists the workspace root.
|
|
56
|
+
* @param sessionId - owning session; its header cwd roots the listing.
|
|
57
|
+
* @param path - directory path as the tree spelled it; blank = root.
|
|
58
|
+
* @param signal - caller cancellation carried through every fs call.
|
|
59
|
+
* @returns the requested path with its workspace-relative entries.
|
|
60
|
+
* @throws RemoteError with a stable MdPreview failure code.
|
|
61
|
+
*/
|
|
62
|
+
list(sessionId: SessionId, path: string, signal: AbortSignal): Promise<MdPreviewListResult>;
|
|
53
63
|
/**
|
|
54
64
|
* The shared authority preamble of the remote methods: resolve a path to a
|
|
55
65
|
* live, contained, regular workspace file, or reject it with the stable
|
|
@@ -63,5 +73,17 @@ export declare class MdPreviewService extends TypertRemoteService {
|
|
|
63
73
|
* @throws RemoteError with a stable MdPreview failure code.
|
|
64
74
|
*/
|
|
65
75
|
private resolveWorkspaceTarget;
|
|
76
|
+
/**
|
|
77
|
+
* The authority middle shared by every method: session → workspace cwd →
|
|
78
|
+
* root resolve → target resolve (a blank path means the root itself) →
|
|
79
|
+
* containment. Extension and type checks belong to the callers.
|
|
80
|
+
* @param sessionId - owning session; its header cwd roots the resolution.
|
|
81
|
+
* @param path - requested path; blank spells the workspace root.
|
|
82
|
+
* @param signal - caller cancellation carried through every fs call.
|
|
83
|
+
* @param op - calling method name for diagnostic messages.
|
|
84
|
+
* @returns the resolved root, target, and the workspace cwd.
|
|
85
|
+
* @throws RemoteError with a stable MdPreview failure code.
|
|
86
|
+
*/
|
|
87
|
+
private resolveContainedTarget;
|
|
66
88
|
}
|
|
67
89
|
//# sourceMappingURL=remote.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RemoteResult, TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol';
|
|
2
2
|
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
3
|
-
import type { MdPreviewFile, MdPreviewWriteResult } from '../protocol.ts';
|
|
3
|
+
import type { MdPreviewFile, MdPreviewListResult, MdPreviewWriteResult } from '../protocol.ts';
|
|
4
4
|
/** Browser face of the mounted `mdPreview` Remote namespace. */
|
|
5
5
|
export interface MdPreviewRemote {
|
|
6
6
|
/** Read one previewable document of a session's workspace. */
|
|
@@ -11,6 +11,8 @@ export interface MdPreviewRemote {
|
|
|
11
11
|
* overwrite unconditionally (the conflict prompt's override).
|
|
12
12
|
*/
|
|
13
13
|
write(sessionId: SessionId, path: string, content: string, fingerprint?: string, force?: boolean, signal?: AbortSignal): Promise<RemoteResult<MdPreviewWriteResult>>;
|
|
14
|
+
/** List one workspace directory for the browser face (blank path = root). */
|
|
15
|
+
list(sessionId: SessionId, path: string, signal?: AbortSignal): Promise<RemoteResult<MdPreviewListResult>>;
|
|
14
16
|
}
|
|
15
17
|
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
16
18
|
interface TypertRemoteNamespaceMap {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@benz-ai-x/dsh-md-preview",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "DSH markdown preview: clicking a markdown document in the conversation opens a rendered preview panel docked to the right of the chat.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|