@notedge/panduck 0.0.0 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/wasm/load.ts CHANGED
@@ -1,23 +1,25 @@
1
- import type { PanduckBindings, PanduckWasmOptions } from "../types.js";
2
-
3
- type WasmModule = {
4
- default: (input?: { module_or_path?: string | URL }) => Promise<unknown>;
5
- panduckVersion: () => string;
6
- supportedFormats: () => string[];
7
- isSupportedFormat: (name: string) => boolean;
8
- };
9
-
10
- /** Load `@notedge/panduck-unknown-wasm32` and return the Panduck binding surface. */
11
- export async function loadPanduckWasm(options: PanduckWasmOptions = {}): Promise<PanduckBindings> {
12
- const wasm = (await import("@notedge/panduck-unknown-wasm32/pkg/panduck_wasm.js")) as WasmModule;
13
- if (options.url) {
14
- await wasm.default({ module_or_path: options.url });
15
- } else {
16
- await wasm.default();
17
- }
18
- return {
19
- panduckVersion: () => wasm.panduckVersion(),
20
- supportedFormats: () => wasm.supportedFormats(),
21
- isSupportedFormat: (name) => wasm.isSupportedFormat(name),
22
- };
23
- }
1
+ import type { PanduckBindings, PanduckWasmOptions } from "../types.js";
2
+
3
+ const ARTIFACT_PACKAGE = "@notedge/panduck-unknown-wasm32";
4
+
5
+ type WasmBinding = {
6
+ default: (input?: { module_or_path?: string | URL }) => Promise<unknown>;
7
+ panduckVersion: () => string;
8
+ supportedFormats: () => string[];
9
+ isSupportedFormat: (name: string) => boolean;
10
+ };
11
+
12
+ /** Load the WASM artifact from `@notedge/panduck-unknown-wasm32`. */
13
+ export async function loadPanduckWasm(options: PanduckWasmOptions = {}): Promise<PanduckBindings> {
14
+ const binding = (await import(ARTIFACT_PACKAGE)) as WasmBinding;
15
+ if (options.url) {
16
+ await binding.default({ module_or_path: options.url });
17
+ } else {
18
+ await binding.default();
19
+ }
20
+ return {
21
+ panduckVersion: () => binding.panduckVersion(),
22
+ supportedFormats: () => binding.supportedFormats(),
23
+ isSupportedFormat: (name) => binding.isSupportedFormat(name),
24
+ };
25
+ }
@@ -1,6 +0,0 @@
1
- declare module '@notedge/panduck-unknown-wasm32/pkg/panduck_wasm.js' {
2
- export default function init(input?: { module_or_path?: string | URL }): Promise<unknown>;
3
- export function panduckVersion(): string;
4
- export function supportedFormats(): string[];
5
- export function isSupportedFormat(name: string): boolean;
6
- }