From f0c4014b529eda434a4f2ef89eec6f53e63240d4 Mon Sep 17 00:00:00 2001 From: Alex Merritt Date: Thu, 15 Aug 2024 11:21:15 -0400 Subject: [PATCH] Add files to fix JS build and test --- index.d.ts | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 30 +++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 index.d.ts create mode 100644 package.json diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..60e6540 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,53 @@ +declare module 'onnxruntime-node' { + export * from 'onnxruntime-common'; + export { listSupportedBackends } from './backend'; + +import { Backend, InferenceSession, InferenceSessionHandler } from 'onnxruntime-common'; +import { Binding } from './binding'; +declare class OnnxruntimeBackend implements Backend { + init(): Promise; + createInferenceSessionHandler(pathOrBuffer: string | Uint8Array, options?: InferenceSession.SessionOptions): Promise; +} +export declare const onnxruntimeBackend: OnnxruntimeBackend; +export declare const listSupportedBackends: () => Binding.SupportedBackend[]; +export {}; + +import { InferenceSession, OnnxValue } from 'onnxruntime-common'; +type SessionOptions = InferenceSession.SessionOptions; +type FeedsType = { + [name: string]: OnnxValue; +}; +type FetchesType = { + [name: string]: OnnxValue | null; +}; +type ReturnType = { + [name: string]: OnnxValue; +}; +type RunOptions = InferenceSession.RunOptions; +/** + * Binding exports a simple synchronized inference session object wrap. + */ +export declare namespace Binding { + interface InferenceSession { + loadModel(modelPath: string, options: SessionOptions): void; + loadModel(buffer: ArrayBuffer, byteOffset: number, byteLength: number, options: SessionOptions): void; + readonly inputNames: string[]; + readonly outputNames: string[]; + run(feeds: FeedsType, fetches: FetchesType, options: RunOptions): ReturnType; + dispose(): void; + } + interface InferenceSessionConstructor { + new (): InferenceSession; + } + interface SupportedBackend { + name: string; + bundled: boolean; + } +} +export declare const binding: { + InferenceSession: Binding.InferenceSessionConstructor; + listSupportedBackends: () => Binding.SupportedBackend[]; +}; +export {}; +export declare const version = '1.18.0'; +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..c52a251 --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "license": "MIT", + "type": "module", + "name": "onnxruntime-common", + "version": "1.18.0", + "repository": { + "url": "https://github.com/Microsoft/onnxruntime.git", + "type": "git" + }, + "author": "fs-eire", + "scripts": { + "build:cjs": "tsc --module commonjs --moduleResolution node10 --outDir ./dist/cjs", + "build:esm": "tsc", + "build:bundles": "webpack", + "build": "node ./build.js", + "prepare": "npm run build", + "pretest": "tsc --build ./test", + "test": "mocha ./test/**/*.js --timeout 30000" + }, + "devDependencies": { + "typedoc": "^0.25.7" + }, + "main": "dist/cjs/index.js", + "keywords": [ + "ONNX", + "ONNXRuntime", + "ONNX Runtime" + ], + "description": "ONNXRuntime JavaScript API library" +}