mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-05 07:07:41 +00:00
change(common/models): baseline es module conversion of lm-layer
This commit is contained in:
parent
f70205fc9d
commit
5bc977c064
4 changed files with 10 additions and 6 deletions
3
common/predictive-text/src/index.ts
Normal file
3
common/predictive-text/src/index.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export { default as LMLayer } from './lmlayer.js';
|
||||
export { default as NodeWorker } from './node/worker.js';
|
||||
export { default as WebWorker } from './web/worker.js';
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import VirtualizedWorker from "./virtualizedWorker.js";
|
||||
import unwrap from '../unwrap.js';
|
||||
|
||||
import { LMLayerWorkerCode } from "@keymanapp/lm-worker/build/lib/worker-main.wrapped-for-bundle.js";
|
||||
import LMLayerWorkerCode from "@keymanapp/lm-worker/build/lib/worker-main.wrapped-for-bundle.js";
|
||||
|
||||
export default class DefaultWorker {
|
||||
static constructInstance(): Worker {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
*
|
||||
* @param fn The function whose body will be returned.
|
||||
*/
|
||||
export default function unwrap(fnCode: string): string {
|
||||
let match = fnCode.match(/function[^{]+{((?:.|\r|\n)+)}[^}]*$/);
|
||||
export default function unwrap(fn: Function): string {
|
||||
let wrapper = fn.toString();
|
||||
let match = wrapper.match(/function[^{]+{((?:.|\r|\n)+)}[^}]*$/);
|
||||
return match[1];
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import unwrap from '../unwrap.js';
|
||||
import { LMLayerWorkerCode } from "@keymanapp/lm-worker/build/lib/worker-main.wrapped-for-bundle.js";
|
||||
import LMLayerWorkerCode from "@keymanapp/lm-worker/build/lib/worker-main.wrapped-for-bundle.js";
|
||||
|
||||
|
||||
export default class DefaultWorker {
|
||||
|
|
@ -21,8 +21,8 @@ export default class DefaultWorker {
|
|||
* }
|
||||
* }));
|
||||
*/
|
||||
static asBlobURI(fnCode: string): string {
|
||||
let code = unwrap(fnCode);
|
||||
static asBlobURI(fn: Function): string {
|
||||
let code = unwrap(fn);
|
||||
let blob = new Blob([code], { type: 'text/javascript' });
|
||||
return URL.createObjectURL(blob);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue