Skip to content

Commit

Permalink
docs: rename adaptor to user agent, add node.js section
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed Aug 30, 2024
1 parent 774542c commit a5a3173
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
44 changes: 24 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
# file-system-access

[File System Access](https://wicg.github.io/file-system-access/) ponyfill for
server side runtime.

This allows the native file dialog and the file system handle API to be used on
the server side.

Complies with
[WICG, File System Access](https://github.com/WICG/file-system-access) and
[File System Standard](https://github.com/whatwg/fs).
[File System Access](https://wicg.github.io/file-system-access/), based on WICG
spec reference implementation.

## Usage

`FileSystemAccess` binds the
[File System Access API](https://wicg.github.io/file-system-access/). The
constructor requires [adaptor](#adaptors).
`createFileSystemAccess` binds the
[File System Access API](https://wicg.github.io/file-system-access/). This
requires [user agent](#user-agent).

```ts
import {
createFileSystemAccess,
type UserAgent,
} from "@miyauci/file-system-access";

declare const agent: UserAgent;
const { showOpenFilePicker } = createFileSystemAccess(agent);
declare const UA: UserAgent;
const { showOpenFilePicker } = createFileSystemAccess(UA);

const [handle] = await showOpenFilePicker();
```

### Adaptors
`createFileSystemAccess` returns the following API:

- [showOpenFilePicker](https://wicg.github.io/file-system-access/#api-showopenfilepicker)
- [showSaveFilePicker](https://wicg.github.io/file-system-access/#api-showsavefilepicker)
- [showDirectoryPicker](https://wicg.github.io/file-system-access/#api-showdirectorypicker)

### User Agent

Adaptor is an abstraction that absorbs runtime differences.
`UserAgent` is different for each runtime. Only execution at the respective
runtime is guaranteed.

#### Deno

```ts
import { UserAgent } from "@miyauci/file-system-access/deno";

const agent = new UserAgent();
const UA = new UserAgent();
```

When using `UserAgent`, the following flags are required.

- `--unstable-ffi`

##### Permissions
##### Permission Flags

It also requires the following permission.

Expand All @@ -54,9 +54,13 @@ It also requires the following permission.
- `--allow-read`(path to binary cache, target directories and files)
- `--allow-write`(path to binary cache, target files)

#### Bun
#### Node.js

// TODO
```ts
import { UserAgent } from "@miyauci/file-system-access/node";

const UA = new UserAgent();
```

## Contributing

Expand Down
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"imports": {
"@miyauci/file-system-access": "./src/mod.ts",
"@miyauci/file-system-access/deno": "./src/deno/mod.ts",
"@miyauci/file-system-access/node": "./src/node/mod.ts",
"@miyauci/format": "jsr:@miyauci/format@^1.1.0",
"@miyauci/fs": "jsr:@miyauci/[email protected]",
"@miyauci/infra": "jsr:@miyauci/infra@^1.0.0",
Expand Down

0 comments on commit a5a3173

Please sign in to comment.