Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
"build": "rm -rf dist && tsc && pnpm build:lib && pnpm build:lib:cjs && pnpm build:browser && pnpm build:cli && pnpm build:shell && pnpm build:worker && pnpm build:clean && cp dist/index.d.ts dist/index.d.cts && sed '1,/^-->/d' AGENTS.npm.md > dist/AGENTS.md",
"build:clean": "find dist -name '*.test.js' -delete && find dist -name '*.test.d.ts' -delete",
"build:worker": "esbuild src/commands/python3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/python3/worker.js --external:../../../vendor/cpython-emscripten/* && cp src/commands/python3/worker.js dist/commands/python3/worker.js && mkdir -p dist/bin/chunks && cp src/commands/python3/worker.js dist/bin/chunks/worker.js && mkdir -p dist/bundle/chunks && cp src/commands/python3/worker.js dist/bundle/chunks/worker.js && esbuild src/commands/js-exec/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/js-exec/worker.js --external:quickjs-emscripten && cp src/commands/js-exec/worker.js dist/commands/js-exec/worker.js && cp src/commands/js-exec/worker.js dist/bin/chunks/js-exec-worker.js && cp src/commands/js-exec/worker.js dist/bundle/chunks/js-exec-worker.js",
"build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs",
"build:lib:cjs": "esbuild dist/index.js --bundle --platform=node --format=cjs --minify --outfile=dist/bundle/index.cjs --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs",
"build:browser": "esbuild dist/browser.js --bundle --platform=browser --format=esm --minify --outfile=dist/bundle/browser.js --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:node:zlib --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs --define:__BROWSER__=true --alias:node:dns=./src/shims/browser-unsupported.js",
"build:cli": "esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs",
"build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs",
"build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
"build:lib:cjs": "esbuild dist/index.js --bundle --platform=node --format=cjs --minify --outfile=dist/bundle/index.cjs --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
"build:browser": "esbuild dist/browser.js --bundle --platform=browser --format=esm --minify --outfile=dist/bundle/browser.js --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:node:zlib --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --define:__BROWSER__=true --alias:node:dns=./src/shims/browser-unsupported.js",
"build:cli": "esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
"build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
"prepublishOnly": "pnpm validate",
"validate": "pnpm lint && pnpm knip && pnpm typecheck && pnpm build && pnpm check:worker-sync && pnpm test:run && pnpm test:wasm && pnpm test:dist && pnpm test:examples",
"test:examples": "cd examples/cjs-consumer && pnpm install --no-frozen-lockfile && npx tsc --noEmit",
Expand Down Expand Up @@ -105,7 +105,7 @@
"vitest": "^4.0.16"
},
"dependencies": {
"compressjs": "^1.0.3",
"seek-bzip": "^2.0.0",
"diff": "^8.0.2",
"fast-xml-parser": "^5.3.3",
"file-type": "^21.2.0",
Expand Down
38 changes: 13 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/commands/browser-excluded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* is not available.
*/
export const BROWSER_EXCLUDED_COMMANDS: readonly string[] = [
"tar", // Uses native compression modules (@mongodb-js/zstd, node-liblzma, compressjs)
"tar", // Uses native compression modules (@mongodb-js/zstd, node-liblzma, seek-bzip)
"yq", // Requires fast-xml-parser and other Node.js-specific parsing
"xan", // Complex CSV/data processing with Node.js dependencies
"sqlite3", // Uses sql.js (WASM) which requires Node.js worker threads
Expand Down
20 changes: 7 additions & 13 deletions src/commands/tar/archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* with optional gzip, bzip2, and xz compression.
*/

// @ts-expect-error - compressjs doesn't have types
import compressjs from "compressjs";
import {
createGzipDecoder,
createGzipEncoder,
Expand All @@ -16,7 +14,10 @@ import {
type TarHeader,
unpackTar,
} from "modern-tar";
// @ts-expect-error - seek-bzip doesn't have types
import seekBzip from "seek-bzip";
import { DefenseInDepthBox } from "../../security/defense-in-depth-box.js";
import { bzip2Compress } from "./bzip2-compress.js";

// Lazy load node-liblzma since it requires native compilation
// that may fail on some systems (e.g., missing liblzma-dev)
Expand Down Expand Up @@ -353,25 +354,18 @@ export function isXzCompressed(data: Uint8Array): boolean {
}

/**
* bzip2 decompression using compressjs
* bzip2 decompression using seek-bzip (MIT licensed)
*/
async function decompressBzip2(data: Uint8Array): Promise<Uint8Array> {
const Bzip2 = compressjs.Bzip2;
// decompressFile accepts an array/buffer directly
const decompressed = Bzip2.decompressFile(Array.from(data));
const decompressed: Buffer = seekBzip.decode(Buffer.from(data));
return new Uint8Array(decompressed);
}

/**
* bzip2 compression using compressjs
* bzip2 compression using our pure-JS implementation
*/
async function compressBzip2(data: Uint8Array): Promise<Uint8Array> {
const Bzip2 = compressjs.Bzip2;
// compressFile accepts input array and output array directly
// coerceInputStream/coerceOutputStream handle the conversion
const output: number[] = [];
Bzip2.compressFile(Array.from(data), output, 9); // block size level 9
return new Uint8Array(output);
return bzip2Compress(data, 9);
}

/**
Expand Down
Loading
Loading