@statewalker/webrun-files-browser 0.7.2 → 0.9.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/dist/browser-files-api.d.ts.map +1 -1
- package/dist/cjs/index.cjs +21 -17
- package/dist/esm/index.js +21 -17
- package/package.json +7 -7
- package/src/browser-files-api.ts +22 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-files-api.d.ts","sourceRoot":"","sources":["../src/browser-files-api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,WAAW,EACX,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAQnC,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,UAAU,EAAE,yBAAyB,CAAC;CACvC;AAED;;;;;;GAMG;AACH,qBAAa,eAAgB,YAAW,QAAQ;IAC9C,OAAO,CAAC,UAAU,CAA4B;
|
|
1
|
+
{"version":3,"file":"browser-files-api.d.ts","sourceRoot":"","sources":["../src/browser-files-api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,WAAW,EACX,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAQnC,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,UAAU,EAAE,yBAAyB,CAAC;CACvC;AAED;;;;;;GAMG;AACH,qBAAa,eAAgB,YAAW,QAAQ;IAC9C,OAAO,CAAC,UAAU,CAA4B;IAE9C,YAAY,OAAO,EAAE,sBAAsB,EAE1C;YAEa,kBAAkB;YAkBlB,aAAa;IAkBpB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,UAAU,CAAC,CA2B1E;IAEK,KAAK,CACT,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC,UAAU,CAAC,GACxD,OAAO,CAAC,IAAI,CAAC,CAoBf;IAEK,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvC;IAEM,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,QAAQ,CAAC,CA0CxE;IAEK,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CA6BxD;IAEK,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG3C;IAEK,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAc3C;IAEK,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA8B3D;IAEK,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA2E3D;CACF;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,eAAe,CAAC,CAGhE"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -83,27 +83,34 @@ var BrowserFilesApi = class {
|
|
|
83
83
|
for await (const [name, handle] of dirHandle.entries()) {
|
|
84
84
|
const entryPath = (0, _statewalker_webrun_files.joinPath)(normalized, name);
|
|
85
85
|
const isDirectory = handle.kind === "directory";
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
let info;
|
|
87
|
+
if (isDirectory) info = {
|
|
88
|
+
kind: "directory",
|
|
88
89
|
name,
|
|
89
|
-
path: entryPath
|
|
90
|
-
lastModified: 0
|
|
90
|
+
path: entryPath
|
|
91
91
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
else {
|
|
93
|
+
let file;
|
|
94
|
+
try {
|
|
95
|
+
file = await handle.getFile();
|
|
96
|
+
} catch {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
info = {
|
|
100
|
+
kind: "file",
|
|
101
|
+
name,
|
|
102
|
+
path: entryPath,
|
|
103
|
+
size: file.size,
|
|
104
|
+
lastModified: file.lastModified
|
|
105
|
+
};
|
|
106
|
+
}
|
|
97
107
|
yield info;
|
|
98
108
|
if (recursive && isDirectory) yield* this.list(entryPath, options);
|
|
99
109
|
}
|
|
100
110
|
}
|
|
101
111
|
async stats(path) {
|
|
102
112
|
const normalized = (0, _statewalker_webrun_files.normalizePath)(path);
|
|
103
|
-
if (normalized === "/") return {
|
|
104
|
-
kind: "directory",
|
|
105
|
-
lastModified: 0
|
|
106
|
-
};
|
|
113
|
+
if (normalized === "/") return { kind: "directory" };
|
|
107
114
|
const fileHandle = await this.getFileHandle(normalized);
|
|
108
115
|
if (fileHandle) try {
|
|
109
116
|
const f = await fileHandle.getFile();
|
|
@@ -115,10 +122,7 @@ var BrowserFilesApi = class {
|
|
|
115
122
|
} catch {
|
|
116
123
|
return;
|
|
117
124
|
}
|
|
118
|
-
if (await this.getDirectoryHandle(normalized)) return {
|
|
119
|
-
kind: "directory",
|
|
120
|
-
lastModified: 0
|
|
121
|
-
};
|
|
125
|
+
if (await this.getDirectoryHandle(normalized)) return { kind: "directory" };
|
|
122
126
|
}
|
|
123
127
|
async exists(path) {
|
|
124
128
|
return await this.stats(path) !== void 0;
|
package/dist/esm/index.js
CHANGED
|
@@ -82,27 +82,34 @@ var BrowserFilesApi = class {
|
|
|
82
82
|
for await (const [name, handle] of dirHandle.entries()) {
|
|
83
83
|
const entryPath = joinPath(normalized, name);
|
|
84
84
|
const isDirectory = handle.kind === "directory";
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
let info;
|
|
86
|
+
if (isDirectory) info = {
|
|
87
|
+
kind: "directory",
|
|
87
88
|
name,
|
|
88
|
-
path: entryPath
|
|
89
|
-
lastModified: 0
|
|
89
|
+
path: entryPath
|
|
90
90
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
else {
|
|
92
|
+
let file;
|
|
93
|
+
try {
|
|
94
|
+
file = await handle.getFile();
|
|
95
|
+
} catch {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
info = {
|
|
99
|
+
kind: "file",
|
|
100
|
+
name,
|
|
101
|
+
path: entryPath,
|
|
102
|
+
size: file.size,
|
|
103
|
+
lastModified: file.lastModified
|
|
104
|
+
};
|
|
105
|
+
}
|
|
96
106
|
yield info;
|
|
97
107
|
if (recursive && isDirectory) yield* this.list(entryPath, options);
|
|
98
108
|
}
|
|
99
109
|
}
|
|
100
110
|
async stats(path) {
|
|
101
111
|
const normalized = normalizePath(path);
|
|
102
|
-
if (normalized === "/") return {
|
|
103
|
-
kind: "directory",
|
|
104
|
-
lastModified: 0
|
|
105
|
-
};
|
|
112
|
+
if (normalized === "/") return { kind: "directory" };
|
|
106
113
|
const fileHandle = await this.getFileHandle(normalized);
|
|
107
114
|
if (fileHandle) try {
|
|
108
115
|
const f = await fileHandle.getFile();
|
|
@@ -114,10 +121,7 @@ var BrowserFilesApi = class {
|
|
|
114
121
|
} catch {
|
|
115
122
|
return;
|
|
116
123
|
}
|
|
117
|
-
if (await this.getDirectoryHandle(normalized)) return {
|
|
118
|
-
kind: "directory",
|
|
119
|
-
lastModified: 0
|
|
120
|
-
};
|
|
124
|
+
if (await this.getDirectoryHandle(normalized)) return { kind: "directory" };
|
|
121
125
|
}
|
|
122
126
|
async exists(path) {
|
|
123
127
|
return await this.stats(path) !== void 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statewalker/webrun-files-browser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Browser File System Access API implementation for webrun-files",
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
"src"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@statewalker/webrun-files": "^0.
|
|
32
|
+
"@statewalker/webrun-files": "^0.9.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@types/node": "^
|
|
35
|
+
"@types/node": "^26.2.0",
|
|
36
36
|
"native-file-system-adapter": "^3.0.1",
|
|
37
37
|
"rimraf": "^6.1.3",
|
|
38
|
-
"rolldown": "^1.
|
|
39
|
-
"typescript": "^
|
|
40
|
-
"vitest": "^4.1.
|
|
41
|
-
"@statewalker/webrun-files-tests": "
|
|
38
|
+
"rolldown": "^1.2.4",
|
|
39
|
+
"typescript": "^7.0.2",
|
|
40
|
+
"vitest": "^4.1.10",
|
|
41
|
+
"@statewalker/webrun-files-tests": "2.0.0"
|
|
42
42
|
},
|
|
43
43
|
"sideEffects": false,
|
|
44
44
|
"publishConfig": {
|
package/src/browser-files-api.ts
CHANGED
|
@@ -147,22 +147,29 @@ export class BrowserFilesApi implements FilesApi {
|
|
|
147
147
|
const entryPath = joinPath(normalized, name);
|
|
148
148
|
const isDirectory = handle.kind === "directory";
|
|
149
149
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
name,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
150
|
+
let info: FileInfo;
|
|
151
|
+
if (isDirectory) {
|
|
152
|
+
info = { kind: "directory", name, path: entryPath };
|
|
153
|
+
} else {
|
|
154
|
+
// A file must report both a size and a time, so the `File` behind the
|
|
155
|
+
// handle has to be obtained before the entry can be yielded at all.
|
|
156
|
+
// `getFile()` rejects when the entry was removed between the directory
|
|
157
|
+
// read and this call, or when permission was revoked mid-iteration;
|
|
158
|
+
// either way there is no file left to describe, and skipping it is
|
|
159
|
+
// the same answer a listing taken a moment later would have given.
|
|
160
|
+
let file: File;
|
|
158
161
|
try {
|
|
159
|
-
|
|
160
|
-
const file = await fileHandle.getFile();
|
|
161
|
-
info.size = file.size;
|
|
162
|
-
info.lastModified = file.lastModified;
|
|
162
|
+
file = await (handle as FileSystemFileHandle).getFile();
|
|
163
163
|
} catch {
|
|
164
|
-
|
|
164
|
+
continue;
|
|
165
165
|
}
|
|
166
|
+
info = {
|
|
167
|
+
kind: "file",
|
|
168
|
+
name,
|
|
169
|
+
path: entryPath,
|
|
170
|
+
size: file.size,
|
|
171
|
+
lastModified: file.lastModified,
|
|
172
|
+
};
|
|
166
173
|
}
|
|
167
174
|
|
|
168
175
|
yield info;
|
|
@@ -177,10 +184,7 @@ export class BrowserFilesApi implements FilesApi {
|
|
|
177
184
|
const normalized = normalizePath(path);
|
|
178
185
|
|
|
179
186
|
if (normalized === "/") {
|
|
180
|
-
return {
|
|
181
|
-
kind: "directory",
|
|
182
|
-
lastModified: 0,
|
|
183
|
-
};
|
|
187
|
+
return { kind: "directory" };
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
// Try as file first
|
|
@@ -201,10 +205,7 @@ export class BrowserFilesApi implements FilesApi {
|
|
|
201
205
|
// Try as directory
|
|
202
206
|
const dirHandle = await this.getDirectoryHandle(normalized);
|
|
203
207
|
if (dirHandle) {
|
|
204
|
-
return {
|
|
205
|
-
kind: "directory",
|
|
206
|
-
lastModified: 0,
|
|
207
|
-
};
|
|
208
|
+
return { kind: "directory" };
|
|
208
209
|
}
|
|
209
210
|
|
|
210
211
|
return undefined;
|