@flun/nodejs-mobile-gyp 1.1.2 → 1.1.4

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 (79) hide show
  1. package/CHANGELOG.md +10 -75
  2. package/LICENSE +9 -4
  3. package/README.md +198 -132
  4. package/addon.gypi +1 -1
  5. package/bin/node-gyp.js +6 -5
  6. package/gyp/README.md +5 -3
  7. package/gyp/data/win/large-pdb-shim.cc +1 -1
  8. package/gyp/gyp +1 -1
  9. package/gyp/gyp.bat +1 -1
  10. package/gyp/gyp_main.py +1 -1
  11. package/gyp/pylib/gyp/MSVSNew.py +1 -1
  12. package/gyp/pylib/gyp/MSVSProject.py +1 -1
  13. package/gyp/pylib/gyp/MSVSSettings.py +1 -1
  14. package/gyp/pylib/gyp/MSVSToolFile.py +1 -1
  15. package/gyp/pylib/gyp/MSVSUserFile.py +1 -1
  16. package/gyp/pylib/gyp/MSVSUtil.py +1 -1
  17. package/gyp/pylib/gyp/MSVSVersion.py +1 -1
  18. package/gyp/pylib/gyp/__init__.py +1 -1
  19. package/gyp/pylib/gyp/common.py +1 -1
  20. package/gyp/pylib/gyp/easy_xml.py +1 -1
  21. package/gyp/pylib/gyp/flock_tool.py +1 -1
  22. package/gyp/pylib/gyp/generator/analyzer.py +1 -1
  23. package/gyp/pylib/gyp/generator/android.py +1 -1
  24. package/gyp/pylib/gyp/generator/cmake.py +1 -1
  25. package/gyp/pylib/gyp/generator/compile_commands_json.py +1 -1
  26. package/gyp/pylib/gyp/generator/dump_dependency_json.py +1 -1
  27. package/gyp/pylib/gyp/generator/eclipse.py +1 -1
  28. package/gyp/pylib/gyp/generator/gypd.py +1 -1
  29. package/gyp/pylib/gyp/generator/gypsh.py +1 -1
  30. package/gyp/pylib/gyp/generator/make.py +23 -12
  31. package/gyp/pylib/gyp/generator/msvs.py +3 -3
  32. package/gyp/pylib/gyp/generator/ninja.py +1 -1
  33. package/gyp/pylib/gyp/generator/xcode.py +1 -1
  34. package/gyp/pylib/gyp/input.py +1 -1
  35. package/gyp/pylib/gyp/mac_tool.py +1 -1
  36. package/gyp/pylib/gyp/msvs_emulation.py +1 -1
  37. package/gyp/pylib/gyp/ninja_syntax.py +1 -1
  38. package/gyp/pylib/gyp/simple_copy.py +1 -1
  39. package/gyp/pylib/gyp/win_tool.py +1 -1
  40. package/gyp/pylib/gyp/xcode_emulation.py +5 -5
  41. package/gyp/pylib/gyp/xcode_ninja.py +1 -1
  42. package/gyp/pylib/gyp/xcodeproj_file.py +1 -1
  43. package/gyp/pylib/gyp/xml_fix.py +1 -1
  44. package/gyp/pylib/packaging/LICENSE +1 -1
  45. package/gyp/pylib/packaging/LICENSE.APACHE +1 -1
  46. package/gyp/pylib/packaging/LICENSE.BSD +1 -1
  47. package/gyp/pylib/packaging/__init__.py +1 -1
  48. package/gyp/pylib/packaging/_elffile.py +1 -1
  49. package/gyp/pylib/packaging/_manylinux.py +1 -1
  50. package/gyp/pylib/packaging/_musllinux.py +1 -1
  51. package/gyp/pylib/packaging/_parser.py +1 -1
  52. package/gyp/pylib/packaging/_structures.py +1 -1
  53. package/gyp/pylib/packaging/_tokenizer.py +1 -1
  54. package/gyp/pylib/packaging/markers.py +1 -1
  55. package/gyp/pylib/packaging/metadata.py +1 -1
  56. package/gyp/pylib/packaging/requirements.py +1 -1
  57. package/gyp/pylib/packaging/specifiers.py +1 -1
  58. package/gyp/pylib/packaging/tags.py +1 -1
  59. package/gyp/pylib/packaging/utils.py +1 -1
  60. package/gyp/pylib/packaging/version.py +1 -1
  61. package/lib/Find-VisualStudio.cs +1 -1
  62. package/lib/build.js +16 -16
  63. package/lib/clean.js +2 -2
  64. package/lib/configure.js +20 -17
  65. package/lib/create-config-gypi.js +8 -8
  66. package/lib/download.js +3 -3
  67. package/lib/find-node-directory.js +9 -9
  68. package/lib/find-python.js +14 -14
  69. package/lib/find-visualstudio.js +19 -19
  70. package/lib/install.js +22 -21
  71. package/lib/list.js +1 -1
  72. package/lib/log.js +2 -2
  73. package/lib/node-gyp.js +7 -7
  74. package/lib/process-release.js +14 -14
  75. package/lib/rebuild.js +1 -1
  76. package/lib/remove.js +2 -2
  77. package/lib/util.js +5 -4
  78. package/package.json +3 -3
  79. package/src/win_delay_load_hook.cc +1 -1
package/lib/node-gyp.js CHANGED
@@ -15,11 +15,11 @@ import { list } from './list.js';
15
15
  import { remove } from './remove.js';
16
16
 
17
17
  const __dirname = path.dirname(fileURLToPath(import.meta.url)),
18
- // 命令名到实现函数的静态映射(ESM 不支持动态 require)
18
+ // 命令名到实现函数的静态映射(ESM 不支持动态 require)
19
19
  commandModules = { build, clean, configure, rebuild, install, list, remove }, commands = Object.keys(commandModules);
20
20
 
21
21
  /**
22
- * node-gyp 主类:解析参数、分发命令、生成 usage
22
+ * node-gyp 主类:解析参数、分发命令、生成 usage
23
23
  */
24
24
  class Gyp extends EventEmitter {
25
25
  /**
@@ -39,7 +39,7 @@ class Gyp extends EventEmitter {
39
39
  make: String, // 'build'
40
40
  'msvs-version': String, // 'configure'
41
41
  ensure: Boolean, // 'install'
42
- solution: String, // 'build'(仅 Windows)
42
+ solution: String, // 'build'(仅 Windows)
43
43
  proxy: String, // 'install'
44
44
  noproxy: String, // 'install'
45
45
  devdir: String, // 各处
@@ -83,7 +83,7 @@ class Gyp extends EventEmitter {
83
83
  }
84
84
 
85
85
  /**
86
- * 解析传入的 argv 数组,设置 'opts'、'argv' 和 'command' 属性
86
+ * 解析传入的 argv 数组,设置 'opts'、'argv' 和 'command' 属性
87
87
  */
88
88
  parseArgv(argv) {
89
89
  this.opts = nopt(this.configDefs, this.shorthands, argv), this.argv = this.opts.argv.remain.slice();
@@ -91,12 +91,12 @@ class Gyp extends EventEmitter {
91
91
  const commands = this.todo = [];
92
92
  // 创建一份把别名映射后的 argv 副本
93
93
  argv = this.argv.map(arg => {
94
- // 如果当前参数是命令别名(如 ls/rm),就替换成真实命令名
94
+ // 如果当前参数是命令别名(如 ls/rm),就替换成真实命令名
95
95
  if (arg in this.aliases) arg = this.aliases[arg];
96
96
  return arg
97
97
  })
98
98
 
99
- // 把映射后的参数处理成 "command" 对象(name 和 args 属性)
99
+ // 把映射后的参数处理成 "command" 对象(name 和 args 属性)
100
100
  argv.slice().forEach(arg => {
101
101
  if (arg in this.commands) {
102
102
  const args = argv.splice(0, argv.indexOf(arg));
@@ -115,7 +115,7 @@ class Gyp extends EventEmitter {
115
115
  if (name === npmConfigPrefix + 'loglevel') log.logger.level = val
116
116
  else {
117
117
  name = name.substring(npmConfigPrefix.length); // 把用户定义的选项加入配置
118
- // gyp@741b7f1 遇到零长度选项会死循环,确保过滤掉
118
+ // gyp@741b7f1 遇到零长度选项会死循环,确保过滤掉
119
119
  if (name) {
120
120
  // 把 force_process_config 这类名字转成 force-process-config
121
121
  if (name.includes('_')) name = name.replace(/_/g, '-');
@@ -4,7 +4,7 @@ import semver from 'semver';
4
4
  import path from 'path';
5
5
  import * as log from './log.js';
6
6
 
7
- // 开始发布 -headers.tar.gz 的版本(io.js v3.x.x 里用的是 "ia32",本应是 "x86")
7
+ // 开始发布 -headers.tar.gz 的版本(io.js v3.x.x 里用的是 "ia32",本应是 "x86")
8
8
  const headersTarballRange = '>= 3.0.0 || ~0.12.10 || ~0.10.42', bitsre = /\/win-(x86|x64|arm64)\//,
9
9
  bitsreV3 = /\/win-(x86|ia32|x64)\//, normalizePath = (p) => path.normalize(p).replace(/\\/g, '/'), // 统一分隔符为 /
10
10
  /**
@@ -17,16 +17,16 @@ const headersTarballRange = '>= 3.0.0 || ~0.12.10 || ~0.10.42', bitsre = /\/win-
17
17
  if (!hasLibUrl) {
18
18
  // 假设传入的是 baseUrl
19
19
  if (versionMajor >= 1) return new URL('win-' + arch + '/' + name + '.lib', base).href;
20
- // io.js@1.0.0 之前,32 位 node.lib 在根目录,64 位在 /x64/
20
+ // io.js@1.0.0 之前,32 位 node.lib 在根目录,64 位在 /x64/
21
21
  const prefix = arch === 'x86' ? '' : arch + '/';
22
22
  return new URL(prefix + name + '.lib', base).href;
23
23
  }
24
- // 否则传入的已经是 .lib 地址,只需保证架构正确
24
+ // 否则传入的已经是 .lib 地址,只需保证架构正确
25
25
  return defaultUrl.replace(versionMajor === 3 ? bitsreV3 : bitsre, '/win-' + arch + '/');
26
26
  },
27
27
  /**
28
- * 负责确定下载 URL、本地目录和文件名。
29
- * 输入来自命令行开关(--target、--dist-url)、process.version 和 process.release。
28
+ * 负责确定下载 URL、本地目录和文件名;
29
+ * 输入来自命令行开关(--target、--dist-url)、process.version 和 process.release;
30
30
  */
31
31
  processRelease = (argv, gyp, defaultVersion, defaultRelease) => {
32
32
  let version = (semver.valid(argv[0]) && argv[0]) || gyp.opts.target || defaultVersion
@@ -37,18 +37,18 @@ const headersTarballRange = '>= 3.0.0 || ~0.12.10 || ~0.10.42', bitsre = /\/win-
37
37
  if (!versionSemver) return { version }; // 如果 semver 不合法,那么原样返回 version
38
38
  version = versionSemver.version; // 把 version 拍平为字符串
39
39
 
40
- // defaultVersion 来自 process.version,应当是合法 semver
40
+ // defaultVersion 来自 process.version,应当是合法 semver
41
41
  const isDefaultVersion = version === semver.parse(defaultVersion).version;
42
42
  if (!isDefaultVersion) defaultRelease = null; // 用了 --target=x.y.z 就不能用 process.release
43
43
  if (defaultRelease) name = defaultRelease.name.replace(/io\.js/, 'iojs'); // 去掉 '.' 以便目录命名
44
44
  else {
45
45
  // 老版本 Node 或自定义 --target
46
- // semver.satisfies() 不支持预发布标签,因此直接判断主版本
46
+ // semver.satisfies() 不支持预发布标签,因此直接判断主版本
47
47
  isNamedForLegacyIojs = versionSemver.major >= 1 && versionSemver.major < 4;
48
- // isNamedForLegacyIojs 是为了支持 Electron < 4(特别是 Electron 3)
49
- // 早期逻辑用它保证 iojs 版本下载 "iojs",Node 版本下载 "node"。
50
- // 但该逻辑过宽,导致 electron@3 的发布物命名为 "iojs" 才能让 node-gyp 正常工作。
51
- // Electron@3 EOL 之后(2019 年底)应移除这个 hack。
48
+ // isNamedForLegacyIojs 是为了支持 Electron < 4(特别是 Electron 3)
49
+ // 早期逻辑用它保证 iojs 版本下载 "iojs",Node 版本下载 "node";
50
+ // 但该逻辑过宽,导致 electron@3 的发布物命名为 "iojs" 才能让 node-gyp 正常工作;
51
+ // Electron@3 EOL 之后(2019 年底)应移除这个 hack;
52
52
  name = isNamedForLegacyIojs ? 'iojs' : 'node';
53
53
  }
54
54
 
@@ -59,7 +59,7 @@ const headersTarballRange = '>= 3.0.0 || ~0.12.10 || ~0.10.42', bitsre = /\/win-
59
59
  else distBaseUrl = 'https://nodejs.org/dist';
60
60
  distBaseUrl += '/v' + version + '/'
61
61
 
62
- // 新式:基于 process.release,大部分数据已有
62
+ // 新式:基于 process.release,大部分数据已有
63
63
  if (defaultRelease?.headersUrl && !overrideDistUrl) {
64
64
  baseUrl = new URL('./', defaultRelease.headersUrl).href;
65
65
  libUrl32 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'x86', versionSemver.major);
@@ -67,14 +67,14 @@ const headersTarballRange = '>= 3.0.0 || ~0.12.10 || ~0.10.42', bitsre = /\/win-
67
67
  libUrlArm64 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'arm64', versionSemver.major);
68
68
  tarballUrl = defaultRelease.headersUrl;
69
69
  } else {
70
- // 没有 process.release 的老版本,需要做很多假设;
70
+ // 没有 process.release 的老版本,需要做很多假设;
71
71
  // 另外 --target=x.y.z 时也无法使用当前 process.release
72
72
  baseUrl = distBaseUrl;
73
73
  libUrl32 = resolveLibUrl(name, baseUrl, 'x86', versionSemver.major);
74
74
  libUrl64 = resolveLibUrl(name, baseUrl, 'x64', versionSemver.major);
75
75
  libUrlArm64 = resolveLibUrl(name, baseUrl, 'arm64', versionSemver.major);
76
76
 
77
- // 大胆假设:任何版本号 >3.0.0 的版本,其 dist 目录都有 *-headers.tar.gz
77
+ // 大胆假设:任何版本号 >3.0.0 的版本,其 dist 目录都有 *-headers.tar.gz
78
78
  canGetHeaders = semver.satisfies(versionSemver, headersTarballRange);
79
79
  tarballUrl = new URL(name + '-v' + version + (canGetHeaders ? '-headers' : '') + '.tar.gz', baseUrl).href;
80
80
  }
package/lib/rebuild.js CHANGED
@@ -6,4 +6,4 @@ const rebuild = async (gyp, argv) => {
6
6
  }
7
7
 
8
8
  rebuild.usage = 'Runs "clean", "configure" and "build" all at once';
9
- export { rebuild }
9
+ export { rebuild }
package/lib/remove.js CHANGED
@@ -14,7 +14,7 @@ const fs = gracefulFs.promises,
14
14
  // 获取用户指定的版本号
15
15
  let version = argv[0] || gyp.opts.target;
16
16
  log.verbose('remove', 'removing target version:', version);
17
- if (!version) throw new Error('必须指定要删除的版本号,例如: "' + process.version + '"');
17
+ if (!version) throw new Error('必须指定要删除的版本号,例如: "' + process.version + '"');
18
18
 
19
19
  const versionSemver = semver.parse(version);
20
20
  if (versionSemver) version = versionSemver.version; // 把版本数组拍平为字符串
@@ -34,4 +34,4 @@ const fs = gracefulFs.promises,
34
34
  }
35
35
 
36
36
  remove.usage = 'Removes the node development files for the specified version';
37
- export { remove }
37
+ export { remove }
package/lib/util.js CHANGED
@@ -16,7 +16,8 @@ const { openSync, closeSync } = gracefulFs,
16
16
  */
17
17
  regGetValue = async (key, value, addOpts) => {
18
18
  const outReValue = value.replace(/\W/g, '.'), outRe = new RegExp(`^\\s+${outReValue}\\s+REG_\\w+\\s+(\\S.*)$`, 'im'),
19
- reg = path.join(process.env.SystemRoot, 'System32', 'reg.exe'), regArgs = ['query', key, '/v', value].concat(addOpts);
19
+ reg = path.join(process.env.SystemRoot, 'System32', 'reg.exe'),
20
+ regArgs = ['query', key, '/v', value].concat(addOpts);
20
21
 
21
22
  log.silly('reg', 'running', reg, regArgs);
22
23
  const [err, stdout, stderr] = await execFile(reg, regArgs, { encoding: 'utf8' });
@@ -39,7 +40,7 @@ const { openSync, closeSync } = gracefulFs,
39
40
  return result[1];
40
41
  },
41
42
  /**
42
- * 依次搜索多个注册表键,返回第一个可读的值
43
+ * 依次搜索多个注册表键,返回第一个可读的值
43
44
  */
44
45
  regSearchKeys = async (keys, value, addOpts) => {
45
46
  for (const key of keys) {
@@ -49,7 +50,7 @@ const { openSync, closeSync } = gracefulFs,
49
50
  }
50
51
  },
51
52
  /**
52
- * 返回候选列表中第一个当前用户可读的文件或目录,都不存在则返回 undefined
53
+ * 返回候选列表中第一个当前用户可读的文件或目录,都不存在则返回 undefined
53
54
  */
54
55
  findAccessibleSync = (logprefix, dir, candidates) => {
55
56
  for (let next = 0; next < candidates.length; next++) {
@@ -58,7 +59,7 @@ const { openSync, closeSync } = gracefulFs,
58
59
  try {
59
60
  fd = openSync(candidate, 'r');
60
61
  } catch (e) {
61
- // 该候选文件不存在或不可读,继续检查下一个
62
+ // 该候选文件不存在或不可读,继续检查下一个
62
63
  log.silly(logprefix, 'Could not open %s: %s', candidate, e.message);
63
64
  continue;
64
65
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "bindings",
12
12
  "gyp"
13
13
  ],
14
- "version": "1.1.2",
14
+ "version": "1.1.4",
15
15
  "installVersion": 11,
16
16
  "author": "flun <open@flun.top>",
17
17
  "bin": {
@@ -54,9 +54,9 @@
54
54
  "node": true
55
55
  },
56
56
  "engines": {
57
- "node": "^22.22.2 || ^24.15.0 || >=26.0.0"
57
+ "node": ">=22.12.0"
58
58
  },
59
- "homepage": "https://github.com/OpenFlun/nodejs-mobile-gyp",
59
+ "homepage": "https://github.com/OpenFlun/nodejs-mobile-gyp#readme",
60
60
  "repository": {
61
61
  "type": "git",
62
62
  "url": "git+https://github.com/OpenFlun/nodejs-mobile-gyp.git"
@@ -36,4 +36,4 @@ decltype(__pfnDliNotifyHook2) __pfnDliNotifyHook2 = load_exe_hook;
36
36
 
37
37
  #pragma managed(pop)
38
38
 
39
- #endif
39
+ #endif