mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-09 17:17:41 +00:00
chore(common/web): cleans up cross-module imports, drops namespaced export setup
This commit is contained in:
parent
2c133dfe5d
commit
b171ff342e
14 changed files with 22 additions and 121 deletions
|
|
@ -8,25 +8,6 @@
|
|||
import esbuild from 'esbuild';
|
||||
import { spawn } from 'child_process';
|
||||
|
||||
// Browser / namespace-targeted bundle
|
||||
esbuild.buildSync({
|
||||
entryPoints: ['build/obj/index-namespaced.js'],
|
||||
bundle: true,
|
||||
sourcemap: true,
|
||||
minify: true,
|
||||
format: "iife",
|
||||
keepNames: true,
|
||||
// Sets 'common/web' as a root folder for module resolution;
|
||||
// this allows the keyman-version and utils imports to resolve.
|
||||
//
|
||||
// We also need to point it at the nested build output folder to resolve in-project
|
||||
// imports when compiled - esbuild doesn't seem to pick up on the shifted base.
|
||||
nodePaths: ['..', "build/obj"],
|
||||
outfile: "build/lib/index.namespaced.js",
|
||||
tsconfig: 'tsconfig.json',
|
||||
target: "es5"
|
||||
});
|
||||
|
||||
// Bundled ES module version
|
||||
esbuild.buildSync({
|
||||
entryPoints: ['build/obj/index.js'],
|
||||
|
|
@ -68,22 +49,9 @@ const dtsBundleCommand = spawn('npx dts-bundle-generator --project tsconfig.json
|
|||
dtsBundleCommand.stdout.on('data', data => console.log(data.toString()));
|
||||
dtsBundleCommand.stderr.on('data', data => console.error(data.toString()));
|
||||
|
||||
// Forces synchronicity; done mostly so that the logs don't get jumbled up.
|
||||
dtsBundleCommand.on('exit', () => {
|
||||
if(dtsBundleCommand.exitCode != 0) {
|
||||
process.exit(dtsBundleCommand.exitCode);
|
||||
}
|
||||
|
||||
const namespacedDtsBundleCmd = spawn('npx dts-bundle-generator --project tsconfig.json -o build/lib/index.namespaced.d.ts src/index-namespaced.ts', {
|
||||
shell: true
|
||||
});
|
||||
|
||||
namespacedDtsBundleCmd.stdout.on('data', data => console.log(data.toString()));
|
||||
namespacedDtsBundleCmd.stderr.on('data', data => console.error(data.toString()));
|
||||
|
||||
namespacedDtsBundleCmd.on('exit', () => {
|
||||
if(namespacedDtsBundleCmd.exitCode != 0) {
|
||||
process.exit(namespacedDtsBundleCmd.exitCode);
|
||||
}
|
||||
})
|
||||
});
|
||||
// // Forces synchronicity; done mostly so that the logs don't get jumbled up.
|
||||
// dtsBundleCommand.on('exit', () => {
|
||||
// if(dtsBundleCommand.exitCode != 0) {
|
||||
// process.exit(dtsBundleCommand.exitCode);
|
||||
// }
|
||||
// });
|
||||
|
|
@ -1 +0,0 @@
|
|||
export * as keyman from './keyman-index.js';
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
// This file exists as a bundling intermediary that attempts to present all of
|
||||
// keyboard-processor's offerings in the 'old', namespaced format - at least,
|
||||
// as of the time that this submodule was converted to ES6 module use.
|
||||
|
||||
// Unfortunately, the declaration-bundling tool that works well for the modules...
|
||||
// struggles a bit here.
|
||||
|
||||
import * as com from "./com-index.js";
|
||||
|
||||
// Make sure the declaration-merger code pays attention.
|
||||
export * as com from "./com-index.js";
|
||||
|
||||
// Force-exports it as the global it always was.
|
||||
com.keyman.utils.getGlobalObject()['com'] = com;
|
||||
|
|
@ -13,10 +13,17 @@ export * from "./text/kbdInterface.js";
|
|||
export { default as KeyboardProcessor } from "./text/keyboardProcessor.js";
|
||||
export * from "./text/keyboardProcessor.js";
|
||||
export { default as KeyEvent } from "./text/keyEvent.js";
|
||||
export * from "./text/keyEvent.js";
|
||||
export { default as KeyMapping } from "./text/keyMapping.js";
|
||||
export { default as OutputTarget } from "./text/outputTarget.js";
|
||||
export * from "./text/outputTarget.js";
|
||||
export { default as RuleBehavior } from "./text/ruleBehavior.js";
|
||||
export * from "./text/systemStores.js";
|
||||
|
||||
export * from "@keymanapp/web-utils/build/obj/index.js";
|
||||
export * from "@keymanapp/web-utils/build/obj/index.js";
|
||||
|
||||
// At the top level, there should be no default export.
|
||||
|
||||
// Without the line below... OutputTarget would likely be aliased there, as it's
|
||||
// the last `export { default as _ }` => `export * from` pairing seen above.
|
||||
export default undefined;
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
// This file exists as a bundling intermediary that attempts to present all of
|
||||
// keyboard-processor's offerings in the 'old', namespaced format - at least,
|
||||
// as of the time that this submodule was converted to ES6 module use.
|
||||
|
||||
// Unfortunately, the declaration-bundling tool that works well for the modules...
|
||||
// struggles a bit here.
|
||||
|
||||
export {
|
||||
ActiveKey,
|
||||
ActiveRow,
|
||||
ActiveLayer,
|
||||
ActiveLayout
|
||||
} from "./activeLayout.js";
|
||||
|
||||
export {
|
||||
Layouts
|
||||
} from "./defaultLayouts.js";
|
||||
|
||||
export { default as Keyboard} from "./keyboard.js";
|
||||
export {
|
||||
LayoutState
|
||||
} from "./keyboard.js";
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
export * as keyboards from './keyboards/index.js';
|
||||
export * as text from './text/index.js';
|
||||
export * as utils from './utils-index.js';
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
export { default as Codes } from "./codes.js";
|
||||
export { Deadkey, DeadkeyTracker } from "./deadkeys.js";
|
||||
export { default as DefaultOutput, EmulationKeystrokes } from "./defaultOutput.js";
|
||||
export { default as KeyboardInterface, KeyInformation, SystemStoreIDs } from "./kbdInterface.js";
|
||||
export { default as KeyboardProcessor } from "./keyboardProcessor.js";
|
||||
export { default as KeyEvent } from "./keyEvent.js";
|
||||
export { default as KeyMapping } from "./keyMapping.js";
|
||||
export { default as OutputTarget, TextTransform, Transcription, Mock } from "./outputTarget.js";
|
||||
export { default as RuleBehavior } from "./ruleBehavior.js";
|
||||
export { SystemStore, MutableSystemStore, PlatformSystemStore } from "./systemStores.js";
|
||||
|
|
@ -5,20 +5,19 @@
|
|||
|
||||
//#region Imports
|
||||
|
||||
import { type DeviceSpec } from "@keymanapp/web-utils/build/obj/index.js";
|
||||
|
||||
import Codes from "./codes.js";
|
||||
import type KeyEvent from "./keyEvent.js";
|
||||
import type { Deadkey } from "./deadkeys.js";
|
||||
import KeyMapping from "./keyMapping.js";
|
||||
import { SystemStore, MutableSystemStore, PlatformSystemStore } from "./systemStores.js";
|
||||
import type { VariableStoreSerializer } from "./keyboardProcessor.js";
|
||||
|
||||
import type OutputTarget from "./outputTarget.js";
|
||||
import { Mock } from "./outputTarget.js";
|
||||
|
||||
import RuleBehavior from "./ruleBehavior.js";
|
||||
import Keyboard, { VariableStoreDictionary } from "../keyboards/keyboard.js";
|
||||
|
||||
import { type DeviceSpec } from "@keymanapp/web-utils/build/obj/index.js";
|
||||
|
||||
//#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type Keyboard from "../keyboards/keyboard.js";
|
||||
import type DeviceSpec from "@keymanapp/web-utils/build/obj/deviceSpec.js";
|
||||
import {type DeviceSpec} from "@keymanapp/web-utils/build/obj/index.js";
|
||||
|
||||
// Represents a probability distribution over a keyboard's keys.
|
||||
// Defined here to avoid compilation issues.
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
export { deepCopy, DeviceSpec, extendString, globalObject as getGlobalObject, Version } from "@keymanapp/web-utils/build/obj/index.js";
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
/**
|
||||
* A temporary file to validate that the bundled version really is bundled and is usable in a
|
||||
* similar manner to its old format.
|
||||
*/
|
||||
|
||||
// Loads `com` into the global namespace.
|
||||
import * as _ from '../build/bundled/index.js';
|
||||
|
||||
console.log(`Int code for ALT: ${com.keyman.text.Codes.modifierCodes['ALT']}`);
|
||||
|
||||
console.log(new com.keyman.keyboards.Keyboard(null));
|
||||
|
||||
console.log();
|
||||
|
||||
// make sure we bundled `utils` as well!
|
||||
console.log(`Verifying proper handling of version 16.0: ${new com.keyman.utils.Version([16, 0]).toString()}`);
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
/// <reference path="proctor.ts" />
|
||||
|
||||
import KeyEvent, { KeyDistribution } from "@keymanapp/keyboard-processor/build/obj/text/keyEvent.js";
|
||||
import type OutputTarget from "@keymanapp/keyboard-processor/build/obj/text/outputTarget.js";
|
||||
import { Mock } from "@keymanapp/keyboard-processor/build/obj/text/outputTarget.js";
|
||||
import { type OutputTarget } from "@keymanapp/keyboard-processor/build/obj/index.js";
|
||||
import { KeyDistribution, KeyEvent, Mock } from "@keymanapp/keyboard-processor/build/obj/index.js";
|
||||
|
||||
import Proctor from "./proctor.js";
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,9 @@ import {
|
|||
RecordedSyntheticKeystroke
|
||||
} from "./index.js";
|
||||
|
||||
import Keyboard from "@keymanapp/keyboard-processor/build/obj/keyboards/keyboard.js";
|
||||
import type KeyEvent from "@keymanapp/keyboard-processor/build/obj/text/keyEvent.js";
|
||||
import KeyboardProcessor from "@keymanapp/keyboard-processor/build/obj/text/keyboardProcessor.js";
|
||||
import type OutputTarget from "@keymanapp/keyboard-processor/build/obj/text/outputTarget.js";
|
||||
import { Mock } from "@keymanapp/keyboard-processor/build/obj/text/outputTarget.js";
|
||||
import { Keyboard, type KeyEvent, KeyboardProcessor, Mock, type OutputTarget } from "@keymanapp/keyboard-processor/build/obj/index.js";
|
||||
|
||||
import DeviceSpec from "@keymanapp/web-utils/build/obj/deviceSpec.js";
|
||||
import { DeviceSpec } from "@keymanapp/web-utils/build/obj/index.js";
|
||||
|
||||
export default class NodeProctor extends Proctor {
|
||||
private keyboard: Keyboard;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { type DeviceSpec } from "@keymanapp/web-utils/build/obj/index.js";
|
||||
import type OutputTarget from "@keymanapp/keyboard-processor/build/obj/text/outputTarget.js";
|
||||
import { type OutputTarget } from "@keymanapp/keyboard-processor/build/obj/index.js";
|
||||
|
||||
import type { KeyboardTest, TestSet, TestSequence } from "./index.js";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue