Skip to content

Commit

Permalink
Rename Zbar to ZbarInstance
Browse files Browse the repository at this point in the history
Rename the file to better reflect its purpose. Also prevent it to be
conflict with zbar.js because github action artifact is case
insensitive.
  • Loading branch information
samsam2310 committed Dec 12, 2021
1 parent f490f86 commit 2196779
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/CppObject.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import ZBar from './ZBar';
import ZBarInstance from './ZBarInstance';

export class CppObject {
protected ptr: number;
protected inst: ZBar;
protected inst: ZBarInstance;

protected constructor(ptr: number, inst: ZBar) {
protected constructor(ptr: number, inst: ZBarInstance) {
this.ptr = ptr;
this.inst = inst;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ZBar.ts → src/ZBarInstance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default interface ZBar extends Record<string, WebAssembly.ExportValue | ArrayBuffer> {
export default interface ZBarInstance extends Record<string, WebAssembly.ExportValue | ArrayBuffer> {
_malloc(size: number): number;
_free(ptr: number): void;

Expand Down
6 changes: 3 additions & 3 deletions src/instance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { loadWasmInstance } from './load';
import ZBar from './ZBar';
import ZBarInstance from './ZBarInstance';

let inst: ZBar | null = null;
let inst: ZBarInstance | null = null;

let instPromise = (async () => {
inst = await loadWasmInstance({});
Expand All @@ -11,6 +11,6 @@ let instPromise = (async () => {
return inst;
})();

export const getInstance = async (): Promise<ZBar> => {
export const getInstance = async (): Promise<ZBarInstance> => {
return await instPromise;
};
4 changes: 2 additions & 2 deletions src/load-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
// import wasmBinaryFile from './zbar.wasm';
import wasmBinaryFileName from './zbar.wasm.bin';
import ZBar from './ZBar';
import ZBarInstance from './ZBarInstance';
import instantiate from './zbar';

// locateFile is used to override the file path to the path provided by
Expand All @@ -21,7 +21,7 @@ const locateFile = (file: string, _scriptDir: string) => {

export const loadWasmInstance = async (
importObj: any
): Promise<ZBar | null> => {
): Promise<ZBarInstance | null> => {
importObj['locateFile'] = locateFile;
return await instantiate(importObj);
};
4 changes: 2 additions & 2 deletions src/load.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ZBar from './ZBar';
import ZBarInstance from './ZBarInstance';
import instantiate from './zbar';

export const loadWasmInstance = async (
importObj: any
): Promise<ZBar | null> => {
): Promise<ZBarInstance | null> => {
return await instantiate(importObj);
};
4 changes: 2 additions & 2 deletions src/zbar.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import ZBar from './ZBar';
declare const instantiate: (importObj: any) => Promise<ZBar>;
import ZBarInstance from './ZBarInstance';
declare const instantiate: (importObj: any) => Promise<ZBarInstance>;
export default instantiate;

0 comments on commit 2196779

Please sign in to comment.