From 694f6ffe108be76961ba5ebf314aef00b7df59f5 Mon Sep 17 00:00:00 2001 From: Jimmy Fitzback <> Date: Sun, 16 Apr 2023 16:32:45 +0900 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20use=20node:=20im?= =?UTF-8?q?ports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/env.js | 6 +++--- src/transformers.js | 3 +-- src/utils.js | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/env.js b/src/env.js index 55ff234ce..b00b19136 100644 --- a/src/env.js +++ b/src/env.js @@ -1,6 +1,6 @@ -import fs from 'fs'; -import path from 'path'; -import { fileURLToPath } from 'url'; +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; import { ONNX } from './backends/onnx.js'; const { env: onnx_env } = ONNX; diff --git a/src/transformers.js b/src/transformers.js index 99e99017d..1626f8f14 100644 --- a/src/transformers.js +++ b/src/transformers.js @@ -29,9 +29,8 @@ export { // environment variables export { env } from './env.js'; - // other export { pipeline } from './pipelines.js'; -export { Tensor } from './tensor_utils.js'; +export { Tensor } from './tensor_utils.js'; \ No newline at end of file diff --git a/src/utils.js b/src/utils.js index dca41ecb7..e6dee777a 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,5 +1,5 @@ -import { existsSync, statSync, promises } from 'fs'; +import { existsSync, statSync, promises } from 'node:fs'; import { env } from './env.js'; From 3adee5ed90588833f13087bd1ea5cc85152e86cc Mon Sep 17 00:00:00 2001 From: Jimmy Fitzback <> Date: Sun, 16 Apr 2023 16:34:22 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=F0=9F=90=9B=20use=20typeof=20self?= =?UTF-8?q?=20for=20canvas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/image_utils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/image_utils.js b/src/image_utils.js index ebf57cf34..deeba0419 100644 --- a/src/image_utils.js +++ b/src/image_utils.js @@ -1,5 +1,5 @@ -import fs from 'fs'; +import fs from 'node:fs'; import { getFile, isString } from './utils.js'; import { env } from './env.js'; @@ -8,7 +8,7 @@ let ImageClass = typeof Image !== 'undefined' ? Image : null; let ImageDataClass; let loadImageFunction; -if (typeof self !== 'undefined') { +if (typeof OffscreenCanvas !== 'undefined') { CanvasClass = OffscreenCanvas; loadImageFunction = self.createImageBitmap; ImageDataClass = ImageData; @@ -18,6 +18,7 @@ if (typeof self !== 'undefined') { CanvasClass = Canvas; loadImageFunction = async (/**@type {Blob}*/ b) => await loadImage(Buffer.from(await b.arrayBuffer())); ImageDataClass = ImageData; + // @ts-ignore ImageClass = Image; }