diff --git a/.github/workflows/prebuild-main.yml b/.github/workflows/prebuild-main.yml index 9914ba80..57bf9a29 100644 --- a/.github/workflows/prebuild-main.yml +++ b/.github/workflows/prebuild-main.yml @@ -16,42 +16,40 @@ jobs: sudo dpkg --add-architecture i386 sudo apt-get update -y -qq sudo apt-get install -y g++-multilib gcc-multilib libcups2-dev libcups2-dev:i386 libc6-dev-i386 linux-libc-dev linux-libc-dev:i386 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 with: - node-version: 16.x - - uses: actions/checkout@v1 + node-version: 20.x + - uses: actions/checkout@v4 - run: npm i - name: Prebuild run: | - npm run apply-patches - npm run prebuild -- --strip --all --arch ia32 -u ${{ secrets.PREBUILD_TOKEN }} - npm run prebuild -- --strip --all --arch x64 -u ${{ secrets.PREBUILD_TOKEN }} + npm run prebuild -- --strip --arch ia32 -u ${{ secrets.PREBUILD_TOKEN }} + npm run prebuild -- --strip --arch x64 -u ${{ secrets.PREBUILD_TOKEN }} prebuild-macos: name: Prebuild Binaries for macOS runs-on: macos-latest timeout-minutes: 30 steps: - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 with: - node-version: 16.x - - uses: actions/checkout@v1 + node-version: 20.x + - uses: actions/checkout@v4 - run: npm i - name: Prebuild run: | - npm run apply-patches - npm run prebuild -- --strip --all --arch x64 -u ${{ secrets.PREBUILD_TOKEN }} + npm run prebuild -- --strip --arch x64 -u ${{ secrets.PREBUILD_TOKEN }} + npm run prebuild -- --strip --arch arm64 -u ${{ secrets.PREBUILD_TOKEN }} prebuild-windows: name: Prebuild Binaries for Windows runs-on: windows-latest timeout-minutes: 30 steps: - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 with: - node-version: 16.x - - uses: actions/checkout@v1 + node-version: 20.x + - uses: actions/checkout@v4 - run: npm i - name: Prebuild run: | - npm run apply-patches - npm run prebuild -- --strip --all --arch ia32 -u ${{ secrets.PREBUILD_TOKEN }} - npm run prebuild -- --strip --all --arch x64 -u ${{ secrets.PREBUILD_TOKEN }} + npm run prebuild -- --strip --arch ia32 -u ${{ secrets.PREBUILD_TOKEN }} + npm run prebuild -- --strip --arch x64 -u ${{ secrets.PREBUILD_TOKEN }} diff --git a/.github/workflows/prebuild-pr.yml b/.github/workflows/prebuild-pr.yml index a4ab8bda..feb4ab0e 100644 --- a/.github/workflows/prebuild-pr.yml +++ b/.github/workflows/prebuild-pr.yml @@ -14,42 +14,40 @@ jobs: sudo dpkg --add-architecture i386 sudo apt-get update -y -qq sudo apt-get install -y g++-multilib gcc-multilib libcups2-dev libcups2-dev:i386 libc6-dev-i386 linux-libc-dev linux-libc-dev:i386 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 with: - node-version: 16.x - - uses: actions/checkout@v1 + node-version: 20.x + - uses: actions/checkout@v4 - run: npm i - name: Prebuild run: | - npm run apply-patches - npm run prebuild -- --strip --all --arch ia32 - npm run prebuild -- --strip --all --arch x64 + npm run prebuild -- --strip --arch ia32 + npm run prebuild -- --strip --arch x64 prebuild-macos: name: Prebuild Binaries for macOS runs-on: macos-latest timeout-minutes: 30 steps: - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 with: - node-version: 16.x - - uses: actions/checkout@v1 + node-version: 20.x + - uses: actions/checkout@v4 - run: npm i - name: Prebuild run: | - npm run apply-patches - npm run prebuild -- --strip --all --arch x64 + npm run prebuild -- --strip --arch x64 + npm run prebuild -- --strip --arch arm64 prebuild-windows: name: Prebuild Binaries for Windows runs-on: windows-latest timeout-minutes: 30 steps: - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 with: - node-version: 16.x - - uses: actions/checkout@v1 + node-version: 20.x + - uses: actions/checkout@v4 - run: npm i - name: Prebuild run: | - npm run apply-patches - npm run prebuild -- --strip --all --arch ia32 - npm run prebuild -- --strip --all --arch x64 + npm run prebuild -- --strip --arch ia32 + npm run prebuild -- --strip --arch x64 diff --git a/.gitignore b/.gitignore index 72d91f8f..33fc3a1d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ node_modules *.swp *.log prebuilds -.prebuildrc \ No newline at end of file +.prebuildrc +.idea diff --git a/README.md b/README.md index a53d6bc5..b904908c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Native bind printers on POSIX and Windows OS from Node.js, electron and node-web [![npm version](https://badge.fury.io/js/@thiagoelg%2Fnode-printer.svg)](https://www.npmjs.com/package/@thiagoelg/node-printer) [![Prebuild Binaries and Publish](https://github.com/thiagoelg/node-printer/actions/workflows/prebuild-main.yml/badge.svg)](https://github.com/thiagoelg/node-printer/actions/workflows/prebuild-main.yml) -> Now compatible with Node.js 20+ with improved native bindings and updated dependencies +> Now compatible with Node.js 20+ and Electron 33+ with improved native bindings and updated dependencies > It just works with Node 12 because of @thiagoelg in his [PR](https://github.com/tojocky/node-printer/pull/261) diff --git a/binding.gyp b/binding.gyp index a7f9a401..8f04ec8c 100644 --- a/binding.gyp +++ b/binding.gyp @@ -25,7 +25,8 @@ 'include_dirs' : [ "= 20.0.0" }, "scripts": { "install": "prebuild-install || node-gyp rebuild", - "apply-patches": "patch-package", "prebuild-all": "prebuild --all --force --strip --verbose --openssl_fips=X", "prebuild": "prebuild", + "prebuild-electron": "prebuild --strip --verbose", "rebuild": "node-gyp rebuild", "test": "nodeunit test" }, diff --git a/patches/node-abi+3.8.0.patch b/patches/node-abi+3.8.0.patch deleted file mode 100644 index f4943bd3..00000000 --- a/patches/node-abi+3.8.0.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/node_modules/node-abi/abi_registry.json b/node_modules/node-abi/abi_registry.json -index 15bbb76..8d6b059 100644 ---- a/node_modules/node-abi/abi_registry.json -+++ b/node_modules/node-abi/abi_registry.json -@@ -52,7 +52,7 @@ - }, - { - "runtime": "node", -- "target": "17.0.0", -+ "target": "17.0.1", - "lts": false, - "future": false, - "abi": "102" diff --git a/src/node_printer_win.cc b/src/node_printer_win.cc index e2b6ac31..23107bb9 100644 --- a/src/node_printer_win.cc +++ b/src/node_printer_win.cc @@ -27,7 +27,7 @@ namespace{ * @param iSizeKbytes size in bytes of required allocating memory */ MemValue(const DWORD iSizeKbytes) { - _value = (Type*)malloc(iSizeKbytes); + this->_value = (Type*)malloc(iSizeKbytes); } ~MemValue () { @@ -35,10 +35,10 @@ namespace{ } protected: virtual void free() { - if(_value != NULL) + if(this->_value != NULL) { - ::free(_value); - _value = NULL; + ::free(this->_value); + this->_value = NULL; } } }; @@ -218,11 +218,11 @@ namespace{ //LPTSTR pPrinterName; ADD_V8_STRING_PROPERTY(name, pPrinterName) //LPTSTR pPrinterName; - ADD_V8_STRING_PROPERTY(printerName, pPrinterName); + ADD_V8_STRING_PROPERTY(printerName, pPrinterName) //LPTSTR pUserName; - ADD_V8_STRING_PROPERTY(user, pUserName); + ADD_V8_STRING_PROPERTY(user, pUserName) //LPTSTR pDatatype; - ADD_V8_STRING_PROPERTY(format, pDatatype); + ADD_V8_STRING_PROPERTY(format, pDatatype) //DWORD Priority; Nan::Set(result_printer_job, V8_STRING_NEW_UTF8("priority"), V8_VALUE_NEW(Number, job->Priority)); //DWORD Size; @@ -246,17 +246,17 @@ namespace{ // Specific fields //LPTSTR pMachineName; - ADD_V8_STRING_PROPERTY(machineName, pMachineName); + ADD_V8_STRING_PROPERTY(machineName, pMachineName) //LPTSTR pDocument; - ADD_V8_STRING_PROPERTY(document, pDocument); + ADD_V8_STRING_PROPERTY(document, pDocument) //LPTSTR pNotifyName; - ADD_V8_STRING_PROPERTY(notifyName, pNotifyName); + ADD_V8_STRING_PROPERTY(notifyName, pNotifyName) //LPTSTR pPrintProcessor; - ADD_V8_STRING_PROPERTY(printProcessor, pPrintProcessor); + ADD_V8_STRING_PROPERTY(printProcessor, pPrintProcessor) //LPTSTR pParameters; - ADD_V8_STRING_PROPERTY(parameters, pParameters); + ADD_V8_STRING_PROPERTY(parameters, pParameters) //LPTSTR pDriverName; - ADD_V8_STRING_PROPERTY(driverName, pDriverName); + ADD_V8_STRING_PROPERTY(driverName, pDriverName) #undef ADD_V8_STRING_PROPERTY //LPDEVMODE pDevMode; //PSECURITY_DESCRIPTOR pSecurityDescriptor;