@helia/unixfs 5.0.3 → 5.0.4-7d471a02
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 +29 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/index.d.ts +29 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +29 -0
- package/dist/src/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +29 -0
- package/dist/typedoc-urls.json +0 -76
package/README.md
CHANGED
|
@@ -74,6 +74,35 @@ for await (const entry of fs.addAll(globSource('path/to/containing/dir', 'glob-p
|
|
|
74
74
|
}
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
+
## Example - Adding files and directories in the browser
|
|
78
|
+
|
|
79
|
+
Uses [@cypsela/browser-source](https://github.com/cypsela/browser-source) to read [FileSystemEntry](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemEntry) and [FileSystemHandle](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle) files and directories.
|
|
80
|
+
|
|
81
|
+
Instances of these data types are available from drag and drop events and window methods like [showOpenFilePicker](https://developer.mozilla.org/en-US/docs/Web/API/Window/showOpenFilePicker).
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { createHelia } from 'helia'
|
|
85
|
+
import { unixfs } from '@helia/unixfs'
|
|
86
|
+
import { fsEntrySource, fsHandleSource } from '@cypsela/browser-source'
|
|
87
|
+
|
|
88
|
+
const helia = await createHelia()
|
|
89
|
+
const fs = unixfs(helia)
|
|
90
|
+
|
|
91
|
+
// get FileSystemEntry from drag and drop events
|
|
92
|
+
const fileEntry = {} as FileSystemEntry
|
|
93
|
+
|
|
94
|
+
for await (const entry of fs.addAll(fsEntrySource(fileEntry))) {
|
|
95
|
+
console.info(entry)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// get FileSystemHandle from drag and drop events or window methods
|
|
99
|
+
const fileHandle = {} as FileSystemHandle
|
|
100
|
+
|
|
101
|
+
for await (const entry of fs.addAll(fsHandleSource(fileHandle))) {
|
|
102
|
+
console.info(entry)
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
77
106
|
# Install
|
|
78
107
|
|
|
79
108
|
```console
|