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): refactor and harmonize constants 🏗️ #12072

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

ermshiperete
Copy link
Contributor

common/web/keyboard-processor/src/text/codes.ts Outdated Show resolved Hide resolved
@@ -13,6 +13,7 @@ SUBPROJECT_NAME=app/browser
# ################################ Main script ################################

builder_describe "Builds the Keyman Engine for Web's website-integrating version for use in non-puppeted browsers." \
"@/common/web/types build" \
Copy link
Contributor

Choose a reason for hiding this comment

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

If this has already been added by @/common/web/keyboard-processor, including it here is redundant. That's why there's no @/common/web/keyboard-processor listed in the original version - that, in turn, is auto-included via input-processor, then engine/main - the last of which is listed.

Granted, the fact that we are directly importing from it in a few files may be worth keeping it listed, I guess.

Suggested change
"@/common/web/types build" \

Copy link
Contributor

Choose a reason for hiding this comment

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

For comparison, you didn't add a listing for web/src/engine/main/build.sh, despite it also not listing @/common/web/keyboard-processor as a dependency.


const Codes = {
// Define Keyman Developer modifier bit-flags (exposed for use by other modules)
// Compare against /common/include/kmx_file.h. CTRL+F "#define LCTRLFLAG" to find the secton.
modifierCodes: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
modifierCodes: {
// Debug-mode keyboards compiled before Keyman 18.0 referenced the `ModifierKeyConstants`
// constants via the names established below. We must continue to support them, as they're
// essentially part of the keyboard API now.
modifierCodes: {

Optionally, we could also emit the same values under their new name:

Suggested change
modifierCodes: {
// Debug-mode keyboards compiled before Keyman 18.0 referenced the `ModifierKeyConstants`
// constants via the names established below. We must continue to support them, as they're
// essentially part of the keyboard API now.
modifierCodes: {
...ModifierKeyConstants,

so that at some point in the distant future, we could drop the old names entirely... maybe.

@ermshiperete ermshiperete force-pushed the change/web/8146_moveCodes2 branch 2 times, most recently from c54de67 to 3ce5f14 Compare August 1, 2024 17:11
@ermshiperete ermshiperete marked this pull request as ready for review August 1, 2024 18:15
@ermshiperete ermshiperete marked this pull request as draft August 1, 2024 18:17
Note that this adds the keyCodes > 50000 to `USVirtualKeyCodes`.

Fixes: #8146
@ermshiperete ermshiperete marked this pull request as ready for review August 1, 2024 20:36
Copy link
Contributor

@jahorton jahorton left a comment

Choose a reason for hiding this comment

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

General changes LGTM.

That said, there are a couple of decisions that were made that I feel @mcdurdin may want to comment about, so I'll hold off giving it the official stamp for the moment.

@darcywong00 darcywong00 modified the milestones: A18S7, A18S8 Aug 2, 2024
"SHIFT":0x0010, // K_SHIFTFLAG
"CTRL":0x0020, // K_CTRLFLAG
"ALT":0x0040, // K_ALTFLAG
...ModifierKeyConstants,
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should include this here -- we should maintain this as a legacy interface only. Mixing the names in a published interface doesn't buy us anything -- we have to maintain the old names anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

…odes`

Keep `modifierCodes` as legacy API. This addresses a code review comment
(#12072 (comment)).
@ermshiperete ermshiperete merged commit ebd2bf4 into master Aug 6, 2024
19 checks passed
@ermshiperete ermshiperete deleted the change/web/8146_moveCodes2 branch August 6, 2024 07:06
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 18.0.83-alpha

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.

chore(web): move KeyboardProcessor.Codes into common/web/types
5 participants