diff --git a/package.json b/package.json index f127ac6..a999f1e 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,10 @@ } }, "scripts": { - "watch": "tsup --watch", + "watch": "tsc --watch", "lint": "eslint src/**/*.ts", "format": "eslint src/**/*.ts --fix", - "build:dev": "tsup --metafile", + "build:dev": "tsc", "build:prod": "tsc", "prepare": "tsc", "pretty": "prettier --write .", diff --git a/src/_internal.ts b/src/_internal.ts index 94cb21c..7749ac3 100644 --- a/src/_internal.ts +++ b/src/_internal.ts @@ -10,25 +10,22 @@ import { SernError, filterTap, resultPayload, + type _Module, } from './core/_internal'; import { createInteractionHandler, executeModule, makeModuleExecutor } from './handlers/event-utils'; -import type { DependencyList } from './types/ioc'; +import type { Emitter } from './core/interfaces' - -export function interactionHandler([emitter, err, log, modules, client]: DependencyList) { +export function interactionHandler(client: Emitter, emitter: Emitter, modules: Map) { const interactionStream$ = sharedEventStream(client, 'interactionCreate'); const handle = createInteractionHandler(interactionStream$, modules); - const interactionHandler$ = merge( - handle(isMessageComponent), - handle(isAutocomplete), - handle(isCommand), - handle(isModal), - ); + const interactionHandler$ = merge(handle(isMessageComponent), + handle(isAutocomplete), + handle(isCommand), + handle(isModal)); return interactionHandler$ - .pipe( - filterTap(e => emitter.emit('warning', resultPayload(PayloadType.Warning, undefined, e))), - concatMap(makeModuleExecutor(module => + .pipe(filterTap(e => emitter.emit('warning', resultPayload(PayloadType.Warning, undefined, e))), + concatMap(makeModuleExecutor(module => emitter.emit('module.activate', resultPayload(PayloadType.Failure, module, SernError.PluginFailure)))), - mergeMap(payload => executeModule(emitter, log, err, payload))); + mergeMap(payload => executeModule(emitter, log, err, payload))); } diff --git a/src/core/ioc/base.ts b/src/core/ioc/base.ts index 2f3d90b..296f3f0 100644 --- a/src/core/ioc/base.ts +++ b/src/core/ioc/base.ts @@ -140,8 +140,7 @@ function composeRoot( container.ready(); } -export async function makeDependencies -(conf: ValidDependencyConfig) { +export async function makeDependencies (conf: ValidDependencyConfig) { containerSubject = new CoreContainer(); if(typeof conf === 'function') { const excluded: string[] = []; diff --git a/src/handlers/dispatchers.ts b/src/handlers/dispatchers.ts deleted file mode 100644 index 8b13789..0000000 --- a/src/handlers/dispatchers.ts +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/handlers/event-utils.ts b/src/handlers/event-utils.ts index cc8e72b..3fe3645 100644 --- a/src/handlers/event-utils.ts +++ b/src/handlers/event-utils.ts @@ -25,6 +25,7 @@ import { arrayifySource, isAutocomplete, treeSearch, + _Module, } from '../core/_internal'; import type { Emitter, ErrorHandling, Logging } from '../core/interfaces'; import { PayloadType } from '../core/structures/enums' @@ -77,10 +78,7 @@ export function eventDispatcher(module: Processed, source: unknown) { execute); } -export function createDispatcher(payload: { - module: Processed; - event: BaseInteraction; -}) { +export function createDispatcher(payload: { module: Processed; event: BaseInteraction; }) { assert.ok(CommandType.Text !== payload.module.type, SernError.MismatchEvent + 'Found text command in interaction stream'); switch (payload.module.type) { @@ -135,7 +133,7 @@ export function fmt(msg: string, prefix: string): string[] { */ export function createInteractionHandler( source: Observable, - mg: any, //TODO + mg: Map, //TODO ) { return createGenericHandler, void>>( source, @@ -143,12 +141,13 @@ export function createInteractionHandler( const possibleIds = Id.reconstruct(event); let fullPaths= possibleIds .map(id => mg.get(id)) - .filter((id): id is Module => id !== undefined); + .filter((id): id is _Module => id !== undefined); if(fullPaths.length == 0) { return Err.EMPTY; } const [ path ] = fullPaths; + //@ts-ignore TODO fixme return Ok(createDispatcher({ module: path as Processed, event })); }); } diff --git a/src/index.ts b/src/index.ts index a391ac5..d7d43fc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ export * as Sern from './sern'; + export type { CommandModule, EventModule,