mirror of
https://github.com/tl-open-source/tl-rtc-file.git
synced 2025-09-27 03:46:11 +08:00

feat: 支持单独发送文件 feat: 支持文本私聊 feat: 支持seafile网盘暂存文件 feat: 支持直播房间 feat: 支持取件码下载文件 feat: 支持预览视频文件 feat: 支持报错告警 feat: 调整补充启动logo feat: 调整补充免责协议 feat: 调整补充配置中的版本号 feat: 调整优化开源协议 feat: 调整补充定制收费服务 feat: 调整优化服务端代码 feat: 调整优化批量发送逻辑 feat: 调整优化样式体验 feat: 调整优化conf中ws, manage相关配置 feat: 调整优化文件发送时间间隔为1秒钟 feat: 调整优化文件发送体验 feat: 调整优化选择文件逻辑 feat: 调整优化启动文件/命令 feat: 调整优化socket配置区分 feat: 调整优化分享进入房间 feat: 调整优化右上角消息提示 feat: 调整删除npm依赖 feat: 调整删除首次弹窗 feat: 即将支持远程cavas画笔 feat: 即将支持远程控制
59 lines
1.8 KiB
JavaScript
59 lines
1.8 KiB
JavaScript
const path = require('path');
|
||
const glob = require('glob');
|
||
const globBase = require('glob-base');
|
||
const { removeExt, unifiedSlash } = require('../comm/util');
|
||
|
||
const directories = [];
|
||
|
||
/**
|
||
* 由于webpack的watch不会对新增文件进行编译,使用这个插件可以在watch状态下可以检测到新增文件入口。
|
||
* */
|
||
class WatchNewEntry {
|
||
static getEntries(globEntries, globOptions = {}) {
|
||
return function () {
|
||
if (!Array.isArray(globEntries)) {
|
||
throw new TypeError('globEntries must be an array of strings');
|
||
}
|
||
|
||
if (globOptions && typeof globOptions !== 'object') {
|
||
throw new TypeError('globOptions must be an object');
|
||
}
|
||
|
||
|
||
let globbedFiles = {};
|
||
|
||
globEntries.forEach((globString) => {
|
||
const globBaseOptions = globBase(globString);
|
||
if (directories.indexOf(globBaseOptions.base) === -1) {
|
||
directories.push(globBaseOptions.base);
|
||
}
|
||
const files = WatchNewEntry.getFiles(globString, globOptions);
|
||
|
||
globbedFiles = Object.assign(files, globbedFiles);
|
||
});
|
||
|
||
return globbedFiles;
|
||
};
|
||
}
|
||
|
||
static getFiles(globString, globOptions) {
|
||
const files = {};
|
||
glob.sync(globString, globOptions).forEach((file) => {
|
||
files[unifiedSlash(path.basename(removeExt(file)))] = unifiedSlash(file);
|
||
});
|
||
return files;
|
||
}
|
||
|
||
apply(compiler) {
|
||
compiler.hooks.afterCompile.tapAsync(this.constructor.name, this.afterCompile);
|
||
}
|
||
|
||
afterCompile(compilation, callback) {
|
||
for (const directory of directories) {
|
||
compilation.contextDependencies.add(directory);
|
||
}
|
||
callback();
|
||
}
|
||
}
|
||
module.exports = WatchNewEntry;
|