frida-float-menu 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +404 -0
- package/lib/api.d.ts +50 -0
- package/lib/api.js +149 -0
- package/lib/component/button.d.ts +11 -0
- package/lib/component/button.js +57 -0
- package/lib/component/category.d.ts +8 -0
- package/lib/component/category.js +37 -0
- package/lib/component/checkBox.d.ts +28 -0
- package/lib/component/checkBox.js +199 -0
- package/lib/component/collapsible.d.ts +19 -0
- package/lib/component/collapsible.js +177 -0
- package/lib/component/image.d.ts +18 -0
- package/lib/component/image.js +87 -0
- package/lib/component/input.d.ts +33 -0
- package/lib/component/input.js +346 -0
- package/lib/component/selector.d.ts +22 -0
- package/lib/component/selector.js +95 -0
- package/lib/component/slider.d.ts +18 -0
- package/lib/component/slider.js +155 -0
- package/lib/component/style/style.d.ts +5 -0
- package/lib/component/style/style.js +261 -0
- package/lib/component/style/theme.d.ts +29 -0
- package/lib/component/style/theme.js +23 -0
- package/lib/component/switch.d.ts +12 -0
- package/lib/component/switch.js +77 -0
- package/lib/component/text.d.ts +9 -0
- package/lib/component/text.js +36 -0
- package/lib/component/ui-components.d.ts +24 -0
- package/lib/component/ui-components.js +49 -0
- package/lib/component/views/log-view.d.ts +25 -0
- package/lib/component/views/log-view.js +231 -0
- package/lib/component/views/tabs-view.d.ts +35 -0
- package/lib/component/views/tabs-view.js +296 -0
- package/lib/event-emitter.d.ts +10 -0
- package/lib/event-emitter.js +52 -0
- package/lib/float-menu.d.ts +63 -0
- package/lib/float-menu.js +568 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +28 -0
- package/lib/logger.d.ts +43 -0
- package/lib/logger.js +183 -0
- package/lib/utils.d.ts +8 -0
- package/lib/utils.js +16 -0
- package/package.json +36 -0
package/lib/logger.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Logger = void 0;
|
|
4
|
+
exports.log = log;
|
|
5
|
+
function log(message) {
|
|
6
|
+
console.log(message);
|
|
7
|
+
}
|
|
8
|
+
class Logger {
|
|
9
|
+
on(arg0, arg1) {
|
|
10
|
+
throw new Error("Method not implemented.");
|
|
11
|
+
}
|
|
12
|
+
static get instance() {
|
|
13
|
+
if (!Logger._instance)
|
|
14
|
+
Logger._instance = new Logger("info");
|
|
15
|
+
return Logger._instance;
|
|
16
|
+
}
|
|
17
|
+
constructor(level = "info", options) {
|
|
18
|
+
this.levelPriority = {
|
|
19
|
+
debug: 0,
|
|
20
|
+
info: 1,
|
|
21
|
+
warn: 2,
|
|
22
|
+
error: 3,
|
|
23
|
+
none: 4,
|
|
24
|
+
};
|
|
25
|
+
this.head = 0;
|
|
26
|
+
this.size = 0;
|
|
27
|
+
this.pending = [];
|
|
28
|
+
this.flushTimer = null;
|
|
29
|
+
this.listeners = [];
|
|
30
|
+
this.currentLevel = level;
|
|
31
|
+
this.maxBuffer = Math.max(50, options?.maxBuffer ?? 300);
|
|
32
|
+
this.flushIntervalMs = Math.max(8, options?.flushIntervalMs ?? 16);
|
|
33
|
+
this.buffer = new Array(this.maxBuffer);
|
|
34
|
+
}
|
|
35
|
+
setLevel(level) {
|
|
36
|
+
this.currentLevel = level;
|
|
37
|
+
}
|
|
38
|
+
setMaxBuffer(max) {
|
|
39
|
+
const newMax = Math.max(50, max | 0);
|
|
40
|
+
if (newMax === this.maxBuffer)
|
|
41
|
+
return;
|
|
42
|
+
const items = this.getRecent(newMax);
|
|
43
|
+
this.maxBuffer = newMax;
|
|
44
|
+
this.buffer = new Array(this.maxBuffer);
|
|
45
|
+
this.head = 0;
|
|
46
|
+
this.size = 0;
|
|
47
|
+
for (const it of items)
|
|
48
|
+
this.pushToBuffer(it);
|
|
49
|
+
}
|
|
50
|
+
debug(...args) {
|
|
51
|
+
this._log("debug", ...args);
|
|
52
|
+
}
|
|
53
|
+
info(...args) {
|
|
54
|
+
this._log("info", ...args);
|
|
55
|
+
}
|
|
56
|
+
warn(...args) {
|
|
57
|
+
this._log("warn", ...args);
|
|
58
|
+
}
|
|
59
|
+
error(...args) {
|
|
60
|
+
this._log("error", ...args);
|
|
61
|
+
}
|
|
62
|
+
onLog(listener, replay = true) {
|
|
63
|
+
this.listeners.push(listener);
|
|
64
|
+
if (replay) {
|
|
65
|
+
const recent = this.getRecent(this.maxBuffer);
|
|
66
|
+
if (recent.length)
|
|
67
|
+
listener(recent);
|
|
68
|
+
}
|
|
69
|
+
return () => {
|
|
70
|
+
const idx = this.listeners.indexOf(listener);
|
|
71
|
+
if (idx >= 0)
|
|
72
|
+
this.listeners.splice(idx, 1);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
getRecent(limit = 200) {
|
|
76
|
+
const n = Math.min(Math.max(1, limit | 0), this.size);
|
|
77
|
+
const out = [];
|
|
78
|
+
if (n <= 0)
|
|
79
|
+
return out;
|
|
80
|
+
const start = (this.head - this.size + this.maxBuffer) % this.maxBuffer;
|
|
81
|
+
const begin = (this.head - n + this.maxBuffer) % this.maxBuffer;
|
|
82
|
+
let i = begin;
|
|
83
|
+
for (let k = 0; k < n; k++) {
|
|
84
|
+
const it = this.buffer[i];
|
|
85
|
+
if (it)
|
|
86
|
+
out.push(it);
|
|
87
|
+
i = (i + 1) % this.maxBuffer;
|
|
88
|
+
}
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
clear() {
|
|
92
|
+
this.buffer = new Array(this.maxBuffer);
|
|
93
|
+
this.head = 0;
|
|
94
|
+
this.size = 0;
|
|
95
|
+
this.pending.length = 0;
|
|
96
|
+
this.emitBatch([]);
|
|
97
|
+
}
|
|
98
|
+
safeStringify(v) {
|
|
99
|
+
try {
|
|
100
|
+
return JSON.stringify(v);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
try {
|
|
104
|
+
return String(v);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return "[Unstringifiable]";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
formatArgs(args) {
|
|
112
|
+
if (!args || args.length === 0)
|
|
113
|
+
return "";
|
|
114
|
+
if (args.length === 1 && typeof args[0] === "string")
|
|
115
|
+
return args[0];
|
|
116
|
+
let out = "";
|
|
117
|
+
for (let i = 0; i < args.length; i++) {
|
|
118
|
+
const a = args[i];
|
|
119
|
+
let s;
|
|
120
|
+
if (typeof a === "string")
|
|
121
|
+
s = a;
|
|
122
|
+
else if (a == null)
|
|
123
|
+
s = String(a);
|
|
124
|
+
else if (typeof a === "number" ||
|
|
125
|
+
typeof a === "boolean" ||
|
|
126
|
+
typeof a === "bigint")
|
|
127
|
+
s = String(a);
|
|
128
|
+
else if (a instanceof Error)
|
|
129
|
+
s = a.stack || a.message || String(a);
|
|
130
|
+
else
|
|
131
|
+
s = this.safeStringify(a);
|
|
132
|
+
if (i === 0)
|
|
133
|
+
out = s;
|
|
134
|
+
else
|
|
135
|
+
out += " " + s;
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
_log(level, ...args) {
|
|
140
|
+
if (this.levelPriority[level] < this.levelPriority[this.currentLevel])
|
|
141
|
+
return;
|
|
142
|
+
const msg = this.formatArgs(args);
|
|
143
|
+
const item = {
|
|
144
|
+
ts: Date.now(),
|
|
145
|
+
level,
|
|
146
|
+
message: msg,
|
|
147
|
+
};
|
|
148
|
+
const formatted = `[${level.toUpperCase()} ${new Date(item.ts).toTimeString().substring(0, 8)}] ${msg}`;
|
|
149
|
+
console.log(formatted);
|
|
150
|
+
this.pushToBuffer(item);
|
|
151
|
+
this.pending.push(item);
|
|
152
|
+
this.scheduleFlush();
|
|
153
|
+
}
|
|
154
|
+
pushToBuffer(item) {
|
|
155
|
+
this.buffer[this.head] = item;
|
|
156
|
+
this.head = (this.head + 1) % this.maxBuffer;
|
|
157
|
+
if (this.size < this.maxBuffer)
|
|
158
|
+
this.size++;
|
|
159
|
+
}
|
|
160
|
+
scheduleFlush() {
|
|
161
|
+
if (this.flushTimer)
|
|
162
|
+
return;
|
|
163
|
+
this.flushTimer = setTimeout(() => {
|
|
164
|
+
this.flushTimer = null;
|
|
165
|
+
const batch = this.pending;
|
|
166
|
+
this.pending = [];
|
|
167
|
+
this.emitBatch(batch);
|
|
168
|
+
}, this.flushIntervalMs);
|
|
169
|
+
}
|
|
170
|
+
emitBatch(items) {
|
|
171
|
+
if (!this.listeners.length)
|
|
172
|
+
return;
|
|
173
|
+
for (let i = 0; i < this.listeners.length; i++) {
|
|
174
|
+
const fn = this.listeners[i];
|
|
175
|
+
try {
|
|
176
|
+
fn(items);
|
|
177
|
+
}
|
|
178
|
+
catch { }
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
exports.Logger = Logger;
|
|
183
|
+
Logger._instance = null;
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function windowToLogical(wx: number, wy: number, sw: number, sh: number, w: number, h: number): {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
};
|
|
5
|
+
export declare function logicalToWindow(lx: number, ly: number, sw: number, sh: number, w: number, h: number): {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.windowToLogical = windowToLogical;
|
|
4
|
+
exports.logicalToWindow = logicalToWindow;
|
|
5
|
+
function windowToLogical(wx, wy, sw, sh, w, h) {
|
|
6
|
+
return {
|
|
7
|
+
x: Math.round(wx + (sw - w) / 2),
|
|
8
|
+
y: Math.round(wy + (sh - h) / 2),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function logicalToWindow(lx, ly, sw, sh, w, h) {
|
|
12
|
+
return {
|
|
13
|
+
x: Math.round(lx - (sw - w) / 2),
|
|
14
|
+
y: Math.round(ly - (sh - h) / 2),
|
|
15
|
+
};
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "frida-float-menu",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "借助frida调用Java Api绘制悬浮窗组件",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"private": false,
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"main": "lib/index.js",
|
|
9
|
+
"types": "lib/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"lib",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build:lib": "tsc",
|
|
16
|
+
"build:example": "frida-compile example.ts -o example.js",
|
|
17
|
+
"prepublishOnly": "npm run build:lib",
|
|
18
|
+
"dev": "frida-compile example.ts -o example.js -w",
|
|
19
|
+
"frida": "frida -UF -l example.js",
|
|
20
|
+
"check": "tsc --noEmit"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"frida",
|
|
24
|
+
"android",
|
|
25
|
+
"ui",
|
|
26
|
+
"floating-window",
|
|
27
|
+
"overlay",
|
|
28
|
+
"hooking"
|
|
29
|
+
],
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/frida-gum": "^18.3.1",
|
|
32
|
+
"@types/node": "^18.14.0",
|
|
33
|
+
"frida-compile": "^19.0.4",
|
|
34
|
+
"typescript": "^5.0.0"
|
|
35
|
+
}
|
|
36
|
+
}
|