@tixae-labs/web-sdk
Version:
Javascript Web SDK for doing WebRTC AI Voice Calls with Convocore.
109 lines (108 loc) • 4.52 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs/promises"));
const path = __importStar(require("path"));
/**
* Deletes all files and folders inside `rootPath` except for those
* whose relative paths (from rootPath) appear in the `exceptions` array.
*
* @param rootPath - The directory to process.
* @param exceptions - An array of paths (relative to rootPath) to keep.
*/
async function deleteAllExcept(rootPath, exceptions) {
// Normalize exception paths for consistent matching.
const exceptionsSet = new Set(exceptions.map(e => path.normalize(e)));
/**
* Recursively processes the directory at `currentPath`.
*
* @param currentPath - Absolute path of the current directory.
* @param relativePath - The path relative to the original rootPath.
*/
async function processDirectory(currentPath, relativePath) {
// Read the directory entries.
const items = await fs.readdir(currentPath);
for (const item of items) {
// Build the relative path for the item.
const itemRelPath = relativePath ? path.join(relativePath, item) : item;
const fullItemPath = path.join(currentPath, item);
// If the item is in the exceptions list, skip processing it.
if (exceptionsSet.has(path.normalize(itemRelPath))) {
// Do not process inside an exception folder (or delete an exception file).
continue;
}
const stats = await fs.lstat(fullItemPath);
if (stats.isDirectory()) {
// Process the contents of the directory.
await processDirectory(fullItemPath, itemRelPath);
// After processing, check if the directory is now empty.
const remaining = await fs.readdir(fullItemPath);
if (remaining.length === 0) {
await fs.rmdir(fullItemPath);
}
}
else {
// Delete the file.
await fs.unlink(fullItemPath);
}
}
}
// Process the root directory but never remove the root itself.
await processDirectory(rootPath, '');
}
// --- Main build cleanup ---
async function main() {
// First, delete everything except the web-call src
await deleteAllExcept('./dist', ['src/public_packages/web-call']);
// Move files from nested location to dist root
const nestedSrc = './dist/src/public_packages/web-call/src';
const distRoot = './dist';
// Check if the nested structure exists
try {
const files = await fs.readdir(nestedSrc);
// Move each file to dist root
for (const file of files) {
const srcPath = path.join(nestedSrc, file);
const destPath = path.join(distRoot, file);
await fs.rename(srcPath, destPath);
}
// Clean up empty nested directories
await fs.rm('./dist/src', { recursive: true, force: true });
}
catch (err) {
console.error('Error moving files:', err);
}
}
main().catch(console.error);