diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index 6f574b7e..403a62a4 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -41,6 +41,26 @@ jobs: - name: Enable code signing only for current repo if: github.event.pull_request.head.repo.full_name == github.repository run: echo "CSC_FOR_PULL_REQUEST=true" >> $GITHUB_ENV + + - name: Set dev version + run: | + echo "Creating patch-version.js" + cat << 'EOF' > patch-version.js + const fs = require('fs'); + const pkg = require('./package.json'); + const sha = process.env.COMMIT_SHA.slice(0, 7); + const pr = process.env.PR_NUMBER; + const baseVersion = pkg.version.replace(/-dev.*$/, ''); + pkg.version = `${baseVersion}-dev.pr${pr}.${sha}`; + fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); + console.log("Updated version:", pkg.version); + EOF + node patch-version.js + shell: bash + env: + GITHUB_SHA: ${{ github.sha }} + PR_NUMBER: ${{ github.event.pull_request.number }} + COMMIT_SHA: ${{ github.event.pull_request.head.sha }} - name: Build/release Electron app uses: samuelmeuli/action-electron-builder@v1 diff --git a/package-lock.json b/package-lock.json index 6a3cb6bd..3a309013 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,7 @@ "@nethesis/nethesis-brands-svg-icons": "github:nethesis/Font-Awesome#ns-brands", "@nethesis/nethesis-light-svg-icons": "github:nethesis/Font-Awesome#ns-light", "@nethesis/nethesis-solid-svg-icons": "github:nethesis/Font-Awesome#ns-solid", - "@nethesis/phone-island": "^0.13.6", + "@nethesis/phone-island": "^0.14.0", "@tailwindcss/forms": "^0.5.7", "@types/lodash": "^4.14.202", "@types/node": "^18.19.9", @@ -5553,76 +5553,6 @@ "node": ">= 10.0.0" } }, - "node_modules/@motionone/animation": { - "version": "10.18.0", - "resolved": "https://registry.npmjs.org/@motionone/animation/-/animation-10.18.0.tgz", - "integrity": "sha512-9z2p5GFGCm0gBsZbi8rVMOAJCtw1WqBTIPw3ozk06gDvZInBPIsQcHgYogEJ4yuHJ+akuW8g1SEIOpTOvYs8hw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@motionone/easing": "^10.18.0", - "@motionone/types": "^10.17.1", - "@motionone/utils": "^10.18.0", - "tslib": "^2.3.1" - } - }, - "node_modules/@motionone/dom": { - "version": "10.18.0", - "resolved": "https://registry.npmjs.org/@motionone/dom/-/dom-10.18.0.tgz", - "integrity": "sha512-bKLP7E0eyO4B2UaHBBN55tnppwRnaE3KFfh3Ps9HhnAkar3Cb69kUCJY9as8LrccVYKgHA+JY5dOQqJLOPhF5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "@motionone/animation": "^10.18.0", - "@motionone/generators": "^10.18.0", - "@motionone/types": "^10.17.1", - "@motionone/utils": "^10.18.0", - "hey-listen": "^1.0.8", - "tslib": "^2.3.1" - } - }, - "node_modules/@motionone/easing": { - "version": "10.18.0", - "resolved": "https://registry.npmjs.org/@motionone/easing/-/easing-10.18.0.tgz", - "integrity": "sha512-VcjByo7XpdLS4o9T8t99JtgxkdMcNWD3yHU/n6CLEz3bkmKDRZyYQ/wmSf6daum8ZXqfUAgFeCZSpJZIMxaCzg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@motionone/utils": "^10.18.0", - "tslib": "^2.3.1" - } - }, - "node_modules/@motionone/generators": { - "version": "10.18.0", - "resolved": "https://registry.npmjs.org/@motionone/generators/-/generators-10.18.0.tgz", - "integrity": "sha512-+qfkC2DtkDj4tHPu+AFKVfR/C30O1vYdvsGYaR13W/1cczPrrcjdvYCj0VLFuRMN+lP1xvpNZHCRNM4fBzn1jg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@motionone/types": "^10.17.1", - "@motionone/utils": "^10.18.0", - "tslib": "^2.3.1" - } - }, - "node_modules/@motionone/types": { - "version": "10.17.1", - "resolved": "https://registry.npmjs.org/@motionone/types/-/types-10.17.1.tgz", - "integrity": "sha512-KaC4kgiODDz8hswCrS0btrVrzyU2CSQKO7Ps90ibBVSQmjkrt2teqta6/sOG59v7+dPnKMAg13jyqtMKV2yJ7A==", - "dev": true, - "license": "MIT" - }, - "node_modules/@motionone/utils": { - "version": "10.18.0", - "resolved": "https://registry.npmjs.org/@motionone/utils/-/utils-10.18.0.tgz", - "integrity": "sha512-3XVF7sgyTSI2KWvTf6uLlBJ5iAgRgmvp3bpuOiQJvInd4nZ19ET8lX5unn30SlmRH7hXbBbH+Gxd0m0klJ3Xtw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@motionone/types": "^10.17.1", - "hey-listen": "^1.0.8", - "tslib": "^2.3.1" - } - }, "node_modules/@nethesis/nethesis-brands-svg-icons": { "version": "6.2.1", "resolved": "git+ssh://git@github.com/nethesis/Font-Awesome.git#dbcf431acf0e504145486c9ac70f14946279e2e7", @@ -5696,9 +5626,9 @@ } }, "node_modules/@nethesis/phone-island": { - "version": "0.13.6", - "resolved": "https://registry.npmjs.org/@nethesis/phone-island/-/phone-island-0.13.6.tgz", - "integrity": "sha512-tJD7Egimppd2+k3lT6Ujt7TTIgS0evaVPjo4dBqzA1CM1ZtIXDpdJBHA2tz8btIouQEGinPOH+8qT1JeMWQX2g==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@nethesis/phone-island/-/phone-island-0.14.0.tgz", + "integrity": "sha512-XFGdAeA5ZUKMb4MVd4wIFaAVmfuxYvQAtQSC/Qdw7X9jOG7Vb4wkIoIb0sVfcnOPobcg0RVk7EMU+e8FIgOr1w==", "dev": true, "license": "GPL-3.0-or-later", "dependencies": { @@ -5713,7 +5643,7 @@ "@swc/helpers": "^0.4.12", "@testing-library/jest-dom": "^5.11.4", "@testing-library/user-event": "^12.1.10", - "framer-motion": "^8.5.5", + "framer-motion": "^12.0.0", "i18next": "^22.4.9", "i18next-browser-languagedetector": "^7.0.1", "i18next-http-backend": "^2.1.1", @@ -5732,25 +5662,6 @@ "webrtc-adapter": "^9.0.1" } }, - "node_modules/@nethesis/phone-island/node_modules/@emotion/is-prop-valid": { - "version": "0.8.8", - "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz", - "integrity": "sha512-u5WtneEAr5IDG2Wv65yhunPSMLIpuKsbuOktRojfrEiEvRyC85LgPMZI63cr7NUqT8ZIGdSVg8ZKGxIug4lXcA==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "@emotion/memoize": "0.7.4" - } - }, - "node_modules/@nethesis/phone-island/node_modules/@emotion/memoize": { - "version": "0.7.4", - "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.4.tgz", - "integrity": "sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==", - "dev": true, - "license": "MIT", - "optional": true - }, "node_modules/@nethesis/phone-island/node_modules/@headlessui/react": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@headlessui/react/-/react-2.2.0.tgz", @@ -5861,22 +5772,31 @@ } }, "node_modules/@nethesis/phone-island/node_modules/framer-motion": { - "version": "8.5.5", - "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-8.5.5.tgz", - "integrity": "sha512-5IDx5bxkjWHWUF3CVJoSyUVOtrbAxtzYBBowRE2uYI/6VYhkEBD+rbTHEGuUmbGHRj6YqqSfoG7Aa1cLyWCrBA==", + "version": "12.10.5", + "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-12.10.5.tgz", + "integrity": "sha512-p6VF1YkwWvNDFzg5IQ5lqPx11Td4TQ6LqDnshV7sWj0Nrp4dwz2/aEzmgh9WA9ridcTIJ625Fr0oiuhgqIoFwQ==", "dev": true, "license": "MIT", "dependencies": { - "@motionone/dom": "^10.15.3", - "hey-listen": "^1.0.8", + "motion-dom": "^12.10.5", + "motion-utils": "^12.9.4", "tslib": "^2.4.0" }, - "optionalDependencies": { - "@emotion/is-prop-valid": "^0.8.2" - }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "@emotion/is-prop-valid": "*", + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@emotion/is-prop-valid": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } } }, "node_modules/@nethesis/phone-island/node_modules/fs-extra": { @@ -5914,6 +5834,23 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/@nethesis/phone-island/node_modules/motion-dom": { + "version": "12.10.5", + "resolved": "https://registry.npmjs.org/motion-dom/-/motion-dom-12.10.5.tgz", + "integrity": "sha512-F7XKmhxXEH/y3aWWf0N2w69wNSN+6PcJ1seqR1WolClmXpPhj+xwzs9j5CpsMFzeHR1D7irl3JcWMToPRwX6Hg==", + "dev": true, + "license": "MIT", + "dependencies": { + "motion-utils": "^12.9.4" + } + }, + "node_modules/@nethesis/phone-island/node_modules/motion-utils": { + "version": "12.9.4", + "resolved": "https://registry.npmjs.org/motion-utils/-/motion-utils-12.9.4.tgz", + "integrity": "sha512-BW3I65zeM76CMsfh3kHid9ansEJk9Qvl+K5cu4DVHKGsI52n76OJ4z2CUJUV+Mn3uEP9k1JJA3tClG0ggSrRcg==", + "dev": true, + "license": "MIT" + }, "node_modules/@nethesis/phone-island/node_modules/react-refresh": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz", @@ -16112,13 +16049,6 @@ "he": "bin/he" } }, - "node_modules/hey-listen": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/hey-listen/-/hey-listen-1.0.8.tgz", - "integrity": "sha512-COpmrF2NOg4TBWUJ5UVyaCU2A88wEMkUPK4hNqyCkqHbxT92BbvfjoSozkAIIm6XhicGlJHhFdullInrdhwU8Q==", - "dev": true, - "license": "MIT" - }, "node_modules/hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", diff --git a/package.json b/package.json index 3bf0a2f9..a1cdf509 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@nethesis/nethesis-brands-svg-icons": "github:nethesis/Font-Awesome#ns-brands", "@nethesis/nethesis-light-svg-icons": "github:nethesis/Font-Awesome#ns-light", "@nethesis/nethesis-solid-svg-icons": "github:nethesis/Font-Awesome#ns-solid", - "@nethesis/phone-island": "^0.13.6", + "@nethesis/phone-island": "^0.14.0", "@tailwindcss/forms": "^0.5.7", "@types/lodash": "^4.14.202", "@types/node": "^18.19.9", diff --git a/src/renderer/src/components/ElectronDraggableWindow.tsx b/src/renderer/src/components/ElectronDraggableWindow.tsx index 32a8a611..7faf71c9 100644 --- a/src/renderer/src/components/ElectronDraggableWindow.tsx +++ b/src/renderer/src/components/ElectronDraggableWindow.tsx @@ -10,6 +10,7 @@ export const ElectronDraggableWindow = ({ children }) => { const mouseDownEvent = useRef(null) const mouseUpEvent = useRef(null) const target = useRef(null) + const lastMouseDownTime = useRef(0) const handleMouseClick = (e: MouseEvent) => { if (e['pointerId'] !== -1) { @@ -28,6 +29,12 @@ export const ElectronDraggableWindow = ({ children }) => { }; const handleMouseDown = (e: MouseEvent) => { + const now = Date.now(); + if (now - lastMouseDownTime.current < 100) { + return; + } + lastMouseDownTime.current = now; + if (!isDrag.current && !mouseDownEvent.current) { target.current = e.target passthroughEvent.current = false @@ -45,16 +52,28 @@ export const ElectronDraggableWindow = ({ children }) => { mouseUpEvent.current = e }; + const handleMouseLeave = () => { + if (isDrag.current) { + window.electron.send(IPC_EVENTS.STOP_DRAG); + isDrag.current = false; + mouseDownEvent.current = null; + } + }; + + const handleWindowBlur = () => { + if (isDrag.current) { + isDrag.current = false; + mouseDownEvent.current = null; + window.electron.send(IPC_EVENTS.STOP_DRAG); + } + }; + useEffect(() => { - document.addEventListener('click', handleMouseClick, { - capture: true, - }); - document.addEventListener('mousedown', handleMouseDown, { - capture: true, - }); - document.addEventListener('mouseup', handleMouseUp, { - capture: true, - }); + document.addEventListener('click', handleMouseClick, { capture: true }); + document.addEventListener('mousedown', handleMouseDown, { capture: true }); + document.addEventListener('mouseup', handleMouseUp, { capture: true }); + window.addEventListener('mouseleave', handleMouseLeave); + window.addEventListener('blur', handleWindowBlur); window.electron.receive(IPC_EVENTS.ENABLE_CLICK, () => { if (target.current && !passthroughEvent.current) { @@ -64,18 +83,19 @@ export const ElectronDraggableWindow = ({ children }) => { cancelable: true, view: window, }); - //we create an untrusted event, with this property we ensure that this event was created by us newEvent['nethlink'] = true target.current.dispatchEvent(newEvent); } - }) + }); return () => { document.removeEventListener('click', handleMouseClick); document.removeEventListener('mousedown', handleMouseDown); document.removeEventListener('mouseup', handleMouseUp); + window.removeEventListener('mouseleave', handleMouseLeave); + window.removeEventListener('blur', handleWindowBlur); }; - }, [handleMouseUp]); + }, []); return (
{ {children}
); -}; - +}; \ No newline at end of file