Skip to content

Commit

Permalink
change(web): remove support for es5
Browse files Browse the repository at this point in the history
Fixes: #11878
  • Loading branch information
ermshiperete committed Jul 2, 2024
1 parent f7d6ebd commit 5a80dbf
Show file tree
Hide file tree
Showing 34 changed files with 73 additions and 294 deletions.
2 changes: 0 additions & 2 deletions android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ KMEA/**/assets/keymanandroid.js
KMEA/**/assets/keyman.js.map
KMEA/**/assets/keymanweb-webview.js
KMEA/**/assets/keymanweb-webview.js.map
KMEA/**/assets/keymanweb-webview.es5.js
KMEA/**/assets/keymanweb-webview.es5.js.map
KMEA/**/assets/map-polyfill.js
KMEA/**/assets/sentry.min.js
KMEA/**/assets/keyman-sentry.js
Expand Down
30 changes: 0 additions & 30 deletions android/KMEA/app/src/main/assets/keyboard.es5.html

This file was deleted.

32 changes: 5 additions & 27 deletions android/KMEA/app/src/main/java/com/keyman/engine/KMManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,7 @@ public String toString() {

// Keyman files
protected static final String KMFilename_KeyboardHtml = "keyboard.html";
protected static final String KMFilename_KeyboardHtml_Legacy = "keyboard.es5.html";
protected static final String KMFilename_JSEngine = "keymanweb-webview.js";
protected static final String KMFilename_JSLegacyEngine = "keymanweb-webview.es5.js";
protected static final String KMFilename_JSSentry = "sentry.min.js";
protected static final String KMFilename_JSSentryInit = "keyman-sentry.js";
protected static final String KMFilename_AndroidHost = "android-host.js";
Expand Down Expand Up @@ -858,25 +856,11 @@ public static boolean copyHTMLBannerAssets(Context context, String path) {
private static void copyAssets(Context context) {
AssetManager assetManager = context.getAssets();

// Will build a temp WebView in order to check Chrome version internally.
boolean legacyMode = WebViewUtils.getEngineWebViewVersionStatus(context, null, null) != WebViewUtils.EngineWebViewVersionStatus.FULL;

try {
// Copy KMW files
if(legacyMode) {
// Replaces the standard ES6-friendly version of the host page with a legacy one that
// includes polyfill requests and that links the legacy, ES5-compatible version of KMW.
copyAssetWithRename(context, KMFilename_KeyboardHtml_Legacy, KMFilename_KeyboardHtml, "", true);

copyAsset(context, KMFilename_JSLegacyEngine, "", true);
} else {
copyAsset(context, KMFilename_KeyboardHtml, "", true);

// For versions of Chrome with full ES6 support, we use the ES6 artifact.
copyAsset(context, KMFilename_JSEngine, "", true);
}
copyAsset(context, KMFilename_KeyboardHtml, "", true);

// Is still built targeting ES5.
copyAsset(context, KMFilename_JSEngine, "", true);
copyAsset(context, KMFilename_JSSentry, "", true);
copyAsset(context, KMFilename_JSSentryInit, "", true);
copyAsset(context, KMFilename_AndroidHost, "", true);
Expand All @@ -887,12 +871,6 @@ private static void copyAssets(Context context) {
// Copy default keyboard font
copyAsset(context, KMDefault_KeyboardFont, "", true);

if(legacyMode) {
copyAsset(context, KMFilename_JSPolyfill, "", true);
copyAsset(context, KMFilename_JSPolyfill2, "", true);
copyAsset(context, KMFilename_JSPolyfill3, "", true);
}

// Keyboard packages directory
File packagesDir = new File(getPackagesDir());
if (!packagesDir.exists()) {
Expand Down Expand Up @@ -1638,7 +1616,7 @@ public static boolean removeKeyboard(Context context, int position) {

public static boolean isDefaultKey(String key) {
return (
key != null &&
key != null &&
key.equals(KMString.format("%s_%s", KMDefault_LanguageID, KMDefault_KeyboardID)));
}

Expand Down Expand Up @@ -2084,11 +2062,11 @@ public static Point getWindowSize(Context context) {
wm.getDefaultDisplay().getSize(size);
return size;
}

WindowMetrics windowMetrics = wm.getCurrentWindowMetrics();
return new Point(
windowMetrics.getBounds().width(),
windowMetrics.getBounds().height());
windowMetrics.getBounds().height());
}

public static float getWindowDensity(Context context) {
Expand Down
2 changes: 0 additions & 2 deletions android/KMEA/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ if builder_start_action build:engine; then
echo "Copying Keyman Web artifacts"
cp "$KEYMAN_WEB_ROOT/build/app/webview/$CONFIG/keymanweb-webview.js" "$ENGINE_ASSETS/keymanweb-webview.js"
cp "$KEYMAN_WEB_ROOT/build/app/webview/$CONFIG/keymanweb-webview.js.map" "$ENGINE_ASSETS/keymanweb-webview.js.map"
cp "$KEYMAN_WEB_ROOT/build/app/webview/$CONFIG/keymanweb-webview.es5.js" "$ENGINE_ASSETS/keymanweb-webview.es5.js"
cp "$KEYMAN_WEB_ROOT/build/app/webview/$CONFIG/keymanweb-webview.es5.js.map" "$ENGINE_ASSETS/keymanweb-webview.es5.js.map"
cp "$KEYMAN_WEB_ROOT/build/app/webview/$CONFIG/map-polyfill.js" "$ENGINE_ASSETS/map-polyfill.js"
cp "$KEYMAN_WEB_ROOT/build/app/resources/osk/ajax-loader.gif" "$ENGINE_ASSETS/ajax-loader.gif"
cp "$KEYMAN_WEB_ROOT/build/app/resources/osk/kmwosk.css" "$ENGINE_ASSETS/kmwosk.css"
Expand Down
2 changes: 1 addition & 1 deletion common/tools/sourcemap-path-remapper/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"inlineSources": true,
"sourceRoot": "/common/tools/sourcemap-path-remapper/src",
"lib": ["dom", "es6"],
"target": "es5",
"target": "es6",
"types": ["node"],
"downlevelIteration": true,
"baseUrl": "./",
Expand Down
3 changes: 1 addition & 2 deletions common/web/es-bundling/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
################################ Main script ################################

builder_describe "Builds KMW's esbuild-oriented common configuration & tooling" \
"@/common/web/tslib" \
"clean" \
"configure" \
"build"
Expand All @@ -24,4 +23,4 @@ builder_parse "$@"

builder_run_action configure verify_npm_setup
builder_run_action clean rm -rf build/
builder_run_action build tsc -b tsconfig.json
builder_run_action build tsc -b tsconfig.json
4 changes: 2 additions & 2 deletions common/web/es-bundling/src/common-bundle.mts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let profilePath;
let sourceRoot;
let platform;

let jsVersionTarget='es5';
let jsVersionTarget='es6';

function doHelp(errCode?: number) {
console.log(`
Expand Down Expand Up @@ -141,4 +141,4 @@ const results = await esbuild.build(config);
if(results.metafile) {
let filesizeProfile = await esbuild.analyzeMetafile(results.metafile, { verbose: true });
fs.writeFileSync(profilePath, filesizeProfile);
}
}
7 changes: 2 additions & 5 deletions common/web/es-bundling/src/configuration.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ import type * as esbuild from 'esbuild';
import { pluginForDowncompiledClassTreeshaking } from './classTreeshaker.mjs';

export const esmConfiguration: esbuild.BuildOptions = {
alias: {
'tslib': '@keymanapp/tslib'
},
bundle: true,
format: "esm",
outExtension: { '.js': '.mjs'},
plugins: [ pluginForDowncompiledClassTreeshaking ],
sourcemap: true,
sourcesContent: true,
target: "es5"
target: "es6"
};

export const iifeConfiguration: esbuild.BuildOptions = {
Expand Down Expand Up @@ -70,4 +67,4 @@ export function bundleObjEntryPoints(configFolder: 'lib' | 'debug' | 'release',
entryPoints: path,
outdir: mappedRoot
};
}
}
9 changes: 4 additions & 5 deletions common/web/keyboard-processor/src/text/stringDivergence.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Future TODO: import from @keymanapp/common-types... once we no longer need to support ES5.
import { Uni_IsSurrogate1, Uni_IsSurrogate2 } from '@keymanapp/web-utils';
import { util } from '@keymanapp/common-types';

/**
* Returns the index for the code point divergence point between two strings, as measured in code
Expand Down Expand Up @@ -73,8 +72,8 @@ export function findCommonSubstringEndIndex(str1: string, str2: string, commonSu
const divergentChar1 = str1.charCodeAt(index);
const divergentChar2 = str2.charCodeAt(index + offset);

const commonSurrogateChecker = commonSuffix ? Uni_IsSurrogate2 : Uni_IsSurrogate1;
const divergentSurrogateChecker = commonSuffix ? Uni_IsSurrogate1 : Uni_IsSurrogate2;
const commonSurrogateChecker = commonSuffix ? util.Uni_IsSurrogate2 : util.Uni_IsSurrogate1;
const divergentSurrogateChecker = commonSuffix ? util.Uni_IsSurrogate1 : util.Uni_IsSurrogate2;

// If the last common character if of the direction-appropriate surrogate type (for
// comprising a potential split surrogate pair representing a non-BMP char)...
Expand All @@ -90,4 +89,4 @@ export function findCommonSubstringEndIndex(str1: string, str2: string, commonSu
}

return index;
}
}
2 changes: 1 addition & 1 deletion common/web/keyman-version/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"compilerOptions": {
"outDir": "./build",
"target": "es5",
"target": "es6",
"rootDir": "."
},

Expand Down
2 changes: 1 addition & 1 deletion common/web/lm-message-types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"outDir": "build/",
"sourceMap": true,
"lib": ["es6"],
"target": "es5"
"target": "es6"
},
"include": ["./*.ts"],
"exclude": ["test.ts"]
Expand Down
4 changes: 2 additions & 2 deletions common/web/lm-worker/build-polyfiller.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,6 @@ await esbuild.build({
// Do NOT enable - will break under Android 5.0 / Chrome 35 environments, likely through Chrome 42.
// https://caniuse.com/mdn-javascript_builtins_function_name_configurable_true
keepNames: false,
target: 'es5',
target: 'es6',
outfile: minDestFile
});
});
34 changes: 1 addition & 33 deletions common/web/lm-worker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,6 @@ function do_configure() {
}

function do_build() {
# Build worker with tsc first
tsc -b $builder_verbose || builder_die "Could not build worker."

$bundle_cmd build/obj/worker-main.js \
--out $INTERMEDIATE/worker-main.es5.js \
--sourceRoot '@keymanapp/keyman/common/web/lm-worker/src/main'

$SRCMAP_CLEANER \
$INTERMEDIATE/worker-main.es5.js.map \
$INTERMEDIATE/worker-main.es5.js.map \
--clean

$bundle_cmd build/obj/worker-main.js \
--out $INTERMEDIATE/worker-main.min.es5.js \
--minify \
--profile build/filesize-profile.es5.log \
--sourceRoot '@keymanapp/keyman/common/web/lm-worker/src/main'

$SRCMAP_CLEANER \
$INTERMEDIATE/worker-main.min.es5.js.map \
$INTERMEDIATE/worker-main.min.es5.js.map \
--clean

EXT_FLAGS=
if builder_has_option --ci; then
EXT_FLAGS=--ci
Expand All @@ -78,16 +55,7 @@ function do_build() {
# Declaration bundling.
tsc --emitDeclarationOnly --outFile $INTERMEDIATE/worker-main.d.ts

echo "Preparing the polyfills + worker for script-embedding"
node build-polyfiller.js $INTERMEDIATE/worker-main.es5.js \
--out $INTERMEDIATE/worker-main.polyfilled.es5.js

mkdir -p $LIB
node build-wrapper.js $INTERMEDIATE/worker-main.polyfilled.es5.js \
--out $LIB/worker-main.wrapped.es5.js \
--sourceMap
node build-wrapper.js $INTERMEDIATE/worker-main.polyfilled.es5.min.js \
--out $LIB/worker-main.wrapped.es5.min.js


# The ES6 target needs no polyfills - we go straight to the wrapped version.
Expand Down Expand Up @@ -142,4 +110,4 @@ function do_test() {
builder_run_action configure do_configure
builder_run_action clean rm -rf build/ intermediate/
builder_run_action build do_build
builder_run_action test do_test
builder_run_action test do_test
6 changes: 2 additions & 4 deletions common/web/lm-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
"main": "./build/lib/worker-main.wrapped.js",
"exports": {
"./worker-main.wrapped.js": {
"es6-bundling": "./build/lib/worker-main.wrapped.js",
"types": "./build/lib/worker-main.wrapped.d.ts",
"default": "./build/lib/worker-main.wrapped.es5.js"
"default": "./build/lib/worker-main.wrapped.js"
},
"./worker-main.wrapped.min.js": {
"es6-bundling": "./build/lib/worker-main.wrapped.min.js",
"types": "./build/lib/worker-main.wrapped.d.ts",
"default": "./build/lib/worker-main.wrapped.es5.min.js"
"default": "./build/lib/worker-main.wrapped.min.js"
}
},
"imports": {
Expand Down
7 changes: 2 additions & 5 deletions common/web/sentry-manager/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export class KeymanSentryManager {
static STANDARD_ALIASABLE_FILES = {
'keymanweb.js': 'keymanweb.js',
'keymanweb-webview.js': 'keymanweb-webview.js',
'keymanweb.es5.js': 'keymanweb.es5.js',
'keymanweb-webview.es5.js': 'keymanweb-webview.es5.js',
'kmwuibutton.js': 'kmwuibutton.js',
'kmwuifloat.js': 'kmwuifloat.js',
'kmwuitoggle.js': 'kmwuitoggle.js',
Expand Down Expand Up @@ -186,8 +184,7 @@ export class KeymanSentryManager {
* Capture errors and warnings logged to Console in order to get
* stack traces. We can't use CaptureConsole integration until we
* upgrade to a newer version of Sentry, which has a bit of a cascade
* of changes required, in particular a change of module type and
* transpiling down to ES5.
* of changes required, in particular a change of module type.
*
* https://stackoverflow.com/a/53214615/1836776
*/
Expand Down Expand Up @@ -262,4 +259,4 @@ export class KeymanSentryManager {

// Publish to the window.
// @ts-ignore
window['KeymanSentryManager'] = KeymanSentryManager;
window['KeymanSentryManager'] = KeymanSentryManager;
15 changes: 0 additions & 15 deletions common/web/tslib/README.md

This file was deleted.

25 changes: 0 additions & 25 deletions common/web/tslib/build.sh

This file was deleted.

Loading

0 comments on commit 5a80dbf

Please sign in to comment.