mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-12 03:45:34 +00:00
refactor(web): move isEmptyTransform to @keymanapp/web-utils
This commit is contained in:
parent
8f08bd2e8a
commit
2dc87f2e37
9 changed files with 21 additions and 15 deletions
|
|
@ -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";
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@
|
|||
"c8": "^7.12.0",
|
||||
"typescript": "^5.4.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@keymanapp/common-types": "*"
|
||||
},
|
||||
"type": "module",
|
||||
"paths": {
|
||||
"@keymanapp/keyman-version": "*"
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
10
web/src/engine/common/web-utils/src/isEmptyTransform.ts
Normal file
10
web/src/engine/common/web-utils/src/isEmptyTransform.ts
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue