@keymanapp/kmc-analyze 18.0.8-alpha → 18.0.9-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/build/src/index.d.ts +3 -2
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +4 -3
- package/build/src/index.js.map +1 -1
- package/build/src/messages.d.ts +8 -4
- package/build/src/messages.d.ts.map +1 -1
- package/build/src/messages.js +11 -5
- package/build/src/messages.js.map +1 -1
- package/build/src/osk-character-use/index.d.ts +61 -1
- package/build/src/osk-character-use/index.d.ts.map +1 -1
- package/build/src/osk-character-use/index.js +50 -16
- package/build/src/osk-character-use/index.js.map +1 -1
- package/build/src/osk-rewrite-pua/index.d.ts +27 -1
- package/build/src/osk-rewrite-pua/index.d.ts.map +1 -1
- package/build/src/osk-rewrite-pua/index.js +29 -3
- package/build/src/osk-rewrite-pua/index.js.map +1 -1
- package/package.json +5 -4
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Keyman Developer - kmc-analyze
|
|
2
|
+
|
|
3
|
+
This package provides Keyman keyboard analysis tools. It can be used from the
|
|
4
|
+
command line with [@keymanapp/kmc](https://npmjs.com/package/@keymanapp/kmc).
|
|
5
|
+
|
|
6
|
+
Currently, the primary function of this package is to work with Keyman's
|
|
7
|
+
[`&displayMap` store](https://help.keyman.com/developer/language/reference/displaymap) for
|
|
8
|
+
rewriting the On Screen Keyboard with PUA characters, for consistent display of
|
|
9
|
+
diacritics and combining marks across all platforms.
|
|
10
|
+
|
|
11
|
+
* [API Reference](https://help.keyman.com/developer/current-version/reference/api/kmc-analyze)
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* kmc-analyze - keyboard analysis classes, including tools for `&displayMap`.
|
|
3
4
|
*/
|
|
4
|
-
export { AnalyzeOskCharacterUse } from './osk-character-use/index.js';
|
|
5
|
+
export { AnalyzeOskCharacterUse, AnalyzeOskCharacterUseOptions } from './osk-character-use/index.js';
|
|
5
6
|
export { AnalyzeOskRewritePua } from './osk-rewrite-pua/index.js';
|
|
6
7
|
export { AnalyzerMessages } from './messages.js';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/build/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
package/build/src/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
1
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4c9393bf-f417-5abb-8feb-4d080e0b6401")}catch(e){}}();
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
* kmc-analyze - keyboard analysis classes, including tools for `&displayMap`.
|
|
4
5
|
*/
|
|
5
6
|
export { AnalyzeOskCharacterUse } from './osk-character-use/index.js';
|
|
6
7
|
export { AnalyzeOskRewritePua } from './osk-rewrite-pua/index.js';
|
|
7
8
|
export { AnalyzerMessages } from './messages.js';
|
|
8
|
-
//# debugId=
|
|
9
|
+
//# debugId=4c9393bf-f417-5abb-8feb-4d080e0b6401
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
package/build/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"debug_id":"
|
|
1
|
+
{"debug_id":"4c9393bf-f417-5abb-8feb-4d080e0b6401","file":"index.js","mappings":";AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAiC,MAAM,8BAA8B,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC","names":[],"sourceRoot":"","sources":["../../src/index.ts"],"version":3}
|
package/build/src/messages.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* Compiler messages for `kmc analyze`
|
|
4
|
+
*/
|
|
1
5
|
export declare class AnalyzerMessages {
|
|
2
|
-
static
|
|
6
|
+
static readonly FATAL_UnexpectedException: number;
|
|
7
|
+
static readonly Fatal_UnexpectedException: (o: {
|
|
3
8
|
e: any;
|
|
4
9
|
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
5
|
-
static
|
|
6
|
-
static Info_ScanningFile: (o: {
|
|
10
|
+
static readonly INFO_ScanningFile: number;
|
|
11
|
+
static readonly Info_ScanningFile: (o: {
|
|
7
12
|
type: string;
|
|
8
13
|
name: string;
|
|
9
14
|
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
10
|
-
static INFO_ScanningFile: number;
|
|
11
15
|
}
|
|
12
16
|
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/messages.ts"],"names":[],"mappings":"AASA,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,yBAAyB,MAAM;QAAC,CAAC,EAAE,GAAG,CAAA;KAAC,
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/messages.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,QAAQ,CAAC,yBAAyB,SAAqB;IAC9D,MAAM,CAAC,QAAQ,CAAC,yBAAyB,MAAM;QAAC,CAAC,EAAE,GAAG,CAAA;KAAC,qDAOrD;IAEF,MAAM,CAAC,QAAQ,CAAC,iBAAiB,SAAoB;IACrD,MAAM,CAAC,QAAQ,CAAC,iBAAiB,MAAM;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,MAAM,CAAA;KAAC,qDAIjE;CACH"}
|
package/build/src/messages.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
-
import { CompilerErrorNamespace, CompilerErrorSeverity, CompilerMessageSpec as m } from "@keymanapp/common-types";
|
|
1
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5232c186-8f1d-5b98-80c2-069d92981b1a")}catch(e){}}();
|
|
2
|
+
import { CompilerErrorNamespace, CompilerErrorSeverity, CompilerMessageSpec as m, CompilerMessageDef as def, CompilerMessageSpecWithException } from "@keymanapp/common-types";
|
|
3
3
|
const Namespace = CompilerErrorNamespace.Analyzer;
|
|
4
4
|
const SevInfo = CompilerErrorSeverity.Info | Namespace;
|
|
5
5
|
// const SevHint = CompilerErrorSeverity.Hint | Namespace;
|
|
6
6
|
// const SevWarn = CompilerErrorSeverity.Warn | Namespace;
|
|
7
7
|
// const SevError = CompilerErrorSeverity.Error | Namespace;
|
|
8
8
|
const SevFatal = CompilerErrorSeverity.Fatal | Namespace;
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
* Compiler messages for `kmc analyze`
|
|
12
|
+
*/
|
|
9
13
|
export class AnalyzerMessages {
|
|
10
|
-
static Fatal_UnexpectedException = (o) => m(this.FATAL_UnexpectedException, null, o.e ?? 'unknown error');
|
|
11
14
|
static FATAL_UnexpectedException = SevFatal | 0x0001;
|
|
12
|
-
static
|
|
15
|
+
static Fatal_UnexpectedException = (o) => CompilerMessageSpecWithException(this.FATAL_UnexpectedException, null, o.e ?? 'unknown error', `Raised when an analysis components has an internal error. If you
|
|
16
|
+
experience this error, it should be reported to the Keyman team for
|
|
17
|
+
resolution via https://github.com/keymanapp/keyman/issues/new`);
|
|
13
18
|
static INFO_ScanningFile = SevInfo | 0x0002;
|
|
19
|
+
static Info_ScanningFile = (o) => m(this.INFO_ScanningFile, `Scanning ${def(o.type)} file ${def(o.name)}`, `Informative message reporting on the current file being scanned`);
|
|
14
20
|
}
|
|
15
21
|
;
|
|
16
|
-
//# debugId=
|
|
22
|
+
//# debugId=5232c186-8f1d-5b98-80c2-069d92981b1a
|
|
17
23
|
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"debug_id":"
|
|
1
|
+
{"debug_id":"5232c186-8f1d-5b98-80c2-069d92981b1a","file":"messages.js","mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,mBAAmB,IAAI,CAAC,EAAE,kBAAkB,IAAI,GAAG,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAE/K,MAAM,SAAS,GAAG,sBAAsB,CAAC,QAAQ,CAAC;AAClD,MAAM,OAAO,GAAG,qBAAqB,CAAC,IAAI,GAAG,SAAS,CAAC;AACvD,0DAA0D;AAC1D,0DAA0D;AAC1D,4DAA4D;AAC5D,MAAM,QAAQ,GAAG,qBAAqB,CAAC,KAAK,GAAG,SAAS,CAAC;AAEzD;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAC3B,MAAM,CAAU,yBAAyB,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC9D,MAAM,CAAU,yBAAyB,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,gCAAgC,CAC1F,IAAI,CAAC,yBAAyB,EAC9B,IAAI,EACJ,CAAC,CAAC,CAAC,IAAI,eAAe,EACtB;;kEAE8D,CAC/D,CAAC;IAEF,MAAM,CAAU,iBAAiB,GAAG,OAAO,GAAG,MAAM,CAAC;IACrD,MAAM,CAAU,iBAAiB,GAAG,CAAC,CAA8B,EAAE,EAAE,CAAC,CAAC,CACvE,IAAI,CAAC,iBAAiB,EACtB,YAAY,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAC7C,iEAAiE,CAClE,CAAC;;AACH,CAAC","names":[],"sourceRoot":"","sources":["../../src/messages.ts"],"version":3}
|
|
@@ -1,15 +1,52 @@
|
|
|
1
1
|
import { CompilerCallbacks } from "@keymanapp/common-types";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
* Options for character analysis
|
|
5
|
+
*/
|
|
2
6
|
export interface AnalyzeOskCharacterUseOptions {
|
|
7
|
+
/**
|
|
8
|
+
* First character to use in PUA for remapping with &displayMap, defaults to
|
|
9
|
+
* U+F100
|
|
10
|
+
*/
|
|
3
11
|
puaBase?: number;
|
|
12
|
+
/**
|
|
13
|
+
* If true, strips U+25CC from the key cap before further analysis
|
|
14
|
+
*/
|
|
4
15
|
stripDottedCircle?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* If true, reports number of references to each character found in each
|
|
18
|
+
* source file
|
|
19
|
+
*/
|
|
5
20
|
includeCounts?: boolean;
|
|
6
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* @public
|
|
24
|
+
* Analyze the characters used in On Screen Keyboard files (.kvks,
|
|
25
|
+
* .keyman-touch-layout) for use with `&displayMap`.
|
|
26
|
+
*/
|
|
7
27
|
export declare class AnalyzeOskCharacterUse {
|
|
8
28
|
private callbacks;
|
|
9
29
|
private _strings;
|
|
10
30
|
private options;
|
|
11
31
|
constructor(callbacks: CompilerCallbacks, options?: AnalyzeOskCharacterUseOptions);
|
|
32
|
+
/**
|
|
33
|
+
* Clears analysis data collected from previous calls to
|
|
34
|
+
* {@link AnalyzeOskCharacterUse.analyze}
|
|
35
|
+
*/
|
|
12
36
|
clear(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Analyzes a single source file for Unicode character usage. Can parse .kmn,
|
|
39
|
+
* .kvks, .keyman-touch-layout file formats. Can be called multiple times to
|
|
40
|
+
* collect results from more than one file. Use
|
|
41
|
+
* {@link AnalyzeOskCharacterUse.getStrings} to retrieve results.
|
|
42
|
+
*
|
|
43
|
+
* Note: `analyze()` collects key cap data, so calling this for a .kmn file
|
|
44
|
+
* will retrieve the key caps from the .kvks and .keyman-touch-layout files
|
|
45
|
+
* that it references, rather than key cap data from the .kmn file itself.
|
|
46
|
+
*
|
|
47
|
+
* @param file - relative or absolute path to a Keyman source file
|
|
48
|
+
* @returns true if the file is successfully loaded and parsed
|
|
49
|
+
*/
|
|
13
50
|
analyze(file: string): Promise<boolean>;
|
|
14
51
|
private analyzeKmnKeyboard;
|
|
15
52
|
private addStrings;
|
|
@@ -17,11 +54,34 @@ export declare class AnalyzeOskCharacterUse {
|
|
|
17
54
|
private scanVisualKeyboard;
|
|
18
55
|
private scanTouchLayout;
|
|
19
56
|
private prepareResults;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the collected results from earlier calls to
|
|
59
|
+
* {@link AnalyzeOskCharacterUse.analyze}. This generates a mapping from a key
|
|
60
|
+
* cap (one or more characters) to a PUA code, for use with `&displayMap`.
|
|
61
|
+
*
|
|
62
|
+
* Three output formats are supported:
|
|
63
|
+
*
|
|
64
|
+
* - .txt: tab-separated string format, with three columns: PUA, Key Cap, and
|
|
65
|
+
* plain string. The PUA and Key Cap columns are formatted as Unicode Scalar
|
|
66
|
+
* Values, e.g. U+0061, and the plain string is the original key cap string.
|
|
67
|
+
*
|
|
68
|
+
* - .md: formatted for documentation purposes. Generates a Markdown table
|
|
69
|
+
* (GFM) with PUA, Key Cap, and plain string. The PUA and Key Cap columns
|
|
70
|
+
* are formatted as Unicode Scalar Values, e.g. U+0061, and the plain string
|
|
71
|
+
* is the original key cap string.
|
|
72
|
+
*
|
|
73
|
+
* - .json: returns the final aggregated data as an array of strings, which
|
|
74
|
+
* can be joined to form a JSON blob of an object with a single member,
|
|
75
|
+
* `map`, which is an array of {@link Osk.StringResult} objects.
|
|
76
|
+
*
|
|
77
|
+
* @param format - file format to return - can be '.txt', '.md', or '.json'
|
|
78
|
+
* @returns an array of strings, formatted according to the `format`
|
|
79
|
+
* parameter.
|
|
80
|
+
*/
|
|
20
81
|
getStrings(format?: '.txt' | '.md' | '.json'): string[];
|
|
21
82
|
private static getStringsAsText;
|
|
22
83
|
private static getStringsAsMarkdown;
|
|
23
84
|
private static getStringsAsJson;
|
|
24
|
-
private static escapeMarkdownChar;
|
|
25
85
|
private static stringToUnicodeSequence;
|
|
26
86
|
}
|
|
27
87
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/osk-character-use/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/osk-character-use/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiF,MAAM,yBAAyB,CAAC;AAS3I;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAQD;;;;GAIG;AACH,qBAAa,sBAAsB;IAIrB,OAAO,CAAC,SAAS;IAH7B,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,OAAO,CAAgC;gBAE3B,SAAS,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,6BAA6B;IAIzF;;;OAGG;IACI,KAAK;IAQZ;;;;;;;;;;;;OAYG;IACU,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;YAwCtC,kBAAkB;IAuBhC,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,kBAAkB;IAyB1B,OAAO,CAAC,eAAe;IAiDvB,OAAO,CAAC,cAAc;IAetB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACI,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,GAAC,KAAK,GAAC,OAAO,GAAG,MAAM,EAAE;IAc1D,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAU/B,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAYnC,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAM/B,OAAO,CAAC,MAAM,CAAC,uBAAuB;CAUvC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
1
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="70134771-c873-591e-8319-0916e19ac20d")}catch(e){}}();
|
|
2
2
|
import { KeymanFileTypes, KvksFileReader, TouchLayoutFileReader } from "@keymanapp/common-types";
|
|
3
3
|
import { CompilerMessages } from '@keymanapp/kmc-kmn';
|
|
4
|
+
import { escapeMarkdownChar } from '@keymanapp/developer-utils';
|
|
4
5
|
import { getOskFromKmnFile } from "../util/get-osk-from-kmn-file.js";
|
|
5
6
|
import { AnalyzerMessages } from "../messages.js";
|
|
6
7
|
const defaultOptions = {
|
|
@@ -8,6 +9,11 @@ const defaultOptions = {
|
|
|
8
9
|
stripDottedCircle: false,
|
|
9
10
|
includeCounts: false,
|
|
10
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
* Analyze the characters used in On Screen Keyboard files (.kvks,
|
|
15
|
+
* .keyman-touch-layout) for use with `&displayMap`.
|
|
16
|
+
*/
|
|
11
17
|
export class AnalyzeOskCharacterUse {
|
|
12
18
|
callbacks;
|
|
13
19
|
_strings = {};
|
|
@@ -16,12 +22,29 @@ export class AnalyzeOskCharacterUse {
|
|
|
16
22
|
this.callbacks = callbacks;
|
|
17
23
|
this.options = { ...defaultOptions, ...options };
|
|
18
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Clears analysis data collected from previous calls to
|
|
27
|
+
* {@link AnalyzeOskCharacterUse.analyze}
|
|
28
|
+
*/
|
|
19
29
|
clear() {
|
|
20
30
|
this._strings = {};
|
|
21
31
|
}
|
|
22
32
|
//
|
|
23
33
|
// Analyze a single file
|
|
24
34
|
//
|
|
35
|
+
/**
|
|
36
|
+
* Analyzes a single source file for Unicode character usage. Can parse .kmn,
|
|
37
|
+
* .kvks, .keyman-touch-layout file formats. Can be called multiple times to
|
|
38
|
+
* collect results from more than one file. Use
|
|
39
|
+
* {@link AnalyzeOskCharacterUse.getStrings} to retrieve results.
|
|
40
|
+
*
|
|
41
|
+
* Note: `analyze()` collects key cap data, so calling this for a .kmn file
|
|
42
|
+
* will retrieve the key caps from the .kvks and .keyman-touch-layout files
|
|
43
|
+
* that it references, rather than key cap data from the .kmn file itself.
|
|
44
|
+
*
|
|
45
|
+
* @param file - relative or absolute path to a Keyman source file
|
|
46
|
+
* @returns true if the file is successfully loaded and parsed
|
|
47
|
+
*/
|
|
25
48
|
async analyze(file) {
|
|
26
49
|
switch (KeymanFileTypes.sourceTypeFromFilename(file)) {
|
|
27
50
|
case ".kvks" /* KeymanFileTypes.Source.VisualKeyboard */: {
|
|
@@ -184,6 +207,30 @@ export class AnalyzeOskCharacterUse {
|
|
|
184
207
|
}
|
|
185
208
|
return result;
|
|
186
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Returns the collected results from earlier calls to
|
|
212
|
+
* {@link AnalyzeOskCharacterUse.analyze}. This generates a mapping from a key
|
|
213
|
+
* cap (one or more characters) to a PUA code, for use with `&displayMap`.
|
|
214
|
+
*
|
|
215
|
+
* Three output formats are supported:
|
|
216
|
+
*
|
|
217
|
+
* - .txt: tab-separated string format, with three columns: PUA, Key Cap, and
|
|
218
|
+
* plain string. The PUA and Key Cap columns are formatted as Unicode Scalar
|
|
219
|
+
* Values, e.g. U+0061, and the plain string is the original key cap string.
|
|
220
|
+
*
|
|
221
|
+
* - .md: formatted for documentation purposes. Generates a Markdown table
|
|
222
|
+
* (GFM) with PUA, Key Cap, and plain string. The PUA and Key Cap columns
|
|
223
|
+
* are formatted as Unicode Scalar Values, e.g. U+0061, and the plain string
|
|
224
|
+
* is the original key cap string.
|
|
225
|
+
*
|
|
226
|
+
* - .json: returns the final aggregated data as an array of strings, which
|
|
227
|
+
* can be joined to form a JSON blob of an object with a single member,
|
|
228
|
+
* `map`, which is an array of {@link Osk.StringResult} objects.
|
|
229
|
+
*
|
|
230
|
+
* @param format - file format to return - can be '.txt', '.md', or '.json'
|
|
231
|
+
* @returns an array of strings, formatted according to the `format`
|
|
232
|
+
* parameter.
|
|
233
|
+
*/
|
|
187
234
|
getStrings(format) {
|
|
188
235
|
const final = this.prepareResults(this._strings);
|
|
189
236
|
switch (format) {
|
|
@@ -212,7 +259,7 @@ export class AnalyzeOskCharacterUse {
|
|
|
212
259
|
lines.push('-------|-------------|---------');
|
|
213
260
|
for (let s of strings) {
|
|
214
261
|
const ux = this.stringToUnicodeSequence(s.str);
|
|
215
|
-
lines.push('U+' + s.pua + ' | ' + ux + ' | ' +
|
|
262
|
+
lines.push('U+' + s.pua + ' | ' + ux + ' | ' + escapeMarkdownChar(s.str, true));
|
|
216
263
|
}
|
|
217
264
|
return lines;
|
|
218
265
|
}
|
|
@@ -221,19 +268,6 @@ export class AnalyzeOskCharacterUse {
|
|
|
221
268
|
let map = { "map": strings };
|
|
222
269
|
return JSON.stringify(map, null, 2).split('\n');
|
|
223
270
|
}
|
|
224
|
-
static escapeMarkdownChar(s) {
|
|
225
|
-
// note: could replace with a common lib but too much baggage to be worth it for now
|
|
226
|
-
// commonmark 2.4: all punct can be escaped
|
|
227
|
-
// const punct = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~';
|
|
228
|
-
s = s.replace(/[!"#$%&'()*+,-./:;<=>?@\[\\\]^_`{|}~]/g, '\\$0');
|
|
229
|
-
// replace whitepsace
|
|
230
|
-
s = s.replace(/[\n]/g, '\\n');
|
|
231
|
-
s = s.replace(/[\r]/g, '\\r');
|
|
232
|
-
s = s.replace(/[\t]/g, '\\t');
|
|
233
|
-
s = s.replace(/ /g, ' ');
|
|
234
|
-
s = s.replace(/\u00a0/g, ' ');
|
|
235
|
-
return s;
|
|
236
|
-
}
|
|
237
271
|
static stringToUnicodeSequence(s, addUPlusPrefix = true) {
|
|
238
272
|
let result = [];
|
|
239
273
|
for (let ch of s) {
|
|
@@ -245,5 +279,5 @@ export class AnalyzeOskCharacterUse {
|
|
|
245
279
|
return result.join(' ');
|
|
246
280
|
}
|
|
247
281
|
}
|
|
248
|
-
//# debugId=
|
|
282
|
+
//# debugId=70134771-c873-591e-8319-0916e19ac20d
|
|
249
283
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"debug_id":"
|
|
1
|
+
{"debug_id":"70134771-c873-591e-8319-0916e19ac20d","file":"index.js","mappings":";AAAA,OAAO,EAAqB,eAAe,EAAY,cAAc,EAAe,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3I,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD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,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;YACrD,IAAG,CAAC,CAAC,MAAM,GAAG,CAAC;gBAAE,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClD,MAAM,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;SAC/C;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CAEF","names":[],"sourceRoot":"","sources":["../../../src/osk-character-use/index.ts"],"version":3}
|
|
@@ -1,10 +1,36 @@
|
|
|
1
|
-
import { CompilerCallbacks
|
|
1
|
+
import { CompilerCallbacks } from "@keymanapp/common-types";
|
|
2
|
+
import { Osk } from '@keymanapp/developer-utils';
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* Rewrite On Screen Keyboard files (.kvks, .keyman-touch-layout) with PUA
|
|
6
|
+
* codepoints, based on analysis provided by {@link AnalyzeOskCharacterUse}
|
|
7
|
+
* class.
|
|
8
|
+
*/
|
|
2
9
|
export declare class AnalyzeOskRewritePua {
|
|
3
10
|
private callbacks;
|
|
4
11
|
private _data;
|
|
5
12
|
constructor(callbacks: CompilerCallbacks);
|
|
13
|
+
/**
|
|
14
|
+
* Clears data collected from previous calls to
|
|
15
|
+
* {@link AnalyzeOskRewritePua.analyze}
|
|
16
|
+
*/
|
|
6
17
|
clear(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Analyze a keyboard file or files, and provide a remapped output. Accepts a
|
|
20
|
+
* .kmn, .kvks, .keyman-touch-layout file formats. For .kmn, will rewrite
|
|
21
|
+
* associated On Screen Keyboard file formats. Can be called multiple times to
|
|
22
|
+
* rewrite multiple files. Use the {@link AnalyzeOskRewritePua.data} property
|
|
23
|
+
* to retrieve the output file content for writing. This does not modify the
|
|
24
|
+
* source file.
|
|
25
|
+
* @param file - relative or absolute path to a Keyman source file
|
|
26
|
+
* @param mapping - OSK keycap map provided by {@link AnalyzeOskCharacterUse}
|
|
27
|
+
* @returns true if the file is successfully loaded and rewritten
|
|
28
|
+
*/
|
|
7
29
|
analyze(file: string, mapping: Osk.StringResult[]): Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the file data for OSK files rewritten with PUA characters, for use
|
|
32
|
+
* with `&displayMap`.
|
|
33
|
+
*/
|
|
8
34
|
get data(): {
|
|
9
35
|
[index: string]: Uint8Array;
|
|
10
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/osk-rewrite-pua/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/osk-rewrite-pua/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA2G,MAAM,yBAAyB,CAAC;AACrK,OAAO,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAKjD;;;;;GAKG;AACH,qBAAa,oBAAoB;IAGnB,OAAO,CAAC,SAAS;IAF7B,OAAO,CAAC,KAAK,CAAoC;gBAE7B,SAAS,EAAE,iBAAiB;IAGhD;;;OAGG;IACI,KAAK;IAQZ;;;;;;;;;;OAUG;IACU,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAgCjF;;;OAGG;IACH,IAAW,IAAI;;MAEd;YAEa,kBAAkB;IAqBhC,OAAO,CAAC,qBAAqB;IA6B7B,OAAO,CAAC,kBAAkB;CAe3B"}
|
|
@@ -1,20 +1,42 @@
|
|
|
1
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
-
import { KeymanFileTypes, KvksFileReader, KvksFileWriter,
|
|
1
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7d1eb705-f9fa-5bdd-b1a8-1d8c6b425ca0")}catch(e){}}();
|
|
2
|
+
import { KeymanFileTypes, KvksFileReader, KvksFileWriter, TouchLayoutFileReader, TouchLayoutFileWriter } from "@keymanapp/common-types";
|
|
3
|
+
import { Osk } from '@keymanapp/developer-utils';
|
|
3
4
|
import { CompilerMessages } from '@keymanapp/kmc-kmn';
|
|
4
5
|
import { getOskFromKmnFile } from "../util/get-osk-from-kmn-file.js";
|
|
5
6
|
import { AnalyzerMessages } from "../messages.js";
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
* Rewrite On Screen Keyboard files (.kvks, .keyman-touch-layout) with PUA
|
|
10
|
+
* codepoints, based on analysis provided by {@link AnalyzeOskCharacterUse}
|
|
11
|
+
* class.
|
|
12
|
+
*/
|
|
6
13
|
export class AnalyzeOskRewritePua {
|
|
7
14
|
callbacks;
|
|
8
15
|
_data = {};
|
|
9
16
|
constructor(callbacks) {
|
|
10
17
|
this.callbacks = callbacks;
|
|
11
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Clears data collected from previous calls to
|
|
21
|
+
* {@link AnalyzeOskRewritePua.analyze}
|
|
22
|
+
*/
|
|
12
23
|
clear() {
|
|
13
24
|
this._data = {};
|
|
14
25
|
}
|
|
15
26
|
//
|
|
16
27
|
// Analyze a single file
|
|
17
28
|
//
|
|
29
|
+
/**
|
|
30
|
+
* Analyze a keyboard file or files, and provide a remapped output. Accepts a
|
|
31
|
+
* .kmn, .kvks, .keyman-touch-layout file formats. For .kmn, will rewrite
|
|
32
|
+
* associated On Screen Keyboard file formats. Can be called multiple times to
|
|
33
|
+
* rewrite multiple files. Use the {@link AnalyzeOskRewritePua.data} property
|
|
34
|
+
* to retrieve the output file content for writing. This does not modify the
|
|
35
|
+
* source file.
|
|
36
|
+
* @param file - relative or absolute path to a Keyman source file
|
|
37
|
+
* @param mapping - OSK keycap map provided by {@link AnalyzeOskCharacterUse}
|
|
38
|
+
* @returns true if the file is successfully loaded and rewritten
|
|
39
|
+
*/
|
|
18
40
|
async analyze(file, mapping) {
|
|
19
41
|
let map = Osk.parseMapping(mapping);
|
|
20
42
|
switch (KeymanFileTypes.sourceTypeFromFilename(file)) {
|
|
@@ -45,6 +67,10 @@ export class AnalyzeOskRewritePua {
|
|
|
45
67
|
}
|
|
46
68
|
return true;
|
|
47
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns the file data for OSK files rewritten with PUA characters, for use
|
|
72
|
+
* with `&displayMap`.
|
|
73
|
+
*/
|
|
48
74
|
get data() {
|
|
49
75
|
return this._data;
|
|
50
76
|
}
|
|
@@ -102,5 +128,5 @@ export class AnalyzeOskRewritePua {
|
|
|
102
128
|
return data;
|
|
103
129
|
}
|
|
104
130
|
}
|
|
105
|
-
//# debugId=
|
|
131
|
+
//# debugId=7d1eb705-f9fa-5bdd-b1a8-1d8c6b425ca0
|
|
106
132
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"debug_id":"
|
|
1
|
+
{"debug_id":"7d1eb705-f9fa-5bdd-b1a8-1d8c6b425ca0","file":"index.js","mappings":";AAAA,OAAO,EAAqB,eAAe,EAAY,cAAc,EAAE,cAAc,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrK,OAAO,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,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AI,qBAAqB,CAAC,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;QAC5D,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;CACF","names":[],"sourceRoot":"","sources":["../../../src/osk-rewrite-pua/index.ts"],"version":3}
|
package/package.json
CHANGED
|
@@ -23,11 +23,12 @@
|
|
|
23
23
|
"build/src/"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@keymanapp/common-types": "18.0.
|
|
27
|
-
"@keymanapp/
|
|
26
|
+
"@keymanapp/common-types": "18.0.9-alpha",
|
|
27
|
+
"@keymanapp/developer-utils": "18.0.9-alpha",
|
|
28
|
+
"@keymanapp/kmc-kmn": "18.0.9-alpha"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@keymanapp/resources-gosh": "18.0.
|
|
31
|
+
"@keymanapp/resources-gosh": "18.0.9-alpha",
|
|
31
32
|
"@types/chai": "^4.1.7",
|
|
32
33
|
"@types/mocha": "^5.2.7",
|
|
33
34
|
"@types/node": "^20.4.1",
|
|
@@ -42,5 +43,5 @@
|
|
|
42
43
|
"type": "git",
|
|
43
44
|
"url": "git+https://github.com/keymanapp/keyman.git"
|
|
44
45
|
},
|
|
45
|
-
"version": "18.0.
|
|
46
|
+
"version": "18.0.9-alpha"
|
|
46
47
|
}
|