diff --git a/web/src/app/browser/src/configuration.ts b/web/src/app/browser/src/configuration.ts index 0b01bbe130..f76184dbd3 100644 --- a/web/src/app/browser/src/configuration.ts +++ b/web/src/app/browser/src/configuration.ts @@ -2,7 +2,7 @@ import { EngineConfiguration, InitOptionSpec, InitOptionDefaults } from "keyman/ import { OutputTargetElementWrapper as DOMOutputTarget } from 'keyman/engine/element-wrappers'; import { OutputTargetInterface, ProcessorAction } from 'keyman/engine/keyboard'; -import { isEmptyTransform } from 'keyman/engine/js-processor'; +import { isEmptyTransform } from '@keymanapp/web-utils'; import { AlertHost } from "./utils/alertHost.js"; import { whenDocumentReady } from "./utils/documentReady.js"; diff --git a/web/src/app/webview/src/contextManager.ts b/web/src/app/webview/src/contextManager.ts index b2c52de00e..bb8253587c 100644 --- a/web/src/app/webview/src/contextManager.ts +++ b/web/src/app/webview/src/contextManager.ts @@ -1,11 +1,11 @@ import { JSKeyboard, Keyboard, OutputTargetInterface, Transcription, TextTransform } from 'keyman/engine/keyboard'; // TODO-web-core: remove usage of OutputTargetBase, use OutputTargetInterface instead -import { Mock, findCommonSubstringEndIndex, isEmptyTransform, OutputTargetBase } from 'keyman/engine/js-processor'; +import { Mock, findCommonSubstringEndIndex, OutputTargetBase } from 'keyman/engine/js-processor'; import { KeyboardStub } from 'keyman/engine/keyboard-storage'; import { ContextManagerBase } from 'keyman/engine/main'; import { WebviewConfiguration } from './configuration.js'; import { LexicalModelTypes } from '@keymanapp/common-types'; -import { KMWString } from '@keymanapp/web-utils'; +import { KMWString, isEmptyTransform } from '@keymanapp/web-utils'; export type OnInsertTextFunc = (deleteLeft: number, text: string, deleteRight: number) => void; diff --git a/web/src/engine/common/web-utils/build.sh b/web/src/engine/common/web-utils/build.sh index 23d38cb952..69b08cb275 100755 --- a/web/src/engine/common/web-utils/build.sh +++ b/web/src/engine/common/web-utils/build.sh @@ -22,6 +22,7 @@ BUNDLE_CMD="node ${KEYMAN_ROOT}/web/src/tools/es-bundling/build/common-bundle.mj builder_describe \ "Compiles the web-oriented utility function module." \ "@/common/web/keyman-version" \ + "@/common/web/types" \ "@/web/src/tools/es-bundling" \ clean configure build test diff --git a/web/src/engine/common/web-utils/package.json b/web/src/engine/common/web-utils/package.json index 557878d43e..1df1836f75 100644 --- a/web/src/engine/common/web-utils/package.json +++ b/web/src/engine/common/web-utils/package.json @@ -29,6 +29,9 @@ "c8": "^7.12.0", "typescript": "^5.4.5" }, + "dependencies": { + "@keymanapp/common-types": "*" + }, "type": "module", "paths": { "@keymanapp/keyman-version": "*" diff --git a/web/src/engine/common/web-utils/src/index.ts b/web/src/engine/common/web-utils/src/index.ts index 30f4821590..343e1486e6 100644 --- a/web/src/engine/common/web-utils/src/index.ts +++ b/web/src/engine/common/web-utils/src/index.ts @@ -23,6 +23,8 @@ export { default as TimeoutPromise, timedPromise } from "./timeoutPromise.js"; export { default as PriorityQueue, QueueComparator } from "./priority-queue.js" +export { isEmptyTransform } from './isEmptyTransform.js'; + // // Uncomment the following line and run the bundled output to verify successful // // esbuild bundling of this submodule: // console.log(Version.CURRENT.toString()); diff --git a/web/src/engine/common/web-utils/src/isEmptyTransform.ts b/web/src/engine/common/web-utils/src/isEmptyTransform.ts new file mode 100644 index 0000000000..db48d1d7c5 --- /dev/null +++ b/web/src/engine/common/web-utils/src/isEmptyTransform.ts @@ -0,0 +1,10 @@ +import { LexicalModelTypes } from '@keymanapp/common-types'; + +// Also relies on string-extensions provided by the web-utils package. + +export function isEmptyTransform(transform: LexicalModelTypes.Transform) { + if (!transform) { + return true; + } + return transform.insert === '' && transform.deleteLeft === 0 && (transform.deleteRight ?? 0) === 0; +} diff --git a/web/src/engine/js-processor/src/outputTargetBase.ts b/web/src/engine/js-processor/src/outputTargetBase.ts index eca7c6766a..a5ed2c2227 100644 --- a/web/src/engine/js-processor/src/outputTargetBase.ts +++ b/web/src/engine/js-processor/src/outputTargetBase.ts @@ -8,15 +8,6 @@ import { type KeyEvent } from 'keyman/engine/keyboard'; import { Deadkey, DeadkeyTracker } from "./deadkeys.js"; import { LexicalModelTypes } from '@keymanapp/common-types'; -// Also relies on string-extensions provided by the web-utils package. - -export function isEmptyTransform(transform: LexicalModelTypes.Transform) { - if(!transform) { - return true; - } - return transform.insert === '' && transform.deleteLeft === 0 && (transform.deleteRight ?? 0) === 0; -} - export abstract class OutputTargetBase implements OutputTargetInterface { private _dks: DeadkeyTracker; diff --git a/web/src/engine/main/src/headless/inputProcessor.ts b/web/src/engine/main/src/headless/inputProcessor.ts index 90ce1787b2..70a0f8105f 100644 --- a/web/src/engine/main/src/headless/inputProcessor.ts +++ b/web/src/engine/main/src/headless/inputProcessor.ts @@ -3,7 +3,7 @@ import ContextWindow from "./contextWindow.js"; import { LanguageProcessor } from "./languageProcessor.js"; import type { ModelSpec, PathConfiguration } from "keyman/engine/interfaces"; -import { globalObject, DeviceSpec } from "@keymanapp/web-utils"; +import { globalObject, DeviceSpec, isEmptyTransform } from "@keymanapp/web-utils"; import { KM_Core } from 'keyman/engine/core-processor'; @@ -20,7 +20,6 @@ import { } from "keyman/engine/keyboard"; // TODO-web-core: remove usage of OutputTargetBase import { - isEmptyTransform, JSKeyboardProcessor, Mock, type ProcessorInitOptions, diff --git a/web/src/engine/osk/src/visualKeyboard.ts b/web/src/engine/osk/src/visualKeyboard.ts index 6985edf192..124fedfcfc 100644 --- a/web/src/engine/osk/src/visualKeyboard.ts +++ b/web/src/engine/osk/src/visualKeyboard.ts @@ -15,7 +15,7 @@ import { timedPromise, ActiveKeyBase } from 'keyman/engine/keyboard'; -import { isEmptyTransform } from 'keyman/engine/js-processor'; +import { isEmptyTransform } from '@keymanapp/web-utils'; import { buildCorrectiveLayout } from './correctionLayout.js'; import { distributionFromDistanceMaps, keyTouchDistances } from './corrections.js';