From ee715234f7b99e7837f4e94a73e2cfa7281a13a4 Mon Sep 17 00:00:00 2001 From: "Dr. Vortex" Date: Wed, 20 Sep 2023 06:51:29 -0500 Subject: [PATCH] Fixed require --- package.json | 8 ++++---- scripts/build.mjs | 12 ++++++------ src/core/utils.ts | 9 ++++----- src/index.ts | 2 ++ tsconfig.json | 3 ++- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index fd747903..ea02e6bd 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "2.0.0", "description": "A filesystem in your browser!", "main": "dist/browserfs.js", - "typings": "dist/browserfs", + "types": "dist", "keywords": [ "filesystem", "node", @@ -28,14 +28,14 @@ "url": "https://github.com/jvilk/BrowserFS/issues" }, "engines": { - "node": ">= 0.10" + "node": ">= 14" }, "bin": { "make_http_index": "./dist/scripts/make_http_index.js" }, "exports": { ".": { - "require": "./dist/browserfs.min.js", + "require": "./dist/browserfs.min.cjs", "import": "./dist/browserfs.min.mjs" } }, @@ -76,4 +76,4 @@ "typedoc": "^0.25.1", "typescript": "^4.9.5" } -} +} \ No newline at end of file diff --git a/scripts/build.mjs b/scripts/build.mjs index 23149df2..12df9611 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -4,7 +4,6 @@ import { polyfillNode } from 'esbuild-plugin-polyfill-node'; const common = { entryPoints: ['src/core/browserfs.ts'], target: ['es6'], - platform: 'browser', globalName: 'BrowserFS', sourcemap: true, bundle: true, @@ -13,11 +12,12 @@ const common = { }; const configs = { - 'browser, unminified': { outfile: 'dist/browserfs.js' }, - 'browser, minified': { outfile: 'dist/browserfs.min.js', minify: true }, - 'ESM, unminified': { outfile: 'dist/browserfs.mjs', format: 'esm' }, - 'ESM, minified': { outfile: 'dist/browserfs.min.mjs', format: 'esm', minify: true }, - node: { outfile: 'dist/browserfs.cjs', platform: 'node', format: 'cjs', minify: true, alias: {}, plugins: [] }, + 'browser, unminified': { outfile: 'dist/browserfs.js', platform: 'browser' }, + 'browser, minified': { outfile: 'dist/browserfs.min.js', platform: 'browser', minify: true }, + 'ESM, unminified': { outfile: 'dist/browserfs.mjs', platform: 'neutral', format: 'esm' }, + 'ESM, minified': { outfile: 'dist/browserfs.min.mjs', platform: 'neutral', format: 'esm', minify: true }, + 'node, unminified': { outfile: 'dist/browserfs.cjs', platform: 'node', format: 'cjs', alias: {}, plugins: [] }, + 'node, minified': { outfile: 'dist/browserfs.min.cjs', platform: 'node', format: 'cjs', minify: true, alias: {}, plugins: [] }, }; for (const [name, config] of Object.entries(configs)) { diff --git a/src/core/utils.ts b/src/core/utils.ts index a640daba..a634a5f4 100644 --- a/src/core/utils.ts +++ b/src/core/utils.ts @@ -51,7 +51,7 @@ export async function bufferValidator(v: object): Promise { */ function _min(d0: number, d1: number, d2: number, bx: number, ay: number): number { - return d0 < d1 || d2 < d1 ? (d0 > d2 ? d2 + 1 : d0 + 1) : bx === ay ? d1 : d1 + 1; + return Math.min(d0 + 1, d1 + 1, d2 + 1, bx === ay ? d1 : d1 + 1); } /** @@ -65,14 +65,13 @@ function levenshtein(a: string, b: string): number { } if (a.length > b.length) { - const tmp = a; - a = b; - b = tmp; + [a, b] = [b, a]; // Swap a and b } let la = a.length; let lb = b.length; + // Trim common suffix while (la > 0 && a.charCodeAt(la - 1) === b.charCodeAt(lb - 1)) { la--; lb--; @@ -80,6 +79,7 @@ function levenshtein(a: string, b: string): number { let offset = 0; + // Trim common prefix while (offset < la && a.charCodeAt(offset) === b.charCodeAt(offset)) { offset++; } @@ -138,7 +138,6 @@ function levenshtein(a: string, b: string): number { return dd; } - /** * Checks that the given options object is valid for the file system options. * @hidden diff --git a/src/index.ts b/src/index.ts index c8eaa9b4..b80bbde1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -188,4 +188,6 @@ export function getFileSystem(config: FileSystemConfiguration, cb?: BFSCallback< export * from './core/backends'; export * from './core/ApiError'; +export * from './generic/key_value_filesystem'; +export * from './generic/inode'; export { EmscriptenFS, FileSystem, BaseFileSystem }; diff --git a/tsconfig.json b/tsconfig.json index 2360884a..e766afcb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,12 +2,13 @@ "compilerOptions": { "module": "es2015", "target": "es2015", - "outDir": "build/temp/library/ts", + "outDir": "dist", "lib": ["dom", "esnext"], "moduleResolution": "node", "sourceMap": true, "inlineSources": true, "declaration": true, + "emitDeclarationOnly": true, "typeRoots": ["node_modules/@types"] }, "include": ["src/**/*"]