ms-types 0.11.6 → 0.11.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-types",
3
- "version": "0.11.6",
3
+ "version": "0.11.8",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "types": "./types/index.d.ts",
@@ -2,24 +2,34 @@
2
2
 
3
3
  // IDEA 没有 typescriptServerPlugins,用 `-r` 预加载:在 JetBrains 的 tsc-ide-plugin 创建项目时,
4
4
  // 对快点JS项目调用 index.cjs 的 inject。tsserver 进程是所有工程共用的,所以要先判断是不是快点JS项目:
5
- // 从项目目录往上找快点JS项目:目录下有 package.json 和 scripts。和 ms-vite-plugin 的
6
- // isValidKuaiJSProject 同一条规则,不看 package.json 的内容;VS Code / IDEA 插件的项目识别也是这条。
5
+ // 从项目目录往上找快点JS项目:目录下有 package.json,并且 scripts 里有入口文件
6
+ // (main.js / main.ts / main.py / main.lua 之一)。不看 package.json 的内容。
7
+ // VS Code / IDEA 插件的项目识别也是这条规则,要一起改。
7
8
  const fs = require('fs');
8
9
  const path = require('path');
9
10
  const Module = require('module');
10
11
  const { inject } = require('./index.cjs');
11
12
 
13
+ const MAIN_SCRIPT_BASENAMES = ['main.js', 'main.ts', 'main.py', 'main.lua'];
12
14
  const MAX_ASCEND = 4;
13
15
  const projectCache = new Map();
14
16
 
15
- function hasKuaiJsPackage(dir) {
17
+ // 路径存在并且是文件(同名目录不算)。
18
+ function isFile(file) {
16
19
  try {
17
- return fs.existsSync(path.join(dir, 'package.json')) && fs.existsSync(path.join(dir, 'scripts'));
20
+ return fs.statSync(file).isFile();
18
21
  } catch (ignored) {
19
22
  return false;
20
23
  }
21
24
  }
22
25
 
26
+ function hasKuaiJsPackage(dir) {
27
+ return (
28
+ isFile(path.join(dir, 'package.json')) &&
29
+ MAIN_SCRIPT_BASENAMES.some((name) => isFile(path.join(dir, 'scripts', name)))
30
+ );
31
+ }
32
+
23
33
  function isKuaiJsProject(info) {
24
34
  let dir;
25
35
  try {
package/types/global.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
- * 运行模式
2
+ * 运行模式。`"agent"`、`"hid"` 或 `"pair"`;`"pair"` 仅 iOS 18 及以上可选。
3
3
  */
4
- declare const __runMode__: "agent" | "hid";
4
+ declare const __runMode__: "agent" | "hid" | "pair";
5
5
  /**
6
6
  * 是否是调试模式
7
7
  */
@@ -4,9 +4,9 @@
4
4
  ---@type boolean
5
5
  IsDebug = false
6
6
 
7
- --- 运行模式:"agent" 或 "hid"
8
- ---@type string
9
- RunMode = ''
7
+ --- 运行模式:`"agent"`、`"hid"` 或 `"pair"`;`"pair"` 仅 iOS 18 及以上可选
8
+ ---@type "agent"|"hid"|"pair"
9
+ RunMode = 'agent'
10
10
 
11
11
  --- 免越狱包为 `"ios"`,越狱包为 `"ios_jb"`
12
12
  ---@type "ios"|"ios_jb"
@@ -8,9 +8,9 @@ declare type 字典<T> = Record<字符串, T>;
8
8
  declare type 无返回值 = void;
9
9
 
10
10
  /**
11
- * 运行模式
11
+ * 运行模式。`"agent"`、`"hid"` 或 `"pair"`;`"pair"` 仅 iOS 18 及以上可选。
12
12
  */
13
- declare const $运行模式: "agent" | "hid";
13
+ declare const $运行模式: "agent" | "hid" | "pair";
14
14
  /**
15
15
  * 是否是调试模式
16
16
  */