onnxruntime-node 1.20.1 → 1.21.0-dev.20250228-beb1a9242e
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/README.md +1 -1
- package/__commit.txt +1 -0
- package/bin/napi-v3/darwin/{x64/libonnxruntime.1.20.1.dylib → arm64/libonnxruntime.1.21.0.dylib} +0 -0
- package/bin/napi-v3/darwin/arm64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/darwin/{arm64/libonnxruntime.1.20.1.dylib → x64/libonnxruntime.1.21.0.dylib} +0 -0
- package/bin/napi-v3/darwin/x64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/linux/arm64/libonnxruntime.so.1 +0 -0
- package/bin/napi-v3/linux/arm64/{libonnxruntime.so.1.20.1 → libonnxruntime.so.1.21.0} +0 -0
- package/bin/napi-v3/linux/arm64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/linux/x64/libonnxruntime.so.1 +0 -0
- package/bin/napi-v3/linux/x64/{libonnxruntime.so.1.20.1 → libonnxruntime.so.1.21.0} +0 -0
- package/bin/napi-v3/linux/x64/libonnxruntime_providers_shared.so +0 -0
- package/bin/napi-v3/linux/x64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/win32/arm64/DirectML.dll +0 -0
- package/bin/napi-v3/win32/arm64/onnxruntime.dll +0 -0
- package/bin/napi-v3/win32/arm64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/win32/x64/DirectML.dll +0 -0
- package/bin/napi-v3/win32/x64/onnxruntime.dll +0 -0
- package/bin/napi-v3/win32/x64/onnxruntime_binding.node +0 -0
- package/dist/backend.d.ts +9 -0
- package/dist/backend.js +5 -2
- package/dist/backend.js.map +1 -1
- package/dist/binding.d.ts +40 -0
- package/dist/binding.js +32 -1
- package/dist/binding.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/lib/backend.ts +7 -3
- package/lib/binding.ts +34 -1
- package/lib/version.ts +1 -1
- package/package.json +3 -2
- package/script/build.js +100 -67
- package/script/build.ts +10 -0
- package/script/install.js +95 -39
- package/script/prepack.js +49 -32
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Refer to [ONNX Runtime JavaScript examples](https://github.com/microsoft/onnxrun
|
|
|
14
14
|
|
|
15
15
|
## Requirements
|
|
16
16
|
|
|
17
|
-
ONNXRuntime works on Node.js v16.x+ (recommend
|
|
17
|
+
ONNXRuntime works on Node.js v16.x+ (recommend v20.x+) or Electron v15.x+ (recommend v28.x+).
|
|
18
18
|
|
|
19
19
|
The following table lists the supported versions of ONNX Runtime Node.js binding provided with pre-built binaries.
|
|
20
20
|
|
package/__commit.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
beb1a9242eaf46ef885f86c75202a94b13dab428
|
package/bin/napi-v3/darwin/{x64/libonnxruntime.1.20.1.dylib → arm64/libonnxruntime.1.21.0.dylib}
RENAMED
|
Binary file
|
|
Binary file
|
package/bin/napi-v3/darwin/{arm64/libonnxruntime.1.20.1.dylib → x64/libonnxruntime.1.21.0.dylib}
RENAMED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Backend, InferenceSession, InferenceSessionHandler } from 'onnxruntime-common';
|
|
2
|
+
import { Binding } from './binding';
|
|
3
|
+
declare class OnnxruntimeBackend implements Backend {
|
|
4
|
+
init(): Promise<void>;
|
|
5
|
+
createInferenceSessionHandler(pathOrBuffer: string | Uint8Array, options?: InferenceSession.SessionOptions): Promise<InferenceSessionHandler>;
|
|
6
|
+
}
|
|
7
|
+
export declare const onnxruntimeBackend: OnnxruntimeBackend;
|
|
8
|
+
export declare const listSupportedBackends: () => Binding.SupportedBackend[];
|
|
9
|
+
export {};
|
package/dist/backend.js
CHANGED
|
@@ -19,6 +19,7 @@ const binding_1 = require("./binding");
|
|
|
19
19
|
class OnnxruntimeSessionHandler {
|
|
20
20
|
constructor(pathOrBuffer, options) {
|
|
21
21
|
_OnnxruntimeSessionHandler_inferenceSession.set(this, void 0);
|
|
22
|
+
(0, binding_1.initOrt)();
|
|
22
23
|
__classPrivateFieldSet(this, _OnnxruntimeSessionHandler_inferenceSession, new binding_1.binding.InferenceSession(), "f");
|
|
23
24
|
if (typeof pathOrBuffer === 'string') {
|
|
24
25
|
__classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").loadModel(pathOrBuffer, options);
|
|
@@ -33,10 +34,12 @@ class OnnxruntimeSessionHandler {
|
|
|
33
34
|
__classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").dispose();
|
|
34
35
|
}
|
|
35
36
|
startProfiling() {
|
|
36
|
-
//
|
|
37
|
+
// startProfiling is a no-op.
|
|
38
|
+
//
|
|
39
|
+
// if sessionOptions.enableProfiling is true, profiling will be enabled when the model is loaded.
|
|
37
40
|
}
|
|
38
41
|
endProfiling() {
|
|
39
|
-
|
|
42
|
+
__classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").endProfiling();
|
|
40
43
|
}
|
|
41
44
|
async run(feeds, fetches, options) {
|
|
42
45
|
return new Promise((resolve, reject) => {
|
package/dist/backend.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../lib/backend.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;AAIlC,
|
|
1
|
+
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../lib/backend.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;AAIlC,uCAAsD;AAEtD,MAAM,yBAAyB;IAG7B,YAAY,YAAiC,EAAE,OAAwC;QAFvF,8DAA4C;QAG1C,IAAA,iBAAO,GAAE,CAAC;QAEV,uBAAA,IAAI,+CAAqB,IAAI,iBAAO,CAAC,gBAAgB,EAAE,MAAA,CAAC;QACxD,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;YACpC,uBAAA,IAAI,mDAAkB,CAAC,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;SACzD;aAAM;YACL,uBAAA,IAAI,mDAAkB,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;SAClH;QACD,IAAI,CAAC,UAAU,GAAG,uBAAA,IAAI,mDAAkB,CAAC,UAAU,CAAC;QACpD,IAAI,CAAC,WAAW,GAAG,uBAAA,IAAI,mDAAkB,CAAC,WAAW,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,OAAO;QACX,uBAAA,IAAI,mDAAkB,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IAKD,cAAc;QACZ,6BAA6B;QAC7B,EAAE;QACF,iGAAiG;IACnG,CAAC;IACD,YAAY;QACV,uBAAA,IAAI,mDAAkB,CAAC,YAAY,EAAE,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,GAAG,CACP,KAA+B,EAC/B,OAAmC,EACnC,OAAoC;QAEpC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,YAAY,CAAC,GAAG,EAAE;gBAChB,IAAI;oBACF,OAAO,CAAC,uBAAA,IAAI,mDAAkB,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;iBAC9D;gBAAC,OAAO,CAAC,EAAE;oBACV,gCAAgC;oBAChC,MAAM,CAAC,CAAC,CAAC,CAAC;iBACX;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;;AAED,MAAM,kBAAkB;IACtB,KAAK,CAAC,IAAI;QACR,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,6BAA6B,CACjC,YAAiC,EACjC,OAAyC;QAEzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,YAAY,CAAC,GAAG,EAAE;gBAChB,IAAI;oBACF,OAAO,CAAC,IAAI,yBAAyB,CAAC,YAAY,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;iBACrE;gBAAC,OAAO,CAAC,EAAE;oBACV,gCAAgC;oBAChC,MAAM,CAAC,CAAC,CAAC,CAAC;iBACX;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAEY,QAAA,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC;AAC9C,QAAA,qBAAqB,GAAG,iBAAO,CAAC,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { InferenceSession, OnnxValue, TensorConstructor } from 'onnxruntime-common';
|
|
2
|
+
type SessionOptions = InferenceSession.SessionOptions;
|
|
3
|
+
type FeedsType = {
|
|
4
|
+
[name: string]: OnnxValue;
|
|
5
|
+
};
|
|
6
|
+
type FetchesType = {
|
|
7
|
+
[name: string]: OnnxValue | null;
|
|
8
|
+
};
|
|
9
|
+
type ReturnType = {
|
|
10
|
+
[name: string]: OnnxValue;
|
|
11
|
+
};
|
|
12
|
+
type RunOptions = InferenceSession.RunOptions;
|
|
13
|
+
/**
|
|
14
|
+
* Binding exports a simple synchronized inference session object wrap.
|
|
15
|
+
*/
|
|
16
|
+
export declare namespace Binding {
|
|
17
|
+
interface InferenceSession {
|
|
18
|
+
loadModel(modelPath: string, options: SessionOptions): void;
|
|
19
|
+
loadModel(buffer: ArrayBuffer, byteOffset: number, byteLength: number, options: SessionOptions): void;
|
|
20
|
+
readonly inputNames: string[];
|
|
21
|
+
readonly outputNames: string[];
|
|
22
|
+
run(feeds: FeedsType, fetches: FetchesType, options: RunOptions): ReturnType;
|
|
23
|
+
endProfiling(): void;
|
|
24
|
+
dispose(): void;
|
|
25
|
+
}
|
|
26
|
+
interface InferenceSessionConstructor {
|
|
27
|
+
new (): InferenceSession;
|
|
28
|
+
}
|
|
29
|
+
interface SupportedBackend {
|
|
30
|
+
name: string;
|
|
31
|
+
bundled: boolean;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export declare const binding: {
|
|
35
|
+
InferenceSession: Binding.InferenceSessionConstructor;
|
|
36
|
+
listSupportedBackends: () => Binding.SupportedBackend[];
|
|
37
|
+
initOrtOnce: (logLevel: number, tensorConstructor: TensorConstructor) => void;
|
|
38
|
+
};
|
|
39
|
+
export declare const initOrt: () => void;
|
|
40
|
+
export {};
|
package/dist/binding.js
CHANGED
|
@@ -2,9 +2,40 @@
|
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.binding = void 0;
|
|
5
|
+
exports.initOrt = exports.binding = void 0;
|
|
6
|
+
const onnxruntime_common_1 = require("onnxruntime-common");
|
|
6
7
|
// export native binding
|
|
7
8
|
exports.binding =
|
|
8
9
|
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
9
10
|
require(`../bin/napi-v3/${process.platform}/${process.arch}/onnxruntime_binding.node`);
|
|
11
|
+
let ortInitialized = false;
|
|
12
|
+
const initOrt = () => {
|
|
13
|
+
if (!ortInitialized) {
|
|
14
|
+
ortInitialized = true;
|
|
15
|
+
let logLevel = 2;
|
|
16
|
+
if (onnxruntime_common_1.env.logLevel) {
|
|
17
|
+
switch (onnxruntime_common_1.env.logLevel) {
|
|
18
|
+
case 'verbose':
|
|
19
|
+
logLevel = 0;
|
|
20
|
+
break;
|
|
21
|
+
case 'info':
|
|
22
|
+
logLevel = 1;
|
|
23
|
+
break;
|
|
24
|
+
case 'warning':
|
|
25
|
+
logLevel = 2;
|
|
26
|
+
break;
|
|
27
|
+
case 'error':
|
|
28
|
+
logLevel = 3;
|
|
29
|
+
break;
|
|
30
|
+
case 'fatal':
|
|
31
|
+
logLevel = 4;
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(`Unsupported log level: ${onnxruntime_common_1.env.logLevel}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.binding.initOrtOnce(logLevel, onnxruntime_common_1.Tensor);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.initOrt = initOrt;
|
|
10
41
|
//# sourceMappingURL=binding.js.map
|
package/dist/binding.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding.js","sourceRoot":"","sources":["../lib/binding.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;
|
|
1
|
+
{"version":3,"file":"binding.js","sourceRoot":"","sources":["../lib/binding.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC,2DAAiG;AA0CjG,wBAAwB;AACX,QAAA,OAAO;AAClB,qGAAqG;AACrG,OAAO,CAAC,kBAAkB,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,2BAA2B,CAKpF,CAAC;AAEJ,IAAI,cAAc,GAAG,KAAK,CAAC;AACpB,MAAM,OAAO,GAAG,GAAS,EAAE;IAChC,IAAI,CAAC,cAAc,EAAE;QACnB,cAAc,GAAG,IAAI,CAAC;QACtB,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,wBAAG,CAAC,QAAQ,EAAE;YAChB,QAAQ,wBAAG,CAAC,QAAQ,EAAE;gBACpB,KAAK,SAAS;oBACZ,QAAQ,GAAG,CAAC,CAAC;oBACb,MAAM;gBACR,KAAK,MAAM;oBACT,QAAQ,GAAG,CAAC,CAAC;oBACb,MAAM;gBACR,KAAK,SAAS;oBACZ,QAAQ,GAAG,CAAC,CAAC;oBACb,MAAM;gBACR,KAAK,OAAO;oBACV,QAAQ,GAAG,CAAC,CAAC;oBACb,MAAM;gBACR,KAAK,OAAO;oBACV,QAAQ,GAAG,CAAC,CAAC;oBACb,MAAM;gBACR;oBACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,wBAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;aAC7D;SACF;QACD,eAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,2BAAM,CAAC,CAAC;KACvC;AACH,CAAC,CAAC;AA3BW,QAAA,OAAO,WA2BlB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version = "1.21.0-dev.20250228-beb1a9242e";
|
package/dist/version.js
CHANGED
|
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
exports.version = void 0;
|
|
6
6
|
// This file is generated by /js/scripts/update-version.ts
|
|
7
7
|
// Do not modify file content manually.
|
|
8
|
-
exports.version = '1.
|
|
8
|
+
exports.version = '1.21.0-dev.20250228-beb1a9242e';
|
|
9
9
|
//# sourceMappingURL=version.js.map
|
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../lib/version.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC,0DAA0D;AAC1D,uCAAuC;AAE1B,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../lib/version.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC,0DAA0D;AAC1D,uCAAuC;AAE1B,QAAA,OAAO,GAAG,gCAAgC,CAAC"}
|
package/lib/backend.ts
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
import { Backend, InferenceSession, InferenceSessionHandler, SessionHandler } from 'onnxruntime-common';
|
|
5
5
|
|
|
6
|
-
import { Binding, binding } from './binding';
|
|
6
|
+
import { Binding, binding, initOrt } from './binding';
|
|
7
7
|
|
|
8
8
|
class OnnxruntimeSessionHandler implements InferenceSessionHandler {
|
|
9
9
|
#inferenceSession: Binding.InferenceSession;
|
|
10
10
|
|
|
11
11
|
constructor(pathOrBuffer: string | Uint8Array, options: InferenceSession.SessionOptions) {
|
|
12
|
+
initOrt();
|
|
13
|
+
|
|
12
14
|
this.#inferenceSession = new binding.InferenceSession();
|
|
13
15
|
if (typeof pathOrBuffer === 'string') {
|
|
14
16
|
this.#inferenceSession.loadModel(pathOrBuffer, options);
|
|
@@ -27,10 +29,12 @@ class OnnxruntimeSessionHandler implements InferenceSessionHandler {
|
|
|
27
29
|
readonly outputNames: string[];
|
|
28
30
|
|
|
29
31
|
startProfiling(): void {
|
|
30
|
-
//
|
|
32
|
+
// startProfiling is a no-op.
|
|
33
|
+
//
|
|
34
|
+
// if sessionOptions.enableProfiling is true, profiling will be enabled when the model is loaded.
|
|
31
35
|
}
|
|
32
36
|
endProfiling(): void {
|
|
33
|
-
|
|
37
|
+
this.#inferenceSession.endProfiling();
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
async run(
|
package/lib/binding.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
|
-
import { InferenceSession, OnnxValue } from 'onnxruntime-common';
|
|
4
|
+
import { InferenceSession, OnnxValue, Tensor, TensorConstructor, env } from 'onnxruntime-common';
|
|
5
5
|
|
|
6
6
|
type SessionOptions = InferenceSession.SessionOptions;
|
|
7
7
|
type FeedsType = {
|
|
@@ -28,6 +28,8 @@ export declare namespace Binding {
|
|
|
28
28
|
|
|
29
29
|
run(feeds: FeedsType, fetches: FetchesType, options: RunOptions): ReturnType;
|
|
30
30
|
|
|
31
|
+
endProfiling(): void;
|
|
32
|
+
|
|
31
33
|
dispose(): void;
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -48,4 +50,35 @@ export const binding =
|
|
|
48
50
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
49
51
|
InferenceSession: Binding.InferenceSessionConstructor;
|
|
50
52
|
listSupportedBackends: () => Binding.SupportedBackend[];
|
|
53
|
+
initOrtOnce: (logLevel: number, tensorConstructor: TensorConstructor) => void;
|
|
51
54
|
};
|
|
55
|
+
|
|
56
|
+
let ortInitialized = false;
|
|
57
|
+
export const initOrt = (): void => {
|
|
58
|
+
if (!ortInitialized) {
|
|
59
|
+
ortInitialized = true;
|
|
60
|
+
let logLevel = 2;
|
|
61
|
+
if (env.logLevel) {
|
|
62
|
+
switch (env.logLevel) {
|
|
63
|
+
case 'verbose':
|
|
64
|
+
logLevel = 0;
|
|
65
|
+
break;
|
|
66
|
+
case 'info':
|
|
67
|
+
logLevel = 1;
|
|
68
|
+
break;
|
|
69
|
+
case 'warning':
|
|
70
|
+
logLevel = 2;
|
|
71
|
+
break;
|
|
72
|
+
case 'error':
|
|
73
|
+
logLevel = 3;
|
|
74
|
+
break;
|
|
75
|
+
case 'fatal':
|
|
76
|
+
logLevel = 4;
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
throw new Error(`Unsupported log level: ${env.logLevel}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
binding.initOrtOnce(logLevel, Tensor);
|
|
83
|
+
}
|
|
84
|
+
};
|
package/lib/version.ts
CHANGED
package/package.json
CHANGED
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
3
|
|
14
14
|
]
|
|
15
15
|
},
|
|
16
|
-
"version": "1.
|
|
16
|
+
"version": "1.21.0-dev.20250228-beb1a9242e",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"
|
|
18
|
+
"global-agent": "^3.0.0",
|
|
19
|
+
"onnxruntime-common": "1.21.0-dev.20250206-d981b153d3",
|
|
19
20
|
"tar": "^7.0.1"
|
|
20
21
|
},
|
|
21
22
|
"scripts": {
|
package/script/build.js
CHANGED
|
@@ -1,49 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
|
-
var __createBinding =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
4
|
+
var __createBinding =
|
|
5
|
+
(this && this.__createBinding) ||
|
|
6
|
+
(Object.create
|
|
7
|
+
? function (o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return m[k];
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}
|
|
20
|
+
: function (o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
});
|
|
24
|
+
var __setModuleDefault =
|
|
25
|
+
(this && this.__setModuleDefault) ||
|
|
26
|
+
(Object.create
|
|
27
|
+
? function (o, v) {
|
|
28
|
+
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
29
|
+
}
|
|
30
|
+
: function (o, v) {
|
|
31
|
+
o['default'] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar =
|
|
34
|
+
(this && this.__importStar) ||
|
|
35
|
+
function (mod) {
|
|
21
36
|
if (mod && mod.__esModule) return mod;
|
|
22
37
|
var result = {};
|
|
23
|
-
if (mod != null)
|
|
38
|
+
if (mod != null)
|
|
39
|
+
for (var k in mod)
|
|
40
|
+
if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
41
|
__setModuleDefault(result, mod);
|
|
25
42
|
return result;
|
|
26
|
-
};
|
|
27
|
-
var __importDefault =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
43
|
+
};
|
|
44
|
+
var __importDefault =
|
|
45
|
+
(this && this.__importDefault) ||
|
|
46
|
+
function (mod) {
|
|
47
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
50
|
+
const child_process_1 = require('child_process');
|
|
51
|
+
const fs = __importStar(require('fs-extra'));
|
|
52
|
+
const minimist_1 = __importDefault(require('minimist'));
|
|
53
|
+
const os = __importStar(require('os'));
|
|
54
|
+
const path = __importStar(require('path'));
|
|
36
55
|
// command line flags
|
|
37
56
|
const buildArgs = (0, minimist_1.default)(process.argv.slice(2));
|
|
38
57
|
// --config=Debug|Release|RelWithDebInfo
|
|
39
58
|
const CONFIG = buildArgs.config || (os.platform() === 'win32' ? 'RelWithDebInfo' : 'Release');
|
|
40
59
|
if (CONFIG !== 'Debug' && CONFIG !== 'Release' && CONFIG !== 'RelWithDebInfo') {
|
|
41
|
-
|
|
60
|
+
throw new Error(`unrecognized config: ${CONFIG}`);
|
|
42
61
|
}
|
|
43
62
|
// --arch=x64|ia32|arm64|arm
|
|
44
63
|
const ARCH = buildArgs.arch || os.arch();
|
|
45
64
|
if (ARCH !== 'x64' && ARCH !== 'ia32' && ARCH !== 'arm64' && ARCH !== 'arm') {
|
|
46
|
-
|
|
65
|
+
throw new Error(`unrecognized architecture: ${ARCH}`);
|
|
47
66
|
}
|
|
48
67
|
// --onnxruntime-build-dir=
|
|
49
68
|
const ONNXRUNTIME_BUILD_DIR = buildArgs['onnxruntime-build-dir'];
|
|
@@ -53,6 +72,8 @@ const ONNXRUNTIME_GENERATOR = buildArgs['onnxruntime-generator'];
|
|
|
53
72
|
const REBUILD = !!buildArgs.rebuild;
|
|
54
73
|
// --use_dml
|
|
55
74
|
const USE_DML = !!buildArgs.use_dml;
|
|
75
|
+
// --use_webgpu
|
|
76
|
+
const USE_WEBGPU = !!buildArgs.use_webgpu;
|
|
56
77
|
// --use_cuda
|
|
57
78
|
const USE_CUDA = !!buildArgs.use_cuda;
|
|
58
79
|
// --use_tensorrt
|
|
@@ -61,78 +82,90 @@ const USE_TENSORRT = !!buildArgs.use_tensorrt;
|
|
|
61
82
|
const USE_COREML = !!buildArgs.use_coreml;
|
|
62
83
|
// --use_qnn
|
|
63
84
|
const USE_QNN = !!buildArgs.use_qnn;
|
|
85
|
+
// --dll_deps=
|
|
86
|
+
const DLL_DEPS = buildArgs.dll_deps;
|
|
64
87
|
// build path
|
|
65
88
|
const ROOT_FOLDER = path.join(__dirname, '..');
|
|
66
89
|
const BIN_FOLDER = path.join(ROOT_FOLDER, 'bin');
|
|
67
90
|
const BUILD_FOLDER = path.join(ROOT_FOLDER, 'build');
|
|
68
91
|
// if rebuild, clean up the dist folders
|
|
69
92
|
if (REBUILD) {
|
|
70
|
-
|
|
71
|
-
|
|
93
|
+
fs.removeSync(BIN_FOLDER);
|
|
94
|
+
fs.removeSync(BUILD_FOLDER);
|
|
72
95
|
}
|
|
73
96
|
const args = [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
97
|
+
'cmake-js',
|
|
98
|
+
REBUILD ? 'reconfigure' : 'configure',
|
|
99
|
+
`--arch=${ARCH}`,
|
|
100
|
+
'--CDnapi_build_version=6',
|
|
101
|
+
`--CDCMAKE_BUILD_TYPE=${CONFIG}`,
|
|
79
102
|
];
|
|
80
103
|
if (ONNXRUNTIME_BUILD_DIR && typeof ONNXRUNTIME_BUILD_DIR === 'string') {
|
|
81
|
-
|
|
104
|
+
args.push(`--CDONNXRUNTIME_BUILD_DIR=${ONNXRUNTIME_BUILD_DIR}`);
|
|
82
105
|
}
|
|
83
106
|
if (ONNXRUNTIME_GENERATOR && typeof ONNXRUNTIME_GENERATOR === 'string') {
|
|
84
|
-
|
|
107
|
+
args.push(`--CDONNXRUNTIME_GENERATOR=${ONNXRUNTIME_GENERATOR}`);
|
|
85
108
|
}
|
|
86
109
|
if (USE_DML) {
|
|
87
|
-
|
|
110
|
+
args.push('--CDUSE_DML=ON');
|
|
111
|
+
}
|
|
112
|
+
if (USE_WEBGPU) {
|
|
113
|
+
args.push('--CDUSE_WEBGPU=ON');
|
|
88
114
|
}
|
|
89
115
|
if (USE_CUDA) {
|
|
90
|
-
|
|
116
|
+
args.push('--CDUSE_CUDA=ON');
|
|
91
117
|
}
|
|
92
118
|
if (USE_TENSORRT) {
|
|
93
|
-
|
|
119
|
+
args.push('--CDUSE_TENSORRT=ON');
|
|
94
120
|
}
|
|
95
121
|
if (USE_COREML) {
|
|
96
|
-
|
|
122
|
+
args.push('--CDUSE_COREML=ON');
|
|
97
123
|
}
|
|
98
124
|
if (USE_QNN) {
|
|
99
|
-
|
|
125
|
+
args.push('--CDUSE_QNN=ON');
|
|
126
|
+
}
|
|
127
|
+
if (DLL_DEPS) {
|
|
128
|
+
args.push(`--CDORT_NODEJS_DLL_DEPS=${DLL_DEPS}`);
|
|
100
129
|
}
|
|
101
130
|
// set CMAKE_OSX_ARCHITECTURES for macOS build
|
|
102
131
|
if (os.platform() === 'darwin') {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
throw new Error(`architecture not supported for macOS build: ${ARCH}`);
|
|
111
|
-
}
|
|
132
|
+
if (ARCH === 'x64') {
|
|
133
|
+
args.push('--CDCMAKE_OSX_ARCHITECTURES=x86_64');
|
|
134
|
+
} else if (ARCH === 'arm64') {
|
|
135
|
+
args.push('--CDCMAKE_OSX_ARCHITECTURES=arm64');
|
|
136
|
+
} else {
|
|
137
|
+
throw new Error(`architecture not supported for macOS build: ${ARCH}`);
|
|
138
|
+
}
|
|
112
139
|
}
|
|
113
140
|
// In Windows, "npx cmake-js configure" uses a powershell script to detect the Visual Studio installation.
|
|
114
141
|
// The script uses the environment variable LIB. If an invalid path is specified in LIB, the script will fail.
|
|
115
142
|
// So we override the LIB environment variable to remove invalid paths.
|
|
116
|
-
const envOverride =
|
|
143
|
+
const envOverride =
|
|
144
|
+
os.platform() === 'win32' && process.env.LIB
|
|
117
145
|
? { ...process.env, LIB: process.env.LIB.split(';').filter(fs.existsSync).join(';') }
|
|
118
146
|
: process.env;
|
|
119
147
|
// launch cmake-js configure
|
|
120
|
-
const procCmakejs = (0, child_process_1.spawnSync)('npx', args, {
|
|
148
|
+
const procCmakejs = (0, child_process_1.spawnSync)('npx', args, {
|
|
149
|
+
shell: true,
|
|
150
|
+
stdio: 'inherit',
|
|
151
|
+
cwd: ROOT_FOLDER,
|
|
152
|
+
env: envOverride,
|
|
153
|
+
});
|
|
121
154
|
if (procCmakejs.status !== 0) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
155
|
+
if (procCmakejs.error) {
|
|
156
|
+
console.error(procCmakejs.error);
|
|
157
|
+
}
|
|
158
|
+
process.exit(procCmakejs.status === null ? undefined : procCmakejs.status);
|
|
126
159
|
}
|
|
127
160
|
// launch cmake to build
|
|
128
161
|
const procCmake = (0, child_process_1.spawnSync)('cmake', ['--build', '.', '--config', CONFIG], {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
162
|
+
shell: true,
|
|
163
|
+
stdio: 'inherit',
|
|
164
|
+
cwd: BUILD_FOLDER,
|
|
132
165
|
});
|
|
133
166
|
if (procCmake.status !== 0) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
167
|
+
if (procCmake.error) {
|
|
168
|
+
console.error(procCmake.error);
|
|
169
|
+
}
|
|
170
|
+
process.exit(procCmake.status === null ? undefined : procCmake.status);
|
|
138
171
|
}
|
package/script/build.ts
CHANGED
|
@@ -29,6 +29,8 @@ const ONNXRUNTIME_GENERATOR = buildArgs['onnxruntime-generator'];
|
|
|
29
29
|
const REBUILD = !!buildArgs.rebuild;
|
|
30
30
|
// --use_dml
|
|
31
31
|
const USE_DML = !!buildArgs.use_dml;
|
|
32
|
+
// --use_webgpu
|
|
33
|
+
const USE_WEBGPU = !!buildArgs.use_webgpu;
|
|
32
34
|
// --use_cuda
|
|
33
35
|
const USE_CUDA = !!buildArgs.use_cuda;
|
|
34
36
|
// --use_tensorrt
|
|
@@ -37,6 +39,8 @@ const USE_TENSORRT = !!buildArgs.use_tensorrt;
|
|
|
37
39
|
const USE_COREML = !!buildArgs.use_coreml;
|
|
38
40
|
// --use_qnn
|
|
39
41
|
const USE_QNN = !!buildArgs.use_qnn;
|
|
42
|
+
// --dll_deps=
|
|
43
|
+
const DLL_DEPS = buildArgs.dll_deps;
|
|
40
44
|
|
|
41
45
|
// build path
|
|
42
46
|
const ROOT_FOLDER = path.join(__dirname, '..');
|
|
@@ -65,6 +69,9 @@ if (ONNXRUNTIME_GENERATOR && typeof ONNXRUNTIME_GENERATOR === 'string') {
|
|
|
65
69
|
if (USE_DML) {
|
|
66
70
|
args.push('--CDUSE_DML=ON');
|
|
67
71
|
}
|
|
72
|
+
if (USE_WEBGPU) {
|
|
73
|
+
args.push('--CDUSE_WEBGPU=ON');
|
|
74
|
+
}
|
|
68
75
|
if (USE_CUDA) {
|
|
69
76
|
args.push('--CDUSE_CUDA=ON');
|
|
70
77
|
}
|
|
@@ -77,6 +84,9 @@ if (USE_COREML) {
|
|
|
77
84
|
if (USE_QNN) {
|
|
78
85
|
args.push('--CDUSE_QNN=ON');
|
|
79
86
|
}
|
|
87
|
+
if (DLL_DEPS) {
|
|
88
|
+
args.push(`--CDORT_NODEJS_DLL_DEPS=${DLL_DEPS}`);
|
|
89
|
+
}
|
|
80
90
|
|
|
81
91
|
// set CMAKE_OSX_ARCHITECTURES for macOS build
|
|
82
92
|
if (os.platform() === 'darwin') {
|
package/script/install.js
CHANGED
|
@@ -19,9 +19,16 @@
|
|
|
19
19
|
// Step.1: Check if we should exit early
|
|
20
20
|
const os = require('os');
|
|
21
21
|
const fs = require('fs');
|
|
22
|
+
const https = require('https');
|
|
22
23
|
const path = require('path');
|
|
23
24
|
const tar = require('tar');
|
|
24
|
-
const {
|
|
25
|
+
const { execFileSync } = require('child_process');
|
|
26
|
+
const { bootstrap: globalAgentBootstrap } = require('global-agent');
|
|
27
|
+
|
|
28
|
+
// Bootstrap global-agent to honor the proxy settings in
|
|
29
|
+
// environment variables, e.g. GLOBAL_AGENT_HTTPS_PROXY.
|
|
30
|
+
// See https://github.com/gajus/global-agent/blob/v3.0.0/README.md#environment-variables for details.
|
|
31
|
+
globalAgentBootstrap();
|
|
25
32
|
|
|
26
33
|
// commandline flag:
|
|
27
34
|
// --onnxruntime-node-install-cuda Force install the CUDA EP binaries. Try to detect the CUDA version.
|
|
@@ -58,59 +65,108 @@ if (NO_INSTALL || !shouldInstall) {
|
|
|
58
65
|
|
|
59
66
|
// Step.2: Download the required binaries
|
|
60
67
|
const artifactUrl = {
|
|
61
|
-
11
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
get 11() {
|
|
69
|
+
// TODO: support ORT Cuda v11 binaries
|
|
70
|
+
throw new Error(`CUDA 11 binaries are not supported by this script yet.
|
|
71
|
+
|
|
72
|
+
To use ONNX Runtime Node.js binding with CUDA v11 support, please follow the manual steps:
|
|
73
|
+
|
|
74
|
+
1. Use "--onnxruntime-node-install-cuda=skip" to skip the auto installation.
|
|
75
|
+
2. Navigate to https://aiinfra.visualstudio.com/PublicPackages/_artifacts/feed/onnxruntime-cuda-11
|
|
76
|
+
3. Download the binaries for your platform and architecture
|
|
77
|
+
4. Extract the following binaries to "node_modules/onnxruntime-node/bin/napi-v3/linux/x64:
|
|
78
|
+
- libonnxruntime_providers_tensorrt.so
|
|
79
|
+
- libonnxruntime_providers_shared.so
|
|
80
|
+
- libonnxruntime.so.${ORT_VERSION}
|
|
81
|
+
- libonnxruntime_providers_cuda.so
|
|
82
|
+
`);
|
|
83
|
+
},
|
|
84
|
+
12: `https://github.com/microsoft/onnxruntime/releases/download/v${ORT_VERSION}/onnxruntime-linux-x64-gpu-${
|
|
65
85
|
ORT_VERSION
|
|
66
86
|
}.tgz`,
|
|
67
87
|
}[INSTALL_CUDA_FLAG || tryGetCudaVersion()];
|
|
68
88
|
console.log(`Downloading "${artifactUrl}"...`);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
89
|
+
|
|
90
|
+
const FILES = new Set([
|
|
91
|
+
'libonnxruntime_providers_tensorrt.so',
|
|
92
|
+
'libonnxruntime_providers_shared.so',
|
|
93
|
+
`libonnxruntime.so.${ORT_VERSION}`,
|
|
94
|
+
'libonnxruntime_providers_cuda.so',
|
|
95
|
+
]);
|
|
96
|
+
|
|
97
|
+
downloadAndExtract(artifactUrl, BIN_FOLDER, FILES);
|
|
98
|
+
|
|
99
|
+
async function downloadAndExtract(url, dest, files) {
|
|
100
|
+
return new Promise((resolve, reject) => {
|
|
101
|
+
https.get(url, (res) => {
|
|
102
|
+
const { statusCode } = res;
|
|
103
|
+
const contentType = res.headers['content-type'];
|
|
104
|
+
|
|
105
|
+
if (statusCode === 301 || statusCode === 302) {
|
|
106
|
+
downloadAndExtract(res.headers.location, dest, files).then(
|
|
107
|
+
(value) => resolve(value),
|
|
108
|
+
(reason) => reject(reason),
|
|
109
|
+
);
|
|
110
|
+
return;
|
|
111
|
+
} else if (statusCode !== 200) {
|
|
112
|
+
throw new Error(`Failed to download the binaries: ${res.statusCode} ${res.statusMessage}.
|
|
72
113
|
|
|
73
114
|
Use "--onnxruntime-node-install-cuda=skip" to skip the installation. You will still be able to use ONNX Runtime, but the CUDA EP will not be available.`);
|
|
74
|
-
|
|
115
|
+
}
|
|
75
116
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
}),
|
|
100
|
-
)
|
|
101
|
-
.on('error', (err) => {
|
|
102
|
-
throw new Error(`Failed to extract the binaries: ${err.message}.
|
|
117
|
+
if (!contentType || !/^application\/octet-stream/.test(contentType)) {
|
|
118
|
+
throw new Error(`unexpected content type: ${contentType}`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
res
|
|
122
|
+
.pipe(
|
|
123
|
+
tar.t({
|
|
124
|
+
strict: true,
|
|
125
|
+
onentry: (entry) => {
|
|
126
|
+
const filename = path.basename(entry.path);
|
|
127
|
+
if (entry.type === 'File' && files.has(filename)) {
|
|
128
|
+
console.log(`Extracting "${filename}" to "${dest}"...`);
|
|
129
|
+
entry.pipe(fs.createWriteStream(path.join(dest, filename)));
|
|
130
|
+
entry.on('finish', () => {
|
|
131
|
+
console.log(`Finished extracting "${filename}".`);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
}),
|
|
136
|
+
)
|
|
137
|
+
.on('error', (err) => {
|
|
138
|
+
throw new Error(`Failed to extract the binaries: ${err.message}.
|
|
103
139
|
|
|
104
140
|
Use "--onnxruntime-node-install-cuda=skip" to skip the installation. You will still be able to use ONNX Runtime, but the CUDA EP will not be available.`);
|
|
141
|
+
});
|
|
105
142
|
});
|
|
106
|
-
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
107
145
|
|
|
108
146
|
function tryGetCudaVersion() {
|
|
109
147
|
// Should only return 11 or 12.
|
|
110
148
|
|
|
111
|
-
//
|
|
149
|
+
// try to get the CUDA version from the system ( `nvcc --version` )
|
|
150
|
+
let ver = 12;
|
|
151
|
+
try {
|
|
152
|
+
const nvccVersion = execFileSync('nvcc', ['--version'], { encoding: 'utf8' });
|
|
153
|
+
const match = nvccVersion.match(/release (\d+)/);
|
|
154
|
+
if (match) {
|
|
155
|
+
ver = parseInt(match[1]);
|
|
156
|
+
if (ver !== 11 && ver !== 12) {
|
|
157
|
+
throw new Error(`Unsupported CUDA version: ${ver}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
} catch (e) {
|
|
161
|
+
if (e?.code === 'ENOENT') {
|
|
162
|
+
console.warn('`nvcc` not found. Assuming CUDA 12.');
|
|
163
|
+
} else {
|
|
164
|
+
console.warn('Failed to detect CUDA version from `nvcc --version`:', e.message);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
112
167
|
|
|
113
|
-
|
|
168
|
+
// assume CUDA 12 if failed to detect
|
|
169
|
+
return ver;
|
|
114
170
|
}
|
|
115
171
|
|
|
116
172
|
function parseInstallCudaFlag() {
|
package/script/prepack.js
CHANGED
|
@@ -1,42 +1,59 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
|
-
var __createBinding =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
4
|
+
var __createBinding =
|
|
5
|
+
(this && this.__createBinding) ||
|
|
6
|
+
(Object.create
|
|
7
|
+
? function (o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return m[k];
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}
|
|
20
|
+
: function (o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
});
|
|
24
|
+
var __setModuleDefault =
|
|
25
|
+
(this && this.__setModuleDefault) ||
|
|
26
|
+
(Object.create
|
|
27
|
+
? function (o, v) {
|
|
28
|
+
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
29
|
+
}
|
|
30
|
+
: function (o, v) {
|
|
31
|
+
o['default'] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar =
|
|
34
|
+
(this && this.__importStar) ||
|
|
35
|
+
function (mod) {
|
|
21
36
|
if (mod && mod.__esModule) return mod;
|
|
22
37
|
var result = {};
|
|
23
|
-
if (mod != null)
|
|
38
|
+
if (mod != null)
|
|
39
|
+
for (var k in mod)
|
|
40
|
+
if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
41
|
__setModuleDefault(result, mod);
|
|
25
42
|
return result;
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports,
|
|
28
|
-
const fs = __importStar(require(
|
|
29
|
-
const path = __importStar(require(
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
45
|
+
const fs = __importStar(require('fs-extra'));
|
|
46
|
+
const path = __importStar(require('path'));
|
|
30
47
|
function updatePackageJson() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
const commonPackageJsonPath = path.join(__dirname, '..', '..', 'common', 'package.json');
|
|
49
|
+
const selfPackageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
50
|
+
console.log(`=== start to update package.json: ${selfPackageJsonPath}`);
|
|
51
|
+
const packageCommon = fs.readJSONSync(commonPackageJsonPath);
|
|
52
|
+
const packageSelf = fs.readJSONSync(selfPackageJsonPath);
|
|
53
|
+
const version = packageCommon.version;
|
|
54
|
+
packageSelf.dependencies['onnxruntime-common'] = `${version}`;
|
|
55
|
+
fs.writeJSONSync(selfPackageJsonPath, packageSelf, { spaces: 2 });
|
|
56
|
+
console.log('=== finished updating package.json.');
|
|
40
57
|
}
|
|
41
58
|
// update version of dependency "onnxruntime-common" before packing
|
|
42
59
|
updatePackageJson();
|