diff --git a/android/KMEA/app/src/main/assets/android-host.js b/android/KMEA/app/src/main/assets/android-host.js index 05f33f71e8d..9c786e17770 100644 --- a/android/KMEA/app/src/main/assets/android-host.js +++ b/android/KMEA/app/src/main/assets/android-host.js @@ -37,11 +37,7 @@ function init() { keyman.beepKeyboard = beepKeyboard; // Readies the keyboard stub for instant loading during the init process. - try { - KeymanWeb.registerStub(JSON.parse(jsInterface.initialKeyboard())); - } catch(error) { - console.error(error); - } + KeymanWeb.registerStub(JSON.parse(jsInterface.initialKeyboard())); keyman.init({ 'embeddingApp':device, diff --git a/common/web/input-processor/src/text/prediction/predictionContext.ts b/common/web/input-processor/src/text/prediction/predictionContext.ts index def3dfa7c04..eebccb0fe3e 100644 --- a/common/web/input-processor/src/text/prediction/predictionContext.ts +++ b/common/web/input-processor/src/text/prediction/predictionContext.ts @@ -105,10 +105,6 @@ export default class PredictionContext extends EventEmitter = this.contextManager.restoreSavedKeyboard(savedKeyboardStr); - - // Wait for the initial keyboard to load before setting the OSK; this will avoid building an - // empty OSK that we'll instantly discard after. - try { - await loadingKbd; - } catch { /* in case of failed fetch due to network error or bad URI; we must still let the OSK init. */ }; - - const firstKbdConfig = { - keyboardToActivate: this.contextManager.activeKeyboard - }; - const osk = device.touchable ? new views.AnchoredOSKView(this, firstKbdConfig) : new views.FloatingOSKView(this, firstKbdConfig); + await Promise.resolve(); + + // Attempt to restore the user's last-used keyboard from their previous session. + // + // Note: any cloud stubs will probably not be available yet. + // If we tracked cloud requests and awaited a Promise.all on pending queries, + // we could handle that too. + this.contextManager.restoreSavedKeyboard(savedKeyboardStr); - setupOskListeners(this, osk, this.contextManager); - // And, now that we have our loaded active keyboard - or failed, thus must use that default... - // Now we set the OSK in place, an act which triggers VisualKeyboard construction. - this.osk = osk; + await Promise.resolve(); } get register(): (x: CloudQueryResult) => void { diff --git a/web/src/app/browser/src/viewsAnchorpoint.ts b/web/src/app/browser/src/viewsAnchorpoint.ts index 3bc6064dbfa..3df908c402e 100644 --- a/web/src/app/browser/src/viewsAnchorpoint.ts +++ b/web/src/app/browser/src/viewsAnchorpoint.ts @@ -17,7 +17,7 @@ function buildBaseOskConfiguration(engine: KeymanEngine) { }; class PublishedAnchoredOSKView extends AnchoredOSKView { - constructor(engine: KeymanEngine, config?: Partial) { + constructor(engine: KeymanEngine, config?: ViewConfiguration) { let finalConfig = { ...buildBaseOskConfiguration(engine), ...(config || {}) @@ -28,7 +28,7 @@ class PublishedAnchoredOSKView extends AnchoredOSKView { } class PublishedFloatingOSKView extends FloatingOSKView { - constructor(engine: KeymanEngine, config?: Partial) { + constructor(engine: KeymanEngine, config?: FloatingOSKViewConfiguration) { let finalConfig: FloatingOSKViewConfiguration = { ...buildBaseOskConfiguration(engine), ...(config || {}) @@ -39,7 +39,7 @@ class PublishedFloatingOSKView extends FloatingOSKView { } class PublishedInlineOSKView extends InlinedOSKView { - constructor(engine: KeymanEngine, config?: Partial) { + constructor(engine: KeymanEngine, config?: ViewConfiguration) { let finalConfig: ViewConfiguration = { ...buildBaseOskConfiguration(engine), ...(config || {}) diff --git a/web/src/app/webview/src/keymanEngine.ts b/web/src/app/webview/src/keymanEngine.ts index f9095aa0222..81704534c62 100644 --- a/web/src/app/webview/src/keymanEngine.ts +++ b/web/src/app/webview/src/keymanEngine.ts @@ -1,4 +1,4 @@ -import { DefaultRules, DeviceSpec, RuleBehavior, isEmptyTransform, Keyboard } from '@keymanapp/keyboard-processor' +import { DefaultRules, DeviceSpec, RuleBehavior } from '@keymanapp/keyboard-processor' import { KeymanEngine as KeymanEngineBase, KeyboardInterface } from 'keyman/engine/main'; import { AnchoredOSKView, ViewConfiguration, StaticActivator } from 'keyman/engine/osk'; import { getAbsoluteX, getAbsoluteY } from 'keyman/engine/dom-utils'; @@ -71,32 +71,7 @@ export default class KeymanEngine extends KeymanEngineBase