Commit graph

2024 commits

Author SHA1 Message Date
Marc Durdin
4c8d173eab chore(developer): enable source maps for bundle 2023-07-13 07:58:16 +07:00
Marc Durdin
5cc373274c chore(developer): remove --dist from sentry-cli sourcemaps inject 2023-07-13 07:44:52 +07:00
Marc Durdin
31ee7bff63 feat(developer): use sentry inject for sourcemap resolution 2023-07-13 06:07:44 +07:00
Marc Durdin
111de31fd6 chore(developer): fix tests and linting 2023-07-12 12:08:48 +07:00
Marc Durdin
fa3980f598 feat(developer): deploy kmc as ES module
Deploy kmc as an ES module, forced now by top-level await that we use in
the sentry load.

Moved NodeCompilerCallbacks to same util folder as schemas are found in,
to avoid rewriting schema loading with imports in this PR. It belongs
better there than messages/ anyway.

Distributed files are now .mjs. Removed --enable-source-maps from
launchers as logging will be managed with sentry anyway.
2023-07-12 10:20:35 +07:00
Marc Durdin
8082f5f3bd chore(developer): workaround TS2367 2023-07-11 17:44:56 +07:00
Marc Durdin
b435471b24 feat(developer): add sentry reporting for kmc
Fixes #9113.

Adds sentry reporting, plus helper functions, for kmc. Includes the
now-standard `-sentry-client-test-exception` command line parameter,
with `kmcmplib` and `event` sub-options available.

Uploads kmc* sourcemaps to sentry on a release build.

On Windows, honours the registry setting for error reporting. Also
includes a command line option `--[no-]error-reporting` (must be used
prior to initial command, e.g. `kmc --no-error-reporting build ...`).
2023-07-11 15:45:41 +07:00
Marc Durdin
d5aeecd7d3 chore(developer): suppress excessive messages in kmc
Fixes #9147.
2023-07-11 12:55:19 +07:00
Marc Durdin
53e2ae0ac2 fix(developer): touch layout font test should be lower case
Fixes #9110.

Also, `!=` has higher precedence than `??`.

This returns a boolean result:

```
(platform.font?.toLowerCase() ?? '') != FTouchLayoutFont
```

But `!=` has higher precedence than `??` so this returns the font name:

```
platform.font?.toLowerCase() ?? '' != FTouchLayoutFont
```
2023-07-11 12:34:11 +07:00
Marc Durdin
31083c2ed3 chore(developer): unit test for compilerWarningsAsErrors
Also adds inverse option -W, --no-compiler-warnings-as-errors
command line parameter.
2023-07-11 12:14:51 +07:00
Marc Durdin
804215145f chore(developer): handle compilerWarningsAsErrors option
Fixes #9100.

The `compilerWarningsAsErrors` option can be passed in as a command-line
option or in the project options. Command-line option, if present, takes
precedence over the project option. If neither is set, then the value is
`false`.

Handling of this is within kmc, rather than individual modules.
2023-07-11 10:16:41 +07:00
Marc Durdin
02a1c48d18 chore(developer): add --color switch to kmc
Fixes #9233.

Adds --color and --no-color switches to kmc command line, with default
being determined by console mode.

Also ensures color initialization happens just once in
NodeCompilerCallbacks and moves constants to top of file.
2023-07-11 06:25:21 +07:00
Marc Durdin
acb2e2e1ff chore(developer): split file and project build messages 2023-07-10 15:36:39 +07:00
Marc Durdin
de1c171f46 chore(developer): cleanup compiler messages in kmc
Fixes #8795.
Relates to #9090.

Cleans up and makes consistent compiler messages in kmc, and related
unit tests.

Adds support for colorized messages.

After installing chalk for ansi coloring in kmc, @types/node needed to
be brought in sync with the Typescript version, per the suggestion of
checking against `npm dist-tags @types/node`,found in a discussion at
https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/64262#discussioncomment-4905069

Additional tidying up includes:
* Deprecating a set of functions in compiler-interfaces, bringing them
  together under a new CompilerError class.
  Separating CompilerErrorSeverity and CompilerErrorMask enums.
* Making CompilerError.formatEvent (formerly compilerEventFormat) print
  messages in the same format as NodeCompilerCallbacks (sans coloring).
* Adding a wrapper class for CompilerCallbacks that manages the filename
  reporting, used currently exclusively by kmc itself.
2023-07-10 15:13:48 +07:00
Marc Durdin
7e8ba8bad3 chore(developer): fixup test parameters 2023-07-10 08:52:59 +07:00
Marc Durdin
5c0f0e87a8 chore: Merge branch 'feature-kmc-kmw' into chore/merge-master-into-feature-kmc-kmw-A17S16 2023-07-07 09:53:34 +07:00
Marc Durdin
306934eb62 fix(developer): kmc-package support for keyboard metadata
Fixes #9208.
Fixes #9209.
Fixes #9203.
Fixes #9198.

The changes here overlap in kmp-compiler.ts. Addresses several issues
with the package compiler:

* refactors the reading of the metadata from keyboards to make use of it
  when refreshing the keyboard metadata in kmp.json (#9208). This is the
  bulk of the changes.
* Fixes case on some fields in the kps file format (#9209)
* Removes code which emitted strings table to kmp.json, as these were
  only ever used for package installer executables (#9203)
* Cleans up code which emitted Start Menu items to make it match spec
  (#9198)
2023-07-06 13:49:04 +07:00
Marc Durdin
3773522e06 feat(developer): kmc-package support for writing kmp.inf
Fixes #9205.
2023-07-06 13:49:03 +07:00
Marc Durdin
2085c26ab0 fix(developer): trim fields when emitting kmp.json
Fixes #9207.
2023-07-06 13:49:03 +07:00
Marc Durdin
84c04d5cbd fix(developer): strip paths from readmeFile and graphicFile
Fixes #9204.
2023-07-06 13:49:02 +07:00
Marc Durdin
8f5ffcc99d chore(developer): fixup ldml test for kmw emit 2023-07-06 13:48:26 +07:00
Steven R. Loomis
1bea614fd5 chore(common): improve coverage, fix todos 🙀
- remove SectionCompiler.required as unused
- minor fixes to common setSplitter
- add edge case tests

for: #8069
2023-07-05 15:48:12 -05:00
Marc Durdin
0a9c95feb4 fix(developer): off-by-one index calculations in js output
Fixes #9185.
2023-07-05 10:08:18 +07:00
Marc Durdin
aa999180c0 fix(developer): kmc: cleanup handling of whitespace in import files
Fixes #9183.

* CSS: blank line required at EOF if not present, but only if the CSS
  file was not empty!
* Embedded HTML needs a blank line at EOF if not present
* `\r` is converted to `\\n` and `\n` is converted to ` `, to match
  kmcomp
2023-07-05 10:03:31 +07:00
Marc Durdin
2d31055f74 fix(developer): escape font name correctly in vk
Fixes #9182.
2023-07-05 09:54:25 +07:00
Marc Durdin
a2c54599a9 fix(developer): call statements were misreferenced in kmc
Fixes #9181.

Two issues:

* First use of a `call` statement had an incorrect index (misuse of
  `push` return value)
* The .call_js files were incorrectly prepended with the basename of the
  keyboard
2023-07-05 09:52:15 +07:00
Steven R. Loomis
2370f97cbe
Merge branch 'chore/developer-7377-refactor-kmn-epic-ldml' into fix/common-7377-multi-escape-reorder-epic-ldml 2023-07-04 15:20:09 -05:00
Steven R. Loomis
5588e3fc34
Merge branch 'fix/developer-8069-coverage-todo-epic-ldml' into chore/developer-7377-refactor-kmn-epic-ldml 2023-07-04 15:19:44 -05:00
Steven R. Loomis
b6992d378b fix(developer): improve coverage, add todos 🙀
- fix to the fix

for: #8069
2023-07-04 15:05:10 -05:00
Steven R. Loomis
8cd846f298 fix(common): support multichar escapes in element sets 🙀
- \u{22 0127} acts like \u{22}\u{0127}

for: #7377
2023-07-04 12:47:58 -05:00
Steven R. Loomis
a5af734160 chore(developer): refactor so KmnCompiler only created once within kmc 🙀
- remove async SectionCompiler.init()  and all callers
- the usetparser lives on the DependencySections, initialized by kmc-ldml (and by the test harnesses)

for: #7377
2023-07-04 11:39:57 -05:00
Steven R. Loomis
69c9ddc99e fix(developer): improve coverage, add todos 🙀
- skip coverage on some actual internal errors
- add todos where coverage is needed

for: #8069
2023-07-04 11:10:05 -05:00
Steven R. Loomis
1126cfb9a2 chore(developer): robust reorder tests 🙀
For: #7377
2023-07-04 10:50:03 -05:00
Steven R. Loomis
52b8dfb205 feat(common): preflighting on uset 🙀
- update docs on UnicodeSet
- uset parser: fix/clarify that the wasm interface takes a bufferSize, but the ts interface takes a range count. This was muddled before.

For: #7377
2023-07-04 10:26:50 -05:00
Marc Durdin
8ebc849345 fix(developer): kmc/kmw was not stripping codes correctly
Fixes #9156.

The compiler was only skipping the first codepoint in a CODE sequence.
2023-07-04 14:48:36 +07:00
Marc Durdin
4d64cb2d38 fix(developer): touch layout was not converting all special keycaps
Fixes #9161.

kmw-compiler was converting only the first key cap with `*special*`
caption, rather than all key caps.
2023-07-04 14:44:42 +07:00
Marc Durdin
d2acfdec5c fix(developer): improve kmcmplib/kmw compiler performance
Fixes #9154.

Improves performance in both kmcmplib and in kmc-kmn/kmw-compiler. After
these changes are applied, vietnamese_telex keyboard builds in around 6
seconds on my machine (down from over 2 minutes). This is certainly only
the surface of performance improvements we could make.

Addresses excessive memory reallocations in kmcmplib, by reallocating
store and key arrays in large chunks of 100 items rather than
reallocating on each new item added. This resulted in a 250x speed-up on
functions such as `AddStore` in WASM build.

Some careful modulus arithmetic was needed for resizing the key array,
which can be grown in larger increments.

Resolved excessive zeroing out of destination buffer in u16ncpy, which
was being called with an 8kb destination buffer on every line of the
file.

In the kmw side, vast majority of the performance cost was in copying of
buffers while loading a .kmx into memory, rather than creating views
into the memory. Essentially replaced this pattern:

```
return this.rString.fromBuffer(source.slice(offset));
```

with:

```
const data = new Uint8Array(source.buffer, source.byteOffset + offset);
return this.rString.fromBuffer(data);
```
2023-07-04 14:36:25 +07:00
Marc Durdin
3a54d9b7f4 fix(developer): kmc-kmn/kmw should strip \r from inline html
Fixes #9157.

Matching kmcomp behaviour once more.
2023-07-04 14:31:01 +07:00
Steven R. Loomis
0f0c1e5e61 feat(common): preflighting on uset 🙀
- allow uset to preflight (calculate # of ranges)

For: #7377
2023-07-03 18:48:48 -05:00
Steven R. Loomis
ebcccbe0ef feat(core): rearrange elem flags 🙀
- per review comments, make the elem flags clearer

For: #7377
2023-07-03 18:20:59 -05:00
Marc Durdin
3d86e608f4 fix(developer): strip .kvk extension
Fixes #9152.
2023-07-03 12:47:22 +07:00
Marc Durdin
92c8c6497e fix(developer): improve warnings around keyboard version matching
Fixes #9145.

* `WARN_KeyboardVersionsDoNotMatch` is now only raised when
  `FollowKeyboardVersion` is set.
* `WARN_KeyboardVersionsDoNotMatchPackageVersion` has been removed,
  because it did not really make sense; if 'FollowKeyboardVersion' is
  set, it could not be raised, and otherwise, the author may wish to
  have separate keyboard + package versions anyway.
* Note that the 0x0013 compiler message allocation for
  `WARN_KeyboardVersionsDoNotMatchPackageVersion` has been left alone;
  as this was only used in pre-release, we can probably re-task it in
  the future.
2023-07-03 09:40:09 +07:00
Marc Durdin
9a1b87824a fix(developer): split keyboard and model language metadata tests
Fixes #9146.

For model packages, 304016 (ERROR_ModelMustHaveAtLeastOneLanguage)
remains as an error (this is a new error for kmc, kmcomp did not
validate model metadata). For keyboard packages, a new warning is
introduced to match the existing kmcomp behaviour, 20401B
(WARN_KeyboardShouldHaveAtLeastOneLanguage).
2023-07-03 09:31:29 +07:00
Marc Durdin
be0b2ae583 fix(developer): allow kmcmplib memory usage to grow
Fixes #9112.

Note that this does not address any performance concerns which are a
much bigger issue; it just avoids the crash.
2023-07-03 09:27:53 +07:00
Marc Durdin
7aede78707 fix(developer): compiler needs to support loading .kvk files
Fixes #9150.

Legacy .kmn keyboards can refer to a binary .kvk file. kmc needs to be
able to load these as well.

Note: there was a short period of time in which .kvk files were either
source or binary format. We moved to .kvk always being binary, and .kvks
always being source (xml), and so IMO we don't need to include support
for mismatched file formats.
2023-07-03 09:25:10 +07:00
Marc Durdin
33affc660f fix(common): legacy .kpj schema
Fixes #9140.
Fixes #9148.

Keyman Developer 9.0 .kpj files included a lot of additional state
metadata. We need a schema which validates these files, as they are
otherwise valid to load (we'll never save them any more). Rather than
add all the extra metadata to what is otherwise a fairly clean schema,
we'll provide a legacy .schema.json.

In the future, we may be able to merge these schemas, as we move towards
the .kpj 2.0 format which doesn't list files. Ideally, all three formats
(Keyman Developer 9.0 schema, call it legacy, 1.0 schema for Keyman
Developer 10.0+ which has Options and Files listed, 2.0 schema for
capturing just project settings for a folder) will be supported by a
single schema file.
2023-07-03 09:06:03 +07:00
Steven R. Loomis
88650e2085 feat(developer): uset in element string 🙀
- fix uset builder and other missing uset parts
- basic.xml passes
- update to constants

Fixes: #7377
2023-06-30 17:27:04 -05:00
Steven R. Loomis
5d5b61cd0a feat(developer): uset in element string 🙀
- update element string constructors to support UnicodeString and the segmented array from ElementParser
- update compiler machinery to pass USetParser in the DependencySections
- test cases

#7377
2023-06-30 15:56:45 -05:00
Marc Durdin
f85478ac6f fix(developer): kmc needs to support .js-only packages
Fixes #9111.

We have existing packages which have only .js in them, for touch-only
keyboards (mostly legacy but still...), so we need to support the freaky
Javascript regex search which we did in the past for extracting
metadata. While this is not necessarily going to work with hand-crafted
Javascript keyboards, it should work with all kmc- and kmcomp-generated
keyboards, so it will suffice to support these legacy packages.

In the future, we will be giving a hint when a package includes a .js
but not a .kmx, gradually upgrading this to a warning and finally an
error as we attempt to phase out .js-based keyboards in preference for
.kmx keyboards.
2023-06-30 08:45:03 +07:00
Marc Durdin
f2a7efa2ec fix(developer): kmcmplib was clobbering previous output
Running kmc on a set of keyboards would sporadically fail after some
time. It turns out this was related to memory allocation, specifically,
resizing the WASM module's memory buffer caused `TypedArray` views into
the memory to be reset!

By default, when a `Uint8Array` is created from an `ArrayBuffer` (e.g.
`Module.HEAP8.buffer`), it is a dynamic view into that buffer. This
module buffer can be dynamically reallocated at any time, which can
happen when allocating memory in WASM code (so the change will look
_really_ weird in a stack trace). Thus, to ensure we don't trip over
ourselves, we need to copy the buffer. Fortunately, creating a
`Uint8Array` from a `Uint8Array` copies the data, and is pretty quick.
2023-06-30 08:38:57 +07:00