Skip to content

Commit 96ff599

Browse files
authored
Merge branch 'solidjs-community:main' into main
2 parents 96764f6 + 2bac2b3 commit 96ff599

File tree

9 files changed

+62
-22
lines changed

9 files changed

+62
-22
lines changed

.changeset/green-needles-approve.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/filesystem/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @solid-primitives/filesystem
22

3+
## 1.2.0
4+
5+
### Minor Changes
6+
7+
- 15a45a50: filesystem: support for webkitEntries
8+
39
## 1.1.0
410

511
### Minor Changes

packages/filesystem/README.md

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ A primitive that allows to manage different file system access methods:
1616
- `createAsyncFileSystem` - Adds a reactive layer to an asynchronous file system adapter
1717
- `makeNoFileSystem` - Adapter that provides a synchronous mock file system
1818
- `makeNoAsyncFileSystem` - Adapter that provides an asynchronous mock file system
19-
- `makeVirtualFileSystem` - Adapter that provides a virtual file system that doubles as FsMap for `typescript-vfs` with its `.toMap()` method.
20-
- `makeWebAccessFileSystem` (client only) - Adapter that provides access to the actual filesystem in the browser using a directory picker
21-
- `makeNodeFileSystem` (server only) - Adapter that abstracts the node fs/promises module for the use with this primitive
22-
- `makeTauriFileSystem` (tauri with fs access enabled only) - Adapter that connects to the tauri fs module
23-
- `makeChokidarWatcher` - (experimental): use chokidar to watch for file system changes and trigger reactive updates
19+
- `makeVirtualFileSystem` - Adapter that provides a virtual file system that doubles as `FsMap` for `typescript-vfs` with its `.toMap()` method.
20+
- `makeWebAccessFileSystem` (client only) - Adapter that provides access to the actual file system in the browser using a directory picker or a given `webkitEntry` from an input with the `webkitdirectory` attribute set
21+
- `makeNodeFileSystem` (server only) - Adapter that abstracts the node `fs/promises` module for the use with this primitive
22+
- `makeTauriFileSystem` (`tauri` with `fs` access enabled only) - Adapter that connects to the `tauri fs` module
23+
- `makeChokidarWatcher` - (experimental): use `chokidar` to watch for file system changes and trigger reactive updates
2424
- `rsync` - small tool to copy over recursively from one file system or adapter to another
2525

2626
## Installation
@@ -67,13 +67,13 @@ export type AsyncFileSystemAdapter = {
6767

6868
To support an unsupported file system, you can provide a wrapper with one of the same APIs.
6969

70-
If no rename method is given, mkdir/writeFile/rm are used to achieve the same effect. An actual rename call will be more performant, though.
70+
If no `rename` method is given, `mkdir/writeFile/rm` are used to achieve the same effect. An actual `rename` call will be more performant, though.
7171

72-
The `createFileSystem` call then creates a reactive surface above each of these APIs so that the return values of all reading calls are signals for synchronous and resources for asynchronous filesystem adapters; writing methods for asynchronous APIs will return the same promise for convenience reasons.
72+
The `createFileSystem` call then creates a reactive surface above each of these APIs so that the return values of all reading calls are signals for synchronous and resources for asynchronous file system adapters; writing methods for asynchronous APIs will return the same promise for convenience reasons.
7373

74-
There is experimental support for a watcher as second argument in `createFileSystems`, which triggers reactive updates on external filesystem changes. Currently, there is only experimental support for chokidar for the node filesystem.
74+
There is experimental support for a watcher as second argument in `createFileSystems`, which triggers reactive updates on external file system changes. Currently, there is only experimental support for `chokidar` for the node file system.
7575

76-
These getters returned from reading methods are bound to Solid's reactivity so that they will automatically cause effects using them outside of untrack() to re-run on updates. Getters may initially return undefined, but will update to the correct value once evaluated.
76+
These getters returned from reading methods are bound to Solid's reactivity so that they will automatically cause effects using them outside `untrack()` to re-run on updates. Getters may initially return undefined, but will update to the correct value once evaluated.
7777

7878
```tsx
7979
const vfs = makeVirtualFileSystem({});
@@ -129,17 +129,41 @@ const Item = (props: { path: string; fs: SyncFileSystem | AsyncFileSystem }) =>
129129
};
130130
```
131131

132+
### Using `makeWebAccessFileSystem` with a `webkitdirectory` input
133+
134+
The previous `<Item>` component can also be used in combination with a file input with the `webkitdirectory` attribute set:
135+
136+
```tsx
137+
const [webkitEntry, setWebkitEntry] = createSignal();
138+
const fs = createMemo(
139+
() => webkitEntry() && createFileSystem(makeWebAccessFileSystem({ webkitEntry: webkitEntry() })),
140+
);
141+
142+
return (
143+
<>
144+
<input
145+
type="file"
146+
webkitdirectory
147+
onChange={e => setWebkitEntry(e.currentTarget.webkitEntry)}
148+
/>
149+
<Show when={fs()}>
150+
<Item fs={fs()} path="/" />
151+
</Show>
152+
</>
153+
);
154+
```
155+
132156
### rsync
133157

134-
In some cases, you might need to move data from one file system (or adapter) to another one. In order to do so, this package comes with an rsync utility:
158+
In some cases, you might need to move data from one file system (or adapter) to another one. In order to do so, this package comes with a rsync utility:
135159

136160
```ts
137161
rsync(srcFs, srcPath, destFs, destPath): Promise<void>;
138162
```
139163

140164
## Demo
141165

142-
You may view a working example of createFileSystem/makeVirtualFileSystem/makeWebAccessFileSystem here:
166+
You may view a working example of `createFileSystem/makeVirtualFileSystem/makeWebAccessFileSystem` here:
143167
https://primitives.solidjs.community/playground/filesystem/
144168

145169
## Changelog

packages/filesystem/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solid-primitives/filesystem",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "A primitive for convenient file system access.",
55
"author": "Alex Lohr <[email protected]>",
66
"contributors": [],

packages/filesystem/src/adapter-web.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ import { DirEntries } from "./types";
1111
export const makeWebAccessFileSystem = isServer
1212
? () => Promise.resolve(null)
1313
: typeof globalThis.showDirectoryPicker === "function"
14-
? async (options?: DirectoryPickerOptions | undefined) => {
15-
const handle = await globalThis.showDirectoryPicker(options);
14+
? async (
15+
options?: DirectoryPickerOptions | { webkitEntry: FileSystemDirectoryHandle } | undefined,
16+
) => {
17+
const handle =
18+
(options as { webkitEntry: FileSystemDirectoryHandle })?.webkitEntry ||
19+
(await globalThis.showDirectoryPicker(options));
1620
const walk = async (
1721
path: string,
1822
handler: (

packages/map/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @solid-primitives/map
22

3+
## 0.4.6
4+
5+
### Patch Changes
6+
7+
- 52a00ca5: Update `ReactiveSet`/`ReactiveMap` constructors to allow passing any iterable as the initial value.
8+
39
## 0.4.5
410

511
### Patch Changes

packages/map/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solid-primitives/map",
3-
"version": "0.4.5",
3+
"version": "0.4.6",
44
"description": "The Map & WeakMap data structures as a reactive signals.",
55
"author": "Damian Tarnawski @thetarnav <[email protected]>",
66
"license": "MIT",

packages/set/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @solid-primitives/set
22

3+
## 0.4.6
4+
5+
### Patch Changes
6+
7+
- 52a00ca5: Update `ReactiveSet`/`ReactiveMap` constructors to allow passing any iterable as the initial value.
8+
39
## 0.4.5
410

511
### Patch Changes

packages/set/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solid-primitives/set",
3-
"version": "0.4.5",
3+
"version": "0.4.6",
44
"description": "The Set & WeakSet data structures as a reactive signals.",
55
"author": "Damian Tarnawski @thetarnav <[email protected]>",
66
"license": "MIT",

0 commit comments

Comments
 (0)