@sf-kmods/kdataforgejs 2026.4.23 → 2026.4.28
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/index.d.ts +96 -10
- package/lib/kdfjs-es2020.d.ts +3 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
declare module "@sf-kmods/kdataforgejs" {
|
|
4
4
|
/** Capability ids for `defineMeta`. Reading and writing reflected values is always granted. */
|
|
5
5
|
export interface CapabilityMap {
|
|
6
|
+
readonly "kdf.schematics.read": true;
|
|
7
|
+
readonly "kdf.overrides.temporary": true;
|
|
8
|
+
readonly "kdf.files.write": true;
|
|
9
|
+
readonly "kdf.datatables.write": true;
|
|
10
|
+
readonly "kdf.datatables.read": true;
|
|
6
11
|
readonly "kdf.behavior.runtime": true;
|
|
7
12
|
readonly "kdf.classes.define": true;
|
|
8
13
|
readonly "kdf.config.read": true;
|
|
@@ -575,10 +580,10 @@ declare module "@sf-kmods/kdataforgejs" {
|
|
|
575
580
|
readonly now: () => number;
|
|
576
581
|
readonly random: (seed: string) => SeededRandom;
|
|
577
582
|
readonly defineEvent: <const S extends EventSchema>(id: string, schema: S) => CustomEvent<S>;
|
|
578
|
-
readonly onCustom: <S extends EventSchema>(event: CustomEvent<S>, key: string, callback: (payload: EventPayload<NoInfer<S>>) => void) => Subscription;
|
|
583
|
+
readonly onCustom: <S extends EventSchema>(event: CustomEvent<S>, key: string, callback: (payload: EventPayload<NoInfer<S>>) => void, options?: EventOptions<EventPayload<NoInfer<S>>>) => Subscription;
|
|
579
584
|
readonly emit: <S extends EventSchema>(event: CustomEvent<S>, payload: EventPayload<NoInfer<S>>) => void;
|
|
580
585
|
/** Atomic, bounded property transaction. Tracked refs and function calls are rejected. */
|
|
581
|
-
readonly batch: <T extends readonly
|
|
586
|
+
readonly batch: <T extends readonly unknown[]>(writes: {
|
|
582
587
|
readonly [K in keyof T]: { readonly property: WritableValueRef<T[K]>; readonly value: NoInfer<T[K]> };
|
|
583
588
|
}) => void;
|
|
584
589
|
readonly lookupItem: (id: string, pack?: string) => Class<UObject> | null;
|
|
@@ -645,24 +650,24 @@ declare module "@sf-kmods/kdataforgejs" {
|
|
|
645
650
|
readonly on: {
|
|
646
651
|
(target: Target, eventId: string, callback: PositionalEventCallback): Subscription;
|
|
647
652
|
(target: Target, eventId: string, callback: NamedEventCallback): Subscription;
|
|
648
|
-
<K extends string>(target: Target, eventId: string, key: K, callback: PositionalEventCallback): Subscription;
|
|
649
|
-
<K extends string>(target: Target, eventId: string, key: K, callback: NamedEventCallback): Subscription;
|
|
650
|
-
<K extends string, TKey extends string>(eventId: K, key: TKey, callback: PositionalEventCallback | NamedEventCallback): Subscription;
|
|
653
|
+
<K extends string>(target: Target, eventId: string, key: K, callback: PositionalEventCallback, options?: EventOptions): Subscription;
|
|
654
|
+
<K extends string>(target: Target, eventId: string, key: K, callback: NamedEventCallback, options?: EventOptions): Subscription;
|
|
655
|
+
<K extends string, TKey extends string>(eventId: K, key: TKey, callback: PositionalEventCallback | NamedEventCallback, options?: EventOptions): Subscription;
|
|
651
656
|
};
|
|
652
657
|
readonly off: (subscription: Subscription) => void;
|
|
653
658
|
readonly unregisterEvent: (key: string) => void;
|
|
654
659
|
readonly hook: {
|
|
655
|
-
<T extends UObject, A extends readonly Value[], R>(target: Class<T>, hook: Hook<T, A, R>, callback: (call: HookCall<T, A, R>) => void): Subscription;
|
|
656
|
-
<T extends UObject, A extends readonly Value[], R>(target: Class<T>, hook: Hook<T, A, R>, phase: "before" | "after", callback: (call: HookCall<T, A, R>) => void): Subscription;
|
|
660
|
+
<T extends UObject, A extends readonly Value[], R>(target: Class<T>, hook: Hook<T, A, R>, callback: (call: HookCall<T, A, R>) => void, options?: HookOptions<A>): Subscription;
|
|
661
|
+
<T extends UObject, A extends readonly Value[], R>(target: Class<T>, hook: Hook<T, A, R>, phase: "before" | "after", callback: (call: HookCall<T, A, R>) => void, options?: HookOptions<A>): Subscription;
|
|
657
662
|
<T extends UObject, A extends readonly Value[], R>(target: Class<T>, hook: Hook<T, A, R>, phase: "replace", callback: (call: HookCall<T, A, R>) => R | void): Subscription;
|
|
658
663
|
};
|
|
659
664
|
readonly unhook: (subscription: Subscription) => void;
|
|
660
665
|
readonly onTyped: {
|
|
661
666
|
(target: Target, eventId: string, callback: PositionalEventCallback): Subscription;
|
|
662
667
|
(target: Target, eventId: string, callback: NamedEventCallback): Subscription;
|
|
663
|
-
<K extends string>(target: Target, eventId: string, key: K, callback: PositionalEventCallback): Subscription;
|
|
664
|
-
<K extends string>(target: Target, eventId: string, key: K, callback: NamedEventCallback): Subscription;
|
|
665
|
-
<K extends string, TKey extends string>(eventId: K, key: TKey, callback: PositionalEventCallback | NamedEventCallback): Subscription;
|
|
668
|
+
<K extends string>(target: Target, eventId: string, key: K, callback: PositionalEventCallback, options?: EventOptions): Subscription;
|
|
669
|
+
<K extends string>(target: Target, eventId: string, key: K, callback: NamedEventCallback, options?: EventOptions): Subscription;
|
|
670
|
+
<K extends string, TKey extends string>(eventId: K, key: TKey, callback: PositionalEventCallback | NamedEventCallback, options?: EventOptions): Subscription;
|
|
666
671
|
};
|
|
667
672
|
readonly spawnActor: <K extends ActorClassKey>(classDescriptorId: K, initialWrites?: ActorInitialWrites<K>) => CatalogActor<K>;
|
|
668
673
|
/** Explicit untyped escape hatch for tools operating on runtime-discovered catalogs. */
|
|
@@ -692,3 +697,84 @@ declare module "@sf-kmods/kdataforgejs" {
|
|
|
692
697
|
readonly dispose: () => void;
|
|
693
698
|
}
|
|
694
699
|
}
|
|
700
|
+
|
|
701
|
+
/** ABI 13 / declaration format 10 authoring extensions. Native limits and phase checks apply at every use. */
|
|
702
|
+
declare module "@sf-kmods/kdataforgejs" {
|
|
703
|
+
export type Delivery = { readonly mode: "immediate" } | { readonly mode: "debounce" | "throttle"; readonly seconds: number };
|
|
704
|
+
export interface EventOptions<P = Readonly<Record<string, Value>>> {
|
|
705
|
+
readonly priority?: number;
|
|
706
|
+
readonly once?: boolean;
|
|
707
|
+
readonly filter?: Partial<P>;
|
|
708
|
+
readonly delivery?: Delivery;
|
|
709
|
+
}
|
|
710
|
+
export type HookFilter<A extends readonly Value[]> = { readonly [I in Extract<keyof A, `${number}`>]?: A[I] };
|
|
711
|
+
export interface HookOptions<A extends readonly Value[]> { readonly priority?: number; readonly once?: boolean; readonly filter?: HookFilter<A>; }
|
|
712
|
+
export interface HookObservation<A extends readonly Value[], R> { readonly args: A; readonly returnValue?: R; }
|
|
713
|
+
export interface SpatialQuery {
|
|
714
|
+
readonly limit?: number;
|
|
715
|
+
readonly tags?: readonly string[];
|
|
716
|
+
readonly sphere?: { readonly center: readonly [number, number, number]; readonly radius: number };
|
|
717
|
+
readonly box?: { readonly min: readonly [number, number, number]; readonly max: readonly [number, number, number] };
|
|
718
|
+
}
|
|
719
|
+
/** A next/close call invalidates this cursor's preceding page handles. Eight cursors, 30-second idle expiry. */
|
|
720
|
+
export interface ActorCursor<T extends UObject> {
|
|
721
|
+
next(): { readonly items: readonly T[]; readonly visited: number; readonly done: boolean };
|
|
722
|
+
close(): void;
|
|
723
|
+
}
|
|
724
|
+
export interface WorldAccess {
|
|
725
|
+
findActors<C extends Class<UObject>>(type: C, query: SpatialQuery): WorldQueryResult<ClassValue<C>>;
|
|
726
|
+
openQuery<C extends Class<UObject>>(type: C, query?: SpatialQuery): ActorCursor<ClassValue<C>>;
|
|
727
|
+
}
|
|
728
|
+
export interface ContentGraphResult<T extends UObject> extends WorldQueryResult<T> { readonly coverage: "loadedAuthorized"; }
|
|
729
|
+
export interface ContentGraph {
|
|
730
|
+
recipes<C extends Class<UObject>>(type: C, filter?: { readonly ingredient?: Class<UObject>; readonly product?: Class<UObject>; readonly producedIn?: Class<UObject> }, limit?: number): ContentGraphResult<ClassValue<C>>;
|
|
731
|
+
schematicsUnlocking<C extends Class<UObject>>(type: C, recipe: Class<UObject>, limit?: number): ContentGraphResult<ClassValue<C>>;
|
|
732
|
+
}
|
|
733
|
+
const rowSchemaBrand: unique symbol;
|
|
734
|
+
export interface StructType<T> { readonly [rowSchemaBrand]: (value: T) => T; }
|
|
735
|
+
export interface DataTable<T> { get(rowName: string): T | null; set(rowName: string, value: NoInfer<T>): void; }
|
|
736
|
+
const valuePropertiesBrand: unique symbol;
|
|
737
|
+
export interface ValuePropertyTag<T> { readonly [valuePropertiesBrand]: T; }
|
|
738
|
+
export type ValueProperties<T> = T extends ValuePropertyTag<infer P> ? P : { readonly [K in keyof T as T[K] extends ReadonlyValueRef<unknown> ? K : never]: T[K] };
|
|
739
|
+
/** Explicit initialization-only scalar CDO sets. No selectors, insertion, generation or registration. */
|
|
740
|
+
export interface ReversibleCdoDocument {
|
|
741
|
+
readonly type: "cdo";
|
|
742
|
+
readonly patches: readonly { readonly target: string; readonly properties: readonly { readonly path: string; readonly op?: "set"; readonly value: Exclude<InputValue, null | undefined> }[] }[];
|
|
743
|
+
}
|
|
744
|
+
export interface LifecyclePayloads {
|
|
745
|
+
readonly worldReady: { readonly worldGeneration: bigint };
|
|
746
|
+
readonly travel: { readonly worldGeneration: bigint };
|
|
747
|
+
readonly shutdown: { readonly worldGeneration: bigint; readonly reason: "shutdown" };
|
|
748
|
+
}
|
|
749
|
+
export interface TemporaryOverride extends Subscription { restore(): void; }
|
|
750
|
+
export interface Context {
|
|
751
|
+
readonly hookOnce: {
|
|
752
|
+
<T extends UObject, A extends readonly Value[], R>(target: Class<T>, hook: Hook<T,A,R>, callback: (call: HookCall<T,A,R>) => void, options?: Omit<HookOptions<A>,"once">): Subscription;
|
|
753
|
+
<T extends UObject, A extends readonly Value[], R>(target: Class<T>, hook: Hook<T,A,R>, phase: "before" | "after", callback: (call: HookCall<T,A,R>) => void, options?: Omit<HookOptions<A>,"once">): Subscription;
|
|
754
|
+
};
|
|
755
|
+
readonly observeHook: <T extends UObject, A extends readonly Value[], R>(target: Class<T>, hook: Hook<T,A,R>, key: string, callback: (call: HookObservation<A,R>) => void, options?: HookOptions<A> & { readonly delivery?: Delivery }) => Subscription;
|
|
756
|
+
readonly lifecycle: { on<K extends keyof LifecyclePayloads>(event: K, key: string, callback: (event: LifecyclePayloads[K]) => void): Subscription };
|
|
757
|
+
readonly applyDocuments: (documents: readonly ReversibleCdoDocument[]) => void;
|
|
758
|
+
readonly dataTables: { open<T>(table: UObject, rowType: StructType<T>): DataTable<T> };
|
|
759
|
+
readonly values: <T extends UObject>(object: T) => ValueProperties<T>;
|
|
760
|
+
readonly graph: ContentGraph;
|
|
761
|
+
/** Scalar actor properties only; 0.001..3600 seconds. Later KDF writes supersede restoration. */
|
|
762
|
+
readonly overrideFor: <T extends Value>(property: WritableValueRef<T>, value: NoInfer<T>, seconds: number) => TemporaryOverride;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
/** Bounded YAML/JSON data; both codecs preserve quoted strings and decode unquoted booleans/numbers. */
|
|
766
|
+
type KDFFileData = null | boolean | number | string | readonly KDFFileData[] | { readonly [key: string]: KDFFileData };
|
|
767
|
+
declare const YML: Readonly<{ parse(text: string): KDFFileData; stringify(value: KDFFileData): string }>;
|
|
768
|
+
/** Server runtime only. Compiler requires direct static string literal. Reads sandbox override, otherwise immutable attested pack input. */
|
|
769
|
+
declare class YMLFile {
|
|
770
|
+
constructor(path: string);
|
|
771
|
+
json(): Promise<KDFFileData>;
|
|
772
|
+
/** Server runtime only, requires kdf.files.write. */
|
|
773
|
+
save(value: KDFFileData): Promise<void>;
|
|
774
|
+
}
|
|
775
|
+
declare class JSONFile {
|
|
776
|
+
constructor(path: string);
|
|
777
|
+
json(): Promise<KDFFileData>;
|
|
778
|
+
/** Server runtime only, requires kdf.files.write. */
|
|
779
|
+
save(value: KDFFileData): Promise<void>;
|
|
780
|
+
}
|
package/lib/kdfjs-es2020.d.ts
CHANGED
|
@@ -85,3 +85,6 @@ interface Performance { readonly timeOrigin: number; now(): number; } declare co
|
|
|
85
85
|
/** Bounded KDataForgeJS logging. No grouping, timing, or trace APIs; table output is safely summarized. */
|
|
86
86
|
interface Console { log(...data: readonly unknown[]): void; info(...data: readonly unknown[]): void; warn(...data: readonly unknown[]): void; error(...data: readonly unknown[]): void; debug(...data: readonly unknown[]): void; table(data: unknown): void; }
|
|
87
87
|
declare const console: Console;
|
|
88
|
+
|
|
89
|
+
/** Standard key exclusion utility used by observational hook options. */
|
|
90
|
+
type Omit<T, K extends PropertyKey> = Pick<T, Exclude<keyof T, K>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sf-kmods/kdataforgejs",
|
|
3
|
-
"version": "2026.4.
|
|
3
|
+
"version": "2026.4.28",
|
|
4
4
|
"description": "TypeScript types for KDataForgeJS packs: declarations of the built-in @sf-kmods/kdataforgejs module plus a strict tsconfig base.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Kyri123/Kyrium",
|