Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(web): banner integration with the new gesture engine 🐵 #9752

Merged
merged 7 commits into from
Oct 24, 2023

Conversation

jahorton
Copy link
Contributor

@jahorton jahorton commented Oct 12, 2023

While #9657 started the process for integrating the new gesture engine with the main keyboard within KMW, it did nothing in regard to the predictive-text banner. This PR remedies the discrepancy, replacing its input-event interpretation engine with the gesture-recognizer as well.

Having both VisualKeyboard and SuggestionBanner use the same engine means we can now go through the code and remove all references to the old event-interpretation engines. (Plural - because I tried to make a generalized one before that never actually got used in both places... just one.) Of course, the new gesture engine is significantly more 'featured' than the old engines, so we'll likely still get a net filesize increase overall... but at least discarding the old engines should make the increase less severe.

@keymanapp-test-bot skip

@jahorton jahorton added this to the A17S24 milestone Oct 12, 2023
@jahorton jahorton marked this pull request as draft October 12, 2023 07:32
web/src/engine/osk/src/visualKeyboard.ts Outdated Show resolved Hide resolved
web/src/engine/osk/src/visualKeyboard.ts Outdated Show resolved Hide resolved
web/src/engine/osk/src/visualKeyboard.ts Outdated Show resolved Hide resolved
* an ongoing contact-point event series. This class standardizes to .pageX
* (document) coordinates, rather than .clientX (viewport) coordinates.
*/
class InputEventCoordinate {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes straight out of the previous file in GitHub's changed-file listings. I've simplified it to include only the functions that are still utilized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The remaining bits are 'small enough' that it's probably not worth the effort at the immediate moment to shift paradigms for this file's exposed class.

* @param startCoord The initial coordinate of a currently-ongoing input event
* @returns
*/
private applyScreenMarginBoundsThresholding(baseBounds: BoundingRect,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inspiration behind the "safe zone padding" gesture-engine feature. As it lives there now, we no longer need it here.

* an ongoing contact-point event series. This class standardizes to .pageX
* (document) coordinates, rather than .clientX (viewport) coordinates.
*/
class InputEventCoordinate {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The remaining bits are 'small enough' that it's probably not worth the effort at the immediate moment to shift paradigms for this file's exposed class.

@jahorton
Copy link
Contributor Author

So, relative to #9719, at this point this PR's deletions save about 12 KB minified. Not as much as I hoped, though it is something.

Once all gestures are implemented, maybe I should go back and investigate the stats properties and either drop the ones we don't end up needing or relegate them to an unreferenced subclass that can be tree-shaken. That would probably give us some additional file-size refunding.

Also, upon investigating the minified source, there are a few bits I had expected to see tree-shaken that weren't; remedying that would certainly be helpful.

@jahorton
Copy link
Contributor Author

jahorton commented Oct 16, 2023

... and it was something really dumb on my end from a while back. There's a big difference between String.replace and String.replaceAll -- some of the stuff I expected to be treeshaken wasn't getting marked as @__PURE__ (by the treeshaking helper) because only the first @class annotation in a file was being replaced, rather than all of them.

In my local build, this fix brings KMW down from 471,845 bytes to 451,879 bytes, a difference of about 20 kB. I'd say that's significant.

@jahorton
Copy link
Contributor Author

jahorton commented Oct 17, 2023

Pending TODO: rebase upon #9779 & resolve merge conflicts.

Certain code currently commented-out here may be 100% removed afterward, as #9779 sees said code's reimplementation / re-integration. (Note some of the new in-comment TODOs in the changelog; they'll be resolved.)

@jahorton jahorton force-pushed the refactor/web/banner-gesture-integration branch from 6358c1f to 4f5ab67 Compare October 18, 2023 02:09
@jahorton jahorton changed the base branch from feat/web/longpress-restoration to feat/web/subkey-corrections October 18, 2023 02:09
@jahorton jahorton marked this pull request as ready for review October 20, 2023 07:30
web/src/engine/osk/src/banner/banner.ts Outdated Show resolved Hide resolved
web/src/engine/osk/src/banner/banner.ts Outdated Show resolved Hide resolved
web/src/engine/osk/src/banner/banner.ts Outdated Show resolved Hide resolved
web/src/engine/osk/src/banner/banner.ts Outdated Show resolved Hide resolved
// * @param touch The starting touch coordinates for the gesture
// * @returns
// */
// initGestures(key: KeyElement, input: InputEventCoordinate) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented code to delete

Base automatically changed from feat/web/subkey-corrections to feature-gestures October 24, 2023 02:13
@jahorton jahorton merged commit 101daa0 into feature-gestures Oct 24, 2023
18 of 19 checks passed
@jahorton jahorton deleted the refactor/web/banner-gesture-integration branch October 24, 2023 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants