New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@itsmapleleaf/gatekeeper

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@itsmapleleaf/gatekeeper - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1-0

dist/main.cjs

153

dist/main.js

@@ -1,9 +0,5 @@

var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;

@@ -24,3 +20,2 @@ var __propIsEnum = Object.prototype.propertyIsEnumerable;

var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __objRest = (source, exclude) => {

@@ -38,29 +33,3 @@ var target = {};

};
var __export = (target, all) => {
__markAsModule(target);
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && key !== "default")
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
return target;
};
var __toModule = (module2) => {
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
};
// src/main.ts
__export(exports, {
Gatekeeper: () => Gatekeeper,
actionRowComponent: () => actionRowComponent,
buttonComponent: () => buttonComponent,
embedComponent: () => embedComponent,
linkComponent: () => linkComponent,
selectMenuComponent: () => selectMenuComponent
});
// src/core/component/action-row-component.ts

@@ -75,7 +44,7 @@ function actionRowComponent(...children) {

// src/core/component/button-component.ts
var import_node_crypto = __toModule(require("crypto"));
import { randomUUID } from "node:crypto";
function buttonComponent(options) {
return __spreadProps(__spreadValues({}, options), {
type: "button",
customId: (0, import_node_crypto.randomUUID)()
customId: randomUUID()
});

@@ -97,3 +66,3 @@ }

// src/core/component/select-menu-component.ts
var import_node_crypto2 = __toModule(require("crypto"));
import { randomUUID as randomUUID2 } from "node:crypto";
function selectMenuComponent(_a) {

@@ -110,3 +79,3 @@ var _b = _a, {

type: "selectMenu",
customId: (0, import_node_crypto2.randomUUID)(),
customId: randomUUID2(),
options: options.map((option) => __spreadProps(__spreadValues({}, option), {

@@ -119,5 +88,5 @@ default: option.default ?? selectedOptions.has(option.value)

// src/core/gatekeeper.ts
var import_chalk3 = __toModule(require("chalk"));
var import_fast_glob = __toModule(require("fast-glob"));
var import_node_path = __toModule(require("path"));
import chalk3 from "chalk";
import glob from "fast-glob";
import { relative } from "node:path";

@@ -156,6 +125,18 @@ // src/internal/helpers.ts

// src/internal/load-file.ts
import { createRequire } from "node:module";
var require2;
async function loadFile(path) {
try {
return await import(path);
} catch {
require2 ??= createRequire(import.meta.url);
return require2(path);
}
}
// src/internal/logger.ts
var import_chalk = __toModule(require("chalk"));
import chalk from "chalk";
function createConsoleLogger(config = {}) {
const prefix = config.name ? import_chalk.default.gray`[${config.name}]` : "";
const prefix = config.name ? chalk.gray`[${config.name}]` : "";
const levels = new Set(config.levels || ["info", "success", "error", "warn"]);

@@ -165,3 +146,3 @@ const logger = {

if (levels.has("info")) {
console.info(prefix, import_chalk.default.cyan`[i]`, ...args);
console.info(prefix, chalk.cyan`[i]`, ...args);
}

@@ -171,3 +152,3 @@ },

if (levels.has("success")) {
console.info(prefix, import_chalk.default.green`[s]`, ...args);
console.info(prefix, chalk.green`[s]`, ...args);
}

@@ -177,3 +158,3 @@ },

if (levels.has("error")) {
console.error(prefix, import_chalk.default.red`[e]`, ...args);
console.error(prefix, chalk.red`[e]`, ...args);
}

@@ -183,3 +164,3 @@ },

if (levels.has("warn")) {
console.warn(prefix, import_chalk.default.yellow`[w]`, ...args);
console.warn(prefix, chalk.yellow`[w]`, ...args);
}

@@ -190,8 +171,8 @@ },

try {
logger.info(description, import_chalk.default.gray`...`);
logger.info(description, chalk.gray`...`);
const result = await promise;
logger.success(description, import_chalk.default.green`done`, import_chalk.default.gray`(${Date.now() - startTime}ms)`);
logger.success(description, chalk.green`done`, chalk.gray`(${Date.now() - startTime}ms)`);
return result;
} catch (error) {
logger.error(description, import_chalk.default.red`failed`, import_chalk.default.gray`(${Date.now() - startTime}ms)`);
logger.error(description, chalk.red`failed`, chalk.gray`(${Date.now() - startTime}ms)`);
logger.error(toError(error).stack || toError(error).message);

@@ -227,4 +208,4 @@ throw error;

// src/core/command/command.ts
var import_chalk2 = __toModule(require("chalk"));
var import_node_crypto3 = __toModule(require("crypto"));
import chalk2 from "chalk";
import { randomUUID as randomUUID3 } from "node:crypto";

@@ -291,3 +272,3 @@ // src/internal/action-queue.ts

if (component.type === "button" || component.type === "link") {
if (lastComponent?.type === "actionRow" && lastComponent.children.every((child) => child.type !== "selectMenu") && lastComponent.children.length < 5) {
if ((lastComponent == null ? void 0 : lastComponent.type) === "actionRow" && lastComponent.children.every((child) => child.type !== "selectMenu") && lastComponent.children.length < 5) {
lastComponent.children.push(component);

@@ -303,3 +284,3 @@ continue;

if (component.type === "selectMenu") {
if (lastComponent?.type === "actionRow" && lastComponent.children.length === 0) {
if ((lastComponent == null ? void 0 : lastComponent.type) === "actionRow" && lastComponent.children.length === 0) {
lastComponent.children.push(component);

@@ -322,2 +303,3 @@ continue;

function createInteractionReplyOptions(components) {
var _a, _b;
const content = components.map((component) => component.type === "text" ? component.text : void 0).filter(isNonNil).join("\n");

@@ -349,4 +331,4 @@ const embeds = components.map((component) => component.type === "embed" && component.embed).filter(isTruthy);

}
const hasComponents = options.components?.length;
const hasContent = options.content || options.embeds?.length;
const hasComponents = (_a = options.components) == null ? void 0 : _a.length;
const hasContent = options.content || ((_b = options.embeds) == null ? void 0 : _b.length);
if (hasComponents && !hasContent) {

@@ -406,2 +388,3 @@ options.content = "_ _";

async createMessage(interaction) {
var _a;
this.renderResult = flattenRenderResult(this.render());

@@ -414,3 +397,3 @@ if (this.renderResult.length === 0) {

if (interaction.deferred && interaction.ephemeral) {
this.message = await interaction.channel?.send(options);
this.message = await ((_a = interaction.channel) == null ? void 0 : _a.send(options));
return;

@@ -435,5 +418,6 @@ }

this.events.onDelete(this);
await message?.delete();
await (message == null ? void 0 : message.delete());
}
async refreshMessage() {
var _a;
if (this.isDeleted)

@@ -446,3 +430,3 @@ return;

}
await this.message?.edit(createInteractionReplyOptions(this.renderResult));
await ((_a = this.message) == null ? void 0 : _a.edit(createInteractionReplyOptions(this.renderResult)));
}

@@ -539,3 +523,3 @@ findInteractionSubject(interaction) {

onError: (actionName, error) => {
this.logger.error(`An error occurred running action`, import_chalk2.default.bold(actionName), `in command`, import_chalk2.default.bold(this.command.name));
this.logger.error(`An error occurred running action`, chalk2.bold(actionName), `in command`, chalk2.bold(this.command.name));
this.logger.error(error);

@@ -548,3 +532,3 @@ }

createReply(render, interaction) {
const id = (0, import_node_crypto3.randomUUID)();
const id = randomUUID3();
const instance = new PublicReplyInstance(render, {

@@ -561,3 +545,4 @@ onDelete: () => this.replyInstances.delete(id)

getReplyMessage(id) {
return this.replyInstances.get(id)?.getMessage();
var _a;
return (_a = this.replyInstances.get(id)) == null ? void 0 : _a.getMessage();
}

@@ -567,3 +552,6 @@ refreshReply(id) {

name: "refresh",
run: async () => this.replyInstances.get(id)?.refreshMessage()
run: async () => {
var _a;
return (_a = this.replyInstances.get(id)) == null ? void 0 : _a.refreshMessage();
}
});

@@ -574,7 +562,10 @@ }

name: "replyInstance.deleteMessage",
run: async () => this.replyInstances.get(id)?.deleteMessage()
run: async () => {
var _a;
return (_a = this.replyInstances.get(id)) == null ? void 0 : _a.deleteMessage();
}
});
}
createEphemeralReply(render, interaction) {
const id = (0, import_node_crypto3.randomUUID)();
const id = randomUUID3();
const instance = new EphemeralReplyInstance(render);

@@ -659,3 +650,3 @@ this.replyInstances.set(id, instance);

// src/core/command/slash-command.ts
var import_discord = __toModule(require("discord.js"));
import { GuildMember, User } from "discord.js";
function sortChannelTypes(arrA) {

@@ -760,3 +751,3 @@ const channelTypesOrder = [

function createResolvedMentionable(value) {
if (value instanceof import_discord.User) {
if (value instanceof User) {
return {

@@ -769,3 +760,3 @@ isUser: true,

}
if (value instanceof import_discord.GuildMember) {
if (value instanceof GuildMember) {
return {

@@ -804,2 +795,3 @@ isUser: true,

run: async (interaction, command) => {
var _a;
const isUserInteraction = interaction.isContextMenu() && interaction.targetType === "USER";

@@ -809,5 +801,5 @@ if (!isUserInteraction)

const targetUser = await interaction.client.users.fetch(interaction.targetId);
const targetGuildMember = await interaction.guild?.members.fetch({
const targetGuildMember = await ((_a = interaction.guild) == null ? void 0 : _a.members.fetch({
user: targetUser
});
}));
await config.run(__spreadProps(__spreadValues({}, createInteractionContext({ interaction, command })), {

@@ -857,3 +849,3 @@ targetUser,

client.on("ready", this.withErrorHandler(async () => {
const commandList = [...this.commands].map((command) => import_chalk3.default.bold(command.name)).join(", ");
const commandList = [...this.commands].map((command) => chalk3.bold(command.name)).join(", ");
this.logger.success(`Using commands: ${commandList}`);

@@ -890,5 +882,5 @@ for (const guild of client.guilds.cache.values()) {

async loadCommandsFromFolder(folderPath) {
const localPath = (0, import_node_path.relative)(process.cwd(), folderPath).replace(/\\/g, "/");
const localPath = relative(process.cwd(), folderPath).replace(/\\/g, "/");
await this.logger.block(`Loading commands from ${localPath}`, async () => {
const files = await (0, import_fast_glob.default)(`./**/*.{ts,tsx,js,jsx,mjs,cjs,mts,cts}`, {
const files = await glob(`./**/*.{ts,tsx,js,jsx,mjs,cjs,mts,cts}`, {
cwd: folderPath,

@@ -898,3 +890,3 @@ absolute: true

await Promise.all(files.map(async (path) => {
const mod = require(path);
const mod = await loadFile(path);
const fn = mod.default || mod;

@@ -913,3 +905,4 @@ if (typeof fn === "function")

await this.logger.block(`Syncing global commands`, async () => {
const commandManager = client.application?.commands ?? raise("No client application found");
var _a;
const commandManager = ((_a = client.application) == null ? void 0 : _a.commands) ?? raise("No client application found");
await this.syncCommands(`globally`, commandManager, await commandManager.fetch());

@@ -936,3 +929,3 @@ });

await command.register(commandManager);
this.logger.info(`Created ${scope}: ${import_chalk3.default.bold(command.name)}`);
this.logger.info(`Created ${scope}: ${chalk3.bold(command.name)}`);
}

@@ -951,2 +944,3 @@ }

async handleCommandInteraction(interaction) {
var _a, _b;
const command = [...this.commands.values()].find((command2) => command2.matchesInteraction(interaction));

@@ -960,5 +954,5 @@ if (!command)

} catch (error) {
this.logger.error(`Error running command`, import_chalk3.default.bold(command.name));
this.logger.error(`Error running command`, chalk3.bold(command.name));
this.logger.error(error);
this.config.onError?.(toError(error));
(_b = (_a = this.config).onError) == null ? void 0 : _b.call(_a, toError(error));
}

@@ -974,2 +968,3 @@ }

return async (...args) => {
var _a, _b;
try {

@@ -979,3 +974,3 @@ return await fn(...args);

this.logger.error("An error occurred:", error);
this.config.onError?.(toError(error));
(_b = (_a = this.config).onError) == null ? void 0 : _b.call(_a, toError(error));
}

@@ -994,4 +989,3 @@ };

}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
export {
Gatekeeper,

@@ -1003,2 +997,3 @@ actionRowComponent,

selectMenuComponent
});
};
//# sourceMappingURL=main.js.map

@@ -5,8 +5,9 @@ {

"author": "itsmapleleaf",
"version": "0.8.0",
"version": "0.8.1-0",
"types": "./dist/main.d.ts",
"type": "module",
"exports": {
".": {
"import": "./dist/main.mjs",
"require": "./dist/main.js"
"import": "./dist/main.js",
"require": "./dist/main.cjs"
}

@@ -42,4 +43,4 @@ },

"typecheck": "tsc --noEmit",
"test": "jest --colors",
"test-watch": "jest --watch",
"test": "ava",
"test-watch": "pnpm test -- --watch",
"lint": "eslint --ext js,ts,tsx .",

@@ -54,4 +55,3 @@ "lint-fix": "npm run lint -- --fix",

"chalk": "^4.1.2",
"fast-glob": "^3.2.7",
"tslib": "^2.3.1"
"fast-glob": "^3.2.7"
},

@@ -62,39 +62,22 @@ "peerDependencies": {

"devDependencies": {
"@babel/core": "7.15.8",
"@babel/preset-typescript": "7.15.0",
"@itsmapleleaf/configs": "1.0.0",
"@rollup/plugin-replace": "3.0.0",
"@types/jest": "27.0.2",
"@types/node": "16.11.0",
"@typescript-eslint/eslint-plugin": "5.0.0",
"@typescript-eslint/parser": "5.0.0",
"cpy-cli": "3.1.1",
"discord.js": "^13.2.0",
"esbuild": "0.13.7",
"esbuild-jest": "0.5.0",
"eslint": "8.0.1",
"@itsmapleleaf/configs": "1.0.1",
"@types/node": "16.11.10",
"@typescript-eslint/eslint-plugin": "5.4.0",
"@typescript-eslint/parser": "5.4.0",
"ava": "^4.0.0-rc.1",
"discord.js": "^13.3.1",
"esbuild": "0.14.0",
"esbuild-node-loader": "^0.6.3",
"eslint": "8.3.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-react": "7.26.1",
"eslint-plugin-react-hooks": "4.2.0",
"jest": "27.2.5",
"jest-mock-console": "1.2.3",
"eslint-plugin-jsx-a11y": "6.5.1",
"eslint-plugin-react": "7.27.1",
"eslint-plugin-react-hooks": "4.3.0",
"npm-run-all": "4.1.5",
"prettier": "2.4.1",
"release-it": "14.11.6",
"prettier": "2.5.0",
"release-it": "14.11.8",
"tsup": "^5.10.0",
"typedoc": "0.22.5",
"typescript": "4.4.4"
"typedoc": "0.22.10",
"typescript": "4.5.2"
},
"tsup": {
"entryPoints": [
"src/main.ts"
],
"target": "node16",
"format": [
"cjs",
"esm"
],
"dts": true
},
"prettier": "@itsmapleleaf/configs/prettier",

@@ -104,23 +87,15 @@ "eslintConfig": {

"./node_modules/@itsmapleleaf/configs/eslint"
],
"ignorePatterns": [
"**/node_modules/**",
"**/dist/**",
"**/docs/**"
]
},
"jest": {
"transform": {
"^.+\\.tsx?$": [
"esbuild-jest",
{
"sourcemap": true
}
]
"ava": {
"files": [
"tests/**/*.test.ts"
],
"extensions": {
"ts": "module"
},
"verbose": true
},
"babel": {
"presets": [
"@babel/preset-typescript"
"nodeArguments": [
"--loader=esbuild-node-loader",
"--experimental-specifier-resolution=node",
"--no-warnings"
]

@@ -127,0 +102,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc