@livedesk/client 0.1.214 → 0.1.215

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": "@livedesk/client",
3
- "version": "0.1.214",
3
+ "version": "0.1.215",
4
4
  "description": "LiveDesk local remote client",
5
5
  "type": "module",
6
6
  "bin": {
@@ -165,6 +165,12 @@ function readCpuTotals() {
165
165
  }
166
166
 
167
167
  function finiteNumber(value) {
168
+ if (value === null
169
+ || value === undefined
170
+ || typeof value === 'boolean'
171
+ || (typeof value === 'string' && value.trim() === '')) {
172
+ return null;
173
+ }
168
174
  const number = Number(value);
169
175
  return Number.isFinite(number) && number >= 0 ? number : null;
170
176
  }
@@ -300,6 +306,53 @@ function normalizeGpu(value) {
300
306
  };
301
307
  }
302
308
 
309
+ export function normalizeGpuIdentityName(value) {
310
+ return normalizeString(value, 160)
311
+ .normalize('NFKC')
312
+ .replace(/\((?:r|tm)\)/giu, '')
313
+ .replace(/[®™]/gu, '')
314
+ .toLocaleLowerCase('en-US')
315
+ .replace(/[^\p{L}\p{N}]+/gu, ' ')
316
+ .trim();
317
+ }
318
+
319
+ export function mergeGpuSnapshots(platformGpus = [], telemetryGpus = []) {
320
+ const merged = [];
321
+ const indexesByIdentity = new Map();
322
+ for (const value of Array.isArray(platformGpus) ? platformGpus : []) {
323
+ const gpu = normalizeGpu(value);
324
+ const identity = normalizeGpuIdentityName(gpu?.name);
325
+ if (!gpu || !identity) continue;
326
+ const index = merged.length;
327
+ merged.push(gpu);
328
+ const indexes = indexesByIdentity.get(identity) || [];
329
+ indexes.push(index);
330
+ indexesByIdentity.set(identity, indexes);
331
+ }
332
+
333
+ const matchedIndexes = new Set();
334
+ for (const value of Array.isArray(telemetryGpus) ? telemetryGpus : []) {
335
+ const gpu = normalizeGpu(value);
336
+ const identity = normalizeGpuIdentityName(gpu?.name);
337
+ if (!gpu || !identity) continue;
338
+ const existingIndex = (indexesByIdentity.get(identity) || [])
339
+ .find(index => !matchedIndexes.has(index));
340
+ if (existingIndex === undefined) {
341
+ merged.push(gpu);
342
+ continue;
343
+ }
344
+ matchedIndexes.add(existingIndex);
345
+ const existing = merged[existingIndex];
346
+ merged[existingIndex] = {
347
+ ...existing,
348
+ usagePercent: gpu.usagePercent ?? existing.usagePercent,
349
+ memoryTotalBytes: gpu.memoryTotalBytes ?? existing.memoryTotalBytes,
350
+ memoryUsedBytes: gpu.memoryUsedBytes ?? existing.memoryUsedBytes
351
+ };
352
+ }
353
+ return merged;
354
+ }
355
+
303
356
  function normalizeDisk(value) {
304
357
  if (!value || typeof value !== 'object') return null;
305
358
  const mount = normalizeString(value.mount, 80);
@@ -430,7 +483,10 @@ async function collectHardwareSnapshot() {
430
483
 
431
484
  const nvidiaGpus = await nvidiaPromise;
432
485
  return {
433
- gpus: nvidiaGpus.length > 0 ? nvidiaGpus : platformSnapshot.gpus,
486
+ // Preserve the platform adapter inventory on hybrid-GPU computers. The
487
+ // NVIDIA sampler enriches its matching adapter instead of replacing every
488
+ // non-NVIDIA display adapter with the telemetry subset.
489
+ gpus: mergeGpuSnapshots(platformSnapshot.gpus, nvidiaGpus),
434
490
  disks: platformSnapshot.disks,
435
491
  collectedAt: new Date().toISOString()
436
492
  };
@@ -730,7 +786,11 @@ export function createClientRuntimeServer(options = {}) {
730
786
  try {
731
787
  const gpus = await collectNvidiaGpuSnapshot();
732
788
  if (gpus.length > 0) {
733
- hardwareSnapshot = { ...hardwareSnapshot, gpus, collectedAt: new Date().toISOString() };
789
+ hardwareSnapshot = {
790
+ ...hardwareSnapshot,
791
+ gpus: mergeGpuSnapshots(hardwareSnapshot.gpus, gpus),
792
+ collectedAt: new Date().toISOString()
793
+ };
734
794
  }
735
795
  } finally {
736
796
  gpuRefreshInFlight = false;