spiegel-keyman/common/models/types
Marc Durdin 3265a714f2 chore(common): add missing deps and files for npm publish
The build/ folder for most packages was missing due to being listed in
.gitignore.

Also, @keymanapp/ldml-keyboard-constants package was not being published
despite being a dependency of @keymanapp/kmc-keyboard.

Instead of relying on npm's use of .gitignore / .npmignore (which has
seriously wonky behaviours), we list the files that should be included
in package.json.

NPM Wonky behaviours: it seems that .npmignore causes .gitignore in the
same folder to be ignored. But, higher level .gitignore files still
affect the files included in the package, which makes
specification-by-exclusion painful (negating exclusions, etc). We do not
recommend use of .npmignore anywhere for this reason.
2023-04-12 14:05:05 +07:00
..
.build-builder fix(common): support npm pack and consolidate npm publishing 2023-04-12 11:55:31 +07:00
.gitignore chore(web): replace lerna with npm workspaces and ts projects 2022-04-12 21:02:33 +10:00
build.sh chore(common): add missing deps and files for npm publish 2023-04-12 14:05:05 +07:00
index.d.ts feat(web): prediction casing follows current layer 2022-04-08 16:14:01 +10:00
package.json chore(common): updates typescript to 4.9.5 2023-02-09 08:40:52 +07:00
README.md chore(web): replace lerna with npm workspaces and ts projects 2022-04-12 21:02:33 +10:00
test.ts refactor(common/lmlayer): move @keymanapp/models-types to its new home 2020-05-19 19:14:15 -06:00
tsconfig.json chore(web): replace lerna with npm workspaces and ts projects 2022-04-12 21:02:33 +10:00

@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!

// 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:

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 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:

  "dependencies": {
    "@keymanapp/models-types": "*",
  }