From a9c40c669cb5025e850e7535f5fa357b7413f342 Mon Sep 17 00:00:00 2001 From: James P Date: Fri, 22 Mar 2024 15:18:44 -0500 Subject: [PATCH] Fixed IndexedDB.isAvailable not returning true on success Upgraded to core 0.4 Fixed build script --- package-lock.json | 81 ++++++++++++++++++++++++++++++++--------- package.json | 2 +- scripts/build.mjs | 2 +- src/FileSystemAccess.ts | 6 +-- src/IndexedDB.ts | 1 + 5 files changed, 70 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index f344b67..a948c80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,23 +21,51 @@ "node": ">= 18" }, "peerDependencies": { - "@browserfs/core": "^0.3.2" + "@browserfs/core": "^0.4.0" } }, "node_modules/@browserfs/core": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@browserfs/core/-/core-0.3.2.tgz", - "integrity": "sha512-jcnwDmR5x24zdyXGz2bVQ/WmLkrRQQ5qJPAJwQDz52FluThynaG1Eibb7aMr9I6DPos4A9LeLXA5V4cUeyta+A==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@browserfs/core/-/core-0.4.0.tgz", + "integrity": "sha512-ZqWKR//IPiZsrViNVinlfEEwfNwM9SIRm71ImgigXLpWQRL5Zq509o22EZ00KJAFJp6i4a6Mr3gxiJzSM+c4Uw==", "peer": true, "dependencies": { "@types/node": "^14.0.0", "@types/readable-stream": "^4.0.10", + "minimatch": "^9.0.3", "readable-stream": "^4.5.2" }, + "bin": { + "make-index": "scripts/make-index.js" + }, "engines": { "node": ">= 18" } }, + "node_modules/@browserfs/core/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "peer": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@browserfs/core/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "peer": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@esbuild/android-arm": { "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.18.tgz", @@ -606,9 +634,9 @@ "peer": true }, "node_modules/@types/readable-stream": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.10.tgz", - "integrity": "sha512-AbUKBjcC8SHmImNi4yK2bbjogQlkFSg7shZCcicxPQapniOlajG8GCc39lvXzCWX4lLRRs7DM3VAeSlqmEVZUA==", + "version": "4.0.11", + "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.11.tgz", + "integrity": "sha512-R3eUMUTTKoIoaz7UpYLxvZCrOmCRPRbAmoDDHKcimTEySltaJhF8hLzj4+EzyDifiX5eK6oDQGSfmNnXjxZzYQ==", "peer": true, "dependencies": { "@types/node": "*", @@ -1043,8 +1071,7 @@ "node_modules/balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha512-9Y0g0Q8rmSt+H33DfKv7FOc3v+iRI+o1lbzt8jGcIosYW37IIW/2XVYq5NPdmaD5NQ59Nk26Kl/vZbwW9Fr8vg==", - "dev": true + "integrity": "sha512-9Y0g0Q8rmSt+H33DfKv7FOc3v+iRI+o1lbzt8jGcIosYW37IIW/2XVYq5NPdmaD5NQ59Nk26Kl/vZbwW9Fr8vg==" }, "node_modules/base64-js": { "version": "1.5.1", @@ -2497,14 +2524,35 @@ }, "dependencies": { "@browserfs/core": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@browserfs/core/-/core-0.3.2.tgz", - "integrity": "sha512-jcnwDmR5x24zdyXGz2bVQ/WmLkrRQQ5qJPAJwQDz52FluThynaG1Eibb7aMr9I6DPos4A9LeLXA5V4cUeyta+A==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@browserfs/core/-/core-0.4.0.tgz", + "integrity": "sha512-ZqWKR//IPiZsrViNVinlfEEwfNwM9SIRm71ImgigXLpWQRL5Zq509o22EZ00KJAFJp6i4a6Mr3gxiJzSM+c4Uw==", "peer": true, "requires": { "@types/node": "^14.0.0", "@types/readable-stream": "^4.0.10", + "minimatch": "^9.0.3", "readable-stream": "^4.5.2" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "peer": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "peer": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } } }, "@esbuild/android-arm": { @@ -2819,9 +2867,9 @@ "peer": true }, "@types/readable-stream": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.10.tgz", - "integrity": "sha512-AbUKBjcC8SHmImNi4yK2bbjogQlkFSg7shZCcicxPQapniOlajG8GCc39lvXzCWX4lLRRs7DM3VAeSlqmEVZUA==", + "version": "4.0.11", + "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.11.tgz", + "integrity": "sha512-R3eUMUTTKoIoaz7UpYLxvZCrOmCRPRbAmoDDHKcimTEySltaJhF8hLzj4+EzyDifiX5eK6oDQGSfmNnXjxZzYQ==", "peer": true, "requires": { "@types/node": "*", @@ -3102,8 +3150,7 @@ "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha512-9Y0g0Q8rmSt+H33DfKv7FOc3v+iRI+o1lbzt8jGcIosYW37IIW/2XVYq5NPdmaD5NQ59Nk26Kl/vZbwW9Fr8vg==", - "dev": true + "integrity": "sha512-9Y0g0Q8rmSt+H33DfKv7FOc3v+iRI+o1lbzt8jGcIosYW37IIW/2XVYq5NPdmaD5NQ59Nk26Kl/vZbwW9Fr8vg==" }, "base64-js": { "version": "1.5.1", diff --git a/package.json b/package.json index 1e8ca98..0301edd 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,6 @@ "typescript": "5.2.2" }, "peerDependencies": { - "@browserfs/core": "^0.3.2" + "@browserfs/core": "^0.4.0" } } diff --git a/scripts/build.mjs b/scripts/build.mjs index 38ae08f..cc32042 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -27,7 +27,7 @@ const ctx = await context({ } try { - execSync('tsc -p tsconfig.json'); + execSync('npx tsc -p tsconfig.json', { stdio: 'inherit' }); } catch (e) { console.error('status' in e ? e.toString() : e); } diff --git a/src/FileSystemAccess.ts b/src/FileSystemAccess.ts index 58f7aa4..d2d3fd2 100644 --- a/src/FileSystemAccess.ts +++ b/src/FileSystemAccess.ts @@ -136,11 +136,11 @@ export class FileSystemAccessFS extends Async(FileSystem) { throw ApiError.OnPath(ErrorCode.ENOENT, path); } if (handle instanceof FileSystemDirectoryHandle) { - return new Stats(FileType.DIRECTORY, 4096); + return new Stats({ mode: 0o777 | FileType.DIRECTORY, size: 4096 }); } if (handle instanceof FileSystemFileHandle) { const { lastModified, size } = await handle.getFile(); - return new Stats(FileType.FILE, size, null, Date.now(), lastModified); + return new Stats({ mode: 0o777 | FileType.FILE, size, mtimeMs: lastModified }); } } @@ -149,7 +149,7 @@ export class FileSystemAccessFS extends Async(FileSystem) { if (handle instanceof FileSystemFileHandle) { const file = await handle.getFile(); const data = new Uint8Array(await file.arrayBuffer()); - const stats = new Stats(FileType.FILE, file.size, null, Date.now(), file.lastModified); + const stats = new Stats({ mode: 0o777 | FileType.FILE, size: file.size, mtimeMs: file.lastModified }); return new FileSystemAccessFile(this, path, flag, stats, data); } } diff --git a/src/IndexedDB.ts b/src/IndexedDB.ts index 86bc5d1..b53bb38 100644 --- a/src/IndexedDB.ts +++ b/src/IndexedDB.ts @@ -225,6 +225,7 @@ export const IndexedDB: Backend = { } catch (e) { return false; } + return true; }, create({ cacheSize = 100, storeName = 'browserfs', idbFactory = globalThis.indexedDB }: IndexedDBOptions) {