@rbxts/scribe 2.5.0 → 2.6.0
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/LICENSE +21 -21
- package/README.md +105 -100
- package/Scribe-source-map.json +1 -1
- package/licenses/ProfileStore-Apache-2.0.txt +201 -201
- package/package.json +1 -1
- package/src/Client/init.luau +9 -12
- package/src/Internal/Derived.luau +37 -7
- package/src/Internal/ExchangeLeg.luau +7 -7
- package/src/Internal/Failure.luau +41 -5
- package/src/Internal/Node.luau +264 -62
- package/src/Internal/Store/ProfileStore.luau +21 -0
- package/src/Internal/Template.luau +78 -8
- package/src/Internal/Version.luau +1 -1
- package/src/Server/Commands.luau +34 -12
- package/src/Server/DebugHook.luau +1 -1
- package/src/Server/Leaderboards.luau +3 -3
- package/src/Server/Monetization.luau +98 -40
- package/src/Server/Persistence.luau +220 -103
- package/src/Server/Replication.luau +230 -21
- package/src/Server/Timed.luau +2 -2
- package/src/Types.luau +3 -1
- package/src/init.luau +137 -71
- package/types/api.d.ts +253 -252
- package/types/common.d.ts +357 -355
- package/types/index.d.ts +226 -226
- package/types/schema.d.ts +276 -276
package/types/schema.d.ts
CHANGED
|
@@ -1,276 +1,276 @@
|
|
|
1
|
-
/** Schema declarations have no JavaScript runtime; Scribe constructs the markers in Luau. */
|
|
2
|
-
declare const declaration: unique symbol;
|
|
3
|
-
export interface Declaration<K extends string, T> {
|
|
4
|
-
readonly [declaration]: readonly [K, T];
|
|
5
|
-
}
|
|
6
|
-
export type ServerOnly<T> = Declaration<"ServerOnly", T>;
|
|
7
|
-
export type Shared<T> = Declaration<"Shared", T>;
|
|
8
|
-
export type Session<T> = Declaration<"Session", T>;
|
|
9
|
-
export type Timed<T> = Declaration<"Timed", T>;
|
|
10
|
-
export type Derived<T> = Declaration<"Derived", T>;
|
|
11
|
-
export type Optional<T> = Declaration<"Optional", T>;
|
|
12
|
-
export type ArrayOf<T> = Declaration<"ArrayOf", T>;
|
|
13
|
-
export type DictOf<T> = Declaration<"DictOf", T>;
|
|
14
|
-
export type MapOf<K extends "integer" | "string", T> = Declaration<"MapOf", readonly [K, T]>;
|
|
15
|
-
export type SetOf<T> = Declaration<"SetOf", T>;
|
|
16
|
-
export type Flags<K extends string = string> = Declaration<"Flags", K>;
|
|
17
|
-
export type EnumValue<K extends string> = Declaration<"Enum", K>;
|
|
18
|
-
export type BigSchema = Declaration<"Big", BigValue>;
|
|
19
|
-
export type Disconnect = (this: void) => void;
|
|
20
|
-
/** Numeric strings are validated at runtime and limited to 256 bytes before whitespace removal. */
|
|
21
|
-
export type BigOperand = BigValue | number | string;
|
|
22
|
-
|
|
23
|
-
/** Immutable mantissa/exponent value. These are genuine Luau self methods. */
|
|
24
|
-
export interface BigValue {
|
|
25
|
-
readonly M: number;
|
|
26
|
-
readonly E: number;
|
|
27
|
-
Add(other: BigOperand): BigValue;
|
|
28
|
-
Subtract(other: BigOperand): BigValue;
|
|
29
|
-
Multiply(other: BigOperand): BigValue;
|
|
30
|
-
Divide(other: BigOperand): BigValue;
|
|
31
|
-
Negate(): BigValue;
|
|
32
|
-
Compare(other: BigOperand): number;
|
|
33
|
-
Equals(other: BigOperand): boolean;
|
|
34
|
-
Pow(exponent: number): BigValue;
|
|
35
|
-
Log10(): number;
|
|
36
|
-
Short(decimals?: number): string;
|
|
37
|
-
ToNumber(): number;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type Datatype = Vector3 | Vector2 | Vector3int16 | Vector2int16 | CFrame | Color3 |
|
|
41
|
-
BrickColor | UDim | UDim2 | Rect | NumberRange | NumberSequence | ColorSequence |
|
|
42
|
-
DateTime | EnumItem | Font | PhysicalProperties;
|
|
43
|
-
export type AtomicValue = Datatype | buffer | BigValue;
|
|
44
|
-
type Widen<T> = T extends number ? number : T extends boolean ? boolean : T extends string ? string : T;
|
|
45
|
-
type KeyOfMap<K> = K extends "integer" ? number : string;
|
|
46
|
-
type OptionalField<T> = undefined extends T ? true : T extends Declaration<infer K, infer V>
|
|
47
|
-
? K extends "Optional" ? true : K extends "ServerOnly" | "Shared" | "Session" ? OptionalField<V> : false
|
|
48
|
-
: false;
|
|
49
|
-
type Simplify<T> = { [K in keyof T]: T[K] };
|
|
50
|
-
type ValueRecord<T> = Simplify<{
|
|
51
|
-
-readonly [K in keyof T as OptionalField<T[K]> extends true ? never : K]: ValueOf<T[K]>;
|
|
52
|
-
} & {
|
|
53
|
-
-readonly [K in keyof T as OptionalField<T[K]> extends true ? K : never]?: ValueOf<T[K]>;
|
|
54
|
-
}>;
|
|
55
|
-
type InputRecord<T> = Simplify<{
|
|
56
|
-
readonly [K in keyof T as OptionalField<T[K]> extends true ? never : K]: InputOf<T[K]>;
|
|
57
|
-
} & {
|
|
58
|
-
readonly [K in keyof T as OptionalField<T[K]> extends true ? K : never]?: InputOf<T[K]>;
|
|
59
|
-
}>;
|
|
60
|
-
|
|
61
|
-
/** Plain, detached value shape; marker wrappers never appear in saved/read values. */
|
|
62
|
-
export type ValueOf<T> = T extends Declaration<infer K, infer V>
|
|
63
|
-
? K extends "Big" ? BigValue
|
|
64
|
-
: K extends "Enum" ? V
|
|
65
|
-
: K extends "Optional" ? ValueOf<V> | undefined
|
|
66
|
-
: K extends "Flags" ? Extract<V, string>[]
|
|
67
|
-
: K extends "ArrayOf" | "SetOf" ? ValueOf<V>[]
|
|
68
|
-
: K extends "DictOf" ? { [key: string]: ValueOf<V> | undefined }
|
|
69
|
-
: K extends "MapOf" ? V extends readonly [infer MK, infer MV] ? Map<KeyOfMap<MK>, ValueOf<MV>> : never
|
|
70
|
-
: ValueOf<V>
|
|
71
|
-
: T extends AtomicValue ? T
|
|
72
|
-
: T extends ReadonlyArray<infer E> ? ValueOf<E>[]
|
|
73
|
-
: T extends ReadonlyMap<infer K, infer V> ? Map<K, ValueOf<V>>
|
|
74
|
-
: T extends object ? ValueRecord<T>
|
|
75
|
-
: Widen<T>;
|
|
76
|
-
|
|
77
|
-
export type DeepReadonly<T> = T extends AtomicValue ? T
|
|
78
|
-
: T extends ReadonlyArray<infer V> ? ReadonlyArray<DeepReadonly<V>>
|
|
79
|
-
: T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<K, DeepReadonly<V>>
|
|
80
|
-
: T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : T;
|
|
81
|
-
|
|
82
|
-
/** Accepted writes. Big values additionally accept numbers and decimal strings. */
|
|
83
|
-
export type InputOf<T> = T extends Declaration<infer K, infer V>
|
|
84
|
-
? K extends "Big" ? BigOperand
|
|
85
|
-
: K extends "Enum" ? V
|
|
86
|
-
: K extends "Optional" ? InputOf<V> | undefined
|
|
87
|
-
: K extends "Flags" ? ReadonlyArray<Extract<V, string>>
|
|
88
|
-
: K extends "ArrayOf" ? ReadonlyArray<ElementInput<V>>
|
|
89
|
-
: K extends "SetOf" ? ReadonlyArray<InputOf<V>>
|
|
90
|
-
: K extends "DictOf" ? { readonly [key: string]: ElementInput<V> | undefined }
|
|
91
|
-
: K extends "MapOf" ? V extends readonly [infer MK, infer MV] ? ReadonlyMap<KeyOfMap<MK>, ElementInput<MV>> : never
|
|
92
|
-
: InputOf<V>
|
|
93
|
-
: T extends Datatype | buffer ? T
|
|
94
|
-
: T extends BigValue ? BigOperand
|
|
95
|
-
: T extends ReadonlyArray<infer E> ? ReadonlyArray<InputOf<E>>
|
|
96
|
-
: T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<K, InputOf<V>>
|
|
97
|
-
: T extends object ? InputRecord<T>
|
|
98
|
-
: Widen<T>;
|
|
99
|
-
|
|
100
|
-
/** Declared container elements fill omitted record fields from their defaults. */
|
|
101
|
-
export type ElementInput<T> = T extends Declaration<infer K, infer V>
|
|
102
|
-
? K extends "ServerOnly" | "Shared" | "Session" | "Timed" | "Derived" ? ElementInput<V>
|
|
103
|
-
: K extends "Optional" ? ElementInput<V> | undefined
|
|
104
|
-
: InputOf<T>
|
|
105
|
-
: T extends AtomicValue ? InputOf<T>
|
|
106
|
-
: T extends ReadonlyArray<infer E> ? ReadonlyArray<InputOf<E>>
|
|
107
|
-
: T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<K, InputOf<V>>
|
|
108
|
-
: T extends object ? string extends keyof T ? InputOf<T>
|
|
109
|
-
: number extends keyof T ? InputOf<T>
|
|
110
|
-
: { readonly [K in keyof T]?: ElementInput<T[K]> }
|
|
111
|
-
: InputOf<T>;
|
|
112
|
-
type WriteInput<T, Closed extends boolean> = Closed extends true ? ElementInput<T> : InputOf<T>;
|
|
113
|
-
|
|
114
|
-
type Hidden<T> = T extends ServerOnly<unknown> ? true
|
|
115
|
-
: T extends Declaration<"Shared" | "Session" | "Timed" | "Optional" | "Derived", infer V> ? Hidden<V> : false;
|
|
116
|
-
export type ClientSchema<T> = T extends Declaration<infer K, infer V>
|
|
117
|
-
? K extends "ServerOnly" ? never
|
|
118
|
-
: K extends "MapOf" ? V extends readonly [infer MK, infer MV] ? MapOf<Extract<MK, "integer" | "string">, ClientSchema<MV>> : never
|
|
119
|
-
: K extends "Big" | "Flags" | "Enum" ? T
|
|
120
|
-
: Declaration<K, ClientSchema<V>>
|
|
121
|
-
: T extends AtomicValue ? T
|
|
122
|
-
: T extends ReadonlyArray<infer E> ? ClientSchema<E>[]
|
|
123
|
-
: T extends object ? { [K in keyof T as Hidden<T[K]> extends true ? never : K]: ClientSchema<T[K]> }
|
|
124
|
-
: T;
|
|
125
|
-
type IsShared<T> = T extends Shared<unknown> ? true
|
|
126
|
-
: T extends Session<infer V> ? IsShared<V> : false;
|
|
127
|
-
export type SharedSchema<T> = { [K in keyof T as IsShared<T[K]> extends true ? K : never]: ClientSchema<T[K]> };
|
|
128
|
-
|
|
129
|
-
/** Adapters can depend on this small structural interface without knowing a schema. */
|
|
130
|
-
export interface ReadableNode<T> {
|
|
131
|
-
readonly Get: (this: void) => T;
|
|
132
|
-
readonly Observe: (this: void, callback: (this: void, value: T) => void) => Disconnect;
|
|
133
|
-
readonly Changed: (this: void, callback: (this: void, value: T, previous: T) => void) => Disconnect;
|
|
134
|
-
}
|
|
135
|
-
type Maybe<T, Missing extends boolean> = Missing extends true ? T | undefined : T;
|
|
136
|
-
type Read<T, Missing extends boolean> = Maybe<DeepReadonly<ValueOf<T>>, Missing>;
|
|
137
|
-
interface ReadOperations<T, Missing extends boolean, Closed extends boolean> extends ReadableNode<Read<T, Missing>> {
|
|
138
|
-
/** Calling an accessor without arguments is its Get shorthand. */
|
|
139
|
-
(this: void): Read<T, Missing>;
|
|
140
|
-
readonly Clone: (this: void) => Maybe<ValueOf<T>, Missing>;
|
|
141
|
-
readonly Default: (this: void) => Missing extends true ? Closed extends true ? ValueOf<T> : ValueOf<T> | undefined : ValueOf<T>;
|
|
142
|
-
}
|
|
143
|
-
interface WriteOperations<T, Missing extends boolean, Closed extends boolean> {
|
|
144
|
-
(this: void, value: WriteInput<T, Closed>, replicate?: boolean): ValueOf<T>;
|
|
145
|
-
(this: void, update: (this: void, current: Read<T, Missing>) => WriteInput<T, Closed>, replicate?: boolean): ValueOf<T>;
|
|
146
|
-
readonly Set: (this: void, value: WriteInput<T, Closed>, replicate?: boolean) => ValueOf<T>;
|
|
147
|
-
readonly Update: (this: void, update: (this: void, current: Read<T, Missing>) => WriteInput<T, Closed>, replicate?: boolean) => ValueOf<T>;
|
|
148
|
-
}
|
|
149
|
-
type Unwrap<T> = T extends Declaration<"ServerOnly" | "Shared" | "Session" | "Timed" | "Derived" | "Optional", infer V> ? Unwrap<V> : Exclude<T, undefined>;
|
|
150
|
-
type HasKind<T, Kind extends string> = T extends Declaration<infer K, infer V>
|
|
151
|
-
? K extends Kind ? true : K extends "ServerOnly" | "Shared" | "Session" | "Timed" | "Derived" | "Optional" ? HasKind<V, Kind> : false
|
|
152
|
-
: false;
|
|
153
|
-
type IsReadOnly<T, ReadOnly extends boolean> = ReadOnly extends true ? true : HasKind<T, "Derived">;
|
|
154
|
-
type Mutate<T, Root extends boolean, Missing extends boolean, ReadOnly extends boolean, Closed extends boolean> = Root extends true ? {}
|
|
155
|
-
: IsReadOnly<T, ReadOnly> extends true ? {} : WriteOperations<T, Missing, Closed>;
|
|
156
|
-
type Bound = number | string;
|
|
157
|
-
type AmountOptions = boolean | import("./common").EconomyMeta;
|
|
158
|
-
interface NumberRead {
|
|
159
|
-
readonly Min: (this: void) => number | undefined;
|
|
160
|
-
readonly Max: (this: void) => number | undefined;
|
|
161
|
-
}
|
|
162
|
-
interface NumberWrite {
|
|
163
|
-
readonly Increment: (this: void, amount: number, options?: AmountOptions) => number;
|
|
164
|
-
readonly Decrement: (this: void, amount: number, options?: AmountOptions) => number;
|
|
165
|
-
}
|
|
166
|
-
interface BigRead {
|
|
167
|
-
readonly Min: (this: void) => Bound | undefined;
|
|
168
|
-
readonly Max: (this: void) => Bound | undefined;
|
|
169
|
-
}
|
|
170
|
-
interface BigWrite {
|
|
171
|
-
readonly Increment: (this: void, amount: BigOperand, options?: AmountOptions) => BigValue;
|
|
172
|
-
readonly Decrement: (this: void, amount: BigOperand, options?: AmountOptions) => BigValue;
|
|
173
|
-
readonly Multiply: (this: void, amount: BigOperand, replicate?: boolean) => BigValue;
|
|
174
|
-
readonly Divide: (this: void, amount: BigOperand, replicate?: boolean) => BigValue;
|
|
175
|
-
}
|
|
176
|
-
type WritableOnly<T, ReadOnly extends boolean, Methods> = IsReadOnly<T, ReadOnly> extends true ? {} : Methods;
|
|
177
|
-
type ScalarMethods<T, ReadOnly extends boolean> = Unwrap<T> extends number ? NumberRead & WritableOnly<T, ReadOnly, NumberWrite>
|
|
178
|
-
: Unwrap<T> extends boolean ? WritableOnly<T, ReadOnly, { readonly Toggle: (this: void, replicate?: boolean) => boolean }>
|
|
179
|
-
: Unwrap<T> extends BigSchema | BigValue ? BigRead & WritableOnly<T, ReadOnly, BigWrite> : {};
|
|
180
|
-
|
|
181
|
-
type ChildEvents<K, V> = {
|
|
182
|
-
readonly OnChildChanged: (this: void, callback: (this: void, key: K, value: DeepReadonly<V> | undefined, previous: DeepReadonly<V> | undefined) => void) => Disconnect;
|
|
183
|
-
};
|
|
184
|
-
type CollectionRead<K, E, ReadOnly extends boolean, Closed extends boolean> = ChildEvents<K, ValueOf<E>> & {
|
|
185
|
-
/** Exact Luau key. Array positions start at 1; map keys are never shifted. */
|
|
186
|
-
readonly Child: (this: void, key: K) => Accessor<E, false, true, ReadOnly, Closed>;
|
|
187
|
-
readonly Count: (this: void) => number;
|
|
188
|
-
};
|
|
189
|
-
type ArrayMethods<T, E, ReadOnly extends boolean, Closed extends boolean> = CollectionRead<number, E, ReadOnly, Closed> & {
|
|
190
|
-
readonly [index: number]: Accessor<E, false, true, ReadOnly, Closed>;
|
|
191
|
-
readonly Find: (this: void, value: InputOf<E>) => number | undefined;
|
|
192
|
-
readonly Has: (this: void, value: InputOf<E>) => boolean;
|
|
193
|
-
readonly OnInsert: (this: void, callback: (this: void, value: DeepReadonly<ValueOf<E>>, index: number) => void) => Disconnect;
|
|
194
|
-
readonly OnRemove: (this: void, callback: (this: void, value: DeepReadonly<ValueOf<E>>, index: number) => void) => Disconnect;
|
|
195
|
-
} & WritableOnly<T, ReadOnly, {
|
|
196
|
-
readonly Insert: (this: void, value: WriteInput<E, Closed>, position?: number, replicate?: boolean) => void;
|
|
197
|
-
readonly Remove: (this: void, position?: number, replicate?: boolean) => ValueOf<E> | undefined;
|
|
198
|
-
readonly RemoveValue: (this: void, value: InputOf<E>, replicate?: boolean) => LuaTuple<[ValueOf<E> | undefined, number | undefined]>;
|
|
199
|
-
readonly Clear: (this: void, replicate?: boolean) => void;
|
|
200
|
-
}>;
|
|
201
|
-
type DictMethods<T, K extends string | number, E, ReadOnly extends boolean, Closed extends boolean> = CollectionRead<K, E, ReadOnly, Closed> & {
|
|
202
|
-
readonly [P in K]: Accessor<E, false, true, ReadOnly, Closed>;
|
|
203
|
-
} & {
|
|
204
|
-
readonly OnKeyAdded: (this: void, callback: (this: void, key: K, value: DeepReadonly<ValueOf<E>>) => void) => Disconnect;
|
|
205
|
-
readonly OnKeyRemoved: (this: void, callback: (this: void, key: K, value: DeepReadonly<ValueOf<E>>) => void) => Disconnect;
|
|
206
|
-
} & WritableOnly<T, ReadOnly, {
|
|
207
|
-
readonly Remove: (this: void, key: K, replicate?: boolean) => ValueOf<E> | undefined;
|
|
208
|
-
readonly Clear: (this: void, replicate?: boolean) => void;
|
|
209
|
-
}>;
|
|
210
|
-
type SetMethods<T, E, ReadOnly extends boolean> = {
|
|
211
|
-
readonly Has: (this: void, value: InputOf<E>) => boolean;
|
|
212
|
-
readonly Find: (this: void, value: InputOf<E>) => number | undefined;
|
|
213
|
-
readonly Count: (this: void) => number;
|
|
214
|
-
} & WritableOnly<T, ReadOnly, {
|
|
215
|
-
readonly Add: (this: void, value: InputOf<E>, replicate?: boolean) => boolean;
|
|
216
|
-
readonly Remove: (this: void, value: InputOf<E>, replicate?: boolean) => boolean;
|
|
217
|
-
readonly Clear: (this: void, replicate?: boolean) => void;
|
|
218
|
-
}>;
|
|
219
|
-
type FlagsMethods<T, K extends string, ReadOnly extends boolean> = {
|
|
220
|
-
readonly Has: (this: void, member: K) => boolean;
|
|
221
|
-
} & WritableOnly<T, ReadOnly, {
|
|
222
|
-
readonly Enable: (this: void, member: K, replicate?: boolean) => void;
|
|
223
|
-
readonly Disable: (this: void, member: K, replicate?: boolean) => void;
|
|
224
|
-
readonly Toggle: (this: void, member: K, replicate?: boolean) => boolean;
|
|
225
|
-
readonly Clear: (this: void, replicate?: boolean) => void;
|
|
226
|
-
}>;
|
|
227
|
-
type ReservedMethod = "Get" | "Set" | "Update" | "Clone" | "Default" | "Changed" | "Observe" | "Child" |
|
|
228
|
-
"OnChildChanged" | "Count" | "Clear" | "Insert" | "Remove" | "RemoveValue" | "Find" | "Has" |
|
|
229
|
-
"OnInsert" | "OnRemove" | "OnKeyAdded" | "OnKeyRemoved" | "Increment" | "Decrement" | "Min" | "Max" |
|
|
230
|
-
"Toggle" | "Enable" | "Disable" | "Add" | "Multiply" | "Divide" | "SetTimed" | "ExtendTimed" | "Active";
|
|
231
|
-
type ChildMissing<T, Missing extends boolean> = Missing extends true ? true : OptionalField<T>;
|
|
232
|
-
type RecordMethods<T, S, Missing extends boolean, ReadOnly extends boolean, Closed extends boolean> = {
|
|
233
|
-
readonly [K in keyof S as K extends ReservedMethod ? never : K]-?: Accessor<S[K], false, ChildMissing<T, Missing>, IsReadOnly<T, ReadOnly>, Closed>;
|
|
234
|
-
} & {
|
|
235
|
-
readonly Child: <K extends Extract<keyof S, string | number>>(this: void, key: K) => Accessor<S[K], false, ChildMissing<T, Missing>, IsReadOnly<T, ReadOnly>, Closed>;
|
|
236
|
-
} & ChildEvents<Extract<keyof S, string | number>, ValueOf<S[keyof S]>>;
|
|
237
|
-
|
|
238
|
-
type ShapeMethods<T, S, Missing extends boolean, ReadOnly extends boolean, Closed extends boolean> = S extends ArrayOf<infer E>
|
|
239
|
-
? ArrayMethods<T, E, ReadOnly, true>
|
|
240
|
-
: S extends DictOf<infer E> ? DictMethods<T, string, E, ReadOnly, true>
|
|
241
|
-
: S extends MapOf<infer K, infer E> ? DictMethods<T, KeyOfMap<K>, E, ReadOnly, true>
|
|
242
|
-
: S extends SetOf<infer E> ? SetMethods<T, E, ReadOnly>
|
|
243
|
-
: S extends Flags<infer K> ? FlagsMethods<T, K, ReadOnly>
|
|
244
|
-
: S extends Declaration<string, unknown> | AtomicValue ? {}
|
|
245
|
-
: S extends ReadonlyArray<infer E> ? ArrayMethods<T, E, ReadOnly, false>
|
|
246
|
-
: S extends object ? string extends keyof S ? DictMethods<T, string, S[string & keyof S], ReadOnly, false>
|
|
247
|
-
: number extends keyof S ? ArrayMethods<T, S[number & keyof S], ReadOnly, false>
|
|
248
|
-
: RecordMethods<T, S, Missing, ReadOnly, Closed>
|
|
249
|
-
: {};
|
|
250
|
-
type TimedMethods<T, ReadOnly extends boolean> = HasKind<T, "Timed"> extends true ? {
|
|
251
|
-
/** Timer state and seconds left. Clients read replicated deadlines; inactive returns false, undefined. */
|
|
252
|
-
readonly Active: (this: void) => LuaTuple<[boolean, number | undefined]>;
|
|
253
|
-
} & WritableOnly<T, ReadOnly, {
|
|
254
|
-
readonly SetTimed: (this: void, value: InputOf<T>, seconds: number, replicate?: boolean) => void;
|
|
255
|
-
readonly ExtendTimed: (this: void, seconds: number, replicate?: boolean) => void;
|
|
256
|
-
}> : {};
|
|
257
|
-
|
|
258
|
-
/** Accessors are proxy objects, never native Array/Map instances. */
|
|
259
|
-
export type Accessor<T, Root extends boolean = false, Missing extends boolean = false, ReadOnly extends boolean = false, Closed extends boolean = false> =
|
|
260
|
-
ReadOperations<T, Missing, Closed> & Mutate<T, Root, Missing, ReadOnly, Closed> & ScalarMethods<T, ReadOnly> &
|
|
261
|
-
ShapeMethods<T, Unwrap<T>, Missing, ReadOnly, Closed> & TimedMethods<T, ReadOnly>;
|
|
262
|
-
export type PlayerData<T> = Accessor<T, true>;
|
|
263
|
-
export type ReadonlyAccessor<T, Root extends boolean = false> = Accessor<T, Root, false, true>;
|
|
264
|
-
|
|
265
|
-
type Join<K extends string, P> = P extends string ? `${K}.${P}` : never;
|
|
266
|
-
/** Static numeric leaf paths only. Dynamic keys require a runtime-validated path. */
|
|
267
|
-
export type NumericPaths<T, IncludeBig extends boolean = false, Depth extends unknown[] = []> =
|
|
268
|
-
Depth extends [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown] ? never
|
|
269
|
-
: Unwrap<T> extends number ? ""
|
|
270
|
-
: Unwrap<T> extends BigSchema | BigValue ? IncludeBig extends true ? "" : never
|
|
271
|
-
: Unwrap<T> extends AtomicValue | Declaration<string, unknown> | ReadonlyArray<unknown> ? never
|
|
272
|
-
: Unwrap<T> extends object ? {
|
|
273
|
-
[K in Extract<keyof Unwrap<T>, string>]: string extends K ? never :
|
|
274
|
-
NumericPaths<Unwrap<T>[K], IncludeBig, [...Depth, unknown]> extends infer P
|
|
275
|
-
? P extends "" ? K : Join<K, P> : never
|
|
276
|
-
}[Extract<keyof Unwrap<T>, string>] : never;
|
|
1
|
+
/** Schema declarations have no JavaScript runtime; Scribe constructs the markers in Luau. */
|
|
2
|
+
declare const declaration: unique symbol;
|
|
3
|
+
export interface Declaration<K extends string, T> {
|
|
4
|
+
readonly [declaration]: readonly [K, T];
|
|
5
|
+
}
|
|
6
|
+
export type ServerOnly<T> = Declaration<"ServerOnly", T>;
|
|
7
|
+
export type Shared<T> = Declaration<"Shared", T>;
|
|
8
|
+
export type Session<T> = Declaration<"Session", T>;
|
|
9
|
+
export type Timed<T> = Declaration<"Timed", T>;
|
|
10
|
+
export type Derived<T> = Declaration<"Derived", T>;
|
|
11
|
+
export type Optional<T> = Declaration<"Optional", T>;
|
|
12
|
+
export type ArrayOf<T> = Declaration<"ArrayOf", T>;
|
|
13
|
+
export type DictOf<T> = Declaration<"DictOf", T>;
|
|
14
|
+
export type MapOf<K extends "integer" | "string", T> = Declaration<"MapOf", readonly [K, T]>;
|
|
15
|
+
export type SetOf<T> = Declaration<"SetOf", T>;
|
|
16
|
+
export type Flags<K extends string = string> = Declaration<"Flags", K>;
|
|
17
|
+
export type EnumValue<K extends string> = Declaration<"Enum", K>;
|
|
18
|
+
export type BigSchema = Declaration<"Big", BigValue>;
|
|
19
|
+
export type Disconnect = (this: void) => void;
|
|
20
|
+
/** Numeric strings are validated at runtime and limited to 256 bytes before whitespace removal. */
|
|
21
|
+
export type BigOperand = BigValue | number | string;
|
|
22
|
+
|
|
23
|
+
/** Immutable mantissa/exponent value. These are genuine Luau self methods. */
|
|
24
|
+
export interface BigValue {
|
|
25
|
+
readonly M: number;
|
|
26
|
+
readonly E: number;
|
|
27
|
+
Add(other: BigOperand): BigValue;
|
|
28
|
+
Subtract(other: BigOperand): BigValue;
|
|
29
|
+
Multiply(other: BigOperand): BigValue;
|
|
30
|
+
Divide(other: BigOperand): BigValue;
|
|
31
|
+
Negate(): BigValue;
|
|
32
|
+
Compare(other: BigOperand): number;
|
|
33
|
+
Equals(other: BigOperand): boolean;
|
|
34
|
+
Pow(exponent: number): BigValue;
|
|
35
|
+
Log10(): number;
|
|
36
|
+
Short(decimals?: number): string;
|
|
37
|
+
ToNumber(): number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type Datatype = Vector3 | Vector2 | Vector3int16 | Vector2int16 | CFrame | Color3 |
|
|
41
|
+
BrickColor | UDim | UDim2 | Rect | NumberRange | NumberSequence | ColorSequence |
|
|
42
|
+
DateTime | EnumItem | Font | PhysicalProperties;
|
|
43
|
+
export type AtomicValue = Datatype | buffer | BigValue;
|
|
44
|
+
type Widen<T> = T extends number ? number : T extends boolean ? boolean : T extends string ? string : T;
|
|
45
|
+
type KeyOfMap<K> = K extends "integer" ? number : string;
|
|
46
|
+
type OptionalField<T> = undefined extends T ? true : T extends Declaration<infer K, infer V>
|
|
47
|
+
? K extends "Optional" ? true : K extends "ServerOnly" | "Shared" | "Session" ? OptionalField<V> : false
|
|
48
|
+
: false;
|
|
49
|
+
type Simplify<T> = { [K in keyof T]: T[K] };
|
|
50
|
+
type ValueRecord<T> = Simplify<{
|
|
51
|
+
-readonly [K in keyof T as OptionalField<T[K]> extends true ? never : K]: ValueOf<T[K]>;
|
|
52
|
+
} & {
|
|
53
|
+
-readonly [K in keyof T as OptionalField<T[K]> extends true ? K : never]?: ValueOf<T[K]>;
|
|
54
|
+
}>;
|
|
55
|
+
type InputRecord<T> = Simplify<{
|
|
56
|
+
readonly [K in keyof T as OptionalField<T[K]> extends true ? never : K]: InputOf<T[K]>;
|
|
57
|
+
} & {
|
|
58
|
+
readonly [K in keyof T as OptionalField<T[K]> extends true ? K : never]?: InputOf<T[K]>;
|
|
59
|
+
}>;
|
|
60
|
+
|
|
61
|
+
/** Plain, detached value shape; marker wrappers never appear in saved/read values. */
|
|
62
|
+
export type ValueOf<T> = T extends Declaration<infer K, infer V>
|
|
63
|
+
? K extends "Big" ? BigValue
|
|
64
|
+
: K extends "Enum" ? V
|
|
65
|
+
: K extends "Optional" ? ValueOf<V> | undefined
|
|
66
|
+
: K extends "Flags" ? Extract<V, string>[]
|
|
67
|
+
: K extends "ArrayOf" | "SetOf" ? ValueOf<V>[]
|
|
68
|
+
: K extends "DictOf" ? { [key: string]: ValueOf<V> | undefined }
|
|
69
|
+
: K extends "MapOf" ? V extends readonly [infer MK, infer MV] ? Map<KeyOfMap<MK>, ValueOf<MV>> : never
|
|
70
|
+
: ValueOf<V>
|
|
71
|
+
: T extends AtomicValue ? T
|
|
72
|
+
: T extends ReadonlyArray<infer E> ? ValueOf<E>[]
|
|
73
|
+
: T extends ReadonlyMap<infer K, infer V> ? Map<K, ValueOf<V>>
|
|
74
|
+
: T extends object ? ValueRecord<T>
|
|
75
|
+
: Widen<T>;
|
|
76
|
+
|
|
77
|
+
export type DeepReadonly<T> = T extends AtomicValue ? T
|
|
78
|
+
: T extends ReadonlyArray<infer V> ? ReadonlyArray<DeepReadonly<V>>
|
|
79
|
+
: T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<K, DeepReadonly<V>>
|
|
80
|
+
: T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : T;
|
|
81
|
+
|
|
82
|
+
/** Accepted writes. Big values additionally accept numbers and decimal strings. */
|
|
83
|
+
export type InputOf<T> = T extends Declaration<infer K, infer V>
|
|
84
|
+
? K extends "Big" ? BigOperand
|
|
85
|
+
: K extends "Enum" ? V
|
|
86
|
+
: K extends "Optional" ? InputOf<V> | undefined
|
|
87
|
+
: K extends "Flags" ? ReadonlyArray<Extract<V, string>>
|
|
88
|
+
: K extends "ArrayOf" ? ReadonlyArray<ElementInput<V>>
|
|
89
|
+
: K extends "SetOf" ? ReadonlyArray<InputOf<V>>
|
|
90
|
+
: K extends "DictOf" ? { readonly [key: string]: ElementInput<V> | undefined }
|
|
91
|
+
: K extends "MapOf" ? V extends readonly [infer MK, infer MV] ? ReadonlyMap<KeyOfMap<MK>, ElementInput<MV>> : never
|
|
92
|
+
: InputOf<V>
|
|
93
|
+
: T extends Datatype | buffer ? T
|
|
94
|
+
: T extends BigValue ? BigOperand
|
|
95
|
+
: T extends ReadonlyArray<infer E> ? ReadonlyArray<InputOf<E>>
|
|
96
|
+
: T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<K, InputOf<V>>
|
|
97
|
+
: T extends object ? InputRecord<T>
|
|
98
|
+
: Widen<T>;
|
|
99
|
+
|
|
100
|
+
/** Declared container elements fill omitted record fields from their defaults. */
|
|
101
|
+
export type ElementInput<T> = T extends Declaration<infer K, infer V>
|
|
102
|
+
? K extends "ServerOnly" | "Shared" | "Session" | "Timed" | "Derived" ? ElementInput<V>
|
|
103
|
+
: K extends "Optional" ? ElementInput<V> | undefined
|
|
104
|
+
: InputOf<T>
|
|
105
|
+
: T extends AtomicValue ? InputOf<T>
|
|
106
|
+
: T extends ReadonlyArray<infer E> ? ReadonlyArray<InputOf<E>>
|
|
107
|
+
: T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<K, InputOf<V>>
|
|
108
|
+
: T extends object ? string extends keyof T ? InputOf<T>
|
|
109
|
+
: number extends keyof T ? InputOf<T>
|
|
110
|
+
: { readonly [K in keyof T]?: ElementInput<T[K]> }
|
|
111
|
+
: InputOf<T>;
|
|
112
|
+
type WriteInput<T, Closed extends boolean> = Closed extends true ? ElementInput<T> : InputOf<T>;
|
|
113
|
+
|
|
114
|
+
type Hidden<T> = T extends ServerOnly<unknown> ? true
|
|
115
|
+
: T extends Declaration<"Shared" | "Session" | "Timed" | "Optional" | "Derived", infer V> ? Hidden<V> : false;
|
|
116
|
+
export type ClientSchema<T> = T extends Declaration<infer K, infer V>
|
|
117
|
+
? K extends "ServerOnly" ? never
|
|
118
|
+
: K extends "MapOf" ? V extends readonly [infer MK, infer MV] ? MapOf<Extract<MK, "integer" | "string">, ClientSchema<MV>> : never
|
|
119
|
+
: K extends "Big" | "Flags" | "Enum" ? T
|
|
120
|
+
: Declaration<K, ClientSchema<V>>
|
|
121
|
+
: T extends AtomicValue ? T
|
|
122
|
+
: T extends ReadonlyArray<infer E> ? ClientSchema<E>[]
|
|
123
|
+
: T extends object ? { [K in keyof T as Hidden<T[K]> extends true ? never : K]: ClientSchema<T[K]> }
|
|
124
|
+
: T;
|
|
125
|
+
type IsShared<T> = T extends Shared<unknown> ? true
|
|
126
|
+
: T extends Session<infer V> ? IsShared<V> : false;
|
|
127
|
+
export type SharedSchema<T> = { [K in keyof T as IsShared<T[K]> extends true ? K : never]: ClientSchema<T[K]> };
|
|
128
|
+
|
|
129
|
+
/** Adapters can depend on this small structural interface without knowing a schema. */
|
|
130
|
+
export interface ReadableNode<T> {
|
|
131
|
+
readonly Get: (this: void) => T;
|
|
132
|
+
readonly Observe: (this: void, callback: (this: void, value: T) => void) => Disconnect;
|
|
133
|
+
readonly Changed: (this: void, callback: (this: void, value: T, previous: T) => void) => Disconnect;
|
|
134
|
+
}
|
|
135
|
+
type Maybe<T, Missing extends boolean> = Missing extends true ? T | undefined : T;
|
|
136
|
+
type Read<T, Missing extends boolean> = Maybe<DeepReadonly<ValueOf<T>>, Missing>;
|
|
137
|
+
interface ReadOperations<T, Missing extends boolean, Closed extends boolean> extends ReadableNode<Read<T, Missing>> {
|
|
138
|
+
/** Calling an accessor without arguments is its Get shorthand. */
|
|
139
|
+
(this: void): Read<T, Missing>;
|
|
140
|
+
readonly Clone: (this: void) => Maybe<ValueOf<T>, Missing>;
|
|
141
|
+
readonly Default: (this: void) => Missing extends true ? Closed extends true ? ValueOf<T> : ValueOf<T> | undefined : ValueOf<T>;
|
|
142
|
+
}
|
|
143
|
+
interface WriteOperations<T, Missing extends boolean, Closed extends boolean> {
|
|
144
|
+
(this: void, value: WriteInput<T, Closed>, replicate?: boolean): ValueOf<T>;
|
|
145
|
+
(this: void, update: (this: void, current: Read<T, Missing>) => WriteInput<T, Closed>, replicate?: boolean): ValueOf<T>;
|
|
146
|
+
readonly Set: (this: void, value: WriteInput<T, Closed>, replicate?: boolean) => ValueOf<T>;
|
|
147
|
+
readonly Update: (this: void, update: (this: void, current: Read<T, Missing>) => WriteInput<T, Closed>, replicate?: boolean) => ValueOf<T>;
|
|
148
|
+
}
|
|
149
|
+
type Unwrap<T> = T extends Declaration<"ServerOnly" | "Shared" | "Session" | "Timed" | "Derived" | "Optional", infer V> ? Unwrap<V> : Exclude<T, undefined>;
|
|
150
|
+
type HasKind<T, Kind extends string> = T extends Declaration<infer K, infer V>
|
|
151
|
+
? K extends Kind ? true : K extends "ServerOnly" | "Shared" | "Session" | "Timed" | "Derived" | "Optional" ? HasKind<V, Kind> : false
|
|
152
|
+
: false;
|
|
153
|
+
type IsReadOnly<T, ReadOnly extends boolean> = ReadOnly extends true ? true : HasKind<T, "Derived">;
|
|
154
|
+
type Mutate<T, Root extends boolean, Missing extends boolean, ReadOnly extends boolean, Closed extends boolean> = Root extends true ? {}
|
|
155
|
+
: IsReadOnly<T, ReadOnly> extends true ? {} : WriteOperations<T, Missing, Closed>;
|
|
156
|
+
type Bound = number | string;
|
|
157
|
+
type AmountOptions = boolean | import("./common").EconomyMeta;
|
|
158
|
+
interface NumberRead {
|
|
159
|
+
readonly Min: (this: void) => number | undefined;
|
|
160
|
+
readonly Max: (this: void) => number | undefined;
|
|
161
|
+
}
|
|
162
|
+
interface NumberWrite {
|
|
163
|
+
readonly Increment: (this: void, amount: number, options?: AmountOptions) => number;
|
|
164
|
+
readonly Decrement: (this: void, amount: number, options?: AmountOptions) => number;
|
|
165
|
+
}
|
|
166
|
+
interface BigRead {
|
|
167
|
+
readonly Min: (this: void) => Bound | undefined;
|
|
168
|
+
readonly Max: (this: void) => Bound | undefined;
|
|
169
|
+
}
|
|
170
|
+
interface BigWrite {
|
|
171
|
+
readonly Increment: (this: void, amount: BigOperand, options?: AmountOptions) => BigValue;
|
|
172
|
+
readonly Decrement: (this: void, amount: BigOperand, options?: AmountOptions) => BigValue;
|
|
173
|
+
readonly Multiply: (this: void, amount: BigOperand, replicate?: boolean) => BigValue;
|
|
174
|
+
readonly Divide: (this: void, amount: BigOperand, replicate?: boolean) => BigValue;
|
|
175
|
+
}
|
|
176
|
+
type WritableOnly<T, ReadOnly extends boolean, Methods> = IsReadOnly<T, ReadOnly> extends true ? {} : Methods;
|
|
177
|
+
type ScalarMethods<T, ReadOnly extends boolean> = Unwrap<T> extends number ? NumberRead & WritableOnly<T, ReadOnly, NumberWrite>
|
|
178
|
+
: Unwrap<T> extends boolean ? WritableOnly<T, ReadOnly, { readonly Toggle: (this: void, replicate?: boolean) => boolean }>
|
|
179
|
+
: Unwrap<T> extends BigSchema | BigValue ? BigRead & WritableOnly<T, ReadOnly, BigWrite> : {};
|
|
180
|
+
|
|
181
|
+
type ChildEvents<K, V> = {
|
|
182
|
+
readonly OnChildChanged: (this: void, callback: (this: void, key: K, value: DeepReadonly<V> | undefined, previous: DeepReadonly<V> | undefined) => void) => Disconnect;
|
|
183
|
+
};
|
|
184
|
+
type CollectionRead<K, E, ReadOnly extends boolean, Closed extends boolean> = ChildEvents<K, ValueOf<E>> & {
|
|
185
|
+
/** Exact Luau key. Array positions start at 1; map keys are never shifted. */
|
|
186
|
+
readonly Child: (this: void, key: K) => Accessor<E, false, true, ReadOnly, Closed>;
|
|
187
|
+
readonly Count: (this: void) => number;
|
|
188
|
+
};
|
|
189
|
+
type ArrayMethods<T, E, ReadOnly extends boolean, Closed extends boolean> = CollectionRead<number, E, ReadOnly, Closed> & {
|
|
190
|
+
readonly [index: number]: Accessor<E, false, true, ReadOnly, Closed>;
|
|
191
|
+
readonly Find: (this: void, value: InputOf<E>) => number | undefined;
|
|
192
|
+
readonly Has: (this: void, value: InputOf<E>) => boolean;
|
|
193
|
+
readonly OnInsert: (this: void, callback: (this: void, value: DeepReadonly<ValueOf<E>>, index: number) => void) => Disconnect;
|
|
194
|
+
readonly OnRemove: (this: void, callback: (this: void, value: DeepReadonly<ValueOf<E>>, index: number) => void) => Disconnect;
|
|
195
|
+
} & WritableOnly<T, ReadOnly, {
|
|
196
|
+
readonly Insert: (this: void, value: WriteInput<E, Closed>, position?: number, replicate?: boolean) => void;
|
|
197
|
+
readonly Remove: (this: void, position?: number, replicate?: boolean) => ValueOf<E> | undefined;
|
|
198
|
+
readonly RemoveValue: (this: void, value: InputOf<E>, replicate?: boolean) => LuaTuple<[ValueOf<E> | undefined, number | undefined]>;
|
|
199
|
+
readonly Clear: (this: void, replicate?: boolean) => void;
|
|
200
|
+
}>;
|
|
201
|
+
type DictMethods<T, K extends string | number, E, ReadOnly extends boolean, Closed extends boolean> = CollectionRead<K, E, ReadOnly, Closed> & {
|
|
202
|
+
readonly [P in K]: Accessor<E, false, true, ReadOnly, Closed>;
|
|
203
|
+
} & {
|
|
204
|
+
readonly OnKeyAdded: (this: void, callback: (this: void, key: K, value: DeepReadonly<ValueOf<E>>) => void) => Disconnect;
|
|
205
|
+
readonly OnKeyRemoved: (this: void, callback: (this: void, key: K, value: DeepReadonly<ValueOf<E>>) => void) => Disconnect;
|
|
206
|
+
} & WritableOnly<T, ReadOnly, {
|
|
207
|
+
readonly Remove: (this: void, key: K, replicate?: boolean) => ValueOf<E> | undefined;
|
|
208
|
+
readonly Clear: (this: void, replicate?: boolean) => void;
|
|
209
|
+
}>;
|
|
210
|
+
type SetMethods<T, E, ReadOnly extends boolean> = {
|
|
211
|
+
readonly Has: (this: void, value: InputOf<E>) => boolean;
|
|
212
|
+
readonly Find: (this: void, value: InputOf<E>) => number | undefined;
|
|
213
|
+
readonly Count: (this: void) => number;
|
|
214
|
+
} & WritableOnly<T, ReadOnly, {
|
|
215
|
+
readonly Add: (this: void, value: InputOf<E>, replicate?: boolean) => boolean;
|
|
216
|
+
readonly Remove: (this: void, value: InputOf<E>, replicate?: boolean) => boolean;
|
|
217
|
+
readonly Clear: (this: void, replicate?: boolean) => void;
|
|
218
|
+
}>;
|
|
219
|
+
type FlagsMethods<T, K extends string, ReadOnly extends boolean> = {
|
|
220
|
+
readonly Has: (this: void, member: K) => boolean;
|
|
221
|
+
} & WritableOnly<T, ReadOnly, {
|
|
222
|
+
readonly Enable: (this: void, member: K, replicate?: boolean) => void;
|
|
223
|
+
readonly Disable: (this: void, member: K, replicate?: boolean) => void;
|
|
224
|
+
readonly Toggle: (this: void, member: K, replicate?: boolean) => boolean;
|
|
225
|
+
readonly Clear: (this: void, replicate?: boolean) => void;
|
|
226
|
+
}>;
|
|
227
|
+
type ReservedMethod = "Get" | "Set" | "Update" | "Clone" | "Default" | "Changed" | "Observe" | "Child" |
|
|
228
|
+
"OnChildChanged" | "Count" | "Clear" | "Insert" | "Remove" | "RemoveValue" | "Find" | "Has" |
|
|
229
|
+
"OnInsert" | "OnRemove" | "OnKeyAdded" | "OnKeyRemoved" | "Increment" | "Decrement" | "Min" | "Max" |
|
|
230
|
+
"Toggle" | "Enable" | "Disable" | "Add" | "Multiply" | "Divide" | "SetTimed" | "ExtendTimed" | "Active";
|
|
231
|
+
type ChildMissing<T, Missing extends boolean> = Missing extends true ? true : OptionalField<T>;
|
|
232
|
+
type RecordMethods<T, S, Missing extends boolean, ReadOnly extends boolean, Closed extends boolean> = {
|
|
233
|
+
readonly [K in keyof S as K extends ReservedMethod ? never : K]-?: Accessor<S[K], false, ChildMissing<T, Missing>, IsReadOnly<T, ReadOnly>, Closed>;
|
|
234
|
+
} & {
|
|
235
|
+
readonly Child: <K extends Extract<keyof S, string | number>>(this: void, key: K) => Accessor<S[K], false, ChildMissing<T, Missing>, IsReadOnly<T, ReadOnly>, Closed>;
|
|
236
|
+
} & ChildEvents<Extract<keyof S, string | number>, ValueOf<S[keyof S]>>;
|
|
237
|
+
|
|
238
|
+
type ShapeMethods<T, S, Missing extends boolean, ReadOnly extends boolean, Closed extends boolean> = S extends ArrayOf<infer E>
|
|
239
|
+
? ArrayMethods<T, E, ReadOnly, true>
|
|
240
|
+
: S extends DictOf<infer E> ? DictMethods<T, string, E, ReadOnly, true>
|
|
241
|
+
: S extends MapOf<infer K, infer E> ? DictMethods<T, KeyOfMap<K>, E, ReadOnly, true>
|
|
242
|
+
: S extends SetOf<infer E> ? SetMethods<T, E, ReadOnly>
|
|
243
|
+
: S extends Flags<infer K> ? FlagsMethods<T, K, ReadOnly>
|
|
244
|
+
: S extends Declaration<string, unknown> | AtomicValue ? {}
|
|
245
|
+
: S extends ReadonlyArray<infer E> ? ArrayMethods<T, E, ReadOnly, false>
|
|
246
|
+
: S extends object ? string extends keyof S ? DictMethods<T, string, S[string & keyof S], ReadOnly, false>
|
|
247
|
+
: number extends keyof S ? ArrayMethods<T, S[number & keyof S], ReadOnly, false>
|
|
248
|
+
: RecordMethods<T, S, Missing, ReadOnly, Closed>
|
|
249
|
+
: {};
|
|
250
|
+
type TimedMethods<T, ReadOnly extends boolean> = HasKind<T, "Timed"> extends true ? {
|
|
251
|
+
/** Timer state and seconds left. Clients read replicated deadlines; inactive returns false, undefined. */
|
|
252
|
+
readonly Active: (this: void) => LuaTuple<[boolean, number | undefined]>;
|
|
253
|
+
} & WritableOnly<T, ReadOnly, {
|
|
254
|
+
readonly SetTimed: (this: void, value: InputOf<T>, seconds: number, replicate?: boolean) => void;
|
|
255
|
+
readonly ExtendTimed: (this: void, seconds: number, replicate?: boolean) => void;
|
|
256
|
+
}> : {};
|
|
257
|
+
|
|
258
|
+
/** Accessors are proxy objects, never native Array/Map instances. */
|
|
259
|
+
export type Accessor<T, Root extends boolean = false, Missing extends boolean = false, ReadOnly extends boolean = false, Closed extends boolean = false> =
|
|
260
|
+
ReadOperations<T, Missing, Closed> & Mutate<T, Root, Missing, ReadOnly, Closed> & ScalarMethods<T, ReadOnly> &
|
|
261
|
+
ShapeMethods<T, Unwrap<T>, Missing, ReadOnly, Closed> & TimedMethods<T, ReadOnly>;
|
|
262
|
+
export type PlayerData<T> = Accessor<T, true>;
|
|
263
|
+
export type ReadonlyAccessor<T, Root extends boolean = false> = Accessor<T, Root, false, true>;
|
|
264
|
+
|
|
265
|
+
type Join<K extends string, P> = P extends string ? `${K}.${P}` : never;
|
|
266
|
+
/** Static numeric leaf paths only. Dynamic keys require a runtime-validated path. */
|
|
267
|
+
export type NumericPaths<T, IncludeBig extends boolean = false, Depth extends unknown[] = []> =
|
|
268
|
+
Depth extends [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown] ? never
|
|
269
|
+
: Unwrap<T> extends number ? ""
|
|
270
|
+
: Unwrap<T> extends BigSchema | BigValue ? IncludeBig extends true ? "" : never
|
|
271
|
+
: Unwrap<T> extends AtomicValue | Declaration<string, unknown> | ReadonlyArray<unknown> ? never
|
|
272
|
+
: Unwrap<T> extends object ? {
|
|
273
|
+
[K in Extract<keyof Unwrap<T>, string>]: string extends K ? never :
|
|
274
|
+
NumericPaths<Unwrap<T>[K], IncludeBig, [...Depth, unknown]> extends infer P
|
|
275
|
+
? P extends "" ? K : Join<K, P> : never
|
|
276
|
+
}[Extract<keyof Unwrap<T>, string>] : never;
|