mirror of
https://github.com/penpot/penpot.git
synced 2026-09-11 22:49:30 +00:00
🐛 Improve change token set performance
This commit is contained in:
parent
3264bc746f
commit
dc5f222230
@ -194,4 +194,4 @@
|
|||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ _]
|
(watch [_ _ _]
|
||||||
(->> (rx/from ids)
|
(->> (rx/from ids)
|
||||||
(rx/map resize-wasm-text)))))
|
(rx/map resize-wasm-text-debounce)))))
|
||||||
|
|||||||
@ -44,6 +44,6 @@ goog.scope(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.replace_token_BANG_ = function(instance, token) {
|
self.replace_token_BANG_ = function(instance, token) {
|
||||||
instance.replaceToken(token);
|
instance?.replaceToken(token);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -43,7 +43,9 @@
|
|||||||
(fn [stream]
|
(fn [stream]
|
||||||
(->> stream
|
(->> stream
|
||||||
#_(rx/tap #(prn (ptk/type %)))
|
#_(rx/tap #(prn (ptk/type %)))
|
||||||
(rx/filter #(ptk/type? event-type %)))))
|
(rx/filter #(ptk/type? event-type %))
|
||||||
|
;; Safeguard timeout
|
||||||
|
(rx/timeout 200 (rx/of :the/end)))))
|
||||||
|
|
||||||
(def stop-on-send-update-indices
|
(def stop-on-send-update-indices
|
||||||
"Stops on `send-update-indices` function being called, which should be the last function of an event chain."
|
"Stops on `send-update-indices` function being called, which should be the last function of an event chain."
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
[app.common.types.text :as txt]
|
[app.common.types.text :as txt]
|
||||||
[app.common.types.tokens-lib :as ctob]
|
[app.common.types.tokens-lib :as ctob]
|
||||||
[app.main.data.workspace.tokens.application :as dwta]
|
[app.main.data.workspace.tokens.application :as dwta]
|
||||||
|
[app.main.data.workspace.wasm-text :as dwwt]
|
||||||
[cljs.test :as t :include-macros true]
|
[cljs.test :as t :include-macros true]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[frontend-tests.helpers.pages :as thp]
|
[frontend-tests.helpers.pages :as thp]
|
||||||
@ -58,8 +59,11 @@
|
|||||||
(ctob/add-token (cthi/id :set-a)
|
(ctob/add-token (cthi/id :set-a)
|
||||||
(ctob/make-token reference-border-radius-token))))))
|
(ctob/make-token reference-border-radius-token))))))
|
||||||
|
|
||||||
|
(def debounce-text-stop
|
||||||
|
(tohs/stop-on ::dwwt/resize-wasm-text-debounce-commit))
|
||||||
|
|
||||||
(t/deftest test-apply-token
|
(t/deftest test-apply-token
|
||||||
(t/testing "applies token to shape and updates shape attributes to resolved value"
|
(t/testing "applies token to shape and updates shape attributes to resolved value"
|
||||||
(t/async
|
(t/async
|
||||||
done
|
done
|
||||||
(let [file (setup-file-with-tokens)
|
(let [file (setup-file-with-tokens)
|
||||||
@ -553,7 +557,8 @@
|
|||||||
(t/is (= (:font-size style-text-blocks) "24"))
|
(t/is (= (:font-size style-text-blocks) "24"))
|
||||||
(t/testing "WASM text mocks were exercised"
|
(t/testing "WASM text mocks were exercised"
|
||||||
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
||||||
(t/is (pos? (thw/call-count :get-text-dimensions)))))))))))
|
(t/is (pos? (thw/call-count :get-text-dimensions))))))
|
||||||
|
debounce-text-stop)))))
|
||||||
|
|
||||||
(t/deftest test-apply-line-height
|
(t/deftest test-apply-line-height
|
||||||
(t/testing "applies line-height token and updates the text line-height"
|
(t/testing "applies line-height token and updates the text line-height"
|
||||||
@ -591,7 +596,8 @@
|
|||||||
(t/is (= (:line-height style-text-blocks) 1.5))
|
(t/is (= (:line-height style-text-blocks) 1.5))
|
||||||
(t/testing "WASM text mocks were exercised"
|
(t/testing "WASM text mocks were exercised"
|
||||||
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
||||||
(t/is (pos? (thw/call-count :get-text-dimensions)))))))))))
|
(t/is (pos? (thw/call-count :get-text-dimensions))))))
|
||||||
|
debounce-text-stop)))))
|
||||||
|
|
||||||
(t/deftest test-apply-letter-spacing
|
(t/deftest test-apply-letter-spacing
|
||||||
(t/testing "applies letter-spacing token and updates the text letter-spacing"
|
(t/testing "applies letter-spacing token and updates the text letter-spacing"
|
||||||
@ -629,7 +635,8 @@
|
|||||||
(t/is (= (:letter-spacing style-text-blocks) "2"))
|
(t/is (= (:letter-spacing style-text-blocks) "2"))
|
||||||
(t/testing "WASM text mocks were exercised"
|
(t/testing "WASM text mocks were exercised"
|
||||||
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
||||||
(t/is (pos? (thw/call-count :get-text-dimensions)))))))))))
|
(t/is (pos? (thw/call-count :get-text-dimensions))))))
|
||||||
|
debounce-text-stop)))))
|
||||||
|
|
||||||
(t/deftest test-apply-font-family
|
(t/deftest test-apply-font-family
|
||||||
(t/testing "applies font-family token and updates the text font-family"
|
(t/testing "applies font-family token and updates the text font-family"
|
||||||
@ -667,7 +674,8 @@
|
|||||||
(t/is (= (:font-family style-text-blocks) (:font-id txt/default-text-attrs)))
|
(t/is (= (:font-family style-text-blocks) (:font-id txt/default-text-attrs)))
|
||||||
(t/testing "WASM text mocks were exercised"
|
(t/testing "WASM text mocks were exercised"
|
||||||
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
||||||
(t/is (pos? (thw/call-count :get-text-dimensions)))))))))))
|
(t/is (pos? (thw/call-count :get-text-dimensions))))))
|
||||||
|
debounce-text-stop)))))
|
||||||
|
|
||||||
(t/deftest test-apply-text-case
|
(t/deftest test-apply-text-case
|
||||||
(t/testing "applies text-case token and updates the text transform"
|
(t/testing "applies text-case token and updates the text transform"
|
||||||
@ -775,7 +783,8 @@
|
|||||||
(t/is (= (:font-weight style-text-blocks) "400"))
|
(t/is (= (:font-weight style-text-blocks) "400"))
|
||||||
(t/testing "WASM text mocks were exercised"
|
(t/testing "WASM text mocks were exercised"
|
||||||
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
||||||
(t/is (pos? (thw/call-count :get-text-dimensions)))))))))))
|
(t/is (pos? (thw/call-count :get-text-dimensions))))))
|
||||||
|
debounce-text-stop)))))
|
||||||
|
|
||||||
(t/deftest test-toggle-token-none
|
(t/deftest test-toggle-token-none
|
||||||
(t/testing "should apply token to all selected items, where no item has the token applied"
|
(t/testing "should apply token to all selected items, where no item has the token applied"
|
||||||
@ -1001,7 +1010,8 @@
|
|||||||
(t/is (= (:text-decoration style-text-blocks) "underline"))
|
(t/is (= (:text-decoration style-text-blocks) "underline"))
|
||||||
(t/testing "WASM text mocks were exercised"
|
(t/testing "WASM text mocks were exercised"
|
||||||
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
||||||
(t/is (pos? (thw/call-count :get-text-dimensions)))))))))))
|
(t/is (pos? (thw/call-count :get-text-dimensions))))))
|
||||||
|
debounce-text-stop)))))
|
||||||
|
|
||||||
(t/deftest test-apply-reference-typography-token
|
(t/deftest test-apply-reference-typography-token
|
||||||
(t/testing "applies typography (composite) tokens with references"
|
(t/testing "applies typography (composite) tokens with references"
|
||||||
@ -1049,7 +1059,8 @@
|
|||||||
(t/is (= (:font-family style-text-blocks) "Arial"))
|
(t/is (= (:font-family style-text-blocks) "Arial"))
|
||||||
(t/testing "WASM text mocks were exercised"
|
(t/testing "WASM text mocks were exercised"
|
||||||
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
||||||
(t/is (pos? (thw/call-count :get-text-dimensions)))))))))))
|
(t/is (pos? (thw/call-count :get-text-dimensions))))))
|
||||||
|
debounce-text-stop)))))
|
||||||
|
|
||||||
(t/deftest test-unapply-atomic-tokens-on-composite-apply
|
(t/deftest test-unapply-atomic-tokens-on-composite-apply
|
||||||
(t/testing "unapplies atomic typography tokens when applying composite token"
|
(t/testing "unapplies atomic typography tokens when applying composite token"
|
||||||
@ -1206,4 +1217,5 @@
|
|||||||
(t/is (nil? (:typography-ref-file text-node-3)))
|
(t/is (nil? (:typography-ref-file text-node-3)))
|
||||||
(t/testing "WASM text mocks were exercised"
|
(t/testing "WASM text mocks were exercised"
|
||||||
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
(t/is (pos? (thw/call-count :set-shape-text-content)))
|
||||||
(t/is (pos? (thw/call-count :get-text-dimensions)))))))))))
|
(t/is (pos? (thw/call-count :get-text-dimensions))))))
|
||||||
|
debounce-text-stop)))))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user