remove barrel for core/structs

This commit is contained in:
jacob
2024-04-30 20:23:17 -05:00
parent 5b33a9d1bb
commit d6eedb1b4d
16 changed files with 32 additions and 25 deletions

View File

@@ -13,9 +13,14 @@ import {
type _Module,
} from './core/_internal';
import { createInteractionHandler, executeModule, makeModuleExecutor } from './handlers/event-utils';
import type { Emitter } from './core/interfaces'
import type { Emitter, ErrorHandling, Logging } from './core/interfaces'
import { Services } from './core/ioc/dependency-injection';
export function interactionHandler(client: Emitter, emitter: Emitter, modules: Map<string, _Module>) {
export function interactionHandler(client: Emitter,
emitter: Emitter,
log: Logging,
err: ErrorHandling,
modules: Map<string, _Module>) {
const interactionStream$ = sharedEventStream<Interaction>(client, 'interactionCreate');
const handle = createInteractionHandler(interactionStream$, modules);
@@ -29,3 +34,9 @@ export function interactionHandler(client: Emitter, emitter: Emitter, modules: M
emitter.emit('module.activate', resultPayload(PayloadType.Failure, module, SernError.PluginFailure)))),
mergeMap(payload => executeModule(emitter, log, err, payload)));
}
export const __dependencies = () =>
Services('@sern/emitter',
'@sern/errors',
'@sern/logger',
'@sern/client');

View File

@@ -5,7 +5,6 @@ export * from './operators';
export * as Files from './module-loading';
export * from './functions';
export { SernError } from './structures/enums';
export { __Services } from './structures';
export { useContainerRaw } from './ioc/base';
export type _Module = {

View File

@@ -1,4 +1,4 @@
import { CommandType, EventType, PluginType } from './structures';
import { CommandType, EventType, PluginType } from './structures/enums';
import type { Plugin, PluginResult, EventArgs, CommandArgs } from '../types/core-plugin';
import type { ClientEvents } from 'discord.js';
import { err, ok } from './functions';

View File

@@ -11,7 +11,7 @@ import type {
AutocompleteInteraction
} from 'discord.js';
import { ApplicationCommandOptionType, InteractionType } from 'discord.js';
import { PayloadType, PluginType } from './structures';
import { PayloadType, PluginType } from './structures/enums';
import assert from 'assert';
import type { Payload } from '../types/utility';

View File

@@ -1,5 +1,5 @@
import { ApplicationCommandType, ComponentType, Interaction, InteractionType } from 'discord.js';
import { CommandType, EventType } from './structures';
import { CommandType, EventType } from './structures/enums';
/**
* Construct unique ID for a given interaction object.

View File

@@ -2,7 +2,7 @@ import * as assert from 'assert';
import type { CoreDependencies, DependencyConfiguration } from '../../types/ioc';
import { CoreContainer } from './container';
import { Result } from 'ts-results-es';
import { __Services } from '../_internal';
import * as __Services from '../structures/default-services';
import { AnyFunction } from '../../types/utility';
import type { Logging } from '../interfaces';
import type { UnpackFunction } from 'iti';

View File

@@ -2,7 +2,7 @@ import { Container } from 'iti';
import type { Disposable } from '../interfaces';
import * as assert from 'node:assert';
import { Subject } from 'rxjs';
import { __Services } from '../_internal';
import * as __Services from '../structures/default-services';
import * as Hooks from './hooks';
import { EventEmitter } from 'node:events';

View File

@@ -1,15 +1,16 @@
import { ClientEvents } from 'discord.js';
import { EventType } from '../core/structures';
import type { ClientEvents } from 'discord.js';
import { EventType } from '../core/structures/enums';
import type { AnyEventPlugin, } from '../types/core-plugin';
import type {
InputCommand,
InputEvent,
} from '../types/core-modules';
import { _Module, partitionPlugins } from './_internal';
import { type _Module, partitionPlugins } from './_internal';
import type { Awaitable } from '../types/utility';
import callsites from 'callsites';
import * as Files from './module-loading'
import * as Id from './id'
/**
* @since 1.0.0 The wrapper function to define command modules for sern
* @param mod
@@ -40,7 +41,6 @@ export function commandModule(mod: InputCommand): _Module {
export function eventModule(mod: InputEvent): _Module {
const [onEvent, plugins] = partitionPlugins(mod.plugins);
const initCallsite = callsites()[1].getFileName();
console.log(initCallsite);
if(!initCallsite) throw Error("initCallsite is null");
const { name, absPath } = Files.parseCallsite(initCallsite);
mod.name ??= name;

View File

@@ -26,7 +26,7 @@ import type { VoidResult } from './_internal';
* @param item
*/
export function filterMapTo<V>(item: () => V): OperatorFunction<boolean, V> {
return concatMap(shouldKeep => (shouldKeep ? of(item()) : EMPTY));
return concatMap(keep => keep ? of(item()) : EMPTY);
}
interface PluginExecutable {

View File

@@ -46,8 +46,7 @@ export const Presence = {
},
/**
* @example
* Presence
* .of({
* Presence.of({
* activities: [
* { name: "Chilling out" }
* ]

View File

@@ -1,4 +0,0 @@
export { CommandType, PluginType, PayloadType, EventType } from './enums';
export * from './context';
export * as __Services from './default-services';

View File

@@ -35,7 +35,8 @@ import type { ControlPlugin } from '../types/core-plugin';
import type { AnyModule, CommandMeta, CommandModule, Module, Processed } from '../types/core-modules';
import { EventEmitter } from 'node:events';
import * as assert from 'node:assert';
import { CommandType, Context } from '../core/structures';
import { Context } from '../core/structures/context';
import { CommandType } from '../core/structures/enums'
import type { Args } from '../types/utility';
import { inspect } from 'node:util'
import { disposeAll } from '../core/ioc/base';

View File

@@ -15,8 +15,7 @@ function isNonBot(prefix: string) {
function hasPrefix(prefix: string, content: string) {
const prefixInContent = content.slice(0, prefix.length);
return (
prefixInContent.localeCompare(prefix, undefined, {
return (prefixInContent.localeCompare(prefix, undefined, {
sensitivity: 'accent',
}) === 0
);

View File

@@ -1,5 +1,5 @@
import { ObservableInput } from 'rxjs';
import { EventType } from '../core/structures';
import { EventType } from '../core/structures/enums';
import { SernError } from '../core/_internal';
import { eventDispatcher } from './event-utils'
import { Service } from '../core/ioc';

View File

@@ -53,5 +53,6 @@ export {
export * from './core/presences'
export * from './core/interfaces'
export * from './core/create-plugins';
export * from './core/structures';
export { CommandType, PluginType, PayloadType, EventType } from './core/structures/enums';
export { Context } from './core/structures/context';
export * from './core/ioc';

View File

@@ -15,7 +15,8 @@ import type {
UserContextMenuCommandInteraction,
UserSelectMenuInteraction,
} from 'discord.js';
import type { CommandType, Context, EventType } from '../core/structures';
import type { CommandType, EventType } from '../core/structures/enums';
import { Context } from '../core/structures/context'
import { AnyCommandPlugin, AnyEventPlugin, ControlPlugin, InitPlugin } from './core-plugin';
import { Awaitable, Args, SlashOptions, SernEventsMapping } from './utility';