Skip to content

Commit

Permalink
fix: updated dist folder and some fixes for running lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ujaval403 committed Jul 1, 2024
1 parent 41e390b commit ab172f9
Show file tree
Hide file tree
Showing 31 changed files with 110 additions and 56 deletions.
2 changes: 1 addition & 1 deletion packages/duckdb-wasm/dist/duckdb-browser-blocking.cjs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/duckdb-wasm/dist/duckdb-browser-blocking.cjs.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/duckdb-wasm/dist/duckdb-browser-blocking.mjs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/duckdb-wasm/dist/duckdb-browser-blocking.mjs.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/duckdb-wasm/dist/duckdb-browser-coi.worker.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/duckdb-wasm/dist/duckdb-browser-coi.worker.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/duckdb-wasm/dist/duckdb-browser-eh.worker.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/duckdb-wasm/dist/duckdb-browser-eh.worker.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/duckdb-wasm/dist/duckdb-browser-mvp.worker.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/duckdb-wasm/dist/duckdb-browser-mvp.worker.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/duckdb-wasm/dist/duckdb-browser.cjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/duckdb-wasm/dist/duckdb-browser.cjs.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/duckdb-wasm/dist/duckdb-browser.mjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/duckdb-wasm/dist/duckdb-browser.mjs.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/duckdb-wasm/dist/duckdb-node-blocking.cjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/duckdb-wasm/dist/duckdb-node-blocking.cjs.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/duckdb-wasm/dist/duckdb-node-eh.worker.cjs.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/duckdb-wasm/dist/duckdb-node-mvp.worker.cjs.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/duckdb-wasm/dist/duckdb-node.cjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/duckdb-wasm/dist/duckdb-node.cjs.map

Large diffs are not rendered by default.

68 changes: 55 additions & 13 deletions packages/duckdb-wasm/dist/tests-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -20445,7 +20445,7 @@ return true;`);
throw new Error(`WASM instantiation requested unexpected file: prefix=${prefix} path=${path}`);
}
/** Instantiate the wasm module */
instantiateWasm(imports, success) {
async instantiateWasm(imports, success) {
globalThis.DUCKDB_RUNTIME = this._runtime;
const handlers = this.onInstantiationProgress;
if (WebAssembly.instantiateStreaming) {
Expand Down Expand Up @@ -20481,15 +20481,43 @@ return true;`);
return new Response(response2.body?.pipeThrough(ts), response2);
};
const response = fetchWithProgress();
WebAssembly.instantiateStreaming(response, imports).then((output) => {
success(output.instance, output.module);
});
const initiateStreaming = async () => {
try {
const output = await WebAssembly.instantiateStreaming(response, imports);
success(output.instance, output.module);
} catch (error) {
this.logger.log({
timestamp: /* @__PURE__ */ new Date(),
level: 4 /* ERROR */,
origin: 3 /* BINDINGS */,
topic: 5 /* INSTANTIATE */,
event: 2 /* ERROR */,
value: "Failed to instantiate WASM: " + error
});
throw error;
}
};
await initiateStreaming();
} else {
console.warn("instantiating without progress handler since transform streams are unavailable");
const request = new Request(this.mainModuleURL);
WebAssembly.instantiateStreaming(fetch(request), imports).then((output) => {
success(output.instance, output.module);
});
const initiateStreaming = async () => {
try {
const output = await WebAssembly.instantiateStreaming(fetch(request), imports);
success(output.instance, output.module);
} catch (error) {
this.logger.log({
timestamp: /* @__PURE__ */ new Date(),
level: 4 /* ERROR */,
origin: 3 /* BINDINGS */,
topic: 5 /* INSTANTIATE */,
event: 2 /* ERROR */,
value: "Failed to instantiate WASM: " + error
});
throw error;
}
};
await initiateStreaming();
}
} else if (typeof XMLHttpRequest == "function") {
const xhr = new XMLHttpRequest();
Expand Down Expand Up @@ -20582,12 +20610,26 @@ return true;`);
super(logger, runtime, mainModuleURL, pthreadWorkerURL);
}
/** Instantiate the bindings */
instantiateImpl(moduleOverrides) {
return (0, import_duckdb_eh.default)({
...moduleOverrides,
instantiateWasm: this.instantiateWasm.bind(this),
locateFile: this.locateFile.bind(this)
});
async instantiateImpl(moduleOverrides) {
try {
const wasm = this.instantiateWasm.bind(this);
const locateFile = this.locateFile.bind(this);
return await (0, import_duckdb_eh.default)({
...moduleOverrides,
instantiateWasm: wasm,
locateFile
});
} catch (error) {
this.logger.log({
timestamp: /* @__PURE__ */ new Date(),
level: 4 /* ERROR */,
origin: 3 /* BINDINGS */,
topic: 5 /* INSTANTIATE */,
event: 2 /* ERROR */,
value: "Failed to instantiate WASM: " + error
});
throw error;
}
}
};

Expand Down
4 changes: 2 additions & 2 deletions packages/duckdb-wasm/dist/tests-browser.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions packages/duckdb-wasm/dist/tests-node.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13596,6 +13596,7 @@ var DuckDBNodeBindings = class extends DuckDBBindingsBase {
instantiateImpl(moduleOverrides) {
return (0, import_duckdb_mvp.default)({
...moduleOverrides,
//@ts-ignore
instantiateWasm: this.instantiateWasm.bind(this)
});
}
Expand All @@ -13611,6 +13612,7 @@ var DuckDB = class extends DuckDBNodeBindings {
instantiateImpl(moduleOverrides) {
return (0, import_duckdb_mvp2.default)({
...moduleOverrides,
//@ts-ignore
instantiateWasm: this.instantiateWasm.bind(this),
locateFile: this.locateFile.bind(this)
});
Expand All @@ -13628,6 +13630,7 @@ var DuckDB2 = class extends DuckDBNodeBindings {
instantiateImpl(moduleOverrides) {
return (0, import_duckdb_eh.default)({
...moduleOverrides,
//@ts-ignore
instantiateWasm: this.instantiateWasm.bind(this),
locateFile: this.locateFile.bind(this)
});
Expand Down
4 changes: 2 additions & 2 deletions packages/duckdb-wasm/dist/tests-node.cjs.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export declare abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
/** Locate a file */
protected locateFile(path: string, prefix: string): string;
/** Instantiate the wasm module */
protected instantiateWasm(imports: any, success: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void): Emscripten.WebAssemblyExports;
protected instantiateWasm(imports: any, success: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void): Promise<Emscripten.WebAssemblyExports>;
protected abstract instantiateImpl(moduleOverrides: Partial<DuckDBModule>): Promise<DuckDBModule>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export interface DuckDBModule extends EmscriptenModule {
stackRestore: typeof stackRestore;
ccall: typeof ccall;
PThread: PThread;
instantiateWasm: (imports: Emscripten.WebAssemblyImports, successCallback: (module: WebAssembly.Module) => void) => Promise<Emscripten.WebAssemblyExports>;
}
2 changes: 1 addition & 1 deletion packages/duckdb-wasm/src/bindings/bindings_browser_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
imports: any,
success: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void,
): Emscripten.WebAssemblyExports {
): Promise<Emscripten.WebAssemblyExports> {
// We rely on the following here:
//
// ...when a Request object is created using the Request.Request constructor,
Expand Down
3 changes: 2 additions & 1 deletion packages/duckdb-wasm/src/bindings/bindings_node_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class DuckDBNodeBindings extends DuckDBBindingsBase {
}

/** Instantiate the wasm module */
protected instantiateWasm(
protected instantiateWasm(
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
imports: any,
success: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void,
Expand All @@ -65,6 +65,7 @@ export class DuckDBNodeBindings extends DuckDBBindingsBase {
protected instantiateImpl(moduleOverrides: Partial<DuckDBModule>): Promise<DuckDBModule> {
return DuckDBWasm({
...moduleOverrides,
//@ts-ignore
instantiateWasm: this.instantiateWasm.bind(this),
});
}
Expand Down
1 change: 1 addition & 0 deletions packages/duckdb-wasm/src/bindings/bindings_node_eh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class DuckDB extends DuckDBNodeBindings {
protected instantiateImpl(moduleOverrides: Partial<DuckDBModule>): Promise<DuckDBModule> {
return DuckDBWasm({
...moduleOverrides,
//@ts-ignore
instantiateWasm: this.instantiateWasm.bind(this),
locateFile: this.locateFile.bind(this),
});
Expand Down
1 change: 1 addition & 0 deletions packages/duckdb-wasm/src/bindings/bindings_node_mvp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class DuckDB extends DuckDBNodeBindings {
protected instantiateImpl(moduleOverrides: Partial<DuckDBModule>): Promise<DuckDBModule> {
return DuckDBWasm({
...moduleOverrides,
//@ts-ignore
instantiateWasm: this.instantiateWasm.bind(this),
locateFile: this.locateFile.bind(this),
});
Expand Down
5 changes: 5 additions & 0 deletions packages/duckdb-wasm/src/bindings/duckdb_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ export interface PThread {
runningWorkers: Worker[];
}

// @ts-ignore - We are trying to fix some thing using the below code
export interface DuckDBModule extends EmscriptenModule {
stackSave: typeof stackSave;
stackAlloc: typeof stackAlloc;
stackRestore: typeof stackRestore;

ccall: typeof ccall;
PThread: PThread;
instantiateWasm: (
imports: Emscripten.WebAssemblyImports,
successCallback: (module: WebAssembly.Module) => void,
) => Promise<Emscripten.WebAssemblyExports>;
}

0 comments on commit ab172f9

Please sign in to comment.