Skip to content

refactor(web): refactor ProcessorInitOptions 📏 🎼#15465

Merged
ermshiperete merged 6 commits intoepic/web-corefrom
refactor/web/ProcessorInitOptions
Jan 22, 2026
Merged

refactor(web): refactor ProcessorInitOptions 📏 🎼#15465
ermshiperete merged 6 commits intoepic/web-corefrom
refactor/web/ProcessorInitOptions

Conversation

@ermshiperete
Copy link
Copy Markdown
Contributor

@ermshiperete ermshiperete commented Jan 16, 2026

This addresses a web-core TODO comment.

This change makes the options parameter in the JSKeyboardProcessor constructor no longer optional. Also baseLayout and defaultOutputRules are now required in ProcessorInitOptions. For testing purposes we export DEFAULT_OPTIONS in a testing endpoint.

The options parameter in the InputProcessor constructor is no longer optional. Also removes the DEFAULT_OPTIONS from
InputProcessor.

This change also moves the ProcessorInitOptions interface to a separate file and makes keyboardInterface a required field.

An alternative approach would have been to get rid of ProcessorInitOptions and instead set the JSKeyboardProcessor fields after creating the instance. Doing it the implemented way seemed cleaner.

Test-bot: skip

… c'tor

This makes the `options` parameter in the `JSKeyboardProcessor`
constructor no longer optional.
Also `baseLayout` and `defaultOutputRules` are now required in
`ProcessorInitOptions`.

For testing purposes we export `DEFAULT_OPTIONS` in a testing endpoint.

Test-bot: skip
This makes the `options` parameter in the `InputProcessor` constructor
no longer optional. Also removes the `DEFAULT_OPTIONS` from
`InputProcessor`.

Test-bot: skip
This change moves the `ProcessorInitOptions` interface to a separate
file and makes `keyboardInterface` a required field.

Test-bot: skip
@keymanapp-test-bot
Copy link
Copy Markdown

keymanapp-test-bot Bot commented Jan 16, 2026

User Test Results

Test specification and instructions

User tests are not required

Test Artifacts

  • Android
    • Keyman for Android apk - build : all tests passed (no artifacts on BuildLevel "build")
    • FirstVoices Keyboards for Android apk - build : all tests passed (no artifacts on BuildLevel "build")
    • FirstVoices Keyboards for Android apk (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
    • KeyboardHarness apk - build : all tests passed (no artifacts on BuildLevel "build")
    • Keyman for Android apk (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
    • KMSample1 apk - build : all tests passed (no artifacts on BuildLevel "build")
    • KMSample2 apk - build : all tests passed (no artifacts on BuildLevel "build")
  • Developer
    • Keyman Developer - build : all tests passed (no artifacts on BuildLevel "build")
    • Compiler Regression Tests - build : all tests passed (no artifacts on BuildLevel "build")
    • Keyman Developer (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
    • kmcomp.zip - build : all tests passed (no artifacts on BuildLevel "build")
    • kmcomp.zip (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
  • iOS
    • Keyman for iOS (simulator image) - build : all tests passed (no artifacts on BuildLevel "build")
    • FirstVoices Keyboards for iOS (simulator image) - build : all tests passed (no artifacts on BuildLevel "build")
    • FirstVoices Keyboards for iOS (simulator image) (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
    • Keyman for iOS (simulator image) (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
  • Keyboards
    • Test Keyboards - build : all tests passed (no artifacts on BuildLevel "build")
  • Web
    • KeymanWeb Test Home - build : all tests passed (no artifacts on BuildLevel "build")

@keymanapp-test-bot keymanapp-test-bot Bot changed the title refactor(web): make ProcessorInitOptions.keyboardInterface mandatory refactor(web): make ProcessorInitOptions.keyboardInterface mandatory 🎼 Jan 16, 2026
@keymanapp-test-bot keymanapp-test-bot Bot added this to the A19S20 milestone Jan 16, 2026
@ermshiperete ermshiperete changed the title refactor(web): make ProcessorInitOptions.keyboardInterface mandatory 🎼 refactor(web): refactor ProcessorInitOptions 📏 🎼 Jan 16, 2026
@keyman-server keyman-server modified the milestones: A19S20, A19S21 Jan 16, 2026
Copy link
Copy Markdown
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.

You've refactored the redundant DEFAULT_OPTIONS this far, I think we can take it one step further into a .tests.ts file so it doesn't get constructed at all except for unit tests.

Comment thread web/src/app/browser/src/keymanEngine.ts Outdated
Comment on lines 64 to 65
// The `engine` parameter cannot be supplied with the constructing instance before calling
// `super`, hence the 'fun' rigging to supply it _from_ `super` via this closure.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I really don't understand this comment!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed

Comment on lines +11 to +15
DEFAULT_OPTIONS: {
baseLayout: 'us',
keyboardInterface: new JSKeyboardInterface(globalObject(), MinimalKeymanGlobal),
defaultOutputRules: new DefaultOutputRules()
} as ProcessorInitOptions
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer this to be in a .tests sourcefile because having this here means we have redundant JSKeyboardInterface and DefaultOutputRules always constructed even though they will never be used at runtime.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. Done.

Comment thread web/src/engine/src/js-processor/processorInitOptions.ts
- remove confusing comment
- move default ProcessorInitOptions to tests folder
- add jsdoc comments to ProcessorInitOptions

Test-bot: skip
@ermshiperete ermshiperete requested a review from mcdurdin January 20, 2026 11:18
Base automatically changed from refactor/web/defaultRules to epic/web-core January 20, 2026 11:22
*/
export interface ProcessorInitOptions {
/**
* The base layout identifier for the keyboard.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What code space is this? It's not BCP-47? Is it just us at this point?


// Now for the real test!
let processor = new JSKeyboardProcessor(device);
let processor = new JSKeyboardProcessor(device, DEFAULT_PROCESSOR_INIT_OPTIONS);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where is DEFAULT_PROCESSOR_INIT_OPTIONS defined? It doesn't seem to be imported in this or defined anywhere in this PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, good question. Seems the file got lost along the way. Makes me wonder how the tests all passed...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes me wonder how the tests all passed...

Indeed! Please do check this out because it may indicate other problems -- we don't want tests to pass for the wrong reasons.

@ermshiperete ermshiperete requested a review from mcdurdin January 21, 2026 12:05
The definition of `DEFAULT_PROCESSOR_INIT_OPTIONS` got lost in
last PR.

Test-bot: skip
@ermshiperete ermshiperete force-pushed the refactor/web/ProcessorInitOptions branch from 1f1a3ef to 40ce71a Compare January 21, 2026 12:07
Copy link
Copy Markdown
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, but please do check to find out why tests still passed with the missing defaultProcessorInitOptions.ts module.

@ermshiperete
Copy link
Copy Markdown
Contributor Author

LGTM, but please do check to find out why tests still passed with the missing defaultProcessorInitOptions.ts module.

We have both .ts and .js tests. When we reduced the number of build scripts for web, the part that ran the .js tests got lost. I'll fix it in a follow-up PR.

@ermshiperete ermshiperete merged commit 7e972ab into epic/web-core Jan 22, 2026
15 of 16 checks passed
@ermshiperete ermshiperete deleted the refactor/web/ProcessorInitOptions branch January 22, 2026 16:34
@github-project-automation github-project-automation Bot moved this from Todo to Done in Keyman Jan 22, 2026
@mcdurdin
Copy link
Copy Markdown
Member

I'll fix it in a follow-up PR.

Please link to it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants