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): unifies touch-layout typing, updating Web to the common/web/types version 🐵 #9664

Merged
merged 15 commits into from
Oct 20, 2023

Conversation

jahorton
Copy link
Contributor

@jahorton jahorton commented Oct 3, 2023

In order to integrate the Web OSK for our new, upcoming gesture types... Web needs the corresponding type information. Rather than continue to keep the touch-layout typing WET, I've put in the work necessary to have Web use the definitions from common/web/types - meaning KMW will now use the same type specifications as Developer's Web-keyboard compiler. (With minor extensions for post-processing.)

There were a few rough edges to resolve in doing so, but it also provided a wonderful excuse to take care of a few longstanding nits we've had. In particular, Web finally gets to say farewell to string form pad, width, and sp typing - though it keeps the legacy-friendly sanitize methods that enforce the correct typing via Number.parse.

The main benefit: Web now has access to flick and multitap layout-spec data, which I'll need for upcoming work.

This was motivated by follow-up work to #9657, but since that starts ripping apart KMW's OSK to the point that certain integration tests will be failing, it's probably clearer for the review process (and for management checks) to 'base' it just before that point.

@keymanapp-test-bot skip

@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Oct 3, 2023

User Test Results

Test specification and instructions

User tests are not required

Comment on lines 1 to 3
// Enables DOM types, but just for this one module.
///<reference lib="dom" />

Copy link
Contributor Author

@jahorton jahorton Oct 3, 2023

Choose a reason for hiding this comment

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

/common/web/keyboard-processor/build.sh build will run into a build error within this file if this line is not present. (The file references the URL type, which is the cause.) It apparently doesn't matter that keyboard-processor doesn't even touch or import anything from the file; it's just a mutual export alongside the ones we do want, and that's enough to cause the issue during TS compilation.

keyboard-processor compiles without access to the DOM libraries except where made explicit.

This is the only change made in this PR to common/web/types.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, @srl295 I think we should pull URL usage out of this module and have a helper instead. It's apparently used in 4 places altogether in unit tests and kmc:

  • kmc buildTestData/index.ts
  • kmc BuildLdmlKeyboard.ts
  • unit test: reader-callback-test.ts
  • unit test helpers/index.ts

Propose the following:

static get defaultImportsURL() {
  return ['../import/', import.meta.url];
}

And in usage:

    readerOptions: {
      importsPath: fileURLToPath(new URL(...LDMLKeyboardXMLSourceFileReader.defaultImportsURL))
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I presume that'd be a separate issue, not something I ought do here?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah it could be a separate PR. Be good to address it before this change lands in master though, just for cleanliness.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Up as #9788.

…ness' into refactor/web/common-layout-typing
@jahorton jahorton marked this pull request as ready for review October 11, 2023 07:33
@mcdurdin mcdurdin modified the milestones: A17S23, A17S24 Oct 15, 2023
Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

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

Looks pretty good, just a couple of suggestions really, and an alternate way of solving the /// <reference> in common/web/types which I think is probably cleaner

Comment on lines 1 to 3
// Enables DOM types, but just for this one module.
///<reference lib="dom" />

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, @srl295 I think we should pull URL usage out of this module and have a helper instead. It's apparently used in 4 places altogether in unit tests and kmc:

  • kmc buildTestData/index.ts
  • kmc BuildLdmlKeyboard.ts
  • unit test: reader-callback-test.ts
  • unit test helpers/index.ts

Propose the following:

static get defaultImportsURL() {
  return ['../import/', import.meta.url];
}

And in usage:

    readerOptions: {
      importsPath: fileURLToPath(new URL(...LDMLKeyboardXMLSourceFileReader.defaultImportsURL))
    }

web/src/engine/osk/src/input/gestures/browser/oskSubKey.ts Outdated Show resolved Hide resolved
@jahorton
Copy link
Contributor Author

jahorton commented Oct 20, 2023

Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

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

LGTM, noting that the validation in oskSubKey ll.27-33 is re-corrected in #9804.

Co-authored-by: Marc Durdin <marc@durdin.net>
Base automatically changed from fix/web/recognizer-polish-and-source-uniqueness to feature-gestures October 20, 2023 09:12
@jahorton jahorton merged commit 6d313f2 into feature-gestures Oct 20, 2023
3 checks passed
@jahorton jahorton deleted the refactor/web/common-layout-typing branch October 20, 2023 09:12
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