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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: |
micromamba activate untarjs

yarn run build:prod
yarn run build

- name: Run eslint
run: |
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ In order to make a new release:
- Commit the change with the message "Release x.x.x" on the `main` branch
- Create a tag `git tag x.x.x`
- Push the new commit and the tag `git push https://github.com/emscripten-forge/untarjs main x.x.x`
- Build and publish `git clean -fdx && yarn && yarn run build:prod && npm publish`
- Build and publish `git clean -fdx && yarn && yarn run build && npm publish`
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "yarn run clean && tsc && yarn run build:wasm && copyfiles -u 1 \"src/**/*.d.ts\" lib",
"build:wasm": "node build_wasm.js",
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
"build": "yarn run clean && tsc && yarn run build:wasm",
"build:prod": "yarn run clean && tsc && yarn run build:wasm",
"prettier": "prettier --list-different --write \"src/**/*.ts\"",
"prettier:check": "prettier --check \"src/**/*.ts\"",
"eslint": "eslint --ext .ts --fix .",
Expand Down Expand Up @@ -44,9 +43,11 @@
},
"devDependencies": {
"@eslint/js": "^9.13.0",
"@types/copyfiles": "^2",
"@types/node": "^22.8.1",
"@typescript-eslint/eslint-plugin": "~6.13.2",
"@typescript-eslint/parser": "~6.13.2",
"copyfiles": "^2.4.1",
"eslint": "~8.55.0",
"eslint-config-prettier": "~9.1.0",
"eslint-plugin-prettier": "~5.0.1",
Expand Down
5 changes: 4 additions & 1 deletion src/helper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import unpack, { IWasmModule } from './unpack';
import unpackWasm from './unpack.wasm';

const initializeWasm = async (): Promise<IWasmModule> => {
const initializeWasm = async (locateWasm?: (file: string) => string): Promise<IWasmModule> => {
const wasmModule: IWasmModule = await unpack({
locateFile(path: string) {
if (path.endsWith('.wasm')) {
if (locateWasm) {
return locateWasm(path);
}
return unpackWasm;
}
return path;
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import initializeWasm from './helper';
import { FilesData, IUnpackJSAPI } from './types';

const fetchByteArray = async (url: string): Promise<Uint8Array> => {
export const fetchByteArray = async (url: string): Promise<Uint8Array> => {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
Expand All @@ -10,8 +10,8 @@ const fetchByteArray = async (url: string): Promise<Uint8Array> => {
return new Uint8Array(arrayBuffer);
};

export const initUntarJS = async (): Promise<IUnpackJSAPI> => {
const wasmModule = await initializeWasm();
export const initUntarJS = async (locateWasm?: (file: string) => string): Promise<IUnpackJSAPI> => {
const wasmModule = await initializeWasm(locateWasm);

const extractData = async (
data: Uint8Array,
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type FilesData = { [filename: string]: Uint8Array };

export interface IUnpackJSAPI {
extractData: (data: Uint8Array) => Promise<FilesData>;
extractData: (data: Uint8Array, decompressionOnly?: boolean) => Promise<FilesData>;
extract: (url: string) => Promise<FilesData>;
}
Loading