Now that we have the file type detection in place, we can replace
existing references to the file extensions, where possible, with the
constant declarations. While we could rely on TypeScript's typing to use
string-based values, this helps us to avoid using file extensions
directly in string transforms, regex, etc, and use the `KeymanFileTypes`
alias instead.
Note that only references in common/web, and kmc-* projects have been
touched. References in other Developer projects have not been touched,
as some of those are not yet ESM, so that needs to be addressed first.
This module is used for identification of Keyman source and binary file
formats by file extension. It is not yet appropriate to use for
constants; this will come in a future commit.
Part 1 of the `CompilerOptions` reorg. kmc now uses `CompilerOptions`
throughout, and `CompilerBaseOptions` maps to the set of options
available to all activities.
Tidies up silent vs quiet vs verbose by adding logLevel as an option.
* Notes that we need to consolidate all the various CompilerOptions
interfaces before they get too much further out of hand.
* Cleans up a couple of other minor TODO items.
In order to match existing behaviour with the legacy KeymanWeb compiler,
we should use quoted numbers for row ids. This behaviour can probably be
changed over to the new model in the future, but for now this prevents
unit tests from causing us grief.
Our dev env mostly assumes that build/ is for build artifacts, so this
just sidesteps issues with code search, etc.
The other glaring example of this is resources/build/ which is a _much_
more painful change, given how many scripts reference it. So not
changing that for now.
We still have cjs modules that rely on the ldml-keyboard-xml-reader, and
this meant that an exported const was being calculated with an invalid
meta url, which crashed the cjs module require() call.
The url module is a node module. We need to move responsibility for
resolving the path of the LDML XML <import> statements out of
common/web/types, and into the ultimate consumer, so it's now surfaced
as an option, along with a helper constant that reports the
import.meta.url-relative base path of the standard imports that are
compiled into common/web/types.
This hopefully means we can use this module in both browser and node
contexts without trouble.
Fixes#8885.
Adds some optimization and error checking to the loadFile callback in
kmc-kmn. Also handles case of zero-byte bitmap file so we won't crash on
it.
kmcmplib no longer has any filesystem access, so it cannot verify if a
referenced filename in a source file has the same case as the actual
filename on disk (a risk when moving projects between platforms). So
I opted to move this to the `loadFile` callback in kmc, which is the
only place where filesystem is actually accessed, and added
corresponding unit test.
Small additional fixes here:
1. Move from `Buffer` to `Uint8Array` in all kmc-* modules, so that we
remove that barrier to running on web.
2. Use `callbacks.loadFile` instead of `callbacks.fs.readFileSync`, so
that we can be sure to run the filename consistency check.
3. Fixed kps parser silently swallowing xml errors on load.
4. Added silent mode to NodeCompilerCallbacks so we could cleanly test
the new filename consistency hint.
5. Noted a location where we still have NodeJS deps in kmc-ldml.
Fixes#8889.
No code changes, just moves WASM interfaces into
CompilerInterfacesWasm.cpp, and CompileKeyboardHandle is renamed to
CompileKeyboardBuffer and moved into its own source file.