autoglm.js 0.0.7 → 0.0.9

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.
Files changed (2) hide show
  1. package/dist/index.mjs +17 -9
  2. package/package.json +5 -4
package/dist/index.mjs CHANGED
@@ -1209,6 +1209,12 @@ function parseAction(actionStr) {
1209
1209
  };
1210
1210
  }
1211
1211
  if (actionStr.startsWith("do(")) {
1212
+ const typeMatch = actionStr.match(/do\(action="Type",\s*text=(.*)\)/s);
1213
+ if (typeMatch) return {
1214
+ _metadata: "do",
1215
+ action: "Type",
1216
+ text: parseQuotedString(typeMatch[1].trim()).trim()
1217
+ };
1212
1218
  const ast = parse(actionStr, { ecmaVersion: "latest" });
1213
1219
  if (ast.body[0].type !== "DoWhileStatement") throw new Error(`Invalid action format: ${actionStr}`);
1214
1220
  const expression = ast.body[0].body.expression;
@@ -1231,15 +1237,6 @@ function parseAction(actionStr) {
1231
1237
  element
1232
1238
  };
1233
1239
  }
1234
- if (actionType === "Type") {
1235
- const text = getText(expression);
1236
- if (!text) throw new Error(`Invalid Type action parameters: ${actionStr}`);
1237
- return {
1238
- _metadata: "do",
1239
- action: "Type",
1240
- text: text.trim()
1241
- };
1242
- }
1243
1240
  if (actionType === "Swipe") {
1244
1241
  const start = getElements(expression, 1);
1245
1242
  const end = getElements(expression, 2);
@@ -1298,6 +1295,17 @@ function parseAction(actionStr) {
1298
1295
  }
1299
1296
  throw new Error(`Unknown action format: ${actionStr}`);
1300
1297
  }
1298
+ /**
1299
+ * Parse a quoted string that may contain newlines and escape sequences.
1300
+ * Handles both single and double quotes.
1301
+ */
1302
+ function parseQuotedString(str) {
1303
+ if (!str) return "";
1304
+ const firstChar = str[0];
1305
+ const lastChar = str[str.length - 1];
1306
+ if (firstChar === "\"" && lastChar === "\"" || firstChar === "'" && lastChar === "'") return str.slice(1, -1);
1307
+ return str;
1308
+ }
1301
1309
 
1302
1310
  //#endregion
1303
1311
  //#region src/adb/types.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "autoglm.js",
3
3
  "type": "module",
4
- "version": "0.0.7",
4
+ "version": "0.0.9",
5
5
  "private": false,
6
6
  "description": "AutoGLM.js is a JavaScript library for Open-AutoGLM",
7
7
  "author": "FliPPeDround <flippedround@qq.com>",
@@ -44,13 +44,14 @@
44
44
  "openai": "^6.10.0",
45
45
  "sharp": "^0.34.5",
46
46
  "std-env": "^3.10.0",
47
- "tinyexec": "^1.0.2"
47
+ "tinyexec": "^1.0.2",
48
+ "unzipper": "^0.12.3"
48
49
  },
49
50
  "optionalDependencies": {
51
+ "@autoglm.js/platform-tools-darwin": "36.0.0",
50
52
  "@autoglm.js/adb-keyboard": "0.0.1",
51
53
  "@autoglm.js/platform-tools-linux": "36.0.0",
52
- "@autoglm.js/platform-tools-windows": "36.0.0",
53
- "@autoglm.js/platform-tools-darwin": "36.0.0"
54
+ "@autoglm.js/platform-tools-windows": "36.0.0"
54
55
  },
55
56
  "devDependencies": {
56
57
  "@types/fs-extra": "^11.0.4",