Commit graph

2740 commits

Author SHA1 Message Date
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
Marc Durdin
562ced5213 fix(developer): GetDelimitedString was using wrong strchr
Picked this up while running `-fsanitize=address` for trying to track
down another bug.

This fixes a buffer overrun (normally invisible) in kmcmplib, where
`xstrchr` was being called, which takes a string as its second
parameter, but being passed a single character. This was incorrect
behaviour for two reasons:

1. Passing a single character doesn't have null termination (big bug!)
2. We were not wanting xstring semantics on the token being parsed here

Replaced with `u16chr`, which does do what we want. Note the
casting because `u16chr` only has a `const` version of its input/output
at present.

Removed `xstrchr` because it is not used anywhere else in kmcmplib.
2023-06-30 08:24:11 +07:00
Marc Durdin
3b735cdc80 fix(developer): ensure delete uses array semantics where appropriate
The kmcmplib compiler source used `delete` instead of `delete[]` in a
number of locations where the corresponding allocation was an array.

This doesn't appear to matter on arrays of primitives on most platforms
that we are targeting, but it _is_ undefined behaviour so we should
correct it.

https://stackoverflow.com/a/2425749/1836776
2023-06-30 08:14:38 +07:00
Marc Durdin
09a204116d fix(developer): ensure errors cancel the build in kmc
Fixes #9108.
2023-06-28 06:18:34 +07:00
Marc Durdin
a031367181 fix(developer): rewrite version object for followKeyboardVersion
Fixes #9105.
2023-06-28 06:16:04 +07:00
Marc Durdin
87c70a286c fix(developer): key id and text are optional
Fixes #9104.
Fixes #9106.
2023-06-28 06:15:02 +07:00
Marc Durdin
1b6769195e fix(developer): resetopt and saveopt used uninitialized return variable
Fixes #9103.
2023-06-28 06:13:57 +07:00
Marc Durdin
d44e7819ea fix(developer): TypeError: String.prototype.replaceAll called with a non-global RegExp argument
Fixes #9102.
2023-06-28 06:13:09 +07:00
Marc Durdin
ed9975ee81 fix(developer): handle missing font spec in touch layout file
Fixes #9101.
2023-06-28 06:11:37 +07:00
Marc Durdin
afa081a170 fix(developer): content files can have mixed case in packages
Fixes #9098.
2023-06-28 06:09:04 +07:00
Marc Durdin
0f42e3c92c fix(developer): key type checks were invalid
Fixes #9097.
2023-06-28 06:07:32 +07:00
Steven R. Loomis
fbf6005bc4
Merge pull request #9084 from keymanapp/feat/developer-9050-utf32-epic-ldml
feat(developer,common,core): ldml UTF-32 literals in binary 🙀
2023-06-26 20:33:27 -05:00
Marc Durdin
d914b6918d chore: Merge branch 'feature-kmc-kmw' into chore/merge-master-into-feature-kmc-kmw-a17s16-start 2023-06-26 14:33:20 +07:00
Marc Durdin
69f679693a
Merge pull request #9088 from keymanapp/chore/developer/kmc-kmn-kmw-compiler-cleanup
chore(developer): cleanup for kmw-compiler.ts 🗜
2023-06-26 17:28:15 +10:00
Marc Durdin
5182b49b0f
Merge pull request #9087 from keymanapp/chore/developer/kmc-kmn-kmwcompiler-handle-layout-file-errors
chore(developer): handle layout file errors in kmw-compiler
2023-06-26 17:28:07 +10:00
Marc Durdin
fbfd8c5b2a
Merge pull request #9086 from keymanapp/chore/developer/kmc-kmw-cleanup-javascript-strings
chore(developer): cleanup javascript-strings.ts 🗜
2023-06-26 17:28:00 +10:00
Marc Durdin
313ad95ecd
Merge pull request #9076 from keymanapp/fix/developer/kmc-kmw-readonly-groups
fix(developer): support readonly groups in kmc-kmn/kmw-compiler 🗜
2023-06-26 17:27:51 +10:00
Marc Durdin
c3bb426ff0
Merge pull request #9075 from keymanapp/fix/developer/kmc-kmw-options-stores
fix(developer): support option stores in kmc-kmn/kmw 🗜
2023-06-26 17:27:41 +10:00
Marc Durdin
90f5ab6884 chore(developer): fix tests for layout validity
The tests for layout validity in #9087 were incomplete; first, they
didn't fail the build if a key had invalid identifier, and second, there
were some constants missing from the KeyIdType test (imperfect
translation from the Delphi code in this case).
2023-06-26 11:48:03 +07:00
Joshua Horton
2ac8a4503b
Merge branch 'master' into feature-esmodule-web-engine 2023-06-26 09:09:43 +07:00
Marc Durdin
b5a1e13d50 chore(developer): add store.line metadata and cleanup 2023-06-26 08:59:56 +07:00
Marc Durdin
7dbf97fa00 chore(developer): implement HasSupplementaryPlaneChars and FCallFunctions in kmw-compiler 2023-06-26 08:42:15 +07:00
Marc Durdin
d9b37d85d3 chore(developer): rename write-compiled-keyboard.ts to kmw-compiler.ts 2023-06-26 08:28:54 +07:00
Marc Durdin
7ccef2e5c6 chore(developer): handle layout file errors in kmw-compiler
Also removes leftover commented code, and changes an enum to string enum
type in order to get constant names for free for an error message.

Error_TouchLayoutIdentifierRequires15 was split into its own error
message because it was overloaded with CERR_TouchLayoutInvalidIdentifier
previously but had a different message.
2023-06-26 07:01:24 +07:00
Marc Durdin
d5331537cd chore(developer): cleanup javascript-strings.ts
Removes old commented code and fixes surrogate pair check.
2023-06-26 06:25:45 +07:00
dependabot[bot]
7d08b08fb2
chore(deps): bump semver from 7.3.8 to 7.5.2
Bumps [semver](https://github.com/npm/node-semver) from 7.3.8 to 7.5.2.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v7.3.8...v7.5.2)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-24 12:37:06 +00:00
Steven R. Loomis
5cd3447bfd feat(developer): last fix for UTF-32 single chars 🙀
- elem

Fixes: #9050
2023-06-23 17:30:48 -05:00
Steven R. Loomis
79526e452d feat(developer): test fix for UTF-32 single chars 🙀
- last but not least, basic.txt

For: #9050
2023-06-23 17:10:51 -05:00
Steven R. Loomis
de90644d7a feat(core,common,developer): support UTF-32 single chars 🙀
- C++ side now
- updated tests
- refactored escaping code and squashed bugs
- still todo: basic.xml

For: #9050
2023-06-23 16:55:05 -05:00
Steven R. Loomis
8304de4ad9 feat(common): support UTF-32 single chars 🙀
- common and developer side
- needs C++ update and basic.xml

For: #9050
2023-06-23 14:11:26 -05:00
Marc Durdin
d6721f68ba chore: Merge branch 'feature-kmc-kmw' into chore/merge-master-into-feature-kmc-kmw 2023-06-23 15:44:06 +07:00
Marc Durdin
da51f545e1 fix(developer): support readonly groups in kmc-kmn/kmw-compiler
Adds support for readonly groups and corresponding unit test. Again
required more metadata from kmcmplib; this metadata is now fairly
straightforward to patch in without side-effects, which is encouraging.
2023-06-23 15:26:21 +07:00
Marc Durdin
dee046e647 chore(developer): tweak comments 2023-06-23 14:29:14 +07:00
Marc Durdin
8432b06547 fix(developer): support option stores in kmc-kmn/kmw
Adds support for option stores to kmc-kmn/kmw-compiler. This required
adding the relevant store metadata into the output from kmcmplib, and
so I also tidied up the corresponding WASM interfaces slightly more in
the process.

Added unit test for the options store.

While testing this, ran into a second bug with the way I ported a
constant from Delphi to Typescript in constants.ts, so fixed that and
added a corresponding unit test. Small steps, but good ones.
2023-06-23 14:21:30 +07:00
Marc Durdin
c67c21d489
Merge branch 'feature-kmc-kmw' into chore/developer/cleanup-wasm-data-passing 2023-06-23 13:25:41 +10:00