From f1c3c41455f366ad766adf0eff77680ba0725978 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 4 Oct 2022 20:59:43 +0200 Subject: [PATCH 1/5] :bug: Fix compatibility issues with some bigint api and safari --- common/src/app/common/uuid_impl.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/common/src/app/common/uuid_impl.js b/common/src/app/common/uuid_impl.js index 3766d3191..06f0220ef 100644 --- a/common/src/app/common/uuid_impl.js +++ b/common/src/app/common/uuid_impl.js @@ -79,6 +79,28 @@ goog.scope(function() { }; })(); + function getBigUint64(view, byteOffset, le) { + const a = view.getUint32(byteOffset, le); + const b = view.getUint32(byteOffset + 4, le); + const leMask = Number(!!le); + const beMask = Number(!le); + return ((BigInt(a * beMask + b * leMask) << 32n) | + (BigInt(a * leMask + b * beMask))); + } + + function setBigUint64(view, byteOffset, value, le) { + const hi = Number(value >> 32n); + const lo = Number(value & 0xffffffffn); + if (le) { + view.setUint32(byteOffset + 4, hi, le); + view.setUint32(byteOffset, lo, le); + } + else { + view.setUint32(byteOffset, hi, le); + view.setUint32(byteOffset + 4, lo, le); + } + } + self.v8 = (function () { const buff = new ArrayBuffer(16); const int8 = new Uint8Array(buff); @@ -104,7 +126,7 @@ goog.scope(function() { const nextLong = () => { fill(tmpInt8); - return tmpView.getBigUint64(0, false); + return getBigUint64(tmpView, 0, false); }; lastRd = nextLong() & 0xffff_ffff_ffff_f0ffn; @@ -118,8 +140,9 @@ goog.scope(function() { | ((ts << 14n) & 0x3fff_ffff_ffff_c000n) | lastCs); - view.setBigUint64(0, msb, false); - view.setBigUint64(8, lsb, false); + setBigUint64(view, 0, msb, false); + setBigUint64(view, 8, lsb, false); + return core.uuid(toHexString(int8)); }; From 7fa44aa2569b6b3de5da4faf9bdb9b7baf376d7d Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 4 Oct 2022 23:19:28 +0200 Subject: [PATCH 2/5] :bug: Disable broadcast-channel when it is not available (mainly safari) --- frontend/src/app/main/broadcast.cljs | 29 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/frontend/src/app/main/broadcast.cljs b/frontend/src/app/main/broadcast.cljs index e950f2d86..15c5da74d 100644 --- a/frontend/src/app/main/broadcast.cljs +++ b/frontend/src/app/main/broadcast.cljs @@ -19,24 +19,29 @@ ;; The main broadcast channel instance, used for emit data (defonce default-channel - (js/BroadcastChannel. default-topic)) + (when (exists? js/BroadcastChannel) + (js/BroadcastChannel. default-topic))) (defonce stream - (->> (rx/create (fn [subs] - (let [chan (js/BroadcastChannel. default-topic)] - (unchecked-set chan "onmessage" #(rx/push! subs (unchecked-get % "data"))) - (fn [] (.close ^js chan))))) - (rx/map t/decode-str) - (rx/map map->BroadcastMessage) - (rx/share))) + (if (exists? js/BroadcastChannel) + (->> (rx/create (fn [subs] + (let [chan (js/BroadcastChannel. default-topic)] + (unchecked-set chan "onmessage" #(rx/push! subs (unchecked-get % "data"))) + (fn [] (.close ^js chan))))) + (rx/map t/decode-str) + (rx/map map->BroadcastMessage) + (rx/share)) + (rx/subject))) (defn emit! ([type data] - (.postMessage ^js default-channel (t/encode-str {:id nil :type type :data data})) - nil) + (when default-channel + (.postMessage ^js default-channel (t/encode-str {:id nil :type type :data data})) + nil)) ([id type data] - (.postMessage ^js default-channel (t/encode-str {:id id :type type :data data})) - nil)) + (when default-channel + (.postMessage ^js default-channel (t/encode-str {:id id :type type :data data})) + nil))) (defn type? ([type] From 348bc48db498394f6f50bf3e652bb282818deb77 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 5 Oct 2022 08:41:56 +0200 Subject: [PATCH 3/5] :paperclip: Minor change on docker build script --- docker/images/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/images/build.sh b/docker/images/build.sh index 488de5e52..7f4caf20d 100755 --- a/docker/images/build.sh +++ b/docker/images/build.sh @@ -7,7 +7,7 @@ PLATFORM=${PENPOT_BUILD_PLATFORM:-linux/amd64}; IMAGE=${1:-backend}; DOCKER_IMAGE="$ORG/$IMAGE"; -OPTIONS="-t $DOCKER_IMAGE:$PENPOT_BUILD_BRANCH"; +OPTIONS="-t $DOCKER_IMAGE:$PENPOT_BUILD_VERSION"; IFS=", " read -a TAGS <<< $PENPOT_BUILD_TAGS; From c534a40923dd9396153b2a23f5493c9873f82706 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 5 Oct 2022 08:42:14 +0200 Subject: [PATCH 4/5] :arrow_up: Update versions on default docker compose file --- docker/images/docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/images/docker-compose.yaml b/docker/images/docker-compose.yaml index e0f162c39..5b3ad2a65 100644 --- a/docker/images/docker-compose.yaml +++ b/docker/images/docker-compose.yaml @@ -54,7 +54,7 @@ services: - penpot penpot-postgres: - image: "postgres:13" + image: "postgres:14" restart: always stop_signal: SIGINT @@ -71,7 +71,7 @@ services: - penpot penpot-redis: - image: redis:6 + image: redis:7 restart: always networks: - penpot From 5a06749664568ec73c89bc0bd6806043dc396db2 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 4 Oct 2022 23:19:28 +0200 Subject: [PATCH 5/5] :bug: Disable broadcast-channel when it is not available (mainly safari) --- frontend/src/app/main/broadcast.cljs | 29 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/frontend/src/app/main/broadcast.cljs b/frontend/src/app/main/broadcast.cljs index ef50e4b31..d962672cb 100644 --- a/frontend/src/app/main/broadcast.cljs +++ b/frontend/src/app/main/broadcast.cljs @@ -19,24 +19,29 @@ ;; The main broadcast channel instance, used for emit data (defonce default-channel - (js/BroadcastChannel. default-topic)) + (when (exists? js/BroadcastChannel) + (js/BroadcastChannel. default-topic))) (defonce stream - (->> (rx/create (fn [subs] - (let [chan (js/BroadcastChannel. default-topic)] - (unchecked-set chan "onmessage" #(rx/push! subs (unchecked-get % "data"))) - (fn [] (.close ^js chan))))) - (rx/map t/decode-str) - (rx/map map->BroadcastMessage) - (rx/share))) + (if (exists? js/BroadcastChannel) + (->> (rx/create (fn [subs] + (let [chan (js/BroadcastChannel. default-topic)] + (unchecked-set chan "onmessage" #(rx/push! subs (unchecked-get % "data"))) + (fn [] (.close ^js chan))))) + (rx/map t/decode-str) + (rx/map map->BroadcastMessage) + (rx/share)) + (rx/subject))) (defn emit! ([type data] - (.postMessage ^js default-channel (t/encode-str {:id nil :type type :data data})) - nil) + (when default-channel + (.postMessage ^js default-channel (t/encode-str {:id nil :type type :data data})) + nil)) ([id type data] - (.postMessage ^js default-channel (t/encode-str {:id id :type type :data data})) - nil)) + (when default-channel + (.postMessage ^js default-channel (t/encode-str {:id id :type type :data data})) + nil))) (defn type? ([type]