chore(vendor): import pi 1.3.0
Imported as a linear vendor commit so forge rebases do not replay the upstream root tree. git-subtree-dir: third_party/pi git-subtree-split: 71023aec1546d6d677a65669c5665c0927ce0dd0
This commit is contained in:
1 parent
719370c8f7
commit
6081e3e325
1743 files changed
+205459
-131704
No files matched your search
+30
@@ -0,0 +1,30 @@
|
||||
import type { Ctx } from "./types.ts";
|
||||
|
||||
export interface Registry<V> {
|
||||
readonly name: string;
|
||||
readonly conflict: "error" | "last";
|
||||
/** Type carrier only; never set. */
|
||||
readonly value?: V;
|
||||
}
|
||||
|
||||
/** `conflict: "error"` rejects two objects registering one key; `"last"` keeps the later registration. */
|
||||
export const defineRegistry = <V>(name: string, options: { conflict?: "error" | "last" } = {}): Registry<V> => ({
|
||||
name,
|
||||
conflict: options.conflict ?? "error",
|
||||
});
|
||||
|
||||
export type RegistryTable<V> = ReadonlyMap<string, V>;
|
||||
|
||||
export interface RegistryView<V> {
|
||||
/** Table of `ctx.codeVersion`, or of the current code version without ctx. */
|
||||
table(ctx?: Ctx): RegistryTable<V>;
|
||||
get(key: string, ctx?: Ctx): V | undefined;
|
||||
/** Called with the current table immediately and whenever a new table is installed. */
|
||||
subscribe(listener: (table: RegistryTable<V>, codeVersion: number) => void): () => void;
|
||||
}
|
||||
|
||||
export interface Registration {
|
||||
readonly registry: Registry<unknown>;
|
||||
readonly key: string;
|
||||
readonly value: unknown;
|
||||
}
|
||||
Reference in new issue
Block a user