diff --git a/.nvmrc b/.nvmrc index b8e593f521..8ce7030825 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -20.15.1 +20.16.0 diff --git a/ACKNOWLEDGMENTS.md b/ACKNOWLEDGMENTS.md index 65f61dfd8c..71ea583ea1 100644 --- a/ACKNOWLEDGMENTS.md +++ b/ACKNOWLEDGMENTS.md @@ -85,6 +85,28 @@ Signal Desktop makes use of the following open source projects. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +## @indutny/simple-windows-notifications + + Copyright Fedor Indutny, 2024. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + ## @indutny/sneequals Copyright Fedor Indutny, 2022. @@ -107,400 +129,6 @@ Signal Desktop makes use of the following open source projects. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -## @nodert-win10-rs4/windows.data.xml.dom - - Copyright 2019, The NodeRT Contributors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ``` - ------------------------------------------------------------------------- - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - ``` - -## @nodert-win10-rs4/windows.ui.notifications - - Copyright 2019, The NodeRT Contributors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ``` - ------------------------------------------------------------------------- - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - ``` - ## @popperjs/core The MIT License (MIT) @@ -776,28 +404,6 @@ Signal Desktop makes use of the following open source projects. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -## @signalapp/windows-dummy-keystroke - - Copyright (c) 2022 David Rickard - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ## @types/fabric MIT License diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 84a7adf8a7..a254520858 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,10 +34,8 @@ Install the [Xcode Command-Line Tools](http://osxdaily.com/2014/02/12/install-co ### Windows -1. Download _Build Tools for Visual Studio 2019_ from the [Visual Studio 'older downloads' page](https://visualstudio.microsoft.com/vs/older-downloads/) and install it, including the "Desktop development with C++" option. -2. Install Windows 10 SDK, version 1803 (10.0.17134.x) from the [SDK Archive page](https://developer.microsoft.com/en-us/windows/downloads/sdk-archive) -3. Download and install the latest Python 3 release from https://www.python.org/downloads/windows/ (3.6 or later required). -4. Copy `platform.winmd` from your build tools location (like `C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\lib\x86\store\references`) to the Windows SDK path: `C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17134.0`. This is for our [`@nodert-win10-rs4`](https://github.com/NodeRT/NodeRT) dependencies. +1. Download _Build Tools for Visual Studio 2022 Community Edition_ from [Microsoft's website](https://visualstudio.microsoft.com/vs/community/) and install it, including the "Desktop development with C++" option. +2. Download and install the latest Python 3 release from https://www.python.org/downloads/windows/ (3.6 or later required). ### Linux diff --git a/app/WindowsNotifications.ts b/app/WindowsNotifications.ts index d025250f7a..a168780b0b 100644 --- a/app/WindowsNotifications.ts +++ b/app/WindowsNotifications.ts @@ -4,45 +4,32 @@ import { ipcMain as ipc } from 'electron'; import type { IpcMainInvokeEvent } from 'electron'; -// These dependencies don't export typescript properly -// https://github.com/NodeRT/NodeRT/issues/167 - -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore -import { XmlDocument } from '@nodert-win10-rs4/windows.data.xml.dom'; import { - ToastNotification, - ToastNotificationManager, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore -} from '@nodert-win10-rs4/windows.ui.notifications'; + Notifier, + sendDummyKeystroke, +} from '@indutny/simple-windows-notifications'; import * as log from '../ts/logging/log'; import { AUMID } from './startup_config'; import type { WindowsNotificationData } from '../ts/services/notifications'; import { renderWindowsToast } from './renderWindowsToast'; -export { sendDummyKeystroke } from '@signalapp/windows-dummy-keystroke'; +export { sendDummyKeystroke }; -const NOTIFICATION_GROUP = 'group'; -const NOTIFICATION_TAG = 'tag'; +const notifier = new Notifier(AUMID); + +const NOTIFICATION_ID = { + group: 'group', + tag: 'tag', +}; ipc.handle( 'windows-notifications:show', (_event: IpcMainInvokeEvent, data: WindowsNotificationData) => { try { // First, clear all previous notifications - we want just one notification at a time - clearAllNotifications(); - - const xmlDocument = new XmlDocument(); - xmlDocument.loadXml(renderWindowsToast(data)); - - const toast = new ToastNotification(xmlDocument); - toast.tag = NOTIFICATION_TAG; - toast.group = NOTIFICATION_GROUP; - - const notifier = ToastNotificationManager.createToastNotifier(AUMID); - notifier.show(toast); + notifier.remove(NOTIFICATION_ID); + notifier.show(renderWindowsToast(data), NOTIFICATION_ID); } catch (error) { log.error( `Windows Notifications: Failed to show notification: ${error.stack}` @@ -53,18 +40,10 @@ ipc.handle( ipc.handle('windows-notifications:clear-all', () => { try { - clearAllNotifications(); + notifier.remove(NOTIFICATION_ID); } catch (error) { log.error( `Windows Notifications: Failed to clear notifications: ${error.stack}` ); } }); - -function clearAllNotifications() { - ToastNotificationManager.history.remove( - NOTIFICATION_TAG, - NOTIFICATION_GROUP, - AUMID - ); -} diff --git a/package-lock.json b/package-lock.json index abcb8055dd..9d7a118811 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,16 +15,14 @@ "@formatjs/intl-localematcher": "0.2.32", "@indutny/dicer": "0.3.2", "@indutny/range-finder": "1.3.4", + "@indutny/simple-windows-notifications": "2.0.1", "@indutny/sneequals": "4.0.0", - "@nodert-win10-rs4/windows.data.xml.dom": "0.4.4", - "@nodert-win10-rs4/windows.ui.notifications": "0.4.4", "@popperjs/core": "2.11.6", "@react-aria/utils": "3.16.0", "@react-spring/web": "9.5.5", - "@signalapp/better-sqlite3": "8.8.0", + "@signalapp/better-sqlite3": "8.8.1", "@signalapp/libsignal-client": "0.55.1", "@signalapp/ringrtc": "2.46.1", - "@signalapp/windows-dummy-keystroke": "1.0.0", "@types/fabric": "4.5.3", "backbone": "1.4.0", "blob-util": "2.0.2", @@ -208,7 +206,7 @@ "csv-parse": "5.5.2", "danger": "11.3.1", "debug": "4.3.3", - "electron": "31.3.1", + "electron": "32.0.1", "electron-builder": "24.13.3", "electron-mocha": "12.2.0", "endanger": "7.0.4", @@ -261,7 +259,7 @@ "webpack-dev-server": "4.11.1" }, "engines": { - "node": "20.15.1" + "node": "20.16.0" }, "optionalDependencies": { "fs-xattr": "0.3.0" @@ -4149,6 +4147,16 @@ "node": ">=12" } }, + "node_modules/@indutny/simple-windows-notifications": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@indutny/simple-windows-notifications/-/simple-windows-notifications-2.0.1.tgz", + "integrity": "sha512-gV9+AgW4ERzzahqzSrDiZvyTIkmZFKrhv2V82gB8mRMSwNJElwN4eEchVjnO6ocqBQtXdBT0icunWphXnHWsjA==", + "hasInstallScript": true, + "dependencies": { + "bindings": "^1.5.0", + "node-addon-api": "*" + } + }, "node_modules/@indutny/sneequals": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@indutny/sneequals/-/sneequals-4.0.0.tgz", @@ -5096,24 +5104,6 @@ "node": ">= 8" } }, - "node_modules/@nodert-win10-rs4/windows.data.xml.dom": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/@nodert-win10-rs4/windows.data.xml.dom/-/windows.data.xml.dom-0.4.4.tgz", - "integrity": "sha512-DxnuNqQC1Fot/bLpOVqeykVGfLKXe0+staMRlh08aUYOFqSSGa4LLxhKvgCHlt65zhZJ89nip0Dw4HJSUPS2uA==", - "hasInstallScript": true, - "dependencies": { - "nan": "latest" - } - }, - "node_modules/@nodert-win10-rs4/windows.ui.notifications": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/@nodert-win10-rs4/windows.ui.notifications/-/windows.ui.notifications-0.4.4.tgz", - "integrity": "sha512-C03i5bj7LdE2Ta9ei7GiTPGb54bPd+ON8xqFAFfwPEeg+KTQEtG9R8JdTfiGJACYM583KiclMT1tKq8uyfZLcA==", - "hasInstallScript": true, - "dependencies": { - "nan": "latest" - } - }, "node_modules/@npmcli/agent": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@npmcli/agent/-/agent-2.2.0.tgz", @@ -7213,9 +7203,9 @@ "dev": true }, "node_modules/@signalapp/better-sqlite3": { - "version": "8.8.0", - "resolved": "https://registry.npmjs.org/@signalapp/better-sqlite3/-/better-sqlite3-8.8.0.tgz", - "integrity": "sha512-CnVbB0oNxIXgx4PEB03qRC+Oewji4jSfMK4tUBTmHHdQ/Z6YwZmRzhl0Em5LbAZOOtHh4EE15sAeVXGISDJ8Cw==", + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/@signalapp/better-sqlite3/-/better-sqlite3-8.8.1.tgz", + "integrity": "sha512-zxNKWbeFpNRmrXeXRxRt8LUl8crne+Cw8CmSajXGzgeC/7sEvh1lkcQFh2UWb+i0k5PGP6t7Tx6SiFFVWCLnGg==", "hasInstallScript": true, "dependencies": { "bindings": "^1.5.0", @@ -7338,16 +7328,6 @@ "tar": "^6.2.1" } }, - "node_modules/@signalapp/windows-dummy-keystroke": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@signalapp/windows-dummy-keystroke/-/windows-dummy-keystroke-1.0.0.tgz", - "integrity": "sha512-52C8p5sitWYGUIQ5iDt8uGls60JNc2xiYpx48Z4x70KnuIdHPjIe8KkXjXfvhK1bRoKde/hvq/Oa8H+nDGHd6Q==", - "hasInstallScript": true, - "dependencies": { - "bindings": "^1.5.0", - "nan": "^2.17.0" - } - }, "node_modules/@sindresorhus/is": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.0.tgz", @@ -18111,12 +18091,11 @@ } }, "node_modules/electron": { - "version": "31.3.1", - "resolved": "https://registry.npmjs.org/electron/-/electron-31.3.1.tgz", - "integrity": "sha512-9fiuWlRhBfygtcT+auRd/WdBK/f8LZZcrpx0RjpXhH2DPTP/PfnkC4JB1PW55qCbGbh4wAgkYbf4ExIag8oGCA==", + "version": "32.0.1", + "resolved": "https://registry.npmjs.org/electron/-/electron-32.0.1.tgz", + "integrity": "sha512-5Hd5Jaf9niYVR2hZxoRd3gOrcxPOxQV1XPV5WaoSfT9jLJHFadhlKtuSDIk3U6rQZke+aC7GqPPAv55nWFCMsA==", "dev": true, "hasInstallScript": true, - "license": "MIT", "dependencies": { "@electron/get": "^2.0.0", "@types/node": "^20.9.0", @@ -27604,11 +27583,6 @@ "thenify-all": "^1.0.0" } }, - "node_modules/nan": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.20.0.tgz", - "integrity": "sha512-bk3gXBZDGILuuo/6sKtr0DQmSThYHLtNCdSdXk9YkxD/jK6X2vmCyyXBBxyqZ4XcnzTyYEAThfX3DCEnLf6igw==" - }, "node_modules/nanoid": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", @@ -27718,6 +27692,14 @@ "integrity": "sha512-AGK2yQKIjRuqnc6VkX2Xj5d+QW8xZ87pa1UK6yA6ouUyuxfHuMP6umE5QK7UmTeOAymo+Zx1Fxiuw9rVx8taHQ==", "dev": true }, + "node_modules/node-addon-api": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.1.0.tgz", + "integrity": "sha512-yBY+qqWSv3dWKGODD6OGE6GnTX7Q2r+4+DfpqxHSHh8x0B4EKP9+wVGLS6U/AM1vxSNNmUEuIV5EGhYwPpfOwQ==", + "engines": { + "node": "^18 || ^20 || >= 21" + } + }, "node_modules/node-cleanup": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/node-cleanup/-/node-cleanup-2.1.2.tgz", diff --git a/package.json b/package.json index 063050dfeb..1547167157 100644 --- a/package.json +++ b/package.json @@ -98,16 +98,14 @@ "@formatjs/intl-localematcher": "0.2.32", "@indutny/dicer": "0.3.2", "@indutny/range-finder": "1.3.4", + "@indutny/simple-windows-notifications": "2.0.1", "@indutny/sneequals": "4.0.0", - "@nodert-win10-rs4/windows.data.xml.dom": "0.4.4", - "@nodert-win10-rs4/windows.ui.notifications": "0.4.4", "@popperjs/core": "2.11.6", "@react-aria/utils": "3.16.0", "@react-spring/web": "9.5.5", - "@signalapp/better-sqlite3": "8.8.0", + "@signalapp/better-sqlite3": "8.8.1", "@signalapp/libsignal-client": "0.55.1", "@signalapp/ringrtc": "2.46.1", - "@signalapp/windows-dummy-keystroke": "1.0.0", "@types/fabric": "4.5.3", "backbone": "1.4.0", "blob-util": "2.0.2", @@ -291,7 +289,7 @@ "csv-parse": "5.5.2", "danger": "11.3.1", "debug": "4.3.3", - "electron": "31.3.1", + "electron": "32.0.1", "electron-builder": "24.13.3", "electron-mocha": "12.2.0", "endanger": "7.0.4", @@ -370,7 +368,7 @@ } }, "engines": { - "node": "20.15.1" + "node": "20.16.0" }, "build": { "appId": "org.whispersystems.signal-desktop", @@ -443,6 +441,9 @@ "target": [ "nsis" ], + "files": [ + "node_modules/@indutny/simple-windows-notifications/build/Release/*.node" + ], "asarUnpack": [ "build/icons/win/icon.ico" ] @@ -576,14 +577,10 @@ "node_modules/@signalapp/better-sqlite3/build/Release/better_sqlite3.node", "node_modules/@signalapp/libsignal-client/prebuilds/${platform}-${arch}/*.node", "!node_modules/@signalapp/ringrtc/scripts/*", - "!node_modules/@nodert-win10-rs4/windows.data.xml.dom/*.cpp", - "!node_modules/@nodert-win10-rs4/windows.ui.notifications/*.cpp", "node_modules/@signalapp/ringrtc/build/${platform}/*${arch}*.node", "node_modules/mac-screen-capture-permissions/build/Release/*.node", "node_modules/fs-xattr/build/Release/*.node", - "node_modules/@nodert-win10-rs4/windows.data.xml.dom/build/Release/*.node", - "node_modules/@nodert-win10-rs4/windows.ui.notifications/build/Release/*.node", - "node_modules/@signalapp/windows-dummy-keystroke/build/Release/*.node", + "!node_modules/@indutny/simple-windows-notifications/*.cpp", "!**/node_modules/react-dom/*/*.development.js", "!node_modules/mp4box/**", "node_modules/mp4box/package.json", diff --git a/sticker-creator/src/components/ArtGrid.tsx b/sticker-creator/src/components/ArtGrid.tsx index e1b056b21f..dfd640233b 100644 --- a/sticker-creator/src/components/ArtGrid.tsx +++ b/sticker-creator/src/components/ArtGrid.tsx @@ -24,6 +24,7 @@ import { useArtType, useArtData, useArtOrder } from '../selectors/art'; import type { Props as DropZoneProps } from '../elements/DropZone'; import { DropZone } from '../elements/DropZone'; import { assert } from '../util/assert'; +import { getFilePath } from '../util/api'; import { processImage, ProcessImageError } from '../util/processImage'; import { useI18n } from '../contexts/I18n'; import { ArtType, MAX_STICKERS } from '../constants'; @@ -95,7 +96,9 @@ export function ArtGrid({ mode, showGuide }: Props): JSX.Element { const handleDrop = React.useCallback( async files => { - dispatch(initializeImages(files.map(({ path, name }) => path || name))); + dispatch( + initializeImages(files.map(file => getFilePath(file) || file.name)) + ); await Promise.all( files.map(async file => { try { @@ -103,7 +106,7 @@ export function ArtGrid({ mode, showGuide }: Props): JSX.Element { dispatch(addImageData(image)); } catch (e) { debug('Error processing image:', e); - dispatch(removeImage(file.path)); + dispatch(removeImage(getFilePath(file))); const key = e instanceof ProcessImageError diff --git a/sticker-creator/src/elements/DropZone.tsx b/sticker-creator/src/elements/DropZone.tsx index 8a4b578e82..b9b5be7813 100644 --- a/sticker-creator/src/elements/DropZone.tsx +++ b/sticker-creator/src/elements/DropZone.tsx @@ -2,17 +2,16 @@ // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; -import type { FileWithPath } from 'react-dropzone'; import styles from './DropZone.module.scss'; import { useI18n } from '../contexts/I18n'; +import { getFilePath } from '../util/api'; import { useStickerDropzone } from '../util/useStickerDropzone'; -import type { FileWithRequiredPath } from '../types.d'; export type Props = { readonly inner?: boolean; readonly label: string; - onDrop(files: ReadonlyArray): unknown; + onDrop(files: ReadonlyArray): unknown; onDragActive?(active: boolean): unknown; }; @@ -33,11 +32,9 @@ export function DropZone(props: Props): JSX.Element { const i18n = useI18n(); const handleDrop = React.useCallback( - (files: ReadonlyArray) => { + (files: ReadonlyArray) => { onDrop( - files.filter( - (file): file is FileWithRequiredPath => file.path !== undefined - ) + files.filter((file): file is File => getFilePath(file) !== undefined) ); }, [onDrop] diff --git a/sticker-creator/src/routes/art/MetaStage.tsx b/sticker-creator/src/routes/art/MetaStage.tsx index 6c71c07151..24f87aeb67 100644 --- a/sticker-creator/src/routes/art/MetaStage.tsx +++ b/sticker-creator/src/routes/art/MetaStage.tsx @@ -2,10 +2,10 @@ // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; -import type { FileWithPath } from 'react-dropzone'; import { useNavigate } from 'react-router-dom'; import { useDispatch } from 'react-redux'; +import { getFilePath } from '../../util/api'; import { processImage } from '../../util/processImage'; import { useStickerDropzone } from '../../util/useStickerDropzone'; import { H2, Text } from '../../elements/Typography'; @@ -19,7 +19,6 @@ import { useTitle, useAuthor, } from '../../selectors/art'; -import type { FileWithRequiredPath } from '../../types.d'; import { useI18n } from '../../contexts/I18n'; import styles from './MetaStage.module.scss'; import { AppStage } from './AppStage'; @@ -37,15 +36,12 @@ export function MetaStage(): JSX.Element { const [confirming, setConfirming] = React.useState(false); const onDrop = React.useCallback( - async ([file]: Array) => { + async ([file]: Array) => { try { - const stickerImage = await processImage( - file as FileWithRequiredPath, - artType - ); + const stickerImage = await processImage(file, artType); dispatch(setCover(stickerImage)); } catch (e) { - dispatch(removeImage(file.path || file.name)); + dispatch(removeImage(getFilePath(file) || file.name)); } }, [dispatch, artType] diff --git a/sticker-creator/src/types.d.ts b/sticker-creator/src/types.d.ts index 5fd08a01f8..71e418c34b 100644 --- a/sticker-creator/src/types.d.ts +++ b/sticker-creator/src/types.d.ts @@ -86,12 +86,3 @@ export type RenderTextCallbackType = (options: { text: string; key: number; }) => JSX.Element | string; - -// -// Files -// - -export type FileWithRequiredPath = File & - Readonly<{ - path: string; - }>; diff --git a/sticker-creator/src/util/api.ts b/sticker-creator/src/util/api.ts index d4a732c118..77f62b5427 100644 --- a/sticker-creator/src/util/api.ts +++ b/sticker-creator/src/util/api.ts @@ -13,6 +13,7 @@ declare global { onProgres?: () => void ): Promise; installStickerPack(packId: string, key: string): void; + getFilePath(file: File): string; } } @@ -51,3 +52,7 @@ export async function upload( packId, }; } + +export function getFilePath(file: File): string { + return window.getFilePath(file); +} diff --git a/sticker-creator/src/util/processImage.ts b/sticker-creator/src/util/processImage.ts index fe551def52..ef0692c960 100644 --- a/sticker-creator/src/util/processImage.ts +++ b/sticker-creator/src/util/processImage.ts @@ -3,13 +3,14 @@ import b64 from 'base64-js'; -import type { ArtImageData, FileWithRequiredPath } from '../types.d'; +import type { ArtImageData } from '../types.d'; import { MIN_IMAGE_SIZE, STICKER_SIZE, MAX_STICKER_BYTE_SIZE, ArtType, } from '../constants'; +import { getFilePath } from './api'; import { getAnimatedPngDataIfExists } from './apng'; import { assert } from './assert'; import { loadImage } from './loadImage'; @@ -37,7 +38,7 @@ export class ProcessImageError extends Error { } export async function processImage( - file: FileWithRequiredPath, + file: File, artType: ArtType ): Promise { const imageData = new Uint8Array(await file.arrayBuffer()); @@ -124,7 +125,7 @@ export async function processImage( } return { - path: file.path || file.name, + path: getFilePath(file) || file.name, buffer: processedBuffer, src: `data:${contentType};base64,${b64.fromByteArray(processedBuffer)}`, contentType, diff --git a/ts/state/ducks/composer.ts b/ts/state/ducks/composer.ts index 8660aada4f..aabb5f55ec 100644 --- a/ts/state/ducks/composer.ts +++ b/ts/state/ducks/composer.ts @@ -5,6 +5,7 @@ import path from 'path'; import { debounce, isEqual } from 'lodash'; import type { ThunkAction, ThunkDispatch } from 'redux-thunk'; import { v4 as generateUuid } from 'uuid'; +import { webUtils } from 'electron'; import type { ReadonlyDeep } from 'type-fest'; import type { @@ -1069,7 +1070,7 @@ function processAttachments({ generateScreenshot: true, }); if (!attachment) { - removeAttachment(conversationId, file.path)( + removeAttachment(conversationId, webUtils.getPathForFile(file))( dispatch, getState, undefined @@ -1086,7 +1087,7 @@ function processAttachments({ 'handleAttachmentsProcessing: failed to process attachment:', err.stack ); - removeAttachment(conversationId, file.path)( + removeAttachment(conversationId, webUtils.getPathForFile(file))( dispatch, getState, undefined diff --git a/ts/windows/sticker-creator/preload.ts b/ts/windows/sticker-creator/preload.ts index 2c55d8607e..c3e33b17cf 100644 --- a/ts/windows/sticker-creator/preload.ts +++ b/ts/windows/sticker-creator/preload.ts @@ -1,7 +1,7 @@ // Copyright 2023 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only -import { contextBridge, ipcRenderer } from 'electron'; +import { contextBridge, ipcRenderer, webUtils } from 'electron'; let onProgress: (() => void) | undefined; @@ -30,3 +30,7 @@ contextBridge.exposeInMainWorld( (packId: string, key: string) => ipcRenderer.invoke('install-sticker-pack', packId, key) ); + +contextBridge.exposeInMainWorld('getFilePath', (file: File) => + webUtils.getPathForFile(file) +);