V5
This commit is contained in:
parent
96f3e9caa7
commit
c2aa0f3687
BIN
assets/pasted-20260216-072603-dff6b275.jpg
Normal file
BIN
assets/pasted-20260216-072603-dff6b275.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 614 KiB |
129
bot/bot.log
129
bot/bot.log
@ -1268,3 +1268,132 @@ Alarm scheduled at 0 30 03 * * *
|
||||
[2026-02-16T07:06:43.786Z] Alarm scheduled at 0 30 03 * * *
|
||||
[2026-02-16T07:12:30.682Z] Ready! Logged in as AsepXiaoQin#6954
|
||||
[2026-02-16T07:12:30.922Z] Alarm scheduled at 0 30 03 * * *
|
||||
[2026-02-16T07:18:44.998Z] Bot berhasil login!
|
||||
[2026-02-16T07:18:45.002Z] Ready! Logged in as AsepXiaoQin#6954
|
||||
[2026-02-16T07:18:45.007Z] FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg
|
||||
[2026-02-16T07:18:46.502Z] Failed to schedule alarm: Too few fields
|
||||
[2026-02-16T07:19:20.513Z] Bot berhasil login!
|
||||
[2026-02-16T07:19:20.514Z] Ready! Logged in as AsepXiaoQin#6954
|
||||
[2026-02-16T07:19:20.514Z] FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg
|
||||
[2026-02-16T07:19:21.251Z] Failed to schedule alarm: sahurTime is not defined
|
||||
[2026-02-16T07:20:05.257Z] Bot berhasil login!
|
||||
[2026-02-16T07:20:05.260Z] Ready! Logged in as AsepXiaoQin#6954
|
||||
[2026-02-16T07:20:05.262Z] FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg
|
||||
[2026-02-16T07:20:05.746Z] Alarm scheduled at 30 3 * * *
|
||||
[2026-02-16T07:20:37.264Z] Bot berhasil login!
|
||||
[2026-02-16T07:20:37.266Z] Ready! Logged in as AsepXiaoQin#6954
|
||||
[2026-02-16T07:20:37.267Z] FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg
|
||||
[2026-02-16T07:20:38.018Z] Alarm scheduled at 30 3 * * *
|
||||
[2026-02-16T07:23:54.764Z] Interaction Error: There is no playing queue in this guild
|
||||
[2026-02-16T07:25:00.894Z] Bot berhasil login!
|
||||
[2026-02-16T07:25:00.895Z] Ready! Logged in as AsepXiaoQin#6954
|
||||
[2026-02-16T07:25:00.896Z] FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg
|
||||
[2026-02-16T07:25:01.155Z] Alarm scheduled at 30 3 * * *
|
||||
[dotenv@17.3.1] injecting env (4) from .env -- tip: ⚙️ write to custom object with { processEnv: myObject }
|
||||
Dependency Report:
|
||||
--------------------------------------------------
|
||||
Core Dependencies
|
||||
- @discordjs/voice: 0.19.0
|
||||
- prism-media: 1.3.5
|
||||
|
||||
Opus Libraries
|
||||
- @discordjs/opus: 0.9.0
|
||||
- opusscript: 0.0.8
|
||||
|
||||
Encryption Libraries
|
||||
- native crypto support for aes-256-gcm: yes
|
||||
- sodium-native: 5.0.10
|
||||
- sodium: not found
|
||||
- libsodium-wrappers: 0.7.16
|
||||
- @stablelib/xchacha20poly1305: 2.0.1
|
||||
- @noble/ciphers: not found
|
||||
|
||||
DAVE Libraries
|
||||
- @snazzah/davey: 0.1.9
|
||||
|
||||
FFmpeg
|
||||
- version: 7.0.2-static https://johnvansickle.com/ffmpeg/
|
||||
- libopus: yes
|
||||
--------------------------------------------------
|
||||
[2026-02-16T07:32:47.310Z] Encryption library (libsodium) is ready.
|
||||
Encryption library (libsodium) is ready.
|
||||
[2026-02-16T07:32:49.307Z] Bot berhasil login!
|
||||
Bot berhasil login!
|
||||
[2026-02-16T07:32:49.541Z] Ready! Logged in as AsepXiaoQin#6954
|
||||
[2026-02-16T07:32:49.541Z] FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg
|
||||
Ready! Logged in as AsepXiaoQin#6954
|
||||
FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg
|
||||
[2026-02-16T07:32:51.062Z] Alarm scheduled at 30 3 * * *
|
||||
Alarm scheduled at 30 3 * * *
|
||||
[dotenv@17.3.1] injecting env (4) from .env -- tip: 🔐 prevent building .env in docker: https://dotenvx.com/prebuild
|
||||
Dependency Report:
|
||||
--------------------------------------------------
|
||||
Core Dependencies
|
||||
- @discordjs/voice: 0.19.0
|
||||
- prism-media: 1.3.5
|
||||
|
||||
Opus Libraries
|
||||
- @discordjs/opus: 0.9.0
|
||||
- opusscript: 0.0.8
|
||||
|
||||
Encryption Libraries
|
||||
- native crypto support for aes-256-gcm: yes
|
||||
- sodium-native: 5.0.10
|
||||
- sodium: not found
|
||||
- libsodium-wrappers: 0.7.16
|
||||
- @stablelib/xchacha20poly1305: 2.0.1
|
||||
- @noble/ciphers: not found
|
||||
|
||||
DAVE Libraries
|
||||
- @snazzah/davey: 0.1.9
|
||||
|
||||
FFmpeg
|
||||
- version: 7.0.2-static https://johnvansickle.com/ffmpeg/
|
||||
- libopus: yes
|
||||
--------------------------------------------------
|
||||
[2026-02-16T07:35:04.554Z] Encryption library (libsodium) is ready.
|
||||
Encryption library (libsodium) is ready.
|
||||
[2026-02-16T07:35:05.001Z] Bot berhasil login!
|
||||
[2026-02-16T07:35:05.001Z] Ready! Logged in as AsepXiaoQin#6954
|
||||
[2026-02-16T07:35:05.002Z] FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg
|
||||
Bot berhasil login!
|
||||
Ready! Logged in as AsepXiaoQin#6954
|
||||
FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg
|
||||
[2026-02-16T07:35:05.079Z] Alarm scheduled at 30 3 * * *
|
||||
Alarm scheduled at 30 3 * * *
|
||||
[dotenv@17.3.1] injecting env (4) from .env -- tip: 🔐 encrypt with Dotenvx: https://dotenvx.com
|
||||
Dependency Report:
|
||||
--------------------------------------------------
|
||||
Core Dependencies
|
||||
- @discordjs/voice: 0.19.0
|
||||
- prism-media: 1.3.5
|
||||
|
||||
Opus Libraries
|
||||
- @discordjs/opus: 0.9.0
|
||||
- opusscript: 0.0.8
|
||||
|
||||
Encryption Libraries
|
||||
- native crypto support for aes-256-gcm: yes
|
||||
- sodium-native: 5.0.10
|
||||
- sodium: not found
|
||||
- libsodium-wrappers: 0.7.16
|
||||
- @stablelib/xchacha20poly1305: 2.0.1
|
||||
- @noble/ciphers: not found
|
||||
|
||||
DAVE Libraries
|
||||
- @snazzah/davey: 0.1.9
|
||||
|
||||
FFmpeg
|
||||
- version: 7.0.2-static https://johnvansickle.com/ffmpeg/
|
||||
- libopus: yes
|
||||
--------------------------------------------------
|
||||
[2026-02-16T07:37:25.997Z] Encryption library (libsodium) is ready.
|
||||
Encryption library (libsodium) is ready.
|
||||
[2026-02-16T07:37:26.881Z] Bot berhasil login!
|
||||
[2026-02-16T07:37:26.882Z] Ready! Logged in as AsepXiaoQin#6954
|
||||
[2026-02-16T07:37:26.882Z] FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg
|
||||
Bot berhasil login!
|
||||
Ready! Logged in as AsepXiaoQin#6954
|
||||
FFMPEG Path: /home/ubuntu/executor/workspace/bot/node_modules/ffmpeg-static/ffmpeg
|
||||
[2026-02-16T07:37:26.937Z] Alarm scheduled at 30 3 * * *
|
||||
Alarm scheduled at 30 3 * * *
|
||||
|
||||
335
bot/index.js
335
bot/index.js
@ -1,20 +1,29 @@
|
||||
process.env.FFMPEG_PATH = require('ffmpeg-static');
|
||||
const { Client, GatewayIntentBits, Events, EmbedBuilder, PermissionsBitField } = require('discord.js');
|
||||
const { DisTube } = require('distube');
|
||||
const { YtDlpPlugin } = require('@distube/yt-dlp');
|
||||
const { SoundCloudPlugin } = require('@distube/soundcloud');
|
||||
const { SpotifyPlugin } = require('@distube/spotify');
|
||||
const { CronJob } = require('cron');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { Client, GatewayIntentBits, Events } = require('discord.js');
|
||||
const { joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayerStatus, NoSubscriberBehavior } = require('@discordjs/voice');
|
||||
const { CronJob } = require('cron');
|
||||
const play = require('play-dl');
|
||||
|
||||
// Ensure .env is loaded early
|
||||
// Load environment variables
|
||||
require('dotenv').config({ path: path.join(__dirname, '.env') });
|
||||
|
||||
// Tambahkan folder ffmpeg ke PATH
|
||||
const ffmpegDir = path.dirname(process.env.FFMPEG_PATH);
|
||||
// Setup FFMPEG
|
||||
const ffmpegStatic = require('ffmpeg-static');
|
||||
process.env.FFMPEG_PATH = ffmpegStatic;
|
||||
const ffmpegDir = path.dirname(ffmpegStatic);
|
||||
if (!process.env.PATH.includes(ffmpegDir)) {
|
||||
process.env.PATH = `${ffmpegDir}${path.delimiter}${process.env.PATH}`;
|
||||
}
|
||||
|
||||
// Generate dependency report for debugging
|
||||
try {
|
||||
const { generateDependencyReport } = require('@discordjs/voice');
|
||||
console.log("Dependency Report:\n" + generateDependencyReport());
|
||||
} catch (e) {}
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
@ -24,13 +33,30 @@ const client = new Client({
|
||||
]
|
||||
});
|
||||
|
||||
// Detect libsodium
|
||||
try {
|
||||
const sodium = require('libsodium-wrappers');
|
||||
sodium.ready.then(() => {
|
||||
logToFile("Encryption library (libsodium) is ready.");
|
||||
});
|
||||
} catch (e) {
|
||||
logToFile("Warning: libsodium-wrappers not found or failed to load.");
|
||||
}
|
||||
|
||||
const distube = new DisTube(client, {
|
||||
plugins: [
|
||||
new SoundCloudPlugin(),
|
||||
new SpotifyPlugin(),
|
||||
new YtDlpPlugin(),
|
||||
],
|
||||
emitNewSongOnly: true,
|
||||
emitAddSongWhenCreatingQueue: false,
|
||||
});
|
||||
|
||||
const VC_ID = process.env.VC_ID;
|
||||
const AUDIO_PATH = path.join(__dirname, 'assets/audio/sahur.mp3');
|
||||
const PREFIX = '!';
|
||||
|
||||
// Global state
|
||||
const queues = new Map(); // guildId -> { queue: [], player, connection }
|
||||
|
||||
function logToFile(message) {
|
||||
const logMessage = `[${new Date().toISOString()}] ${message}\n`;
|
||||
try {
|
||||
@ -42,15 +68,19 @@ function logToFile(message) {
|
||||
}
|
||||
|
||||
client.once(Events.ClientReady, () => {
|
||||
console.log('Bot berhasil login!');
|
||||
logToFile(`Bot berhasil login!`);
|
||||
logToFile(`Ready! Logged in as ${client.user.tag}`);
|
||||
|
||||
logToFile(`FFMPEG Path: ${process.env.FFMPEG_PATH}`);
|
||||
|
||||
// Sahur Alarm
|
||||
const sahurTime = process.env.SAHUR_TIME || '30 03 * * *';
|
||||
let cronTime = sahurTime;
|
||||
if (sahurTime.includes(':') && !sahurTime.includes('*')) {
|
||||
const [hour, minute] = sahurTime.split(':');
|
||||
cronTime = `0 ${minute} ${hour} * * *`;
|
||||
const rawSahurTime = process.env.SAHUR_TIME || '03:30';
|
||||
let cronTime = '30 3 * * *';
|
||||
|
||||
if (rawSahurTime.includes(':')) {
|
||||
const [hour, minute] = rawSahurTime.split(':');
|
||||
cronTime = `${parseInt(minute)} ${parseInt(hour)} * * *`;
|
||||
} else {
|
||||
cronTime = rawSahurTime;
|
||||
}
|
||||
|
||||
try {
|
||||
@ -59,8 +89,13 @@ client.once(Events.ClientReady, () => {
|
||||
const guild = client.guilds.cache.first();
|
||||
if (!guild) return;
|
||||
const channel = guild.channels.cache.get(VC_ID);
|
||||
if (channel) {
|
||||
playLocal(channel, AUDIO_PATH);
|
||||
if (channel && fs.existsSync(AUDIO_PATH)) {
|
||||
distube.voices.join(channel).then(voice => {
|
||||
const stream = fs.createReadStream(AUDIO_PATH);
|
||||
voice.play(stream);
|
||||
}).catch(err => {
|
||||
logToFile(`Alarm join error: ${err.message}`);
|
||||
});
|
||||
}
|
||||
}, null, true, 'Asia/Jakarta');
|
||||
logToFile(`Alarm scheduled at ${cronTime}`);
|
||||
@ -69,28 +104,86 @@ client.once(Events.ClientReady, () => {
|
||||
}
|
||||
});
|
||||
|
||||
async function playLocal(channel, filePath) {
|
||||
// Slash Command Handler
|
||||
client.on(Events.InteractionCreate, async interaction => {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
const { commandName } = interaction;
|
||||
const voiceChannel = interaction.member?.voice.channel;
|
||||
|
||||
try {
|
||||
const connection = joinVoiceChannel({
|
||||
channelId: channel.id,
|
||||
guildId: channel.guild.id,
|
||||
adapterCreator: channel.guild.voiceAdapterCreator,
|
||||
});
|
||||
if (commandName === 'join') {
|
||||
if (!voiceChannel) return interaction.reply({ content: 'Anda harus berada di voice channel!', ephemeral: true });
|
||||
await interaction.deferReply();
|
||||
await distube.voices.join(voiceChannel);
|
||||
await interaction.editReply('Sudah join! 🎧');
|
||||
}
|
||||
|
||||
const player = createAudioPlayer();
|
||||
const resource = createAudioResource(filePath);
|
||||
player.play(resource);
|
||||
connection.subscribe(player);
|
||||
else if (commandName === 'testsahur') {
|
||||
if (!voiceChannel) return interaction.reply({ content: 'Anda harus berada di voice channel!', ephemeral: true });
|
||||
if (!fs.existsSync(AUDIO_PATH)) return interaction.reply({ content: `File audio tidak ditemukan di ${AUDIO_PATH}`, ephemeral: true });
|
||||
|
||||
await interaction.deferReply();
|
||||
logToFile(`Playing local file using stream: ${AUDIO_PATH}`);
|
||||
try {
|
||||
const voice = await distube.voices.join(voiceChannel);
|
||||
const stream = fs.createReadStream(AUDIO_PATH);
|
||||
voice.play(stream);
|
||||
await interaction.editReply('Memainkan suara sahur... 📢');
|
||||
} catch (e) {
|
||||
logToFile(`Error in testsahur: ${e.message}`);
|
||||
await interaction.editReply(`Gagal memutar audio: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
player.once(AudioPlayerStatus.Idle, () => {
|
||||
connection.destroy();
|
||||
});
|
||||
} catch (err) {
|
||||
logToFile(`Error playing local file: ${err.message}`);
|
||||
else if (commandName === 'play') {
|
||||
const query = interaction.options.getString('query');
|
||||
if (!voiceChannel) return interaction.reply({ content: 'Anda harus berada di voice channel!', ephemeral: true });
|
||||
|
||||
await interaction.deferReply();
|
||||
logToFile(`Fetching stream for: ${query}`);
|
||||
distube.play(voiceChannel, query, {
|
||||
member: interaction.member,
|
||||
textChannel: interaction.channel,
|
||||
interaction
|
||||
}).catch(e => {
|
||||
logToFile(`Play Error: ${e.message}`);
|
||||
interaction.editReply(`Terjadi kesalahan saat memutar: ${e.message}`);
|
||||
});
|
||||
await interaction.editReply(`Mencari: **${query}**... 🔍`);
|
||||
}
|
||||
|
||||
else if (commandName === 'pause') {
|
||||
distube.pause(interaction.guildId);
|
||||
await interaction.reply('Musik dipause. ⏸️');
|
||||
}
|
||||
|
||||
else if (commandName === 'resume') {
|
||||
distube.resume(interaction.guildId);
|
||||
await interaction.reply('Musik dilanjutkan. ▶️');
|
||||
}
|
||||
|
||||
else if (commandName === 'skip') {
|
||||
await distube.skip(interaction.guildId);
|
||||
await interaction.reply('Lagu dilewati! ⏭️');
|
||||
}
|
||||
|
||||
else if (commandName === 'stop') {
|
||||
await distube.stop(interaction.guildId);
|
||||
await interaction.reply('Musik dihentikan dan antrean dihapus. 👋');
|
||||
}
|
||||
} catch (error) {
|
||||
logToFile(`Interaction Error (${commandName}): ${error.message}`);
|
||||
if (!interaction.replied && !interaction.deferred) {
|
||||
await interaction.reply({ content: `Terjadi kesalahan: ${error.message}`, ephemeral: true });
|
||||
} else {
|
||||
await interaction.editReply({ content: `Terjadi kesalahan: ${error.message}`, ephemeral: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
client.on(Events.MessageCreate, async (message) => {
|
||||
// Prefix Command Handler (Legacy/Backup)
|
||||
client.on(Events.MessageCreate, async message => {
|
||||
if (message.author.bot || !message.content.startsWith(PREFIX)) return;
|
||||
|
||||
const args = message.content.slice(PREFIX.length).trim().split(/ +/);
|
||||
@ -98,134 +191,64 @@ client.on(Events.MessageCreate, async (message) => {
|
||||
const voiceChannel = message.member?.voice.channel;
|
||||
|
||||
try {
|
||||
if (command === 'join') {
|
||||
if (!voiceChannel) return message.reply('Anda harus berada di voice channel!');
|
||||
joinVoiceChannel({
|
||||
channelId: voiceChannel.id,
|
||||
guildId: message.guild.id,
|
||||
adapterCreator: message.guild.voiceAdapterCreator,
|
||||
});
|
||||
message.reply('Sudah join! 🎧');
|
||||
}
|
||||
|
||||
else if (command === 'testsahur') {
|
||||
if (!voiceChannel) return message.reply('Anda harus berada di voice channel!');
|
||||
if (!fs.existsSync(AUDIO_PATH)) return message.reply(`File audio tidak ditemukan di ${AUDIO_PATH}`);
|
||||
playLocal(voiceChannel, AUDIO_PATH);
|
||||
message.reply('Memainkan suara sahur... 📢');
|
||||
}
|
||||
|
||||
else if (command === 'play') {
|
||||
if (!voiceChannel) return message.reply('Anda harus berada di voice channel!');
|
||||
if (command === 'play') {
|
||||
const query = args.join(' ');
|
||||
if (!query) return message.reply('Berikan link atau nama lagu!');
|
||||
|
||||
let serverQueue = queues.get(message.guild.id);
|
||||
|
||||
if (!serverQueue) {
|
||||
serverQueue = {
|
||||
songs: [],
|
||||
connection: null,
|
||||
player: createAudioPlayer({
|
||||
behaviors: { noSubscriber: NoSubscriberBehavior.Play }
|
||||
}),
|
||||
};
|
||||
queues.set(message.guild.id, serverQueue);
|
||||
if (!voiceChannel) return message.reply('Anda harus berada di voice channel!');
|
||||
if (!query) return message.reply('Masukkan judul atau link lagu!');
|
||||
distube.play(voiceChannel, query, {
|
||||
member: message.member,
|
||||
textChannel: message.channel,
|
||||
message
|
||||
});
|
||||
} else if (['skip', 'stop', 'pause', 'resume'].includes(command)) {
|
||||
if (!voiceChannel) return message.reply('Anda harus berada di voice channel!');
|
||||
const method = command === 'skip' ? 'skip' : (command === 'stop' ? 'stop' : (command === 'pause' ? 'pause' : 'resume'));
|
||||
await distube[method](message.guildId);
|
||||
message.reply(`${command} berhasil!`);
|
||||
} else if (command === 'testsahur') {
|
||||
if (!voiceChannel) return message.reply('Anda harus berada di voice channel!');
|
||||
try {
|
||||
const voice = await distube.voices.join(voiceChannel);
|
||||
const stream = fs.createReadStream(AUDIO_PATH);
|
||||
voice.play(stream);
|
||||
message.reply('Mengetes suara sahur... 📢');
|
||||
} catch (e) {
|
||||
message.reply(`❌ Error: ${e.message}`);
|
||||
}
|
||||
|
||||
message.reply('Mencari lagu... 🔍');
|
||||
|
||||
let songInfo;
|
||||
if (play.sp_validate(query) === 'track') {
|
||||
const sp_data = await play.spotify(query);
|
||||
const search = await play.search(`${sp_data.name} ${sp_data.artists[0].name}`, { limit: 1 });
|
||||
songInfo = { title: sp_data.name, url: search[0].url };
|
||||
} else if (play.so_validate(query)) {
|
||||
const so_data = await play.soundcloud(query);
|
||||
songInfo = { title: so_data.name, url: so_data.url };
|
||||
} else {
|
||||
const yt_info = await play.search(query, { limit: 1 });
|
||||
if (yt_info.length === 0) return message.channel.send('Lagu tidak ditemukan!');
|
||||
songInfo = { title: yt_info[0].title, url: yt_info[0].url };
|
||||
}
|
||||
|
||||
serverQueue.songs.push(songInfo);
|
||||
|
||||
if (serverQueue.songs.length === 1) {
|
||||
playSong(message.guild.id, voiceChannel);
|
||||
message.channel.send(`🎵 Sekarang memutar: **${songInfo.title}**`);
|
||||
} else {
|
||||
message.channel.send(`✅ **${songInfo.title}** ditambahkan ke antrean.`);
|
||||
}
|
||||
}
|
||||
|
||||
else if (command === 'skip') {
|
||||
const serverQueue = queues.get(message.guild.id);
|
||||
if (!serverQueue) return message.reply('Tidak ada lagu yang sedang diputar!');
|
||||
serverQueue.player.stop();
|
||||
message.reply('Lagu dilewati! ⏭️');
|
||||
}
|
||||
|
||||
else if (command === 'stop') {
|
||||
const serverQueue = queues.get(message.guild.id);
|
||||
if (serverQueue) {
|
||||
serverQueue.songs = [];
|
||||
serverQueue.player.stop();
|
||||
if (serverQueue.connection) serverQueue.connection.destroy();
|
||||
queues.delete(message.guild.id);
|
||||
}
|
||||
message.reply('Musik dihentikan. 👋');
|
||||
}
|
||||
|
||||
else if (command === 'pause') {
|
||||
const serverQueue = queues.get(message.guild.id);
|
||||
if (serverQueue) serverQueue.player.pause();
|
||||
message.reply('Dipause. ⏸️');
|
||||
}
|
||||
|
||||
else if (command === 'resume') {
|
||||
const serverQueue = queues.get(message.guild.id);
|
||||
if (serverQueue) serverQueue.player.unpause();
|
||||
message.reply('Dilanjutkan. ▶️');
|
||||
}
|
||||
} catch (error) {
|
||||
logToFile(`Command Error (${command}): ${error.stack || error.message}`);
|
||||
message.reply(`❌ Terjadi kesalahan: ${error.message}`);
|
||||
logToFile(`Message Command Error: ${error.message}`);
|
||||
message.reply(`❌ Error: ${error.message}`);
|
||||
}
|
||||
});
|
||||
|
||||
async function playSong(guildId, channel) {
|
||||
const serverQueue = queues.get(guildId);
|
||||
if (!serverQueue || serverQueue.songs.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const song = serverQueue.songs[0];
|
||||
const stream = await play.stream(song.url);
|
||||
const resource = createAudioResource(stream.stream, { inputType: stream.type });
|
||||
|
||||
if (!serverQueue.connection) {
|
||||
serverQueue.connection = joinVoiceChannel({
|
||||
channelId: channel.id,
|
||||
guildId: guildId,
|
||||
adapterCreator: channel.guild.voiceAdapterCreator,
|
||||
});
|
||||
serverQueue.connection.subscribe(serverQueue.player);
|
||||
// DisTube Events
|
||||
distube
|
||||
.on('playSong', (queue, song) => {
|
||||
queue.textChannel.send(`🎵 Sekarang memutar: **${song.name}** - \`${song.formatDuration}\`\nRequested by: ${song.user}`);
|
||||
})
|
||||
.on('addSong', (queue, song) => {
|
||||
queue.textChannel.send(`✅ **${song.name}** ditambahkan ke antrean oleh ${song.user}`);
|
||||
})
|
||||
.on('error', (channel, e) => {
|
||||
logToFile(`DisTube Error: ${e.message}`);
|
||||
if (e.message.includes('Sign in to confirm you’re not a bot')) {
|
||||
if (channel) channel.send(`❌ YouTube memblokir akses bot. Silakan coba link dari SoundCloud atau Spotify.`);
|
||||
} else if (channel) {
|
||||
channel.send(`❌ Terjadi kesalahan: ${e.message.slice(0, 2000)}`);
|
||||
}
|
||||
});
|
||||
|
||||
serverQueue.player.play(resource);
|
||||
// Handle uncaught errors to prevent crash
|
||||
process.on('unhandledRejection', error => {
|
||||
logToFile(`Unhandled Rejection: ${error.message}`);
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
serverQueue.player.once(AudioPlayerStatus.Idle, () => {
|
||||
serverQueue.songs.shift();
|
||||
playSong(guildId, channel);
|
||||
});
|
||||
} catch (err) {
|
||||
logToFile(`Playback Error: ${err.message}`);
|
||||
serverQueue.songs.shift();
|
||||
playSong(guildId, channel);
|
||||
}
|
||||
}
|
||||
process.on('uncaughtException', error => {
|
||||
logToFile(`Uncaught Exception: ${error.message}`);
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
// Login at the very bottom
|
||||
// Login
|
||||
client.login(process.env.DISCORD_TOKEN);
|
||||
|
||||
72
bot/node_modules/.package-lock.json
generated
vendored
72
bot/node_modules/.package-lock.json
generated
vendored
@ -529,6 +529,47 @@
|
||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/bare-addon-resolve": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/bare-addon-resolve/-/bare-addon-resolve-1.10.0.tgz",
|
||||
"integrity": "sha512-sSd0jieRJlDaODOzj0oe0RjFVC1QI0ZIjGIdPkbrTXsdVVtENg14c+lHHAhHwmWCZ2nQlMhy8jA3Y5LYPc/isA==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"bare-module-resolve": "^1.10.0",
|
||||
"bare-semver": "^1.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bare-url": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bare-url": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/bare-module-resolve": {
|
||||
"version": "1.12.1",
|
||||
"resolved": "https://registry.npmjs.org/bare-module-resolve/-/bare-module-resolve-1.12.1.tgz",
|
||||
"integrity": "sha512-hbmAPyFpEq8FoZMd5sFO3u6MC5feluWoGE8YKlA8fCrl6mNtx68Wjg4DTiDJcqRJaovTvOYKfYngoBUnbaT7eg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"bare-semver": "^1.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bare-url": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bare-url": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/bare-semver": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/bare-semver/-/bare-semver-1.0.2.tgz",
|
||||
"integrity": "sha512-ESVaN2nzWhcI5tf3Zzcq9aqCZ676VWzqw07eEZ0qxAcEOAFYBa0pWq8sK34OQeHLY3JsfKXZS9mDyzyxGjeLzA==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "1.1.12",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz",
|
||||
@ -1524,6 +1565,18 @@
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/require-addon": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/require-addon/-/require-addon-1.2.0.tgz",
|
||||
"integrity": "sha512-VNPDZlYgIYQwWp9jMTzljx+k0ZtatKlcvOhktZ/anNPI3dQ9NXk7cq2U4iJ1wd9IrytRnYhyEocFWbkdPb+MYA==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"bare-addon-resolve": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"bare": ">=1.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/rimraf": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
|
||||
@ -1656,6 +1709,19 @@
|
||||
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/sodium-native": {
|
||||
"version": "5.0.10",
|
||||
"resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-5.0.10.tgz",
|
||||
"integrity": "sha512-UIw+0AbpCQRuTJF88JWrZomP4O+PXhlWvdopiAJOsUivTyHTf3korMyStxkZuPngSbBEtEfDdc4ewEd8/T4/lA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"require-addon": "^1.1.0",
|
||||
"which-runtime": "^1.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"bare": ">=1.16.0"
|
||||
}
|
||||
},
|
||||
"node_modules/soundcloud.ts": {
|
||||
"version": "0.6.9",
|
||||
"resolved": "https://registry.npmjs.org/soundcloud.ts/-/soundcloud.ts-0.6.9.tgz",
|
||||
@ -1836,6 +1902,12 @@
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/which-runtime": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/which-runtime/-/which-runtime-1.3.2.tgz",
|
||||
"integrity": "sha512-5kwCfWml7+b2NO7KrLMhYihjRx0teKkd3yGp1Xk5Vaf2JGdSh+rgVhEALAD9c/59dP+YwJHXoEO7e8QPy7gOkw==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/wide-align": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz",
|
||||
|
||||
201
bot/node_modules/bare-addon-resolve/LICENSE
generated
vendored
Normal file
201
bot/node_modules/bare-addon-resolve/LICENSE
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
156
bot/node_modules/bare-addon-resolve/README.md
generated
vendored
Normal file
156
bot/node_modules/bare-addon-resolve/README.md
generated
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
# bare-addon-resolve
|
||||
|
||||
Low-level addon resolution algorithm for Bare. The algorithm is implemented as a generator function that yields either package manifests to be read or resolution candidates to be tested by the caller. As a convenience, the main export is a synchronous and asynchronous iterable that relies on package manifests being read by a callback. For asynchronous iteration, the callback may return promises which will be awaited before being passed to the generator.
|
||||
|
||||
```
|
||||
npm i bare-addon-resolve
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
For synchronous resolution:
|
||||
|
||||
```js
|
||||
const resolve = require('bare-addon-resolve')
|
||||
|
||||
function readPackage(url) {
|
||||
// Read and parse `url` if it exists, otherwise `null`
|
||||
}
|
||||
|
||||
for (const resolution of resolve('./addon', new URL('file:///directory/'), readPackage)) {
|
||||
console.log(resolution)
|
||||
}
|
||||
```
|
||||
|
||||
For asynchronous resolution:
|
||||
|
||||
```js
|
||||
const resolve = require('bare-addon-resolve')
|
||||
|
||||
async function readPackage(url) {
|
||||
// Read and parse `url` if it exists, otherwise `null`
|
||||
}
|
||||
|
||||
for await (const resolution of resolve('./addon', new URL('file:///directory/'), readPackage)) {
|
||||
console.log(resolution)
|
||||
}
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
#### `const resolver = resolve(specifier, parentURL[, options][, readPackage])`
|
||||
|
||||
Resolve `specifier` relative to `parentURL`, which must be a WHATWG `URL` instance. `readPackage` is called with a `URL` instance for every package manifest to be read and must either return the parsed JSON package manifest, if it exists, or `null`. If `readPackage` returns a promise, synchronous iteration is not supported.
|
||||
|
||||
Options include:
|
||||
|
||||
```js
|
||||
options = {
|
||||
// A list of builtin addon specifiers. If matched, the protocol of the
|
||||
// resolved URL will be `builtinProtocol`.
|
||||
builtins: [],
|
||||
// The protocol to use for resolved builtin addon specifiers.
|
||||
builtinProtocol: 'builtin:',
|
||||
// Whether or not addons linked ahead-of-time should be resolved.
|
||||
linked: true,
|
||||
// The protocol to use for addons linked ahead-of-time.
|
||||
linkedProtocol: 'linked:',
|
||||
// The supported import conditions. "default" is always recognized.
|
||||
conditions: [],
|
||||
// An array reference which will contain the matched conditions when yielding
|
||||
// resolutions.
|
||||
matchedConditions: [],
|
||||
// The `<platform>-<arch>` combinations to look for when resolving dynamic
|
||||
// addons. If empty, only builtin specifiers can be resolved. In Bare,
|
||||
// pass `[Bare.Addon.host]`.
|
||||
hosts: [],
|
||||
// The file extensions to look for when resolving dynamic addons.
|
||||
extensions: [],
|
||||
// A map of preresolved imports with keys being serialized directory URLs and
|
||||
// values being "imports" maps.
|
||||
resolutions
|
||||
}
|
||||
```
|
||||
|
||||
#### `for (const resolution of resolver)`
|
||||
|
||||
Synchronously iterate the addon resolution candidates. The resolved addon is the first candidate that exists as a file on the file system.
|
||||
|
||||
#### `for await (const resolution of resolver)`
|
||||
|
||||
Asynchronously iterate the addon resolution candidates. If `readPackage` returns promises, these will be awaited. The same comments as `for (const resolution of resolver)` apply.
|
||||
|
||||
### Algorithm
|
||||
|
||||
The following generator functions implement the resolution algorithm. The yielded values have the following shape:
|
||||
|
||||
**Package manifest**
|
||||
|
||||
```js
|
||||
next.value = {
|
||||
package: URL
|
||||
}
|
||||
```
|
||||
|
||||
If the package manifest identified by `next.value.package` exists, `generator.next()` must be passed the parsed JSON value of the manifest. If it does not exist, pass `null` instead.
|
||||
|
||||
**Resolution candidate**
|
||||
|
||||
```js
|
||||
next.value = {
|
||||
resolution: URL
|
||||
}
|
||||
```
|
||||
|
||||
If the addon identified by `next.value.resolution` exists, `generator.next()` may be passed `true` to signal that the resolution for the current set of conditions has been identified. If it does not exist, pass `false` instead.
|
||||
|
||||
To drive the generator functions, a loop like the following can be used:
|
||||
|
||||
```js
|
||||
const generator = resolve.addon(specifier, parentURL)
|
||||
|
||||
let next = generator.next()
|
||||
|
||||
while (next.done !== true) {
|
||||
const value = next.value
|
||||
|
||||
if (value.package) {
|
||||
// Read and parse `value.package` if it exists, otherwise `null`
|
||||
let info
|
||||
|
||||
next = generator.next(info)
|
||||
} else {
|
||||
const resolution = value.resolution
|
||||
|
||||
// `true` if `resolution` was the correct candidate, otherwise `false`
|
||||
let resolved
|
||||
|
||||
next = generator.next(resolved)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Options are the same as `resolve()` for all functions.
|
||||
|
||||
> [!WARNING]
|
||||
> These functions are currently subject to change between minor releases. If using them directly, make sure to specify a tilde range (`~1.2.3`) when declaring the module dependency.
|
||||
|
||||
#### `const generator = resolve.addon(specifier, parentURL[, options])`
|
||||
|
||||
#### `const generator = resolve.url(url, parentURL[, options])`
|
||||
|
||||
#### `const generator = resolve.package(packageSpecifier, packageVersion, parentURL[, options])`
|
||||
|
||||
#### `const generator = resolve.packageSelf(packageName, packageSubpath, packageVersion, parentURL[, options])`
|
||||
|
||||
#### `const generator = resolve.preresolved(directoryURL, resolutions[, options])`
|
||||
|
||||
#### `const generator = resolve.file(filename, parentURL[, options])`
|
||||
|
||||
#### `const generator = resolve.directory(dirname, version, parentURL[, options])`
|
||||
|
||||
#### `const generator = resolve.linked(name, version[, options])`
|
||||
|
||||
## License
|
||||
|
||||
Apache-2.0
|
||||
85
bot/node_modules/bare-addon-resolve/index.d.ts
generated
vendored
Normal file
85
bot/node_modules/bare-addon-resolve/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
import URL from 'bare-url'
|
||||
import { constants, type Builtins, type Conditions, type ResolutionsMap } from 'bare-module-resolve'
|
||||
|
||||
type JSON = string | number | boolean | JSON[] | { [key: string]: JSON }
|
||||
|
||||
interface ResolveOptions {
|
||||
builtinProtocol?: string
|
||||
builtins?: Builtins
|
||||
conditions?: Conditions
|
||||
extensions?: string[]
|
||||
host?: string
|
||||
hosts?: string[]
|
||||
linked?: boolean
|
||||
linkedProtocol?: string
|
||||
matchedConditions?: string[]
|
||||
resolutions?: ResolutionsMap
|
||||
}
|
||||
|
||||
declare function resolve(
|
||||
specifier: string,
|
||||
parentURL: URL,
|
||||
readPackage?: (url: URL) => JSON | null
|
||||
): Iterable<URL>
|
||||
|
||||
declare function resolve(
|
||||
specifier: string,
|
||||
parentURL: URL,
|
||||
readPackage: (url: URL) => Promise<JSON | null>
|
||||
): AsyncIterable<URL>
|
||||
|
||||
declare function resolve(
|
||||
specifier: string,
|
||||
parentURL: URL,
|
||||
opts: ResolveOptions,
|
||||
readPackage?: (url: URL) => JSON | null
|
||||
): Iterable<URL>
|
||||
|
||||
declare function resolve(
|
||||
specifier: string,
|
||||
parentURL: URL,
|
||||
opts: ResolveOptions,
|
||||
readPackage: (url: URL) => Promise<JSON | null>
|
||||
): AsyncIterable<URL>
|
||||
|
||||
declare namespace resolve {
|
||||
export { constants, type ResolveOptions }
|
||||
|
||||
export type Resolver = Generator<
|
||||
{ resolution: URL } | { package: URL },
|
||||
number,
|
||||
void | boolean | JSON | null
|
||||
>
|
||||
|
||||
export function addon(specifier: string, parentURL: URL, opts?: ResolveOptions): Resolver
|
||||
|
||||
export function url(specifier: string, parentURL: URL, opts?: ResolveOptions): Resolver
|
||||
|
||||
export function package(
|
||||
packageSpecifier: string,
|
||||
packageVersion: string,
|
||||
parentURL: URL,
|
||||
opts?: ResolveOptions
|
||||
): Resolver
|
||||
|
||||
export function packageSelf(
|
||||
packageName: string,
|
||||
packageSubpath: string,
|
||||
packageVersion: string,
|
||||
parentURL: URL,
|
||||
opts?: ResolveOptions
|
||||
): Resolver
|
||||
|
||||
export function file(filename: string, parentURL: URL, opts?: ResolveOptions): Resolver
|
||||
|
||||
export function directory(
|
||||
dirname: string,
|
||||
version: string,
|
||||
parentURL: URL,
|
||||
opts?: ResolveOptions
|
||||
): Resolver
|
||||
|
||||
export function linked(name: string, version?: string, opts?: ResolveOptions): Resolver
|
||||
}
|
||||
|
||||
export = resolve
|
||||
471
bot/node_modules/bare-addon-resolve/index.js
generated
vendored
Normal file
471
bot/node_modules/bare-addon-resolve/index.js
generated
vendored
Normal file
@ -0,0 +1,471 @@
|
||||
const resolve = require('bare-module-resolve')
|
||||
const { Version } = require('bare-semver')
|
||||
const errors = require('./lib/errors')
|
||||
|
||||
module.exports = exports = function resolve(specifier, parentURL, opts, readPackage) {
|
||||
if (typeof opts === 'function') {
|
||||
readPackage = opts
|
||||
opts = {}
|
||||
} else if (typeof readPackage !== 'function') {
|
||||
readPackage = defaultReadPackage
|
||||
}
|
||||
|
||||
return {
|
||||
*[Symbol.iterator]() {
|
||||
const generator = exports.addon(specifier, parentURL, opts)
|
||||
|
||||
let next = generator.next()
|
||||
|
||||
while (next.done !== true) {
|
||||
const value = next.value
|
||||
|
||||
if (value.package) {
|
||||
next = generator.next(readPackage(value.package))
|
||||
} else {
|
||||
next = generator.next(yield value.resolution)
|
||||
}
|
||||
}
|
||||
|
||||
return next.value
|
||||
},
|
||||
|
||||
async *[Symbol.asyncIterator]() {
|
||||
const generator = exports.addon(specifier, parentURL, opts)
|
||||
|
||||
let next = generator.next()
|
||||
|
||||
while (next.done !== true) {
|
||||
const value = next.value
|
||||
|
||||
if (value.package) {
|
||||
next = generator.next(await readPackage(value.package))
|
||||
} else {
|
||||
next = generator.next(yield value.resolution)
|
||||
}
|
||||
}
|
||||
|
||||
return next.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function defaultReadPackage() {
|
||||
return null
|
||||
}
|
||||
|
||||
const { UNRESOLVED, YIELDED, RESOLVED } = resolve.constants
|
||||
|
||||
exports.constants = {
|
||||
UNRESOLVED,
|
||||
YIELDED,
|
||||
RESOLVED
|
||||
}
|
||||
|
||||
exports.addon = function* (specifier, parentURL, opts = {}) {
|
||||
const { resolutions = null } = opts
|
||||
|
||||
if (exports.startsWithWindowsDriveLetter(specifier)) {
|
||||
specifier = '/' + specifier
|
||||
}
|
||||
|
||||
let status
|
||||
|
||||
if (resolutions) {
|
||||
status = yield* resolve.preresolved(specifier, resolutions, parentURL, opts)
|
||||
|
||||
if (status) return status
|
||||
}
|
||||
|
||||
status = yield* exports.url(specifier, parentURL, opts)
|
||||
|
||||
if (status) return status
|
||||
|
||||
let version = null
|
||||
|
||||
const i = specifier.lastIndexOf('@')
|
||||
|
||||
if (i > 0) {
|
||||
version = specifier.substring(i + 1)
|
||||
|
||||
try {
|
||||
Version.parse(version)
|
||||
|
||||
specifier = specifier.substring(0, i)
|
||||
} catch {
|
||||
version = null
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
specifier === '.' ||
|
||||
specifier === '..' ||
|
||||
specifier[0] === '/' ||
|
||||
specifier[0] === '\\' ||
|
||||
specifier.startsWith('./') ||
|
||||
specifier.startsWith('.\\') ||
|
||||
specifier.startsWith('../') ||
|
||||
specifier.startsWith('..\\')
|
||||
) {
|
||||
status = yield* exports.file(specifier, parentURL, opts)
|
||||
|
||||
if (status === RESOLVED) return status
|
||||
|
||||
return yield* exports.directory(specifier, version, parentURL, opts)
|
||||
}
|
||||
|
||||
return yield* exports.package(specifier, version, parentURL, opts)
|
||||
}
|
||||
|
||||
exports.url = function* (url, parentURL, opts = {}) {
|
||||
let resolution
|
||||
try {
|
||||
resolution = new URL(url)
|
||||
} catch {
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
const resolved = yield { resolution }
|
||||
|
||||
return resolved ? RESOLVED : YIELDED
|
||||
}
|
||||
|
||||
exports.package = function* (packageSpecifier, packageVersion, parentURL, opts = {}) {
|
||||
if (packageSpecifier === '') {
|
||||
throw errors.INVALID_ADDON_SPECIFIER(
|
||||
`Addon specifier '${packageSpecifier}' is not a valid package name`
|
||||
)
|
||||
}
|
||||
|
||||
let packageName
|
||||
|
||||
if (packageSpecifier[0] !== '@') {
|
||||
packageName = packageSpecifier.split('/', 1).join()
|
||||
} else {
|
||||
if (!packageSpecifier.includes('/')) {
|
||||
throw errors.INVALID_ADDON_SPECIFIER(
|
||||
`Addon specifier '${packageSpecifier}' is not a valid package name`
|
||||
)
|
||||
}
|
||||
|
||||
packageName = packageSpecifier.split('/', 2).join('/')
|
||||
}
|
||||
|
||||
if (packageName[0] === '.' || packageName.includes('\\') || packageName.includes('%')) {
|
||||
throw errors.INVALID_ADDON_SPECIFIER(
|
||||
`Addon specifier '${packageSpecifier}' is not a valid package name`
|
||||
)
|
||||
}
|
||||
|
||||
const packageSubpath = '.' + packageSpecifier.substring(packageName.length)
|
||||
|
||||
const status = yield* exports.packageSelf(
|
||||
packageName,
|
||||
packageSubpath,
|
||||
packageVersion,
|
||||
parentURL,
|
||||
opts
|
||||
)
|
||||
|
||||
if (status) return status
|
||||
|
||||
parentURL = new URL(parentURL.href)
|
||||
|
||||
do {
|
||||
const packageURL = new URL('node_modules/' + packageName + '/', parentURL)
|
||||
|
||||
parentURL.pathname = parentURL.pathname.substring(0, parentURL.pathname.lastIndexOf('/'))
|
||||
|
||||
const info = yield { package: new URL('package.json', packageURL) }
|
||||
|
||||
if (info) {
|
||||
return yield* exports.directory(packageSubpath, packageVersion, packageURL, opts)
|
||||
}
|
||||
} while (parentURL.pathname !== '' && parentURL.pathname !== '/')
|
||||
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
exports.packageSelf = function* (
|
||||
packageName,
|
||||
packageSubpath,
|
||||
packageVersion,
|
||||
parentURL,
|
||||
opts = {}
|
||||
) {
|
||||
for (const packageURL of resolve.lookupPackageScope(parentURL, opts)) {
|
||||
const info = yield { package: packageURL }
|
||||
|
||||
if (info) {
|
||||
if (info.name === packageName) {
|
||||
return yield* exports.directory(packageSubpath, packageVersion, packageURL, opts)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
exports.lookupPrebuildsScope = function* lookupPrebuildsScope(url, opts = {}) {
|
||||
const scopeURL = new URL(url.href)
|
||||
|
||||
do {
|
||||
yield new URL('prebuilds/', scopeURL)
|
||||
|
||||
scopeURL.pathname = scopeURL.pathname.substring(0, scopeURL.pathname.lastIndexOf('/'))
|
||||
|
||||
if (
|
||||
scopeURL.pathname.length === 3 &&
|
||||
exports.isWindowsDriveLetter(scopeURL.pathname.substring(1))
|
||||
) {
|
||||
break
|
||||
}
|
||||
} while (scopeURL.pathname !== '' && scopeURL.pathname !== '/')
|
||||
}
|
||||
|
||||
exports.file = function* (filename, parentURL, opts = {}) {
|
||||
if (
|
||||
filename === '.' ||
|
||||
filename === '..' ||
|
||||
filename[filename.length - 1] === '/' ||
|
||||
filename[filename.length - 1] === '\\'
|
||||
) {
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
if (parentURL.protocol === 'file:' && /%2f|%5c/i.test(filename)) {
|
||||
throw errors.INVALID_ADDON_SPECIFIER(`Addon specifier '${filename}' is invalid`)
|
||||
}
|
||||
|
||||
const { extensions = [] } = opts
|
||||
|
||||
let status = UNRESOLVED
|
||||
|
||||
for (let ext of extensions) {
|
||||
if (filename.endsWith(ext)) ext = ''
|
||||
|
||||
if (yield { resolution: new URL(filename + ext, parentURL) }) {
|
||||
return RESOLVED
|
||||
}
|
||||
|
||||
status = YIELDED
|
||||
}
|
||||
|
||||
return status
|
||||
}
|
||||
|
||||
exports.directory = function* (dirname, version, parentURL, opts = {}) {
|
||||
const {
|
||||
host = null, // Shorthand for single host resolution
|
||||
hosts = host !== null ? [host] : [],
|
||||
builtins = [],
|
||||
matchedConditions = []
|
||||
} = opts
|
||||
|
||||
let directoryURL
|
||||
|
||||
if (dirname[dirname.length - 1] === '/' || dirname[dirname.length - 1] === '\\') {
|
||||
directoryURL = new URL(dirname, parentURL)
|
||||
} else {
|
||||
directoryURL = new URL(dirname + '/', parentURL)
|
||||
}
|
||||
|
||||
const unversioned = version === null
|
||||
|
||||
let name = null
|
||||
|
||||
const info = yield { package: new URL('package.json', directoryURL) }
|
||||
|
||||
if (info) {
|
||||
if (typeof info.name === 'string' && info.name !== '') {
|
||||
if (info.name.includes('__')) {
|
||||
throw errors.INVALID_PACKAGE_NAME(`Package name '${info.name}' is invalid`)
|
||||
}
|
||||
|
||||
name = info.name.replace(/\//g, '__').replace(/^@/, '')
|
||||
} else {
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
if (typeof info.version === 'string' && info.version !== '') {
|
||||
if (version !== null && info.version !== version) return UNRESOLVED
|
||||
|
||||
version = info.version
|
||||
}
|
||||
} else {
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
let status
|
||||
|
||||
status = yield* resolve.builtinTarget(name, version, builtins, opts)
|
||||
|
||||
if (status) return status
|
||||
|
||||
for (const prebuildsURL of exports.lookupPrebuildsScope(directoryURL, opts)) {
|
||||
status = UNRESOLVED
|
||||
|
||||
for (const host of hosts) {
|
||||
const conditions = host.split('-')
|
||||
|
||||
const universal = supportsUniversalPrebuilds(host)
|
||||
? conditions.with(1, 'universal').join('-')
|
||||
: null
|
||||
|
||||
matchedConditions.push(...conditions)
|
||||
|
||||
if (version !== null) {
|
||||
status |= yield* exports.file(host + '/' + name + '@' + version, prebuildsURL, opts)
|
||||
|
||||
if (universal) {
|
||||
status |= yield* exports.file(universal + '/' + name + '@' + version, prebuildsURL, opts)
|
||||
}
|
||||
}
|
||||
|
||||
if (unversioned) {
|
||||
status |= yield* exports.file(host + '/' + name, prebuildsURL, opts)
|
||||
|
||||
if (universal) {
|
||||
status |= yield* exports.file(universal + '/' + name, prebuildsURL, opts)
|
||||
}
|
||||
}
|
||||
|
||||
for (const _ of conditions) matchedConditions.pop()
|
||||
}
|
||||
|
||||
if (status === RESOLVED) return status
|
||||
}
|
||||
|
||||
return yield* exports.linked(name, version, opts)
|
||||
}
|
||||
|
||||
exports.linked = function* (name, version = null, opts = {}) {
|
||||
const {
|
||||
linked = true,
|
||||
host = null, // Shorthand for single host resolution
|
||||
hosts = host !== null ? [host] : [],
|
||||
matchedConditions = []
|
||||
} = opts
|
||||
|
||||
if (linked === false || hosts.length === 0) return UNRESOLVED
|
||||
|
||||
let status = UNRESOLVED
|
||||
|
||||
for (const host of hosts) {
|
||||
const [platform = null] = host.split('-', 1)
|
||||
|
||||
if (platform === null) continue
|
||||
|
||||
matchedConditions.push(platform)
|
||||
|
||||
status |= yield* platformArtefact(name, version, platform, opts)
|
||||
|
||||
matchedConditions.pop()
|
||||
}
|
||||
|
||||
return status
|
||||
}
|
||||
|
||||
function* platformArtefact(name, version = null, platform, opts = {}) {
|
||||
const { linkedProtocol = 'linked:' } = opts
|
||||
|
||||
if (platform === 'darwin' || platform === 'ios') {
|
||||
if (version !== null) {
|
||||
if (
|
||||
yield {
|
||||
resolution: new URL(`${linkedProtocol}${name}.${version}.framework/${name}.${version}`)
|
||||
}
|
||||
) {
|
||||
return RESOLVED
|
||||
}
|
||||
|
||||
if (platform === 'darwin') {
|
||||
if (
|
||||
yield {
|
||||
resolution: new URL(`${linkedProtocol}lib${name}.${version}.dylib`)
|
||||
}
|
||||
) {
|
||||
return RESOLVED
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
yield {
|
||||
resolution: new URL(`${linkedProtocol}${name}.framework/${name}`)
|
||||
}
|
||||
) {
|
||||
return RESOLVED
|
||||
}
|
||||
|
||||
if (platform === 'darwin') {
|
||||
if (
|
||||
yield {
|
||||
resolution: new URL(`${linkedProtocol}lib${name}.dylib`)
|
||||
}
|
||||
) {
|
||||
return RESOLVED
|
||||
}
|
||||
}
|
||||
|
||||
return YIELDED
|
||||
}
|
||||
|
||||
if (platform === 'linux' || platform === 'android') {
|
||||
if (version !== null) {
|
||||
if (
|
||||
yield {
|
||||
resolution: new URL(`${linkedProtocol}lib${name}.${version}.so`)
|
||||
}
|
||||
) {
|
||||
return RESOLVED
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
yield {
|
||||
resolution: new URL(`${linkedProtocol}lib${name}.so`)
|
||||
}
|
||||
) {
|
||||
return RESOLVED
|
||||
}
|
||||
|
||||
return YIELDED
|
||||
}
|
||||
|
||||
if (platform === 'win32') {
|
||||
if (version !== null) {
|
||||
if (
|
||||
yield {
|
||||
resolution: new URL(`${linkedProtocol}${name}-${version}.dll`)
|
||||
}
|
||||
) {
|
||||
return RESOLVED
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
yield {
|
||||
resolution: new URL(`${linkedProtocol}${name}.dll`)
|
||||
}
|
||||
) {
|
||||
return RESOLVED
|
||||
}
|
||||
}
|
||||
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
exports.isWindowsDriveLetter = resolve.isWindowsDriveLetter
|
||||
|
||||
exports.startsWithWindowsDriveLetter = resolve.startsWithWindowsDriveLetter
|
||||
|
||||
function supportsUniversalPrebuilds(host) {
|
||||
return (
|
||||
host === 'darwin-arm64' ||
|
||||
host === 'darwin-x64' ||
|
||||
host === 'ios-arm64-simulator' ||
|
||||
host === 'ios-x64-simulator'
|
||||
)
|
||||
}
|
||||
8
bot/node_modules/bare-addon-resolve/lib/errors.d.ts
generated
vendored
Normal file
8
bot/node_modules/bare-addon-resolve/lib/errors.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
declare class AddonResolveError extends Error {
|
||||
readonly code: string
|
||||
|
||||
static INVALID_ADDON_SPECIFIER(msg: string): AddonResolveError
|
||||
static INVALID_PACKAGE_NAME(msg: string): AddonResolveError
|
||||
}
|
||||
|
||||
export = AddonResolveError
|
||||
30
bot/node_modules/bare-addon-resolve/lib/errors.js
generated
vendored
Normal file
30
bot/node_modules/bare-addon-resolve/lib/errors.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
module.exports = class AddonResolveError extends Error {
|
||||
constructor(msg, code, fn = AddonResolveError) {
|
||||
super(`${code}: ${msg}`)
|
||||
this.code = code
|
||||
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, fn)
|
||||
}
|
||||
}
|
||||
|
||||
get name() {
|
||||
return 'AddonResolveError'
|
||||
}
|
||||
|
||||
static INVALID_ADDON_SPECIFIER(msg) {
|
||||
return new AddonResolveError(
|
||||
msg,
|
||||
'INVALID_ADDON_SPECIFIER',
|
||||
AddonResolveError.INVALID_ADDON_SPECIFIER
|
||||
)
|
||||
}
|
||||
|
||||
static INVALID_PACKAGE_NAME(msg) {
|
||||
return new AddonResolveError(
|
||||
msg,
|
||||
'INVALID_PACKAGE_NAME',
|
||||
AddonResolveError.INVALID_PACKAGE_NAME
|
||||
)
|
||||
}
|
||||
}
|
||||
52
bot/node_modules/bare-addon-resolve/package.json
generated
vendored
Normal file
52
bot/node_modules/bare-addon-resolve/package.json
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "bare-addon-resolve",
|
||||
"version": "1.10.0",
|
||||
"description": "Low-level addon resolution algorithm for Bare",
|
||||
"exports": {
|
||||
"./package": "./package.json",
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"./errors": {
|
||||
"types": "./lib/errors.d.ts",
|
||||
"default": "./lib/errors.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "prettier . --check && bare test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/holepunchto/bare-addon-resolve.git"
|
||||
},
|
||||
"author": "Holepunch",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/holepunchto/bare-addon-resolve/issues"
|
||||
},
|
||||
"homepage": "https://github.com/holepunchto/bare-addon-resolve#readme",
|
||||
"dependencies": {
|
||||
"bare-module-resolve": "^1.10.0",
|
||||
"bare-semver": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bare-url": "^2.1.3",
|
||||
"brittle": "^3.2.1",
|
||||
"prettier": "^3.3.3",
|
||||
"prettier-config-holepunch": "^2.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bare-url": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bare-url": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
201
bot/node_modules/bare-module-resolve/LICENSE
generated
vendored
Normal file
201
bot/node_modules/bare-module-resolve/LICENSE
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
352
bot/node_modules/bare-module-resolve/README.md
generated
vendored
Normal file
352
bot/node_modules/bare-module-resolve/README.md
generated
vendored
Normal file
@ -0,0 +1,352 @@
|
||||
# bare-module-resolve
|
||||
|
||||
Low-level module resolution algorithm for Bare. The algorithm is implemented as a generator function that yields either package manifests to be read or resolution candidates to be tested by the caller. As a convenience, the main export is a synchronous and asynchronous iterable that relies on package manifests being read by a callback. For asynchronous iteration, the callback may return promises which will be awaited before being passed to the generator.
|
||||
|
||||
```
|
||||
npm i bare-module-resolve
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
For synchronous resolution:
|
||||
|
||||
```js
|
||||
const resolve = require('bare-module-resolve')
|
||||
|
||||
function readPackage(url) {
|
||||
// Read and parse `url` if it exists, otherwise `null`
|
||||
}
|
||||
|
||||
for (const resolution of resolve('./file.js', new URL('file:///directory/'), readPackage)) {
|
||||
console.log(resolution)
|
||||
}
|
||||
```
|
||||
|
||||
For asynchronous resolution:
|
||||
|
||||
```js
|
||||
const resolve = require('bare-module-resolve')
|
||||
|
||||
async function readPackage(url) {
|
||||
// Read and parse `url` if it exists, otherwise `null`
|
||||
}
|
||||
|
||||
for await (const resolution of resolve('./file.js', new URL('file:///directory/'), readPackage)) {
|
||||
console.log(resolution)
|
||||
}
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
#### `const resolver = resolve(specifier, parentURL[, options][, readPackage])`
|
||||
|
||||
Resolve `specifier` relative to `parentURL`, which must be a WHATWG `URL` instance. `readPackage` is called with a `URL` instance for every package manifest to be read and must either return the parsed JSON package manifest, if it exists, or `null`. If `readPackage` returns a promise, synchronous iteration is not supported.
|
||||
|
||||
Options include:
|
||||
|
||||
```js
|
||||
options = {
|
||||
// A default "imports" map to apply to all specifiers. Follows the same
|
||||
// syntax and rules as the "imports" property defined in `package.json`.
|
||||
imports,
|
||||
// A list of builtin module specifiers. If matched, the protocol of the
|
||||
// resolved URL will be `builtinProtocol`.
|
||||
builtins: [],
|
||||
// The protocol to use for resolved builtin module specifiers.
|
||||
builtinProtocol: 'builtin:',
|
||||
// A list of module specifiers whose resolution should be deferred. If matched,
|
||||
// the protocol of the resolved URL will be `deferredProtocol`.
|
||||
defer: [],
|
||||
// The protocol to use for resolved deferred module specifiers.
|
||||
deferredProtocol: 'deferred:',
|
||||
// The supported import conditions. "default" is always recognized.
|
||||
conditions: [],
|
||||
// An array reference which will contain the matched conditions when yielding
|
||||
// resolutions.
|
||||
matchedConditions: [],
|
||||
// The supported engine versions.
|
||||
engines: {},
|
||||
// The file extensions to look for. Must be provided to support extensionless
|
||||
// specifier resolution and directory support, such as resolving './foo' to
|
||||
// './foo.js' or './foo/index.js'.
|
||||
extensions: [],
|
||||
// A map of preresolved imports with keys being serialized parent URLs and
|
||||
// values being "imports" maps.
|
||||
resolutions
|
||||
}
|
||||
```
|
||||
|
||||
#### `for (const resolution of resolver)`
|
||||
|
||||
Synchronously iterate the module resolution candidates. The resolved module is the first candidate that exists, either as a file on a file system, a resource at a URL, or something else entirely.
|
||||
|
||||
#### `for await (const resolution of resolver)`
|
||||
|
||||
Asynchronously iterate the module resolution candidates. If `readPackage` returns promises, these will be awaited. The same comments as `for (const resolution of resolver)` apply.
|
||||
|
||||
### Algorithm
|
||||
|
||||
The following generator functions implement the resolution algorithm, which has been adapted from the Node.js resolution algorithms for CommonJS and ES modules. Unlike Node.js, Bare uses the same resolution algorithm for both module formats. The yielded values have the following shape:
|
||||
|
||||
**Package manifest**
|
||||
|
||||
```js
|
||||
next.value = {
|
||||
package: URL
|
||||
}
|
||||
```
|
||||
|
||||
If the package manifest identified by `next.value.package` exists, `generator.next()` must be passed the parsed JSON value of the manifest. If it does not exist, pass `null` instead.
|
||||
|
||||
**Resolution candidate**
|
||||
|
||||
```js
|
||||
next.value = {
|
||||
resolution: URL
|
||||
}
|
||||
```
|
||||
|
||||
If the module identified by `next.value.resolution` exists, `generator.next()` may be passed `true` to signal that the resolution for the current set of conditions has been identified. If it does not exist, pass `false` instead.
|
||||
|
||||
To drive the generator functions, a loop like the following can be used:
|
||||
|
||||
```js
|
||||
const generator = resolve.module(specifier, parentURL)
|
||||
|
||||
let next = generator.next()
|
||||
|
||||
while (next.done !== true) {
|
||||
const value = next.value
|
||||
|
||||
if (value.package) {
|
||||
// Read and parse `value.package` if it exists, otherwise `null`
|
||||
let info
|
||||
|
||||
next = generator.next(info)
|
||||
} else {
|
||||
const resolution = value.resolution
|
||||
|
||||
// `true` if `resolution` was the correct candidate, otherwise `false`
|
||||
let resolved
|
||||
|
||||
next = generator.next(resolved)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Options are the same as `resolve()` for all functions.
|
||||
|
||||
> [!WARNING]
|
||||
> These functions are currently subject to change between minor releases. If using them directly, make sure to specify a tilde range (`~1.2.3`) when declaring the module dependency.
|
||||
|
||||
#### `const generator = resolve.module(specifier, parentURL[, options])`
|
||||
|
||||
1. If `specifier` [starts with a Windows drive letter](https://url.spec.whatwg.org/#start-with-a-windows-drive-letter):
|
||||
1. Prepend `/` to `specifier`.
|
||||
2. If `options.resolutions` is set:
|
||||
1. If `preresolved(specifier, options.resolutions, parentURL, options)` yields, return.
|
||||
3. If `url(specifier, parentURL, options)` yields, return.
|
||||
4. If `packageImports(specifier, parentURL, options)` yields, return.
|
||||
5. If `specifier` equals `.` or `..`, or if `specifier` starts with `/`, `\`, `./`, `.\`, `../`, or `..\`:
|
||||
1. If `options.imports` is set:
|
||||
1. If `packageImportsExports(specifier, options.imports, parentURL, true, options)` yields, return.
|
||||
2. If `deferred(specifier, options)` yields, return.
|
||||
3. If `file(specifier, parentURL, false, options)` resolves, return.
|
||||
4. Return `directory(specifier, parentURL, options)`.
|
||||
6. Return `package(specifier, parentURL, options)`.
|
||||
|
||||
#### `const generator = resolve.url(url, parentURL[, options])`
|
||||
|
||||
1. If `url` is not a valid URL, return.
|
||||
2. If `options.imports` is set:
|
||||
1. If `packageImportsExports(url.href, options.imports, parentURL, true, options)` yields, return.
|
||||
3. If `url.protocol` equals `options.deferredProtocol`:
|
||||
1. Let `specifier` be `url.pathname`.
|
||||
2. If `options.resolutions` is set:
|
||||
1. Let `imports` be `options.resolutions[parentURL]`.
|
||||
2. If `imports` is a non-`null` object:
|
||||
1. Set `imports[specifier]` to `null`.
|
||||
3. Return `module(specifier, parentURL, options)`.
|
||||
4. If `url.protocol` equals `node:`:
|
||||
1. Let `specifier` be `url.pathname`.
|
||||
2. If `specifier` equals `.` or `..`, or if `specifier` starts with `/`, `\`, `./`, `.\`, `../`, or `..\`, throw.
|
||||
3. Return `package(specifier, parentURL, options)`.
|
||||
5. Yield `url`.
|
||||
|
||||
#### `const generator = resolve.preresolved(specifier, resolutions, parentURL[, options])`
|
||||
|
||||
1. Let `imports` be `resolutions[parentURL]`.
|
||||
2. If `imports` is a non-`null` object:
|
||||
1. Return `packageImportsExports(specifier, imports, parentURL, true, options)`.
|
||||
|
||||
#### `const generator = resolve.deferred(specifier[, options])`
|
||||
|
||||
1. If `options.defer` includes `specifier`:
|
||||
1. Yield `options.deferredProtocol` concatenated with `specifier` and return.
|
||||
|
||||
#### `const generator = resolve.package(packageSpecifier, parentURL[, options])`
|
||||
|
||||
1. If `packageSpecifier` is the empty string, throw.
|
||||
2. If `packageSpecifier` does not start with `@`:
|
||||
1. Set `packageName` to the substring of `packageSpecifier` until the first `/` or the end of the string.
|
||||
3. Let `packageName` be `undefined`.
|
||||
4. Otherwise:
|
||||
1. If `packageSpecifier` does not include `/`, throw.
|
||||
2. Set `packageName` to the substring of `packageSpecifier` until the second `/` or the end of the string.
|
||||
5. If `packageName` starts with `.` or includes `\` or `%`, throw.
|
||||
6. If `builtinTarget(packageSpecifier, null, options.builtins, options)` yields, return.
|
||||
7. If `deferred(packageSpecifier, options)` yields, return.
|
||||
8. Let `packageSubpath` be `.` concatenated with the substring of `packageSpecifier` from the position at the length of `packageName`.
|
||||
9. If `packageSelf(packageName, packageSubpath, parentURL, options)` yields, return.
|
||||
10. For each value `packageURL` of `lookupPackageRoot(packageName, parentURL, options)`:
|
||||
1. Let `info` be the result of yielding `packageURL`.
|
||||
2. If `info` is not `null`:
|
||||
1. If `info.engines` is set:
|
||||
1. Call `validateEngines(packageURL, info.engines, options)`.
|
||||
2. If `info.exports` is set:
|
||||
1. Return `packageExports(packageURL, packageSubpath, info.exports, options)`.
|
||||
3. If `packageSubpath` is `.`:
|
||||
1. If `info.main` is a non-empty string:
|
||||
1. Set `packageSubpath` to `info.main`.
|
||||
2. Otherwise:
|
||||
1. Return `file('index', packageURL, true, options)`.
|
||||
4. If `file(packageSubpath, packageURL, false, options)` resolves, return.
|
||||
5. Return `directory(packageSubpath, packageURL, options)`.
|
||||
|
||||
#### `const generator = resolve.packageSelf(packageName, packageSubpath, parentURL[, options])`
|
||||
|
||||
1. For each value `packageURL` of `lookupPackageScope(parentURL, options)`:
|
||||
1. Let `info` be the result of yielding `packageURL`.
|
||||
2. If `info` is not `null`:
|
||||
1. If `info.name` does not equal `packageName`, return.
|
||||
2. If `info.exports` is set:
|
||||
1. Return `packageExports(packageURL, packageSubpath, info.exports, options)`.
|
||||
3. If `packageSubpath` is `.`:
|
||||
1. If `info.main` is a non-empty string:
|
||||
1. Set `packageSubpath` to `info.main`.
|
||||
2. Otherwise:
|
||||
1. Return `file('index', packageURL, true, options)`.
|
||||
4. If `file(packageSubpath, packageURL, false, options)` resolves, return.
|
||||
5. Return `directory(packageSubpath, packageURL, options)`.
|
||||
|
||||
#### `const generator = resolve.packageExports(packageURL, subpath, exports[, options])`
|
||||
|
||||
1. If `subpath` is `.`:
|
||||
1. Let `mainExport` be `undefined`.
|
||||
2. If `exports` is a string or an array:
|
||||
1. Set `mainExport` to `exports`.
|
||||
3. If `exports` is a non-`null` object:
|
||||
1. If some keys of `exports` start with `.`:
|
||||
1. If `.` is a key of `exports`:
|
||||
1. Set `mainExport` to `exports['.']`.
|
||||
2. Otherwise:
|
||||
1. Set `mainExport` to `exports`.
|
||||
4. If `mainExport` is not `undefined`:
|
||||
1. If `packageTarget(packageURL, mainExport, null, false, options)` yields, return.
|
||||
2. Otherwise, if `exports` is a non-`null` object:
|
||||
1. If every key of `exports` starts with `.`:
|
||||
1. If `packageImportsExports(subpath, exports, packageURL, false, options)` yields, return.
|
||||
3. Throw.
|
||||
|
||||
#### `const generator = resolve.packageImports(specifier, parentURL[, options])`
|
||||
|
||||
1. If `specifier` is `#` or starts with `#/`, throw.
|
||||
2. For each value `packageURL` of `lookupPackageScope(parentURL, options)`:
|
||||
1. Let `info` be the result of yielding `packageURL`.
|
||||
2. If `info` is not `null`:
|
||||
1. If `info.imports` is set:
|
||||
1. If `packageImportsExports(specifier, info.imports, packageURL, true, options)` yields, return.
|
||||
2. If specifier starts with `#`, throw.
|
||||
3. Return.
|
||||
3. If `options.imports` is set:
|
||||
1. If `packageImportsExports(url.href, options.imports, parentURL, true, options)` yields, return.
|
||||
|
||||
#### `const generator = resolve.packageImportsExports(matchKey, matchObject, packageURL, isImports[, options])`
|
||||
|
||||
1. If `matchKey` is a key of `matchObject` and `matchKey` does not include `*`:
|
||||
1. Let `target` be `matchObject[matchKey]`.
|
||||
2. Return `packageTarget(packageURL, target, null, isImports, options)`.
|
||||
2. Let `expansionKeys` be the keys of `matchObject` that include `*` sorted by `patternKeyCompare`.
|
||||
3. For each value `expansionKey` of `expansionKeys`:
|
||||
1. Let `patternBase` be the substring of `expansionKey` until the first `*`.
|
||||
2. If `matchKey` starts with but isn't equal to `patternBase`:
|
||||
1. Let `patternTrailer` be the substring of `expansionKey` from the position at the index after the first `*`.
|
||||
2. If `patternTrailer` is the empty string, or if `matchKey` ends with `patternTrailer` and the length of `matchKey` is greater than or equal to the length of `expansionKey`:
|
||||
1. Let `target` be `matchObject[expansionKey]`.
|
||||
2. Let `patternMatch` be the substring of `matchKey` from the position at the length of `patternBase` until the length of `matchKey` minus the length of `patternTrailer`.
|
||||
3. Return `packageTarget(packageURL, target, patternMatch, isImports, options)`.
|
||||
|
||||
#### `const generator = resolve.packageTarget(packageURL, target, patternMatch, isImports[, options])`
|
||||
|
||||
1. If `target` is a string:
|
||||
1. If `target` does not start with `./` and `isImports` is `false`, throw.
|
||||
2. If `patternMatch` is not `null`:
|
||||
1. Replace every instance of `*` in `target` with `patternMatch`.
|
||||
3. If `url(target, packageURL, options)` yields, return.
|
||||
4. If `target` equals `.` or `..`, or if `target` starts with `/`, `./`, or `../`:
|
||||
1. Yield the resolution of `target` relative to `packageURL` and return.
|
||||
5. Return `package(target, packageURL, options)`.
|
||||
2. If `target` is an array:
|
||||
1. For each value `targetValue` of `target`:
|
||||
1. If `packageTarget(packageURL, targetValue, patternMatch, isImports, options)` yields, return.
|
||||
3. If `target` is a non-`null` object:
|
||||
1. For each key `condition` of `target`:
|
||||
1. If `condition` equals `default` or if `options.conditions` includes `condition`:
|
||||
1. Let `targetValue` be `target[condition]`.
|
||||
2. Return `packageTarget(packageURL, targetValue, patternMatch, isImports, options)`.
|
||||
|
||||
#### `const generator = resolve.builtinTarget(packageSpecifier, packageVersion, target[, options])`
|
||||
|
||||
1. If `target` is a string:
|
||||
1. If `target` does not start with `@`:
|
||||
1. Let `targetName` be the substring of `target` until the first `@` or the end of the string.
|
||||
2. Let `targetVersion` be the substring of `target` from the character following the first `@` and to the end of string, or `null` if no such substring exists.
|
||||
2. Otherwise:
|
||||
1. Let `targetName` be the substring of `target` until the second `@` or the end of the string.
|
||||
2. Let `targetVersion` be the substring of `target` from the character following the second `@` and to the end of string, or `null` if no such substring exists.
|
||||
3. If `packageSpecifier` equals `targetName`:
|
||||
1. If `packageVersion` is `null` and `targetVersion` is `null`:
|
||||
1. Yield `options.builtinProtocol` concatenated with `packageSpecifier` and return.
|
||||
2. Let `version` be `null`.
|
||||
3. If `packageVersion` is `null`, let `version` be `targetVersion`.
|
||||
4. Otherwise, if `targetVersion` is either `null` or equals `packageVersion`, let `version` be `packageVersion`
|
||||
5. If `version` is not `null`:
|
||||
1. Yield `options.builtinProtocol` concatenated with `packageSpecifier`, `@`, and `version` and return.
|
||||
2. If `target` is an array:
|
||||
1. For each value `targetValue` of `target`:
|
||||
1. If `builtinTarget(packageSpecifier, packageVersion, targetValue, options)` yields, return.
|
||||
3. If `target` is a non-`null` object:
|
||||
1. For each key `condition` of `target`:
|
||||
1. If `condition` equals `default` or if `options.conditions` includes `condition`:
|
||||
1. Let `targetValue` be `target[condition]`.
|
||||
2. Return `builtinTarget(packageSpecifier, packageVersion, targetValue, options)`.
|
||||
|
||||
#### `const generator = resolve.file(filename, parentURL, isIndex[, options])`
|
||||
|
||||
1. If `filename` equals `.` or `..`, or if `filename` ends with `/` or `\`, return.
|
||||
2. If `parentURL` is a `file:` URL and `filename` includes encoded `/` or `\`, throw.
|
||||
3. If `isIndex` is `false`:
|
||||
1. Yield the resolution of `filename` relative to `parentURL`.
|
||||
4. For each value `ext` of `options.extensions`:
|
||||
1. If `filename` ends with `ext`, continue.
|
||||
2. Yield the resolution of `filename` concatenated with `ext` relative to `parentURL`.
|
||||
|
||||
#### `const generator = resolve.directory(dirname, parentURL[, options])`
|
||||
|
||||
1. Let `directoryURL` be `undefined`.
|
||||
2. If `dirname` ends with `/` or `\`:
|
||||
1. Set `directoryURL` to the resolution of `dirname` relative to `parentURL`.
|
||||
3. Otherwise:
|
||||
1. Set `directoryURL` to the resolution of `dirname` concatenated with `/` relative to `parentURL`.
|
||||
4. Let `info` be the result of yielding the resolution of `package.json` relative to `directoryURL`.
|
||||
5. If `info` is not `null`:
|
||||
1. If `info.exports` is set:
|
||||
1. Return `packageExports(directoryURL, '.', info.exports, options)`.
|
||||
2. If `info.main` is a non-empty string:
|
||||
1. If `file(info.main, directoryURL, false, options)` resolves, return.
|
||||
2. Return `directory(info.main, directoryURL, options)`.
|
||||
6. Return `file('index', directoryURL, true, options)`.
|
||||
|
||||
## License
|
||||
|
||||
Apache-2.0
|
||||
147
bot/node_modules/bare-module-resolve/index.d.ts
generated
vendored
Normal file
147
bot/node_modules/bare-module-resolve/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,147 @@
|
||||
import URL from 'bare-url'
|
||||
|
||||
type ConditionalSpecifier =
|
||||
| string
|
||||
| ConditionalSpecifier[]
|
||||
| { [condition: string]: ConditionalSpecifier }
|
||||
|
||||
type ImportsMap = { [specifier: string]: ConditionalSpecifier }
|
||||
|
||||
type ExportsMap = ImportsMap
|
||||
|
||||
type ResolutionsMap = { [href: string]: ImportsMap }
|
||||
|
||||
type Builtins = ConditionalSpecifier[]
|
||||
|
||||
type Conditions = string[] | Conditions[]
|
||||
|
||||
type Engines = { [name: string]: string }
|
||||
|
||||
type JSON = string | number | boolean | JSON[] | { [key: string]: JSON }
|
||||
|
||||
interface ResolveOptions {
|
||||
builtinProtocol?: string
|
||||
builtins?: Builtins
|
||||
conditions?: Conditions
|
||||
defer?: string[]
|
||||
deferredProtocol?: string
|
||||
engines?: Engines
|
||||
extensions?: string[]
|
||||
imports?: ImportsMap
|
||||
matchedConditions?: string[]
|
||||
resolutions?: ResolutionsMap
|
||||
}
|
||||
|
||||
declare function resolve(
|
||||
specifier: string,
|
||||
parentURL: URL,
|
||||
readPackage?: (url: URL) => JSON | null
|
||||
): Iterable<URL>
|
||||
|
||||
declare function resolve(
|
||||
specifier: string,
|
||||
parentURL: URL,
|
||||
readPackage: (url: URL) => Promise<JSON | null>
|
||||
): AsyncIterable<URL>
|
||||
|
||||
declare function resolve(
|
||||
specifier: string,
|
||||
parentURL: URL,
|
||||
opts: ResolveOptions,
|
||||
readPackage?: (url: URL) => JSON | null
|
||||
): Iterable<URL>
|
||||
|
||||
declare function resolve(
|
||||
specifier: string,
|
||||
parentURL: URL,
|
||||
opts: ResolveOptions,
|
||||
readPackage: (url: URL) => Promise<JSON | null>
|
||||
): AsyncIterable<URL>
|
||||
|
||||
declare namespace resolve {
|
||||
export {
|
||||
type ConditionalSpecifier,
|
||||
type ImportsMap,
|
||||
type ExportsMap,
|
||||
type ResolutionsMap,
|
||||
type Builtins,
|
||||
type Conditions,
|
||||
type Engines,
|
||||
type ResolveOptions
|
||||
}
|
||||
|
||||
export const constants: {
|
||||
UNRESOLVED: number
|
||||
YIELDED: number
|
||||
RESOLVED: number
|
||||
}
|
||||
|
||||
export type Resolver = Generator<
|
||||
{ package: URL } | { resolution: URL },
|
||||
number,
|
||||
void | boolean | JSON | null
|
||||
>
|
||||
|
||||
export function module(specifier: string, parentURL: URL, opts?: ResolveOptions): Resolver
|
||||
|
||||
export function url(url: string, parentURL: URL, opts?: ResolveOptions): Resolver
|
||||
|
||||
export function preresolved(
|
||||
specifier: string,
|
||||
resolutions: ResolutionsMap,
|
||||
parentURL: URL,
|
||||
opts?: ResolveOptions
|
||||
): Resolver
|
||||
|
||||
export function package(packageSpecifier: string, parentURL: URL, opts?: ResolveOptions): Resolver
|
||||
|
||||
export function packageSelf(
|
||||
packageName: string,
|
||||
packageSubpath: string,
|
||||
parentURL: URL,
|
||||
opts?: ResolveOptions
|
||||
): Resolver
|
||||
|
||||
export function packageExports(
|
||||
packageURL: URL,
|
||||
subpath: string,
|
||||
packageExports: ExportsMap,
|
||||
opts?: ResolveOptions
|
||||
): Resolver
|
||||
|
||||
export function packageImports(specifier: string, parentURL: URL, opts?: ResolveOptions): Resolver
|
||||
|
||||
export function packageImportsExports(
|
||||
matchKey: string,
|
||||
matchObject: ImportsMap | ExportsMap,
|
||||
packageURL: URL,
|
||||
isImports: boolean,
|
||||
opts?: ResolveOptions
|
||||
): Resolver
|
||||
|
||||
export function packageTarget(
|
||||
packageURL: URL,
|
||||
target: ConditionalSpecifier,
|
||||
patternMatch: string,
|
||||
isImports: boolean,
|
||||
opts?: ResolveOptions
|
||||
): Resolver
|
||||
|
||||
export function builtinTarget(
|
||||
packageSpecifier: string,
|
||||
packageVersion: string,
|
||||
target: ConditionalSpecifier,
|
||||
opts?: ResolveOptions
|
||||
): Resolver
|
||||
|
||||
export function file(
|
||||
filename: string,
|
||||
parentURL: URL,
|
||||
isIndex: boolean,
|
||||
opts?: ResolveOptions
|
||||
): Resolver
|
||||
|
||||
export function directory(dirname: string, parentURL: URL, opts?: ResolveOptions): Resolver
|
||||
}
|
||||
|
||||
export = resolve
|
||||
796
bot/node_modules/bare-module-resolve/index.js
generated
vendored
Normal file
796
bot/node_modules/bare-module-resolve/index.js
generated
vendored
Normal file
@ -0,0 +1,796 @@
|
||||
const { satisfies } = require('bare-semver')
|
||||
const errors = require('./lib/errors')
|
||||
|
||||
module.exports = exports = function resolve(specifier, parentURL, opts, readPackage) {
|
||||
if (typeof opts === 'function') {
|
||||
readPackage = opts
|
||||
opts = {}
|
||||
} else if (typeof readPackage !== 'function') {
|
||||
readPackage = defaultReadPackage
|
||||
}
|
||||
|
||||
return {
|
||||
*[Symbol.iterator]() {
|
||||
const generator = exports.module(specifier, parentURL, opts)
|
||||
|
||||
let next = generator.next()
|
||||
|
||||
while (next.done !== true) {
|
||||
const value = next.value
|
||||
|
||||
if (value.package) {
|
||||
next = generator.next(readPackage(value.package))
|
||||
} else {
|
||||
next = generator.next(yield value.resolution)
|
||||
}
|
||||
}
|
||||
|
||||
return next.value
|
||||
},
|
||||
|
||||
async *[Symbol.asyncIterator]() {
|
||||
const generator = exports.module(specifier, parentURL, opts)
|
||||
|
||||
let next = generator.next()
|
||||
|
||||
while (next.done !== true) {
|
||||
const value = next.value
|
||||
|
||||
if (value.package) {
|
||||
next = generator.next(await readPackage(value.package))
|
||||
} else {
|
||||
next = generator.next(yield value.resolution)
|
||||
}
|
||||
}
|
||||
|
||||
return next.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function defaultReadPackage() {
|
||||
return null
|
||||
}
|
||||
|
||||
// No resolution candidate was yielded
|
||||
const UNRESOLVED = 0x0
|
||||
// At least 1 resolution candidate was yielded
|
||||
const YIELDED = 0x1
|
||||
// At least 1 resolution candidate was yielded and resolved
|
||||
const RESOLVED = YIELDED | 0x2
|
||||
|
||||
exports.constants = {
|
||||
UNRESOLVED,
|
||||
YIELDED,
|
||||
RESOLVED
|
||||
}
|
||||
|
||||
exports.module = function* (specifier, parentURL, opts = {}) {
|
||||
const { resolutions = null, imports = null } = opts
|
||||
|
||||
if (exports.startsWithWindowsDriveLetter(specifier)) {
|
||||
specifier = '/' + specifier
|
||||
}
|
||||
|
||||
let status
|
||||
|
||||
if (resolutions) {
|
||||
status = yield* exports.preresolved(specifier, resolutions, parentURL, opts)
|
||||
|
||||
if (status) return status
|
||||
}
|
||||
|
||||
status = yield* exports.url(specifier, parentURL, opts)
|
||||
|
||||
if (status) return status
|
||||
|
||||
status = yield* exports.packageImports(specifier, parentURL, opts)
|
||||
|
||||
if (status) return status
|
||||
|
||||
if (
|
||||
specifier === '.' ||
|
||||
specifier === '..' ||
|
||||
specifier[0] === '/' ||
|
||||
specifier[0] === '\\' ||
|
||||
specifier.startsWith('./') ||
|
||||
specifier.startsWith('.\\') ||
|
||||
specifier.startsWith('../') ||
|
||||
specifier.startsWith('..\\')
|
||||
) {
|
||||
if (imports) {
|
||||
status = yield* exports.packageImportsExports(specifier, imports, parentURL, true, opts)
|
||||
|
||||
if (status) return status
|
||||
}
|
||||
|
||||
status = yield* exports.deferred(specifier, opts)
|
||||
|
||||
if (status) return status
|
||||
|
||||
status = yield* exports.file(specifier, parentURL, false, opts)
|
||||
|
||||
if (status === RESOLVED) return status
|
||||
|
||||
return yield* exports.directory(specifier, parentURL, opts)
|
||||
}
|
||||
|
||||
return yield* exports.package(specifier, parentURL, opts)
|
||||
}
|
||||
|
||||
exports.url = function* (url, parentURL, opts = {}) {
|
||||
const { imports = null, deferredProtocol = 'deferred:', resolutions = null } = opts
|
||||
|
||||
let resolution
|
||||
try {
|
||||
resolution = new URL(url)
|
||||
} catch {
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
if (imports) {
|
||||
const status = yield* exports.packageImportsExports(
|
||||
resolution.href,
|
||||
imports,
|
||||
parentURL,
|
||||
true,
|
||||
opts
|
||||
)
|
||||
|
||||
if (status) return status
|
||||
}
|
||||
|
||||
if (resolution.protocol === deferredProtocol) {
|
||||
const specifier = resolution.pathname
|
||||
|
||||
if (resolutions) {
|
||||
const imports = resolutions[parentURL.href]
|
||||
|
||||
if (typeof imports === 'object' && imports !== null) {
|
||||
opts = {
|
||||
...opts,
|
||||
resolutions: { ...resolutions, [parentURL.href]: { ...imports, [specifier]: null } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return yield* exports.module(specifier, parentURL, opts)
|
||||
}
|
||||
|
||||
if (resolution.protocol === 'node:') {
|
||||
const specifier = resolution.pathname
|
||||
|
||||
if (
|
||||
specifier === '.' ||
|
||||
specifier === '..' ||
|
||||
specifier[0] === '/' ||
|
||||
specifier.startsWith('./') ||
|
||||
specifier.startsWith('../')
|
||||
) {
|
||||
throw errors.INVALID_MODULE_SPECIFIER(`Module specifier '${url}' is not a valid package name`)
|
||||
}
|
||||
|
||||
return yield* exports.package(specifier, parentURL, opts)
|
||||
}
|
||||
|
||||
const resolved = yield { resolution }
|
||||
|
||||
return resolved ? RESOLVED : YIELDED
|
||||
}
|
||||
|
||||
exports.preresolved = function* (specifier, resolutions, parentURL, opts = {}) {
|
||||
const imports = resolutions[parentURL.href]
|
||||
|
||||
if (typeof imports === 'object' && imports !== null) {
|
||||
return yield* exports.packageImportsExports(specifier, imports, parentURL, true, opts)
|
||||
}
|
||||
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
exports.deferred = function* (specifier, opts = {}) {
|
||||
const { deferredProtocol = 'deferred:', defer = [] } = opts
|
||||
|
||||
if (defer.includes(specifier)) {
|
||||
const resolved = yield { resolution: new URL(deferredProtocol + specifier) }
|
||||
|
||||
return resolved ? RESOLVED : YIELDED
|
||||
}
|
||||
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
exports.package = function* (packageSpecifier, parentURL, opts = {}) {
|
||||
const { builtins = [] } = opts
|
||||
|
||||
if (packageSpecifier === '') {
|
||||
throw errors.INVALID_MODULE_SPECIFIER(
|
||||
`Module specifier '${packageSpecifier}' is not a valid package name`
|
||||
)
|
||||
}
|
||||
|
||||
let packageName
|
||||
|
||||
if (packageSpecifier[0] !== '@') {
|
||||
packageName = packageSpecifier.split('/', 1).join()
|
||||
} else {
|
||||
if (!packageSpecifier.includes('/')) {
|
||||
throw errors.INVALID_MODULE_SPECIFIER(
|
||||
`Module specifier '${packageSpecifier}' is not a valid package name`
|
||||
)
|
||||
}
|
||||
|
||||
packageName = packageSpecifier.split('/', 2).join('/')
|
||||
}
|
||||
|
||||
if (packageName[0] === '.' || packageName.includes('\\') || packageName.includes('%')) {
|
||||
throw errors.INVALID_MODULE_SPECIFIER(
|
||||
`Module specifier '${packageSpecifier}' is not a valid package name`
|
||||
)
|
||||
}
|
||||
|
||||
let status
|
||||
|
||||
status = yield* exports.builtinTarget(packageSpecifier, null, builtins, opts)
|
||||
|
||||
if (status) return status
|
||||
|
||||
status = yield* exports.deferred(packageSpecifier, opts)
|
||||
|
||||
if (status) return status
|
||||
|
||||
let packageSubpath = '.' + packageSpecifier.substring(packageName.length)
|
||||
|
||||
status = yield* exports.packageSelf(packageName, packageSubpath, parentURL, opts)
|
||||
|
||||
if (status) return status
|
||||
|
||||
parentURL = new URL(parentURL.href)
|
||||
|
||||
for (const packageURL of exports.lookupPackageRoot(packageName, parentURL)) {
|
||||
const info = yield { package: packageURL }
|
||||
|
||||
if (info) {
|
||||
if (info.engines) exports.validateEngines(packageURL, info.engines, opts)
|
||||
|
||||
if (info.exports) {
|
||||
return yield* exports.packageExports(packageURL, packageSubpath, info.exports, opts)
|
||||
}
|
||||
|
||||
if (packageSubpath === '.') {
|
||||
if (typeof info.main === 'string' && info.main !== '') {
|
||||
packageSubpath = info.main
|
||||
} else {
|
||||
return yield* exports.file('index', packageURL, true, opts)
|
||||
}
|
||||
}
|
||||
|
||||
status = yield* exports.file(packageSubpath, packageURL, false, opts)
|
||||
|
||||
if (status === RESOLVED) return status
|
||||
|
||||
return yield* exports.directory(packageSubpath, packageURL, opts)
|
||||
}
|
||||
}
|
||||
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
exports.packageSelf = function* (packageName, packageSubpath, parentURL, opts = {}) {
|
||||
for (const packageURL of exports.lookupPackageScope(parentURL, opts)) {
|
||||
const info = yield { package: packageURL }
|
||||
|
||||
if (info) {
|
||||
if (info.name !== packageName) return false
|
||||
|
||||
if (info.exports) {
|
||||
return yield* exports.packageExports(packageURL, packageSubpath, info.exports, opts)
|
||||
}
|
||||
|
||||
if (packageSubpath === '.') {
|
||||
if (typeof info.main === 'string' && info.main !== '') {
|
||||
packageSubpath = info.main
|
||||
} else {
|
||||
return yield* exports.file('index', packageURL, true, opts)
|
||||
}
|
||||
}
|
||||
|
||||
const status = yield* exports.file(packageSubpath, packageURL, false, opts)
|
||||
|
||||
if (status === RESOLVED) return status
|
||||
|
||||
return yield* exports.directory(packageSubpath, packageURL, opts)
|
||||
}
|
||||
}
|
||||
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
exports.packageExports = function* (packageURL, subpath, packageExports, opts = {}) {
|
||||
if (subpath === '.') {
|
||||
let mainExport
|
||||
|
||||
if (typeof packageExports === 'string' || Array.isArray(packageExports)) {
|
||||
mainExport = packageExports
|
||||
} else if (typeof packageExports === 'object' && packageExports !== null) {
|
||||
const keys = Object.keys(packageExports)
|
||||
|
||||
if (keys.some((key) => key.startsWith('.'))) {
|
||||
if ('.' in packageExports) mainExport = packageExports['.']
|
||||
} else {
|
||||
mainExport = packageExports
|
||||
}
|
||||
}
|
||||
|
||||
if (mainExport) {
|
||||
const status = yield* exports.packageTarget(packageURL, mainExport, null, false, opts)
|
||||
|
||||
if (status) return status
|
||||
}
|
||||
} else if (typeof packageExports === 'object' && packageExports !== null) {
|
||||
const keys = Object.keys(packageExports)
|
||||
|
||||
if (keys.every((key) => key.startsWith('.'))) {
|
||||
const status = yield* exports.packageImportsExports(
|
||||
subpath,
|
||||
packageExports,
|
||||
packageURL,
|
||||
false,
|
||||
opts
|
||||
)
|
||||
|
||||
if (status) return status
|
||||
}
|
||||
}
|
||||
|
||||
throw errors.PACKAGE_PATH_NOT_EXPORTED(
|
||||
`Package subpath '${subpath}' is not defined by "exports" in '${packageURL}'`
|
||||
)
|
||||
}
|
||||
|
||||
exports.packageImports = function* (specifier, parentURL, opts = {}) {
|
||||
const { imports = null } = opts
|
||||
|
||||
if (specifier === '#' || specifier.startsWith('#/')) {
|
||||
throw errors.INVALID_MODULE_SPECIFIER(
|
||||
`Module specifier '${specifier}' is not a valid internal imports specifier`
|
||||
)
|
||||
}
|
||||
|
||||
for (const packageURL of exports.lookupPackageScope(parentURL, opts)) {
|
||||
const info = yield { package: packageURL }
|
||||
|
||||
if (info) {
|
||||
if (info.imports) {
|
||||
const status = yield* exports.packageImportsExports(
|
||||
specifier,
|
||||
info.imports,
|
||||
packageURL,
|
||||
true,
|
||||
opts
|
||||
)
|
||||
|
||||
if (status) return status
|
||||
}
|
||||
|
||||
if (specifier.startsWith('#')) {
|
||||
throw errors.PACKAGE_IMPORT_NOT_DEFINED(
|
||||
`Package import specifier '${specifier}' is not defined by "imports" in '${packageURL}'`
|
||||
)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (imports) {
|
||||
const status = yield* exports.packageImportsExports(specifier, imports, parentURL, true, opts)
|
||||
|
||||
if (status) return status
|
||||
}
|
||||
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
exports.packageImportsExports = function* (
|
||||
matchKey,
|
||||
matchObject,
|
||||
packageURL,
|
||||
isImports,
|
||||
opts = {}
|
||||
) {
|
||||
if (matchKey in matchObject && !matchKey.includes('*')) {
|
||||
const target = matchObject[matchKey]
|
||||
|
||||
return yield* exports.packageTarget(packageURL, target, null, isImports, opts)
|
||||
}
|
||||
|
||||
const expansionKeys = Object.keys(matchObject)
|
||||
.filter((key) => key.includes('*'))
|
||||
.sort(exports.patternKeyCompare)
|
||||
|
||||
for (const expansionKey of expansionKeys) {
|
||||
const patternIndex = expansionKey.indexOf('*')
|
||||
const patternBase = expansionKey.substring(0, patternIndex)
|
||||
|
||||
if (matchKey.startsWith(patternBase) && matchKey !== patternBase) {
|
||||
const patternTrailer = expansionKey.substring(patternIndex + 1)
|
||||
|
||||
if (
|
||||
patternTrailer === '' ||
|
||||
(matchKey.endsWith(patternTrailer) && matchKey.length >= expansionKey.length)
|
||||
) {
|
||||
const target = matchObject[expansionKey]
|
||||
|
||||
const patternMatch = matchKey.substring(
|
||||
patternBase.length,
|
||||
matchKey.length - patternTrailer.length
|
||||
)
|
||||
|
||||
return yield* exports.packageTarget(packageURL, target, patternMatch, isImports, opts)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
exports.validateEngines = function validateEngines(packageURL, packageEngines, opts = {}) {
|
||||
const { engines = {} } = opts
|
||||
|
||||
for (const [engine, range] of Object.entries(packageEngines)) {
|
||||
if (engine in engines) {
|
||||
const version = engines[engine]
|
||||
|
||||
if (!satisfies(version, range)) {
|
||||
throw errors.UNSUPPORTED_ENGINE(
|
||||
`Package not compatible with engine '${engine}' ${version}, requires range '${range}' defined by "engines" in '${packageURL}'`
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.patternKeyCompare = function patternKeyCompare(keyA, keyB) {
|
||||
const patternIndexA = keyA.indexOf('*')
|
||||
const patternIndexB = keyB.indexOf('*')
|
||||
const baseLengthA = patternIndexA === -1 ? keyA.length : patternIndexA + 1
|
||||
const baseLengthB = patternIndexB === -1 ? keyB.length : patternIndexB + 1
|
||||
if (baseLengthA > baseLengthB) return -1
|
||||
if (baseLengthB > baseLengthA) return 1
|
||||
if (patternIndexA === -1) return 1
|
||||
if (patternIndexB === -1) return -1
|
||||
if (keyA.length > keyB.length) return -1
|
||||
if (keyB.length > keyA.length) return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
exports.packageTarget = function* (packageURL, target, patternMatch, isImports, opts = {}) {
|
||||
const { conditions = [], matchedConditions = [] } = opts
|
||||
|
||||
if (typeof target === 'string') {
|
||||
if (!target.startsWith('./') && !isImports) {
|
||||
throw errors.INVALID_PACKAGE_TARGET(
|
||||
`Invalid target '${target}' defined by "exports" in '${packageURL}'`
|
||||
)
|
||||
}
|
||||
|
||||
if (patternMatch !== null) {
|
||||
target = target.replaceAll('*', patternMatch)
|
||||
}
|
||||
|
||||
const status = yield* exports.url(target, packageURL, opts)
|
||||
|
||||
if (status) return status
|
||||
|
||||
if (
|
||||
target === '.' ||
|
||||
target === '..' ||
|
||||
target[0] === '/' ||
|
||||
target.startsWith('./') ||
|
||||
target.startsWith('../')
|
||||
) {
|
||||
const resolved = yield { resolution: new URL(target, packageURL) }
|
||||
|
||||
return resolved ? RESOLVED : YIELDED
|
||||
}
|
||||
|
||||
return yield* exports.package(target, packageURL, opts)
|
||||
}
|
||||
|
||||
if (Array.isArray(target)) {
|
||||
for (const targetValue of target) {
|
||||
const status = yield* exports.packageTarget(
|
||||
packageURL,
|
||||
targetValue,
|
||||
patternMatch,
|
||||
isImports,
|
||||
opts
|
||||
)
|
||||
|
||||
if (status) return status
|
||||
}
|
||||
} else if (typeof target === 'object' && target !== null) {
|
||||
let status = UNRESOLVED
|
||||
|
||||
for (const [condition, targetValue, subset] of exports.conditionMatches(
|
||||
target,
|
||||
conditions,
|
||||
opts
|
||||
)) {
|
||||
matchedConditions.push(condition)
|
||||
|
||||
status |= yield* exports.packageTarget(packageURL, targetValue, patternMatch, isImports, {
|
||||
...opts,
|
||||
conditions: subset
|
||||
})
|
||||
|
||||
matchedConditions.pop()
|
||||
}
|
||||
|
||||
if (status) return status
|
||||
}
|
||||
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
exports.builtinTarget = function* (packageSpecifier, packageVersion, target, opts = {}) {
|
||||
const { builtinProtocol = 'builtin:', conditions = [], matchedConditions = [] } = opts
|
||||
|
||||
if (typeof target === 'string') {
|
||||
const targetParts = target.split('@')
|
||||
|
||||
let targetName
|
||||
let targetVersion
|
||||
|
||||
if (target[0] !== '@') {
|
||||
targetName = targetParts[0]
|
||||
targetVersion = targetParts[1] || null
|
||||
} else {
|
||||
targetName = targetParts.slice(0, 2).join('@')
|
||||
targetVersion = targetParts[2] || null
|
||||
}
|
||||
|
||||
if (packageSpecifier === targetName) {
|
||||
if (packageVersion === null && targetVersion === null) {
|
||||
const resolved = yield {
|
||||
resolution: new URL(builtinProtocol + packageSpecifier)
|
||||
}
|
||||
|
||||
return resolved ? RESOLVED : YIELDED
|
||||
}
|
||||
|
||||
let version = null
|
||||
|
||||
if (packageVersion === null) {
|
||||
version = targetVersion
|
||||
} else if (targetVersion === null || packageVersion === targetVersion) {
|
||||
version = packageVersion
|
||||
}
|
||||
|
||||
if (version !== null) {
|
||||
const resolved = yield {
|
||||
resolution: new URL(builtinProtocol + packageSpecifier + '@' + version)
|
||||
}
|
||||
|
||||
return resolved ? RESOLVED : YIELDED
|
||||
}
|
||||
}
|
||||
} else if (Array.isArray(target)) {
|
||||
for (const targetValue of target) {
|
||||
const status = yield* exports.builtinTarget(
|
||||
packageSpecifier,
|
||||
packageVersion,
|
||||
targetValue,
|
||||
opts
|
||||
)
|
||||
|
||||
if (status) return status
|
||||
}
|
||||
} else if (typeof target === 'object' && target !== null) {
|
||||
let status = UNRESOLVED
|
||||
|
||||
for (const [condition, targetValue, subset] of exports.conditionMatches(
|
||||
target,
|
||||
conditions,
|
||||
opts
|
||||
)) {
|
||||
matchedConditions.push(condition)
|
||||
|
||||
status |= yield* exports.builtinTarget(packageSpecifier, packageVersion, targetValue, {
|
||||
...opts,
|
||||
conditions: subset
|
||||
})
|
||||
|
||||
matchedConditions.pop()
|
||||
}
|
||||
|
||||
if (status) return status
|
||||
}
|
||||
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
exports.conditionMatches = function* conditionMatches(target, conditions, opts = {}) {
|
||||
if (conditions.every((condition) => typeof condition === 'string')) {
|
||||
const keys = Object.keys(target)
|
||||
|
||||
for (const condition of keys) {
|
||||
if (condition === 'default' || conditions.includes(condition)) {
|
||||
yield [condition, target[condition], conditions]
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
let yielded = false
|
||||
|
||||
for (const subset of conditions) {
|
||||
if (yield* conditionMatches(target, subset, opts)) {
|
||||
yielded = true
|
||||
}
|
||||
}
|
||||
|
||||
return yielded
|
||||
}
|
||||
|
||||
exports.lookupPackageRoot = function* (packageName, parentURL) {
|
||||
parentURL = new URL(parentURL.href)
|
||||
|
||||
do {
|
||||
const packageURL = new URL('node_modules/' + packageName + '/', parentURL)
|
||||
|
||||
const info = yield new URL('package.json', packageURL)
|
||||
|
||||
if (info) return info
|
||||
|
||||
parentURL.pathname = parentURL.pathname.substring(0, parentURL.pathname.lastIndexOf('/'))
|
||||
|
||||
if (
|
||||
parentURL.pathname.length === 3 &&
|
||||
exports.isWindowsDriveLetter(parentURL.pathname.substring(1))
|
||||
) {
|
||||
break
|
||||
}
|
||||
} while (parentURL.pathname !== '' && parentURL.pathname !== '/')
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
exports.lookupPackageScope = function* lookupPackageScope(scopeURL, opts = {}) {
|
||||
const { resolutions = null } = opts
|
||||
|
||||
if (resolutions) {
|
||||
for (const { resolution } of exports.preresolved('#package', resolutions, scopeURL, opts)) {
|
||||
if (resolution) return yield resolution
|
||||
}
|
||||
}
|
||||
|
||||
scopeURL = new URL(scopeURL.href)
|
||||
|
||||
do {
|
||||
if (scopeURL.pathname.endsWith('/node_modules')) break
|
||||
|
||||
const info = yield new URL('package.json', scopeURL)
|
||||
|
||||
if (info) return info
|
||||
|
||||
scopeURL.pathname = scopeURL.pathname.substring(0, scopeURL.pathname.lastIndexOf('/'))
|
||||
|
||||
if (
|
||||
scopeURL.pathname.length === 3 &&
|
||||
exports.isWindowsDriveLetter(scopeURL.pathname.substring(1))
|
||||
) {
|
||||
break
|
||||
}
|
||||
} while (scopeURL.pathname !== '' && scopeURL.pathname !== '/')
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
exports.file = function* (filename, parentURL, isIndex, opts = {}) {
|
||||
if (
|
||||
filename === '.' ||
|
||||
filename === '..' ||
|
||||
filename[filename.length - 1] === '/' ||
|
||||
filename[filename.length - 1] === '\\'
|
||||
) {
|
||||
return UNRESOLVED
|
||||
}
|
||||
|
||||
if (parentURL.protocol === 'file:' && /%2f|%5c/i.test(filename)) {
|
||||
throw errors.INVALID_MODULE_SPECIFIER(`Module specifier '${filename}' is invalid`)
|
||||
}
|
||||
|
||||
const { extensions = [] } = opts
|
||||
|
||||
let status = UNRESOLVED
|
||||
|
||||
if (!isIndex) {
|
||||
if (yield { resolution: new URL(filename, parentURL) }) {
|
||||
return RESOLVED
|
||||
}
|
||||
|
||||
status = YIELDED
|
||||
}
|
||||
|
||||
for (const ext of extensions) {
|
||||
if (filename.endsWith(ext)) continue
|
||||
|
||||
if (yield { resolution: new URL(filename + ext, parentURL) }) {
|
||||
return RESOLVED
|
||||
}
|
||||
|
||||
status = YIELDED
|
||||
}
|
||||
|
||||
return status
|
||||
}
|
||||
|
||||
exports.directory = function* (dirname, parentURL, opts = {}) {
|
||||
let directoryURL
|
||||
|
||||
if (dirname[dirname.length - 1] === '/' || dirname[dirname.length - 1] === '\\') {
|
||||
directoryURL = new URL(dirname, parentURL)
|
||||
} else {
|
||||
directoryURL = new URL(dirname + '/', parentURL)
|
||||
}
|
||||
|
||||
const info = yield { package: new URL('package.json', directoryURL) }
|
||||
|
||||
if (info) {
|
||||
if (info.exports) {
|
||||
return yield* exports.packageExports(directoryURL, '.', info.exports, opts)
|
||||
}
|
||||
|
||||
if (typeof info.main === 'string' && info.main !== '') {
|
||||
const status = yield* exports.file(info.main, directoryURL, false, opts)
|
||||
|
||||
if (status === RESOLVED) return status
|
||||
|
||||
return yield* exports.directory(info.main, directoryURL, opts)
|
||||
}
|
||||
}
|
||||
|
||||
return yield* exports.file('index', directoryURL, true, opts)
|
||||
}
|
||||
|
||||
// https://infra.spec.whatwg.org/#ascii-upper-alpha
|
||||
function isASCIIUpperAlpha(c) {
|
||||
return c >= 0x41 && c <= 0x5a
|
||||
}
|
||||
|
||||
// https://infra.spec.whatwg.org/#ascii-lower-alpha
|
||||
function isASCIILowerAlpha(c) {
|
||||
return c >= 0x61 && c <= 0x7a
|
||||
}
|
||||
|
||||
// https://infra.spec.whatwg.org/#ascii-alpha
|
||||
function isASCIIAlpha(c) {
|
||||
return isASCIIUpperAlpha(c) || isASCIILowerAlpha(c)
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#windows-drive-letter
|
||||
exports.isWindowsDriveLetter = function isWindowsDriveLetter(input) {
|
||||
return (
|
||||
input.length >= 2 &&
|
||||
isASCIIAlpha(input.charCodeAt(0)) &&
|
||||
(input.charCodeAt(1) === 0x3a || input.charCodeAt(1) === 0x7c)
|
||||
)
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
|
||||
exports.startsWithWindowsDriveLetter = function startsWithWindowsDriveLetter(input) {
|
||||
return (
|
||||
input.length >= 2 &&
|
||||
exports.isWindowsDriveLetter(input) &&
|
||||
(input.length === 2 ||
|
||||
input.charCodeAt(2) === 0x2f ||
|
||||
input.charCodeAt(2) === 0x5c ||
|
||||
input.charCodeAt(2) === 0x3f ||
|
||||
input.charCodeAt(2) === 0x23)
|
||||
)
|
||||
}
|
||||
11
bot/node_modules/bare-module-resolve/lib/errors.d.ts
generated
vendored
Normal file
11
bot/node_modules/bare-module-resolve/lib/errors.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
declare class ModuleResolveError extends Error {
|
||||
readonly code: string
|
||||
|
||||
static INVALID_MODULE_SPECIFIER(msg: string): ModuleResolveError
|
||||
static INVALID_PACKAGE_TARGET(msg: string): ModuleResolveError
|
||||
static PACKAGE_PATH_NOT_EXPORTED(msg: string): ModuleResolveError
|
||||
static PACKAGE_IMPORT_NOT_DEFINED(msg: string): ModuleResolveError
|
||||
static UNSUPPORTED_ENGINE(msg: string): ModuleResolveError
|
||||
}
|
||||
|
||||
export = ModuleResolveError
|
||||
50
bot/node_modules/bare-module-resolve/lib/errors.js
generated
vendored
Normal file
50
bot/node_modules/bare-module-resolve/lib/errors.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
module.exports = class ModuleResolveError extends Error {
|
||||
constructor(msg, code, fn = ModuleResolveError) {
|
||||
super(`${code}: ${msg}`)
|
||||
this.code = code
|
||||
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, fn)
|
||||
}
|
||||
}
|
||||
|
||||
get name() {
|
||||
return 'ModuleResolveError'
|
||||
}
|
||||
|
||||
static INVALID_MODULE_SPECIFIER(msg) {
|
||||
return new ModuleResolveError(
|
||||
msg,
|
||||
'INVALID_MODULE_SPECIFIER',
|
||||
ModuleResolveError.INVALID_MODULE_SPECIFIER
|
||||
)
|
||||
}
|
||||
|
||||
static INVALID_PACKAGE_TARGET(msg) {
|
||||
return new ModuleResolveError(
|
||||
msg,
|
||||
'INVALID_PACKAGE_TARGET',
|
||||
ModuleResolveError.INVALID_PACKAGE_TARGET
|
||||
)
|
||||
}
|
||||
|
||||
static PACKAGE_PATH_NOT_EXPORTED(msg) {
|
||||
return new ModuleResolveError(
|
||||
msg,
|
||||
'PACKAGE_PATH_NOT_EXPORTED',
|
||||
ModuleResolveError.PACKAGE_PATH_NOT_EXPORTED
|
||||
)
|
||||
}
|
||||
|
||||
static PACKAGE_IMPORT_NOT_DEFINED(msg) {
|
||||
return new ModuleResolveError(
|
||||
msg,
|
||||
'PACKAGE_IMPORT_NOT_DEFINED',
|
||||
ModuleResolveError.PACKAGE_IMPORT_NOT_DEFINED
|
||||
)
|
||||
}
|
||||
|
||||
static UNSUPPORTED_ENGINE(msg) {
|
||||
return new ModuleResolveError(msg, 'UNSUPPORTED_ENGINE', ModuleResolveError.UNSUPPORTED_ENGINE)
|
||||
}
|
||||
}
|
||||
51
bot/node_modules/bare-module-resolve/package.json
generated
vendored
Normal file
51
bot/node_modules/bare-module-resolve/package.json
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "bare-module-resolve",
|
||||
"version": "1.12.1",
|
||||
"description": "Low-level module resolution algorithm for Bare",
|
||||
"exports": {
|
||||
"./package": "./package.json",
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"./errors": {
|
||||
"types": "./lib/errors.d.ts",
|
||||
"default": "./lib/errors.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "prettier . --check && bare test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/holepunchto/bare-module-resolve.git"
|
||||
},
|
||||
"author": "Holepunch",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/holepunchto/bare-module-resolve/issues"
|
||||
},
|
||||
"homepage": "https://github.com/holepunchto/bare-module-resolve#readme",
|
||||
"dependencies": {
|
||||
"bare-semver": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bare-url": "^2.1.3",
|
||||
"brittle": "^3.2.1",
|
||||
"prettier": "^3.3.3",
|
||||
"prettier-config-holepunch": "^2.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bare-url": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bare-url": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
201
bot/node_modules/bare-semver/LICENSE
generated
vendored
Normal file
201
bot/node_modules/bare-semver/LICENSE
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
19
bot/node_modules/bare-semver/README.md
generated
vendored
Normal file
19
bot/node_modules/bare-semver/README.md
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# bare-semver
|
||||
|
||||
Minimal semantic versioning library for Bare.
|
||||
|
||||
```
|
||||
npm i bare-semver
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const { Version } = require('bare-semver')
|
||||
|
||||
Version.parse('1.2.3')
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Apache-2.0
|
||||
61
bot/node_modules/bare-semver/index.d.ts
generated
vendored
Normal file
61
bot/node_modules/bare-semver/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
export const constants: { EQ: 1; LT: 2; LTE: 3; GT: 4; GTE: 5 }
|
||||
|
||||
declare class SemVerError extends Error {
|
||||
static INVALID_VERSION(msg: string, fn?: Function): SemVerError
|
||||
|
||||
static INVALID_RANGE(msg: string, fn?: Function): SemVerError
|
||||
}
|
||||
|
||||
export { SemVerError as errors }
|
||||
|
||||
export function satisfies(version: Version, range: Range): boolean
|
||||
|
||||
export class Version {
|
||||
constructor(
|
||||
major: number,
|
||||
minor: number,
|
||||
patch: number,
|
||||
opts?: { prerelease?: string[]; build?: string[] }
|
||||
)
|
||||
|
||||
major: number
|
||||
minor: number
|
||||
patch: number
|
||||
prerealease: string[]
|
||||
build: string[]
|
||||
|
||||
compare(version: Version): boolean
|
||||
|
||||
toString(): string
|
||||
}
|
||||
|
||||
export namespace Version {
|
||||
export function parse(input: string): Version
|
||||
|
||||
export function compare(a: Version, b: Version): number
|
||||
}
|
||||
|
||||
export class Comparator {
|
||||
constructor(operator: number, version: Version)
|
||||
|
||||
operator: number
|
||||
version: Version
|
||||
|
||||
test(version: Version): boolean
|
||||
|
||||
toString(): string
|
||||
}
|
||||
|
||||
export class Range {
|
||||
constructor(comparators?: Comparator[][])
|
||||
|
||||
comparators: Comparator[][]
|
||||
|
||||
test(version: Version): boolean
|
||||
|
||||
toString(): string
|
||||
}
|
||||
|
||||
export namespace Range {
|
||||
export function parse(input: string): Range
|
||||
}
|
||||
13
bot/node_modules/bare-semver/index.js
generated
vendored
Normal file
13
bot/node_modules/bare-semver/index.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
exports.constants = require('./lib/constants')
|
||||
exports.errors = require('./lib/errors')
|
||||
|
||||
const Version = (exports.Version = require('./lib/version'))
|
||||
const Range = (exports.Range = require('./lib/range'))
|
||||
exports.Comparator = require('./lib/comparator')
|
||||
|
||||
exports.satisfies = function satisfies(version, range) {
|
||||
if (typeof version === 'string') version = Version.parse(version)
|
||||
if (typeof range === 'string') range = Range.parse(range)
|
||||
|
||||
return range.test(version)
|
||||
}
|
||||
37
bot/node_modules/bare-semver/lib/comparator.js
generated
vendored
Normal file
37
bot/node_modules/bare-semver/lib/comparator.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
const constants = require('./constants')
|
||||
|
||||
const symbols = {
|
||||
[constants.EQ]: '=',
|
||||
[constants.LT]: '<',
|
||||
[constants.LTE]: '<=',
|
||||
[constants.GT]: '>',
|
||||
[constants.GTE]: '>='
|
||||
}
|
||||
|
||||
module.exports = class Comparator {
|
||||
constructor(operator, version) {
|
||||
this.operator = operator
|
||||
this.version = version
|
||||
}
|
||||
|
||||
test(version) {
|
||||
const result = version.compare(this.version)
|
||||
|
||||
switch (this.operator) {
|
||||
case constants.LT:
|
||||
return result < 0
|
||||
case constants.LTE:
|
||||
return result <= 0
|
||||
case constants.GT:
|
||||
return result > 0
|
||||
case constants.GTE:
|
||||
return result >= 0
|
||||
default:
|
||||
return result === 0
|
||||
}
|
||||
}
|
||||
|
||||
toString() {
|
||||
return symbols[this.operator] + this.version
|
||||
}
|
||||
}
|
||||
7
bot/node_modules/bare-semver/lib/constants.js
generated
vendored
Normal file
7
bot/node_modules/bare-semver/lib/constants.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
EQ: 1,
|
||||
LT: 2,
|
||||
LTE: 3,
|
||||
GT: 4,
|
||||
GTE: 5
|
||||
}
|
||||
22
bot/node_modules/bare-semver/lib/errors.js
generated
vendored
Normal file
22
bot/node_modules/bare-semver/lib/errors.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
module.exports = class SemVerError extends Error {
|
||||
constructor(msg, code, fn = SemVerError) {
|
||||
super(`${code}: ${msg}`)
|
||||
this.code = code
|
||||
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, fn)
|
||||
}
|
||||
}
|
||||
|
||||
get name() {
|
||||
return 'SemVerError'
|
||||
}
|
||||
|
||||
static INVALID_VERSION(msg, fn = SemVerError.INVALID_VERSION) {
|
||||
return new SemVerError(msg, 'INVALID_VERSION', fn)
|
||||
}
|
||||
|
||||
static INVALID_RANGE(msg, fn = SemVerError.INVALID_RANGE) {
|
||||
return new SemVerError(msg, 'INVALID_RANGE', fn)
|
||||
}
|
||||
}
|
||||
121
bot/node_modules/bare-semver/lib/range.js
generated
vendored
Normal file
121
bot/node_modules/bare-semver/lib/range.js
generated
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
const constants = require('./constants')
|
||||
const errors = require('./errors')
|
||||
const Version = require('./version')
|
||||
const Comparator = require('./comparator')
|
||||
|
||||
class Range {
|
||||
constructor(comparators = []) {
|
||||
this.comparators = comparators
|
||||
}
|
||||
|
||||
test(version) {
|
||||
for (const set of this.comparators) {
|
||||
let matches = true
|
||||
|
||||
for (const comparator of set) {
|
||||
if (comparator.test(version)) continue
|
||||
matches = false
|
||||
break
|
||||
}
|
||||
|
||||
if (matches) return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
toString() {
|
||||
let result = ''
|
||||
let first = true
|
||||
|
||||
for (const set of this.comparators) {
|
||||
if (first) first = false
|
||||
else result += ' || '
|
||||
|
||||
result += set.join(' ')
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = Range
|
||||
|
||||
exports.parse = function parse(input, state = { position: 0, partial: false }) {
|
||||
let i = state.position
|
||||
let c
|
||||
|
||||
const unexpected = (expected) => {
|
||||
let msg
|
||||
|
||||
if (i >= input.length) {
|
||||
msg = `Unexpected end of input in '${input}'`
|
||||
} else {
|
||||
msg = `Unexpected token '${input[i]}' in '${input}' at position ${i}`
|
||||
}
|
||||
|
||||
if (expected) msg += `, ${expected}`
|
||||
|
||||
throw errors.INVALID_VERSION(msg, unexpected)
|
||||
}
|
||||
|
||||
const comparators = []
|
||||
|
||||
while (i < input.length) {
|
||||
const set = []
|
||||
|
||||
while (i < input.length) {
|
||||
c = input[i]
|
||||
|
||||
let operator = constants.EQ
|
||||
|
||||
if (c === '<') {
|
||||
operator = constants.LT
|
||||
c = input[++i]
|
||||
|
||||
if (c === '=') {
|
||||
operator = constants.LTE
|
||||
c = input[++i]
|
||||
}
|
||||
} else if (c === '>') {
|
||||
operator = constants.GT
|
||||
c = input[++i]
|
||||
|
||||
if (c === '=') {
|
||||
operator = constants.GTE
|
||||
c = input[++i]
|
||||
}
|
||||
} else if (c === '=') {
|
||||
c = input[++i]
|
||||
}
|
||||
|
||||
const state = { position: i, partial: true, range: true }
|
||||
|
||||
set.push(new Comparator(operator, Version.parse(input, state)))
|
||||
|
||||
c = input[(i = state.position)]
|
||||
|
||||
while (c === ' ') c = input[++i]
|
||||
|
||||
if (c === '|' && input[i + 1] === '|') {
|
||||
c = input[(i += 2)]
|
||||
|
||||
while (c === ' ') c = input[++i]
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
if (c && c !== '<' && c !== '>') unexpected("expected '||', '<', or '>'")
|
||||
}
|
||||
|
||||
if (set.length) comparators.push(set)
|
||||
}
|
||||
|
||||
if (i < input.length && state.partial === false) {
|
||||
unexpected('expected end of input')
|
||||
}
|
||||
|
||||
state.position = i
|
||||
|
||||
return new Range(comparators)
|
||||
}
|
||||
208
bot/node_modules/bare-semver/lib/version.js
generated
vendored
Normal file
208
bot/node_modules/bare-semver/lib/version.js
generated
vendored
Normal file
@ -0,0 +1,208 @@
|
||||
const errors = require('./errors')
|
||||
|
||||
class Version {
|
||||
constructor(major, minor, patch, opts = {}) {
|
||||
const { prerelease = [], build = [] } = opts
|
||||
|
||||
this.major = major
|
||||
this.minor = minor
|
||||
this.patch = patch
|
||||
this.prerelease = prerelease
|
||||
this.build = build
|
||||
}
|
||||
|
||||
compare(version) {
|
||||
return exports.compare(this, version)
|
||||
}
|
||||
|
||||
toString() {
|
||||
let result = `${this.major}.${this.minor}.${this.patch}`
|
||||
|
||||
if (this.prerelease.length) {
|
||||
result += '-' + this.prerelease.join('.')
|
||||
}
|
||||
|
||||
if (this.build.length) {
|
||||
result += '+' + this.build.join('.')
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = Version
|
||||
|
||||
exports.parse = function parse(
|
||||
input,
|
||||
state = { position: 0, partial: false, range: false }
|
||||
) {
|
||||
let i = state.position
|
||||
let c
|
||||
|
||||
const unexpected = (expected) => {
|
||||
let msg
|
||||
|
||||
if (i >= input.length) {
|
||||
msg = `Unexpected end of input in '${input}'`
|
||||
} else {
|
||||
msg = `Unexpected token '${input[i]}' in '${input}' at position ${i}`
|
||||
}
|
||||
|
||||
if (expected) msg += `, ${expected}`
|
||||
|
||||
throw errors.INVALID_VERSION(msg, unexpected)
|
||||
}
|
||||
|
||||
const components = [0, 0, 0]
|
||||
|
||||
let k = 0
|
||||
|
||||
while (k < 3) {
|
||||
c = input[i]
|
||||
|
||||
if (k > 0) {
|
||||
if (c === '.') c = input[++i]
|
||||
else if (state.range) break
|
||||
else unexpected("expected '.'")
|
||||
}
|
||||
|
||||
if (c === '0') {
|
||||
i++
|
||||
k++
|
||||
} else if (c >= '1' && c <= '9') {
|
||||
let j = 0
|
||||
do c = input[i + ++j]
|
||||
while (c >= '0' && c <= '9')
|
||||
|
||||
components[k++] = parseInt(input.substring(i, i + j))
|
||||
|
||||
i += j
|
||||
} else unexpected('expected /[0-9]/')
|
||||
}
|
||||
|
||||
const prerelease = []
|
||||
|
||||
if (k === 3 && input[i] === '-') {
|
||||
i++
|
||||
|
||||
while (true) {
|
||||
c = input[i]
|
||||
|
||||
let tag = ''
|
||||
let j = 0
|
||||
|
||||
while (c >= '0' && c <= '9') c = input[i + ++j]
|
||||
|
||||
let isNumeric = false
|
||||
|
||||
if (j) {
|
||||
tag += input.substring(i, i + j)
|
||||
|
||||
c = input[(i += j)]
|
||||
|
||||
isNumeric = tag[0] !== '0' || tag.length === 1
|
||||
}
|
||||
|
||||
j = 0
|
||||
|
||||
while (
|
||||
(c >= '0' && c <= '9') ||
|
||||
(c >= 'a' && c <= 'z') ||
|
||||
(c >= 'A' && c <= 'Z') ||
|
||||
c === '-'
|
||||
)
|
||||
c = input[i + ++j]
|
||||
|
||||
if (j) {
|
||||
tag += input.substring(i, i + j)
|
||||
|
||||
c = input[(i += j)]
|
||||
} else if (!isNumeric) unexpected('expected /[a-zA-Z-]/')
|
||||
|
||||
prerelease.push(tag)
|
||||
|
||||
if (c === '.') c = input[++i]
|
||||
else break
|
||||
}
|
||||
}
|
||||
|
||||
const build = []
|
||||
|
||||
if (k === 3 && input[i] === '+') {
|
||||
i++
|
||||
|
||||
while (true) {
|
||||
c = input[i]
|
||||
|
||||
let tag = ''
|
||||
let j = 0
|
||||
|
||||
while (
|
||||
(c >= '0' && c <= '9') ||
|
||||
(c >= 'a' && c <= 'z') ||
|
||||
(c >= 'A' && c <= 'Z') ||
|
||||
c === '-'
|
||||
)
|
||||
c = input[i + ++j]
|
||||
|
||||
if (j) {
|
||||
tag += input.substring(i, i + j)
|
||||
|
||||
c = input[(i += j)]
|
||||
} else unexpected('expected /[0-9a-zA-Z-]/')
|
||||
|
||||
build.push(tag)
|
||||
|
||||
if (c === '.') c = input[++i]
|
||||
else break
|
||||
}
|
||||
}
|
||||
|
||||
if (i < input.length && state.partial === false) {
|
||||
unexpected('expected end of input')
|
||||
}
|
||||
|
||||
state.position = i
|
||||
|
||||
return new Version(...components, { prerelease, build })
|
||||
}
|
||||
|
||||
const integer = /^[0-9]+$/
|
||||
|
||||
exports.compare = function compare(a, b) {
|
||||
if (a.major > b.major) return 1
|
||||
if (a.major < b.major) return -1
|
||||
|
||||
if (a.minor > b.minor) return 1
|
||||
if (a.minor < b.minor) return -1
|
||||
|
||||
if (a.patch > b.patch) return 1
|
||||
if (a.patch < b.patch) return -1
|
||||
|
||||
if (a.prerelease.length === 0) return b.prerelease.length === 0 ? 0 : 1
|
||||
if (b.prerelease.length === 0) return -1
|
||||
|
||||
let i = 0
|
||||
do {
|
||||
let x = a.prerelease[i]
|
||||
let y = b.prerelease[i]
|
||||
|
||||
if (x === undefined) return y === undefined ? 0 : -1
|
||||
if (y === undefined) return 1
|
||||
|
||||
if (x === y) continue
|
||||
|
||||
const xInt = integer.test(x)
|
||||
const yInt = integer.test(y)
|
||||
|
||||
if (xInt && yInt) {
|
||||
x = +x
|
||||
y = +y
|
||||
} else {
|
||||
if (xInt) return -1
|
||||
if (yInt) return 1
|
||||
}
|
||||
|
||||
return x > y ? 1 : -1
|
||||
} while (++i)
|
||||
}
|
||||
40
bot/node_modules/bare-semver/package.json
generated
vendored
Normal file
40
bot/node_modules/bare-semver/package.json
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "bare-semver",
|
||||
"version": "1.0.2",
|
||||
"description": "Minimal semantic versioning library for Bare",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"./package": "./package.json",
|
||||
"./constants": "./lib/constants.js",
|
||||
"./errors": "./lib/errors.js",
|
||||
"./version": "./lib/version.js",
|
||||
"./range": "./lib/range.js",
|
||||
"./comparator": "./lib/comparator.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "prettier . --check && bare test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/holepunchto/bare-semver.git"
|
||||
},
|
||||
"author": "Holepunch",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/holepunchto/bare-semver/issues"
|
||||
},
|
||||
"homepage": "https://github.com/holepunchto/bare-semver#readme",
|
||||
"devDependencies": {
|
||||
"brittle": "^3.2.1",
|
||||
"prettier": "^3.4.2",
|
||||
"prettier-config-standard": "^7.0.0"
|
||||
}
|
||||
}
|
||||
201
bot/node_modules/require-addon/LICENSE
generated
vendored
Normal file
201
bot/node_modules/require-addon/LICENSE
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
19
bot/node_modules/require-addon/README.md
generated
vendored
Normal file
19
bot/node_modules/require-addon/README.md
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# require-addon
|
||||
|
||||
Import native addons across JavaScript runtimes.
|
||||
|
||||
```
|
||||
npm i require-addon
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
require.addon = require('require-addon')
|
||||
|
||||
const bindings = require.addon('.', __filename)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Apache-2.0
|
||||
1
bot/node_modules/require-addon/lib/bare.js
generated
vendored
Normal file
1
bot/node_modules/require-addon/lib/bare.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require.addon.bind(require)
|
||||
7
bot/node_modules/require-addon/lib/default.js
generated
vendored
Normal file
7
bot/node_modules/require-addon/lib/default.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
if (typeof require.addon === 'function') {
|
||||
module.exports = require.addon.bind(require)
|
||||
} else {
|
||||
module.exports = function addon(specifier, parentURL) {
|
||||
throw new Error(`Cannot find addon '${specifier}' imported from '${parentURL}'`)
|
||||
}
|
||||
}
|
||||
71
bot/node_modules/require-addon/lib/node.js
generated
vendored
Normal file
71
bot/node_modules/require-addon/lib/node.js
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
if (typeof require.addon === 'function') {
|
||||
module.exports = require.addon.bind(require)
|
||||
} else {
|
||||
const url = require('url')
|
||||
const fs = require('fs')
|
||||
const resolve = require('bare-addon-resolve')
|
||||
|
||||
let host = process.platform + '-' + process.arch
|
||||
const conditions = ['addon', 'node', process.platform, process.arch]
|
||||
const extensions = ['.node']
|
||||
|
||||
if (isAlpine()) {
|
||||
host += '-musl'
|
||||
conditions.push('musl')
|
||||
}
|
||||
|
||||
module.exports = function addon(specifier, parentURL) {
|
||||
if (typeof parentURL === 'string') parentURL = url.pathToFileURL(parentURL)
|
||||
|
||||
const candidates = []
|
||||
|
||||
let cause
|
||||
|
||||
for (const resolution of resolve(
|
||||
specifier,
|
||||
parentURL,
|
||||
{ host, conditions, extensions },
|
||||
readPackage
|
||||
)) {
|
||||
candidates.push(resolution)
|
||||
|
||||
switch (resolution.protocol) {
|
||||
case 'file:':
|
||||
try {
|
||||
return require(url.fileURLToPath(resolution))
|
||||
} catch (err) {
|
||||
cause = err
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let message = `Cannot find addon '${specifier}' imported from '${parentURL.href}'`
|
||||
|
||||
if (candidates.length > 0) {
|
||||
message += '\nCandidates:'
|
||||
message += '\n' + candidates.map((url) => '- ' + url.href).join('\n')
|
||||
}
|
||||
|
||||
const err = new Error(message, cause ? { cause } : {})
|
||||
|
||||
err.code = 'ADDON_NOT_FOUND'
|
||||
err.specifier = specifier
|
||||
err.referrer = parentURL
|
||||
err.candidates = candidates
|
||||
|
||||
throw err
|
||||
}
|
||||
|
||||
function readPackage(packageURL) {
|
||||
try {
|
||||
return require(url.fileURLToPath(packageURL))
|
||||
} catch (err) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function isAlpine() {
|
||||
return process.platform === 'linux' && fs.existsSync('/etc/alpine-release')
|
||||
}
|
||||
}
|
||||
63
bot/node_modules/require-addon/package.json
generated
vendored
Normal file
63
bot/node_modules/require-addon/package.json
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "require-addon",
|
||||
"version": "1.2.0",
|
||||
"description": "Import native addons across JavaScript runtimes",
|
||||
"exports": {
|
||||
"./package": "./package.json",
|
||||
".": {
|
||||
"bare": "./lib/bare.js",
|
||||
"node": "./lib/node.js",
|
||||
"default": "./lib/default.js"
|
||||
}
|
||||
},
|
||||
"imports": {
|
||||
"fs": {
|
||||
"bare": "bare-fs",
|
||||
"default": "fs"
|
||||
},
|
||||
"path": {
|
||||
"bare": "bare-path",
|
||||
"default": "path"
|
||||
},
|
||||
"url": {
|
||||
"bare": "bare-url",
|
||||
"default": "url"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "npm run lint && npm run test:bare && npm run test:node",
|
||||
"test:bare": "bare test.js",
|
||||
"test:node": "node test.js",
|
||||
"lint": "prettier --check .",
|
||||
"format": "prettier --write ."
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/holepunchto/require-addon.git"
|
||||
},
|
||||
"author": "Holepunch",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/holepunchto/require-addon/issues"
|
||||
},
|
||||
"homepage": "https://github.com/holepunchto/require-addon#readme",
|
||||
"engines": {
|
||||
"bare": ">=1.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"bare-addon-resolve": "^1.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bare-bundle": "^1.8.1",
|
||||
"bare-bundle-evaluate": "^1.1.0",
|
||||
"bare-fs": "^4.0.0",
|
||||
"bare-path": "^3.0.0",
|
||||
"bare-url": "^2.1.0",
|
||||
"brittle": "^3.7.0",
|
||||
"prettier": "^3.6.2",
|
||||
"prettier-config-holepunch": "^2.0.0"
|
||||
}
|
||||
}
|
||||
278
bot/node_modules/sodium-native/CMakeLists.txt
generated
vendored
Normal file
278
bot/node_modules/sodium-native/CMakeLists.txt
generated
vendored
Normal file
@ -0,0 +1,278 @@
|
||||
cmake_minimum_required(VERSION 3.25)
|
||||
|
||||
find_package(cmake-bare REQUIRED PATHS node_modules/cmake-bare)
|
||||
find_package(cmake-fetch REQUIRED PATHS node_modules/cmake-fetch)
|
||||
find_package(cmake-napi REQUIRED PATHS node_modules/cmake-napi)
|
||||
find_package(cmake-npm REQUIRED PATHS node_modules/cmake-npm)
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
project(sodium_native C ASM CXX)
|
||||
|
||||
fetch_package("github:jedisct1/libsodium#stable" SOURCE_DIR sodium)
|
||||
fetch_package("github:holepunchto/libjstl#098664c")
|
||||
|
||||
bare_target(target)
|
||||
|
||||
if(target MATCHES "win32")
|
||||
add_compile_options(/MT$<$<CONFIG:Debug>:d>)
|
||||
endif()
|
||||
|
||||
file(COPY_FILE "${sodium}/builds/msvc/version.h" "${sodium}/src/libsodium/include/sodium/version.h")
|
||||
|
||||
file(GLOB_RECURSE sodium_headers CONFIGURE_DEPENDS "${sodium}/src/libsodium/**/*.h")
|
||||
file(GLOB_RECURSE sodium_sources CONFIGURE_DEPENDS "${sodium}/src/libsodium/**/*.c")
|
||||
file(GLOB_RECURSE sodium_asm_sources CONFIGURE_DEPENDS "${sodium}/src/libsodium/**/*.S")
|
||||
|
||||
add_library(sodium OBJECT)
|
||||
|
||||
target_sources(
|
||||
sodium
|
||||
INTERFACE
|
||||
${sodium_headers}
|
||||
PRIVATE
|
||||
${sodium_sources}
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
sodium
|
||||
INTERFACE
|
||||
"${sodium}/src/libsodium/include"
|
||||
PRIVATE
|
||||
"${sodium}/src/libsodium/include/sodium"
|
||||
)
|
||||
|
||||
if(NOT target MATCHES "win32")
|
||||
target_compile_options(
|
||||
sodium
|
||||
PRIVATE
|
||||
-fvisibility=hidden
|
||||
-fno-strict-aliasing
|
||||
-fwrapv
|
||||
-flax-vector-conversions
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(
|
||||
sodium
|
||||
PUBLIC
|
||||
SODIUM_STATIC=1
|
||||
PRIVATE
|
||||
_GNU_SOURCE=1
|
||||
CONFIGURED=1
|
||||
DEV_MODE=1
|
||||
HAVE_ATOMIC_OPS=1
|
||||
HAVE_C11_MEMORY_FENCES=1
|
||||
HAVE_CET_H=1
|
||||
HAVE_GCC_MEMORY_FENCES=1
|
||||
HAVE_INLINE_ASM=1
|
||||
HAVE_INTTYPES_H=1
|
||||
HAVE_STDINT_H=1
|
||||
HAVE_TI_MODE=1
|
||||
)
|
||||
|
||||
if(target MATCHES "darwin|ios")
|
||||
target_compile_definitions(
|
||||
sodium
|
||||
PRIVATE
|
||||
ASM_HIDE_SYMBOL=.private_extern
|
||||
TLS=_Thread_local
|
||||
HAVE_ARC4RANDOM=1
|
||||
HAVE_ARC4RANDOM_BUF=1
|
||||
HAVE_CATCHABLE_ABRT=1
|
||||
HAVE_CATCHABLE_SEGV=1
|
||||
HAVE_CLOCK_GETTIME=1
|
||||
HAVE_GETPID=1
|
||||
HAVE_MADVISE=1
|
||||
HAVE_MEMSET_S=1
|
||||
HAVE_MLOCK=1
|
||||
HAVE_MMAP=1
|
||||
HAVE_MPROTECT=1
|
||||
HAVE_NANOSLEEP=1
|
||||
HAVE_POSIX_MEMALIGN=1
|
||||
HAVE_PTHREAD=1
|
||||
HAVE_PTHREAD_PRIO_INHERIT=1
|
||||
HAVE_RAISE=1
|
||||
HAVE_SYSCONF=1
|
||||
HAVE_SYS_MMAN_H=1
|
||||
HAVE_SYS_PARAM_H=1
|
||||
HAVE_WEAK_SYMBOLS=1
|
||||
)
|
||||
|
||||
if(NOT target MATCHES "ios")
|
||||
target_compile_definitions(
|
||||
sodium
|
||||
PRIVATE
|
||||
HAVE_GETENTROPY=1
|
||||
HAVE_SYS_RANDOM_H=1
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(target MATCHES "linux")
|
||||
target_compile_definitions(
|
||||
sodium
|
||||
PRIVATE
|
||||
ASM_HIDE_SYMBOL=.hidden
|
||||
TLS=_Thread_local
|
||||
HAVE_CATCHABLE_ABRT=1
|
||||
HAVE_CATCHABLE_SEGV=1
|
||||
HAVE_CLOCK_GETTIME=1
|
||||
HAVE_GETPID=1
|
||||
HAVE_MADVISE=1
|
||||
HAVE_MLOCK=1
|
||||
HAVE_MMAP=1
|
||||
HAVE_MPROTECT=1
|
||||
HAVE_NANOSLEEP=1
|
||||
HAVE_POSIX_MEMALIGN=1
|
||||
HAVE_PTHREAD_PRIO_INHERIT=1
|
||||
HAVE_PTHREAD=1
|
||||
HAVE_RAISE=1
|
||||
HAVE_SYSCONF=1
|
||||
HAVE_SYS_AUXV_H=1
|
||||
HAVE_SYS_MMAN_H=1
|
||||
HAVE_SYS_PARAM_H=1
|
||||
HAVE_SYS_RANDOM_H=1
|
||||
HAVE_WEAK_SYMBOLS=1
|
||||
)
|
||||
endif()
|
||||
|
||||
if(target MATCHES "win32")
|
||||
target_compile_definitions(
|
||||
sodium
|
||||
PRIVATE
|
||||
_CRT_SECURE_NO_WARNINGS=1
|
||||
HAVE_RAISE=1
|
||||
)
|
||||
endif()
|
||||
|
||||
if(target MATCHES "x64")
|
||||
target_compile_definitions(
|
||||
sodium
|
||||
PRIVATE
|
||||
HAVE_CPUID=1
|
||||
HAVE_RDRAND=1
|
||||
HAVE_EMMINTRIN_H=1 # SSE2
|
||||
HAVE_PMMINTRIN_H=1 # SSE3
|
||||
HAVE_TMMINTRIN_H=1 # SSSE3
|
||||
HAVE_SMMINTRIN_H=1 # SSE4.1
|
||||
HAVE_WMMINTRIN_H=1 # AES
|
||||
HAVE_AVXINTRIN_H=1 # AVX
|
||||
HAVE_AVX2INTRIN_H=1 # AVX2
|
||||
HAVE_AVX512FINTRIN_H # AVX512F
|
||||
)
|
||||
|
||||
if(NOT target MATCHES "win32")
|
||||
target_compile_definitions(
|
||||
sodium
|
||||
PRIVATE
|
||||
HAVE_AMD64_ASM=1
|
||||
HAVE_AVX_ASM=1
|
||||
)
|
||||
|
||||
target_sources(
|
||||
sodium
|
||||
PRIVATE
|
||||
${sodium_asm_sources}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(target MATCHES "arm64")
|
||||
target_compile_definitions(
|
||||
sodium
|
||||
PRIVATE
|
||||
HAVE_ARMCRYPTO=1
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_BYTE_ORDER MATCHES "BIG_ENDIAN")
|
||||
target_compile_definitions(
|
||||
sodium
|
||||
PRIVATE
|
||||
NATIVE_BIG_ENDIAN=1
|
||||
)
|
||||
else()
|
||||
target_compile_definitions(
|
||||
sodium
|
||||
PRIVATE
|
||||
NATIVE_LITTLE_ENDIAN=1
|
||||
)
|
||||
endif()
|
||||
|
||||
if(target MATCHES "linux|android")
|
||||
target_link_options(
|
||||
sodium
|
||||
PUBLIC
|
||||
-Wl,-z,noexecstack
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(sodium_extensions OBJECT)
|
||||
|
||||
target_sources(
|
||||
sodium_extensions
|
||||
PRIVATE
|
||||
extensions/tweak/tweak.c
|
||||
extensions/tweak/tweak.h
|
||||
extensions/pbkdf2/pbkdf2.c
|
||||
extensions/pbkdf2/pbkdf2.h
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
sodium_extensions
|
||||
PUBLIC
|
||||
sodium
|
||||
)
|
||||
|
||||
add_bare_module(sodium_native_bare)
|
||||
|
||||
target_sources(
|
||||
${sodium_native_bare}
|
||||
PRIVATE
|
||||
binding.cc
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
${sodium_native_bare}
|
||||
PRIVATE
|
||||
$<TARGET_OBJECTS:sodium>
|
||||
$<TARGET_OBJECTS:sodium_extensions>
|
||||
jstl
|
||||
PUBLIC
|
||||
sodium
|
||||
sodium_extensions
|
||||
)
|
||||
|
||||
add_napi_module(sodium_native_node)
|
||||
|
||||
target_sources(
|
||||
${sodium_native_node}
|
||||
PRIVATE
|
||||
binding.cc
|
||||
)
|
||||
|
||||
target_compile_definitions(
|
||||
${sodium_native_node}
|
||||
PRIVATE
|
||||
NAPI_VERSION=9
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
${sodium_native_node}
|
||||
PRIVATE
|
||||
$<TARGET_OBJECTS:sodium>
|
||||
$<TARGET_OBJECTS:sodium_extensions>
|
||||
jstl
|
||||
PUBLIC
|
||||
sodium
|
||||
sodium_extensions
|
||||
)
|
||||
|
||||
resolve_node_module(bare-compat-napi compat)
|
||||
|
||||
target_include_directories(
|
||||
${sodium_native_node}
|
||||
PRIVATE
|
||||
"${compat}/include"
|
||||
)
|
||||
21
bot/node_modules/sodium-native/LICENSE
generated
vendored
Normal file
21
bot/node_modules/sodium-native/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Mathias Buus and Emil Bay
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
53
bot/node_modules/sodium-native/README.md
generated
vendored
Normal file
53
bot/node_modules/sodium-native/README.md
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
# sodium-native
|
||||
|
||||
Low level bindings for [libsodium](https://github.com/jedisct1/libsodium).
|
||||
|
||||
```
|
||||
npm install sodium-native
|
||||
```
|
||||
|
||||
The goal of this project is to be thin, stable, unopionated wrapper around libsodium.
|
||||
|
||||
All methods exposed are more or less a direct translation of the libsodium c-api.
|
||||
This means that most data types are buffers and you have to manage allocating return values and passing them in as arguments instead of receiving them as return values.
|
||||
|
||||
This makes this API harder to use than other libsodium wrappers out there, but also means that you'll be able to get a lot of perf / memory improvements as you can do stuff like inline encryption / decryption, reuse buffers etc.
|
||||
|
||||
This also makes this library useful as a foundation for more high level crypto abstractions that you want to make.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var sodium = require('sodium-native')
|
||||
|
||||
var nonce = Buffer.alloc(sodium.crypto_secretbox_NONCEBYTES)
|
||||
var key = sodium.sodium_malloc(sodium.crypto_secretbox_KEYBYTES) // secure buffer
|
||||
var message = Buffer.from('Hello, World!')
|
||||
var ciphertext = Buffer.alloc(message.length + sodium.crypto_secretbox_MACBYTES)
|
||||
|
||||
sodium.randombytes_buf(nonce) // insert random data into nonce
|
||||
sodium.randombytes_buf(key) // insert random data into key
|
||||
|
||||
// encrypted message is stored in ciphertext.
|
||||
sodium.crypto_secretbox_easy(ciphertext, message, nonce, key)
|
||||
|
||||
console.log('Encrypted message:', ciphertext)
|
||||
|
||||
var plainText = Buffer.alloc(
|
||||
ciphertext.length - sodium.crypto_secretbox_MACBYTES
|
||||
)
|
||||
|
||||
if (!sodium.crypto_secretbox_open_easy(plainText, ciphertext, nonce, key)) {
|
||||
console.log('Decryption failed!')
|
||||
} else {
|
||||
console.log('Decrypted message:', plainText, '(' + plainText.toString() + ')')
|
||||
}
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
Complete documentation may be found on the [sodium-friends website](https://sodium-friends.github.io/docs/docs/getstarted)
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
4094
bot/node_modules/sodium-native/binding.cc
generated
vendored
Normal file
4094
bot/node_modules/sodium-native/binding.cc
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
bot/node_modules/sodium-native/binding.js
generated
vendored
Normal file
2
bot/node_modules/sodium-native/binding.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
require.addon = require('require-addon')
|
||||
module.exports = require.addon('.', __filename)
|
||||
90
bot/node_modules/sodium-native/extensions/pbkdf2/pbkdf2.c
generated
vendored
Normal file
90
bot/node_modules/sodium-native/extensions/pbkdf2/pbkdf2.c
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
/*-
|
||||
* Copyright 2005,2007,2009 Colin Percival
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Adapted from libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf-sha256.c
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <sodium.h>
|
||||
|
||||
#include "pbkdf2.h"
|
||||
|
||||
/**
|
||||
* pbkdf2_sha512(passwd, passwdlen, salt, saltlen, c, buf, dkLen):
|
||||
* Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and
|
||||
* write the output to buf. The value dkLen must be at most 32 * (2^32 - 1).
|
||||
*/
|
||||
int
|
||||
sn__extension_pbkdf2_sha512(const unsigned char *passwd, size_t passwdlen,
|
||||
const unsigned char *salt, size_t saltlen, uint64_t c,
|
||||
unsigned char *buf, size_t dkLen)
|
||||
{
|
||||
crypto_auth_hmacsha512_state PShctx, hctx;
|
||||
size_t i;
|
||||
unsigned char ivec[4];
|
||||
unsigned char U[64];
|
||||
unsigned char T[64];
|
||||
uint64_t j;
|
||||
unsigned int k;
|
||||
size_t clen;
|
||||
|
||||
if (dkLen > sn__extension_pbkdf2_sha512_BYTES_MAX) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
crypto_auth_hmacsha512_init(&PShctx, passwd, passwdlen);
|
||||
crypto_auth_hmacsha512_update(&PShctx, salt, saltlen);
|
||||
|
||||
for (i = 0; i * crypto_auth_hmacsha512_BYTES < dkLen; i++) {
|
||||
SN_PBKDF2_STORE32_BE(ivec, (uint32_t)(i + 1));
|
||||
memcpy(&hctx, &PShctx, sizeof(crypto_auth_hmacsha512_state));
|
||||
crypto_auth_hmacsha512_update(&hctx, ivec, 4);
|
||||
crypto_auth_hmacsha512_final(&hctx, U);
|
||||
|
||||
memcpy(T, U, crypto_auth_hmacsha512_BYTES);
|
||||
/* LCOV_EXCL_START */
|
||||
for (j = 2; j <= c; j++) {
|
||||
crypto_auth_hmacsha512_init(&hctx, passwd, passwdlen);
|
||||
crypto_auth_hmacsha512_update(&hctx, U, crypto_auth_hmacsha512_BYTES);
|
||||
crypto_auth_hmacsha512_final(&hctx, U);
|
||||
|
||||
for (k = 0; k < crypto_auth_hmacsha512_BYTES; k++) {
|
||||
T[k] ^= U[k];
|
||||
}
|
||||
}
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
||||
clen = dkLen - i * crypto_auth_hmacsha512_BYTES;
|
||||
if (clen > crypto_auth_hmacsha512_BYTES) {
|
||||
clen = crypto_auth_hmacsha512_BYTES;
|
||||
}
|
||||
memcpy(&buf[i * crypto_auth_hmacsha512_BYTES], T, clen);
|
||||
}
|
||||
sodium_memzero((void *) &PShctx, sizeof PShctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
60
bot/node_modules/sodium-native/extensions/pbkdf2/pbkdf2.h
generated
vendored
Normal file
60
bot/node_modules/sodium-native/extensions/pbkdf2/pbkdf2.h
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
/*-
|
||||
* Copyright 2005,2007,2009 Colin Percival
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Adapted from libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf-sha256.c
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <sodium.h>
|
||||
|
||||
#define SN_PBKDF2_STORE32_BE(buf, n32) \
|
||||
buf[0] = n32 >> 24 & 0xff; \
|
||||
buf[1] = n32 >> 16 & 0xff; \
|
||||
buf[2] = n32 >> 8 & 0xff; \
|
||||
buf[3] = n32 >> 0 & 0xff;
|
||||
|
||||
#define sn__extension_pbkdf2_sha512_SALTBYTES 16U
|
||||
|
||||
#define sn__extension_pbkdf2_sha512_HASHBYTES crypto_hash_sha512_BYTES
|
||||
|
||||
#define sn__extension_pbkdf2_sha512_ITERATIONS_MIN 1U
|
||||
|
||||
#define sn__extension_pbkdf2_sha512_BYTES_MAX 0x3fffffffc0ULL
|
||||
|
||||
/**
|
||||
* extension_pbkdf2_sha512(passwd, passwdlen, salt, saltlen, c, buf, dkLen):
|
||||
* Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and
|
||||
* write the output to buf. The value dkLen must be at most 32 * (2^32 - 1).
|
||||
*/
|
||||
int sn__extension_pbkdf2_sha512(const unsigned char *, size_t, const unsigned char *, size_t,
|
||||
uint64_t, unsigned char *, size_t);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
206
bot/node_modules/sodium-native/extensions/tweak/tweak.c
generated
vendored
Normal file
206
bot/node_modules/sodium-native/extensions/tweak/tweak.c
generated
vendored
Normal file
@ -0,0 +1,206 @@
|
||||
#include "tweak.h"
|
||||
|
||||
/*
|
||||
*EXPERIMENTAL API*
|
||||
|
||||
This module is an experimental implementation of a key tweaking protocol
|
||||
over ed25519 keys. The signature algorithm has been reimplemented from
|
||||
libsodium, but the nonce generation algorithm is *non-standard*.
|
||||
|
||||
Use at your own risk
|
||||
*/
|
||||
|
||||
static void _extension_tweak_nonce (unsigned char *nonce, const unsigned char *n,
|
||||
const unsigned char *m, unsigned long long mlen)
|
||||
{
|
||||
// dom2(x, y) with x = 0 (not prehashed) and y = "crypto_tweak_ed25519"
|
||||
static const unsigned char TWEAK_PREFIX[32 + 2 + 20] = {
|
||||
'S', 'i', 'g', 'E', 'd', '2', '5', '5', '1', '9', ' ',
|
||||
'n', 'o', ' ', 'E', 'd', '2', '5', '5', '1', '9', ' ',
|
||||
'c', 'o', 'l', 'l', 'i', 's', 'i', 'o', 'n', 's', 0,
|
||||
20, 'c', 'r', 'y', 'p', 't', 'o', '_', 't', 'w', 'e',
|
||||
'a', 'k', '_', 'e', 'd', '2', '5', '5', '1', '9'
|
||||
};
|
||||
|
||||
crypto_hash_sha512_state hs;
|
||||
|
||||
crypto_hash_sha512_init(&hs);
|
||||
crypto_hash_sha512_update(&hs, TWEAK_PREFIX, sizeof TWEAK_PREFIX);
|
||||
crypto_hash_sha512_update(&hs, n, 32);
|
||||
crypto_hash_sha512_update(&hs, m, mlen);
|
||||
crypto_hash_sha512_final(&hs, nonce);
|
||||
}
|
||||
|
||||
static inline void
|
||||
_crypto_sign_ed25519_clamp(unsigned char k[32])
|
||||
{
|
||||
k[0] &= 248;
|
||||
k[31] &= 127;
|
||||
k[31] |= 64;
|
||||
}
|
||||
|
||||
static void _extension_tweak_ed25519(unsigned char *q, unsigned char *n,
|
||||
const unsigned char *ns, unsigned long long nslen)
|
||||
{
|
||||
sodium_memzero(q, sizeof q);
|
||||
|
||||
crypto_hash(n, ns, nslen);
|
||||
n[31] &= 127; // clear highest bit
|
||||
|
||||
crypto_scalarmult_ed25519_base_noclamp(q, n);
|
||||
|
||||
// hash tweak until we get a valid tweaked q
|
||||
while (crypto_core_ed25519_is_valid_point(q) != 1) {
|
||||
crypto_hash(n, n, 32);
|
||||
n[31] &= 127; // clear highest bit
|
||||
|
||||
crypto_scalarmult_ed25519_base_noclamp(q, n);
|
||||
}
|
||||
}
|
||||
|
||||
void sn__extension_tweak_ed25519_base(unsigned char *pk, unsigned char *scalar,
|
||||
const unsigned char *ns, unsigned long long nslen)
|
||||
{
|
||||
unsigned char n64[64];
|
||||
|
||||
_extension_tweak_ed25519(pk, n64, ns, nslen);
|
||||
|
||||
SN_TWEAK_COPY_32(scalar, n64)
|
||||
}
|
||||
|
||||
int sn__extension_tweak_ed25519_sign_detached(unsigned char *sig, unsigned long long *siglen_p,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *n, unsigned char *pk)
|
||||
{
|
||||
crypto_hash_sha512_state hs;
|
||||
|
||||
unsigned char nonce[64];
|
||||
unsigned char R[32];
|
||||
unsigned char hram[64];
|
||||
unsigned char _pk[32];
|
||||
|
||||
// check if pk was passed
|
||||
if (pk == NULL) {
|
||||
pk = _pk;
|
||||
|
||||
// derive pk from scalar
|
||||
if (crypto_scalarmult_ed25519_base_noclamp(pk, n) != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
_extension_tweak_nonce(nonce, n, m, mlen);
|
||||
crypto_core_ed25519_scalar_reduce(nonce, nonce);
|
||||
|
||||
// R = G ^ nonce : curve point from nonce
|
||||
if (crypto_scalarmult_ed25519_base_noclamp(R, nonce) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// generate challenge as h(ram) = hash(R, pk, message)
|
||||
crypto_hash_sha512_init(&hs);
|
||||
crypto_hash_sha512_update(&hs, R, 32);
|
||||
crypto_hash_sha512_update(&hs, pk, 32);
|
||||
crypto_hash_sha512_update(&hs, m, mlen);
|
||||
|
||||
crypto_hash_sha512_final(&hs, hram);
|
||||
|
||||
crypto_core_ed25519_scalar_reduce(hram, hram);
|
||||
|
||||
// sig = nonce + n * h(ram)
|
||||
crypto_core_ed25519_scalar_mul(sig, hram, n);
|
||||
crypto_core_ed25519_scalar_add(sig + 32, nonce, sig);
|
||||
|
||||
SN_TWEAK_COPY_32(sig, R)
|
||||
|
||||
if (siglen_p != NULL) {
|
||||
*siglen_p = 64U;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// tweak a secret key
|
||||
void sn__extension_tweak_ed25519_sk_to_scalar(unsigned char *n, const unsigned char *sk)
|
||||
{
|
||||
unsigned char n64[64];
|
||||
|
||||
// get sk scalar from seed, cf. crypto_sign_keypair_seed
|
||||
crypto_hash(n64, sk, 32);
|
||||
_crypto_sign_ed25519_clamp(n64);
|
||||
|
||||
SN_TWEAK_COPY_32(n, n64)
|
||||
}
|
||||
|
||||
// tweak a secret key
|
||||
void sn__extension_tweak_ed25519_scalar(unsigned char *scalar_out,
|
||||
const unsigned char *scalar,
|
||||
const unsigned char *ns,
|
||||
unsigned long long nslen)
|
||||
{
|
||||
unsigned char n[64];
|
||||
unsigned char q[32];
|
||||
|
||||
_extension_tweak_ed25519(q, n, ns, nslen);
|
||||
crypto_core_ed25519_scalar_add(scalar_out, scalar, n);
|
||||
}
|
||||
|
||||
// tweak a public key
|
||||
int sn__extension_tweak_ed25519_pk(unsigned char *tpk,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *ns,
|
||||
unsigned long long nslen)
|
||||
{
|
||||
unsigned char n[64];
|
||||
unsigned char q[32];
|
||||
|
||||
_extension_tweak_ed25519(q, n, ns, nslen);
|
||||
return crypto_core_ed25519_add(tpk, q, pk);
|
||||
}
|
||||
|
||||
|
||||
void sn__extension_tweak_ed25519_keypair(unsigned char *pk, unsigned char *scalar_out,
|
||||
unsigned char *scalar, const unsigned char *ns,
|
||||
unsigned long long nslen)
|
||||
{
|
||||
unsigned char n64[64];
|
||||
|
||||
crypto_hash(n64, ns, nslen);
|
||||
n64[31] &= 127; // clear highest bit
|
||||
|
||||
sn__extension_tweak_ed25519_scalar_add(scalar_out, scalar, n64);
|
||||
crypto_scalarmult_ed25519_base_noclamp(pk, scalar_out);
|
||||
|
||||
// hash tweak until we get a valid tweaked point
|
||||
while (crypto_core_ed25519_is_valid_point(pk) != 1) {
|
||||
crypto_hash(n64, n64, 32);
|
||||
n64[31] &= 127; // clear highest bit
|
||||
|
||||
sn__extension_tweak_ed25519_scalar_add(scalar_out, scalar, n64);
|
||||
crypto_scalarmult_ed25519_base_noclamp(pk, scalar_out);
|
||||
}
|
||||
}
|
||||
|
||||
// add tweak to scalar
|
||||
void sn__extension_tweak_ed25519_scalar_add(unsigned char *scalar_out,
|
||||
const unsigned char *scalar,
|
||||
const unsigned char *n)
|
||||
{
|
||||
crypto_core_ed25519_scalar_add(scalar_out, scalar, n);
|
||||
}
|
||||
|
||||
// add tweak point to public key
|
||||
int sn__extension_tweak_ed25519_pk_add(unsigned char *tpk,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *q)
|
||||
{
|
||||
return crypto_core_ed25519_add(tpk, pk, q);
|
||||
}
|
||||
|
||||
|
||||
int sn__extension_tweak_ed25519_keypair_add(unsigned char *pk, unsigned char *scalar_out,
|
||||
unsigned char *scalar, const unsigned char *tweak)
|
||||
{
|
||||
sn__extension_tweak_ed25519_scalar_add(scalar_out, scalar, tweak);
|
||||
return crypto_scalarmult_ed25519_base_noclamp(pk, scalar_out);
|
||||
}
|
||||
62
bot/node_modules/sodium-native/extensions/tweak/tweak.h
generated
vendored
Normal file
62
bot/node_modules/sodium-native/extensions/tweak/tweak.h
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <sodium.h>
|
||||
|
||||
// copy 32 bytes using int64_t pointers
|
||||
#define SN_TWEAK_COPY_32(a, b) \
|
||||
{ \
|
||||
long long *dst = (long long *) a; \
|
||||
long long *src = (long long *) b; \
|
||||
dst[0] = src[0]; \
|
||||
dst[1] = src[1]; \
|
||||
dst[2] = src[2]; \
|
||||
dst[3] = src[3]; \
|
||||
}
|
||||
|
||||
#define sn__extension_tweak_ed25519_BYTES crypto_sign_ed25519_PUBLICKEYBYTES
|
||||
|
||||
#define sn__extension_tweak_ed25519_SCALARBYTES crypto_scalarmult_ed25519_SCALARBYTES
|
||||
|
||||
int sn__extension_tweak_ed25519_sign_detached(unsigned char *sig, unsigned long long *siglen_p,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *n, unsigned char *pk);
|
||||
|
||||
void sn__extension_tweak_ed25519_base(unsigned char *pk, unsigned char *scalar,
|
||||
const unsigned char *ns, unsigned long long nslen);
|
||||
|
||||
void sn__extension_tweak_ed25519_sk_to_scalar(unsigned char *scalar, const unsigned char *sk);
|
||||
|
||||
// tweak a secret key
|
||||
void sn__extension_tweak_ed25519_scalar(unsigned char *scalar_out,
|
||||
const unsigned char *scalar,
|
||||
const unsigned char *ns,
|
||||
unsigned long long nslen);
|
||||
|
||||
// tweak a public key
|
||||
int sn__extension_tweak_ed25519_pk(unsigned char *tpk,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *ns,
|
||||
unsigned long long nslen);
|
||||
|
||||
void sn__extension_tweak_ed25519_keypair(unsigned char *pk, unsigned char *scalar_out,
|
||||
unsigned char *scalar, const unsigned char *ns,
|
||||
unsigned long long nslen);
|
||||
|
||||
// add tweak scalar to private key
|
||||
void sn__extension_tweak_ed25519_scalar_add(unsigned char *scalar_out,
|
||||
const unsigned char *scalar,
|
||||
const unsigned char *n);
|
||||
|
||||
// add tweak point to public key
|
||||
int sn__extension_tweak_ed25519_pk_add(unsigned char *tpk,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *q);
|
||||
|
||||
int sn__extension_tweak_ed25519_keypair_add(unsigned char *pk, unsigned char *scalar_out,
|
||||
unsigned char *scalar, const unsigned char *tweak);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
2272
bot/node_modules/sodium-native/index.js
generated
vendored
Normal file
2272
bot/node_modules/sodium-native/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
55
bot/node_modules/sodium-native/package.json
generated
vendored
Normal file
55
bot/node_modules/sodium-native/package.json
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "sodium-native",
|
||||
"version": "5.0.10",
|
||||
"description": "Low level bindings for libsodium",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"binding.cc",
|
||||
"binding.js",
|
||||
"extensions",
|
||||
"prebuilds",
|
||||
"CMakeLists.txt"
|
||||
],
|
||||
"addon": true,
|
||||
"dependencies": {
|
||||
"require-addon": "^1.1.0",
|
||||
"which-runtime": "^1.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bare-compat-napi": "^1.3.5",
|
||||
"brittle": "^3.16.2",
|
||||
"cmake-bare": "^1.6.1",
|
||||
"cmake-fetch": "^1.4.3",
|
||||
"cmake-napi": "^1.2.1",
|
||||
"prettier": "^3.6.2",
|
||||
"prettier-config-holepunch": "^1.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "prettier . --check && npm run test:node && npm run test:bare",
|
||||
"test:node": "node test/all.js",
|
||||
"test:bare": "bare test/all.js"
|
||||
},
|
||||
"standard": {
|
||||
"ignore": [
|
||||
"/test/fixtures/*.js"
|
||||
]
|
||||
},
|
||||
"engines": {
|
||||
"bare": ">=1.16.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/holepunchto/sodium-native.git"
|
||||
},
|
||||
"contributors": [
|
||||
"Emil Bay <github@tixz.dk> (http://bayes.dk)",
|
||||
"Mathias Buus <mathiasbuus@gmail.com> (https://mafinto.sh)",
|
||||
"Christophe Diederichs <chm-diederichs@hyperdivision.dk>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/holepunchto/sodium-native/issues"
|
||||
},
|
||||
"homepage": "https://github.com/holepunchto/sodium-native"
|
||||
}
|
||||
BIN
bot/node_modules/sodium-native/prebuilds/android-arm/sodium-native.bare
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/android-arm/sodium-native.bare
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/android-arm/sodium-native.node
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/android-arm/sodium-native.node
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/android-arm64/sodium-native.bare
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/android-arm64/sodium-native.bare
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/android-arm64/sodium-native.node
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/android-arm64/sodium-native.node
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/android-ia32/sodium-native.bare
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/android-ia32/sodium-native.bare
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/android-ia32/sodium-native.node
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/android-ia32/sodium-native.node
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/android-x64/sodium-native.bare
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/android-x64/sodium-native.bare
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/android-x64/sodium-native.node
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/android-x64/sodium-native.node
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/darwin-arm64/sodium-native.bare
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/darwin-arm64/sodium-native.bare
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/darwin-arm64/sodium-native.node
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/darwin-arm64/sodium-native.node
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/darwin-x64/sodium-native.bare
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/darwin-x64/sodium-native.bare
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/darwin-x64/sodium-native.node
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/darwin-x64/sodium-native.node
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/ios-arm64-simulator/sodium-native.bare
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/ios-arm64-simulator/sodium-native.bare
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/ios-arm64/sodium-native.bare
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/ios-arm64/sodium-native.bare
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/ios-x64-simulator/sodium-native.bare
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/ios-x64-simulator/sodium-native.bare
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/linux-arm64/sodium-native.bare
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/linux-arm64/sodium-native.bare
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/linux-arm64/sodium-native.node
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/linux-arm64/sodium-native.node
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/linux-x64/sodium-native.bare
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/linux-x64/sodium-native.bare
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/linux-x64/sodium-native.node
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/linux-x64/sodium-native.node
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/win32-arm64/sodium-native.bare
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/win32-arm64/sodium-native.bare
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/win32-arm64/sodium-native.node
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/win32-arm64/sodium-native.node
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/win32-x64/sodium-native.bare
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/win32-x64/sodium-native.bare
generated
vendored
Normal file
Binary file not shown.
BIN
bot/node_modules/sodium-native/prebuilds/win32-x64/sodium-native.node
generated
vendored
Normal file
BIN
bot/node_modules/sodium-native/prebuilds/win32-x64/sodium-native.node
generated
vendored
Normal file
Binary file not shown.
201
bot/node_modules/which-runtime/LICENSE
generated
vendored
Normal file
201
bot/node_modules/which-runtime/LICENSE
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
29
bot/node_modules/which-runtime/README.md
generated
vendored
Normal file
29
bot/node_modules/which-runtime/README.md
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
# which-runtime
|
||||
|
||||
Detect if you are in Bare or Node and which os etc
|
||||
|
||||
```
|
||||
npm install which-runtime
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
``` js
|
||||
import {
|
||||
runtime, // bare, node, or browser
|
||||
platform, // the platform string, ie darwin, win32, etc
|
||||
arch, // which arch, arm64, ia32, x64 etc
|
||||
isBrowser,
|
||||
isBare,
|
||||
isNode,
|
||||
isLinux,
|
||||
isWindows,
|
||||
isMac,
|
||||
isIOS,
|
||||
isAndroid
|
||||
} from 'which-runtime'
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Apache-2.0
|
||||
24
bot/node_modules/which-runtime/index.js
generated
vendored
Normal file
24
bot/node_modules/which-runtime/index.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
const { runtime, platform, arch } = typeof Bare !== 'undefined'
|
||||
? { runtime: 'bare', platform: global.Bare.platform, arch: global.Bare.arch }
|
||||
: typeof process !== 'undefined'
|
||||
? { runtime: 'node', platform: global.process.platform, arch: global.process.arch }
|
||||
: typeof Window !== 'undefined'
|
||||
? { runtime: 'browser', platform: 'unknown', arch: 'unknown' }
|
||||
: { runtime: 'unknown', platform: 'unknown', arch: 'unknown' }
|
||||
|
||||
exports.runtime = runtime
|
||||
exports.platform = platform
|
||||
exports.arch = arch
|
||||
exports.isBare = runtime === 'bare'
|
||||
exports.isBareKit = exports.isBare && typeof BareKit !== 'undefined'
|
||||
exports.isPear = typeof Pear !== 'undefined'
|
||||
exports.isNode = runtime === 'node'
|
||||
exports.isBrowser = runtime === 'browser'
|
||||
exports.isWindows = platform === 'win32'
|
||||
exports.isLinux = platform === 'linux'
|
||||
exports.isMac = platform === 'darwin'
|
||||
exports.isIOS = platform === 'ios' || platform === 'ios-simulator'
|
||||
exports.isAndroid = platform === 'android'
|
||||
exports.isElectron = typeof process !== 'undefined' && !!global.process.versions?.electron
|
||||
exports.isElectronRenderer = exports.isElectron && global.process.type === 'renderer'
|
||||
exports.isElectronWorker = exports.isElectron && global.process.type === 'worker'
|
||||
26
bot/node_modules/which-runtime/package.json
generated
vendored
Normal file
26
bot/node_modules/which-runtime/package.json
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "which-runtime",
|
||||
"version": "1.3.2",
|
||||
"description": "Detect if you are in Bare or Node and which os etc",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"standard": "^17.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/holepunchto/which-runtime.git"
|
||||
},
|
||||
"author": "Holepunch Inc.",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/holepunchto/which-runtime/issues"
|
||||
},
|
||||
"homepage": "https://github.com/holepunchto/which-runtime"
|
||||
}
|
||||
75
bot/package-lock.json
generated
75
bot/package-lock.json
generated
@ -21,7 +21,8 @@
|
||||
"dotenv": "^17.3.1",
|
||||
"ffmpeg-static": "^5.3.0",
|
||||
"libsodium-wrappers": "^0.7.16",
|
||||
"play-dl": "^1.9.7"
|
||||
"play-dl": "^1.9.7",
|
||||
"sodium-native": "^5.0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/@derhuerst/http-basic": {
|
||||
@ -798,6 +799,47 @@
|
||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/bare-addon-resolve": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/bare-addon-resolve/-/bare-addon-resolve-1.10.0.tgz",
|
||||
"integrity": "sha512-sSd0jieRJlDaODOzj0oe0RjFVC1QI0ZIjGIdPkbrTXsdVVtENg14c+lHHAhHwmWCZ2nQlMhy8jA3Y5LYPc/isA==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"bare-module-resolve": "^1.10.0",
|
||||
"bare-semver": "^1.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bare-url": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bare-url": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/bare-module-resolve": {
|
||||
"version": "1.12.1",
|
||||
"resolved": "https://registry.npmjs.org/bare-module-resolve/-/bare-module-resolve-1.12.1.tgz",
|
||||
"integrity": "sha512-hbmAPyFpEq8FoZMd5sFO3u6MC5feluWoGE8YKlA8fCrl6mNtx68Wjg4DTiDJcqRJaovTvOYKfYngoBUnbaT7eg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"bare-semver": "^1.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bare-url": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bare-url": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/bare-semver": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/bare-semver/-/bare-semver-1.0.2.tgz",
|
||||
"integrity": "sha512-ESVaN2nzWhcI5tf3Zzcq9aqCZ676VWzqw07eEZ0qxAcEOAFYBa0pWq8sK34OQeHLY3JsfKXZS9mDyzyxGjeLzA==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "1.1.12",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz",
|
||||
@ -1793,6 +1835,18 @@
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/require-addon": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/require-addon/-/require-addon-1.2.0.tgz",
|
||||
"integrity": "sha512-VNPDZlYgIYQwWp9jMTzljx+k0ZtatKlcvOhktZ/anNPI3dQ9NXk7cq2U4iJ1wd9IrytRnYhyEocFWbkdPb+MYA==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"bare-addon-resolve": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"bare": ">=1.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/rimraf": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
|
||||
@ -1925,6 +1979,19 @@
|
||||
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/sodium-native": {
|
||||
"version": "5.0.10",
|
||||
"resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-5.0.10.tgz",
|
||||
"integrity": "sha512-UIw+0AbpCQRuTJF88JWrZomP4O+PXhlWvdopiAJOsUivTyHTf3korMyStxkZuPngSbBEtEfDdc4ewEd8/T4/lA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"require-addon": "^1.1.0",
|
||||
"which-runtime": "^1.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"bare": ">=1.16.0"
|
||||
}
|
||||
},
|
||||
"node_modules/soundcloud.ts": {
|
||||
"version": "0.6.9",
|
||||
"resolved": "https://registry.npmjs.org/soundcloud.ts/-/soundcloud.ts-0.6.9.tgz",
|
||||
@ -2105,6 +2172,12 @@
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/which-runtime": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/which-runtime/-/which-runtime-1.3.2.tgz",
|
||||
"integrity": "sha512-5kwCfWml7+b2NO7KrLMhYihjRx0teKkd3yGp1Xk5Vaf2JGdSh+rgVhEALAD9c/59dP+YwJHXoEO7e8QPy7gOkw==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/wide-align": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz",
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
"dotenv": "^17.3.1",
|
||||
"ffmpeg-static": "^5.3.0",
|
||||
"libsodium-wrappers": "^0.7.16",
|
||||
"play-dl": "^1.9.7"
|
||||
"play-dl": "^1.9.7",
|
||||
"sodium-native": "^5.0.10"
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user