node-nim 10.10.1-beta.88 → 10.10.1

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": "node-nim",
3
- "version": "10.10.1-beta.88",
3
+ "version": "10.10.1",
4
4
  "description": "NetEase IM nodejs wrapper based on NetEase IM C++ SDK",
5
5
  "main": "dist/node-nim.js",
6
6
  "bin": {
@@ -6,9 +6,16 @@ const decompress = require('decompress')
6
6
 
7
7
  // Global variables
8
8
  const default_arch = 'universal'
9
+ const supportedPackageArchByPlatform = {
10
+ darwin: ['universal', 'arm64', 'x64'],
11
+ win32: ['ia32', 'x64'],
12
+ linux: ['arm64', 'x64'],
13
+ ohos: ['arm64']
14
+ }
9
15
  const platform = normalizePlatform(process.env.npm_config_platform || process.platform)
10
- const current_arch = normalizeArch(process.env.npm_config_arch || (platform === 'ohos' ? 'arm64' : process.arch))
11
- const arch = platform === 'darwin' ? default_arch : current_arch
16
+ const configured_arch = process.env.npm_config_arch
17
+ const current_arch = configured_arch || getRuntimeArch(platform)
18
+ const arch = resolvePackageArch(platform, current_arch, platform === 'darwin' && !configured_arch)
12
19
  const channel = 'message'
13
20
  const product = 'nim'
14
21
  const savePath = path.join(__dirname, '..', 'temporary')
@@ -356,10 +363,17 @@ function platformAliases(nodePlatform) {
356
363
  }
357
364
 
358
365
  function archAliases(nodeArch) {
359
- if (normalizeArch(nodeArch) === 'arm64') {
360
- return ['arm64', 'arm64-v8a', 'arm64_v8a']
366
+ const arch = normalizeArch(nodeArch)
367
+ if (arch === 'arm64') {
368
+ return ['arm64', 'arm64-v8a', 'arm64_v8a', 'aarch64']
369
+ }
370
+ if (arch === 'x64') {
371
+ return ['x64', 'x86_64', 'amd64']
372
+ }
373
+ if (arch === 'ia32') {
374
+ return ['ia32', 'x86', 'i386', 'i686']
361
375
  }
362
- return [nodeArch]
376
+ return [arch]
363
377
  }
364
378
 
365
379
  function normalizePlatform(nodePlatform) {
@@ -370,12 +384,40 @@ function normalizePlatform(nodePlatform) {
370
384
  }
371
385
 
372
386
  function normalizeArch(nodeArch) {
373
- if (['arm64-v8a', 'arm64_v8a'].includes(nodeArch)) {
387
+ if (['arm64-v8a', 'arm64_v8a', 'aarch64'].includes(nodeArch)) {
374
388
  return 'arm64'
375
389
  }
390
+ if (['x86_64', 'amd64'].includes(nodeArch)) {
391
+ return 'x64'
392
+ }
393
+ if (['x86', 'i386', 'i686'].includes(nodeArch)) {
394
+ return 'ia32'
395
+ }
376
396
  return nodeArch
377
397
  }
378
398
 
399
+ function getRuntimeArch(nodePlatform) {
400
+ return normalizePlatform(nodePlatform) === 'ohos' ? 'arm64' : process.arch
401
+ }
402
+
403
+ function getSupportedArchList(nodePlatform) {
404
+ nodePlatform = normalizePlatform(nodePlatform)
405
+ if (!Object.prototype.hasOwnProperty.call(supportedPackageArchByPlatform, nodePlatform)) {
406
+ throw new Error(`Unsupported platform ${nodePlatform}`)
407
+ }
408
+ return supportedPackageArchByPlatform[nodePlatform]
409
+ }
410
+
411
+ function resolvePackageArch(nodePlatform, nodeArch, preferUniversal) {
412
+ nodePlatform = normalizePlatform(nodePlatform)
413
+ const arch = preferUniversal ? default_arch : normalizeArch(nodeArch)
414
+ const supportedArchList = getSupportedArchList(nodePlatform)
415
+ if (!supportedArchList.includes(arch)) {
416
+ throw new Error(`Unsupported arch ${nodeArch} for ${nodePlatform}. Supported arch: ${supportedArchList.join(', ')}`)
417
+ }
418
+ return arch
419
+ }
420
+
379
421
  // Parse directory listing from HTTP server
380
422
  async function parseDirectoryListing(url) {
381
423
  try {
@@ -444,9 +486,7 @@ async function findLatestBuildWithPackage(baseUrl, branch, nodePlatform, nodeArc
444
486
  // Map Node.js platform/arch to SDK directory format
445
487
  function getPlatformArchDir(nodePlatform, nodeArch) {
446
488
  nodePlatform = normalizePlatform(nodePlatform)
447
- nodeArch = normalizeArch(nodeArch)
448
- // Normalize arch - default to x64 if not arm64
449
- const arch = nodeArch === 'arm64' ? 'arm64' : (nodeArch === 'ia32' ? 'ia32' : 'x64')
489
+ const arch = resolvePackageArch(nodePlatform, nodeArch, false)
450
490
  // For win32, include multi-threaded suffix
451
491
  if (nodePlatform === 'win32') {
452
492
  return `win32-${arch}-multi-threaded/`
@@ -491,6 +531,25 @@ async function findPackage(buildUrl, nodePlatform, nodeArch) {
491
531
  return `${fullUrl}${packageFile}`
492
532
  }
493
533
 
534
+ // Find latest version from release directory (e.g., 10.10.1 from release/10.10.1/)
535
+ async function findLatestReleaseVersion(baseUrl) {
536
+ const releaseUrl = `${baseUrl}release/`
537
+ log(` 🔍 Searching for latest version in ${releaseUrl}`)
538
+ const items = await parseDirectoryListing(releaseUrl)
539
+
540
+ const versions = items
541
+ .filter(item => item.endsWith('/'))
542
+ .map(item => item.replace('/', ''))
543
+ .filter(v => /^\d+\.\d+\.\d+/.test(v))
544
+ .sort((a, b) => compareVersions.compare(b, a))
545
+
546
+ if (versions.length === 0) {
547
+ throw new Error(`No version directories found in ${releaseUrl}`)
548
+ }
549
+ log(` ✅ Found latest version: ${versions[0]}`)
550
+ return versions[0]
551
+ }
552
+
494
553
  // Build package URL from branch name
495
554
  async function buildPackageUrlFromBranch(branch, nodePlatform, nodeArch) {
496
555
  // Base64 encoded internal server URL (decode when needed)
@@ -498,9 +557,16 @@ async function buildPackageUrlFromBranch(branch, nodePlatform, nodeArch) {
498
557
  const baseUrl = Buffer.from(encodedBaseUrl, 'base64').toString('utf-8')
499
558
  log(` 🌿 Resolving package URL for branch: ${branch}`)
500
559
 
560
+ let effectiveBranch = branch
561
+ if (branch === 'beta') {
562
+ const latestVersion = await findLatestReleaseVersion(baseUrl)
563
+ effectiveBranch = `release/${latestVersion}`
564
+ log(` 📦 Beta channel: using latest release version ${latestVersion}`)
565
+ }
566
+
501
567
  // Find latest build that contains the requested platform package
502
568
  // This will automatically fallback to previous builds if the latest doesn't have the package
503
- const { buildNumber, packageUrl } = await findLatestBuildWithPackage(baseUrl, branch, nodePlatform, nodeArch)
569
+ const { buildNumber, packageUrl } = await findLatestBuildWithPackage(baseUrl, effectiveBranch, nodePlatform, nodeArch)
504
570
 
505
571
  return packageUrl
506
572
  }
@@ -538,3 +604,7 @@ if (require.main === module) {
538
604
  })()
539
605
  }
540
606
  exports.downloadSDK = downloadSDK
607
+ exports.normalizeArch = normalizeArch
608
+ exports.resolvePackageArch = resolvePackageArch
609
+ exports.getPlatformArchDir = getPlatformArchDir
610
+ exports.getSupportedArchList = getSupportedArchList
@@ -357,6 +357,28 @@ function isSemverCore(version) {
357
357
  return /^\d+\.\d+\.\d+$/.test(version)
358
358
  }
359
359
 
360
+ function resolveSdkDisplayVersion(sdkVersion) {
361
+ const sdkDisplayVersions = {
362
+ 17: '5.0.5(17)'
363
+ }
364
+ return sdkDisplayVersions[sdkVersion] || sdkVersion
365
+ }
366
+
367
+ function resolveSdkApiVersion(sdkVersion) {
368
+ const value = String(sdkVersion).trim()
369
+ const displayMatch = value.match(/\((\d+)\)$/)
370
+ if (displayMatch) {
371
+ return displayMatch[1]
372
+ }
373
+ if (/^\d+$/.test(value)) {
374
+ return value
375
+ }
376
+ if (!value) {
377
+ throw new Error(`Invalid OHOS SDK version: ${sdkVersion}`)
378
+ }
379
+ throw new Error(`OHOS SDK version must be an API level, got: ${sdkVersion}`)
380
+ }
381
+
360
382
  function getPackageVersion() {
361
383
  const gitTag = runGit(['describe', '--abbrev=0', '--tags', '--exact-match'])
362
384
  const gitBranch = runGit(['rev-parse', '--abbrev-ref', 'HEAD'])
@@ -421,9 +443,11 @@ function main() {
421
443
  throw new Error('Missing required argument: --ohos-install-dir')
422
444
  }
423
445
  const version = getPackageVersion()
424
- const sdkVersion = args.sdkVersion || process.env.OHPM_SDK_VERSION || '20'
446
+ const sdkVersion = args.sdkVersion || process.env.OHPM_SDK_VERSION || '17'
447
+ const sdkApiVersion = resolveSdkApiVersion(sdkVersion)
448
+ const sdkDisplayVersion = resolveSdkDisplayVersion(sdkVersion)
425
449
  const tools = resolvePackagingTools({
426
- sdkVersion,
450
+ sdkVersion: sdkApiVersion,
427
451
  skipNpmInstall: args.skipNpmInstall
428
452
  })
429
453
 
@@ -443,7 +467,8 @@ function main() {
443
467
  const nativeTypePackage = 'libnode-nim.so'
444
468
 
445
469
  console.log(`[node-nim][ohpm] Package version: ${version}`)
446
- console.log(`[node-nim][ohpm] OHOS SDK version: ${sdkVersion}`)
470
+ console.log(`[node-nim][ohpm] OHOS SDK version: ${sdkApiVersion}`)
471
+ console.log(`[node-nim][ohpm] OHOS SDK display version: ${sdkDisplayVersion}`)
447
472
  console.log(`[node-nim][ohpm] OHOS install directory: ${ohosInstallDir}`)
448
473
  if (process.env.OHOS_NATIVE_HOME) {
449
474
  console.log(`[node-nim][ohpm] OHOS_NATIVE_HOME: ${process.env.OHOS_NATIVE_HOME}`)
@@ -510,7 +535,8 @@ function main() {
510
535
  const restoreProjectFiles = replaceInFilesWithRestore(projectDir, placeholderExt, (content) => {
511
536
  return content
512
537
  .replace(/\{\{VERSION\}\}/g, version)
513
- .replace(/\{\{OHOS_SDK_VERSION\}\}/g, sdkVersion)
538
+ .replace(/"\{\{OHOS_SDK_VERSION\}\}"/g, sdkApiVersion)
539
+ .replace(/\{\{OHOS_SDK_VERSION\}\}/g, sdkApiVersion)
514
540
  })
515
541
 
516
542
  try {