refactor(web): refactor ProcessorInitOptions 📏 🎼#15465
refactor(web): refactor ProcessorInitOptions 📏 🎼#15465ermshiperete merged 6 commits intoepic/web-corefrom
ProcessorInitOptions 📏 🎼#15465Conversation
… 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
User Test ResultsTest specification and instructions User tests are not required Test Artifacts
|
ProcessorInitOptions.keyboardInterface mandatoryProcessorInitOptions.keyboardInterface mandatory 🎼
ProcessorInitOptions.keyboardInterface mandatory 🎼ProcessorInitOptions 📏 🎼
mcdurdin
left a comment
There was a problem hiding this comment.
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.
| // 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. |
There was a problem hiding this comment.
I really don't understand this comment!
| DEFAULT_OPTIONS: { | ||
| baseLayout: 'us', | ||
| keyboardInterface: new JSKeyboardInterface(globalObject(), MinimalKeymanGlobal), | ||
| defaultOutputRules: new DefaultOutputRules() | ||
| } as ProcessorInitOptions |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Good point. Done.
- remove confusing comment - move default ProcessorInitOptions to tests folder - add jsdoc comments to ProcessorInitOptions Test-bot: skip
…b/ProcessorInitOptions
| */ | ||
| export interface ProcessorInitOptions { | ||
| /** | ||
| * The base layout identifier for the keyboard. |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Where is DEFAULT_PROCESSOR_INIT_OPTIONS defined? It doesn't seem to be imported in this or defined anywhere in this PR?
There was a problem hiding this comment.
Hmm, good question. Seems the file got lost along the way. Makes me wonder how the tests all passed...
There was a problem hiding this comment.
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.
The definition of `DEFAULT_PROCESSOR_INIT_OPTIONS` got lost in last PR. Test-bot: skip
1f1a3ef to
40ce71a
Compare
mcdurdin
left a comment
There was a problem hiding this comment.
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. |
Please link to it here. |
This addresses a web-core TODO comment.
This change makes the
optionsparameter in theJSKeyboardProcessorconstructor no longer optional. AlsobaseLayoutanddefaultOutputRulesare now required inProcessorInitOptions. For testing purposes we exportDEFAULT_OPTIONSin a testing endpoint.The
optionsparameter in theInputProcessorconstructor is no longer optional. Also removes theDEFAULT_OPTIONSfromInputProcessor.This change also moves the
ProcessorInitOptionsinterface to a separate file and makeskeyboardInterfacea required field.An alternative approach would have been to get rid of
ProcessorInitOptionsand instead set theJSKeyboardProcessorfields after creating the instance. Doing it the implemented way seemed cleaner.Test-bot: skip