refactor(web): move model/types to web/types

Part-of: #12133
This commit is contained in:
Eberhard Beilharz 2024-09-06 17:31:11 +02:00
parent 9f4ca5070d
commit c3e587193e
No known key found for this signature in database
GPG key ID: E9140597606020D3
85 changed files with 127 additions and 264 deletions

1
.github/labeler.yml vendored
View file

@ -21,7 +21,6 @@ common/:
- resources/**
common/models/: common/models/**
common/models/types/: common/models/types/**
common/models/templates/: common/models/templates/**
common/models/wordbreakers/: common/models/wordbreakers/**

View file

@ -51,7 +51,7 @@
"url": "https://github.com/keymanapp/keyman/issues"
},
"devDependencies": {
"@keymanapp/models-types": "*",
"@keymanapp/common-types": "*",
"@keymanapp/web-utils": "*",
"@types/mocha": "^7.0.2",
"c8": "^7.12.0",
@ -61,7 +61,7 @@
},
"dependencies": {
"@keymanapp/keyman-version": "*",
"@keymanapp/models-types": "*",
"@keymanapp/common-types": "*",
"@keymanapp/models-wordbreakers": "*",
"@keymanapp/resources-gosh": "*"
}

View file

@ -1,4 +1,5 @@
// Allows the kmwstring bindings to resolve.
import { CasingForm, Context, Outcome, Suggestion, Transform, WithOutcome } from '@keymanapp/common-types';
import { extendString } from "@keymanapp/web-utils";
extendString();

View file

@ -1,3 +1,5 @@
import { LexicalModelPunctuation } from '@keymanapp/common-types';
export enum QuoteBehavior {
noQuotes = "no-quotes",
useQuotes = "use-quotes",
@ -35,4 +37,4 @@ export namespace QuoteBehavior {
}
}
export default QuoteBehavior;
export default QuoteBehavior;

View file

@ -1,6 +1,8 @@
// While we _could_ define this within @keymanapp/models-wordbreakers instead, it's probably
// better to leave that package as _just_ the wordbreakers.
import { WordBreakingFunction, USVString, Context } from '@keymanapp/common-types';
export interface Token {
text: string,
isWhitespace?: boolean
@ -214,4 +216,4 @@ export function getLastPreCaretToken(wordBreaker: WordBreakingFunction, context:
// would likely be pretty painful.
export function wordbreak(wordBreaker: WordBreakingFunction, context: Context): USVString {
return getLastPreCaretToken(wordBreaker, context);
}
}

View file

@ -31,6 +31,7 @@ import { default as defaultWordBreaker } from "@keymanapp/models-wordbreakers";
import { applyTransform, isHighSurrogate, isSentinel, SENTINEL_CODE_UNIT, transformToSuggestion } from "./common.js";
import { getLastPreCaretToken } from "./tokenization.js";
import { Capabilities, CasingFunction, Configuration, Context, Distribution, LexicalModel, LexicalModelPunctuation, LexiconTraversal, Suggestion, TextWithProbability, Transform, USVString, WithOutcome, WordBreakingFunction } from '@keymanapp/common-types';
extendString();

View file

@ -8,7 +8,7 @@
"rootDir": "./src"
},
"references": [
{ "path": "../types" },
{ "path": "../../web/types" },
{ "path": "../../web/utils" },
{ "path": "../../models/wordbreakers" }
],

View file

@ -1 +0,0 @@
The presence of this file tells CI to use the new builder_ style parameters for build.sh.

View file

@ -1,5 +0,0 @@
# Specifically here:
test.js
node_modules/
build/

View file

@ -1,68 +0,0 @@
`@keymanapp/models-types`
=========================
Declares TypeScript types and interfaces required to define **Lexical
Models**, **Word breaking functions**, and all things in between.
Install
-------
> (see below if you are working in the keymanapp/keyman repo!)
npm install --save-dev @keymanapp/models-types
Usage
-----
Say you are creating a **custom lexical model**. Then import this module
in your lexical model file!
```Typescript
// my-nifty-model.ts
import "@keymanapp/models-types";
export class MyNiftyClass implements LexicalModel {
configure(capabilities: Capabilities): Configuration {
// TODO: implement me!
throw new Error("Method not implemented.");
}
predict(transform: Transform, context: Context): ProbabilityMass<Suggestion>[] {
// TODO: implement me!
throw new Error("Method not implemented.");
}
wordbreak(context: Context): string {
// TODO: implement me!
throw new Error("Method not implemented.");
}
punctuation?: LexicalModelPunctuation;
}
```
If your are creating a **custom word breaker**, you would do the same:
```typescript
import "@keymanapp/models-types";
export let myShinyWordBreaker: WordBreakingFunction;
myShinyWordBreaker = function (phrase: string): Span[] {
// TODO: implement me!
throw new Error("Function not implemented")
}
```
Look at [index.d.ts](./index.d.ts) for documentation on each and every
type!
Usage within keymanapp/keyman repo
----------------------------------
To use it in other subprojects within keymanapp/keyman, ensure that this package
is linked using `"*"`. Add this dependency to your subproject like so:
```json
"dependencies": {
"@keymanapp/models-types": "*",
}
```

View file

@ -1,35 +0,0 @@
#!/usr/bin/env bash
#
# Packages the @keymanapp/models-types package.
#
## START STANDARD BUILD SCRIPT INCLUDE
# adjust relative paths as necessary
THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
. "${THIS_SCRIPT%/*}/../../../resources/build/builder.inc.sh"
## END STANDARD BUILD SCRIPT INCLUDE
. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh"
. "$KEYMAN_ROOT/resources/build/build-utils-ci.inc.sh"
builder_describe "Keyman model types package" \
"clean" \
"configure" \
"build" \
"test" \
"publish publish to npm" \
"--npm-publish+ For publish, do a npm publish, not npm pack (only for CI)" \
"--dry-run,-n don't actually publish, just dry run"
builder_describe_outputs \
configure /node_modules \
build /common/models/types/build/common/models/types/tsconfig.tsbuildinfo
builder_parse "$@"
#-------------------------------------------------------------------------------------------------------------------
builder_run_action clean rm -rf ./build/
builder_run_action configure verify_npm_setup
builder_run_action build tsc --build
builder_run_action test tsc test.ts -lib es6
builder_run_action publish builder_publish_npm

View file

@ -1,38 +0,0 @@
{
"name": "@keymanapp/models-types",
"description": "Type definitions in used in the modeling (lexical model/predictive text) component of Keyman.",
"types": "./index.d.ts",
"scripts": {
"test": "tsc test.ts -lib es6"
},
"repository": {
"type": "git",
"url": "https://github.com/keymanapp/keyman"
},
"keywords": [
"lmlayer",
"keyman",
"predictive",
"text",
"types",
"typing",
"typescript"
],
"author": "Marc Durdin <marc@keyman.com> (https://github.com/mcdurdin)",
"contributors": [
"Eddie Antonio Santos <Eddie.Santos@nrc-cnrc.gc.ca> (https://github.com/eddieantonio)",
"Joshua Horton"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/keymanapp/keyman/issues"
},
"homepage": "https://github.com/keymanapp/keyman/tree/master/common/models/types#readme",
"devDependencies": {
"typescript": "^5.4.5"
},
"files": [
"README.md",
"index.d.ts"
]
}

View file

@ -1,9 +0,0 @@
{
"extends": "../tsconfig.kmw-worker-base.json",
"compilerOptions": {
"declaration": true,
"outDir": "build/",
},
"include": ["./*.ts"],
"exclude": ["test.ts"]
}

View file

@ -54,7 +54,7 @@
"url": "https://github.com/keymanapp/keyman/issues"
},
"devDependencies": {
"@keymanapp/models-types": "*",
"@keymanapp/common-types": "*",
"@keymanapp/resources-gosh": "*",
"@types/mocha": "^7.0.2",
"c8": "^7.12.0",

View file

@ -1,4 +1,4 @@
///<reference types="@keymanapp/models-types" />
import { Span } from '@keymanapp/common-types';
/**
* Splits ASCII words.

View file

@ -1,3 +1,4 @@
import { Span } from '@keymanapp/common-types';
import { WordBreakProperty, propertyMap } from "./data.inc.js";
import { searchForProperty } from "./searchForProperty.js";
@ -576,4 +577,4 @@ function propertyVal(propName: string, options?: DefaultWordBreakerOptions) {
const customIndex = options?.customProperties?.findIndex(matcher) ?? -1;
return customIndex != -1 ? -customIndex - 1 : propertyMap.findIndex(matcher);
}
}

View file

@ -1,3 +1,5 @@
import { Span } from '@keymanapp/common-types';
/**
* A **VERY** dumb word breaker that simply splits at words. Do not use this
* word breaker!

View file

@ -10,7 +10,7 @@
"moduleResolution": "node16"
},
"references": [
{ "path": "../../../types" }
{ "path": "../../../../web/types" }
],
"include": [
"./**/*"

View file

@ -7,13 +7,10 @@
"tsBuildInfoFile": "./build/main/obj/tsconfig.tsbuildinfo",
"rootDir": "./src/main"
},
"references": [
{ "path": "../types" }
],
"include": [
"./src/main/**/*"
],
"exclude": [
"node_modules"
]
}
}

View file

@ -8,9 +8,11 @@
"unicode"
],
"type": "module",
"types": "./build/src/main.d.ts",
"exports": {
".": {
"es6-bundling": "./src/main.ts",
"types": "./build/src/main.d.ts",
"default": "./build/src/main.js"
}
},
@ -68,6 +70,7 @@
"src/kmx/kmx-plus.ts",
"src/kmx/kmx-builder.ts",
"src/kmx/element-string.ts",
"src/lexical-model-types.ts",
"src/kmx/string-list.ts",
"src/ldml-keyboard/ldml-keyboard-testdata-xml.ts",
"src/ldml-keyboard/unicodeset-parser-api.ts",

View file

@ -1,7 +1,7 @@
import { constants } from '@keymanapp/ldml-keyboard-constants';
import { DependencySections, StrsItem, UsetItem } from './kmx-plus.js';
import { ElementParser, ElementSegment, ElementType } from '../../ldml-keyboard/pattern-parser.js';
import { util } from '@keymanapp/common-types';
import * as util from '../../util/util.js';
import MATCH_HEX_ESCAPE = util.MATCH_HEX_ESCAPE;
import unescapeOneQuadString = util.unescapeOneQuadString;

View file

@ -2,8 +2,8 @@ import { constants } from '@keymanapp/ldml-keyboard-constants';
import * as r from 'restructure';
import { ElementString } from './element-string.js';
import { ListItem } from '../../ldml-keyboard/string-list.js';
import { util } from '@keymanapp/common-types';
import { KMX } from '@keymanapp/common-types';
import * as util from '../../util/util.js';
import * as KMX from '../kmx.js';
import { UnicodeSetParser, UnicodeSet } from '../../ldml-keyboard/unicodeset-parser-api.js';
import { VariableParser } from '../../ldml-keyboard/pattern-parser.js';
import { MarkerParser } from '../../ldml-keyboard/pattern-parser.js';

View file

@ -15,14 +15,14 @@
*
* See also: https://developer.mozilla.org/en-US/docs/Web/API/USVString
*/
declare type USVString = string;
export type USVString = string;
declare type CasingForm = 'lower' | 'initial' | 'upper';
export type CasingForm = 'lower' | 'initial' | 'upper';
/**
* Represents one lexical entry and its probability..
*/
type TextWithProbability = {
export type TextWithProbability = {
/**
* A lexical entry (word) offered by the model.
*
@ -42,7 +42,7 @@ type TextWithProbability = {
* Used to facilitate edit-distance calculations by allowing the LMLayer to
* efficiently search the model's lexicon in a Trie-like manner.
*/
declare interface LexiconTraversal {
export interface LexiconTraversal {
/**
* Provides an iterable pattern used to search for words with a 'keyed' prefix matching
* the current traversal state's prefix when a new character is appended. Iterating
@ -116,7 +116,7 @@ declare interface LexiconTraversal {
/**
* The model implementation, within the Worker.
*/
declare interface LexicalModel {
export interface LexicalModel {
/**
* Processes `config` messages, configuring the newly-loaded model based on the host
* platform's capability restrictions.
@ -263,7 +263,7 @@ declare interface LexicalModel {
* first, you delete the specified amount amount from the left
* and right, then you insert the provided text.
*/
declare interface Transform {
export interface Transform {
/**
* Facilitates use of unique identifiers for tracking the Transform and
* any related data from its original source, as the reference cannot be
@ -298,7 +298,7 @@ declare interface Transform {
/**
* A concrete suggestion
*/
declare interface Suggestion {
export interface Suggestion {
/**
* Indicates the externally-supplied id of the Transform that prompted
* the Suggestion. Automatically handled by the LMLayer; models should
@ -341,11 +341,11 @@ declare interface Suggestion {
autoAccept?: boolean
}
interface Reversion extends Suggestion {
export interface Reversion extends Suggestion {
tag: 'revert';
}
interface Keep extends Suggestion {
export interface Keep extends Suggestion {
tag: 'keep';
/**
@ -368,12 +368,12 @@ interface Keep extends Suggestion {
*
* If left undefined, the consumers will assume this is a prediction.
*/
type SuggestionTag = undefined | 'keep' | 'revert' | 'correction' | 'emoji';
export type SuggestionTag = undefined | 'keep' | 'revert' | 'correction' | 'emoji';
/**
* The text and environment surrounding the insertion point (text cursor).
*/
declare interface Context {
export interface Context {
/**
* Up to maxLeftContextCodeUnits code units of Unicode scalar value
* (i. e., characters) to the left of the insertion point in the
@ -413,7 +413,7 @@ declare interface Context {
* from ambiguous text sequences. Designed for use with fat-finger correction
* and similar typing ambiguities.
*/
interface ProbabilityMass<T> {
export interface ProbabilityMass<T> {
/**
* An individual sample from a Distribution over the same type.
*/
@ -426,12 +426,12 @@ interface ProbabilityMass<T> {
p: number;
}
declare type Distribution<T> = ProbabilityMass<T>[];
export type Distribution<T> = ProbabilityMass<T>[];
/**
* A type augmented with an optional probability.
*/
type Outcome<T> = T & {
export type Outcome<T> = T & {
/**
* [optional] probability of this outcome.
*/
@ -441,7 +441,7 @@ type Outcome<T> = T & {
/**
* A type augmented with a probability.
*/
type WithOutcome<T> = T & {
export type WithOutcome<T> = T & {
/**
* Probability of this outcome.
*/
@ -458,7 +458,7 @@ type WithOutcome<T> = T & {
* prediction, as well as what operations the keyboard is allowed to do on the
* underlying buffer.
*/
declare interface Capabilities {
export interface Capabilities {
/**
* The maximum amount of UTF-16 code points that the keyboard will provide to
* the left of the cursor, as an integer.
@ -482,7 +482,7 @@ declare interface Capabilities {
/**
* Configuration of the LMLayer, sent back to the keyboard.
*/
declare interface Configuration {
export interface Configuration {
/**
* How many UTF-16 code units maximum to send as the context to the
* left of the cursor ("left" in the Unicode character stream).
@ -538,14 +538,14 @@ declare interface Configuration {
* @returns an array of spans from the phrase, in order as they appear in the
* phrase, each span which representing a word.
*/
declare interface WordBreakingFunction {
export interface WordBreakingFunction {
// invariant: span[i].end <= span[i + 1].start
// invariant: for all span[i] and span[i + 1], there does not exist a span[k]
// where span[i].end <= span[k].start AND span[k].end <= span[i + 1].start
(phrase: string): Span[];
}
declare interface CasingFunction {
export interface CasingFunction {
(caseToApply: CasingForm, text: string, defaultApplyCasing?: CasingFunction): string;
}
@ -553,7 +553,7 @@ declare interface CasingFunction {
* A span of text in a phrase. This is usually meant to represent words from a
* pharse.
*/
declare interface Span {
export interface Span {
// invariant: start < end (empty spans not allowed)
readonly start: number;
// invariant: end > end (empty spans not allowed)
@ -572,7 +572,7 @@ declare interface Span {
/**
* Options for various punctuation to use in suggestions.
*/
interface LexicalModelPunctuation {
export interface LexicalModelPunctuation {
/**
* The quotes that appear in "keep" suggestions, e.g., keep what the user
* typed verbatim.

View file

@ -29,3 +29,5 @@ export * as KMXPlus from './kmx/kmx-plus/kmx-plus.js';
export { UnicodeSetParser, UnicodeSet } from './ldml-keyboard/unicodeset-parser-api.js';
export { VariableParser, MarkerParser } from './ldml-keyboard/pattern-parser.js';
export { ElementString } from './kmx/kmx-plus/element-string.js';
export * from './lexical-model-types.js';

View file

@ -1,12 +1,12 @@
/// <reference path="./index.d.ts" />
/**
* This file "tests" the exports from the main module.
*
*
* Since the exports are all types, the "test" here is that the type can be
* imported and compiled without any compiler errors.
*/
import { USVString, Transform, Suggestion, SuggestionTag, Context, Capabilities, Configuration, Distribution, WordBreakingFunction, Span, LexicalModelPunctuation, ElementString, KMXPlus } from '@keymanapp/common-types';
export let u: USVString;
export let l: Transform
export let s: Suggestion;
@ -17,4 +17,9 @@ export let conf: Configuration;
export let d: Distribution<Suggestion>;
export let wbf: WordBreakingFunction;
export let sp: Span;
export let lmp: LexicalModelPunctuation;
export let lmp: LexicalModelPunctuation;
// try some of the other types - that should still work
export let elemString: ElementString;
export let section: KMXPlus.Section;

View file

@ -11,11 +11,12 @@
},
"include": [
"**/test-*.ts",
"**/*.tests.ts",
"./helpers/*.ts",
],
"references": [
{ "path": "../../keyman-version" },
{ "path": "../../../../core/include/ldml/"},
{ "path": "../" },
]
],
}

View file

@ -4,7 +4,7 @@
```ts
/// <reference types="@keymanapp/models-types" />
/// <reference types="@keymanapp/common-types" />
import { CompilerCallbacks } from '@keymanapp/common-types';
import { CompilerEvent } from '@keymanapp/common-types';

View file

@ -151,7 +151,6 @@ function do_publish() {
../../common/web/keyman-version/build.sh publish $DRY_RUN $NPM_PUBLISH
../../common/web/types/build.sh publish $DRY_RUN $NPM_PUBLISH
../../common/models/types/build.sh publish $DRY_RUN $NPM_PUBLISH
../../core/include/ldml/build.sh publish $DRY_RUN $NPM_PUBLISH
# end TODO
#--------------------------------------------------------

View file

@ -1,6 +1,3 @@
/// <reference types="@keymanapp/common-types" />
// above is required for now, seemingly https://github.com/microsoft/TypeScript/issues/42873
// probably addressed in ts 5.5.2
import { CompilerErrorNamespace, CompilerErrorSeverity, CompilerMessageSpec as m, CompilerMessageDef as def, CompilerMessageSpecWithException, KeymanUrls } from "@keymanapp/developer-utils";
const Namespace = CompilerErrorNamespace.Analyzer;

View file

@ -9,7 +9,6 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
builder_describe "Build Keyman kmc Lexical Model model-info Compiler module" \
"@/common/web/types" \
"@/common/models/types" \
"clean" \
"configure" \
"build" \

View file

@ -31,7 +31,7 @@
},
"dependencies": {
"@keymanapp/common-types": "*",
"@keymanapp/models-types": "*",
"@keymanapp/common-types": "*",
"@keymanapp/developer-utils": "*"
},
"devDependencies": {

View file

@ -10,7 +10,6 @@
],
"references": [
{ "path": "../../../common/web/types" },
{ "path": "../../../common/models/types" },
{ "path": "../common/web/utils" },
]
}

View file

@ -8,8 +8,6 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh"
. "$KEYMAN_ROOT/resources/build/build-utils-ci.inc.sh"
# TODO: "@/common/models/types" \
builder_describe "Keyman kmc Lexical Model Compiler module" \
"@/common/web/keyman-version" \
"@/developer/src/common/web/test-helpers" \

View file

@ -32,7 +32,7 @@
"dependencies": {
"@keymanapp/common-types": "*",
"@keymanapp/keyman-version": "*",
"@keymanapp/models-types": "*",
"@keymanapp/common-types": "*",
"typescript": "^5.4.5"
},
"devDependencies": {

View file

@ -1,4 +1,4 @@
/// <reference types="@keymanapp/models-types" />
import { Span, WordBreakingFunction } from '@keymanapp/common-types';
/**
* Returns a word breaker that joins spans of an existing word breaker.

View file

@ -3,6 +3,8 @@
* the LMLayer's internal worker code, so we provide those definitions too.
*/
import { CasingFunction, LexicalModelPunctuation, WordBreakingFunction } from '@keymanapp/common-types';
export interface LexicalModelDeclaration {
readonly format: 'trie-1.0'|'fst-foma-1.0'|'custom-1.0',
//... metadata ...

View file

@ -1,3 +1,5 @@
import { CasingForm, CasingFunction } from '@keymanapp/common-types';
/**
* Converts wordforms into an indexable form. It does this by
* normalizing the letter case of characters INDIVIDUALLY (to disregard
@ -104,4 +106,4 @@ export function defaultApplyCasing(casing: CasingForm, text: string): string {
return text.substring(0, headUnitLength).toUpperCase() // head - uppercased
.concat(text.substring(headUnitLength)); // tail - lowercased
}
}
}

View file

@ -5,6 +5,7 @@ import { defaultApplyCasing,
import KEYMAN_VERSION from "@keymanapp/keyman-version";
import { LexicalModelSource, WordformToKeySpec } from "./lexical-model.js";
import { CasingForm, CasingFunction } from '@keymanapp/common-types';
/**
* Processes certain defined model behaviors in such a way that the needed closures
@ -219,4 +220,4 @@ export class ModelDefinitions {
}
// Because it references the class field, this line must come afterward.
const PSEUDOCLOSURE = ModelDefinitions.COMPILED_NAME;
const PSEUDOCLOSURE = ModelDefinitions.COMPILED_NAME;

View file

@ -1,3 +1,4 @@
import { Span, WordBreakingFunction } from '@keymanapp/common-types';
import { OverrideScriptDefaults } from "./lexical-model.js";
import { ModelCompilerError, ModelCompilerMessages } from "./model-compiler-messages.js";

View file

@ -1,5 +1,3 @@
/// <reference types="@keymanapp/models-types" />
/**
* Helpers and utilities for the Mocha tests.
*/

View file

@ -4,6 +4,7 @@ import 'mocha';
import { makePathToFixture, compileModelSourceCode } from './helpers/index.js';
import { TestCompilerCallbacks } from '@keymanapp/developer-test-helpers';
import { CasingForm, CasingFunction } from '@keymanapp/common-types';
describe('LexicalModelCompiler - pseudoclosure compilation + use', function () {
const callbacks = new TestCompilerCallbacks();

View file

@ -8,6 +8,7 @@ import { createTrieDataStructure } from '../src/build-trie.js';
import { ModelCompilerError } from '../src/model-compiler-messages.js';
import { TestCompilerCallbacks } from '@keymanapp/developer-test-helpers';
import { TrieModel } from '@keymanapp/models-templates';
import { Span } from '@keymanapp/common-types';
describe('LexicalModelCompiler', function () {
const callbacks = new TestCompilerCallbacks();

View file

@ -4,6 +4,7 @@ import {assert} from 'chai';
import { defaultSearchTermToKey,
defaultCasedSearchTermToKey,
defaultApplyCasing } from '../src/model-defaults.js';
import { CasingForm, CasingFunction } from '@keymanapp/common-types';
describe('The default searchTermToKey() function', function () {

View file

@ -1,6 +1,7 @@
import { assert } from "chai";
import defaultWordBreaker from '@keymanapp/models-wordbreakers';
import {decorateWithJoin} from '../src/join-word-breaker-decorator.js';
import { Span } from '@keymanapp/common-types';
describe('The join word breaker decorator', function () {
it('should decorate an existing word breaker', function () {

View file

@ -2,6 +2,7 @@ import 'mocha';
import { assert } from 'chai';
import { ModelDefinitions } from '../src/model-definitions.js';
import { LexicalModelSource } from '../src/lexical-model.js';
import { CasingForm, CasingFunction } from '@keymanapp/common-types';
describe('Model definition pseudoclosures', function () {
describe('14.0 defaults', function() {
@ -195,4 +196,4 @@ describe('Model definition pseudoclosures', function () {
});
}
});
});
});

View file

@ -1,6 +1,7 @@
import { assert } from "chai";
import defaultWordBreaker from '@keymanapp/models-wordbreakers';
import {decorateWithScriptOverrides} from '../src/script-overrides-decorator.js';
import { Span } from '@keymanapp/common-types';
const THIN_SPACE = "\u2009";

View file

@ -12,7 +12,6 @@
],
"references": [
{ "path": "../../../common/web/keyman-version" },
{ "path": "../../../common/models/types" },
{ "path": "../../../common/web/types" },
]
}

View file

@ -44,7 +44,7 @@
"@keymanapp/kmc-model": "*",
"@keymanapp/kmc-model-info": "*",
"@keymanapp/kmc-package": "*",
"@keymanapp/models-types": "*",
"@keymanapp/common-types": "*",
"@sentry/node": "^7.57.0",
"chalk": "^2.4.2",
"commander": "^10.0.0",

View file

@ -6,7 +6,6 @@
readonly PACKAGES=(
common/web/keyman-version
common/web/types
common/models/types
core/include/ldml
developer/src/common/web/utils
developer/src/kmc-analyze

View file

@ -19,13 +19,13 @@ Packages are **never** published from a developer's machine.
* `@keymanapp/kmc-model` -- located at `developer/src/kmc-model`
* `@keymanapp/kmc-model-info` -- located at `developer/src/kmc-model-info`
* `@keymanapp/kmc-package` -- located at `developer/src/kmc-package`
* `@keymanapp/models-types` -- located at `common/models/types`
### Deprecated npm packages
* `@keymanapp/developer-lexical-model-compiler` -- replaced by `@keymanapp/kmc`
* `@keymanapp/lexical-model-compiler` -- replaced by `@keymanapp/kmc`
* `@keymanapp/lexical-model-types` -- replaced by `@keymanapp/models-types`
* `@keymanapp/lexical-model-types` -- replaced by `@keymanapp/common-types`
* `@keymanapp/models-types` -- replaced by `@keymanapp/common-types`
* `@keymanapp/lmlayer-cli` -- replaced by `@keymanapp/kmc`
* `@keymanapp/models-wordbreakers` -- published accidentally

30
package-lock.json generated
View file

@ -74,13 +74,13 @@
"name": "@keymanapp/models-templates",
"license": "MIT",
"dependencies": {
"@keymanapp/common-types": "*",
"@keymanapp/keyman-version": "*",
"@keymanapp/models-types": "*",
"@keymanapp/models-wordbreakers": "*",
"@keymanapp/resources-gosh": "*"
},
"devDependencies": {
"@keymanapp/models-types": "*",
"@keymanapp/common-types": "*",
"@keymanapp/web-utils": "*",
"@types/mocha": "^7.0.2",
"c8": "^7.12.0",
@ -89,18 +89,11 @@
"typescript": "^5.4.5"
}
},
"common/models/types": {
"name": "@keymanapp/models-types",
"license": "MIT",
"devDependencies": {
"typescript": "^5.4.5"
}
},
"common/models/wordbreakers": {
"name": "@keymanapp/models-wordbreakers",
"license": "MIT",
"devDependencies": {
"@keymanapp/models-types": "*",
"@keymanapp/common-types": "*",
"@keymanapp/resources-gosh": "*",
"@types/mocha": "^7.0.2",
"c8": "^7.12.0",
@ -521,7 +514,6 @@
"@keymanapp/kmc-model": "*",
"@keymanapp/kmc-model-info": "*",
"@keymanapp/kmc-package": "*",
"@keymanapp/models-types": "*",
"@sentry/node": "^7.57.0",
"chalk": "^2.4.2",
"commander": "^10.0.0",
@ -1330,7 +1322,6 @@
"dependencies": {
"@keymanapp/common-types": "*",
"@keymanapp/keyman-version": "*",
"@keymanapp/models-types": "*",
"typescript": "^5.4.5"
},
"devDependencies": {
@ -1349,8 +1340,7 @@
"license": "MIT",
"dependencies": {
"@keymanapp/common-types": "*",
"@keymanapp/developer-utils": "*",
"@keymanapp/models-types": "*"
"@keymanapp/developer-utils": "*"
},
"devDependencies": {
"@types/mocha": "^5.2.7",
@ -2846,10 +2836,6 @@
"resolved": "common/models/templates",
"link": true
},
"node_modules/@keymanapp/models-types": {
"resolved": "common/models/types",
"link": true
},
"node_modules/@keymanapp/models-wordbreakers": {
"resolved": "common/models/wordbreakers",
"link": true
@ -14735,9 +14721,9 @@
"name": "keyman",
"license": "MIT",
"dependencies": {
"@keymanapp/common-types": "*",
"@keymanapp/keyman-version": "*",
"@keymanapp/lexical-model-layer": "*",
"@keymanapp/models-types": "*",
"@keymanapp/recorder-core": "*",
"@keymanapp/web-utils": "*",
"core-js": "^3.34.0",
@ -14787,7 +14773,7 @@
"string.prototype.codepointat": "^0.2.1"
},
"devDependencies": {
"@keymanapp/models-types": "*",
"@keymanapp/common-types": "*",
"@keymanapp/resources-gosh": "*",
"mocha": "^10.0.0",
"mocha-teamcity-reporter": "^4.0.0",
@ -14808,7 +14794,7 @@
},
"devDependencies": {
"@keymanapp/common-test-resources": "*",
"@keymanapp/models-types": "*",
"@keymanapp/common-types": "*",
"@keymanapp/resources-gosh": "*",
"c8": "^7.12.0",
"combine-source-map": "^0.8.0",
@ -14821,8 +14807,8 @@
"name": "@keymanapp/recorder-core",
"license": "MIT",
"dependencies": {
"@keymanapp/common-types": "*",
"@keymanapp/keyman-version": "*",
"@keymanapp/models-types": "*",
"@keymanapp/web-utils": "*"
},
"devDependencies": {

View file

@ -27,7 +27,6 @@
"paths": {
"@keymanapp/common-types": ["./common/web/types/src/main"],
"@keymanapp/keyman": ["./web" ],
"@keymanapp/models-types": ["./common/models/types"],
"@keymanapp/models-templates": ["./common/models/templates"],
"@keymanapp/models-wordbreakers": ["./common/models/wordbreakers"],
"@keymanapp/web-utils": ["./common/web/utils"],

View file

@ -3,7 +3,6 @@
{ "path": "./core/include/ldml/tsconfig.json" },
{ "path": "./common/models/templates/tsconfig.json" },
{ "path": "./common/models/types/tsconfig.json" },
{ "path": "./common/models/wordbreakers/tsconfig.json" },
{ "path": "./common/tools/hextobin/" },

View file

@ -122,7 +122,7 @@
"dependencies": {
"@keymanapp/keyman-version": "*",
"@keymanapp/lexical-model-layer": "*",
"@keymanapp/models-types": "*",
"@keymanapp/common-types": "*",
"@keymanapp/recorder-core": "*",
"@keymanapp/web-utils": "*",
"core-js": "^3.34.0",

View file

@ -3,6 +3,7 @@ import { EngineConfiguration, InitOptionSpec, InitOptionDefaults } from "keyman/
import { buildMergedTransform } from '@keymanapp/models-templates';
import { type OnInsertTextFunc } from "./contextManager.js";
import { Transform } from '@keymanapp/common-types';
export class WebviewConfiguration extends EngineConfiguration {
private _embeddingApp: string;

View file

@ -3,6 +3,7 @@ import { Mock, OutputTarget, Transcription, findCommonSubstringEndIndex, isEmpty
import { KeyboardStub } from 'keyman/engine/keyboard-storage';
import { ContextManagerBase } from 'keyman/engine/main';
import { WebviewConfiguration } from './configuration.js';
import { Transform } from '@keymanapp/common-types';
export type OnInsertTextFunc = (deleteLeft: number, text: string, deleteRight: number) => void;

View file

@ -1,5 +1,4 @@
///<reference types="@keymanapp/models-types" />
import { Suggestion, Reversion } from '@keymanapp/common-types';
import { EventEmitter } from "eventemitter3";
import { OutputTarget } from "keyman/engine/keyboard";

View file

@ -1,4 +1,5 @@
import { EventEmitter } from "eventemitter3";
import { Keep, Reversion, Suggestion } from '@keymanapp/common-types';
import { type LanguageProcessorSpec , ReadySuggestions, type InvalidateSourceEnum, StateChangeHandler } from './languageProcessor.interface.js';
import { type OutputTarget } from "keyman/engine/keyboard";

View file

@ -1,5 +1,3 @@
///<reference types="@keymanapp/models-types" />
import { extendString } from "@keymanapp/web-utils";
import { findCommonSubstringEndIndex } from "./stringDivergence.js";
import { Mock } from "./mock.js";
@ -10,6 +8,7 @@ extendString();
// Defines deadkey management in a manner attachable to each element interface.
import { type KeyEvent } from 'keyman/engine/keyboard';
import { Deadkey, DeadkeyTracker } from "./deadkeys.js";
import { ProbabilityMass, Transform } from '@keymanapp/common-types';
// Also relies on string-extensions provided by the web-utils package.

View file

@ -1,10 +1,9 @@
///<reference types="@keymanapp/models-types" />
import KeyboardProcessor from "./keyboardProcessor.js";
import { VariableStoreDictionary } from "keyman/engine/keyboard";
import OutputTarget, { type Transcription } from './outputTarget.js';
import { Mock } from "./mock.js";
import { type VariableStore } from "./systemStores.js";
import { Suggestion } from '@keymanapp/common-types';
/**
* Represents the commands and state changes that result from a matched keyboard rule.

View file

@ -1,3 +1,4 @@
import { CasingForm, Configuration, Context } from '@keymanapp/common-types';
import { Mock } from "keyman/engine/js-processor";
export default class ContextWindow implements Context {

View file

@ -1,7 +1,5 @@
// Defines a 'polyfill' of sorts for NPM's events module
/// <reference types="@keymanapp/models-types" />
import ContextWindow from "./contextWindow.js";
import { LanguageProcessor } from "./languageProcessor.js";
import type { ModelSpec } from "keyman/engine/interfaces";
@ -21,6 +19,7 @@ import {
} from 'keyman/engine/js-processor';
import { TranscriptionCache } from "./transcriptionCache.js";
import { Transform } from '@keymanapp/common-types';
export class InputProcessor {
public static readonly DEFAULT_OPTIONS: ProcessorInitOptions = {

View file

@ -4,6 +4,7 @@ import { OutputTarget, Transcription, Mock } from "keyman/engine/js-processor";
import { LanguageProcessorEventMap, ModelSpec, StateChangeEnum, ReadySuggestions } from 'keyman/engine/interfaces';
import ContextWindow from "./contextWindow.js";
import { TranscriptionCache } from "./transcriptionCache.js";
import { Capabilities, Configuration, Reversion, Suggestion } from '@keymanapp/common-types';
/* Is more like the model configuration engine */
export class LanguageProcessor extends EventEmitter<LanguageProcessorEventMap> {

View file

@ -19,6 +19,7 @@ import { ParsedLengthStyle } from '../lengthStyle.js';
import { getFontSizeStyle } from '../fontSizeUtils.js';
import { getTextMetrics } from '../keyboard-layout/getTextMetrics.js';
import { BannerScrollState } from './bannerScrollState.js';
import { Suggestion } from '@keymanapp/common-types';
const TOUCHED_CLASS: string = 'kmw-suggest-touched';
const BANNER_SCROLLER_CLASS = 'kmw-suggest-banner-scroller';

View file

@ -20,7 +20,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/// <reference types="@keymanapp/models-types" />
import { Configuration, Reversion, Suggestion, USVString } from '@keymanapp/common-types';
/**
* Tokens are signed 31-bit integers!

View file

@ -1,6 +1,7 @@
{
"name": "@keymanapp/lm-message-types",
"description": "Type definitions in used in the lm layer (lexical model/predictive text) component of Keyman.",
"type": "module",
"types": "./message.d.ts",
"scripts": {
"test": "tsc test.ts -lib es6"

View file

@ -17,11 +17,10 @@ BUNDLE_CMD="node $KEYMAN_ROOT/common/web/es-bundling/build/common-bundle.mjs"
################################ Main script ################################
# "@../models/types" \ # is just a .d.ts, so there's nothing to actually BUILD.
builder_describe "Builds the lm-layer module" \
"@/common/web/keyman-version" \
"@/common/web/es-bundling" \
"@/common/web/types" \
"@/web/src/engine/predictive-text/worker-thread" \
"clean" \
"configure" \

View file

@ -42,7 +42,7 @@
},
"homepage": "https://github.com/keymanapp/keyman#readme",
"devDependencies": {
"@keymanapp/models-types": "*",
"@keymanapp/common-types": "*",
"@keymanapp/resources-gosh": "*",
"mocha": "^10.0.0",
"mocha-teamcity-reporter": "^4.0.0",

View file

@ -20,9 +20,10 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import { Capabilities, Configuration, Context, Distribution, Reversion, Suggestion, Transform, USVString } from '@keymanapp/common-types';
import PromiseStore from "./promise-store.js";
import { OutgoingMessage } from '@keymanapp/lm-message-types';
/// <reference types="@keymanapp/lm-message-types" />
/// <reference types="worker-interface.d.ts" />
/**

View file

@ -22,6 +22,8 @@
/// <reference types="@keymanapp/lm-message-types" />
import { Token } from '@keymanapp/lm-message-types';
type Resolve<T> = (value?: T | PromiseLike<T>) => void;
type Reject = (reason?: any) => void;
interface PromiseCallbacks<T> {

View file

@ -9,7 +9,7 @@
},
"references": [
{ "path": "../../../../../../common/web/utils" },
{ "path": "../../../../../../common/models/types"},
{ "path": "../../../../../../common/web/types"},
{ "path": "../../types"}
],
"include" : [ "./*.ts" ],

View file

@ -14,7 +14,7 @@
"files": [],
"references": [
{ "path": "../../../../../common/web/utils" },
{ "path": "../../../../../common/models/types"},
{ "path": "../../../../../common/web/types"},
{ "path": "../types"},
{ "path": "src/node" },
{ "path": "src/web" }

View file

@ -26,7 +26,7 @@
"license": "MIT",
"devDependencies": {
"@keymanapp/common-test-resources": "*",
"@keymanapp/models-types": "*",
"@keymanapp/common-types": "*",
"@keymanapp/resources-gosh": "*",
"c8": "^7.12.0",
"combine-source-map": "^0.8.0",

View file

@ -5,6 +5,7 @@ import { SearchSpace } from './distance-modeler.js';
import TransformUtils from '../transformUtils.js';
import { determineModelTokenizer } from '../model-helpers.js';
import { tokenizeTransform, tokenizeTransformDistribution } from './transform-tokenization.js';
import { Context, Distribution, LexicalModel, Suggestion, Transform, USVString } from '@keymanapp/common-types';
function textToCharTransforms(text: string, transformId?: number) {
let perCharTransforms: Transform[] = [];

View file

@ -3,6 +3,7 @@ import { QueueComparator as Comparator, PriorityQueue } from '@keymanapp/web-uti
import { ClassicalDistanceCalculation, EditToken } from './classical-calculation.js';
import { ExecutionTimer, STANDARD_TIME_BETWEEN_DEFERS } from './execution-timer.js';
import { Distribution, LexicalModel, LexiconTraversal, ProbabilityMass, Transform, USVString } from '@keymanapp/common-types';
type RealizedInput = ProbabilityMass<Transform>[]; // NOT Distribution - they're masses from separate distributions.

View file

@ -1,3 +1,4 @@
import { Context, Distribution, Transform } from '@keymanapp/common-types';
import { applyTransform, type Tokenization } from "@keymanapp/models-templates";
/**

View file

@ -40,6 +40,8 @@ import * as wordBreakers from '@keymanapp/models-wordbreakers';
import ModelCompositor from './model-compositor.js';
import { ImportScripts, IncomingMessage, LMLayerWorkerState, LoadMessage, ModelEval, ModelFile, ModelSourceSpec, PostMessage } from './worker-interfaces.js';
import { Capabilities, LexicalModel } from '@keymanapp/common-types';
import { OutgoingMessageKind } from '@keymanapp/lm-message-types';
/**
* Encapsulates all the state required for the LMLayer's worker thread.

View file

@ -4,6 +4,7 @@ import * as correction from './correction/index.js'
import TransformUtils from './transformUtils.js';
import { correctAndEnumerate, dedupeSuggestions, finalizeSuggestions, predictionAutoSelect, processSimilarity, toAnnotatedSuggestion, tupleDisplayOrderSort } from './predict-helpers.js';
import { detectCurrentCasing, determineModelTokenizer, determineModelWordbreaker, determinePunctuationFromModel } from './model-helpers.js';
import { CasingForm, Context, Distribution, LexicalModel, LexicalModelPunctuation, Reversion, Suggestion, Transform, USVString } from '@keymanapp/common-types';
export class ModelCompositor {
private lexicalModel: LexicalModel;

View file

@ -1,3 +1,4 @@
import { CasingForm, Context, LexicalModel, LexicalModelPunctuation } from '@keymanapp/common-types';
import * as models from '@keymanapp/models-templates';
import * as wordBreakers from '@keymanapp/models-wordbreakers';

View file

@ -1,5 +1,7 @@
/// <reference types="@keymanapp/lm-message-types" />
import { Capabilities, CasingForm, Configuration, Context, Distribution, LexicalModel, LexicalModelPunctuation, Outcome, Suggestion, Transform, WordBreakingFunction } from '@keymanapp/common-types';
/*
* Copyright (c) 2018 National Research Council Canada (author: Eddie A. Santos)
* Copyright (c) 2018 SIL International

View file

@ -5,6 +5,7 @@ import { determineModelTokenizer, determineModelWordbreaker, determinePunctuatio
import { ContextTracker, TrackedContextState } from './correction/context-tracker.js';
import { ExecutionTimer } from './correction/execution-timer.js';
import ModelCompositor from './model-compositor.js';
import { ProbabilityMass, Suggestion, LexicalModel, Distribution, Outcome, Keep, SuggestionTag, Reversion, Transform, Context } from '@keymanapp/common-types';
/*
* The functions in this file exist to provide unit-testable stateless components for the

View file

@ -1,3 +1,5 @@
import { Transform } from '@keymanapp/common-types';
export default class TransformUtils {
static isWhitespace(transform: Transform): boolean {
// Matches a string that is entirely one or more characters with Unicode general property Z* or the following: CR, LF, and Tab.

View file

@ -28,7 +28,9 @@
/// <reference types="@keymanapp/lm-message-types" />
import { Capabilities, Context, Distribution, LexicalModel, Reversion, Suggestion, Transform } from '@keymanapp/common-types';
import type ModelCompositor from './model-compositor.js';
import { Token } from '@keymanapp/models-templates';
/**
* The signature of self.postMessage(), so that unit tests can mock it.

View file

@ -18,7 +18,7 @@
},
"references": [
// types
{ "path": "../../../../../common/models/types" },
{ "path": "../../../../../common/web/types" },
{ "path": "../types" },
// modules
{ "path": "../../../../../common/web/keyman-version" },

View file

@ -19,7 +19,7 @@
},
"homepage": "https://github.com/keymanapp/keyman#readme",
"dependencies": {
"@keymanapp/models-types": "*",
"@keymanapp/common-types": "*",
"@keymanapp/keyman-version": "*",
"@keymanapp/web-utils": "*"
},