46 lines
1.7 KiB
JavaScript
46 lines
1.7 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.detectRemotionServer = void 0;
|
|
const http_1 = __importDefault(require("http"));
|
|
const detectRemotionServer = (port, cwd) => {
|
|
return new Promise((resolve) => {
|
|
const req = http_1.default.get({
|
|
hostname: 'localhost',
|
|
port,
|
|
path: '/__remotion_config',
|
|
timeout: 1000,
|
|
}, (res) => {
|
|
let data = '';
|
|
res.on('data', (chunk) => {
|
|
data += chunk;
|
|
});
|
|
res.on('end', () => {
|
|
try {
|
|
const json = JSON.parse(data);
|
|
if ((json === null || json === void 0 ? void 0 : json.isRemotion) !== true) {
|
|
return resolve({ type: 'not-remotion' });
|
|
}
|
|
// Normalize paths for comparison to avoid issues with different separators or casing on Windows
|
|
const normalize = (p) => p.replace(/\\/g, '/').toLowerCase();
|
|
if (normalize(json.cwd) === normalize(cwd)) {
|
|
return resolve({ type: 'match' });
|
|
}
|
|
return resolve({ type: 'mismatch' });
|
|
}
|
|
catch (_a) {
|
|
resolve({ type: 'not-remotion' });
|
|
}
|
|
});
|
|
});
|
|
req.on('error', () => resolve({ type: 'not-remotion' }));
|
|
req.on('timeout', () => {
|
|
req.destroy();
|
|
resolve({ type: 'not-remotion' });
|
|
});
|
|
});
|
|
};
|
|
exports.detectRemotionServer = detectRemotionServer;
|