onnxruntime-node 1.21.0 → 1.22.0-dev.20250415-c18e06d5e3

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.
Files changed (34) hide show
  1. package/__commit.txt +1 -0
  2. package/bin/napi-v3/darwin/arm64/{libonnxruntime.1.21.0.dylib → libonnxruntime.1.22.0.dylib} +0 -0
  3. package/bin/napi-v3/darwin/arm64/onnxruntime_binding.node +0 -0
  4. package/bin/napi-v3/darwin/x64/{libonnxruntime.1.21.0.dylib → libonnxruntime.1.22.0.dylib} +0 -0
  5. package/bin/napi-v3/darwin/x64/onnxruntime_binding.node +0 -0
  6. package/bin/napi-v3/linux/arm64/libonnxruntime.so.1 +0 -0
  7. package/bin/napi-v3/linux/arm64/onnxruntime_binding.node +0 -0
  8. package/bin/napi-v3/linux/x64/libonnxruntime.so.1 +0 -0
  9. package/bin/napi-v3/linux/x64/onnxruntime_binding.node +0 -0
  10. package/bin/napi-v3/win32/arm64/DirectML.dll +0 -0
  11. package/bin/napi-v3/{linux/x64/libonnxruntime.so.1.21.0 → win32/arm64/dxcompiler.dll} +0 -0
  12. package/bin/napi-v3/win32/arm64/dxil.dll +0 -0
  13. package/bin/napi-v3/win32/arm64/onnxruntime.dll +0 -0
  14. package/bin/napi-v3/win32/arm64/onnxruntime_binding.node +0 -0
  15. package/bin/napi-v3/win32/x64/DirectML.dll +0 -0
  16. package/bin/napi-v3/{linux/arm64/libonnxruntime.so.1.21.0 → win32/x64/dxcompiler.dll} +0 -0
  17. package/bin/napi-v3/win32/x64/dxil.dll +0 -0
  18. package/bin/napi-v3/win32/x64/onnxruntime.dll +0 -0
  19. package/bin/napi-v3/win32/x64/onnxruntime_binding.node +0 -0
  20. package/dist/backend.js +71 -2
  21. package/dist/backend.js.map +1 -1
  22. package/dist/binding.d.ts +9 -2
  23. package/dist/binding.js.map +1 -1
  24. package/dist/version.d.ts +1 -1
  25. package/dist/version.js +1 -1
  26. package/dist/version.js.map +1 -1
  27. package/lib/backend.ts +79 -2
  28. package/lib/binding.ts +9 -2
  29. package/lib/version.ts +1 -1
  30. package/package.json +2 -2
  31. package/script/build.js +92 -69
  32. package/script/install.js +0 -1
  33. package/script/prepack.js +49 -32
  34. package/bin/napi-v3/linux/x64/libonnxruntime_providers_shared.so +0 -0
package/__commit.txt ADDED
@@ -0,0 +1 @@
1
+ c18e06d5e38e732600e214ba451049cec2435b06
Binary file
Binary file
Binary file
package/dist/backend.js CHANGED
@@ -16,6 +16,31 @@ var _OnnxruntimeSessionHandler_inferenceSession;
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.listSupportedBackends = exports.onnxruntimeBackend = void 0;
18
18
  const binding_1 = require("./binding");
19
+ const dataTypeStrings = [
20
+ undefined,
21
+ 'float32',
22
+ 'uint8',
23
+ 'int8',
24
+ 'uint16',
25
+ 'int16',
26
+ 'int32',
27
+ 'int64',
28
+ 'string',
29
+ 'bool',
30
+ 'float16',
31
+ 'float64',
32
+ 'uint32',
33
+ 'uint64',
34
+ undefined,
35
+ undefined,
36
+ undefined,
37
+ undefined,
38
+ undefined,
39
+ undefined,
40
+ undefined,
41
+ 'uint4',
42
+ 'int4',
43
+ ];
19
44
  class OnnxruntimeSessionHandler {
20
45
  constructor(pathOrBuffer, options) {
21
46
  _OnnxruntimeSessionHandler_inferenceSession.set(this, void 0);
@@ -27,8 +52,52 @@ class OnnxruntimeSessionHandler {
27
52
  else {
28
53
  __classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").loadModel(pathOrBuffer.buffer, pathOrBuffer.byteOffset, pathOrBuffer.byteLength, options);
29
54
  }
30
- this.inputNames = __classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").inputNames;
31
- this.outputNames = __classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").outputNames;
55
+ // prepare input/output names and metadata
56
+ this.inputNames = [];
57
+ this.outputNames = [];
58
+ this.inputMetadata = [];
59
+ this.outputMetadata = [];
60
+ // this function takes raw metadata from binding and returns a tuple of the following 2 items:
61
+ // - an array of string representing names
62
+ // - an array of converted InferenceSession.ValueMetadata
63
+ const fillNamesAndMetadata = (rawMetadata) => {
64
+ const names = [];
65
+ const metadata = [];
66
+ for (const m of rawMetadata) {
67
+ names.push(m.name);
68
+ if (!m.isTensor) {
69
+ metadata.push({ name: m.name, isTensor: false });
70
+ }
71
+ else {
72
+ const type = dataTypeStrings[m.type];
73
+ if (type === undefined) {
74
+ throw new Error(`Unsupported data type: ${m.type}`);
75
+ }
76
+ const shape = [];
77
+ for (let i = 0; i < m.shape.length; ++i) {
78
+ const dim = m.shape[i];
79
+ if (dim === -1) {
80
+ shape.push(m.symbolicDimensions[i]);
81
+ }
82
+ else if (dim >= 0) {
83
+ shape.push(dim);
84
+ }
85
+ else {
86
+ throw new Error(`Invalid dimension: ${dim}`);
87
+ }
88
+ }
89
+ metadata.push({
90
+ name: m.name,
91
+ isTensor: m.isTensor,
92
+ type,
93
+ shape,
94
+ });
95
+ }
96
+ }
97
+ return [names, metadata];
98
+ };
99
+ [this.inputNames, this.inputMetadata] = fillNamesAndMetadata(__classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").inputMetadata);
100
+ [this.outputNames, this.outputMetadata] = fillNamesAndMetadata(__classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").outputMetadata);
32
101
  }
33
102
  async dispose() {
34
103
  __classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").dispose();
@@ -1 +1 @@
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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AAC,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"}
package/dist/binding.d.ts CHANGED
@@ -14,11 +14,18 @@ type RunOptions = InferenceSession.RunOptions;
14
14
  * Binding exports a simple synchronized inference session object wrap.
15
15
  */
16
16
  export declare namespace Binding {
17
+ interface ValueMetadata {
18
+ name: string;
19
+ isTensor: boolean;
20
+ symbolicDimensions: string[];
21
+ shape: number[];
22
+ type: number;
23
+ }
17
24
  interface InferenceSession {
18
25
  loadModel(modelPath: string, options: SessionOptions): void;
19
26
  loadModel(buffer: ArrayBuffer, byteOffset: number, byteLength: number, options: SessionOptions): void;
20
- readonly inputNames: string[];
21
- readonly outputNames: string[];
27
+ readonly inputMetadata: ValueMetadata[];
28
+ readonly outputMetadata: ValueMetadata[];
22
29
  run(feeds: FeedsType, fetches: FetchesType, options: RunOptions): ReturnType;
23
30
  endProfiling(): void;
24
31
  dispose(): void;
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"binding.js","sourceRoot":"","sources":["../lib/binding.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC,2DAAiG;AAiDjG,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/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.21.0";
1
+ export declare const version = "1.22.0-dev.20250415-c18e06d5e3";
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.21.0';
8
+ exports.version = '1.22.0-dev.20250415-c18e06d5e3';
9
9
  //# sourceMappingURL=version.js.map
@@ -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,QAAQ,CAAC"}
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
@@ -5,6 +5,32 @@ import { Backend, InferenceSession, InferenceSessionHandler, SessionHandler } fr
5
5
 
6
6
  import { Binding, binding, initOrt } from './binding';
7
7
 
8
+ const dataTypeStrings = [
9
+ undefined, // 0
10
+ 'float32',
11
+ 'uint8',
12
+ 'int8',
13
+ 'uint16',
14
+ 'int16',
15
+ 'int32',
16
+ 'int64',
17
+ 'string',
18
+ 'bool',
19
+ 'float16',
20
+ 'float64',
21
+ 'uint32',
22
+ 'uint64',
23
+ undefined, // 14
24
+ undefined, // 15
25
+ undefined, // 16
26
+ undefined, // 17
27
+ undefined, // 18
28
+ undefined, // 19
29
+ undefined, // 20
30
+ 'uint4',
31
+ 'int4',
32
+ ] as const;
33
+
8
34
  class OnnxruntimeSessionHandler implements InferenceSessionHandler {
9
35
  #inferenceSession: Binding.InferenceSession;
10
36
 
@@ -17,8 +43,56 @@ class OnnxruntimeSessionHandler implements InferenceSessionHandler {
17
43
  } else {
18
44
  this.#inferenceSession.loadModel(pathOrBuffer.buffer, pathOrBuffer.byteOffset, pathOrBuffer.byteLength, options);
19
45
  }
20
- this.inputNames = this.#inferenceSession.inputNames;
21
- this.outputNames = this.#inferenceSession.outputNames;
46
+
47
+ // prepare input/output names and metadata
48
+ this.inputNames = [];
49
+ this.outputNames = [];
50
+ this.inputMetadata = [];
51
+ this.outputMetadata = [];
52
+
53
+ // this function takes raw metadata from binding and returns a tuple of the following 2 items:
54
+ // - an array of string representing names
55
+ // - an array of converted InferenceSession.ValueMetadata
56
+ const fillNamesAndMetadata = (
57
+ rawMetadata: readonly Binding.ValueMetadata[],
58
+ ): [names: string[], metadata: InferenceSession.ValueMetadata[]] => {
59
+ const names: string[] = [];
60
+ const metadata: InferenceSession.ValueMetadata[] = [];
61
+
62
+ for (const m of rawMetadata) {
63
+ names.push(m.name);
64
+ if (!m.isTensor) {
65
+ metadata.push({ name: m.name, isTensor: false });
66
+ } else {
67
+ const type = dataTypeStrings[m.type];
68
+ if (type === undefined) {
69
+ throw new Error(`Unsupported data type: ${m.type}`);
70
+ }
71
+ const shape: Array<number | string> = [];
72
+ for (let i = 0; i < m.shape.length; ++i) {
73
+ const dim = m.shape[i];
74
+ if (dim === -1) {
75
+ shape.push(m.symbolicDimensions[i]);
76
+ } else if (dim >= 0) {
77
+ shape.push(dim);
78
+ } else {
79
+ throw new Error(`Invalid dimension: ${dim}`);
80
+ }
81
+ }
82
+ metadata.push({
83
+ name: m.name,
84
+ isTensor: m.isTensor,
85
+ type,
86
+ shape,
87
+ });
88
+ }
89
+ }
90
+
91
+ return [names, metadata];
92
+ };
93
+
94
+ [this.inputNames, this.inputMetadata] = fillNamesAndMetadata(this.#inferenceSession.inputMetadata);
95
+ [this.outputNames, this.outputMetadata] = fillNamesAndMetadata(this.#inferenceSession.outputMetadata);
22
96
  }
23
97
 
24
98
  async dispose(): Promise<void> {
@@ -28,6 +102,9 @@ class OnnxruntimeSessionHandler implements InferenceSessionHandler {
28
102
  readonly inputNames: string[];
29
103
  readonly outputNames: string[];
30
104
 
105
+ readonly inputMetadata: InferenceSession.ValueMetadata[];
106
+ readonly outputMetadata: InferenceSession.ValueMetadata[];
107
+
31
108
  startProfiling(): void {
32
109
  // startProfiling is a no-op.
33
110
  //
package/lib/binding.ts CHANGED
@@ -19,12 +19,19 @@ type RunOptions = InferenceSession.RunOptions;
19
19
  * Binding exports a simple synchronized inference session object wrap.
20
20
  */
21
21
  export declare namespace Binding {
22
+ export interface ValueMetadata {
23
+ name: string;
24
+ isTensor: boolean;
25
+ symbolicDimensions: string[];
26
+ shape: number[];
27
+ type: number;
28
+ }
22
29
  export interface InferenceSession {
23
30
  loadModel(modelPath: string, options: SessionOptions): void;
24
31
  loadModel(buffer: ArrayBuffer, byteOffset: number, byteLength: number, options: SessionOptions): void;
25
32
 
26
- readonly inputNames: string[];
27
- readonly outputNames: string[];
33
+ readonly inputMetadata: ValueMetadata[];
34
+ readonly outputMetadata: ValueMetadata[];
28
35
 
29
36
  run(feeds: FeedsType, fetches: FetchesType, options: RunOptions): ReturnType;
30
37
 
package/lib/version.ts CHANGED
@@ -4,4 +4,4 @@
4
4
  // This file is generated by /js/scripts/update-version.ts
5
5
  // Do not modify file content manually.
6
6
 
7
- export const version = '1.21.0';
7
+ export const version = '1.22.0-dev.20250415-c18e06d5e3';
package/package.json CHANGED
@@ -13,10 +13,10 @@
13
13
  3
14
14
  ]
15
15
  },
16
- "version": "1.21.0",
16
+ "version": "1.22.0-dev.20250415-c18e06d5e3",
17
17
  "dependencies": {
18
18
  "global-agent": "^3.0.0",
19
- "onnxruntime-common": "1.21.0",
19
+ "onnxruntime-common": "1.22.0-dev.20250409-89f8206ba4",
20
20
  "tar": "^7.0.1"
21
21
  },
22
22
  "scripts": {
package/script/build.js CHANGED
@@ -1,49 +1,68 @@
1
- "use strict";
1
+ 'use strict';
2
2
  // Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  // Licensed under the MIT License.
4
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
- if (k2 === undefined) k2 = k;
6
- var desc = Object.getOwnPropertyDescriptor(m, k);
7
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
- desc = { enumerable: true, get: function() { return m[k]; } };
9
- }
10
- Object.defineProperty(o, k2, desc);
11
- }) : (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- o[k2] = m[k];
14
- }));
15
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
- Object.defineProperty(o, "default", { enumerable: true, value: v });
17
- }) : function(o, v) {
18
- o["default"] = v;
19
- });
20
- var __importStar = (this && this.__importStar) || function (mod) {
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) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
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 = (this && this.__importDefault) || function (mod) {
28
- return (mod && mod.__esModule) ? mod : { "default": mod };
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- const child_process_1 = require("child_process");
32
- const fs = __importStar(require("fs-extra"));
33
- const minimist_1 = __importDefault(require("minimist"));
34
- const os = __importStar(require("os"));
35
- const path = __importStar(require("path"));
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
- throw new Error(`unrecognized config: ${CONFIG}`);
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
- throw new Error(`unrecognized architecture: ${ARCH}`);
65
+ throw new Error(`unrecognized architecture: ${ARCH}`);
47
66
  }
48
67
  // --onnxruntime-build-dir=
49
68
  const ONNXRUNTIME_BUILD_DIR = buildArgs['onnxruntime-build-dir'];
@@ -71,78 +90,82 @@ const BIN_FOLDER = path.join(ROOT_FOLDER, 'bin');
71
90
  const BUILD_FOLDER = path.join(ROOT_FOLDER, 'build');
72
91
  // if rebuild, clean up the dist folders
73
92
  if (REBUILD) {
74
- fs.removeSync(BIN_FOLDER);
75
- fs.removeSync(BUILD_FOLDER);
93
+ fs.removeSync(BIN_FOLDER);
94
+ fs.removeSync(BUILD_FOLDER);
76
95
  }
77
96
  const args = [
78
- 'cmake-js',
79
- REBUILD ? 'reconfigure' : 'configure',
80
- `--arch=${ARCH}`,
81
- '--CDnapi_build_version=6',
82
- `--CDCMAKE_BUILD_TYPE=${CONFIG}`,
97
+ 'cmake-js',
98
+ REBUILD ? 'reconfigure' : 'configure',
99
+ `--arch=${ARCH}`,
100
+ '--CDnapi_build_version=6',
101
+ `--CDCMAKE_BUILD_TYPE=${CONFIG}`,
83
102
  ];
84
103
  if (ONNXRUNTIME_BUILD_DIR && typeof ONNXRUNTIME_BUILD_DIR === 'string') {
85
- args.push(`--CDONNXRUNTIME_BUILD_DIR=${ONNXRUNTIME_BUILD_DIR}`);
104
+ args.push(`--CDONNXRUNTIME_BUILD_DIR=${ONNXRUNTIME_BUILD_DIR}`);
86
105
  }
87
106
  if (ONNXRUNTIME_GENERATOR && typeof ONNXRUNTIME_GENERATOR === 'string') {
88
- args.push(`--CDONNXRUNTIME_GENERATOR=${ONNXRUNTIME_GENERATOR}`);
107
+ args.push(`--CDONNXRUNTIME_GENERATOR=${ONNXRUNTIME_GENERATOR}`);
89
108
  }
90
109
  if (USE_DML) {
91
- args.push('--CDUSE_DML=ON');
110
+ args.push('--CDUSE_DML=ON');
92
111
  }
93
112
  if (USE_WEBGPU) {
94
- args.push('--CDUSE_WEBGPU=ON');
113
+ args.push('--CDUSE_WEBGPU=ON');
95
114
  }
96
115
  if (USE_CUDA) {
97
- args.push('--CDUSE_CUDA=ON');
116
+ args.push('--CDUSE_CUDA=ON');
98
117
  }
99
118
  if (USE_TENSORRT) {
100
- args.push('--CDUSE_TENSORRT=ON');
119
+ args.push('--CDUSE_TENSORRT=ON');
101
120
  }
102
121
  if (USE_COREML) {
103
- args.push('--CDUSE_COREML=ON');
122
+ args.push('--CDUSE_COREML=ON');
104
123
  }
105
124
  if (USE_QNN) {
106
- args.push('--CDUSE_QNN=ON');
125
+ args.push('--CDUSE_QNN=ON');
107
126
  }
108
127
  if (DLL_DEPS) {
109
- args.push(`--CDORT_NODEJS_DLL_DEPS=${DLL_DEPS}`);
128
+ args.push(`--CDORT_NODEJS_DLL_DEPS=${DLL_DEPS}`);
110
129
  }
111
130
  // set CMAKE_OSX_ARCHITECTURES for macOS build
112
131
  if (os.platform() === 'darwin') {
113
- if (ARCH === 'x64') {
114
- args.push('--CDCMAKE_OSX_ARCHITECTURES=x86_64');
115
- }
116
- else if (ARCH === 'arm64') {
117
- args.push('--CDCMAKE_OSX_ARCHITECTURES=arm64');
118
- }
119
- else {
120
- throw new Error(`architecture not supported for macOS build: ${ARCH}`);
121
- }
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
+ }
122
139
  }
123
140
  // In Windows, "npx cmake-js configure" uses a powershell script to detect the Visual Studio installation.
124
141
  // The script uses the environment variable LIB. If an invalid path is specified in LIB, the script will fail.
125
142
  // So we override the LIB environment variable to remove invalid paths.
126
- const envOverride = os.platform() === 'win32' && process.env.LIB
143
+ const envOverride =
144
+ os.platform() === 'win32' && process.env.LIB
127
145
  ? { ...process.env, LIB: process.env.LIB.split(';').filter(fs.existsSync).join(';') }
128
146
  : process.env;
129
147
  // launch cmake-js configure
130
- const procCmakejs = (0, child_process_1.spawnSync)('npx', args, { shell: true, stdio: 'inherit', cwd: ROOT_FOLDER, env: envOverride });
148
+ const procCmakejs = (0, child_process_1.spawnSync)('npx', args, {
149
+ shell: true,
150
+ stdio: 'inherit',
151
+ cwd: ROOT_FOLDER,
152
+ env: envOverride,
153
+ });
131
154
  if (procCmakejs.status !== 0) {
132
- if (procCmakejs.error) {
133
- console.error(procCmakejs.error);
134
- }
135
- process.exit(procCmakejs.status === null ? undefined : procCmakejs.status);
155
+ if (procCmakejs.error) {
156
+ console.error(procCmakejs.error);
157
+ }
158
+ process.exit(procCmakejs.status === null ? undefined : procCmakejs.status);
136
159
  }
137
160
  // launch cmake to build
138
161
  const procCmake = (0, child_process_1.spawnSync)('cmake', ['--build', '.', '--config', CONFIG], {
139
- shell: true,
140
- stdio: 'inherit',
141
- cwd: BUILD_FOLDER,
162
+ shell: true,
163
+ stdio: 'inherit',
164
+ cwd: BUILD_FOLDER,
142
165
  });
143
166
  if (procCmake.status !== 0) {
144
- if (procCmake.error) {
145
- console.error(procCmake.error);
146
- }
147
- process.exit(procCmake.status === null ? undefined : procCmake.status);
167
+ if (procCmake.error) {
168
+ console.error(procCmake.error);
169
+ }
170
+ process.exit(procCmake.status === null ? undefined : procCmake.status);
148
171
  }
package/script/install.js CHANGED
@@ -9,7 +9,6 @@
9
9
 
10
10
  // The purpose of this script is to download the required binaries for the platform and architecture.
11
11
  // Currently, most of the binaries are already bundled in the package, except for the following:
12
- // - Linux/x64/CUDA 11
13
12
  // - Linux/x64/CUDA 12
14
13
  //
15
14
  // The CUDA binaries are not bundled because they are too large to be allowed in the npm registry. Instead, they are
package/script/prepack.js CHANGED
@@ -1,42 +1,59 @@
1
- "use strict";
1
+ 'use strict';
2
2
  // Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  // Licensed under the MIT License.
4
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
- if (k2 === undefined) k2 = k;
6
- var desc = Object.getOwnPropertyDescriptor(m, k);
7
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
- desc = { enumerable: true, get: function() { return m[k]; } };
9
- }
10
- Object.defineProperty(o, k2, desc);
11
- }) : (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- o[k2] = m[k];
14
- }));
15
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
- Object.defineProperty(o, "default", { enumerable: true, value: v });
17
- }) : function(o, v) {
18
- o["default"] = v;
19
- });
20
- var __importStar = (this && this.__importStar) || function (mod) {
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) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
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, "__esModule", { value: true });
28
- const fs = __importStar(require("fs-extra"));
29
- const path = __importStar(require("path"));
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
- const commonPackageJsonPath = path.join(__dirname, '..', '..', 'common', 'package.json');
32
- const selfPackageJsonPath = path.join(__dirname, '..', 'package.json');
33
- console.log(`=== start to update package.json: ${selfPackageJsonPath}`);
34
- const packageCommon = fs.readJSONSync(commonPackageJsonPath);
35
- const packageSelf = fs.readJSONSync(selfPackageJsonPath);
36
- const version = packageCommon.version;
37
- packageSelf.dependencies['onnxruntime-common'] = `${version}`;
38
- fs.writeJSONSync(selfPackageJsonPath, packageSelf, { spaces: 2 });
39
- console.log('=== finished updating package.json.');
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();