@vrcalphabet/web-fs 1.0.2 → 2.0.0

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 CHANGED
@@ -11,47 +11,47 @@ TypeScriptで書かれたFile System APIを簡単に操作するためのラッ
11
11
  ### テキストファイルの読み込み
12
12
 
13
13
  ```typescript
14
- import { pickFile } from "@vrcalphabet/web-fs";
14
+ import { isHandle, pickFile } from '@vrcalphabet/web-fs'
15
15
 
16
16
  const handle = await pickFile({
17
17
  types: [
18
18
  {
19
- description: "テキストファイル",
20
- accept: [".txt"],
19
+ description: 'テキストファイル',
20
+ accept: ['.txt'],
21
21
  },
22
22
  ],
23
- });
23
+ })
24
24
 
25
- if (handle) {
26
- const content = await handle.text();
27
- console.log(content);
25
+ if (isHandle(handle)) {
26
+ const content = await handle.text()
27
+ console.log(content)
28
28
  }
29
29
  ```
30
30
 
31
31
  ### ディレクトリ構造の表示
32
32
 
33
33
  ```typescript
34
- import { pickDirectory } from "@vrcalphabet/web-fs";
34
+ import { isHandle, pickDirectory } from '@vrcalphabet/web-fs'
35
35
 
36
- const dirHandle = await pickDirectory();
36
+ const dirHandle = await pickDirectory()
37
37
 
38
- if (dirHandle) {
39
- const tree = await dirHandle.treeString();
40
- console.log(tree);
38
+ if (isHandle(dirHandle)) {
39
+ const tree = await dirHandle.stringifyTree()
40
+ console.log(tree)
41
41
  }
42
42
  ```
43
43
 
44
44
  ### ファイルの作成と書き込み
45
45
 
46
46
  ```typescript
47
- import { pickDirectory } from "@vrcalphabet/web-fs";
47
+ import { isHandle, pickDirectory } from '@vrcalphabet/web-fs'
48
48
 
49
- const dirHandle = await pickDirectory({ mode: "readwrite" });
49
+ const dirHandle = await pickDirectory({ mode: 'readwrite' })
50
50
 
51
- if (dirHandle) {
52
- const fileHandle = await dirHandle.createFile("example.txt");
51
+ if (isHandle(dirHandle)) {
52
+ const fileHandle = await dirHandle.createFile('example.txt')
53
53
  if (fileHandle) {
54
- await fileHandle.write("Hello, World!");
54
+ await fileHandle.write('Hello, World!')
55
55
  }
56
56
  }
57
57
  ```
@@ -59,15 +59,15 @@ if (dirHandle) {
59
59
  ### Globパターンによる検索
60
60
 
61
61
  ```typescript
62
- import { pickDirectory } from "@vrcalphabet/web-fs";
62
+ import { isHandle, pickDirectory } from '@vrcalphabet/web-fs'
63
63
 
64
- const dirHandle = await pickDirectory();
64
+ const dirHandle = await pickDirectory()
65
65
 
66
- if (dirHandle) {
66
+ if (isHandle(dirHandle)) {
67
67
  // srcディレクトリ以下のすべてのtsファイルを取得
68
- const files = await dirHandle.glob("src/**/*.ts");
68
+ const files = await dirHandle.glob('src/**/*.ts')
69
69
  for (const file of files) {
70
- console.log((await file.info()).name);
70
+ console.log((await file.info()).size)
71
71
  }
72
72
  }
73
73
  ```
@@ -75,37 +75,27 @@ if (dirHandle) {
75
75
  ### ハンドルの永続化
76
76
 
77
77
  ```typescript
78
- import { pickFile } from "@vrcalphabet/web-fs";
78
+ import { isHandle, pickFile } from '@vrcalphabet/web-fs'
79
79
 
80
80
  // IDを指定して永続化を有効にする
81
81
  const handle = await pickFile({
82
- id: "my-text-file",
82
+ id: 'my-text-file',
83
83
  persistence: true,
84
- });
84
+ })
85
85
 
86
- if (handle) {
86
+ if (isHandle(handle)) {
87
87
  // 次回以降、同じIDを指定するとピッカーを表示せずにハンドルを取得可能
88
- console.log(await handle.text());
88
+ console.log(await handle.text())
89
89
  }
90
90
  ```
91
91
 
92
92
  ## インストール
93
93
 
94
- ### npm
95
-
96
94
  ```bash
97
95
  npm install @vrcalphabet/web-fs
98
- ```
99
-
100
- ### yarn
101
-
102
- ```bash
96
+ # or
103
97
  yarn add @vrcalphabet/web-fs
104
- ```
105
-
106
- ### pnpm
107
-
108
- ```bash
98
+ # or
109
99
  pnpm add @vrcalphabet/web-fs
110
100
  ```
111
101
 
@@ -129,3 +119,11 @@ MIT License
129
119
  ### v1.0.0 (2026-02-02)
130
120
 
131
121
  - 初回リリース
122
+
123
+ ### v2.0.0 (2026-04-05)
124
+
125
+ - `glob()` の修正 (`web-fs-glob` によるglobパターンでのファイル検索に移行)
126
+ - `isHandle()` / `filterHandle()` の追加 (型ガードユーティリティ)
127
+ - `hash()` のアルゴリズムを追加 (`md5`、`sha1`、`sha256`、`sha384`、`sha512`)
128
+ - `WebFsFileInfo` に `lastModifiedDate` (`Date`型) を追加
129
+ - `treeString()` を `stringifyTree()` にリネーム