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

Convert to ESM #60

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* jshint esnext: true, evil: true */

const {getApi, defaultInvocationOptions} = require('./lib/api');
const fastpaths = require('./lib/fastpaths');
import {getApi, defaultInvocationOptions} from './lib/api.js';
import * as fastpaths from './lib/fastpaths.js';

function Runtime() {
const pointerSize = Process.pointerSize;
Expand Down Expand Up @@ -2702,4 +2702,5 @@ function Runtime() {
}
}

module.exports = new Runtime();
const runtime = new Runtime();
export default runtime;
9 changes: 2 additions & 7 deletions lib/api.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
let cachedApi = null;

const defaultInvocationOptions = {
export const defaultInvocationOptions = {
exceptions: 'propagate'
};

function getApi() {
export function getApi() {
if (cachedApi !== null) {
return cachedApi;
}
Expand Down Expand Up @@ -161,8 +161,3 @@ function getApi() {

return cachedApi;
}

module.exports = {
getApi,
defaultInvocationOptions,
};
13 changes: 6 additions & 7 deletions lib/fastpaths.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {getApi} from './api.js';

const code = `#include <glib.h>
#include <ptrauth.h>

Expand Down Expand Up @@ -203,18 +205,15 @@ read_local_memory (task_t remote_task,
}
`;

const {getApi} = require('./api');

const {pointerSize} = Process;

let cachedModule = null;

module.exports = {
get() {
if (cachedModule === null)
cachedModule = compileModule();
return cachedModule;
},
export function get() {
if (cachedModule === null)
cachedModule = compileModule();
return cachedModule;
};

function compileModule() {
Expand Down
10 changes: 9 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "7.0.6",
"description": "Objective-C runtime interop from Frida",
"main": "index.js",
"type":"module",
"files": [
"/index.js",
"/lib/**/*.js"
Expand Down
3 changes: 2 additions & 1 deletion test/bundle.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
global.LocalObjC = require('../');
import * as bridge from 'frida-objc-bridge';
global.LocalObjC = bridge;
Loading