@bendyline/docblocks 0.1.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/LICENSE +21 -21
- 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
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Bendyline
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bendyline
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/host/index.ts
|
|
2
|
+
function isElectronHost() {
|
|
3
|
+
if (typeof globalThis === "undefined") return false;
|
|
4
|
+
const host = globalThis.docblocksHost;
|
|
5
|
+
return typeof host === "object" && host !== null && typeof host.fs === "object" && host.fs !== null;
|
|
6
|
+
}
|
|
7
|
+
function getDocblocksHost() {
|
|
8
|
+
const host = globalThis.docblocksHost;
|
|
9
|
+
if (!host) {
|
|
10
|
+
throw new Error("docblocksHost is not available \u2014 not running under Electron?");
|
|
11
|
+
}
|
|
12
|
+
return host;
|
|
13
|
+
}
|
|
14
|
+
function maybeGetDocblocksHost() {
|
|
15
|
+
return globalThis.docblocksHost ?? null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
isElectronHost,
|
|
20
|
+
getDocblocksHost,
|
|
21
|
+
maybeGetDocblocksHost
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=chunk-AOBPNSU6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/host/index.ts"],"sourcesContent":["/**\n * Host bridge — shared types + runtime access for the Electron desktop\n * host. The renderer calls `getDocblocksHost()` to reach the preload\n * contextBridge; `isElectronHost()` gates desktop-only UI branches.\n */\n\nexport type {\n DocblocksHostAPI,\n DocblocksHostFsAPI,\n DocblocksHostWorkspacesAPI,\n DocblocksHostShellAPI,\n DocblocksHostFfmpegAPI,\n DocblocksHostUpdaterAPI,\n ElectronWorkspaceInfo,\n HostEnvironment,\n MenuCommand,\n OpenRequest,\n UpdaterStatus,\n} from './types.js';\n\nimport type { DocblocksHostAPI } from './types.js';\n\n/** True when running inside the Electron desktop shell. */\nexport function isElectronHost(): boolean {\n if (typeof globalThis === 'undefined') return false;\n const host = (globalThis as { docblocksHost?: unknown }).docblocksHost;\n return (\n typeof host === 'object' &&\n host !== null &&\n typeof (host as { fs?: unknown }).fs === 'object' &&\n (host as { fs?: unknown }).fs !== null\n );\n}\n\n/** Return the host API, or throw if not running under Electron. */\nexport function getDocblocksHost(): DocblocksHostAPI {\n const host = (globalThis as { docblocksHost?: DocblocksHostAPI }).docblocksHost;\n if (!host) {\n throw new Error('docblocksHost is not available — not running under Electron?');\n }\n return host;\n}\n\n/** Return the host API, or null if not running under Electron. */\nexport function maybeGetDocblocksHost(): DocblocksHostAPI | null {\n return (globalThis as { docblocksHost?: DocblocksHostAPI }).docblocksHost ?? null;\n}\n"],"mappings":";AAuBO,SAAS,iBAA0B;AACxC,MAAI,OAAO,eAAe,YAAa,QAAO;AAC9C,QAAM,OAAQ,WAA2C;AACzD,SACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAQ,KAA0B,OAAO,YACxC,KAA0B,OAAO;AAEtC;AAGO,SAAS,mBAAqC;AACnD,QAAM,OAAQ,WAAoD;AAClE,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,MAAM,mEAA8D;AAAA,EAChF;AACA,SAAO;AACT;AAGO,SAAS,wBAAiD;AAC/D,SAAQ,WAAoD,iBAAiB;AAC/E;","names":[]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
maybeGetDocblocksHost
|
|
3
|
+
} from "./chunk-AOBPNSU6.js";
|
|
4
|
+
|
|
1
5
|
// src/filesystem/indexeddb-provider.ts
|
|
2
6
|
import { LocalForageAdapter } from "@bendyline/squisq/storage";
|
|
3
7
|
function normalisePath(p) {
|
|
@@ -296,6 +300,159 @@ var IndexedDBContentContainer = class {
|
|
|
296
300
|
}
|
|
297
301
|
};
|
|
298
302
|
|
|
303
|
+
// src/filesystem/filesystem-content-container.ts
|
|
304
|
+
import { findDocumentPath as findDocumentPath2 } from "@bendyline/squisq/storage";
|
|
305
|
+
var EXTENSION_MIME_MAP2 = {
|
|
306
|
+
".md": "text/markdown",
|
|
307
|
+
".txt": "text/plain",
|
|
308
|
+
".json": "application/json",
|
|
309
|
+
".jpg": "image/jpeg",
|
|
310
|
+
".jpeg": "image/jpeg",
|
|
311
|
+
".png": "image/png",
|
|
312
|
+
".gif": "image/gif",
|
|
313
|
+
".svg": "image/svg+xml",
|
|
314
|
+
".webp": "image/webp",
|
|
315
|
+
".avif": "image/avif",
|
|
316
|
+
".mp4": "video/mp4",
|
|
317
|
+
".webm": "video/webm",
|
|
318
|
+
".mp3": "audio/mpeg",
|
|
319
|
+
".wav": "audio/wav",
|
|
320
|
+
".ogg": "audio/ogg"
|
|
321
|
+
};
|
|
322
|
+
function guessMimeType2(path) {
|
|
323
|
+
const dot = path.lastIndexOf(".");
|
|
324
|
+
if (dot === -1) return "application/octet-stream";
|
|
325
|
+
const ext = path.slice(dot).toLowerCase();
|
|
326
|
+
return EXTENSION_MIME_MAP2[ext] ?? "application/octet-stream";
|
|
327
|
+
}
|
|
328
|
+
function joinPrefix(prefix, p) {
|
|
329
|
+
const clean = p.replace(/^\/+/, "");
|
|
330
|
+
return prefix.replace(/\/+$/, "") + "/" + clean;
|
|
331
|
+
}
|
|
332
|
+
var FileSystemContentContainer = class {
|
|
333
|
+
constructor(provider, prefix = ".docblocks/media") {
|
|
334
|
+
this.provider = provider;
|
|
335
|
+
this.prefix = prefix.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
336
|
+
}
|
|
337
|
+
async readFile(path) {
|
|
338
|
+
return this.provider.readBinary(joinPrefix(this.prefix, path));
|
|
339
|
+
}
|
|
340
|
+
async writeFile(path, data, _mimeType) {
|
|
341
|
+
await this.provider.writeBinary(joinPrefix(this.prefix, path), data);
|
|
342
|
+
}
|
|
343
|
+
async removeFile(path) {
|
|
344
|
+
await this.provider.delete(joinPrefix(this.prefix, path));
|
|
345
|
+
}
|
|
346
|
+
async listFiles(prefix) {
|
|
347
|
+
const entries = [];
|
|
348
|
+
const walk = async (dir) => {
|
|
349
|
+
let children;
|
|
350
|
+
try {
|
|
351
|
+
children = await this.provider.readDirectory(dir);
|
|
352
|
+
} catch {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
for (const child of children) {
|
|
356
|
+
if (child.kind === "directory") {
|
|
357
|
+
await walk(child.path);
|
|
358
|
+
} else {
|
|
359
|
+
const rel = child.path.replace(new RegExp("^/?" + this.prefix + "/?"), "");
|
|
360
|
+
if (prefix && !rel.startsWith(prefix)) continue;
|
|
361
|
+
const meta = await this.provider.stat(child.path);
|
|
362
|
+
entries.push({
|
|
363
|
+
path: rel,
|
|
364
|
+
mimeType: guessMimeType2(rel),
|
|
365
|
+
size: meta?.size ?? 0
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
await walk("/" + this.prefix);
|
|
371
|
+
return entries;
|
|
372
|
+
}
|
|
373
|
+
async exists(path) {
|
|
374
|
+
return this.provider.exists(joinPrefix(this.prefix, path));
|
|
375
|
+
}
|
|
376
|
+
async getDocumentPath() {
|
|
377
|
+
return findDocumentPath2(await this.listFiles());
|
|
378
|
+
}
|
|
379
|
+
async readDocument() {
|
|
380
|
+
const docPath = await this.getDocumentPath();
|
|
381
|
+
if (!docPath) return null;
|
|
382
|
+
const data = await this.readFile(docPath);
|
|
383
|
+
if (!data) return null;
|
|
384
|
+
return new TextDecoder().decode(data);
|
|
385
|
+
}
|
|
386
|
+
async writeDocument(markdown, filename) {
|
|
387
|
+
const name = filename ?? "index.md";
|
|
388
|
+
const data = new TextEncoder().encode(markdown);
|
|
389
|
+
await this.writeFile(name, data, "text/markdown");
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
// src/filesystem/file-media-provider.ts
|
|
394
|
+
function stripExt(name) {
|
|
395
|
+
return name.replace(/\.[^.]+$/, "");
|
|
396
|
+
}
|
|
397
|
+
function createFileMediaProvider(container, markdownBasename) {
|
|
398
|
+
const folder = stripExt(markdownBasename) + "_files";
|
|
399
|
+
const prefix = folder + "/";
|
|
400
|
+
const blobUrlCache = /* @__PURE__ */ new Map();
|
|
401
|
+
function toKey(ref) {
|
|
402
|
+
const clean = ref.replace(/^\/+/, "");
|
|
403
|
+
return clean.startsWith(prefix) ? clean : prefix + clean;
|
|
404
|
+
}
|
|
405
|
+
return {
|
|
406
|
+
async resolveUrl(ref) {
|
|
407
|
+
const key = toKey(ref);
|
|
408
|
+
const cached = blobUrlCache.get(key);
|
|
409
|
+
if (cached) return cached;
|
|
410
|
+
const data = await container.readFile(key);
|
|
411
|
+
if (!data) return ref;
|
|
412
|
+
const entries = await container.listFiles();
|
|
413
|
+
const entry = entries.find((e) => e.path === key);
|
|
414
|
+
const mimeType = entry?.mimeType ?? "application/octet-stream";
|
|
415
|
+
const url = URL.createObjectURL(new Blob([data], { type: mimeType }));
|
|
416
|
+
blobUrlCache.set(key, url);
|
|
417
|
+
return url;
|
|
418
|
+
},
|
|
419
|
+
async listMedia() {
|
|
420
|
+
const entries = await container.listFiles(prefix);
|
|
421
|
+
return entries.filter((e) => !e.path.toLowerCase().endsWith(".md")).map((e) => ({
|
|
422
|
+
name: e.path,
|
|
423
|
+
mimeType: e.mimeType,
|
|
424
|
+
size: e.size
|
|
425
|
+
}));
|
|
426
|
+
},
|
|
427
|
+
async addMedia(name, data, mimeType) {
|
|
428
|
+
const key = toKey(name);
|
|
429
|
+
const cached = blobUrlCache.get(key);
|
|
430
|
+
if (cached) {
|
|
431
|
+
URL.revokeObjectURL(cached);
|
|
432
|
+
blobUrlCache.delete(key);
|
|
433
|
+
}
|
|
434
|
+
const buffer = data instanceof Blob ? new Uint8Array(await data.arrayBuffer()) : data;
|
|
435
|
+
await container.writeFile(key, buffer, mimeType);
|
|
436
|
+
return key;
|
|
437
|
+
},
|
|
438
|
+
async removeMedia(ref) {
|
|
439
|
+
const key = toKey(ref);
|
|
440
|
+
const cached = blobUrlCache.get(key);
|
|
441
|
+
if (cached) {
|
|
442
|
+
URL.revokeObjectURL(cached);
|
|
443
|
+
blobUrlCache.delete(key);
|
|
444
|
+
}
|
|
445
|
+
await container.removeFile(key);
|
|
446
|
+
},
|
|
447
|
+
dispose() {
|
|
448
|
+
for (const url of blobUrlCache.values()) {
|
|
449
|
+
URL.revokeObjectURL(url);
|
|
450
|
+
}
|
|
451
|
+
blobUrlCache.clear();
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
|
|
299
456
|
// src/filesystem/native-provider.ts
|
|
300
457
|
function isNativeFileSystemSupported() {
|
|
301
458
|
return typeof globalThis !== "undefined" && "showDirectoryPicker" in globalThis;
|
|
@@ -545,15 +702,74 @@ async function restoreNativeFolder(workspaceId) {
|
|
|
545
702
|
return null;
|
|
546
703
|
}
|
|
547
704
|
|
|
705
|
+
// src/filesystem/electron-provider.ts
|
|
706
|
+
function getHostFs() {
|
|
707
|
+
const host = maybeGetDocblocksHost();
|
|
708
|
+
if (!host) {
|
|
709
|
+
throw new Error(
|
|
710
|
+
"ElectronFileSystemProvider: docblocksHost is not available \u2014 not running under Electron?"
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
return host.fs;
|
|
714
|
+
}
|
|
715
|
+
var ElectronFileSystemProvider = class {
|
|
716
|
+
constructor(id, label, rootPath) {
|
|
717
|
+
this.id = id;
|
|
718
|
+
this.label = label;
|
|
719
|
+
this.rootPath = rootPath;
|
|
720
|
+
}
|
|
721
|
+
/** Absolute path this provider is rooted at. */
|
|
722
|
+
getRootPath() {
|
|
723
|
+
return this.rootPath;
|
|
724
|
+
}
|
|
725
|
+
readFile(path) {
|
|
726
|
+
return getHostFs().readFile(this.rootPath, path);
|
|
727
|
+
}
|
|
728
|
+
writeFile(path, content) {
|
|
729
|
+
return getHostFs().writeFile(this.rootPath, path, content);
|
|
730
|
+
}
|
|
731
|
+
delete(path) {
|
|
732
|
+
return getHostFs().delete(this.rootPath, path);
|
|
733
|
+
}
|
|
734
|
+
rename(oldPath, newPath) {
|
|
735
|
+
return getHostFs().rename(this.rootPath, oldPath, newPath);
|
|
736
|
+
}
|
|
737
|
+
readDirectory(path) {
|
|
738
|
+
return getHostFs().readDirectory(this.rootPath, path);
|
|
739
|
+
}
|
|
740
|
+
exists(path) {
|
|
741
|
+
return getHostFs().exists(this.rootPath, path);
|
|
742
|
+
}
|
|
743
|
+
createDirectory(path) {
|
|
744
|
+
return getHostFs().createDirectory(this.rootPath, path);
|
|
745
|
+
}
|
|
746
|
+
stat(path) {
|
|
747
|
+
return getHostFs().stat(this.rootPath, path);
|
|
748
|
+
}
|
|
749
|
+
readBinary(path) {
|
|
750
|
+
return getHostFs().readBinary(this.rootPath, path);
|
|
751
|
+
}
|
|
752
|
+
writeBinary(path, data) {
|
|
753
|
+
return getHostFs().writeBinary(this.rootPath, path, data);
|
|
754
|
+
}
|
|
755
|
+
/** Subscribe to external change notifications under this root. */
|
|
756
|
+
watch(onChange) {
|
|
757
|
+
return getHostFs().watch(this.rootPath, onChange);
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
|
|
548
761
|
export {
|
|
549
762
|
IndexedDBFileSystemProvider,
|
|
550
763
|
IndexedDBContentContainer,
|
|
764
|
+
FileSystemContentContainer,
|
|
765
|
+
createFileMediaProvider,
|
|
551
766
|
isNativeFileSystemSupported,
|
|
552
767
|
storeDirectoryHandle,
|
|
553
768
|
loadDirectoryHandle,
|
|
554
769
|
removeDirectoryHandle,
|
|
555
770
|
NativeFileSystemProvider,
|
|
556
771
|
openNativeFolder,
|
|
557
|
-
restoreNativeFolder
|
|
772
|
+
restoreNativeFolder,
|
|
773
|
+
ElectronFileSystemProvider
|
|
558
774
|
};
|
|
559
|
-
//# sourceMappingURL=chunk-
|
|
775
|
+
//# sourceMappingURL=chunk-OGJN2J4P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/filesystem/indexeddb-provider.ts","../src/filesystem/indexeddb-content-container.ts","../src/filesystem/filesystem-content-container.ts","../src/filesystem/file-media-provider.ts","../src/filesystem/native-provider.ts","../src/filesystem/electron-provider.ts"],"sourcesContent":["/**\n * IndexedDBFileSystemProvider — virtualises a filesystem on top of IndexedDB\n * using the LocalForageAdapter from @bendyline/squisq/storage.\n *\n * Key schema:\n * fs:{path}:content → string (text file contents)\n * fs:{path}:binary → ArrayBuffer (binary file contents)\n * fs:{path}:meta → FileMeta object\n * fs:dirs → Set<string> of known directory paths\n */\n\nimport { LocalForageAdapter } from '@bendyline/squisq/storage';\nimport type { FileSystemProvider, FileSystemEntry, FileMeta } from './types.js';\n\n// ── Helpers ────────────────────────────────────────────────────────\n\n/** Normalise a path: strip leading/trailing slashes, collapse doubles. */\nfunction normalisePath(p: string): string {\n return p.replace(/\\\\/g, '/').replace(/\\/+/g, '/').replace(/^\\//, '').replace(/\\/$/, '');\n}\n\n/** Get the parent directory of a path, or empty string for root-level. */\nfunction parentDir(p: string): string {\n const idx = p.lastIndexOf('/');\n return idx === -1 ? '' : p.slice(0, idx);\n}\n\n/** Get the filename component of a path. */\nfunction baseName(p: string): string {\n const idx = p.lastIndexOf('/');\n return idx === -1 ? p : p.slice(idx + 1);\n}\n\n// ── Key helpers ────────────────────────────────────────────────────\n\nfunction contentKey(path: string): string {\n return `fs:${path}:content`;\n}\n\nfunction binaryKey(path: string): string {\n return `fs:${path}:binary`;\n}\n\nfunction metaKey(path: string): string {\n return `fs:${path}:meta`;\n}\n\nconst DIRS_KEY = 'fs:dirs';\n\n// ── Implementation ─────────────────────────────────────────────────\n\nexport class IndexedDBFileSystemProvider implements FileSystemProvider {\n readonly id: string;\n readonly label: string;\n\n private store: LocalForageAdapter;\n\n constructor(id: string, label: string) {\n this.id = id;\n this.label = label;\n this.store = new LocalForageAdapter({\n name: `docblocks-fs-${id}`,\n storeName: 'files',\n });\n }\n\n // ── Directory tracking ──────────────────────────────────────────\n\n private async getDirs(): Promise<Set<string>> {\n const raw = await this.store.get<string[]>(DIRS_KEY);\n return new Set(raw ?? []);\n }\n\n private async saveDirs(dirs: Set<string>): Promise<void> {\n await this.store.set(DIRS_KEY, [...dirs]);\n }\n\n /** Ensure a directory (and all ancestors) are tracked. */\n private async ensureDir(dirPath: string): Promise<void> {\n if (!dirPath) return;\n const dirs = await this.getDirs();\n const parts = dirPath.split('/');\n let current = '';\n let changed = false;\n for (const part of parts) {\n current = current ? `${current}/${part}` : part;\n if (!dirs.has(current)) {\n dirs.add(current);\n changed = true;\n }\n }\n if (changed) {\n await this.saveDirs(dirs);\n }\n }\n\n // ── FileSystemProvider implementation ───────────────────────────\n\n async readFile(path: string): Promise<string | null> {\n const p = normalisePath(path);\n return this.store.get<string>(contentKey(p));\n }\n\n async writeFile(path: string, content: string): Promise<void> {\n const p = normalisePath(path);\n const parent = parentDir(p);\n if (parent) {\n await this.ensureDir(parent);\n }\n\n const meta: FileMeta = {\n name: baseName(p),\n path: p,\n size: new Blob([content]).size,\n lastModified: new Date().toISOString(),\n };\n\n await this.store.set(contentKey(p), content);\n await this.store.set(metaKey(p), meta);\n }\n\n async delete(path: string): Promise<void> {\n const p = normalisePath(path);\n\n // Remove file keys\n await this.store.remove(contentKey(p));\n await this.store.remove(binaryKey(p));\n await this.store.remove(metaKey(p));\n\n // If it was a directory, remove it and all children\n const dirs = await this.getDirs();\n if (dirs.has(p)) {\n const prefix = p + '/';\n const toRemove: string[] = [p];\n for (const d of dirs) {\n if (d.startsWith(prefix)) {\n toRemove.push(d);\n }\n }\n for (const d of toRemove) {\n dirs.delete(d);\n }\n await this.saveDirs(dirs);\n\n // Remove all file keys under this directory\n const allKeys = await this.store.keys();\n const filePrefix = `fs:${p}/`;\n const keysToRemove = allKeys.filter((k) => k.startsWith(filePrefix));\n await Promise.all(keysToRemove.map((k) => this.store.remove(k)));\n }\n }\n\n async rename(oldPath: string, newPath: string): Promise<void> {\n const op = normalisePath(oldPath);\n const np = normalisePath(newPath);\n\n // Read existing data\n const content = await this.store.get<string>(contentKey(op));\n const binary = await this.store.get<ArrayBuffer>(binaryKey(op));\n const meta = await this.store.get<FileMeta>(metaKey(op));\n\n // Write to new location\n if (content !== null) {\n await this.store.set(contentKey(np), content);\n }\n if (binary !== null) {\n await this.store.set(binaryKey(np), binary);\n }\n if (meta) {\n meta.name = baseName(np);\n meta.path = np;\n await this.store.set(metaKey(np), meta);\n }\n\n // Ensure parent dir of new path exists\n const newParent = parentDir(np);\n if (newParent) {\n await this.ensureDir(newParent);\n }\n\n // Delete old\n await this.store.remove(contentKey(op));\n await this.store.remove(binaryKey(op));\n await this.store.remove(metaKey(op));\n\n // Handle directory rename\n const dirs = await this.getDirs();\n if (dirs.has(op)) {\n dirs.delete(op);\n dirs.add(np);\n const oldPrefix = op + '/';\n const newPrefix = np + '/';\n for (const d of [...dirs]) {\n if (d.startsWith(oldPrefix)) {\n dirs.delete(d);\n dirs.add(newPrefix + d.slice(oldPrefix.length));\n }\n }\n await this.saveDirs(dirs);\n }\n }\n\n async readDirectory(path: string): Promise<FileSystemEntry[]> {\n const p = normalisePath(path);\n const dirs = await this.getDirs();\n const entries: FileSystemEntry[] = [];\n const seen = new Set<string>();\n\n // Find child directories\n const prefix = p ? p + '/' : '';\n for (const d of dirs) {\n if (!p && !d.includes('/')) {\n // Root-level directory\n if (!seen.has(d)) {\n seen.add(d);\n entries.push({ kind: 'directory', name: d, path: d });\n }\n } else if (p && d.startsWith(prefix)) {\n const rest = d.slice(prefix.length);\n if (!rest.includes('/')) {\n // Direct child directory\n if (!seen.has(rest)) {\n seen.add(rest);\n entries.push({ kind: 'directory', name: rest, path: d });\n }\n }\n }\n }\n\n // Find child files by scanning meta keys\n const allKeys = await this.store.keys();\n const metaPrefix = p ? `fs:${p}/` : 'fs:';\n const metaSuffix = ':meta';\n\n for (const key of allKeys) {\n if (!key.startsWith(metaPrefix) || !key.endsWith(metaSuffix)) continue;\n\n const filePath = key.slice(3, -metaSuffix.length); // strip \"fs:\" and \":meta\"\n const rel = p ? filePath.slice(prefix.length) : filePath;\n\n // Only direct children (no further slashes)\n if (rel.includes('/')) continue;\n\n if (!seen.has(rel)) {\n seen.add(rel);\n entries.push({ kind: 'file', name: rel, path: filePath });\n }\n }\n\n // Sort: directories first, then alphabetical\n entries.sort((a, b) => {\n if (a.kind !== b.kind) return a.kind === 'directory' ? -1 : 1;\n return a.name.localeCompare(b.name);\n });\n\n return entries;\n }\n\n async exists(path: string): Promise<boolean> {\n const p = normalisePath(path);\n const dirs = await this.getDirs();\n if (dirs.has(p)) return true;\n const meta = await this.store.get(metaKey(p));\n return meta !== null;\n }\n\n async createDirectory(path: string): Promise<void> {\n const p = normalisePath(path);\n await this.ensureDir(p);\n }\n\n async stat(path: string): Promise<FileMeta | null> {\n const p = normalisePath(path);\n return this.store.get<FileMeta>(metaKey(p));\n }\n\n async readBinary(path: string): Promise<ArrayBuffer | null> {\n const p = normalisePath(path);\n return this.store.get<ArrayBuffer>(binaryKey(p));\n }\n\n async writeBinary(path: string, data: ArrayBuffer | Uint8Array): Promise<void> {\n const p = normalisePath(path);\n const parent = parentDir(p);\n if (parent) {\n await this.ensureDir(parent);\n }\n\n const meta: FileMeta = {\n name: baseName(p),\n path: p,\n size: data.byteLength,\n lastModified: new Date().toISOString(),\n };\n\n await this.store.set(binaryKey(p), data);\n await this.store.set(metaKey(p), meta);\n }\n}\n","/**\n * IndexedDBContentContainer — a ContentContainer backed by IndexedDB.\n *\n * Uses a dedicated IndexedDBFileSystemProvider instance (separate store)\n * to persist media files across page refreshes.\n */\n\nimport type { ContentContainer, ContentEntry } from '@bendyline/squisq/storage';\nimport { findDocumentPath } from '@bendyline/squisq/storage';\nimport { IndexedDBFileSystemProvider } from './indexeddb-provider.js';\n\n// ── MIME type guessing ─────────────────────────────────────────────\n\nconst EXTENSION_MIME_MAP: Record<string, string> = {\n '.md': 'text/markdown',\n '.txt': 'text/plain',\n '.json': 'application/json',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.png': 'image/png',\n '.gif': 'image/gif',\n '.svg': 'image/svg+xml',\n '.webp': 'image/webp',\n '.avif': 'image/avif',\n '.mp4': 'video/mp4',\n '.webm': 'video/webm',\n '.mp3': 'audio/mpeg',\n '.wav': 'audio/wav',\n '.ogg': 'audio/ogg',\n};\n\nfunction guessMimeType(path: string): string {\n const dot = path.lastIndexOf('.');\n if (dot === -1) return 'application/octet-stream';\n const ext = path.slice(dot).toLowerCase();\n return EXTENSION_MIME_MAP[ext] ?? 'application/octet-stream';\n}\n\n// ── Implementation ─────────────────────────────────────────────────\n\nexport class IndexedDBContentContainer implements ContentContainer {\n private provider: IndexedDBFileSystemProvider;\n\n constructor(workspaceId: string) {\n this.provider = new IndexedDBFileSystemProvider(`${workspaceId}-media`, 'Media Storage');\n }\n\n async readFile(path: string): Promise<ArrayBuffer | null> {\n return this.provider.readBinary(path);\n }\n\n async writeFile(path: string, data: ArrayBuffer | Uint8Array, _mimeType?: string): Promise<void> {\n await this.provider.writeBinary(path, data);\n }\n\n async removeFile(path: string): Promise<void> {\n await this.provider.delete(path);\n }\n\n async listFiles(prefix?: string): Promise<ContentEntry[]> {\n const entries: ContentEntry[] = [];\n const walk = async (dir: string) => {\n const children = await this.provider.readDirectory(dir);\n for (const child of children) {\n if (child.kind === 'directory') {\n await walk(child.path);\n } else {\n const filePath = child.path.replace(/^\\//, '');\n if (prefix && !filePath.startsWith(prefix)) continue;\n const meta = await this.provider.stat(child.path);\n entries.push({\n path: filePath,\n mimeType: guessMimeType(filePath),\n size: meta?.size ?? 0,\n });\n }\n }\n };\n await walk('/');\n return entries;\n }\n\n async exists(path: string): Promise<boolean> {\n return this.provider.exists(path);\n }\n\n async getDocumentPath(): Promise<string | null> {\n return findDocumentPath(await this.listFiles());\n }\n\n async readDocument(): Promise<string | null> {\n const docPath = await this.getDocumentPath();\n if (!docPath) return null;\n const data = await this.readFile(docPath);\n if (!data) return null;\n return new TextDecoder().decode(data);\n }\n\n async writeDocument(markdown: string, filename?: string): Promise<void> {\n const name = filename ?? 'index.md';\n const data = new TextEncoder().encode(markdown);\n await this.writeFile(name, data, 'text/markdown');\n }\n}\n","/**\n * FileSystemContentContainer — a ContentContainer backed by any\n * FileSystemProvider, scoped to a sub-path (e.g., \".docblocks/media/\").\n *\n * Used by the Electron desktop app so media lives inside the workspace\n * folder (visible as regular files) rather than in a separate IndexedDB\n * origin that only the app can see.\n */\n\nimport type { ContentContainer, ContentEntry } from '@bendyline/squisq/storage';\nimport { findDocumentPath } from '@bendyline/squisq/storage';\nimport type { FileSystemProvider } from './types.js';\n\nconst EXTENSION_MIME_MAP: Record<string, string> = {\n '.md': 'text/markdown',\n '.txt': 'text/plain',\n '.json': 'application/json',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.png': 'image/png',\n '.gif': 'image/gif',\n '.svg': 'image/svg+xml',\n '.webp': 'image/webp',\n '.avif': 'image/avif',\n '.mp4': 'video/mp4',\n '.webm': 'video/webm',\n '.mp3': 'audio/mpeg',\n '.wav': 'audio/wav',\n '.ogg': 'audio/ogg',\n};\n\nfunction guessMimeType(path: string): string {\n const dot = path.lastIndexOf('.');\n if (dot === -1) return 'application/octet-stream';\n const ext = path.slice(dot).toLowerCase();\n return EXTENSION_MIME_MAP[ext] ?? 'application/octet-stream';\n}\n\nfunction joinPrefix(prefix: string, p: string): string {\n const clean = p.replace(/^\\/+/, '');\n return prefix.replace(/\\/+$/, '') + '/' + clean;\n}\n\nexport class FileSystemContentContainer implements ContentContainer {\n private readonly prefix: string;\n\n constructor(\n private readonly provider: FileSystemProvider,\n prefix = '.docblocks/media',\n ) {\n this.prefix = prefix.replace(/^\\/+/, '').replace(/\\/+$/, '');\n }\n\n async readFile(path: string): Promise<ArrayBuffer | null> {\n return this.provider.readBinary(joinPrefix(this.prefix, path));\n }\n\n async writeFile(path: string, data: ArrayBuffer | Uint8Array, _mimeType?: string): Promise<void> {\n await this.provider.writeBinary(joinPrefix(this.prefix, path), data);\n }\n\n async removeFile(path: string): Promise<void> {\n await this.provider.delete(joinPrefix(this.prefix, path));\n }\n\n async listFiles(prefix?: string): Promise<ContentEntry[]> {\n const entries: ContentEntry[] = [];\n const walk = async (dir: string) => {\n let children;\n try {\n children = await this.provider.readDirectory(dir);\n } catch {\n return;\n }\n for (const child of children) {\n if (child.kind === 'directory') {\n await walk(child.path);\n } else {\n const rel = child.path.replace(new RegExp('^/?' + this.prefix + '/?'), '');\n if (prefix && !rel.startsWith(prefix)) continue;\n const meta = await this.provider.stat(child.path);\n entries.push({\n path: rel,\n mimeType: guessMimeType(rel),\n size: meta?.size ?? 0,\n });\n }\n }\n };\n await walk('/' + this.prefix);\n return entries;\n }\n\n async exists(path: string): Promise<boolean> {\n return this.provider.exists(joinPrefix(this.prefix, path));\n }\n\n async getDocumentPath(): Promise<string | null> {\n return findDocumentPath(await this.listFiles());\n }\n\n async readDocument(): Promise<string | null> {\n const docPath = await this.getDocumentPath();\n if (!docPath) return null;\n const data = await this.readFile(docPath);\n if (!data) return null;\n return new TextDecoder().decode(data);\n }\n\n async writeDocument(markdown: string, filename?: string): Promise<void> {\n const name = filename ?? 'index.md';\n const data = new TextEncoder().encode(markdown);\n await this.writeFile(name, data, 'text/markdown');\n }\n}\n","/**\n * createFileMediaProvider — per-file media storage following the pandoc /\n * Word convention: a markdown file `notes.md` gets a sibling folder\n * `notes_files/` that holds its images, audio, and video.\n *\n * Given:\n * • `container` — a ContentContainer scoped to the markdown file's\n * parent directory (so `readFile('notes_files/image.png')` maps to the\n * parent-relative path)\n * • `markdownBasename` — e.g. `\"notes.md\"`\n *\n * Returns a MediaProvider that:\n * • Writes new media under `{basename}_files/{name}` in the parent dir\n * • Returns the folder-qualified path (`notes_files/image.png`) from\n * addMedia so the markdown stays portable outside DocBlocks\n * • Resolves both bare (`image.png`) and folder-qualified\n * (`notes_files/image.png`) references — so legacy markdown and\n * exports from other tools both work\n */\n\nimport type { MediaProvider, MediaEntry } from '@bendyline/squisq/schemas';\nimport type { ContentContainer } from '@bendyline/squisq/storage';\n\nfunction stripExt(name: string): string {\n return name.replace(/\\.[^.]+$/, '');\n}\n\nexport function createFileMediaProvider(\n container: ContentContainer,\n markdownBasename: string,\n): MediaProvider {\n const folder = stripExt(markdownBasename) + '_files';\n const prefix = folder + '/';\n const blobUrlCache = new Map<string, string>();\n\n function toKey(ref: string): string {\n const clean = ref.replace(/^\\/+/, '');\n return clean.startsWith(prefix) ? clean : prefix + clean;\n }\n\n return {\n async resolveUrl(ref: string): Promise<string> {\n const key = toKey(ref);\n const cached = blobUrlCache.get(key);\n if (cached) return cached;\n\n const data = await container.readFile(key);\n if (!data) return ref;\n\n const entries = await container.listFiles();\n const entry = entries.find((e) => e.path === key);\n const mimeType = entry?.mimeType ?? 'application/octet-stream';\n\n const url = URL.createObjectURL(new Blob([data], { type: mimeType }));\n blobUrlCache.set(key, url);\n return url;\n },\n\n async listMedia(): Promise<MediaEntry[]> {\n const entries = await container.listFiles(prefix);\n return entries\n .filter((e) => !e.path.toLowerCase().endsWith('.md'))\n .map((e) => ({\n name: e.path,\n mimeType: e.mimeType,\n size: e.size,\n }));\n },\n\n async addMedia(\n name: string,\n data: ArrayBuffer | Blob | Uint8Array,\n mimeType: string,\n ): Promise<string> {\n const key = toKey(name);\n const cached = blobUrlCache.get(key);\n if (cached) {\n URL.revokeObjectURL(cached);\n blobUrlCache.delete(key);\n }\n const buffer = data instanceof Blob ? new Uint8Array(await data.arrayBuffer()) : data;\n await container.writeFile(key, buffer, mimeType);\n return key;\n },\n\n async removeMedia(ref: string): Promise<void> {\n const key = toKey(ref);\n const cached = blobUrlCache.get(key);\n if (cached) {\n URL.revokeObjectURL(cached);\n blobUrlCache.delete(key);\n }\n await container.removeFile(key);\n },\n\n dispose(): void {\n for (const url of blobUrlCache.values()) {\n URL.revokeObjectURL(url);\n }\n blobUrlCache.clear();\n },\n };\n}\n","/**\n * NativeFileSystemProvider — wraps the File System Access API\n * (window.showDirectoryPicker / FileSystemDirectoryHandle).\n *\n * Progressive enhancement: only available in browsers that support\n * the API (Chrome, Edge). Feature-detect with `isNativeFileSystemSupported()`.\n */\n\nimport type { FileSystemProvider, FileSystemEntry, FileMeta } from './types.js';\n\n// ── Feature detection ──────────────────────────────────────────────\n\nexport function isNativeFileSystemSupported(): boolean {\n return typeof globalThis !== 'undefined' && 'showDirectoryPicker' in globalThis;\n}\n\n// ── Handle persistence (IndexedDB, structured clone) ───────────────\n\nconst HANDLE_DB_NAME = 'docblocks-handles';\nconst HANDLE_STORE_NAME = 'directory-handles';\n\nfunction openHandleDB(): Promise<IDBDatabase> {\n return new Promise((resolve, reject) => {\n const req = indexedDB.open(HANDLE_DB_NAME, 1);\n req.onupgradeneeded = () => {\n req.result.createObjectStore(HANDLE_STORE_NAME);\n };\n req.onsuccess = () => resolve(req.result);\n req.onerror = () => reject(req.error);\n });\n}\n\n/** Persist a FileSystemDirectoryHandle so it survives page reloads. */\nexport async function storeDirectoryHandle(\n workspaceId: string,\n handle: FileSystemDirectoryHandle,\n): Promise<void> {\n const db = await openHandleDB();\n return new Promise((resolve, reject) => {\n const tx = db.transaction(HANDLE_STORE_NAME, 'readwrite');\n tx.objectStore(HANDLE_STORE_NAME).put(handle, workspaceId);\n tx.oncomplete = () => {\n db.close();\n resolve();\n };\n tx.onerror = () => {\n db.close();\n reject(tx.error);\n };\n });\n}\n\n/** Retrieve a previously stored handle. Returns null if not found. */\nexport async function loadDirectoryHandle(\n workspaceId: string,\n): Promise<FileSystemDirectoryHandle | null> {\n const db = await openHandleDB();\n return new Promise((resolve, reject) => {\n const tx = db.transaction(HANDLE_STORE_NAME, 'readonly');\n const req = tx.objectStore(HANDLE_STORE_NAME).get(workspaceId);\n req.onsuccess = () => {\n db.close();\n resolve(req.result ?? null);\n };\n req.onerror = () => {\n db.close();\n reject(req.error);\n };\n });\n}\n\n/** Remove a stored handle (e.g. when deleting a workspace). */\nexport async function removeDirectoryHandle(workspaceId: string): Promise<void> {\n const db = await openHandleDB();\n return new Promise((resolve, reject) => {\n const tx = db.transaction(HANDLE_STORE_NAME, 'readwrite');\n tx.objectStore(HANDLE_STORE_NAME).delete(workspaceId);\n tx.oncomplete = () => {\n db.close();\n resolve();\n };\n tx.onerror = () => {\n db.close();\n reject(tx.error);\n };\n });\n}\n\n// ── Helpers ────────────────────────────────────────────────────────\n\nfunction normalisePath(p: string): string {\n return p.replace(/\\\\/g, '/').replace(/\\/+/g, '/').replace(/^\\//, '').replace(/\\/$/, '');\n}\n\n/**\n * Walk a chain of path segments to reach a FileSystemDirectoryHandle.\n * Returns null if any segment is missing.\n */\nasync function resolveDir(\n root: FileSystemDirectoryHandle,\n dirPath: string,\n): Promise<FileSystemDirectoryHandle | null> {\n if (!dirPath) return root;\n const parts = dirPath.split('/');\n let current = root;\n for (const part of parts) {\n try {\n current = await current.getDirectoryHandle(part);\n } catch {\n return null;\n }\n }\n return current;\n}\n\n/**\n * Walk path segments, creating directories as needed.\n */\nasync function resolveDirCreate(\n root: FileSystemDirectoryHandle,\n dirPath: string,\n): Promise<FileSystemDirectoryHandle> {\n if (!dirPath) return root;\n const parts = dirPath.split('/');\n let current = root;\n for (const part of parts) {\n current = await current.getDirectoryHandle(part, { create: true });\n }\n return current;\n}\n\nfunction parentDir(p: string): string {\n const idx = p.lastIndexOf('/');\n return idx === -1 ? '' : p.slice(0, idx);\n}\n\nfunction baseName(p: string): string {\n const idx = p.lastIndexOf('/');\n return idx === -1 ? p : p.slice(idx + 1);\n}\n\n// ── Implementation ─────────────────────────────────────────────────\n\nexport class NativeFileSystemProvider implements FileSystemProvider {\n readonly id: string;\n readonly label: string;\n\n private root: FileSystemDirectoryHandle;\n\n constructor(id: string, root: FileSystemDirectoryHandle) {\n this.id = id;\n this.label = root.name;\n this.root = root;\n }\n\n async readFile(path: string): Promise<string | null> {\n const p = normalisePath(path);\n const dir = await resolveDir(this.root, parentDir(p));\n if (!dir) return null;\n try {\n const fileHandle = await dir.getFileHandle(baseName(p));\n const file = await fileHandle.getFile();\n return file.text();\n } catch {\n return null;\n }\n }\n\n async writeFile(path: string, content: string): Promise<void> {\n const p = normalisePath(path);\n const dir = await resolveDirCreate(this.root, parentDir(p));\n const fileHandle = await dir.getFileHandle(baseName(p), { create: true });\n const writable = await fileHandle.createWritable();\n await writable.write(content);\n await writable.close();\n }\n\n async delete(path: string): Promise<void> {\n const p = normalisePath(path);\n const parent = parentDir(p);\n const name = baseName(p);\n const dir = await resolveDir(this.root, parent);\n if (!dir) return;\n await dir.removeEntry(name, { recursive: true });\n }\n\n async rename(oldPath: string, newPath: string): Promise<void> {\n const op = normalisePath(oldPath);\n const np = normalisePath(newPath);\n\n // The File System Access API doesn't have a native rename.\n // Read → write → delete.\n const content = await this.readFile(op);\n if (content !== null) {\n await this.writeFile(np, content);\n await this.delete(op);\n return;\n }\n\n // Try binary\n const binary = await this.readBinary(op);\n if (binary !== null) {\n await this.writeBinary(np, binary);\n await this.delete(op);\n }\n }\n\n async readDirectory(path: string): Promise<FileSystemEntry[]> {\n const p = normalisePath(path);\n const dir = await resolveDir(this.root, p);\n if (!dir) return [];\n\n const entries: FileSystemEntry[] = [];\n for await (const [name, handle] of dir as unknown as AsyncIterable<\n [string, FileSystemHandle]\n >) {\n const entryPath = p ? `${p}/${name}` : name;\n if (handle.kind === 'directory') {\n entries.push({ kind: 'directory', name, path: entryPath });\n } else {\n entries.push({ kind: 'file', name, path: entryPath });\n }\n }\n\n // Sort: directories first, then alphabetical\n entries.sort((a, b) => {\n if (a.kind !== b.kind) return a.kind === 'directory' ? -1 : 1;\n return a.name.localeCompare(b.name);\n });\n\n return entries;\n }\n\n async exists(path: string): Promise<boolean> {\n const p = normalisePath(path);\n const parent = parentDir(p);\n const name = baseName(p);\n const dir = await resolveDir(this.root, parent);\n if (!dir) return false;\n\n try {\n await dir.getFileHandle(name);\n return true;\n } catch {\n try {\n await dir.getDirectoryHandle(name);\n return true;\n } catch {\n return false;\n }\n }\n }\n\n async createDirectory(path: string): Promise<void> {\n const p = normalisePath(path);\n await resolveDirCreate(this.root, p);\n }\n\n async stat(path: string): Promise<FileMeta | null> {\n const p = normalisePath(path);\n const dir = await resolveDir(this.root, parentDir(p));\n if (!dir) return null;\n\n try {\n const fileHandle = await dir.getFileHandle(baseName(p));\n const file = await fileHandle.getFile();\n return {\n name: file.name,\n path: p,\n size: file.size,\n lastModified: new Date(file.lastModified).toISOString(),\n };\n } catch {\n return null;\n }\n }\n\n async readBinary(path: string): Promise<ArrayBuffer | null> {\n const p = normalisePath(path);\n const dir = await resolveDir(this.root, parentDir(p));\n if (!dir) return null;\n try {\n const fileHandle = await dir.getFileHandle(baseName(p));\n const file = await fileHandle.getFile();\n return file.arrayBuffer();\n } catch {\n return null;\n }\n }\n\n async writeBinary(path: string, data: ArrayBuffer | Uint8Array): Promise<void> {\n const p = normalisePath(path);\n const dir = await resolveDirCreate(this.root, parentDir(p));\n const fileHandle = await dir.getFileHandle(baseName(p), { create: true });\n const writable = await fileHandle.createWritable();\n if (data instanceof ArrayBuffer) {\n await writable.write(data);\n } else {\n await writable.write(data.buffer as ArrayBuffer);\n }\n await writable.close();\n }\n}\n\n/**\n * Prompt the user to pick a local folder and return a NativeFileSystemProvider.\n * The directory handle is persisted in IndexedDB so it can be restored later.\n * Throws if the user cancels or the API is unsupported.\n */\nexport async function openNativeFolder(): Promise<NativeFileSystemProvider> {\n if (!isNativeFileSystemSupported()) {\n throw new Error('File System Access API is not supported in this browser');\n }\n\n const handle = await (\n globalThis as unknown as { showDirectoryPicker: () => Promise<FileSystemDirectoryHandle> }\n ).showDirectoryPicker();\n const id = `native-${handle.name}-${Date.now()}`;\n await storeDirectoryHandle(id, handle);\n return new NativeFileSystemProvider(id, handle);\n}\n\n/**\n * Restore a previously opened native folder from a persisted handle.\n * Re-requests read/write permission (browser will show a prompt).\n * Returns null if the handle is not found or permission is denied.\n */\nexport async function restoreNativeFolder(\n workspaceId: string,\n): Promise<NativeFileSystemProvider | null> {\n const handle = await loadDirectoryHandle(workspaceId);\n if (!handle) return null;\n\n // Verify/request permission\n const opts = { mode: 'readwrite' as const };\n const h = handle as FileSystemDirectoryHandle & {\n queryPermission(desc: { mode: string }): Promise<string>;\n requestPermission(desc: { mode: string }): Promise<string>;\n };\n if ((await h.queryPermission(opts)) === 'granted') {\n return new NativeFileSystemProvider(workspaceId, handle);\n }\n if ((await h.requestPermission(opts)) === 'granted') {\n return new NativeFileSystemProvider(workspaceId, handle);\n }\n\n return null;\n}\n","/**\n * ElectronFileSystemProvider — implements FileSystemProvider by delegating\n * to the Electron desktop host's fs IPC bridge. Every operation is scoped\n * to an absolute root path that the main process validates against a\n * whitelist of registered workspace roots.\n *\n * This file has no Electron dependency — it is a pure IPC client that\n * relies on the `docblocksHost` global installed by the preload script.\n */\n\nimport type { FileSystemProvider, FileSystemEntry, FileMeta } from './types.js';\nimport { maybeGetDocblocksHost } from '../host/index.js';\nimport type { DocblocksHostFsAPI } from '../host/types.js';\n\nexport { isElectronHost } from '../host/index.js';\n\nfunction getHostFs(): DocblocksHostFsAPI {\n const host = maybeGetDocblocksHost();\n if (!host) {\n throw new Error(\n 'ElectronFileSystemProvider: docblocksHost is not available — not running under Electron?',\n );\n }\n return host.fs;\n}\n\nexport class ElectronFileSystemProvider implements FileSystemProvider {\n readonly id: string;\n readonly label: string;\n\n private readonly rootPath: string;\n\n constructor(id: string, label: string, rootPath: string) {\n this.id = id;\n this.label = label;\n this.rootPath = rootPath;\n }\n\n /** Absolute path this provider is rooted at. */\n getRootPath(): string {\n return this.rootPath;\n }\n\n readFile(path: string): Promise<string | null> {\n return getHostFs().readFile(this.rootPath, path);\n }\n\n writeFile(path: string, content: string): Promise<void> {\n return getHostFs().writeFile(this.rootPath, path, content);\n }\n\n delete(path: string): Promise<void> {\n return getHostFs().delete(this.rootPath, path);\n }\n\n rename(oldPath: string, newPath: string): Promise<void> {\n return getHostFs().rename(this.rootPath, oldPath, newPath);\n }\n\n readDirectory(path: string): Promise<FileSystemEntry[]> {\n return getHostFs().readDirectory(this.rootPath, path);\n }\n\n exists(path: string): Promise<boolean> {\n return getHostFs().exists(this.rootPath, path);\n }\n\n createDirectory(path: string): Promise<void> {\n return getHostFs().createDirectory(this.rootPath, path);\n }\n\n stat(path: string): Promise<FileMeta | null> {\n return getHostFs().stat(this.rootPath, path);\n }\n\n readBinary(path: string): Promise<ArrayBuffer | null> {\n return getHostFs().readBinary(this.rootPath, path);\n }\n\n writeBinary(path: string, data: ArrayBuffer | Uint8Array): Promise<void> {\n return getHostFs().writeBinary(this.rootPath, path, data);\n }\n\n /** Subscribe to external change notifications under this root. */\n watch(onChange: (changedPath: string) => void): () => void {\n return getHostFs().watch(this.rootPath, onChange);\n }\n}\n"],"mappings":";;;;;AAWA,SAAS,0BAA0B;AAMnC,SAAS,cAAc,GAAmB;AACxC,SAAO,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,QAAQ,GAAG,EAAE,QAAQ,OAAO,EAAE,EAAE,QAAQ,OAAO,EAAE;AACxF;AAGA,SAAS,UAAU,GAAmB;AACpC,QAAM,MAAM,EAAE,YAAY,GAAG;AAC7B,SAAO,QAAQ,KAAK,KAAK,EAAE,MAAM,GAAG,GAAG;AACzC;AAGA,SAAS,SAAS,GAAmB;AACnC,QA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U,IAAI;AAAA,EACjD;AAAA,EAEA,UAAU,MAAc,SAAgC;AACtD,WAAO,UAAU,EAAE,UAAU,KAAK,UAAU,MAAM,OAAO;AAAA,EAC3D;AAAA,EAEA,OAAO,MAA6B;AAClC,WAAO,UAAU,EAAE,OAAO,KAAK,UAAU,IAAI;AAAA,EAC/C;AAAA,EAEA,OAAO,SAAiB,SAAgC;AACtD,WAAO,UAAU,EAAE,OAAO,KAAK,UAAU,SAAS,OAAO;AAAA,EAC3D;AAAA,EAEA,cAAc,MAA0C;AACtD,WAAO,UAAU,EAAE,cAAc,KAAK,UAAU,IAAI;AAAA,EACtD;AAAA,EAEA,OAAO,MAAgC;AACrC,WAAO,UAAU,EAAE,OAAO,KAAK,UAAU,IAAI;AAAA,EAC/C;AAAA,EAEA,gBAAgB,MAA6B;AAC3C,WAAO,UAAU,EAAE,gBAAgB,KAAK,UAAU,IAAI;AAAA,EACxD;AAAA,EAEA,KAAK,MAAwC;AAC3C,WAAO,UAAU,EAAE,KAAK,KAAK,UAAU,IAAI;AAAA,EAC7C;AAAA,EAEA,WAAW,MAA2C;AACpD,WAAO,UAAU,EAAE,WAAW,KAAK,UAAU,IAAI;AAAA,EACnD;AAAA,EAEA,YAAY,MAAc,MAA+C;AACvE,WAAO,UAAU,EAAE,YAAY,KAAK,UAAU,MAAM,IAAI;AAAA,EAC1D;AAAA;AAAA,EAGA,MAAM,UAAqD;AACzD,WAAO,UAAU,EAAE,MAAM,KAAK,UAAU,QAAQ;AAAA,EAClD;AACF;","names":["findDocumentPath","EXTENSION_MIME_MAP","guessMimeType","normalisePath","parentDir","baseName"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ElectronFileSystemProvider — implements FileSystemProvider by delegating
|
|
3
|
+
* to the Electron desktop host's fs IPC bridge. Every operation is scoped
|
|
4
|
+
* to an absolute root path that the main process validates against a
|
|
5
|
+
* whitelist of registered workspace roots.
|
|
6
|
+
*
|
|
7
|
+
* This file has no Electron dependency — it is a pure IPC client that
|
|
8
|
+
* relies on the `docblocksHost` global installed by the preload script.
|
|
9
|
+
*/
|
|
10
|
+
import type { FileSystemProvider, FileSystemEntry, FileMeta } from './types.js';
|
|
11
|
+
export { isElectronHost } from '../host/index.js';
|
|
12
|
+
export declare class ElectronFileSystemProvider implements FileSystemProvider {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly label: string;
|
|
15
|
+
private readonly rootPath;
|
|
16
|
+
constructor(id: string, label: string, rootPath: string);
|
|
17
|
+
/** Absolute path this provider is rooted at. */
|
|
18
|
+
getRootPath(): string;
|
|
19
|
+
readFile(path: string): Promise<string | null>;
|
|
20
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
21
|
+
delete(path: string): Promise<void>;
|
|
22
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
23
|
+
readDirectory(path: string): Promise<FileSystemEntry[]>;
|
|
24
|
+
exists(path: string): Promise<boolean>;
|
|
25
|
+
createDirectory(path: string): Promise<void>;
|
|
26
|
+
stat(path: string): Promise<FileMeta | null>;
|
|
27
|
+
readBinary(path: string): Promise<ArrayBuffer | null>;
|
|
28
|
+
writeBinary(path: string, data: ArrayBuffer | Uint8Array): Promise<void>;
|
|
29
|
+
/** Subscribe to external change notifications under this root. */
|
|
30
|
+
watch(onChange: (changedPath: string) => void): () => void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=electron-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"electron-provider.d.ts","sourceRoot":"","sources":["../../src/filesystem/electron-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAIhF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAYlD,qBAAa,0BAA2B,YAAW,kBAAkB;IACnE,QAAQ,CAAC,EAAE,EAAE,MAAM,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op host's fs IPC bridge. Every operation is scoped
|
|
4
|
+
* to an absolute root path that the main process validates against a
|
|
5
|
+
* whitelist of registered workspace roots.
|
|
6
|
+
*
|
|
7
|
+
* This file has no Electron dependency — it is a pure IPC client that
|
|
8
|
+
* relies on the `docblocksHost` global installed by the preload script.
|
|
9
|
+
*/
|
|
10
|
+
import { maybeGetDocblocksHost } from '../host/index.js';
|
|
11
|
+
export { isElectronHost } from '../host/index.js';
|
|
12
|
+
function getHostFs() {
|
|
13
|
+
const host = maybeGetDocblocksHost();
|
|
14
|
+
if (!host) {
|
|
15
|
+
throw new Error('ElectronFileSystemProvider: docblocksHost is not available — not running under Electron?');
|
|
16
|
+
}
|
|
17
|
+
return host.fs;
|
|
18
|
+
}
|
|
19
|
+
export class ElectronFileSystemProvider {
|
|
20
|
+
constructor(id, label, rootPath) {
|
|
21
|
+
this.id = id;
|
|
22
|
+
this.label = label;
|
|
23
|
+
this.rootPath = rootPath;
|
|
24
|
+
}
|
|
25
|
+
/** Absolute path this provider is rooted at. */
|
|
26
|
+
getRootPath() {
|
|
27
|
+
return this.rootPath;
|
|
28
|
+
}
|
|
29
|
+
readFile(path) {
|
|
30
|
+
return getHostFs().readFile(this.rootPath, path);
|
|
31
|
+
}
|
|
32
|
+
writeFile(path, content) {
|
|
33
|
+
return getHostFs().writeFile(this.rootPath, path, content);
|
|
34
|
+
}
|
|
35
|
+
delete(path) {
|
|
36
|
+
return getHostFs().delete(this.rootPath, path);
|
|
37
|
+
}
|
|
38
|
+
rename(oldPath, newPath) {
|
|
39
|
+
return getHostFs().rename(this.rootPath, oldPath, newPath);
|
|
40
|
+
}
|
|
41
|
+
readDirectory(path) {
|
|
42
|
+
return getHostFs().readDirectory(this.rootPath, path);
|
|
43
|
+
}
|
|
44
|
+
exists(path) {
|
|
45
|
+
return getHostFs().exists(this.rootPath, path);
|
|
46
|
+
}
|
|
47
|
+
createDirectory(path) {
|
|
48
|
+
return getHostFs().createDirectory(this.rootPath, path);
|
|
49
|
+
}
|
|
50
|
+
stat(path) {
|
|
51
|
+
return getHostFs().stat(this.rootPath, path);
|
|
52
|
+
}
|
|
53
|
+
readBinary(path) {
|
|
54
|
+
return getHostFs().readBinary(this.rootPath, path);
|
|
55
|
+
}
|
|
56
|
+
writeBinary(path, data) {
|
|
57
|
+
return getHostFs().writeBinary(this.rootPath, path, data);
|
|
58
|
+
}
|
|
59
|
+
/** Subscribe to external change notifications under this root. */
|
|
60
|
+
watch(onChange) {
|
|
61
|
+
return getHostFs().watch(this.rootPath, onChange);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=electron-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"electron-provider.js","sourceRoot":"","sources":["../../src/filesystem/electron-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,SAAS,SAAS;IAChB,MAAM,IAAI,GAAG,qBAAqB,EAAE,CAAC;IACrC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,0FAA0F,CAC3F,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC,EAAE,CAAC;AACjB,CAAC;AAED,MAAM,OAAO,0BAA0B;IAMrC,YAAY,EAAU,EAAE,KAAa,EAAE,QAAgB;QACrD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,gDAAgD;IAChD,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,OAAO,SAAS,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;I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AAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createFileMediaProvider — per-file media storage following the pandoc /
|
|
3
|
+
* Word convention: a markdown file `notes.md` gets a sibling folder
|
|
4
|
+
* `notes_files/` that holds its images, audio, and video.
|
|
5
|
+
*
|
|
6
|
+
* Given:
|
|
7
|
+
* • `container` — a ContentContainer scoped to the markdown file's
|
|
8
|
+
* parent directory (so `readFile('notes_files/image.png')` maps to the
|
|
9
|
+
* parent-relative path)
|
|
10
|
+
* • `markdownBasename` — e.g. `"notes.md"`
|
|
11
|
+
*
|
|
12
|
+
* Returns a MediaProvider that:
|
|
13
|
+
* • Writes new media under `{basename}_files/{name}` in the parent dir
|
|
14
|
+
* • Returns the folder-qualified path (`notes_files/image.png`) from
|
|
15
|
+
* addMedia so the markdown stays portable outside DocBlocks
|
|
16
|
+
* • Resolves both bare (`image.png`) and folder-qualified
|
|
17
|
+
* (`notes_files/image.png`) references — so legacy markdown and
|
|
18
|
+
* exports from other tools both work
|
|
19
|
+
*/
|
|
20
|
+
import type { MediaProvider } from '@bendyline/squisq/schemas';
|
|
21
|
+
import type { ContentContainer } from '@bendyline/squisq/storage';
|
|
22
|
+
export declare function createFileMediaProvider(container: ContentContainer, markdownBasename: string): MediaProvider;
|
|
23
|
+
//# sourceMappingURL=file-media-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-media-provider.d.ts","sourceRoot":"","sources":["../../src/filesystem/file-media-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,2BAA2B,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAMlE,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,gBAAgB,EAC3B,gBAAgB,EAAE,MAAM,GACvB,aAAa,CAwEf"}
|