@statewalker/webrun-files-composite 0.10.0 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -4
- package/package.json +14 -9
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ the types `PathFilter`, `FileGuard`, `FileOperation`, `CowOptions` and
|
|
|
29
29
|
|
|
30
30
|
## Why it exists
|
|
31
31
|
|
|
32
|
-
Real
|
|
32
|
+
Real file systems are rarely flat. Applications need to combine
|
|
33
33
|
storage backends (local FS for projects, in-memory FS for transient data,
|
|
34
34
|
remote FS for shared documents), forbid writes to system folders, and hide
|
|
35
35
|
implementation-detail paths from end users. Implementing all of this inside
|
|
@@ -49,9 +49,13 @@ three concerns are deliberately split across separate classes:
|
|
|
49
49
|
## How to use
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
|
-
pnpm add @statewalker/webrun-files-composite
|
|
52
|
+
pnpm add @statewalker/webrun-files-composite @statewalker/webrun-files
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
One entry point, `@statewalker/webrun-files-composite`: ESM (`dist/esm/index.js`), CommonJS
|
|
56
|
+
(`dist/cjs/index.cjs`), types (`dist/index.d.ts`); sources in `src/`. No runtime-specific
|
|
57
|
+
imports: browsers, workers, Node.js.
|
|
58
|
+
|
|
55
59
|
The decorators all implement `FilesApi`, so they compose freely. A typical
|
|
56
60
|
stack: a composite root that mounts a few backends, wrapped first with a
|
|
57
61
|
filter to hide internals, then with guards to forbid writes to system
|
|
@@ -185,9 +189,26 @@ to gate these flows by composite path:
|
|
|
185
189
|
await fs.move("/cache/draft.md", "/docs/draft.md"); // memFs → s3Fs
|
|
186
190
|
```
|
|
187
191
|
|
|
192
|
+
### Read-only, overlay and copy-on-write views
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
import { cow, overlay, readOnly } from "@statewalker/webrun-files-composite";
|
|
196
|
+
import { MemFilesApi } from "@statewalker/webrun-files-mem";
|
|
197
|
+
|
|
198
|
+
const ro = readOnly(sourceFiles);
|
|
199
|
+
await ro.write("/a.txt", data); // throws "read-only: /a.txt"
|
|
200
|
+
|
|
201
|
+
// userFiles shadows defaultFiles; the union is read-only
|
|
202
|
+
const view = overlay(userFiles, defaultFiles);
|
|
203
|
+
|
|
204
|
+
// Changes land in the MemFilesApi; templateFiles is never modified
|
|
205
|
+
const draft = cow(templateFiles, new MemFilesApi());
|
|
206
|
+
await draft.remove("/obsolete.md"); // recorded as /.wh.obsolete.md in the writable layer
|
|
207
|
+
```
|
|
208
|
+
|
|
188
209
|
## Internals
|
|
189
210
|
|
|
190
|
-
###
|
|
211
|
+
### How the decorators stack
|
|
191
212
|
|
|
192
213
|
```
|
|
193
214
|
+---------------------+
|
|
@@ -255,7 +276,7 @@ multiple operation lists.
|
|
|
255
276
|
| `move` / `copy` | `false` (no side effect) |
|
|
256
277
|
| `write` / `mkdir` | throws `"Path is hidden"` (silent drop would lose data) |
|
|
257
278
|
|
|
258
|
-
###
|
|
279
|
+
### What it refuses, and what is not atomic
|
|
259
280
|
|
|
260
281
|
- The root mount (`/`) is fixed at construction; you cannot remount it.
|
|
261
282
|
- Mount points are immutable — `remove()` on a mount point throws.
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statewalker/webrun-files-composite",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Composite FilesApi with mount points and access guards",
|
|
7
|
-
"
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/statewalker/webrun-files/issues"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/statewalker/webrun-files/tree/main/packages/webrun-files-composite#readme",
|
|
8
11
|
"author": {
|
|
9
12
|
"name": "Mikhail Kotelnikov",
|
|
10
13
|
"email": "mikhail.kotelnikov@gmail.com"
|
|
@@ -12,13 +15,15 @@
|
|
|
12
15
|
"license": "MIT",
|
|
13
16
|
"repository": {
|
|
14
17
|
"type": "git",
|
|
15
|
-
"url": "git
|
|
18
|
+
"url": "git+https://github.com/statewalker/webrun-files.git",
|
|
19
|
+
"directory": "packages/webrun-files-composite"
|
|
16
20
|
},
|
|
17
21
|
"main": "./dist/cjs/index.cjs",
|
|
18
22
|
"module": "./dist/esm/index.js",
|
|
19
23
|
"types": "./dist/index.d.ts",
|
|
20
24
|
"exports": {
|
|
21
25
|
".": {
|
|
26
|
+
"source": "./src/index.ts",
|
|
22
27
|
"types": "./dist/index.d.ts",
|
|
23
28
|
"import": "./dist/esm/index.js",
|
|
24
29
|
"require": "./dist/cjs/index.cjs"
|
|
@@ -29,16 +34,16 @@
|
|
|
29
34
|
"src"
|
|
30
35
|
],
|
|
31
36
|
"dependencies": {
|
|
32
|
-
"@statewalker/webrun-files": "0.10.
|
|
37
|
+
"@statewalker/webrun-files": "^0.10.2"
|
|
33
38
|
},
|
|
34
39
|
"devDependencies": {
|
|
35
|
-
"@types/node": "^26.
|
|
40
|
+
"@types/node": "^26.6.4",
|
|
36
41
|
"rimraf": "^6.1.3",
|
|
37
|
-
"rolldown": "^1.2.
|
|
42
|
+
"rolldown": "^1.2.12",
|
|
38
43
|
"typescript": "^7.0.2",
|
|
39
|
-
"vitest": "^
|
|
40
|
-
"@statewalker/webrun-files-
|
|
41
|
-
"@statewalker/webrun-files-
|
|
44
|
+
"vitest": "^5.0.3",
|
|
45
|
+
"@statewalker/webrun-files-tests": "^3.0.0",
|
|
46
|
+
"@statewalker/webrun-files-mem": "^0.10.3"
|
|
42
47
|
},
|
|
43
48
|
"sideEffects": false,
|
|
44
49
|
"publishConfig": {
|