New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

node-labstreaminglayer

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-labstreaminglayer - npm Package Compare versions

Comparing version
0.2.0
to
0.2.1
+50
-3
dist/lib/index.js

@@ -16,2 +16,3 @@ /**

import { fileURLToPath } from 'url';
import { existsSync } from 'fs';
// Get the directory of this module for resolving library paths

@@ -27,4 +28,9 @@ const __dirname = dirname(fileURLToPath(import.meta.url));

*
* This function is Electron-aware and will check multiple paths including:
* - Standard path in node_modules
* - Unpacked path when in ASAR archive (Electron production)
* - Electron resources path
*
* @returns {string} Absolute path to the platform-specific LSL library
* @throws {Error} If the platform is not supported
* @throws {Error} If the platform is not supported or library cannot be found
*/

@@ -51,4 +57,45 @@ function getLibraryPath() {

}
// Resolve to prebuild directory containing platform binaries
return join(__dirname, '..', '..', 'prebuild', libName);
// Build list of possible paths to try
const possiblePaths = [];
// 1. Standard path (works in development and regular Node.js)
const standardPath = join(__dirname, '..', '..', 'prebuild', libName);
possiblePaths.push(standardPath);
// 2. Check if we're in an ASAR archive (Electron production)
if (standardPath.includes('app.asar')) {
// Try the unpacked version (where native modules must be extracted)
const unpackedPath = standardPath.replace('app.asar', 'app.asar.unpacked');
possiblePaths.push(unpackedPath);
}
// 3. Try Electron's resources path if available (production Electron)
// @ts-ignore - process.resourcesPath is an Electron-specific property
if (typeof process !== 'undefined' && process.resourcesPath) {
// @ts-ignore
const resourcesPath = process.resourcesPath;
possiblePaths.push(join(resourcesPath, 'app.asar.unpacked', 'node_modules', 'node-labstreaminglayer', 'prebuild', libName));
possiblePaths.push(join(resourcesPath, 'node_modules', 'node-labstreaminglayer', 'prebuild', libName));
}
// 4. Check for Electron app path
// @ts-ignore - global.app is an Electron-specific property
if (typeof global !== 'undefined' && global.app?.getPath) {
try {
// @ts-ignore
const appPath = global.app.getPath('exe');
const exeDir = dirname(appPath);
possiblePaths.push(join(exeDir, 'resources', 'app.asar.unpacked', 'node_modules', 'node-labstreaminglayer', 'prebuild', libName));
}
catch (e) {
// Ignore if not in Electron main process
}
}
// Find the first existing path
for (const path of possiblePaths) {
if (existsSync(path)) {
return path;
}
}
// If no path exists, throw an error with helpful information
throw new Error(`Failed to find LSL library '${libName}'. Searched paths:\n` +
possiblePaths.map(p => ` - ${p}`).join('\n') +
'\n\nFor Electron apps, ensure native modules are unpacked from ASAR.\n' +
'See: https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules');
}

@@ -55,0 +102,0 @@ // Load the LSL library using Koffi FFI

+1
-1
{
"name": "node-labstreaminglayer",
"version": "0.2.0",
"version": "0.2.1",
"description": "Node.js bindings for Lab Streaming Layer (LSL)",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -17,2 +17,3 @@ /**

import { fileURLToPath } from 'url';
import { existsSync } from 'fs';

@@ -30,4 +31,9 @@ // Get the directory of this module for resolving library paths

*
* This function is Electron-aware and will check multiple paths including:
* - Standard path in node_modules
* - Unpacked path when in ASAR archive (Electron production)
* - Electron resources path
*
* @returns {string} Absolute path to the platform-specific LSL library
* @throws {Error} If the platform is not supported
* @throws {Error} If the platform is not supported or library cannot be found
*/

@@ -53,4 +59,52 @@ function getLibraryPath(): string {

// Resolve to prebuild directory containing platform binaries
return join(__dirname, '..', '..', 'prebuild', libName);
// Build list of possible paths to try
const possiblePaths: string[] = [];
// 1. Standard path (works in development and regular Node.js)
const standardPath = join(__dirname, '..', '..', 'prebuild', libName);
possiblePaths.push(standardPath);
// 2. Check if we're in an ASAR archive (Electron production)
if (standardPath.includes('app.asar')) {
// Try the unpacked version (where native modules must be extracted)
const unpackedPath = standardPath.replace('app.asar', 'app.asar.unpacked');
possiblePaths.push(unpackedPath);
}
// 3. Try Electron's resources path if available (production Electron)
// @ts-ignore - process.resourcesPath is an Electron-specific property
if (typeof process !== 'undefined' && process.resourcesPath) {
// @ts-ignore
const resourcesPath = process.resourcesPath;
possiblePaths.push(join(resourcesPath, 'app.asar.unpacked', 'node_modules', 'node-labstreaminglayer', 'prebuild', libName));
possiblePaths.push(join(resourcesPath, 'node_modules', 'node-labstreaminglayer', 'prebuild', libName));
}
// 4. Check for Electron app path
// @ts-ignore - global.app is an Electron-specific property
if (typeof global !== 'undefined' && global.app?.getPath) {
try {
// @ts-ignore
const appPath = global.app.getPath('exe');
const exeDir = dirname(appPath);
possiblePaths.push(join(exeDir, 'resources', 'app.asar.unpacked', 'node_modules', 'node-labstreaminglayer', 'prebuild', libName));
} catch (e) {
// Ignore if not in Electron main process
}
}
// Find the first existing path
for (const path of possiblePaths) {
if (existsSync(path)) {
return path;
}
}
// If no path exists, throw an error with helpful information
throw new Error(
`Failed to find LSL library '${libName}'. Searched paths:\n` +
possiblePaths.map(p => ` - ${p}`).join('\n') +
'\n\nFor Electron apps, ensure native modules are unpacked from ASAR.\n' +
'See: https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules'
);
}

@@ -57,0 +111,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet