onnxruntime-node 1.19.2 → 1.20.0-dev.20241022-2d00351d7b

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 (32) hide show
  1. package/__commit.txt +1 -0
  2. package/bin/napi-v3/darwin/arm64/{libonnxruntime.1.19.2.dylib → libonnxruntime.1.20.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.19.2.dylib → libonnxruntime.1.20.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/{libonnxruntime.so.1.19.2 → libonnxruntime.so.1.20.0} +0 -0
  8. package/bin/napi-v3/linux/arm64/onnxruntime_binding.node +0 -0
  9. package/bin/napi-v3/linux/x64/libonnxruntime.so.1 +0 -0
  10. package/bin/napi-v3/linux/x64/{libonnxruntime.so.1.19.2 → libonnxruntime.so.1.20.0} +0 -0
  11. package/bin/napi-v3/linux/x64/onnxruntime_binding.node +0 -0
  12. package/bin/napi-v3/win32/arm64/DirectML.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/win32/x64/onnxruntime.dll +0 -0
  17. package/bin/napi-v3/win32/x64/onnxruntime_binding.node +0 -0
  18. package/dist/backend.js.map +1 -1
  19. package/dist/binding.js.map +1 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/version.js +1 -1
  22. package/dist/version.js.map +1 -1
  23. package/lib/backend.ts +12 -7
  24. package/lib/binding.ts +9 -10
  25. package/lib/index.ts +5 -5
  26. package/lib/version.ts +1 -1
  27. package/package.json +2 -2
  28. package/script/build.js +94 -67
  29. package/script/build.ts +15 -11
  30. package/script/install.js +15 -12
  31. package/script/prepack.js +49 -32
  32. package/script/prepack.ts +1 -1
package/__commit.txt ADDED
@@ -0,0 +1 @@
1
+ 2d00351d7b4975a4d03f6a437772b6976726a252
Binary file
@@ -1 +1 @@
1
- {"version":3,"file":"backend.js","sourceRoot":"","sources":["../lib/backend.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;AAIlC,uCAA2C;AAE3C,MAAM,yBAAyB;IAG7B,YAAY,YAA+B,EAAE,OAAwC;QAFrF,8DAA4C;QAG1C,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,4BAA4B;IAC9B,CAAC;IACD,YAAY;QACV,4BAA4B;IAC9B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAA+B,EAAE,OAAmC,EAAE,OAAoC;QAElH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,YAAY,CAAC,GAAG,EAAE;gBAChB,IAAI;oBACF,OAAO,CAAC,uBAAA,IA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C,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"binding.js","sourceRoot":"","sources":["../lib/binding.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AA2ClC,wBAAwB;AACX,QAAA,OAAO;AAChB,qGAAqG;AACrG,OAAO,CAAC,kBAAkB,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,2BAA2B,CAIxF,CAAC"}
1
+ {"version":3,"file":"binding.js","sourceRoot":"","sources":["../lib/binding.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AA0ClC,wBAAwB;AACX,QAAA,OAAO;AAClB,qGAAqG;AACrG,OAAO,CAAC,kBAAkB,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,2BAA2B,CAIpF,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;;AAElC,qDAAmC;AACnC,qCAAgD;AAAxC,gHAAA,qBAAqB,OAAA;AAC7B,2DAAwD;AACxD,uCAAkC;AAClC,uCAAoE;AAEpE,MAAM,QAAQ,GAAG,IAAA,+BAAqB,GAAE,CAAC;AACzC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;IAC9B,IAAA,oCAAe,EAAC,OAAO,CAAC,IAAI,EAAE,4BAAkB,EAAE,GAAG,CAAC,CAAC;CACxD;AAED,MAAM,CAAC,cAAc,CAAC,wBAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAC,KAAK,EAAE,iBAAO,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;;AAElC,qDAAmC;AACnC,qCAAkD;AAAzC,gHAAA,qBAAqB,OAAA;AAC9B,2DAA0D;AAC1D,uCAAoC;AACpC,uCAAsE;AAEtE,MAAM,QAAQ,GAAG,IAAA,+BAAqB,GAAE,CAAC;AACzC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;IAC9B,IAAA,oCAAe,EAAC,OAAO,CAAC,IAAI,EAAE,4BAAkB,EAAE,GAAG,CAAC,CAAC;CACxD;AAED,MAAM,CAAC,cAAc,CAAC,wBAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,iBAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC"}
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.19.2';
8
+ exports.version = '1.20.0-dev.20241022-2d00351d7b';
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
@@ -1,14 +1,14 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
3
 
4
- import {Backend, InferenceSession, InferenceSessionHandler, SessionHandler} from 'onnxruntime-common';
4
+ import { Backend, InferenceSession, InferenceSessionHandler, SessionHandler } from 'onnxruntime-common';
5
5
 
6
- import {Binding, binding} from './binding';
6
+ import { Binding, binding } from './binding';
7
7
 
8
8
  class OnnxruntimeSessionHandler implements InferenceSessionHandler {
9
9
  #inferenceSession: Binding.InferenceSession;
10
10
 
11
- constructor(pathOrBuffer: string|Uint8Array, options: InferenceSession.SessionOptions) {
11
+ constructor(pathOrBuffer: string | Uint8Array, options: InferenceSession.SessionOptions) {
12
12
  this.#inferenceSession = new binding.InferenceSession();
13
13
  if (typeof pathOrBuffer === 'string') {
14
14
  this.#inferenceSession.loadModel(pathOrBuffer, options);
@@ -33,8 +33,11 @@ class OnnxruntimeSessionHandler implements InferenceSessionHandler {
33
33
  // TODO: implement profiling
34
34
  }
35
35
 
36
- async run(feeds: SessionHandler.FeedsType, fetches: SessionHandler.FetchesType, options: InferenceSession.RunOptions):
37
- Promise<SessionHandler.ReturnType> {
36
+ async run(
37
+ feeds: SessionHandler.FeedsType,
38
+ fetches: SessionHandler.FetchesType,
39
+ options: InferenceSession.RunOptions,
40
+ ): Promise<SessionHandler.ReturnType> {
38
41
  return new Promise((resolve, reject) => {
39
42
  setImmediate(() => {
40
43
  try {
@@ -53,8 +56,10 @@ class OnnxruntimeBackend implements Backend {
53
56
  return Promise.resolve();
54
57
  }
55
58
 
56
- async createInferenceSessionHandler(pathOrBuffer: string|Uint8Array, options?: InferenceSession.SessionOptions):
57
- Promise<InferenceSessionHandler> {
59
+ async createInferenceSessionHandler(
60
+ pathOrBuffer: string | Uint8Array,
61
+ options?: InferenceSession.SessionOptions,
62
+ ): Promise<InferenceSessionHandler> {
58
63
  return new Promise((resolve, reject) => {
59
64
  setImmediate(() => {
60
65
  try {
package/lib/binding.ts CHANGED
@@ -1,21 +1,20 @@
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 } from 'onnxruntime-common';
5
5
 
6
6
  type SessionOptions = InferenceSession.SessionOptions;
7
7
  type FeedsType = {
8
8
  [name: string]: OnnxValue;
9
9
  };
10
10
  type FetchesType = {
11
- [name: string]: OnnxValue|null;
11
+ [name: string]: OnnxValue | null;
12
12
  };
13
13
  type ReturnType = {
14
14
  [name: string]: OnnxValue;
15
15
  };
16
16
  type RunOptions = InferenceSession.RunOptions;
17
17
 
18
-
19
18
  /**
20
19
  * Binding exports a simple synchronized inference session object wrap.
21
20
  */
@@ -33,7 +32,7 @@ export declare namespace Binding {
33
32
  }
34
33
 
35
34
  export interface InferenceSessionConstructor {
36
- new(): InferenceSession;
35
+ new (): InferenceSession;
37
36
  }
38
37
 
39
38
  export interface SupportedBackend {
@@ -44,9 +43,9 @@ export declare namespace Binding {
44
43
 
45
44
  // export native binding
46
45
  export const binding =
47
- // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
48
- require(`../bin/napi-v3/${process.platform}/${process.arch}/onnxruntime_binding.node`) as {
49
- // eslint-disable-next-line @typescript-eslint/naming-convention
50
- InferenceSession: Binding.InferenceSessionConstructor;
51
- listSupportedBackends: () => Binding.SupportedBackend[];
52
- };
46
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
47
+ require(`../bin/napi-v3/${process.platform}/${process.arch}/onnxruntime_binding.node`) as {
48
+ // eslint-disable-next-line @typescript-eslint/naming-convention
49
+ InferenceSession: Binding.InferenceSessionConstructor;
50
+ listSupportedBackends: () => Binding.SupportedBackend[];
51
+ };
package/lib/index.ts CHANGED
@@ -2,14 +2,14 @@
2
2
  // Licensed under the MIT License.
3
3
 
4
4
  export * from 'onnxruntime-common';
5
- export {listSupportedBackends} from './backend';
6
- import {registerBackend, env} from 'onnxruntime-common';
7
- import {version} from './version';
8
- import {onnxruntimeBackend, listSupportedBackends} from './backend';
5
+ export { listSupportedBackends } from './backend';
6
+ import { registerBackend, env } from 'onnxruntime-common';
7
+ import { version } from './version';
8
+ import { onnxruntimeBackend, listSupportedBackends } from './backend';
9
9
 
10
10
  const backends = listSupportedBackends();
11
11
  for (const backend of backends) {
12
12
  registerBackend(backend.name, onnxruntimeBackend, 100);
13
13
  }
14
14
 
15
- Object.defineProperty(env.versions, 'node', {value: version, enumerable: true});
15
+ Object.defineProperty(env.versions, 'node', { value: version, enumerable: true });
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.19.2';
7
+ export const version = '1.20.0-dev.20241022-2d00351d7b';
package/package.json CHANGED
@@ -13,9 +13,9 @@
13
13
  3
14
14
  ]
15
15
  },
16
- "version": "1.19.2",
16
+ "version": "1.20.0-dev.20241022-2d00351d7b",
17
17
  "dependencies": {
18
- "onnxruntime-common": "1.19.2",
18
+ "onnxruntime-common": "1.20.0-dev.20241016-2b8fc5529b",
19
19
  "tar": "^7.0.1"
20
20
  },
21
21
  "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'];
@@ -67,68 +86,76 @@ const BIN_FOLDER = path.join(ROOT_FOLDER, 'bin');
67
86
  const BUILD_FOLDER = path.join(ROOT_FOLDER, 'build');
68
87
  // if rebuild, clean up the dist folders
69
88
  if (REBUILD) {
70
- fs.removeSync(BIN_FOLDER);
71
- fs.removeSync(BUILD_FOLDER);
89
+ fs.removeSync(BIN_FOLDER);
90
+ fs.removeSync(BUILD_FOLDER);
72
91
  }
73
92
  const args = [
74
- 'cmake-js',
75
- (REBUILD ? 'reconfigure' : 'configure'),
76
- `--arch=${ARCH}`,
77
- '--CDnapi_build_version=6',
78
- `--CDCMAKE_BUILD_TYPE=${CONFIG}`,
93
+ 'cmake-js',
94
+ REBUILD ? 'reconfigure' : 'configure',
95
+ `--arch=${ARCH}`,
96
+ '--CDnapi_build_version=6',
97
+ `--CDCMAKE_BUILD_TYPE=${CONFIG}`,
79
98
  ];
80
99
  if (ONNXRUNTIME_BUILD_DIR && typeof ONNXRUNTIME_BUILD_DIR === 'string') {
81
- args.push(`--CDONNXRUNTIME_BUILD_DIR=${ONNXRUNTIME_BUILD_DIR}`);
100
+ args.push(`--CDONNXRUNTIME_BUILD_DIR=${ONNXRUNTIME_BUILD_DIR}`);
82
101
  }
83
102
  if (ONNXRUNTIME_GENERATOR && typeof ONNXRUNTIME_GENERATOR === 'string') {
84
- args.push(`--CDONNXRUNTIME_GENERATOR=${ONNXRUNTIME_GENERATOR}`);
103
+ args.push(`--CDONNXRUNTIME_GENERATOR=${ONNXRUNTIME_GENERATOR}`);
85
104
  }
86
105
  if (USE_DML) {
87
- args.push('--CDUSE_DML=ON');
106
+ args.push('--CDUSE_DML=ON');
88
107
  }
89
108
  if (USE_CUDA) {
90
- args.push('--CDUSE_CUDA=ON');
109
+ args.push('--CDUSE_CUDA=ON');
91
110
  }
92
111
  if (USE_TENSORRT) {
93
- args.push('--CDUSE_TENSORRT=ON');
112
+ args.push('--CDUSE_TENSORRT=ON');
94
113
  }
95
114
  if (USE_COREML) {
96
- args.push('--CDUSE_COREML=ON');
115
+ args.push('--CDUSE_COREML=ON');
97
116
  }
98
117
  if (USE_QNN) {
99
- args.push('--CDUSE_QNN=ON');
118
+ args.push('--CDUSE_QNN=ON');
100
119
  }
101
120
  // set CMAKE_OSX_ARCHITECTURES for macOS build
102
121
  if (os.platform() === 'darwin') {
103
- if (ARCH === 'x64') {
104
- args.push('--CDCMAKE_OSX_ARCHITECTURES=x86_64');
105
- }
106
- else if (ARCH === 'arm64') {
107
- args.push('--CDCMAKE_OSX_ARCHITECTURES=arm64');
108
- }
109
- else {
110
- throw new Error(`architecture not supported for macOS build: ${ARCH}`);
111
- }
122
+ if (ARCH === 'x64') {
123
+ args.push('--CDCMAKE_OSX_ARCHITECTURES=x86_64');
124
+ } else if (ARCH === 'arm64') {
125
+ args.push('--CDCMAKE_OSX_ARCHITECTURES=arm64');
126
+ } else {
127
+ throw new Error(`architecture not supported for macOS build: ${ARCH}`);
128
+ }
112
129
  }
113
130
  // In Windows, "npx cmake-js configure" uses a powershell script to detect the Visual Studio installation.
114
131
  // The script uses the environment variable LIB. If an invalid path is specified in LIB, the script will fail.
115
132
  // So we override the LIB environment variable to remove invalid paths.
116
- const envOverride = os.platform() === 'win32' && process.env.LIB ?
117
- { ...process.env, LIB: process.env.LIB.split(';').filter(fs.existsSync).join(';') } :
118
- process.env;
133
+ const envOverride =
134
+ os.platform() === 'win32' && process.env.LIB
135
+ ? { ...process.env, LIB: process.env.LIB.split(';').filter(fs.existsSync).join(';') }
136
+ : process.env;
119
137
  // launch cmake-js configure
120
- const procCmakejs = (0, child_process_1.spawnSync)('npx', args, { shell: true, stdio: 'inherit', cwd: ROOT_FOLDER, env: envOverride });
138
+ const procCmakejs = (0, child_process_1.spawnSync)('npx', args, {
139
+ shell: true,
140
+ stdio: 'inherit',
141
+ cwd: ROOT_FOLDER,
142
+ env: envOverride,
143
+ });
121
144
  if (procCmakejs.status !== 0) {
122
- if (procCmakejs.error) {
123
- console.error(procCmakejs.error);
124
- }
125
- process.exit(procCmakejs.status === null ? undefined : procCmakejs.status);
145
+ if (procCmakejs.error) {
146
+ console.error(procCmakejs.error);
147
+ }
148
+ process.exit(procCmakejs.status === null ? undefined : procCmakejs.status);
126
149
  }
127
150
  // launch cmake to build
128
- const procCmake = (0, child_process_1.spawnSync)('cmake', ['--build', '.', '--config', CONFIG], { shell: true, stdio: 'inherit', cwd: BUILD_FOLDER });
151
+ const procCmake = (0, child_process_1.spawnSync)('cmake', ['--build', '.', '--config', CONFIG], {
152
+ shell: true,
153
+ stdio: 'inherit',
154
+ cwd: BUILD_FOLDER,
155
+ });
129
156
  if (procCmake.status !== 0) {
130
- if (procCmake.error) {
131
- console.error(procCmake.error);
132
- }
133
- process.exit(procCmake.status === null ? undefined : procCmake.status);
157
+ if (procCmake.error) {
158
+ console.error(procCmake.error);
159
+ }
160
+ process.exit(procCmake.status === null ? undefined : procCmake.status);
134
161
  }
package/script/build.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 {spawnSync} from 'child_process';
4
+ import { spawnSync } from 'child_process';
5
5
  import * as fs from 'fs-extra';
6
6
  import minimist from 'minimist';
7
7
  import * as os from 'os';
@@ -11,13 +11,13 @@ import * as path from 'path';
11
11
  const buildArgs = minimist(process.argv.slice(2));
12
12
 
13
13
  // --config=Debug|Release|RelWithDebInfo
14
- const CONFIG: 'Debug'|'Release'|'RelWithDebInfo' =
15
- buildArgs.config || (os.platform() === 'win32' ? 'RelWithDebInfo' : 'Release');
14
+ const CONFIG: 'Debug' | 'Release' | 'RelWithDebInfo' =
15
+ buildArgs.config || (os.platform() === 'win32' ? 'RelWithDebInfo' : 'Release');
16
16
  if (CONFIG !== 'Debug' && CONFIG !== 'Release' && CONFIG !== 'RelWithDebInfo') {
17
17
  throw new Error(`unrecognized config: ${CONFIG}`);
18
18
  }
19
19
  // --arch=x64|ia32|arm64|arm
20
- const ARCH: 'x64'|'ia32'|'arm64'|'arm' = buildArgs.arch || os.arch();
20
+ const ARCH: 'x64' | 'ia32' | 'arm64' | 'arm' = buildArgs.arch || os.arch();
21
21
  if (ARCH !== 'x64' && ARCH !== 'ia32' && ARCH !== 'arm64' && ARCH !== 'arm') {
22
22
  throw new Error(`unrecognized architecture: ${ARCH}`);
23
23
  }
@@ -51,7 +51,7 @@ if (REBUILD) {
51
51
 
52
52
  const args = [
53
53
  'cmake-js',
54
- (REBUILD ? 'reconfigure' : 'configure'),
54
+ REBUILD ? 'reconfigure' : 'configure',
55
55
  `--arch=${ARCH}`,
56
56
  '--CDnapi_build_version=6',
57
57
  `--CDCMAKE_BUILD_TYPE=${CONFIG}`,
@@ -92,12 +92,13 @@ if (os.platform() === 'darwin') {
92
92
  // In Windows, "npx cmake-js configure" uses a powershell script to detect the Visual Studio installation.
93
93
  // The script uses the environment variable LIB. If an invalid path is specified in LIB, the script will fail.
94
94
  // So we override the LIB environment variable to remove invalid paths.
95
- const envOverride = os.platform() === 'win32' && process.env.LIB ?
96
- {...process.env, LIB: process.env.LIB.split(';').filter(fs.existsSync).join(';')} :
97
- process.env;
95
+ const envOverride =
96
+ os.platform() === 'win32' && process.env.LIB
97
+ ? { ...process.env, LIB: process.env.LIB.split(';').filter(fs.existsSync).join(';') }
98
+ : process.env;
98
99
 
99
100
  // launch cmake-js configure
100
- const procCmakejs = spawnSync('npx', args, {shell: true, stdio: 'inherit', cwd: ROOT_FOLDER, env: envOverride});
101
+ const procCmakejs = spawnSync('npx', args, { shell: true, stdio: 'inherit', cwd: ROOT_FOLDER, env: envOverride });
101
102
  if (procCmakejs.status !== 0) {
102
103
  if (procCmakejs.error) {
103
104
  console.error(procCmakejs.error);
@@ -106,8 +107,11 @@ if (procCmakejs.status !== 0) {
106
107
  }
107
108
 
108
109
  // launch cmake to build
109
- const procCmake =
110
- spawnSync('cmake', ['--build', '.', '--config', CONFIG], {shell: true, stdio: 'inherit', cwd: BUILD_FOLDER});
110
+ const procCmake = spawnSync('cmake', ['--build', '.', '--config', CONFIG], {
111
+ shell: true,
112
+ stdio: 'inherit',
113
+ cwd: BUILD_FOLDER,
114
+ });
111
115
  if (procCmake.status !== 0) {
112
116
  if (procCmake.error) {
113
117
  console.error(procCmake.error);
package/script/install.js CHANGED
@@ -21,7 +21,7 @@ const os = require('os');
21
21
  const fs = require('fs');
22
22
  const path = require('path');
23
23
  const tar = require('tar');
24
- const {Readable} = require('stream');
24
+ const { Readable } = require('stream');
25
25
 
26
26
  // commandline flag:
27
27
  // --onnxruntime-node-install-cuda Force install the CUDA EP binaries. Try to detect the CUDA version.
@@ -49,7 +49,7 @@ const ORT_VERSION = require('../package.json').version;
49
49
  const npm_config_local_prefix = process.env.npm_config_local_prefix;
50
50
  const npm_package_json = process.env.npm_package_json;
51
51
  const SKIP_LOCAL_INSTALL =
52
- npm_config_local_prefix && npm_package_json && path.dirname(npm_package_json) === npm_config_local_prefix;
52
+ npm_config_local_prefix && npm_package_json && path.dirname(npm_package_json) === npm_config_local_prefix;
53
53
 
54
54
  const shouldInstall = FORCE_INSTALL || (!SKIP_LOCAL_INSTALL && IS_LINUX_X64 && BIN_FOLDER_EXISTS && !CUDA_DLL_EXISTS);
55
55
  if (NO_INSTALL || !shouldInstall) {
@@ -59,12 +59,14 @@ if (NO_INSTALL || !shouldInstall) {
59
59
  // Step.2: Download the required binaries
60
60
  const artifactUrl = {
61
61
  11: `https://github.com/microsoft/onnxruntime/releases/download/v${ORT_VERSION}/onnxruntime-linux-x64-gpu-${
62
- ORT_VERSION}.tgz`,
62
+ ORT_VERSION
63
+ }.tgz`,
63
64
  12: `https://github.com/microsoft/onnxruntime/releases/download/v${ORT_VERSION}/onnxruntime-linux-x64-gpu-cuda12-${
64
- ORT_VERSION}.tgz`
65
+ ORT_VERSION
66
+ }.tgz`,
65
67
  }[INSTALL_CUDA_FLAG || tryGetCudaVersion()];
66
68
  console.log(`Downloading "${artifactUrl}"...`);
67
- fetch(artifactUrl).then(res => {
69
+ fetch(artifactUrl).then((res) => {
68
70
  if (!res.ok) {
69
71
  throw new Error(`Failed to download the binaries: ${res.status} ${res.statusText}.
70
72
 
@@ -81,7 +83,8 @@ Use "--onnxruntime-node-install-cuda=skip" to skip the installation. You will st
81
83
  ]);
82
84
 
83
85
  Readable.fromWeb(res.body)
84
- .pipe(tar.t({
86
+ .pipe(
87
+ tar.t({
85
88
  strict: true,
86
89
  onentry: (entry) => {
87
90
  const filename = path.basename(entry.path);
@@ -92,16 +95,16 @@ Use "--onnxruntime-node-install-cuda=skip" to skip the installation. You will st
92
95
  console.log(`Finished extracting "${filename}".`);
93
96
  });
94
97
  }
95
- }
96
- }))
97
- .on('error', (err) => {
98
- throw new Error(`Failed to extract the binaries: ${err.message}.
98
+ },
99
+ }),
100
+ )
101
+ .on('error', (err) => {
102
+ throw new Error(`Failed to extract the binaries: ${err.message}.
99
103
 
100
104
  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.`);
101
- });
105
+ });
102
106
  });
103
107
 
104
-
105
108
  function tryGetCudaVersion() {
106
109
  // Should only return 11 or 12.
107
110
 
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();
package/script/prepack.ts CHANGED
@@ -12,7 +12,7 @@ function updatePackageJson() {
12
12
  const packageSelf = fs.readJSONSync(selfPackageJsonPath);
13
13
  const version = packageCommon.version;
14
14
  packageSelf.dependencies['onnxruntime-common'] = `${version}`;
15
- fs.writeJSONSync(selfPackageJsonPath, packageSelf, {spaces: 2});
15
+ fs.writeJSONSync(selfPackageJsonPath, packageSelf, { spaces: 2 });
16
16
  console.log('=== finished updating package.json.');
17
17
  }
18
18