@statewalker/webrun-files-composite 0.10.2 → 0.10.4

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 (2) hide show
  1. package/README.md +25 -4
  2. package/package.json +10 -6
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 filesystems are rarely flat. Workbench-style apps need to combine
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
- ### Architecture
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
- ### Constraints
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.2",
3
+ "version": "0.10.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Composite FilesApi with mount points and access guards",
7
- "homepage": "https://github.com/statewalker/webrun-files",
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,7 +15,8 @@
12
15
  "license": "MIT",
13
16
  "repository": {
14
17
  "type": "git",
15
- "url": "git@github.com:statewalker/webrun-files.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",
@@ -30,16 +34,16 @@
30
34
  "src"
31
35
  ],
32
36
  "dependencies": {
33
- "@statewalker/webrun-files": "^0.10.1"
37
+ "@statewalker/webrun-files": "^0.10.4"
34
38
  },
35
39
  "devDependencies": {
36
40
  "@types/node": "^26.6.4",
37
41
  "rimraf": "^6.1.3",
38
42
  "rolldown": "^1.2.12",
39
43
  "typescript": "^7.0.2",
40
- "vitest": "^5.0.3",
44
+ "vitest": "^4.1.4 || ^5.0.3",
41
45
  "@statewalker/webrun-files-tests": "^3.0.0",
42
- "@statewalker/webrun-files-mem": "^0.10.2"
46
+ "@statewalker/webrun-files-mem": "^0.10.4"
43
47
  },
44
48
  "sideEffects": false,
45
49
  "publishConfig": {