@oh-my-pi/hashline 17.2.8 → 17.2.10
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/CHANGELOG.md +6 -0
- package/dist/types/snapshots.d.ts +1 -1
- package/package.json +3 -3
- package/src/fs.ts +8 -8
- package/src/snapshots.ts +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -88,7 +88,7 @@ export interface InMemorySnapshotStoreOptions {
|
|
|
88
88
|
maxTotalBytes?: number;
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
|
-
* In-memory {@link SnapshotStore} backed by
|
|
91
|
+
* In-memory {@link SnapshotStore} backed by a bounded LRU. Per-path history is a
|
|
92
92
|
* short ring of full-file versions (oldest dropped first); per-session path
|
|
93
93
|
* tracking is LRU-bounded so cold paths age out automatically.
|
|
94
94
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/hashline",
|
|
4
|
-
"version": "17.2.
|
|
4
|
+
"version": "17.2.10",
|
|
5
5
|
"description": "Hashline: a compact, line-anchored patch language and applier. Pluggable FS/IO so it works over disk, in-memory, or any custom backend.",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"fmt": "biome format --write ."
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@oh-my-pi/pi-natives": "17.2.
|
|
37
|
-
"
|
|
36
|
+
"@oh-my-pi/pi-natives": "17.2.10",
|
|
37
|
+
"@oh-my-pi/pi-utils": "17.2.10"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/bun": "^1.3.14"
|
package/src/fs.ts
CHANGED
|
@@ -150,11 +150,11 @@ export class InMemoryFilesystem extends Filesystem {
|
|
|
150
150
|
return { text: content };
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
async delete(path: string): Promise<void> {
|
|
153
|
+
override async delete(path: string): Promise<void> {
|
|
154
154
|
if (!this.#files.delete(path)) throw new NotFoundError(path);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
async move(from: string, to: string, content?: string): Promise<void> {
|
|
157
|
+
override async move(from: string, to: string, content?: string): Promise<void> {
|
|
158
158
|
const existing = this.#files.get(from);
|
|
159
159
|
if (existing === undefined) throw new NotFoundError(from);
|
|
160
160
|
const finalContent = content ?? existing;
|
|
@@ -162,7 +162,7 @@ export class InMemoryFilesystem extends Filesystem {
|
|
|
162
162
|
this.#files.delete(from);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
async exists(path: string): Promise<boolean> {
|
|
165
|
+
override async exists(path: string): Promise<boolean> {
|
|
166
166
|
return this.#files.has(path);
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -199,7 +199,7 @@ export class NodeFilesystem extends Filesystem {
|
|
|
199
199
|
return file.text();
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
async readBinary(path: string): Promise<Uint8Array> {
|
|
202
|
+
override async readBinary(path: string): Promise<Uint8Array> {
|
|
203
203
|
try {
|
|
204
204
|
return await fs.readFile(path);
|
|
205
205
|
} catch (error) {
|
|
@@ -213,7 +213,7 @@ export class NodeFilesystem extends Filesystem {
|
|
|
213
213
|
return { text: content };
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
async delete(path: string): Promise<void> {
|
|
216
|
+
override async delete(path: string): Promise<void> {
|
|
217
217
|
try {
|
|
218
218
|
await fs.rm(path);
|
|
219
219
|
} catch (error) {
|
|
@@ -222,7 +222,7 @@ export class NodeFilesystem extends Filesystem {
|
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
async move(from: string, to: string, content?: string): Promise<void> {
|
|
225
|
+
override async move(from: string, to: string, content?: string): Promise<void> {
|
|
226
226
|
if (content !== undefined) {
|
|
227
227
|
await Bun.write(to, content);
|
|
228
228
|
await this.delete(from);
|
|
@@ -236,11 +236,11 @@ export class NodeFilesystem extends Filesystem {
|
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
canonicalPath(path: string): string {
|
|
239
|
+
override canonicalPath(path: string): string {
|
|
240
240
|
return pathModule.resolve(path);
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
async exists(path: string): Promise<boolean> {
|
|
243
|
+
override async exists(path: string): Promise<boolean> {
|
|
244
244
|
return Bun.file(path).exists();
|
|
245
245
|
}
|
|
246
246
|
}
|
package/src/snapshots.ts
CHANGED
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
*
|
|
16
16
|
* The abstract base class lets callers plug in whatever storage they like
|
|
17
17
|
* (LRU, persistent SQLite, etc.). {@link InMemorySnapshotStore} ships as a
|
|
18
|
-
* sensible default backed by
|
|
18
|
+
* sensible default backed by a bounded LRU: a limited set of paths, each with a
|
|
19
19
|
* short history of full-file versions so in-session edit chains can still
|
|
20
20
|
* recover against the version a stale tag names.
|
|
21
21
|
*/
|
|
22
|
-
import { LRUCache } from "
|
|
22
|
+
import { LRUCache } from "@oh-my-pi/pi-utils/lru";
|
|
23
23
|
import { computeFileHash } from "./format";
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -137,7 +137,7 @@ export interface InMemorySnapshotStoreOptions {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
|
-
* In-memory {@link SnapshotStore} backed by
|
|
140
|
+
* In-memory {@link SnapshotStore} backed by a bounded LRU. Per-path history is a
|
|
141
141
|
* short ring of full-file versions (oldest dropped first); per-session path
|
|
142
142
|
* tracking is LRU-bounded so cold paths age out automatically.
|
|
143
143
|
*
|
|
@@ -180,7 +180,7 @@ export class InMemorySnapshotStore extends SnapshotStore {
|
|
|
180
180
|
return history?.find(version => version.text === fullText) ?? null;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
findByHash(hash: string): Snapshot[] {
|
|
183
|
+
override findByHash(hash: string): Snapshot[] {
|
|
184
184
|
const matches: Snapshot[] = [];
|
|
185
185
|
for (const history of this.#versions.values()) {
|
|
186
186
|
for (const version of history) {
|