Commit graph

147 commits

Author SHA1 Message Date
Marc Durdin
d1d6dc5d99 refactor(developer): compiler interface part 1 for wasm
This starts the refactor of the .kmn compiler interfaces for WASM,
moving more file writes into typescript and out of the compiler. Adds a
cleaner binding and structures for passing compile metadata back to
typescript for additional build steps (e.g. kvk, js builds).

Will rebase the Typescript-based KMW compiler onto this so it can start
to benefit from the refactoring.

* Fixes a minor issue with loading a .kvks file with an empty flags set.
* Adds a writeFileSync method to the compiler callback interfaces.
* Adds an e2e compiler test to verify that .kmx and .kvk are both
  correctly compiled.
2023-05-23 15:26:28 +07:00
Steven R. Loomis
1937552f39 Merge remote-tracking branch 'upstream/master' into feat/developer-234-uset-wasm-epic-ldml 2023-05-12 08:44:19 -05:00
Marc Durdin
7982bd955c
Merge pull request #8729 from keymanapp/chore/developer/move-package-formats-to-common-types
chore(developer): move package formats to common/web/types
2023-05-12 12:25:19 +10:00
Steven R. Loomis
6317583528 feat(developer): kmc-kmn: wasm and error message updates 🙀
developer:
- update wasm machinery in kmc-kmn to be more self contained
- improve exception situation in wasm functions

common:
- compilerErrorFormatCode() for formatting the raw code such as for tests
- compilerExceptionToString() for formatting exceptions in messages

for: #7234
2023-05-11 10:37:46 -05:00
Marc Durdin
53ccdbe241 chore(developer): move package formats to common/web/types
Package file interfaces were stored in developer/kmc-package but belong
better now in common/web/types.
2023-05-09 15:48:50 +07:00
Marc Durdin
4838ba1ffe chore: rename kmc-keyboard to kmc-ldml
Part of #8719.
2023-05-09 14:08:45 +07:00
Steven R. Loomis
07392ed460 feat(developer): update tests and reader for transforms 🙀
- not working yet, but 'update' some XML

for #7377
2023-04-27 12:21:03 -05:00
Marc Durdin
f2bc55bb31
Merge pull request #8674 from keymanapp/refactor/developer/callbacks-instead-of-direct-fs
refactor(developer): use callbacks to avoid direct fs access in kmc-package
2023-04-27 17:56:47 +10:00
Marc Durdin
983d5076f9
Merge pull request #8666 from keymanapp/chore/developer/kmc-keyboard-web-compatible
chore(developer): kmc-keyboard should not use any node-specific modules
2023-04-27 17:56:23 +10:00
Marc Durdin
6fb9b72437 fix(developer): project relative path calculation and add test 2023-04-26 15:56:00 +07:00
Marc Durdin
5e0471f0b7 refactor(developer): use callbacks to avoid direct fs access in kmc-package
Fixes #8644.

This is a signficant cleanup and refactor of code that was accessing the
fs or path modules in Node directly. Given we want to be able to run
these modules on web as well in the future, it is important that we
avoid that.

This also redesigns the CompilerCallback interfaces to provide Node-like
interfaces for path and fs, with a minimal set of functions. The aim
here is to provide a surface that will hopefully match a future
web-based component such as path-browserify without significant
retooling of the kmc-* modules.

Enables linting for common/web/types and turns on the
eslintNoNodeImports checks for that module and kmc-package.

Note: Buffer is still in use in a few places also, so we'll need to
refactor that in a future commit.
2023-04-26 12:31:50 +07:00
Steven R. Loomis
79afbd75ae fix(developer): fix jis scan codes 🙀
- also see discussion in https://github.com/keymanapp/keyman/pull/8513

for #8552
2023-04-25 17:40:20 -05:00
Marc Durdin
5f9ccab4ce refactor(common): move basename func to common/web/types
This is the best place for it for now. Later we may move elsewhere.
2023-04-25 14:49:45 +07:00
Marc Durdin
f9c818f103 chore(common): update dependency paths 2023-04-24 08:51:39 +07:00
Marc Durdin
cf4022ac8a feat(developer): use CompilerEvent for messages in all of kmc
Cleans up majority of remaining kmc-* modules to use CompilerEvent
messages instead of console.log and friends, adding
InfrastructureMessages class for kmc CLI messages.

Consolidates schema loading functions into a single `loadSchema`
function in the CompilerCallbacks interface and implementations.

Moves responsibility for instantiating NodeCompilerCallbacks out of
each individual BuildActivity and into higher level modules.

Fixes return value for failing builds.
2023-04-24 07:26:43 +07:00
Marc Durdin
8ec69471dc feat(common): kmx file reader
Read a .kmx file into memory in Typescript. Currently only reads stores
from the file, as these are the most common things needed for other
processes. Will add support for reading other metadata and rules in
future when required.
2023-04-21 11:52:18 +07:00
Marc Durdin
e0ed058e89 refactor(developer): kmc-model to use CompilerEvent
Replaces the existing error reporting in kmc-model with CompilerEvent
style messages. Some of the existing error reporting was kinda nice, but
consistency trumps pretty here.

One downside at present is the global filename and line variables in the
model-compiler-errors.ts unit. This is fragile, and should probably be
refactored further in the future.

Where it made sense, I converted various throws into ModelCompilerError
instances. If it appeared to be an internal error, I left it as-is, but
the external API interfaces wrap all unknown exceptions and convert them
into a compiler error message, so these APIs (compileModel and
loadFromFilename) now have a guarantee that they will never throw.

At this point, all of the error messages in the model compiler are
unrecoverable -- they will halt the compile entirely. However, the
pathway is there to support recoverable errors through the normal
callbacks.reportMessage mechanisms.

The message-counting mechanism is currently missing from this, as it
belongs in the API consumer, rather than in the low-level reporting
infrastructure. This means that models with large numbers of warnings
are going to generate scads of messages for now.

Note that the _users_ of CompilerCallbacks are subject to change in the
future, once we have all the compilers using the callbacks.
2023-04-20 16:40:04 +07:00
Marc Durdin
39d473fb2d refactor(developer): move comperr.h to kmn_compiler_errors.h
Consolidates the two copies of comperr.h (they were identical) and
moves to a common folder. Updates all references to comperr.h, except
for one github commit ref.
2023-04-20 13:20:29 +07:00
Marc Durdin
2f7407b4b8 feat(developer): warn if .kps file includes a non-binary .kvk file
Relates to #8150.

Legacy .kmp compiler would transform xml-format .kvk files into a binary
.kvk file; now we want that to remain the responsibility of the keyboard
compiler, so we'll warn the few users who are still doing this.
2023-04-19 15:32:29 +07:00
Marc Durdin
66542f6323 feat(developer): use new message infrastructure in kmc-kmn
Moves to using the `reportMessage` callback for reporting all errors in
kmc-kmn.

This required some patching to common/web/types in order to get the new
constants in place and add support for line numbers to `CompilerEvent`,
so at the same time I refactored `compilerErrorSeverityName` into the
module.

After the refactor, coverage tests were failing because they included
the test/ folder, so cleaned that up at the same time.
2023-04-19 10:13:14 +07:00
Marc Durdin
501cf03dc2 chore(common): update description for 'build.sh pack' 2023-04-12 14:18:31 +07:00
Marc Durdin
3265a714f2 chore(common): add missing deps and files for npm publish
The build/ folder for most packages was missing due to being listed in
.gitignore.

Also, @keymanapp/ldml-keyboard-constants package was not being published
despite being a dependency of @keymanapp/kmc-keyboard.

Instead of relying on npm's use of .gitignore / .npmignore (which has
seriously wonky behaviours), we list the files that should be included
in package.json.

NPM Wonky behaviours: it seems that .npmignore causes .gitignore in the
same folder to be ignored. But, higher level .gitignore files still
affect the files included in the package, which makes
specification-by-exclusion painful (negating exclusions, etc). We do not
recommend use of .npmignore anywhere for this reason.
2023-04-12 14:05:05 +07:00
Marc Durdin
10a59f789d fix(common): support npm pack and consolidate npm publishing
Fixes #8586.

All npm publish actions in the repository are now run as part of the
Developer release build, hosted at present by kmc, until we setup a
higher-level build script to do it.

Adds a 'pack' action which mirrors 'publish' for all npm packages.

Removes unnecessary dev dependencies of models-templates and
models-wordbreakers from kmc-model.

Web Release build CI step has been updated to check for presence of
.build-builder.
2023-04-12 11:55:31 +07:00
Marc Durdin
c5d79a9fb4
Merge pull request #7330 from keymanapp/feature-kmcompx
epic: kmcompx - kmcmpdll cross-platform compiler 🚑
2023-04-10 07:34:04 +10:00
Marc Durdin
787b32ba34
Revert "chore(web): merge master into feature-esmodule-web-engine (A17S9 end) 🧩" 2023-03-31 14:17:37 +11:00
Joshua Horton
6df63eddc5
Merge pull request #8549 from keymanapp/chore/master-to-esmodule-merge-a17s9 2023-03-31 08:51:27 +07:00
Marc Durdin
2a871c8165 chore(developer): publish all required npm modules 2023-03-27 11:36:21 +07:00
Steven R. Loomis
93ca0473e5 fix(developer): ldml add ABNT2 🙀
- compiles, at least

For: #8161
2023-03-24 12:49:00 -05:00
Steven R. Loomis
a474d8cbc6 fix(developer): ldml add JIS 🙀
- compiles, at least

For: #8161
2023-03-24 12:13:36 -05:00
Joshua A. Horton
b85087f392 chore(web): Merge branch 'master' into chore/web/update-feature-esmodule-for-configure-fix 2023-03-23 15:15:07 +07:00
Steven R. Loomis
f0cc2b56e6
Merge pull request #8436 from keymanapp/fix/developer-8069/todo2-epic-ldml 2023-03-14 21:51:08 -05:00
Steven R. Loomis
f7e5b114cf
Merge pull request #8412 from keymanapp/chore/resources-7042-cldr-update-202303-epic-ldml 2023-03-14 21:50:17 -05:00
Marc Durdin
409b722eb6
Merge pull request #8426 from keymanapp/fix/common-8419
fix(common): fix broken common/web/types cases 🙀
2023-03-15 11:33:44 +11:00
Steven R. Loomis
f7499238a2 fix(core): ldml more TODO-LDML fixes 🙀
- drop some TODO-LDMLs, document others.

For: #8069
2023-03-14 18:54:28 -05:00
Steven R. Loomis
f92cd36125 chore(developer): ldml update compiler for updated spec 🙀
#7042
2023-03-14 17:38:30 -05:00
Steven R. Loomis
5c25bf429f fix(common): fix broken common/web/types cases
Fixes: #8419
2023-03-14 17:34:37 -05:00
Joshua Horton
10518dd62e
Merge pull request #8429 from keymanapp/chore/common/ldml-ts-and-node-updates
chore(common): TS updates to non-sync'd packages, feature-esmodule merge conflict prevention
2023-03-14 12:06:15 +07:00
Joshua A. Horton
f7d082981c chore: Merge branch 'master' into chore/feature-esmodule-master-update 2023-03-14 11:51:57 +07:00
Joshua A. Horton
f5e64a10a5 chore: Merge branch 'chore/common/ldml-ts-and-node-updates' into chore/feature-esmodule-master-update 2023-03-14 09:23:39 +07:00
Joshua A. Horton
2439ba4e97 fix(developer): updates kmc, web/types module resolution, adds missing type import/exports 2023-03-14 08:41:29 +07:00
Joshua A. Horton
0da7ac24be chore(common): updates TS, sets export map for keyman-version 2023-03-14 08:22:26 +07:00
Marc Durdin
92ed99c4d6 chore(common): build script performance improvements
Improves build script performance by:
* using built-ins wherever possible (e.g. string splitting)
* eliminating redundant code
* using absolute (to $KEYMAN_ROOT) rather than relative paths to avoid realpath
* removing unnecessary `npm run` calls

BEFORE                         | AFTER
-------------------------------|----------------------
time ./core/build.sh --help    |
real    0m2.116s               | real    0m0.874s
user    0m0.578s               | user    0m0.198s
sys     0m0.984s               | sys     0m0.289s
-------------------------------|----------------------
time ./web/build.sh --help     |
real    0m3.523s               | real    0m0.757s
user    0m1.166s               | user    0m0.320s
sys     0m2.273s               | sys     0m0.455s
-------------------------------|----------------------
time ./web/build.sh -d         |
real    1m34.750s              | real    0m59.974s
user    0m9.721s               | user    0m6.284s
sys     0m19.652s              | sys     0m13.202s

@keymanapp-test-bot skip
2023-03-13 07:18:09 +07:00
Marc Durdin
be4f036a3c feat(developer): Add support for building a folder to kmc
Relates to #2761.

kmc now supports passing in a folder and building all Keyman source
files found in the folder, even if a .kpj is not present in the folder.

If a .kpj file exists, `KeymanDeveloperProject/Options/Version` will be
checked to determine behaviour. If this field is missing or "1.0", then
the classical behaviour persists.

If the Version field is "2.0", the `Files` key is ignored, and .kmn,
.xml, .model.ts, and .kps files under `sourcePath` are enumerated and
added to the in-memory project for build.

If a .kpj is not present in the folder, a virtual project is constructed
in memory with the following defaults:

* `version`: `2.0`
* `buildPath`: `$PROJECTPATH/build`
* `sourcePath`: `$PROJECTPATH/source`
* `compilerWarningsAsErrors`: `false`
* `warnDeprecatedCode`: `true`
* `checkFilenameConventions`: `true`

It is still considered an error to include both a keyboard and a model
in the same file, but a version 2.0 project will not include the field
determining its type in `Options/ProjectType`; this will instead be
checked during build.

The call to `kmc` can reference a folder or a .kpj file. The .kpj file
must have the same basename as the folder name (e.g.
`khmer_angkor/khmer_angkor.kpj`).

WARNING: this does not add support for 2.0 projects to Keyman Developer;
it is likely that opening a version 2.0 project in Developer will
currently corrupt it.

WARNING: it is not anticipated that kmcomp.exe will be updated to
support version 2.0 projects -- rather kmcomp.exe will be removed before
release of v17, and replaced with kmc.
2023-02-27 13:11:22 +07:00
Marc Durdin
b04489a47b feat(developer): kmc .kpj support
Adds support for building .kpj projects. Required minor tweak to kmcomp
to allow it to build both .kmx and .js from .kmn command line.
Currently, calls kmcomp.exe to build .kmn files, until we support a
cross-platform kmc-kmn C++ project.
2023-02-27 06:14:06 +07:00
Marc Durdin
35c706576b chore(common): export kpj from module 2023-02-26 06:02:43 +07:00
Marc Durdin
647803ef28 feat(common): add .kpj typescript reader and schema 2023-02-25 11:17:39 +07:00
Marc Durdin
a2ceb98948 chore: rewrite extra standard build script prolog 2023-02-23 08:09:41 +07:00
Marc Durdin
a0ecb30a9c
Merge pull request #8265 from keymanapp/feat/developer/epic-ldml/7238-touch-layout-compiler
feat(developer): touch layout compiler for LDML 🙀
2023-02-23 08:47:46 +11:00
Steven R. Loomis
e1e5eea469 feat(core): ldml rename key2 to keys 🙀
- So in summary, since before #7532 basically keys was restructured, and the old 'keys' was moved into 'keys.kmap'.

#8069
2023-02-20 17:40:34 -06:00
Marc Durdin
88df443ba1 feat(developer): touch layout compiler [unfinished] 2023-02-20 10:18:01 +07:00