@yaks/file 0.0.0-stage → 0.2.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +121 -2
  3. package/_dist/blobs.d.ts +16 -0
  4. package/_dist/blobs.d.ts.map +1 -0
  5. package/_dist/io.d.ts +148 -0
  6. package/_dist/io.d.ts.map +1 -0
  7. package/_dist/local.d.ts +18 -0
  8. package/_dist/local.d.ts.map +1 -0
  9. package/_dist/mod.d.ts +27 -0
  10. package/_dist/mod.d.ts.map +1 -0
  11. package/_dist/occupancy.d.ts +207 -0
  12. package/_dist/occupancy.d.ts.map +1 -0
  13. package/_dist/service.d.ts +31 -0
  14. package/_dist/service.d.ts.map +1 -0
  15. package/_dist/views.d.ts +24 -0
  16. package/_dist/views.d.ts.map +1 -0
  17. package/_dist/vocab.d.ts +9 -0
  18. package/_dist/vocab.d.ts.map +1 -0
  19. package/blobs.js +47 -0
  20. package/blobs.js.map +1 -0
  21. package/blobs.ts +52 -0
  22. package/deno.json +1 -0
  23. package/io.js +361 -0
  24. package/io.js.map +1 -0
  25. package/io.ts +528 -0
  26. package/local.js +105 -0
  27. package/local.js.map +1 -0
  28. package/local.ts +91 -0
  29. package/measure.js +88 -0
  30. package/measure.js.map +1 -0
  31. package/measure.ts +109 -0
  32. package/mod.js +86 -0
  33. package/mod.js.map +1 -0
  34. package/mod.ts +84 -0
  35. package/occupancy.js +256 -0
  36. package/occupancy.js.map +1 -0
  37. package/occupancy.ts +341 -0
  38. package/package.json +54 -4
  39. package/page.js +296 -0
  40. package/page.js.map +1 -0
  41. package/page.ts +444 -0
  42. package/service.js +116 -0
  43. package/service.js.map +1 -0
  44. package/service.ts +155 -0
  45. package/upkeep.js +52 -0
  46. package/upkeep.js.map +1 -0
  47. package/upkeep.ts +78 -0
  48. package/views.js +27 -0
  49. package/views.js.map +1 -0
  50. package/views.ts +25 -0
  51. package/vocab.js +19 -0
  52. package/vocab.js.map +1 -0
  53. package/vocab.json +163 -0
  54. package/vocab.ts +20 -0
@@ -0,0 +1,207 @@
1
+ /**
2
+ * What fills a volume, as a look at it records it:
3
+ * `occupancy{volume, day, at, size, used, free, counted, paths}`, one row a
4
+ * volume a UTC day. Here is reading a run
5
+ * of them the way the Disks page does: what a directory holds, what is too
6
+ * small to list, which directories are drawn open, the largest files, the
7
+ * change between two looks, and which file is the graph's own. Pure; looking
8
+ * is ./service.ts, drawing ./page.ts.
9
+ *
10
+ * @module
11
+ */ import type { Bundle, Eid } from "@yaks/graph";
12
+ /** A look at a volume. */ export type Occupancy = {
13
+ volume: Eid;
14
+ day: string;
15
+ at: string;
16
+ size: number;
17
+ used: number;
18
+ free: number;
19
+ counted: number;
20
+ paths: Record<string, number>;
21
+ };
22
+ /** A filesystem this computer keeps files on, at its mount. */ export type Disk = {
23
+ mount: string;
24
+ size: number;
25
+ used: number;
26
+ free: number;
27
+ };
28
+ /** What a walk of a volume counted. */ export type Walk = Pick<Occupancy, 'counted' | 'paths'>;
29
+ /** The entity a volume's day is: the eid `occupancy{volume, day}` derives. */ export declare let occupancyOf: (volume: Eid, day: string) => Eid;
30
+ /** A bundle's `occupancy`, if it has one. */ export declare let occupancyIn: (b?: Bundle) => Occupancy | undefined;
31
+ /** The share of a volume a path takes to be listed: a thousandth. */ export declare let SHARE: any;
32
+ /** The fewest bytes a path on a volume of `size` bytes holds to be listed. */ export declare let listed: (size: number) => number;
33
+ /**
34
+ * What `du -0 -B1` printed: each path it listed, with its bytes.
35
+ *
36
+ * ```ts
37
+ * import { entries } from './occupancy.ts'
38
+ * import { equal } from '@yaks/testing'
39
+ *
40
+ * equal(entries('300\t/home/a.db\x00900\t/home\x00'), [[300, '/home/a.db'], [900, '/home']])
41
+ * ```
42
+ */ export declare let entries: (out: string) => [bytes: number, absolute: string][];
43
+ /**
44
+ * A walk under `mount`, from what `du` listed and which of those paths are
45
+ * directories: the bytes counted under the mount, and each path below it from
46
+ * the mount, a directory's ending in `/`.
47
+ *
48
+ * ```ts
49
+ * import { walked } from './occupancy.ts'
50
+ * import { equal } from '@yaks/testing'
51
+ *
52
+ * let found: [number, string][] = [[300, '/home/a.db'], [900, '/home'], [1000, '/']]
53
+ * equal(walked(found, '/', new Set(['/home', '/'])), {
54
+ * counted: 1000,
55
+ * paths: { 'home/a.db': 300, 'home/': 900 },
56
+ * })
57
+ * ```
58
+ */ export declare let walked: (found: [bytes: number, absolute: string][], mount: string, dirs: Set<string>) => Walk;
59
+ /** The directory a path is listed in; `''` is the mount. */ export declare let parent: (path: string) => string;
60
+ /** A path's own name, a directory's ending in `/`. */ export declare let named: (path: string) => string;
61
+ /** Whether a listed path is a directory. */ export declare let directory: (path: string) => boolean;
62
+ /** The bytes a path holds: `''`, the mount, holds what the walk counted. */ export declare let held: (o: Walk, path: string) => number;
63
+ /**
64
+ * What a directory holds: the paths listed in it, largest first, and the
65
+ * bytes of everything in it too small to list.
66
+ *
67
+ * ```ts
68
+ * import { within } from './occupancy.ts'
69
+ * import { equal } from '@yaks/testing'
70
+ *
71
+ * let o = { counted: 1000, paths: { 'home/': 900, 'home/a.db': 300, 'home/b/': 500, 'usr/': 80 } }
72
+ * equal(within(o, ''), { listed: [['home/', 900], ['usr/', 80]], rest: 20 })
73
+ * equal(within(o, 'home/'), { listed: [['home/b/', 500], ['home/a.db', 300]], rest: 100 })
74
+ * ```
75
+ */ export declare let within: (o: Walk, dir: string) => {
76
+ listed: [string, number][];
77
+ rest: number;
78
+ };
79
+ /** The share of what is used a directory holds to be drawn open by itself. */ export declare let OPEN: any;
80
+ /**
81
+ * Whether a directory is drawn open: as the person left it, or else when it
82
+ * holds a tenth of what is used.
83
+ *
84
+ * ```ts
85
+ * import { opens } from './occupancy.ts'
86
+ * import { equal } from '@yaks/testing'
87
+ *
88
+ * equal([opens(undefined, 70, 600), opens(undefined, 50, 600)], [true, false])
89
+ * equal([opens(false, 500, 600), opens(true, 5, 600)], [false, true])
90
+ * ```
91
+ */ export declare let opens: (chosen: boolean | undefined, bytes: number, used: number) => boolean;
92
+ /**
93
+ * A change in bytes as read: blank where there is none, `new` where the older
94
+ * look did not list the path.
95
+ *
96
+ * ```ts
97
+ * import { change } from './occupancy.ts'
98
+ * import { equal } from '@yaks/testing'
99
+ *
100
+ * equal([change(undefined, false), change(undefined, true), change(0, true)], ['', 'new', ''])
101
+ * equal([change(1e8, true), change(-2e9, true)], ['+100 MB', '−2 GB'])
102
+ * ```
103
+ */ export declare let change: (n: number | undefined, compared: boolean) => string;
104
+ /**
105
+ * The bytes of a path that are free pages, where it is the file the graph
106
+ * keeps its pages in, as the store's day's measurement names it
107
+ * (`kept{file, free}`, @yaks/journal).
108
+ *
109
+ * ```ts
110
+ * import { pagesFree } from './occupancy.ts'
111
+ * import { fileOf } from './mod.ts'
112
+ * import { equal } from '@yaks/testing'
113
+ *
114
+ * let kept = { file: fileOf('v', 'home/.yak/yak.db'), free: 3e9 }
115
+ * equal(pagesFree(kept, 'v', 'home/.yak/yak.db'), 3e9)
116
+ * equal(pagesFree(kept, 'v', 'tmp/copy/yak.db'), undefined)
117
+ * ```
118
+ */ export declare let pagesFree: (kept: {
119
+ file?: string;
120
+ free?: number;
121
+ } | undefined, volume: Eid, path: string) => number | undefined;
122
+ /** A line of a volume's tree: a path listed, or what the directory `path`
123
+ * holds too small to list (`rest`); how deep it sits, its bytes, and whether
124
+ * it is a directory drawn open. */ export type Line = {
125
+ path: string;
126
+ depth: number;
127
+ bytes: number;
128
+ open?: boolean;
129
+ rest?: true;
130
+ };
131
+ /**
132
+ * A volume's tree as lines, from `dir` down: each path listed in it, largest
133
+ * first, an open directory's own lines beneath it, and last what the
134
+ * directory holds too small to list. `open` says which directories are.
135
+ *
136
+ * ```ts
137
+ * import { lines } from './occupancy.ts'
138
+ * import { equal } from '@yaks/testing'
139
+ *
140
+ * let o = { counted: 100, paths: { 'home/': 90, 'home/a.db': 60, 'usr/': 5 } }
141
+ * equal(lines(o, (path) => path == 'home/'), [
142
+ * { path: 'home/', depth: 0, bytes: 90, open: true },
143
+ * { path: 'home/a.db', depth: 1, bytes: 60 },
144
+ * { path: 'home/', depth: 1, bytes: 30, rest: true },
145
+ * { path: 'usr/', depth: 0, bytes: 5, open: false },
146
+ * { path: '', depth: 0, bytes: 5, rest: true },
147
+ * ])
148
+ * ```
149
+ */ export declare let lines: (o: Walk, open: (path: string, bytes: number) => boolean, dir?: string, depth?: number) => Line[];
150
+ /**
151
+ * The largest files listed, largest first.
152
+ *
153
+ * ```ts
154
+ * import { files } from './occupancy.ts'
155
+ * import { equal } from '@yaks/testing'
156
+ *
157
+ * equal(files({ counted: 9, paths: { 'a/': 9, 'a/x': 2, 'a/y': 5 } }, 1), [['a/y', 5]])
158
+ * ```
159
+ */ export declare let files: (o: Walk, n: number) => [string, number][];
160
+ /** The bytes in use the walk did not count: in directories it could not
161
+ * read, or kept by the filesystem itself. */ export declare let uncounted: (o: Pick<Occupancy, 'used' | 'counted'>) => number;
162
+ /**
163
+ * How much a path grew from an older look to a newer one; undefined where
164
+ * the older look did not list it, so nothing is known of what it held then.
165
+ *
166
+ * ```ts
167
+ * import { grew } from './occupancy.ts'
168
+ * import { equal } from '@yaks/testing'
169
+ *
170
+ * let older = { counted: 10, paths: { 'a/': 4 } }
171
+ * let newer = { counted: 16, paths: { 'a/': 9, 'b/': 3 } }
172
+ * equal([grew(older, newer, ''), grew(older, newer, 'a/'), grew(older, newer, 'b/')], [6, 5, undefined])
173
+ * ```
174
+ */ export declare let grew: (older: Walk | undefined, newer: Walk, path: string) => number | undefined;
175
+ /**
176
+ * The look to compare the newest against, from looks newest first: the
177
+ * newest at least `days` older than it, or else the oldest there is.
178
+ *
179
+ * ```ts
180
+ * import { since } from './occupancy.ts'
181
+ * import { equal } from '@yaks/testing'
182
+ *
183
+ * let at = (day: string) => ({ at: `${day}T04:00:00Z` })
184
+ * let looks = [at('2026-10-21'), at('2026-10-15'), at('2026-10-14'), at('2026-10-01')]
185
+ * equal(since(looks, 7), at('2026-10-14'))
186
+ * equal(since(looks.slice(0, 2), 7), at('2026-10-15'))
187
+ * equal(since(looks.slice(0, 1), 7), undefined)
188
+ * ```
189
+ */ export declare let since: <T extends {
190
+ at: string;
191
+ }>(looks: T[], days: number) => T | undefined;
192
+ /**
193
+ * `of`'s growth a day between an older look and a newer one.
194
+ *
195
+ * ```ts
196
+ * import { perDay } from './occupancy.ts'
197
+ * import { equal } from '@yaks/testing'
198
+ *
199
+ * let older = { at: '2026-10-14T04:00:00Z', used: 100 }
200
+ * let newer = { at: '2026-10-21T04:00:00Z', used: 800 }
201
+ * equal(perDay(older, newer, (o) => o.used), 100)
202
+ * equal(perDay(newer, newer, (o) => o.used), undefined)
203
+ * ```
204
+ */ export declare let perDay: <T extends {
205
+ at: string;
206
+ }>(older: T, newer: T, of: (o: T) => number) => number | undefined;
207
+ //# sourceMappingURL=occupancy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"occupancy.d.ts","sources":["../occupancy.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,31 @@
1
+ import type { Graph } from "@yaks/graph";
2
+ import { type Disk, type Walk } from "./occupancy.js";
3
+ /** How long a pass waits for the next, in milliseconds: five minutes, so a
4
+ * disk running low is told within them. A walk still waits for the next day. */ export declare let EVERY: any;
5
+ /** How often the mirror caches are pruned: an hour. */ export declare let AGAIN: any;
6
+ /** How a computer is looked at: its disks, and a walk of one. */ export type Looking = {
7
+ disks: () => Promise<Disk[]>;
8
+ /** what a walk of the filesystem at `mount` counted, listing each path of
9
+ * at least `least` bytes; undefined once `signal` aborts */ walk: (mount: string, least: number, signal?: AbortSignal) => Promise<Walk | undefined>;
10
+ };
11
+ /** This computer, measured through the file API: the disks holding its root
12
+ * and the home directory. */ export declare let computer: Looking;
13
+ /** One pass: walk each of this computer's disks whose day has no look yet,
14
+ * into its day's row. */ export declare let pass: (g: Graph, look?: Looking, now?: number, signal?: AbortSignal) => Promise<void>;
15
+ export type Options = {
16
+ /** milliseconds between passes (default {@link EVERY}) */ every?: number;
17
+ /** the free bytes each disk is kept above; below it the host is told once
18
+ * a spell (default a tenth of the disk) */ floor?: number;
19
+ /** caches laid out by the absolute paths of the files they were made from,
20
+ * such as Deno's `gen/file`, pruned of directories whose files are gone
21
+ * every `AGAIN` */ mirrors?: string[];
22
+ };
23
+ /** Look, then look again every `every`, until the signal aborts. An already
24
+ * aborted signal is one pass. Each pass tells the host of a disk newly below
25
+ * its floor, as a failure: a full disk fails every write on it. */ export declare let service: (host: {
26
+ graph: Graph;
27
+ report?: (error: unknown, context?: {
28
+ tags?: Record<string, string>;
29
+ }) => unknown;
30
+ }, options?: Options, signal?: AbortSignal) => Promise<void>;
31
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sources":["../service.ts"],"names":[],"mappings":"AAoBA,cAAc,KAAK,2BAAgC;AAKnD,SACE,KAAK,IAAI,EAIT,KAAK,IAAI,yBACY;AAEvB;8EAC8E,GAC9E,OAAO,YAAI,WAAqB;AAEhC,qDAAqD,GACrD,OAAO,YAAI,WAAsB;AAEjC,+DAA+D,GAC/D,YAAY;EACV,aAAa,QAAQ;EACrB;4DAC0D,GAC1D,OACE,OAAO,MAAM,EACb,OAAO,MAAM,EACb,SAAS,gBACN,QAAQ,OAAO,SAAS;;AAG/B;2BAC2B,GAC3B,OAAO,YAAI,UAAU,QAMpB;AAED;uBACuB,GACvB,OAAO,YAAI,OACT,GAAG,OACH,OAAM,SACN,MAAK,MAAM,EACX,SAAS,gBACR,QAAQ,IAAI,EAkCd;AAED,YAAY;EACV,wDAAwD,GACxD,QAAQ,MAAM;EACd;2CACyC,GACzC,QAAQ,MAAM;EACd;;mBAEiB,GACjB,UAAU,MAAM;;AAGlB;;iEAEiE,GACjE,OAAO,YAAI,UACT;EACE,OAAO;EACP,UACE,OAAO,OAAO,EACd;IAAY,OAAO,OAAO,MAAM,EAAE,MAAM;QACrC,OAAO;GAEd,UAAS,SACT,SAAQ,gBACP,QAAQ,IAAI,EAwBd"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * What the browsing app draws from this package: a machine's disks, the tab a
3
+ * machine or a volume opens on, and the Disks page the sidebar offers, every
4
+ * disk looked at. The page is loaded when first drawn (./page.ts).
5
+ *
6
+ * @module
7
+ */ import type { View } from "@yaks/inspect";
8
+ // @ts-types="@yaks/ui/lucide"
9
+ import HardDrive from "lucide/dist/esm/icons/hard-drive.mjs";
10
+ /** The page and the tab, loaded when first drawn. */ export declare let inspectViews: () => Promise<View[]>;
11
+ /** The tab a machine or a volume opens on: its disks. */ export declare let tabs: readonly [{
12
+ readonly view: string;
13
+ readonly icon: string;
14
+ }];
15
+ /** The page the sidebar offers: every disk looked at, by machine. */ export declare let destinations: readonly [{
16
+ readonly key: string;
17
+ readonly name: string;
18
+ readonly icon: string;
19
+ readonly view: string;
20
+ }];
21
+ /** The glyph it wears there. */ export declare let icons: {
22
+ readonly 'hard-drive': any;
23
+ };
24
+ //# sourceMappingURL=views.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.d.ts","sources":["../views.ts"],"names":[],"mappings":"AAAA;;;;;;CAMC,GACD,cAAc,IAAI,6BAAkC;AACpD,8BAA8B;AAC9B,OAAO,sDAAgE;AAEvE,mDAAmD,GACnD,OAAO,YAAI,oBAAmB,QAAQ,QACW;AAEjD,uDAAuD,GACvD,OAAO,YAAI;aAAU;aAAe;KAAqB;AAEzD,mEAAmE,GACnE,OAAO,YAAI;aACP;aAAc;aAAe;aAAoB;KACpD;AAED,8BAA8B,GAC9B,OAAO,YAAI;WAAU;EAAyB"}
@@ -0,0 +1,9 @@
1
+ import type { VocabDoc } from "@yaks/vocab";
2
+ /** The file vocabulary: `file{path, root}`, `lines{file, start, end}`,
3
+ * `volume{machine, mount}` and
4
+ * `occupancy{volume, day, at, size, used, free, counted, paths}`, in the form
5
+ * `loadVocab` accepts. */ export declare let fileDoc: VocabDoc;
6
+ /** What this package is: its manifest's description, the one place it is
7
+ * written, which a host stamps on each document here. */ export declare let description: string;
8
+ /** Every document this package declares. */ export declare let docs: VocabDoc[];
9
+ //# sourceMappingURL=vocab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab.d.ts","sources":["../vocab.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,2BAAgC;AAItD;;;wBAGwB,GACxB,OAAO,YAAI,SAAS,SAA0B;AAE9C;uDACuD,GACvD,OAAO,YAAI,aAAa,MAAM,CAAuB;AAErD,0CAA0C,GAC1C,OAAO,YAAI,MAAM,WAAsB"}
package/blobs.js ADDED
@@ -0,0 +1,47 @@
1
+ // The byte store that is a directory: one file per object, named by its
2
+ // address. It is the oldest form of content-addressed storage there is, and it
3
+ // is the right one for large or binary content — nothing reads it but this
4
+ // package, and a filesystem is very good at handing back a big file.
5
+ //
6
+ // It lives here, beside the filesystem boundary, as its own entry
7
+ // (`@yaks/file/blobs`): @yaks/blob itself never loads a filesystem, so a
8
+ // Worker or a browser tab using it never does.
9
+ //
10
+ // No part of the name comes from a caller: the file is named by the address,
11
+ // which this package computes, so no path can escape the directory.
12
+ import { memoryBlobs } from "@yaks/blob/store";
13
+ import { mkdir, readFile, writeFile } from "./io.js";
14
+ /**
15
+ * A {@link Blobs} over a directory: `<dir>/<sha>` holds the bytes stored under
16
+ * `sha`. The directory is created on the first write.
17
+ *
18
+ * ```ts
19
+ * import { fileBlobs } from '@yaks/file/blobs'
20
+ * import { env } from '@yaks/process/env'
21
+ *
22
+ * let store = fileBlobs(`${env.get('HOME')}/.blobs`)
23
+ * ```
24
+ *
25
+ * Asynchronous, so a graph writing through it applies asynchronously.
26
+ */ export let fileBlobs = (dir)=>{
27
+ let at = (sha)=>`${dir}/${sha}`;
28
+ let get = async (sha)=>{
29
+ try {
30
+ return await readFile(at(sha));
31
+ } catch {
32
+ return undefined;
33
+ }
34
+ };
35
+ return {
36
+ get,
37
+ has: async (sha)=>await get(sha) != null,
38
+ put: async (sha, bytes)=>{
39
+ await mkdir(dir, {
40
+ recursive: true
41
+ });
42
+ await writeFile(at(sha), bytes);
43
+ }
44
+ };
45
+ };
46
+ /** The default binary store: beside a file-backed graph, or in memory. */ export let artifactsAt = (path)=>path == ':memory:' ? memoryBlobs() : fileBlobs(path.slice(0, path.lastIndexOf('/') + 1) + 'images');
47
+ //# sourceMappingURL=blobs.js.map
package/blobs.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blobs.js","sources":["./blobs.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,+EAA+E;AAC/E,2EAA2E;AAC3E,qEAAqE;AACrE,EAAE;AACF,kEAAkE;AAClE,yEAAyE;AACzE,+CAA+C;AAC/C,EAAE;AACF,6EAA6E;AAC7E,oEAAoE;AAEpE,SAAqB,WAAW,gCAAqC;AACrE,SAAS,KAAK,EAAE,QAAQ,EAAE,SAAS,kBAAiB;AAEpD;;;;;;;;;;;;CAYC,GACD,OAAO,IAAI,YAAY,CAAC;EACtB,IAAI,KAAK,CAAC,MAAgB,GAAG,IAAI,CAAC,EAAE,KAAK;EACzC,IAAI,MAAM,OAAO;IACf,IAAI;MACF,OAAO,MAAM,SAAS,GAAG;IAC3B,EAAE,OAAM;MACN,OAAO;IACT;EACF;EACA,OAAO;IACL;IACA,KAAK,OAAO,MAAQ,AAAC,MAAM,IAAI,QAAS;IACxC,KAAK,OAAO,KAAK;MACf,MAAM,MAAM,KAAK;QAAE,WAAW;MAAK;MACnC,MAAM,UAAU,GAAG,MAAM;IAC3B;EACF;AACF,EAAC;AAED,wEAAwE,GACxE,OAAO,IAAI,cAAc,CAAC,OACxB,QAAQ,aACJ,gBACA,UAAU,KAAK,KAAK,CAAC,GAAG,KAAK,WAAW,CAAC,OAAO,KAAK,UAAS"}
package/blobs.ts ADDED
@@ -0,0 +1,52 @@
1
+ // The byte store that is a directory: one file per object, named by its
2
+ // address. It is the oldest form of content-addressed storage there is, and it
3
+ // is the right one for large or binary content — nothing reads it but this
4
+ // package, and a filesystem is very good at handing back a big file.
5
+ //
6
+ // It lives here, beside the filesystem boundary, as its own entry
7
+ // (`@yaks/file/blobs`): @yaks/blob itself never loads a filesystem, so a
8
+ // Worker or a browser tab using it never does.
9
+ //
10
+ // No part of the name comes from a caller: the file is named by the address,
11
+ // which this package computes, so no path can escape the directory.
12
+
13
+ import { type Blobs, memoryBlobs } from '@yaks/blob/store'
14
+ import { mkdir, readFile, writeFile } from './io.js'
15
+
16
+ /**
17
+ * A {@link Blobs} over a directory: `<dir>/<sha>` holds the bytes stored under
18
+ * `sha`. The directory is created on the first write.
19
+ *
20
+ * ```ts
21
+ * import { fileBlobs } from '@yaks/file/blobs'
22
+ * import { env } from '@yaks/process/env'
23
+ *
24
+ * let store = fileBlobs(`${env.get('HOME')}/.blobs`)
25
+ * ```
26
+ *
27
+ * Asynchronous, so a graph writing through it applies asynchronously.
28
+ */
29
+ export let fileBlobs = (dir: string): Blobs => {
30
+ let at = (sha: string) => `${dir}/${sha}`
31
+ let get = async (sha: string): Promise<Uint8Array | undefined> => {
32
+ try {
33
+ return await readFile(at(sha))
34
+ } catch {
35
+ return undefined
36
+ }
37
+ }
38
+ return {
39
+ get,
40
+ has: async (sha) => (await get(sha)) != null,
41
+ put: async (sha, bytes) => {
42
+ await mkdir(dir, { recursive: true })
43
+ await writeFile(at(sha), bytes)
44
+ },
45
+ }
46
+ }
47
+
48
+ /** The default binary store: beside a file-backed graph, or in memory. */
49
+ export let artifactsAt = (path: string): Blobs =>
50
+ path == ':memory:'
51
+ ? memoryBlobs()
52
+ : fileBlobs(path.slice(0, path.lastIndexOf('/') + 1) + 'images')
package/deno.json ADDED
@@ -0,0 +1 @@
1
+ {"compilerOptions":{"lib":["deno.ns","dom","esnext"]},"publish":{"exclude":["**/*_test.ts"]},"name":"@yaks/file","version":"0.2.36","license":"Apache-2.0","description":"Files as entities: a path read in a root (a repository's tree, or a volume a machine mounts), the lines of a file an entity sits at, and what fills each volume of a machine, day by day.","exports":{".":"./mod.ts","./vocab":"./vocab.ts","./local":"./local.ts","./occupancy":"./occupancy.ts","./service":"./service.ts","./views":"./views.ts","./io":"./io.ts","./blobs":"./blobs.ts"},"imports":{"@yaks/file":"./mod.ts","@yaks/file/vocab":"./vocab.ts","@yaks/file/local":"./local.ts","@yaks/file/occupancy":"./occupancy.ts","@yaks/file/service":"./service.ts","@yaks/file/views":"./views.ts","@yaks/file/io":"./io.ts","@yaks/file/blobs":"./blobs.ts"}}