@b9g/filesystem 0.1.4 → 0.1.5
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 +35 -22
- package/package.json +2 -27
- package/src/bun-s3.d.ts +48 -47
- package/src/bun-s3.js +212 -185
- package/src/index.d.ts +212 -6
- package/src/index.js +335 -17
- package/src/memory.d.ts +70 -12
- package/src/memory.js +189 -171
- package/src/node.d.ts +25 -58
- package/src/node.js +100 -218
- package/src/directory-storage.d.ts +0 -50
- package/src/directory-storage.js +0 -74
- package/src/registry.d.ts +0 -52
- package/src/registry.js +0 -79
- package/src/types.d.ts +0 -31
- package/src/types.js +0 -1
package/README.md
CHANGED
|
@@ -244,45 +244,58 @@ router.post('/upload', async (request) => {
|
|
|
244
244
|
});
|
|
245
245
|
```
|
|
246
246
|
|
|
247
|
+
## Exports
|
|
248
|
+
|
|
249
|
+
### Classes
|
|
250
|
+
|
|
251
|
+
- `ShovelFileHandle` - FileSystemFileHandle implementation
|
|
252
|
+
- `ShovelDirectoryHandle` - FileSystemDirectoryHandle implementation
|
|
253
|
+
- `ShovelHandle` - Base handle class
|
|
254
|
+
- `CustomBucketStorage` - Bucket storage with custom backend factories
|
|
255
|
+
|
|
256
|
+
### Types
|
|
257
|
+
|
|
258
|
+
- `Bucket` - Alias for FileSystemDirectoryHandle
|
|
259
|
+
- `BucketStorage` - Interface for bucket storage (`open(name): Promise<FileSystemDirectoryHandle>`)
|
|
260
|
+
- `BucketFactory` - Factory function type for creating bucket backends
|
|
261
|
+
- `FileSystemConfig` - Configuration for filesystem backends
|
|
262
|
+
- `FileSystemPermissionDescriptor` - Permission descriptor type
|
|
263
|
+
- `FileSystemBackend` - Backend interface for filesystem implementations
|
|
264
|
+
|
|
247
265
|
## API Reference
|
|
248
266
|
|
|
249
|
-
###
|
|
267
|
+
### BucketStorage
|
|
250
268
|
|
|
251
269
|
```typescript
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
270
|
+
interface BucketStorage {
|
|
271
|
+
open(name: string): Promise<FileSystemDirectoryHandle>;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
class CustomBucketStorage implements BucketStorage {
|
|
275
|
+
register(name: string, factory: BucketFactory): void;
|
|
276
|
+
open(name: string): Promise<FileSystemDirectoryHandle>;
|
|
258
277
|
}
|
|
259
278
|
```
|
|
260
279
|
|
|
261
|
-
###
|
|
280
|
+
### FileSystemHandle Interface
|
|
262
281
|
|
|
263
282
|
```typescript
|
|
264
|
-
interface
|
|
265
|
-
getDirectoryHandle(name: string, options?: GetDirectoryOptions): Promise<DirectoryHandle>;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
interface DirectoryHandle {
|
|
283
|
+
interface FileSystemDirectoryHandle {
|
|
269
284
|
kind: 'directory';
|
|
270
285
|
name: string;
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
entries(): AsyncIterableIterator<[string, DirectoryHandle | FileHandle]>;
|
|
286
|
+
getDirectoryHandle(name: string, options?: { create?: boolean }): Promise<FileSystemDirectoryHandle>;
|
|
287
|
+
getFileHandle(name: string, options?: { create?: boolean }): Promise<FileSystemFileHandle>;
|
|
288
|
+
removeEntry(name: string, options?: { recursive?: boolean }): Promise<void>;
|
|
289
|
+
entries(): AsyncIterableIterator<[string, FileSystemDirectoryHandle | FileSystemFileHandle]>;
|
|
276
290
|
keys(): AsyncIterableIterator<string>;
|
|
277
|
-
values(): AsyncIterableIterator<
|
|
291
|
+
values(): AsyncIterableIterator<FileSystemDirectoryHandle | FileSystemFileHandle>;
|
|
278
292
|
}
|
|
279
293
|
|
|
280
|
-
interface
|
|
294
|
+
interface FileSystemFileHandle {
|
|
281
295
|
kind: 'file';
|
|
282
296
|
name: string;
|
|
283
|
-
|
|
284
297
|
getFile(): Promise<File>;
|
|
285
|
-
createWritable(
|
|
298
|
+
createWritable(): Promise<FileSystemWritableFileStream>;
|
|
286
299
|
}
|
|
287
300
|
```
|
|
288
301
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b9g/filesystem",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Universal File System Access API implementations for all platforms",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"devDependencies": {
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"@types/bun": "^1.2.2"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"@types/wicg-file-system-access": "^2023.10.7",
|
|
12
11
|
"@types/node": "^18.0.0"
|
|
13
12
|
},
|
|
14
13
|
"peerDependenciesMeta": {
|
|
@@ -56,30 +55,6 @@
|
|
|
56
55
|
"types": "./src/node.d.ts",
|
|
57
56
|
"import": "./src/node.js"
|
|
58
57
|
},
|
|
59
|
-
"./
|
|
60
|
-
"types": "./src/registry.d.ts",
|
|
61
|
-
"import": "./src/registry.js"
|
|
62
|
-
},
|
|
63
|
-
"./registry.js": {
|
|
64
|
-
"types": "./src/registry.d.ts",
|
|
65
|
-
"import": "./src/registry.js"
|
|
66
|
-
},
|
|
67
|
-
"./types": {
|
|
68
|
-
"types": "./src/types.d.ts",
|
|
69
|
-
"import": "./src/types.js"
|
|
70
|
-
},
|
|
71
|
-
"./types.js": {
|
|
72
|
-
"types": "./src/types.d.ts",
|
|
73
|
-
"import": "./src/types.js"
|
|
74
|
-
},
|
|
75
|
-
"./package.json": "./package.json",
|
|
76
|
-
"./directory-storage": {
|
|
77
|
-
"types": "./src/directory-storage.d.ts",
|
|
78
|
-
"import": "./src/directory-storage.js"
|
|
79
|
-
},
|
|
80
|
-
"./directory-storage.js": {
|
|
81
|
-
"types": "./src/directory-storage.d.ts",
|
|
82
|
-
"import": "./src/directory-storage.js"
|
|
83
|
-
}
|
|
58
|
+
"./package.json": "./package.json"
|
|
84
59
|
}
|
|
85
60
|
}
|
package/src/bun-s3.d.ts
CHANGED
|
@@ -1,46 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Bun S3 implementation
|
|
2
|
+
* Bun S3 filesystem implementation
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Provides S3Bucket (root) and S3FileSystemBackend for storage operations
|
|
5
|
+
* using Bun's native S3 client.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
7
|
+
import { type FileSystemBackend } from "./index.js";
|
|
8
8
|
/**
|
|
9
|
-
* Bun S3
|
|
9
|
+
* S3 storage backend that implements FileSystemBackend using Bun's S3 client
|
|
10
10
|
*/
|
|
11
|
-
export declare class
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
export declare class S3FileSystemBackend implements FileSystemBackend {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(s3Client: any, bucketName: string, prefix?: string);
|
|
14
|
+
stat(path: string): Promise<{
|
|
15
|
+
kind: "file" | "directory";
|
|
16
|
+
} | null>;
|
|
17
|
+
readFile(path: string): Promise<Uint8Array>;
|
|
18
|
+
writeFile(path: string, data: Uint8Array): Promise<void>;
|
|
19
|
+
listDir(path: string): Promise<Array<{
|
|
20
|
+
name: string;
|
|
21
|
+
kind: "file" | "directory";
|
|
22
|
+
}>>;
|
|
23
|
+
createDir(path: string): Promise<void>;
|
|
24
|
+
remove(path: string, recursive?: boolean): Promise<void>;
|
|
15
25
|
}
|
|
16
26
|
/**
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Bun S3 implementation of FileSystemDirectoryHandle
|
|
27
|
+
* S3 bucket - root entry point for S3 filesystem using Bun's S3 client
|
|
28
|
+
* Implements FileSystemDirectoryHandle for S3 object storage
|
|
29
|
+
*
|
|
30
|
+
* Example usage with namespacing:
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const s3 = new S3Client({ ... });
|
|
33
|
+
*
|
|
34
|
+
* // Use in CustomBucketStorage factory for multi-tenancy
|
|
35
|
+
* const buckets = new CustomBucketStorage(async (name) => {
|
|
36
|
+
* return new S3Bucket(
|
|
37
|
+
* s3,
|
|
38
|
+
* "my-company-bucket",
|
|
39
|
+
* `my-app/production/${name}` // Prefix for isolation
|
|
40
|
+
* );
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
36
43
|
*/
|
|
37
|
-
export declare class
|
|
38
|
-
private
|
|
39
|
-
private prefix;
|
|
44
|
+
export declare class S3Bucket implements FileSystemDirectoryHandle {
|
|
45
|
+
#private;
|
|
40
46
|
readonly kind: "directory";
|
|
41
47
|
readonly name: string;
|
|
42
|
-
constructor(s3Client: any,
|
|
43
|
-
prefix: string);
|
|
48
|
+
constructor(s3Client: any, bucketName: string, prefix?: string);
|
|
44
49
|
getFileHandle(name: string, options?: {
|
|
45
50
|
create?: boolean;
|
|
46
51
|
}): Promise<FileSystemFileHandle>;
|
|
@@ -50,22 +55,18 @@ export declare class BunS3FileSystemDirectoryHandle implements FileSystemDirecto
|
|
|
50
55
|
removeEntry(name: string, options?: {
|
|
51
56
|
recursive?: boolean;
|
|
52
57
|
}): Promise<void>;
|
|
53
|
-
resolve(
|
|
54
|
-
entries(): AsyncIterableIterator<[
|
|
58
|
+
resolve(possibleDescendant: FileSystemHandle): Promise<string[] | null>;
|
|
59
|
+
entries(): AsyncIterableIterator<[
|
|
60
|
+
string,
|
|
61
|
+
FileSystemFileHandle | FileSystemDirectoryHandle
|
|
62
|
+
]>;
|
|
55
63
|
keys(): AsyncIterableIterator<string>;
|
|
56
|
-
values(): AsyncIterableIterator<
|
|
64
|
+
values(): AsyncIterableIterator<FileSystemFileHandle | FileSystemDirectoryHandle>;
|
|
65
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<[
|
|
66
|
+
string,
|
|
67
|
+
FileSystemFileHandle | FileSystemDirectoryHandle
|
|
68
|
+
]>;
|
|
57
69
|
isSameEntry(other: FileSystemHandle): Promise<boolean>;
|
|
58
70
|
queryPermission(): Promise<PermissionState>;
|
|
59
71
|
requestPermission(): Promise<PermissionState>;
|
|
60
72
|
}
|
|
61
|
-
/**
|
|
62
|
-
* S3 bucket using Bun's native S3Client
|
|
63
|
-
*/
|
|
64
|
-
export declare class S3Bucket implements Bucket {
|
|
65
|
-
private config;
|
|
66
|
-
private s3Client;
|
|
67
|
-
constructor(s3Client: any, config?: FileSystemConfig);
|
|
68
|
-
getDirectoryHandle(name: string): Promise<FileSystemDirectoryHandle>;
|
|
69
|
-
getConfig(): FileSystemConfig;
|
|
70
|
-
dispose(): Promise<void>;
|
|
71
|
-
}
|