Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from CommonJS to ECMAScript modules #284

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions .eslintrc.js

This file was deleted.

35 changes: 35 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import neostandard from 'neostandard'

export default neostandard({
semi: true,
globals: {
"Arm64Relocator": "readonly",
"Arm64Writer": "readonly",
"Checksum": "readonly",
"CModule": "readonly",
"DebugSymbol": "readonly",
"File": "readonly",
"Instruction": "readonly",
"Int64": "readonly",
"Interceptor": "readonly",
"MatchPattern": "readonly",
"Memory": "readonly",
"Module": "readonly",
"NULL": "readonly",
"NativeCallback": "readonly",
"NativeFunction": "readonly",
"NativePointer": "readonly",
"Process": "readonly",
"Script": "readonly",
"Thread": "readonly",
"ThumbRelocator": "readonly",
"ThumbWriter": "readonly",
"UnixInputStream": "readonly",
"UnixOutputStream": "readonly",
"X86Relocator": "readonly",
"X86Writer": "readonly",
"ptr": "readonly",
"int64": "readonly",
"uint64": "readonly",
},
})
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const getApi = require('./lib/api');
const {
import getApi from './lib/api.js';
import {
getAndroidVersion,
withAllArtThreadsSuspended,
withRunnableArtThread,
Expand All @@ -9,13 +9,13 @@ const {
deoptimizeEverything,
deoptimizeBootImage,
deoptimizeMethod
} = require('./lib/android');
const ClassFactory = require('./lib/class-factory');
const ClassModel = require('./lib/class-model');
const Env = require('./lib/env');
const Types = require('./lib/types');
const VM = require('./lib/vm');
const { checkJniResult } = require('./lib/result');
} from './lib/android.js';
import ClassFactory from './lib/class-factory.js';
import ClassModel from './lib/class-model.js';
import Env from './lib/env.js';
import { initialize } from './lib/types.js';
import VM from './lib/vm.js';
import { checkJniResult } from './lib/result.js';

const jsizeSize = 4;
const pointerSize = Process.pointerSize;
Expand Down Expand Up @@ -78,7 +78,7 @@ class Runtime {
const vm = new VM(api);
this.vm = vm;

Types.initialize(vm);
initialize(vm);
ClassFactory._initialize(vm, api);
this.classFactory = new ClassFactory();

Expand Down Expand Up @@ -594,4 +594,4 @@ function initFactoryFromLoadedApk (factory, apk) {
const runtime = new Runtime();
Script.bindWeak(runtime, () => { runtime._dispose(); });

module.exports = runtime;
export default runtime;
4 changes: 1 addition & 3 deletions lib/alloc.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ function abs (nptr) {
return nptr.and(mask);
}

function makeAllocator (sliceSize) {
export default function makeAllocator (sliceSize) {
return new CodeAllocator(sliceSize);
}

module.exports = makeAllocator;
Loading
Loading