Skip to content

Commit f1cd928

Browse files
committed
fix jitsi#140 changed import path
1 parent 0cf5059 commit f1cd928

File tree

6 files changed

+77
-155
lines changed

6 files changed

+77
-155
lines changed

eslint.config.mjs

+9-41
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,36 @@ export default [
44
js.configs.recommended,
55
{
66
languageOptions: {
7-
ecmaVersion: 2021, // Use modern ECMAScript version
7+
ecmaVersion: 2021,
88
sourceType: 'module',
99
globals: {
1010
__filename: false
1111
}
1212
},
1313
rules: {
14-
'new-cap': [
15-
'error',
16-
{
17-
capIsNew: false
18-
}
19-
],
14+
'new-cap': ['error', { capIsNew: false }],
2015
'no-console': 'off',
2116
'semi': 'error'
2217
},
23-
ignores: [
24-
'node_modules',
25-
'dist'
26-
]
18+
ignores: ['node_modules', 'dist']
2719
},
2820
{
29-
// Node.js (Main process)
30-
files: ['**/main/**/*.js', '**/*.cjs'],
31-
languageOptions: {
32-
globals: {
33-
require: 'readonly',
34-
module: 'readonly',
35-
process: 'readonly',
36-
console: 'readonly',
37-
__dirname: 'readonly'
38-
}
21+
files: ['**/main/**/*.js', '**/*.cjs', 'node_addons/sourceId2Coordinates/**/*.js'],
22+
env: {
23+
node: true
3924
}
4025
},
4126
{
42-
// Browser (Renderer process)
4327
files: ['**/render/**/*.js'],
44-
env: {
45-
browser: true, // Add this line
46-
es2021: true // Or es6: true if you're using ES6 features
47-
},
28+
env: { browser: true, node: true, es2021: true },
4829
languageOptions: {
49-
globals: {
50-
window: 'readonly',
51-
document: 'readonly',
52-
URL: 'readonly',
53-
console: 'readonly'
54-
},
55-
// browser: true
30+
globals: { window: 'readonly', document: 'readonly', URL: 'readonly', console: 'readonly' }
5631
}
5732
},
5833
{
59-
// Test files
6034
files: ['**/*.test.js'],
6135
languageOptions: {
62-
globals: {
63-
describe: 'readonly',
64-
it: 'readonly',
65-
expect: 'readonly',
66-
jest: 'readonly',
67-
assert: 'readonly'
68-
}
36+
globals: { describe: 'readonly', it: 'readonly', expect: 'readonly', jest: 'readonly', assert: 'readonly' }
6937
}
7038
}
7139
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
'targets': [
3+
{
4+
'target_name': 'sourceId2Coordinates',
5+
'sources': [
6+
'src/index.cc',
7+
'src/sourceId2Coordinates.cc'
8+
],
9+
'include_dirs': [
10+
"<!@(node -p \"require('node-addon-api').include\")"
11+
],
12+
'defines': [
13+
'NAPI_CPP_EXCEPTIONS'
14+
],
15+
'cflags_cc': [
16+
'/EHsc'
17+
]
18+
}
19+
]
20+
}

node_addons/sourceId2Coordinates/index.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
import { sourceId2Coordinates } from 'node-gyp-build';
1+
import { createRequire } from 'module';
2+
3+
/**
4+
* @typedef {{ x: number; y: number }} Coordinates
5+
*/
26

37
/**
48
* Returns the coordinates of a desktop using the passed desktop sharing source
59
* id.
610
*
711
* @param {string} sourceId - The desktop sharing source id.
8-
* @returns {Object.<string, number>|undefined} - The x and y coordinates of the
12+
* @returns {Coordinates | undefined} - The x and y coordinates of the
913
* top left corner of the desktop. Currently works only for Windows. Returns
1014
* undefined for Mac OS, Linux.
1115
*/
@@ -20,8 +24,14 @@ export default (sourceId) => {
2024
const id = Number(idArr.length > 1 ? idArr[0] : sourceId);
2125

2226
if (!isNaN(id)) {
23-
return sourceId2Coordinates(id);
27+
try {
28+
const sourceId2Coordinates = createRequire(import.meta.url)('node-gyp-build').sourceId2Coordinates;
29+
return sourceId2Coordinates(id);
30+
} catch (error) {
31+
console.error("Error loading or executing node-gyp-build:", error);
32+
return undefined;
33+
}
2434
}
25-
35+
2636
return undefined;
27-
};
37+
};

0 commit comments

Comments
 (0)