Commit graph

1977 commits

Author SHA1 Message Date
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
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
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
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
Marc Durdin
3730f2db53
Merge pull request #9058 from keymanapp/chore/developer/kmw-support-embed-files
chore(developer): support embedded files in kmw compiler 🗜
2023-06-23 13:25:23 +10:00
Marc Durdin
fd640288fb
Merge pull request #9057 from keymanapp/chore/developer/wasm-load-only-once
chore(developer): load wasm module only once per process 🗜
2023-06-23 13:25:03 +10:00
Marc Durdin
2222e875c9
Merge pull request #9056 from keymanapp/chore/developer/cleanup-display-underlying-flag
chore(developer): cleanup displayUnderlying flag in kmw compiler 🗜
2023-06-23 13:24:52 +10:00
Marc Durdin
6928188d13
Merge pull request #9054 from keymanapp/chore/developer/cleanup-font-style-in-kvk
chore(developer): remove font style/color from kvk 🗜
2023-06-23 13:24:41 +10:00
Marc Durdin
23ef2da1be
Merge pull request #9046 from keymanapp/chore/developer/kmc-web-compiler-cleanup
refactor(developer): move constants and globals for kmw compiler 🗜
2023-06-23 13:24:26 +10:00
Marc Durdin
9216a69636
chore: Update developer/src/kmc-kmn/src/compiler/compiler.ts
Co-authored-by: Eberhard Beilharz <ermshiperete@users.noreply.github.com>
2023-06-23 13:23:29 +10:00
Marc Durdin
557c400d57
chore: Apply suggestions from code review
Co-authored-by: Eberhard Beilharz <ermshiperete@users.noreply.github.com>
2023-06-23 13:21:23 +10:00
Marc Durdin
8cd28bdc97 chore(developer): rename data to extra 2023-06-22 07:47:39 +07:00
Marc Durdin
24910fb25a chore(developer): cleanup data passing from wasm
Reorganizes the data structures passed out of kmcmplib via WASM to make
it easier to work with the extra metadata and reduce the number of
places we have to touch when we add extra metadata fields.

Preparation for supporting the metadata that the kmw compiler requires.
2023-06-21 15:33:09 +07:00
Marc Durdin
165dcbe4aa chore(developer): support embedded files in kmw compiler
Adds support for `&kmw_embedcss`, `&kmw_embedjs`, `&kmw_helpfile`.
2023-06-21 12:29:51 +07:00
Marc Durdin
2c2e6feaa3 chore(developer): load wasm module only once per process
Improves performance, and also resolves warning from node:

(node:21032) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 uncaughtException listeners added to [process]. Use emitter.setMaxListeners() to
increase limit
2023-06-21 11:52:57 +07:00
Marc Durdin
a67abadb2f chore(developer): cleanup displayUnderlying flag in kmw compiler 2023-06-21 11:46:24 +07:00
Marc Durdin
3f507f974a chore(developer): remove font style/color from kvk
While .kvk includes a font color field, it is essentially unused. There
was also some sort of support provided for font style in the KeymanWeb
keyboard compiler, but this was never streamed into .kvk or .kvks files,
so was always a no-op.

Thus, this PR removes any semblance of support for font style and color
from the .kvk and .kvks readers and writers. When we write the font
color field which is present in .kvk, we always use the default
TColor.clWindowText which is what the legacy Delphi-based writer would
always have written.

Also sorted out the default font size and name in the .kvk transform
from .kvks, and in so doing cleaned up the basic.kvk and basic.js in
LDML keyboard compiler to match what we are doing in the .kmn compiler.
2023-06-21 10:53:45 +07:00