Skip to content

Commit

Permalink
refactor: rename Piece.Context to Piece.LoaderContext (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranet authored Nov 16, 2023
1 parent 3c722ef commit f5bb225
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/lib/structures/AliasPiece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class AliasPiece<Options extends AliasPieceOptions = AliasPieceOptions, S
*/
public aliases: readonly string[];

public constructor(context: AliasPiece.Context, options: AliasPieceOptions = {}) {
public constructor(context: AliasPiece.LoaderContext<StoreName>, options: AliasPieceOptions = {}) {
super(context, options);
this.aliases = options.aliases ?? [];
}
Expand All @@ -48,7 +48,9 @@ export interface AliasPieceJSON extends Piece.JSON {
export namespace AliasPiece {
export const { Location } = Piece;
export type Options = AliasPieceOptions;
export type Context<StoreName extends StoreRegistryKey = StoreRegistryKey> = Piece.Context<StoreName>;
/** @deprecated Use {@linkcode LoaderContext} instead. */
export type Context<StoreName extends StoreRegistryKey = StoreRegistryKey> = Piece.LoaderContext<StoreName>;
export type LoaderContext<StoreName extends StoreRegistryKey = StoreRegistryKey> = Piece.LoaderContext<StoreName>;
export type JSON = AliasPieceJSON;
export type LocationJSON = Piece.LocationJSON;
}
13 changes: 9 additions & 4 deletions src/lib/structures/Piece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import type { StoreOf, StoreRegistryKey } from './StoreRegistry';
* The context for the piece, contains extra information from the store,
* the piece's path, and the store that loaded it.
*/
export interface PieceContext<StoreName extends StoreRegistryKey = StoreRegistryKey> {
export interface LoaderPieceContext<StoreName extends StoreRegistryKey = StoreRegistryKey> {
/**
* The root directory the piece was loaded from.
*/
readonly root: string;

/**
* The path the module was loaded from, relative to {@link PieceContext.root}.
* The path the module was loaded from, relative to {@link LoaderPieceContext.root}.
*/
readonly path: string;

Expand All @@ -30,6 +30,9 @@ export interface PieceContext<StoreName extends StoreRegistryKey = StoreRegistry
readonly store: StoreOf<StoreName>;
}

/** @deprecated Use {@linkcode LoaderPieceContext} instead. */
export interface PieceContext<StoreName extends StoreRegistryKey = StoreRegistryKey> extends LoaderPieceContext<StoreName> {}

/**
* The options for the {@link Piece}.
*/
Expand Down Expand Up @@ -76,7 +79,7 @@ export class Piece<Options extends PieceOptions = PieceOptions, StoreName extend
*/
public readonly options: Options;

public constructor(context: PieceContext<StoreName>, options: PieceOptions = {}) {
public constructor(context: Piece.LoaderContext<StoreName>, options: PieceOptions = {}) {
this.store = context.store;
this.location = new PieceLocation(context.path, context.root);
this.name = options.name ?? context.name;
Expand Down Expand Up @@ -149,7 +152,9 @@ export interface PieceJSON {
export namespace Piece {
export const Location = PieceLocation;
export type Options = PieceOptions;
export type Context<StoreName extends StoreRegistryKey = StoreRegistryKey> = PieceContext<StoreName>;
/** @deprecated Use {@linkcode LoaderContext} instead. */
export type Context<StoreName extends StoreRegistryKey = StoreRegistryKey> = LoaderPieceContext<StoreName>;
export type LoaderContext<StoreName extends StoreRegistryKey = StoreRegistryKey> = LoaderPieceContext<StoreName>;
export type JSON = PieceJSON;
export type LocationJSON = PieceLocationJSON;
}

0 comments on commit f5bb225

Please sign in to comment.