@rhythmjs/rhythm 0.0.17 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mount.d.ts +3 -2
- package/dist/rhythm.d.ts +2 -1
- package/dist/types.d.ts +9 -0
- package/package.json +1 -1
package/dist/mount.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type { Middleware, Mountable } from "./types";
|
|
2
|
-
export declare function mount<
|
|
1
|
+
import type { Middleware, MountMiddleware, Mountable } from "./types";
|
|
2
|
+
export declare function mount<I extends object>(plugin: Mountable<I>): MountMiddleware<I>;
|
|
3
|
+
export declare function mount<T extends object = {}, I extends object = any>(plugin: Mountable<I> & (T extends I ? unknown : never), condition: (ctx: T) => boolean): Middleware<T>;
|
package/dist/rhythm.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Pipeline } from "./pipeline";
|
|
2
|
-
import type { CleanupCallback, ExtensionMiddleware, ExtensionRegister, Middleware, PipelineOptions, RegisterCallback, RhythmHandler } from "./types";
|
|
2
|
+
import type { CleanupCallback, ExtensionMiddleware, ExtensionRegister, Middleware, MountMiddleware, PipelineOptions, RegisterCallback, RhythmHandler, WidenInput } from "./types";
|
|
3
3
|
export { compose } from "./compose";
|
|
4
4
|
export { decorate } from "./decorate";
|
|
5
5
|
export { derive } from "./derive";
|
|
@@ -18,6 +18,7 @@ export declare class Rhythm<S extends object = {}, I extends object = {}, D exte
|
|
|
18
18
|
stop(): Promise<void>;
|
|
19
19
|
[Symbol.asyncDispose](): Promise<void>;
|
|
20
20
|
use<U extends object>(middleware: ExtensionMiddleware<S & I & D, U>): Rhythm<S, I, D & U>;
|
|
21
|
+
use<X extends object>(middleware: MountMiddleware<X>): Rhythm<S, WidenInput<S & I & D, I, X>, D>;
|
|
21
22
|
use(middleware: Middleware<S & I & D>): this;
|
|
22
23
|
callback(): RhythmHandler<I, S & I & D>;
|
|
23
24
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -5,6 +5,15 @@ declare const extension: unique symbol;
|
|
|
5
5
|
export type Extension<U extends object> = {
|
|
6
6
|
[extension]: U;
|
|
7
7
|
};
|
|
8
|
+
declare const input: unique symbol;
|
|
9
|
+
export type Input<I extends object> = {
|
|
10
|
+
[input]: I;
|
|
11
|
+
};
|
|
12
|
+
export type MountMiddleware<I extends object> = Middleware<any> & Input<I>;
|
|
13
|
+
export type Unsupplied<Ctx extends object, X extends object> = {
|
|
14
|
+
[K in keyof X as K extends keyof Ctx ? (Ctx[K] extends X[K] ? never : K) : K]: X[K];
|
|
15
|
+
};
|
|
16
|
+
export type WidenInput<Ctx extends object, I extends object, X extends object> = I & Unsupplied<Ctx, X>;
|
|
8
17
|
export type ExtensionMiddleware<T extends object, U extends object> = Middleware<T> & Extension<U>;
|
|
9
18
|
export type RegisterCallback<T extends object> = (ctx: T, app: Rhythm<T, any, any>) => unknown;
|
|
10
19
|
export type CleanupCallback<T extends object> = (ctx: T, app: Rhythm<T, any, any>) => unknown;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhythmjs/rhythm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "A minimal, type-safe middleware and startup-composition kernel: register() at startup, use() per request, with derive, decorate, mount and include.",
|
|
5
5
|
"homepage": "https://rhythm.js.org/rhythm",
|
|
6
6
|
"license": "ISC",
|