Commit graph

271 commits

Author SHA1 Message Date
Marc Durdin
b7810bdd2e fix(developer): check vars string usage before definition
Validation of vars was not properly checking for forward references to
string variables. This, coupled with a null vs undefined bug in
subsequent use, meant that forward reference variables were ending up
with a literal string value of 'undefined'.

This also fixes the test for visual-keyboard-compiler, where the fixture
was actually buggy and was the trigger for investigating this problem.

Fixes: #12403
Relates-to: #12395
2024-09-12 09:18:06 +07:00
Marc Durdin
e4017a8c28 fix(developer): rewrite ldml visual keyboard compiler
The visual keyboard compiler was never finished in 17.0. This rewrites
it to:

1. Use the kmxplus data rather than reading from xml directly
2. Fill in `visualkeyboard.header.kbdname`
3. Support modifiers
4. Handle encoded characters like `\u{1234}`
5. Handle string variables like `${one}`*

Additional unit tests have been added to verify the behavior of the
visual keyboard compiler in more detail.

TODO-LDML: string variables appear to have a secondary bug -- they seem
to be returning the string 'undefined'. I have disabled the related
tests and will examine this separately, and enable those tests once
fixed.

TODO-LDML: we should probably add a compiler warning + unit test for
`<layers formId="us"><layer id="base">`, because this pattern does not
make sense: when using non-touch forms, the `<layer>` element should use
`modifiers` attribute, and correspondingly, `modifiers` attribute should
_not_ be used when `formId` is `touch`.

Other fixes:

1. The LDML XML reader was relying on its input being a Node.js `Buffer`
   even though it was declared `Uint8Array`, as it implicitly used
   `Buffer.toString()` to do text conversion. (`Buffer` subclasses from
   `Uint8Array`). This breaks when using `Uint8Array` directly and means
   we had an implicit dependency on Node.js. See also #12331.
2. XML errors were not captured in the LDML XML reader. See also #12331.
3. The unused and unfinished touch-layout-compiler.ts and
   keymanweb-compiler.ts have been removed along with corresponding unit
   tests and fixtures. These are replaced by Core implementations; see
   #12291.

Fixes: #12395
2024-09-12 06:06:00 +07:00
Marc Durdin
6353f926ba
chore: Update developer/src/kmc-ldml/src/compiler/visual-keyboard-compiler.ts 2024-08-26 09:09:00 +02:00
Marc Durdin
d028124ca9 fix(developer): find last matching key in LDML key bag when building KVK
Fixes: #12056
2024-08-24 00:15:33 +02:00
Steven R. Loomis
fb3bee1e90
Merge pull request #11858 from keymanapp/feat/developer/11054-improve-linter
fix(developer): remove redundant check in LdmlKeyboardCompiler.validate() 🙀
2024-08-19 08:44:51 -05:00
dependabot[bot]
6fad148466
chore(deps): bump semver from 7.5.4 to 7.6.0
Bumps [semver](https://github.com/npm/node-semver) from 7.5.4 to 7.6.0.
- [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.5.4...v7.6.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-14 11:22:58 +00:00
Steven R. Loomis
0c6f8d62d2 Merge remote-tracking branch 'upstream/master' into feat/developer/11054-improve-linter 2024-08-07 14:54:30 -05:00
Marc Durdin
32b4711659
Merge branch 'master' into refactor/common/9665-move-compiler-interfaces-to-developer 2024-08-07 15:15:45 +10:00
Marc Durdin
ed143fb333
Merge branch 'master' into refactor/common/9665-move-ldml-keyboard-source-file-to-developer 2024-08-07 15:15:04 +10:00
Marc Durdin
ec72245575
Merge pull request #11765 from keymanapp/refactor/common/9665-move-keyman-touch-layout-file-to-developer
refactor(common): move .keyman-touch-layout reader/writer to @keymanapp/developer-utils 🐉
2024-08-07 15:14:06 +10:00
Steven R. Loomis
4335f19a6a fix(developer): remove redundant check in linter
- simplify LdmlKeyboardCompiler.validate() by removing a redundant check
2024-08-06 09:22:28 -05:00
Marc Durdin
e67aed1606 refactor(common): move compiler-interfaces to @keymanapp/developer-utils
This should be the last step in the refactoring.

Fixes: #9665
2024-08-02 13:49:59 +07:00
Marc Durdin
d3d3ac1eec refactor(common): move LDML keyboard .xml reader/writer and kmx-plus builder to @keymanapp/developer-utils
Relates-to: #9665
2024-08-02 10:23:11 +07:00
Marc Durdin
bd070683f4 refactor(developer): move additional references for TouchLayoutFile 2024-08-01 13:18:32 +07:00
Marc Durdin
d8986be12f refactor(common): merge master into branch 2024-08-01 07:07:07 +07:00
Marc Durdin
d1e351a1ac
Revert "chore(developer): remove redundant references from tsconfig.json" 2024-08-01 08:57:27 +10:00
Eberhard Beilharz
1389d40965
Merge branch 'master' into change/web/11878_remove-es5 2024-07-31 15:28:38 +02:00
Eberhard Beilharz
fd8ffb5efc
chore(web): don't deep import and remove sub-export of util
Addresses code review comments and reverts eb9205f46e and
partially reverts 5552fdd5ad.
2024-07-29 17:43:34 +02:00
Marc Durdin
1cff1a5084 chore(developer): remove redundant references from tsconfig.json
With the full move to ES Modules, we no longer need to include
`references` in tsconfig.json, as we can rely on package.json and
build.sh dependency management. Note however that `tsc -b` may not work
to build dependencies -- they need to be built using `build.sh`, which
calculates which dependencies need building.

kmc-keyboard-info was missing a dependency link to kmc-package in
build.sh, correcting this at the same time.

Relates-to: #12027
2024-07-27 05:44:22 +07:00
Marc Durdin
1afa4beb01 fix(developer): remove paths from tsconfig.json
Fixes: #12027
2024-07-26 06:59:45 +07:00
Eberhard Beilharz
eb9205f46e
chore(web): fix build
Missed one occurrence of `util`...
2024-07-24 18:42:53 +02:00
Eberhard Beilharz
5552fdd5ad
chore(web): expose util.ts as separate sub-export
The exports of the `util.ts` can now be imported as
`@keymanapp/common-types/utils`. Those methods are used by developer.
We still export the `Uni_IsSurrogate*` methods in `main.js` because they
are needed by the keyboard-processor, but exporting everything would
increase the size of the resulting `keymanweb.js`. Doing it this way
keeps the size the same.
2024-07-24 17:33:48 +02:00
Marc Durdin
cfa85d1cc8 chore(developer): rename kmc-ldml export LdmlKeyboardCompilerMessages to LdmlCompilerMessages
This makes the exported class name more consistent with the other
compiler message classes and removes one more unnecessary alias.
2024-07-22 15:58:39 +07:00
Marc Durdin
909b71b6fc chore(developer): rename kmc-ldml CompilerMessages to LdmlCompilerMessages
It is easier to differentiate between all the compiler message classes
if each one has its own name.
2024-07-22 15:52:37 +07:00
Marc Durdin
632f98d029 chore(developer): update unit test CompilerMessages references 2024-07-22 15:26:09 +07:00
Steven R. Loomis
f390de30da
Merge pull request #11843 from keymanapp/fix/developer/10553-reduce-bogus-unclear-errors
fix(developer): layr: fix modifier err message on layer w/o id 🙀
2024-06-21 08:25:08 -05:00
Steven R. Loomis
4dc02c4952 fix(developer): layr: fix modifier err message on layer w/o id
- the error message was broken when there wasn't a layer id (which is allowed)
- add a test case

Fixes: #10553
2024-06-20 17:19:44 -05:00
Steven R. Loomis
570766ca7c feat(developer): linter on blank keycaps
add a linter and hints to detect these cases:
- 'switch' key with no output and no matching display
- any other key whose only output is markers (so cannot otherwise display) and no matching display

Fixes: #11054
2024-06-20 16:02:43 -05:00
Steven R. Loomis
174a2ae80b feat(developer): linter API
- add a Linter class that gets passed the compiled KMXPlus file, and the source file
2024-06-18 11:17:43 -05:00
Steven R. Loomis
8deae5137c test(developer): shuffle tests
- split out test-strs from test-compiler-e2e
- split out test-linter from test-compiler-e2e
2024-06-18 10:15:28 -05:00
Steven R. Loomis
c614de0cd1
feat(developer): Update developer/src/kmc-ldml/src/compiler/messages.ts
Co-authored-by: Marc Durdin <marc@durdin.net>
2024-06-18 09:59:40 -05:00
Steven R. Loomis
612064f1b2 feat(developer): warn on empty keycaps
- add a hint and test for cases where no display matches a marker-only key

Fixes: #11054
2024-06-17 17:49:59 -05:00
Joshua A. Horton
d07fa7e953 chore(common): eliminate ts-node ref from most subpackages 2024-06-10 10:07:58 +07:00
Joshua A. Horton
e527317d3a fix(common): remove subpackge entries for older TS version 2024-06-10 09:14:03 +07:00
Marc Durdin
b874de25e8 chore: replace git dep on restructure with 3.0.1 in npm
3.0.1 includes our fix. However, 3.0.2 does not yet appear to have been
published, which has a patch for our fix?

Fixes: #8616
2024-06-03 14:58:39 +07:00
Marc Durdin
75d39069ec chore(developer): increase timeout for kmc-ldml compiler test
Fixes: #11632
2024-05-31 15:44:40 +07:00
Marc Durdin
ee0fc0ce14 chore(developer): cleanup npm publish
Use a new flag `--npm-publish` in conjunction with `publish` action,
so that the default will always be to `npm pack` if the new flag is not
specified. This flag is also guarded in the actual npm publish code to
ensure that it can only run in the appropriate CI alpha/beta/stable
environment, and not in local or test.

This then also removes the separate `pack` action.

Also removes legacy boilerplate from a number of build scripts.
2024-05-20 06:34:57 +07:00
Marc Durdin
c8a1c6aa39 chore(developer): use builder.inc.sh instead of build-utils.sh in build scripts
also, remove old Makefiles
2024-05-20 06:34:46 +07:00
Joshua A. Horton
398b9e0ae2 chore(common): drops package-specific 'chai', '@types/chai' versions
chore(web): missed leaving these out of the rebase
2024-05-07 14:35:09 +07:00
Marc Durdin
cd8121ef65 chore(common): builder scripts now use /resources/build/builder.inc.sh
Note: there is a bit of potential confusion about the difference between
/resources/builder.inc.sh (the full implementation for builder scripts),
and /resources/build/builder.inc.sh (the source script that builder
scripts should always use).

This allows us to make assumptions that will always be true for builder
scripts that may not be true for other scripts, such as setting base
folder.
2024-05-02 15:54:31 +07:00
Marc Durdin
0f390d47cc chore(common): maintenance on build scripts - cd
Fixes #11324.

* Always `cd "$THIS_SCRIPT_PATH"`
* Remove unnecessary `cd` from all build.sh
* Remove unnecessary `set -eu` from all build.sh (and `# set -x`)
* Replace old build-utils.sh incantation in a few build.sh scripts
2024-05-02 15:54:29 +07:00
Steven R. Loomis
7fb97efa43 fix(developer): escape plus and asterisk sign
- additional tests for asterisk and plus

Fixes: #11233
2024-04-19 16:37:16 -05:00
Steven R. Loomis
cc7ef60f51 fix(developer): error on missing variable name
- improve unit tests
- split out message for dollarsign, create numberspace for transform errs

Fixes: #11044
2024-03-29 11:57:04 -05:00
Steven R. Loomis
876c0e7488 fix(developer): error on missing variable name
- disallow any stray $ in the from pattern (unless escaped)

Fixes: #11044
2024-03-28 11:43:55 -05:00
Steven R. Loomis
ad64bdf163 chore(developer): failing test for invalid variable name
for #11044
2024-03-28 01:17:18 -05:00
Steven R. Loomis
53224cb083
Update developer/src/kmc-ldml/src/util/util.ts
Co-authored-by: Marc Durdin <marc@durdin.net>
2024-03-28 00:12:50 -05:00
Steven R. Loomis
d6e080dd0d feat(developer): implement comma in modifiers 🙀
- improve modifier parsing
- test cases for keys and layr

For: feat(developer) ldml: comma in modifiers #11040
2024-03-25 18:49:13 -05:00
Steven R. Loomis
72de9bed9f feat(developer): scaffolding for comma in modifiers 🙀
- modifiers is a list, not a single entity
- test cases

For: feat(developer) ldml: comma in modifiers #11040
2024-03-25 17:48:31 -05:00
Steven R. Loomis
56add095e6 fix(developer): error if a regex pattern matches the empty string 🙀
- add message and check if the regex matches '' (empty string) and error if so
- add test cases

Fixes: bug(core): assert with vertical pipe #11062
2024-03-25 15:18:35 -05:00
Steven R. Loomis
f2ad7d4e68 fix(common): further improvement to string/set substitution
- tran: check for \uXXXX earlier in the chain, because we emit this format further down
- add test cases for syntax chars being used in variables

Fixes: bug(core): assert when matching markers #11045
Fixes: bug(developer): escape on string substitution if syntax char #11037
2024-03-25 14:52:32 -05:00