@bendyline/docblocks 1.0.0 → 1.1.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/dist/chunk-AOBPNSU6.js +23 -0
- package/dist/chunk-AOBPNSU6.js.map +1 -0
- package/dist/{chunk-NSVTXALR.js → chunk-OGJN2J4P.js} +218 -2
- package/dist/chunk-OGJN2J4P.js.map +1 -0
- package/dist/filesystem/electron-provider.d.ts +32 -0
- package/dist/filesystem/electron-provider.d.ts.map +1 -0
- package/dist/filesystem/electron-provider.js +64 -0
- package/dist/filesystem/electron-provider.js.map +1 -0
- package/dist/filesystem/file-media-provider.d.ts +23 -0
- package/dist/filesystem/file-media-provider.d.ts.map +1 -0
- package/dist/filesystem/file-media-provider.js +85 -0
- package/dist/filesystem/file-media-provider.js.map +1 -0
- package/dist/filesystem/filesystem-content-container.d.ts +24 -0
- package/dist/filesystem/filesystem-content-container.d.ts.map +1 -0
- package/dist/filesystem/filesystem-content-container.js +103 -0
- package/dist/filesystem/filesystem-content-container.js.map +1 -0
- package/dist/filesystem/index.d.ts +3 -0
- package/dist/filesystem/index.d.ts.map +1 -1
- package/dist/filesystem/index.js +3 -0
- package/dist/filesystem/index.js.map +1 -1
- package/dist/host/index.d.ts +14 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +28 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/types.d.ts +149 -0
- package/dist/host/types.d.ts.map +1 -0
- package/dist/host/types.js +10 -0
- package/dist/host/types.js.map +1 -0
- package/dist/index-TtDaQ3vS.d.ts +213 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/workspace/types.d.ts +9 -2
- package/dist/workspace/types.d.ts.map +1 -1
- package/package.json +12 -7
- package/src/filesystem/electron-provider.ts +88 -0
- package/src/filesystem/file-media-provider.ts +103 -0
- package/src/filesystem/filesystem-content-container.ts +115 -0
- package/src/filesystem/index.ts +4 -0
- package/src/host/index.ts +47 -0
- package/src/host/types.ts +153 -0
- package/src/index.ts +2 -1
- package/src/workspace/types.ts +9 -2
- package/dist/chunk-NSVTXALR.js.map +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FileSystemContentContainer — a ContentContainer backed by any
|
|
3
|
+
* FileSystemProvider, scoped to a sub-path (e.g., ".docblocks/media/").
|
|
4
|
+
*
|
|
5
|
+
* Used by the Electron desktop app so media lives inside the workspace
|
|
6
|
+
* folder (visible as regular files) rather than in a separate IndexedDB
|
|
7
|
+
* origin that only the app can see.
|
|
8
|
+
*/
|
|
9
|
+
import type { ContentContainer, ContentEntry } from '@bendyline/squisq/storage';
|
|
10
|
+
import type { FileSystemProvider } from './types.js';
|
|
11
|
+
export declare class FileSystemContentContainer implements ContentContainer {
|
|
12
|
+
private readonly provider;
|
|
13
|
+
private readonly prefix;
|
|
14
|
+
constructor(provider: FileSystemProvider, prefix?: string);
|
|
15
|
+
readFile(path: string): Promise<ArrayBuffer | null>;
|
|
16
|
+
writeFile(path: string, data: ArrayBuffer | Uint8Array, _mimeType?: string): Promise<void>;
|
|
17
|
+
removeFile(path: string): Promise<void>;
|
|
18
|
+
listFiles(prefix?: string): Promise<ContentEntry[]>;
|
|
19
|
+
exists(path: string): Promise<boolean>;
|
|
20
|
+
getDocumentPath(): Promise<string | null>;
|
|
21
|
+
readDocument(): Promise<string | null>;
|
|
22
|
+
writeDocument(markdown: string, filename?: string): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=filesystem-content-container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem-content-container.d.ts","sourceRoot":"","sources":["../../src/filesystem/filesystem-content-container.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEhF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAgCrD,qBAAa,0BAA2B,YAAW,gBAAgB;IAI/D,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAH3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAGb,QAAQ,EAAE,kBAAkB,EAC7C,MAAM,SAAqB;IAKvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAInD,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,UAAU,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1F,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IA4BnD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAItC,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIzC,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAQtC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAKxE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FileSystemContentContainer — a ContentContainer backed by any
|
|
3
|
+
* FileSystemProvider, scoped to a sub-path (e.g., ".docblocks/media/").
|
|
4
|
+
*
|
|
5
|
+
* Used by the Electron desktop app so media lives inside the workspace
|
|
6
|
+
* folder (visible as regular files) rather than in a separate IndexedDB
|
|
7
|
+
* origin that only the app can see.
|
|
8
|
+
*/
|
|
9
|
+
import { findDocumentPath } from '@bendyline/squisq/storage';
|
|
10
|
+
const EXTENSION_MIME_MAP = {
|
|
11
|
+
'.md': 'text/markdown',
|
|
12
|
+
'.txt': 'text/plain',
|
|
13
|
+
'.json': 'application/json',
|
|
14
|
+
'.jpg': 'image/jpeg',
|
|
15
|
+
'.jpeg': 'image/jpeg',
|
|
16
|
+
'.png': 'image/png',
|
|
17
|
+
'.gif': 'image/gif',
|
|
18
|
+
'.svg': 'image/svg+xml',
|
|
19
|
+
'.webp': 'image/webp',
|
|
20
|
+
'.avif': 'image/avif',
|
|
21
|
+
'.mp4': 'video/mp4',
|
|
22
|
+
'.webm': 'video/webm',
|
|
23
|
+
'.mp3': 'audio/mpeg',
|
|
24
|
+
'.wav': 'audio/wav',
|
|
25
|
+
'.ogg': 'audio/ogg',
|
|
26
|
+
};
|
|
27
|
+
function guessMimeType(path) {
|
|
28
|
+
const dot = path.lastIndexOf('.');
|
|
29
|
+
if (dot === -1)
|
|
30
|
+
return 'application/octet-stream';
|
|
31
|
+
const ext = path.slice(dot).toLowerCase();
|
|
32
|
+
return EXTENSION_MIME_MAP[ext] ?? 'application/octet-stream';
|
|
33
|
+
}
|
|
34
|
+
function joinPrefix(prefix, p) {
|
|
35
|
+
const clean = p.replace(/^\/+/, '');
|
|
36
|
+
return prefix.replace(/\/+$/, '') + '/' + clean;
|
|
37
|
+
}
|
|
38
|
+
export class FileSystemContentContainer {
|
|
39
|
+
constructor(provider, prefix = '.docblocks/media') {
|
|
40
|
+
this.provider = provider;
|
|
41
|
+
this.prefix = prefix.replace(/^\/+/, '').replace(/\/+$/, '');
|
|
42
|
+
}
|
|
43
|
+
async readFile(path) {
|
|
44
|
+
return this.provider.readBinary(joinPrefix(this.prefix, path));
|
|
45
|
+
}
|
|
46
|
+
async writeFile(path, data, _mimeType) {
|
|
47
|
+
await this.provider.writeBinary(joinPrefix(this.prefix, path), data);
|
|
48
|
+
}
|
|
49
|
+
async removeFile(path) {
|
|
50
|
+
await this.provider.delete(joinPrefix(this.prefix, path));
|
|
51
|
+
}
|
|
52
|
+
async listFiles(prefix) {
|
|
53
|
+
const entries = [];
|
|
54
|
+
const walk = async (dir) => {
|
|
55
|
+
let children;
|
|
56
|
+
try {
|
|
57
|
+
children = await this.provider.readDirectory(dir);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
for (const child of children) {
|
|
63
|
+
if (child.kind === 'directory') {
|
|
64
|
+
await walk(child.path);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const rel = child.path.replace(new RegExp('^/?' + this.prefix + '/?'), '');
|
|
68
|
+
if (prefix && !rel.startsWith(prefix))
|
|
69
|
+
continue;
|
|
70
|
+
const meta = await this.provider.stat(child.path);
|
|
71
|
+
entries.push({
|
|
72
|
+
path: rel,
|
|
73
|
+
mimeType: guessMimeType(rel),
|
|
74
|
+
size: meta?.size ?? 0,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
await walk('/' + this.prefix);
|
|
80
|
+
return entries;
|
|
81
|
+
}
|
|
82
|
+
async exists(path) {
|
|
83
|
+
return this.provider.exists(joinPrefix(this.prefix, path));
|
|
84
|
+
}
|
|
85
|
+
async getDocumentPath() {
|
|
86
|
+
return findDocumentPath(await this.listFiles());
|
|
87
|
+
}
|
|
88
|
+
async readDocument() {
|
|
89
|
+
const docPath = await this.getDocumentPath();
|
|
90
|
+
if (!docPath)
|
|
91
|
+
return null;
|
|
92
|
+
const data = await this.readFile(docPath);
|
|
93
|
+
if (!data)
|
|
94
|
+
return null;
|
|
95
|
+
return new TextDecoder().decode(data);
|
|
96
|
+
}
|
|
97
|
+
async writeDocument(markdown, filename) {
|
|
98
|
+
const name = filename ?? 'index.md';
|
|
99
|
+
const data = new TextEncoder().encode(markdown);
|
|
100
|
+
await this.writeFile(name, data, 'text/markdown');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=filesystem-content-container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fil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AI,WAAW,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export type { FileSystemProvider, FileSystemEntry, FileEntry, FolderEntry, FileMeta, } from './types.js';
|
|
2
2
|
export { IndexedDBFileSystemProvider } from './indexeddb-provider.js';
|
|
3
3
|
export { IndexedDBContentContainer } from './indexeddb-content-container.js';
|
|
4
|
+
export { FileSystemContentContainer } from './filesystem-content-container.js';
|
|
5
|
+
export { createFileMediaProvider } from './file-media-provider.js';
|
|
4
6
|
export { NativeFileSystemProvider, isNativeFileSystemSupported, openNativeFolder, restoreNativeFolder, storeDirectoryHandle, loadDirectoryHandle, removeDirectoryHandle, } from './native-provider.js';
|
|
7
|
+
export { ElectronFileSystemProvider, isElectronHost } from './electron-provider.js';
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filesystem/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,SAAS,EACT,WAAW,EACX,QAAQ,GACT,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filesystem/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,SAAS,EACT,WAAW,EACX,QAAQ,GACT,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/filesystem/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { IndexedDBFileSystemProvider } from './indexeddb-provider.js';
|
|
2
2
|
export { IndexedDBContentContainer } from './indexeddb-content-container.js';
|
|
3
|
+
export { FileSystemContentContainer } from './filesystem-content-container.js';
|
|
4
|
+
export { createFileMediaProvider } from './file-media-provider.js';
|
|
3
5
|
export { NativeFileSystemProvider, isNativeFileSystemSupported, openNativeFolder, restoreNativeFolder, storeDirectoryHandle, loadDirectoryHandle, removeDirectoryHandle, } from './native-provider.js';
|
|
6
|
+
export { ElectronFileSystemProvider, isElectronHost } from './electron-provider.js';
|
|
4
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/filesystem/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/filesystem/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host bridge — shared types + runtime access for the Electron desktop
|
|
3
|
+
* host. The renderer calls `getDocblocksHost()` to reach the preload
|
|
4
|
+
* contextBridge; `isElectronHost()` gates desktop-only UI branches.
|
|
5
|
+
*/
|
|
6
|
+
export type { DocblocksHostAPI, DocblocksHostFsAPI, DocblocksHostWorkspacesAPI, DocblocksHostShellAPI, DocblocksHostFfmpegAPI, DocblocksHostUpdaterAPI, ElectronWorkspaceInfo, HostEnvironment, MenuCommand, OpenRequest, UpdaterStatus, } from './types.js';
|
|
7
|
+
import type { DocblocksHostAPI } from './types.js';
|
|
8
|
+
/** True when running inside the Electron desktop shell. */
|
|
9
|
+
export declare function isElectronHost(): boolean;
|
|
10
|
+
/** Return the host API, or throw if not running under Electron. */
|
|
11
|
+
export declare function getDocblocksHost(): DocblocksHostAPI;
|
|
12
|
+
/** Return the host API, or null if not running under Electron. */
|
|
13
|
+
export declare function maybeGetDocblocksHost(): DocblocksHostAPI | null;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,EACf,WAAW,EACX,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,2DAA2D;AAC3D,wBAAgB,cAAc,IAAI,OAAO,CASxC;AAED,mEAAmE;AACnE,wBAAgB,gBAAgB,IAAI,gBAAgB,CAMnD;AAED,kEAAkE;AAClE,wBAAgB,qBAAqB,IAAI,gBAAgB,GAAG,IAAI,CAE/D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host bridge — shared types + runtime access for the Electron desktop
|
|
3
|
+
* host. The renderer calls `getDocblocksHost()` to reach the preload
|
|
4
|
+
* contextBridge; `isElectronHost()` gates desktop-only UI branches.
|
|
5
|
+
*/
|
|
6
|
+
/** True when running inside the Electron desktop shell. */
|
|
7
|
+
export function isElectronHost() {
|
|
8
|
+
if (typeof globalThis === 'undefined')
|
|
9
|
+
return false;
|
|
10
|
+
const host = globalThis.docblocksHost;
|
|
11
|
+
return (typeof host === 'object' &&
|
|
12
|
+
host !== null &&
|
|
13
|
+
typeof host.fs === 'object' &&
|
|
14
|
+
host.fs !== null);
|
|
15
|
+
}
|
|
16
|
+
/** Return the host API, or throw if not running under Electron. */
|
|
17
|
+
export function getDocblocksHost() {
|
|
18
|
+
const host = globalThis.docblocksHost;
|
|
19
|
+
if (!host) {
|
|
20
|
+
throw new Error('docblocksHost is not available — not running under Electron?');
|
|
21
|
+
}
|
|
22
|
+
return host;
|
|
23
|
+
}
|
|
24
|
+
/** Return the host API, or null if not running under Electron. */
|
|
25
|
+
export function maybeGetDocblocksHost() {
|
|
26
|
+
return globalThis.docblocksHost ?? null;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkBH,2DAA2D;AAC3D,MAAM,UAAU,cAAc;IAC5B,IAAI,OAAO,UAAU,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IACpD,MAAM,IAAI,GAAI,UAA0C,CAAC,aAAa,CAAC;IACvE,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,OAAQ,IAAyB,CAAC,EAAE,KAAK,QAAQ;QAChD,IAAyB,CAAC,EAAE,KAAK,IAAI,CACvC,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,gBAAgB;IAC9B,MAAM,IAAI,GAAI,UAAmD,CAAC,aAAa,CAAC;IAChF,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;IAClF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,qBAAqB;IACnC,OAAQ,UAAmD,CAAC,aAAa,IAAI,IAAI,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DocblocksHostAPI — the contract exposed by the Electron desktop shell
|
|
3
|
+
* to its renderer process via contextBridge.
|
|
4
|
+
*
|
|
5
|
+
* This file is the single source of truth for the host ↔ renderer
|
|
6
|
+
* bridge. The Electron preload script exposes an implementation matching
|
|
7
|
+
* this shape; the React renderer calls it through `window.docblocksHost`.
|
|
8
|
+
*/
|
|
9
|
+
import type { FileSystemEntry, FileMeta } from '../filesystem/types.js';
|
|
10
|
+
/** Filesystem operations scoped to a registered absolute root path. */
|
|
11
|
+
export interface DocblocksHostFsAPI {
|
|
12
|
+
readFile(rootPath: string, path: string): Promise<string | null>;
|
|
13
|
+
writeFile(rootPath: string, path: string, content: string): Promise<void>;
|
|
14
|
+
delete(rootPath: string, path: string): Promise<void>;
|
|
15
|
+
rename(rootPath: string, oldPath: string, newPath: string): Promise<void>;
|
|
16
|
+
readDirectory(rootPath: string, path: string): Promise<FileSystemEntry[]>;
|
|
17
|
+
exists(rootPath: string, path: string): Promise<boolean>;
|
|
18
|
+
createDirectory(rootPath: string, path: string): Promise<void>;
|
|
19
|
+
stat(rootPath: string, path: string): Promise<FileMeta | null>;
|
|
20
|
+
readBinary(rootPath: string, path: string): Promise<ArrayBuffer | null>;
|
|
21
|
+
writeBinary(rootPath: string, path: string, data: ArrayBuffer | Uint8Array): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Subscribe to change notifications for a watched root. Returns an
|
|
24
|
+
* unsubscribe function. The main process uses chokidar under the hood.
|
|
25
|
+
*/
|
|
26
|
+
watch(rootPath: string, onChange: (path: string) => void): () => void;
|
|
27
|
+
}
|
|
28
|
+
/** Descriptor returned for an Electron-managed workspace (backed by a folder). */
|
|
29
|
+
export interface ElectronWorkspaceInfo {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
rootPath: string;
|
|
33
|
+
}
|
|
34
|
+
/** Workspace-management operations exposed to the renderer. */
|
|
35
|
+
export interface DocblocksHostWorkspacesAPI {
|
|
36
|
+
/**
|
|
37
|
+
* Return the default workspace (creating ~/Documents/DocBlocks on first
|
|
38
|
+
* call, or the user's configured default).
|
|
39
|
+
*/
|
|
40
|
+
getDefault(): Promise<ElectronWorkspaceInfo>;
|
|
41
|
+
/**
|
|
42
|
+
* Open the native folder picker. Returns null if the user cancels.
|
|
43
|
+
* The selected folder is registered in the main process whitelist.
|
|
44
|
+
*/
|
|
45
|
+
pickFolder(): Promise<ElectronWorkspaceInfo | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Re-register a previously known workspace so its rootPath is trusted
|
|
48
|
+
* for subsequent fs calls. Called on app startup for persisted
|
|
49
|
+
* electron-native workspaces before any fs operation.
|
|
50
|
+
*/
|
|
51
|
+
register(info: ElectronWorkspaceInfo): Promise<void>;
|
|
52
|
+
/** Remove a workspace from the trusted whitelist. */
|
|
53
|
+
unregister(id: string): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
/** Shell operations — reveal in Finder/Explorer, open external URLs. */
|
|
56
|
+
export interface DocblocksHostShellAPI {
|
|
57
|
+
/** Reveal a file (by absolute path) in the OS file manager. */
|
|
58
|
+
revealInFolder(absolutePath: string): Promise<void>;
|
|
59
|
+
/** Open a URL in the default browser. */
|
|
60
|
+
openExternal(url: string): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
/** System ffmpeg detection and invocation. */
|
|
63
|
+
export interface DocblocksHostFfmpegAPI {
|
|
64
|
+
/** True if `ffmpeg` is available on PATH (or bundled). */
|
|
65
|
+
available(): Promise<boolean>;
|
|
66
|
+
/** Version string from `ffmpeg -version`, or null if unavailable. */
|
|
67
|
+
version(): Promise<string | null>;
|
|
68
|
+
/**
|
|
69
|
+
* Render a markdown file at the given absolute path to MP4 using the
|
|
70
|
+
* existing squisq-video CLI pipeline. Returns the absolute path to the
|
|
71
|
+
* produced MP4 file, or throws on failure.
|
|
72
|
+
*/
|
|
73
|
+
renderVideo(markdownAbsolutePath: string, options: {
|
|
74
|
+
fps?: number;
|
|
75
|
+
quality?: 'draft' | 'normal' | 'high';
|
|
76
|
+
}): Promise<string>;
|
|
77
|
+
}
|
|
78
|
+
/** Auto-updater control. */
|
|
79
|
+
export interface DocblocksHostUpdaterAPI {
|
|
80
|
+
/** Kick off a check; resolves to true if an update is available. */
|
|
81
|
+
checkForUpdates(): Promise<boolean>;
|
|
82
|
+
/** Current app version string. */
|
|
83
|
+
getVersion(): Promise<string>;
|
|
84
|
+
/**
|
|
85
|
+
* Quit the app and apply a downloaded update. Should only be called
|
|
86
|
+
* after an `UpdaterStatus` of kind `'downloaded'` has been observed.
|
|
87
|
+
*/
|
|
88
|
+
quitAndInstall(): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Subscribe to updater status events. Returns an unsubscribe function.
|
|
91
|
+
*/
|
|
92
|
+
onStatus(listener: (status: UpdaterStatus) => void): () => void;
|
|
93
|
+
}
|
|
94
|
+
export type UpdaterStatus = {
|
|
95
|
+
kind: 'checking';
|
|
96
|
+
} | {
|
|
97
|
+
kind: 'available';
|
|
98
|
+
version: string;
|
|
99
|
+
releaseNotes?: string;
|
|
100
|
+
releaseUrl?: string;
|
|
101
|
+
} | {
|
|
102
|
+
kind: 'not-available';
|
|
103
|
+
} | {
|
|
104
|
+
kind: 'downloading';
|
|
105
|
+
percent: number;
|
|
106
|
+
} | {
|
|
107
|
+
kind: 'downloaded';
|
|
108
|
+
version: string;
|
|
109
|
+
releaseNotes?: string;
|
|
110
|
+
releaseUrl?: string;
|
|
111
|
+
} | {
|
|
112
|
+
kind: 'error';
|
|
113
|
+
message: string;
|
|
114
|
+
};
|
|
115
|
+
/** Menu-command events pushed from the main process to the renderer. */
|
|
116
|
+
export type MenuCommand = 'file:new' | 'file:openFolder' | 'file:revealWorkspace' | 'file:settings' | 'help:about' | 'help:checkForUpdates' | 'help:viewOnGitHub';
|
|
117
|
+
/** Deep-link event: the user opened a docblocks:// URL or dropped a file. */
|
|
118
|
+
export interface OpenRequest {
|
|
119
|
+
/** For docblocks:// URLs — the full URL string. */
|
|
120
|
+
url?: string;
|
|
121
|
+
/** For file drops / open-with — absolute path to the file. */
|
|
122
|
+
filePath?: string;
|
|
123
|
+
}
|
|
124
|
+
/** Environment metadata provided by the host. */
|
|
125
|
+
export interface HostEnvironment {
|
|
126
|
+
platform: 'darwin' | 'win32' | 'linux';
|
|
127
|
+
appVersion: string;
|
|
128
|
+
isDev: boolean;
|
|
129
|
+
}
|
|
130
|
+
/** The full DocBlocks desktop host API. */
|
|
131
|
+
export interface DocblocksHostAPI {
|
|
132
|
+
env: HostEnvironment;
|
|
133
|
+
fs: DocblocksHostFsAPI;
|
|
134
|
+
workspaces: DocblocksHostWorkspacesAPI;
|
|
135
|
+
shell: DocblocksHostShellAPI;
|
|
136
|
+
ffmpeg: DocblocksHostFfmpegAPI;
|
|
137
|
+
updater: DocblocksHostUpdaterAPI;
|
|
138
|
+
/**
|
|
139
|
+
* Subscribe to menu commands dispatched by the native menu.
|
|
140
|
+
* Returns an unsubscribe function.
|
|
141
|
+
*/
|
|
142
|
+
onMenuCommand(listener: (cmd: MenuCommand) => void): () => void;
|
|
143
|
+
/**
|
|
144
|
+
* Subscribe to open-file / open-url requests from the OS.
|
|
145
|
+
* Returns an unsubscribe function.
|
|
146
|
+
*/
|
|
147
|
+
onOpenRequest(listener: (request: OpenRequest) => void): () => void;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/host/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAExE,uEAAuE;AACvE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACjE,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1E,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1E,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAC1E,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzD,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IA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E;AACxE,MAAM,MAAM,WAAW,GACnB,UAAU,GACV,iBAAiB,GACjB,sBAAsB,GACtB,eAAe,GACf,YAAY,GACZ,sBAAsB,GACtB,mBAAmB,CAAC;AAExB,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,mDAAmD;IACnD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,iDAAiD;AACjD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,2CAA2C;AAC3C,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,eAAe,CAAC;IACrB,EAAE,EAAE,kBAAkB,CAAC;IACvB,UAAU,EAAE,0BAA0B,CAAC;IACvC,KAAK,EAAE,qBAAqB,CAAC;IAC7B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,OAAO,EAAE,uBAAuB,CAAC;IACjC;;;OAGG;IACH,aAAa,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAChE;;;OAGG;IACH,aAAa,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACrE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DocblocksHostAPI — the contract exposed by the Electron desktop shell
|
|
3
|
+
* to its renderer process via contextBridge.
|
|
4
|
+
*
|
|
5
|
+
* This file is the single source of truth for the host ↔ renderer
|
|
6
|
+
* bridge. The Electron preload script exposes an implementation matching
|
|
7
|
+
* this shape; the React renderer calls it through `window.docblocksHost`.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/host/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FileSystemProvider — abstract interface for a virtual filesystem.
|
|
3
|
+
*
|
|
4
|
+
* Implementations back onto IndexedDB (for browser-local storage) or
|
|
5
|
+
* the File System Access API (for native folder access).
|
|
6
|
+
*/
|
|
7
|
+
interface FileEntry {
|
|
8
|
+
kind: 'file';
|
|
9
|
+
name: string;
|
|
10
|
+
path: string;
|
|
11
|
+
}
|
|
12
|
+
interface FolderEntry {
|
|
13
|
+
kind: 'directory';
|
|
14
|
+
name: string;
|
|
15
|
+
path: string;
|
|
16
|
+
}
|
|
17
|
+
type FileSystemEntry = FileEntry | FolderEntry;
|
|
18
|
+
interface FileMeta {
|
|
19
|
+
name: string;
|
|
20
|
+
path: string;
|
|
21
|
+
size: number;
|
|
22
|
+
lastModified: string;
|
|
23
|
+
}
|
|
24
|
+
interface FileSystemProvider {
|
|
25
|
+
/** Unique identifier for this provider instance. */
|
|
26
|
+
readonly id: string;
|
|
27
|
+
/** Human-readable label (e.g., folder name or "Browser Storage"). */
|
|
28
|
+
readonly label: string;
|
|
29
|
+
/** Read the text content of a file. Returns null if the file doesn't exist. */
|
|
30
|
+
readFile(path: string): Promise<string | null>;
|
|
31
|
+
/** Write text content to a file, creating it (and parent dirs) if needed. */
|
|
32
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
33
|
+
/** Delete a file or empty directory. */
|
|
34
|
+
delete(path: string): Promise<void>;
|
|
35
|
+
/** Rename or move an entry. */
|
|
36
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
37
|
+
/** List immediate children of a directory. */
|
|
38
|
+
readDirectory(path: string): Promise<FileSystemEntry[]>;
|
|
39
|
+
/** Check whether a path exists. */
|
|
40
|
+
exists(path: string): Promise<boolean>;
|
|
41
|
+
/** Create a directory (and parents if needed). */
|
|
42
|
+
createDirectory(path: string): Promise<void>;
|
|
43
|
+
/** Get metadata for a file. Returns null if not found. */
|
|
44
|
+
stat(path: string): Promise<FileMeta | null>;
|
|
45
|
+
/** Read raw binary content. Returns null if not found. */
|
|
46
|
+
readBinary(path: string): Promise<ArrayBuffer | null>;
|
|
47
|
+
/** Write raw binary content. */
|
|
48
|
+
writeBinary(path: string, data: ArrayBuffer | Uint8Array): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* DocblocksHostAPI — the contract exposed by the Electron desktop shell
|
|
53
|
+
* to its renderer process via contextBridge.
|
|
54
|
+
*
|
|
55
|
+
* This file is the single source of truth for the host ↔ renderer
|
|
56
|
+
* bridge. The Electron preload script exposes an implementation matching
|
|
57
|
+
* this shape; the React renderer calls it through `window.docblocksHost`.
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/** Filesystem operations scoped to a registered absolute root path. */
|
|
61
|
+
interface DocblocksHostFsAPI {
|
|
62
|
+
readFile(rootPath: string, path: string): Promise<string | null>;
|
|
63
|
+
writeFile(rootPath: string, path: string, content: string): Promise<void>;
|
|
64
|
+
delete(rootPath: string, path: string): Promise<void>;
|
|
65
|
+
rename(rootPath: string, oldPath: string, newPath: string): Promise<void>;
|
|
66
|
+
readDirectory(rootPath: string, path: string): Promise<FileSystemEntry[]>;
|
|
67
|
+
exists(rootPath: string, path: string): Promise<boolean>;
|
|
68
|
+
createDirectory(rootPath: string, path: string): Promise<void>;
|
|
69
|
+
stat(rootPath: string, path: string): Promise<FileMeta | null>;
|
|
70
|
+
readBinary(rootPath: string, path: string): Promise<ArrayBuffer | null>;
|
|
71
|
+
writeBinary(rootPath: string, path: string, data: ArrayBuffer | Uint8Array): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Subscribe to change notifications for a watched root. Returns an
|
|
74
|
+
* unsubscribe function. The main process uses chokidar under the hood.
|
|
75
|
+
*/
|
|
76
|
+
watch(rootPath: string, onChange: (path: string) => void): () => void;
|
|
77
|
+
}
|
|
78
|
+
/** Descriptor returned for an Electron-managed workspace (backed by a folder). */
|
|
79
|
+
interface ElectronWorkspaceInfo {
|
|
80
|
+
id: string;
|
|
81
|
+
name: string;
|
|
82
|
+
rootPath: string;
|
|
83
|
+
}
|
|
84
|
+
/** Workspace-management operations exposed to the renderer. */
|
|
85
|
+
interface DocblocksHostWorkspacesAPI {
|
|
86
|
+
/**
|
|
87
|
+
* Return the default workspace (creating ~/Documents/DocBlocks on first
|
|
88
|
+
* call, or the user's configured default).
|
|
89
|
+
*/
|
|
90
|
+
getDefault(): Promise<ElectronWorkspaceInfo>;
|
|
91
|
+
/**
|
|
92
|
+
* Open the native folder picker. Returns null if the user cancels.
|
|
93
|
+
* The selected folder is registered in the main process whitelist.
|
|
94
|
+
*/
|
|
95
|
+
pickFolder(): Promise<ElectronWorkspaceInfo | null>;
|
|
96
|
+
/**
|
|
97
|
+
* Re-register a previously known workspace so its rootPath is trusted
|
|
98
|
+
* for subsequent fs calls. Called on app startup for persisted
|
|
99
|
+
* electron-native workspaces before any fs operation.
|
|
100
|
+
*/
|
|
101
|
+
register(info: ElectronWorkspaceInfo): Promise<void>;
|
|
102
|
+
/** Remove a workspace from the trusted whitelist. */
|
|
103
|
+
unregister(id: string): Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
/** Shell operations — reveal in Finder/Explorer, open external URLs. */
|
|
106
|
+
interface DocblocksHostShellAPI {
|
|
107
|
+
/** Reveal a file (by absolute path) in the OS file manager. */
|
|
108
|
+
revealInFolder(absolutePath: string): Promise<void>;
|
|
109
|
+
/** Open a URL in the default browser. */
|
|
110
|
+
openExternal(url: string): Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
/** System ffmpeg detection and invocation. */
|
|
113
|
+
interface DocblocksHostFfmpegAPI {
|
|
114
|
+
/** True if `ffmpeg` is available on PATH (or bundled). */
|
|
115
|
+
available(): Promise<boolean>;
|
|
116
|
+
/** Version string from `ffmpeg -version`, or null if unavailable. */
|
|
117
|
+
version(): Promise<string | null>;
|
|
118
|
+
/**
|
|
119
|
+
* Render a markdown file at the given absolute path to MP4 using the
|
|
120
|
+
* existing squisq-video CLI pipeline. Returns the absolute path to the
|
|
121
|
+
* produced MP4 file, or throws on failure.
|
|
122
|
+
*/
|
|
123
|
+
renderVideo(markdownAbsolutePath: string, options: {
|
|
124
|
+
fps?: number;
|
|
125
|
+
quality?: 'draft' | 'normal' | 'high';
|
|
126
|
+
}): Promise<string>;
|
|
127
|
+
}
|
|
128
|
+
/** Auto-updater control. */
|
|
129
|
+
interface DocblocksHostUpdaterAPI {
|
|
130
|
+
/** Kick off a check; resolves to true if an update is available. */
|
|
131
|
+
checkForUpdates(): Promise<boolean>;
|
|
132
|
+
/** Current app version string. */
|
|
133
|
+
getVersion(): Promise<string>;
|
|
134
|
+
/**
|
|
135
|
+
* Quit the app and apply a downloaded update. Should only be called
|
|
136
|
+
* after an `UpdaterStatus` of kind `'downloaded'` has been observed.
|
|
137
|
+
*/
|
|
138
|
+
quitAndInstall(): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Subscribe to updater status events. Returns an unsubscribe function.
|
|
141
|
+
*/
|
|
142
|
+
onStatus(listener: (status: UpdaterStatus) => void): () => void;
|
|
143
|
+
}
|
|
144
|
+
type UpdaterStatus = {
|
|
145
|
+
kind: 'checking';
|
|
146
|
+
} | {
|
|
147
|
+
kind: 'available';
|
|
148
|
+
version: string;
|
|
149
|
+
releaseNotes?: string;
|
|
150
|
+
releaseUrl?: string;
|
|
151
|
+
} | {
|
|
152
|
+
kind: 'not-available';
|
|
153
|
+
} | {
|
|
154
|
+
kind: 'downloading';
|
|
155
|
+
percent: number;
|
|
156
|
+
} | {
|
|
157
|
+
kind: 'downloaded';
|
|
158
|
+
version: string;
|
|
159
|
+
releaseNotes?: string;
|
|
160
|
+
releaseUrl?: string;
|
|
161
|
+
} | {
|
|
162
|
+
kind: 'error';
|
|
163
|
+
message: string;
|
|
164
|
+
};
|
|
165
|
+
/** Menu-command events pushed from the main process to the renderer. */
|
|
166
|
+
type MenuCommand = 'file:new' | 'file:openFolder' | 'file:revealWorkspace' | 'file:settings' | 'help:about' | 'help:checkForUpdates' | 'help:viewOnGitHub';
|
|
167
|
+
/** Deep-link event: the user opened a docblocks:// URL or dropped a file. */
|
|
168
|
+
interface OpenRequest {
|
|
169
|
+
/** For docblocks:// URLs — the full URL string. */
|
|
170
|
+
url?: string;
|
|
171
|
+
/** For file drops / open-with — absolute path to the file. */
|
|
172
|
+
filePath?: string;
|
|
173
|
+
}
|
|
174
|
+
/** Environment metadata provided by the host. */
|
|
175
|
+
interface HostEnvironment {
|
|
176
|
+
platform: 'darwin' | 'win32' | 'linux';
|
|
177
|
+
appVersion: string;
|
|
178
|
+
isDev: boolean;
|
|
179
|
+
}
|
|
180
|
+
/** The full DocBlocks desktop host API. */
|
|
181
|
+
interface DocblocksHostAPI {
|
|
182
|
+
env: HostEnvironment;
|
|
183
|
+
fs: DocblocksHostFsAPI;
|
|
184
|
+
workspaces: DocblocksHostWorkspacesAPI;
|
|
185
|
+
shell: DocblocksHostShellAPI;
|
|
186
|
+
ffmpeg: DocblocksHostFfmpegAPI;
|
|
187
|
+
updater: DocblocksHostUpdaterAPI;
|
|
188
|
+
/**
|
|
189
|
+
* Subscribe to menu commands dispatched by the native menu.
|
|
190
|
+
* Returns an unsubscribe function.
|
|
191
|
+
*/
|
|
192
|
+
onMenuCommand(listener: (cmd: MenuCommand) => void): () => void;
|
|
193
|
+
/**
|
|
194
|
+
* Subscribe to open-file / open-url requests from the OS.
|
|
195
|
+
* Returns an unsubscribe function.
|
|
196
|
+
*/
|
|
197
|
+
onOpenRequest(listener: (request: OpenRequest) => void): () => void;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Host bridge — shared types + runtime access for the Electron desktop
|
|
202
|
+
* host. The renderer calls `getDocblocksHost()` to reach the preload
|
|
203
|
+
* contextBridge; `isElectronHost()` gates desktop-only UI branches.
|
|
204
|
+
*/
|
|
205
|
+
|
|
206
|
+
/** True when running inside the Electron desktop shell. */
|
|
207
|
+
declare function isElectronHost(): boolean;
|
|
208
|
+
/** Return the host API, or throw if not running under Electron. */
|
|
209
|
+
declare function getDocblocksHost(): DocblocksHostAPI;
|
|
210
|
+
/** Return the host API, or null if not running under Electron. */
|
|
211
|
+
declare function maybeGetDocblocksHost(): DocblocksHostAPI | null;
|
|
212
|
+
|
|
213
|
+
export { type DocblocksHostAPI as D, type ElectronWorkspaceInfo as E, type FileEntry as F, type HostEnvironment as H, type MenuCommand as M, type OpenRequest as O, type UpdaterStatus as U, type DocblocksHostFfmpegAPI as a, type DocblocksHostFsAPI as b, type DocblocksHostShellAPI as c, type DocblocksHostUpdaterAPI as d, type DocblocksHostWorkspacesAPI as e, type FileMeta as f, type FileSystemEntry as g, type FileSystemProvider as h, type FolderEntry as i, getDocblocksHost as j, isElectronHost as k, maybeGetDocblocksHost as m };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @bendyline/docblocks — Core package
|
|
3
3
|
*
|
|
4
|
-
* Re-exports filesystem and
|
|
4
|
+
* Re-exports filesystem, workspace, and host modules for convenience.
|
|
5
5
|
*/
|
|
6
6
|
export * from './filesystem/index.js';
|
|
7
7
|
export * from './workspace/index.js';
|
|
8
|
+
export * from './host/index.js';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @bendyline/docblocks — Core package
|
|
3
3
|
*
|
|
4
|
-
* Re-exports filesystem and
|
|
4
|
+
* Re-exports filesystem, workspace, and host modules for convenience.
|
|
5
5
|
*/
|
|
6
6
|
export * from './filesystem/index.js';
|
|
7
7
|
export * from './workspace/index.js';
|
|
8
|
+
export * from './host/index.js';
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
|