@rbxts/types 1.0.937 → 1.0.939
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/include/generated/None.d.ts +789 -187
- package/include/generated/PluginSecurity.d.ts +191 -34
- package/include/generated/enums.d.ts +135 -19
- package/include/roblox.d.ts +1 -0
- package/include/selector.d.ts +152 -0
- package/package.json +1 -1
|
@@ -26844,6 +26844,42 @@ declare namespace Enum {
|
|
|
26844
26844
|
export function FromValue(this: globalThis.Enum, value: number): globalThis.Enum.PredictionStatus | undefined;
|
|
26845
26845
|
}
|
|
26846
26846
|
export type PredictionStatus = PredictionStatus.Authoritative | PredictionStatus.Predicted | PredictionStatus.None;
|
|
26847
|
+
/**
|
|
26848
|
+
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PredictiveStreamingMode)
|
|
26849
|
+
*/
|
|
26850
|
+
export namespace PredictiveStreamingMode {
|
|
26851
|
+
/**
|
|
26852
|
+
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PredictiveStreamingMode#Default)
|
|
26853
|
+
*/
|
|
26854
|
+
export interface Default extends globalThis.EnumItem {
|
|
26855
|
+
Name: "Default";
|
|
26856
|
+
Value: 0;
|
|
26857
|
+
EnumType: typeof globalThis.Enum.PredictiveStreamingMode;
|
|
26858
|
+
}
|
|
26859
|
+
export const Default: Default;
|
|
26860
|
+
/**
|
|
26861
|
+
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PredictiveStreamingMode#Enabled)
|
|
26862
|
+
*/
|
|
26863
|
+
export interface Enabled extends globalThis.EnumItem {
|
|
26864
|
+
Name: "Enabled";
|
|
26865
|
+
Value: 1;
|
|
26866
|
+
EnumType: typeof globalThis.Enum.PredictiveStreamingMode;
|
|
26867
|
+
}
|
|
26868
|
+
export const Enabled: Enabled;
|
|
26869
|
+
/**
|
|
26870
|
+
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PredictiveStreamingMode#Disabled)
|
|
26871
|
+
*/
|
|
26872
|
+
export interface Disabled extends globalThis.EnumItem {
|
|
26873
|
+
Name: "Disabled";
|
|
26874
|
+
Value: 2;
|
|
26875
|
+
EnumType: typeof globalThis.Enum.PredictiveStreamingMode;
|
|
26876
|
+
}
|
|
26877
|
+
export const Disabled: Disabled;
|
|
26878
|
+
export function GetEnumItems(this: globalThis.Enum): Array<globalThis.Enum.PredictiveStreamingMode>;
|
|
26879
|
+
export function FromName(this: globalThis.Enum, name: string): globalThis.Enum.PredictiveStreamingMode | undefined;
|
|
26880
|
+
export function FromValue(this: globalThis.Enum, value: number): globalThis.Enum.PredictiveStreamingMode | undefined;
|
|
26881
|
+
}
|
|
26882
|
+
export type PredictiveStreamingMode = PredictiveStreamingMode.Default | PredictiveStreamingMode.Enabled | PredictiveStreamingMode.Disabled;
|
|
26847
26883
|
/**
|
|
26848
26884
|
* This enum is used with `UserInputService.PreferredInput` to indicate the primary input type a player is likely using.
|
|
26849
26885
|
*
|
|
@@ -27499,6 +27535,78 @@ declare namespace Enum {
|
|
|
27499
27535
|
export function FromValue(this: globalThis.Enum, value: number): globalThis.Enum.PromptCreateAvatarResult | undefined;
|
|
27500
27536
|
}
|
|
27501
27537
|
export type PromptCreateAvatarResult = PromptCreateAvatarResult.Success | PromptCreateAvatarResult.PermissionDenied | PromptCreateAvatarResult.Timeout | PromptCreateAvatarResult.UploadFailed | PromptCreateAvatarResult.NoUserInput | PromptCreateAvatarResult.InvalidHumanoidDescription | PromptCreateAvatarResult.UGCValidationFailed | PromptCreateAvatarResult.ModeratedName | PromptCreateAvatarResult.MaxOutfits | PromptCreateAvatarResult.PurchaseFailure | PromptCreateAvatarResult.UnknownFailure | PromptCreateAvatarResult.TokenInvalid;
|
|
27538
|
+
/**
|
|
27539
|
+
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PromptCreateOutfitResult)
|
|
27540
|
+
*/
|
|
27541
|
+
export namespace PromptCreateOutfitResult {
|
|
27542
|
+
/**
|
|
27543
|
+
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PromptCreateOutfitResult#Success)
|
|
27544
|
+
*/
|
|
27545
|
+
export interface Success extends globalThis.EnumItem {
|
|
27546
|
+
Name: "Success";
|
|
27547
|
+
Value: 1;
|
|
27548
|
+
EnumType: typeof globalThis.Enum.PromptCreateOutfitResult;
|
|
27549
|
+
}
|
|
27550
|
+
export const Success: Success;
|
|
27551
|
+
/**
|
|
27552
|
+
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PromptCreateOutfitResult#PartialSuccess)
|
|
27553
|
+
*/
|
|
27554
|
+
export interface PartialSuccess extends globalThis.EnumItem {
|
|
27555
|
+
Name: "PartialSuccess";
|
|
27556
|
+
Value: 2;
|
|
27557
|
+
EnumType: typeof globalThis.Enum.PromptCreateOutfitResult;
|
|
27558
|
+
}
|
|
27559
|
+
export const PartialSuccess: PartialSuccess;
|
|
27560
|
+
/**
|
|
27561
|
+
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PromptCreateOutfitResult#CreationFailure)
|
|
27562
|
+
*/
|
|
27563
|
+
export interface CreationFailure extends globalThis.EnumItem {
|
|
27564
|
+
Name: "CreationFailure";
|
|
27565
|
+
Value: 3;
|
|
27566
|
+
EnumType: typeof globalThis.Enum.PromptCreateOutfitResult;
|
|
27567
|
+
}
|
|
27568
|
+
export const CreationFailure: CreationFailure;
|
|
27569
|
+
/**
|
|
27570
|
+
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PromptCreateOutfitResult#PermissionDenied)
|
|
27571
|
+
*/
|
|
27572
|
+
export interface PermissionDenied extends globalThis.EnumItem {
|
|
27573
|
+
Name: "PermissionDenied";
|
|
27574
|
+
Value: 4;
|
|
27575
|
+
EnumType: typeof globalThis.Enum.PromptCreateOutfitResult;
|
|
27576
|
+
}
|
|
27577
|
+
export const PermissionDenied: PermissionDenied;
|
|
27578
|
+
/**
|
|
27579
|
+
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PromptCreateOutfitResult#Timeout)
|
|
27580
|
+
*/
|
|
27581
|
+
export interface Timeout extends globalThis.EnumItem {
|
|
27582
|
+
Name: "Timeout";
|
|
27583
|
+
Value: 5;
|
|
27584
|
+
EnumType: typeof globalThis.Enum.PromptCreateOutfitResult;
|
|
27585
|
+
}
|
|
27586
|
+
export const Timeout: Timeout;
|
|
27587
|
+
/**
|
|
27588
|
+
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PromptCreateOutfitResult#NoUserInput)
|
|
27589
|
+
*/
|
|
27590
|
+
export interface NoUserInput extends globalThis.EnumItem {
|
|
27591
|
+
Name: "NoUserInput";
|
|
27592
|
+
Value: 6;
|
|
27593
|
+
EnumType: typeof globalThis.Enum.PromptCreateOutfitResult;
|
|
27594
|
+
}
|
|
27595
|
+
export const NoUserInput: NoUserInput;
|
|
27596
|
+
/**
|
|
27597
|
+
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PromptCreateOutfitResult#UnknownFailure)
|
|
27598
|
+
*/
|
|
27599
|
+
export interface UnknownFailure extends globalThis.EnumItem {
|
|
27600
|
+
Name: "UnknownFailure";
|
|
27601
|
+
Value: 7;
|
|
27602
|
+
EnumType: typeof globalThis.Enum.PromptCreateOutfitResult;
|
|
27603
|
+
}
|
|
27604
|
+
export const UnknownFailure: UnknownFailure;
|
|
27605
|
+
export function GetEnumItems(this: globalThis.Enum): Array<globalThis.Enum.PromptCreateOutfitResult>;
|
|
27606
|
+
export function FromName(this: globalThis.Enum, name: string): globalThis.Enum.PromptCreateOutfitResult | undefined;
|
|
27607
|
+
export function FromValue(this: globalThis.Enum, value: number): globalThis.Enum.PromptCreateOutfitResult | undefined;
|
|
27608
|
+
}
|
|
27609
|
+
export type PromptCreateOutfitResult = PromptCreateOutfitResult.Success | PromptCreateOutfitResult.PartialSuccess | PromptCreateOutfitResult.CreationFailure | PromptCreateOutfitResult.PermissionDenied | PromptCreateOutfitResult.Timeout | PromptCreateOutfitResult.NoUserInput | PromptCreateOutfitResult.UnknownFailure;
|
|
27502
27610
|
/**
|
|
27503
27611
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PromptExperienceDetailsResult)
|
|
27504
27612
|
*/
|
|
@@ -27771,10 +27879,14 @@ declare namespace Enum {
|
|
|
27771
27879
|
}
|
|
27772
27880
|
export type ProximityPromptStyle = ProximityPromptStyle.Default | ProximityPromptStyle.Custom;
|
|
27773
27881
|
/**
|
|
27882
|
+
* Specifies the type of purchase option in a bulk purchase prompt.
|
|
27883
|
+
*
|
|
27774
27884
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PurchaseOption)
|
|
27775
27885
|
*/
|
|
27776
27886
|
export namespace PurchaseOption {
|
|
27777
27887
|
/**
|
|
27888
|
+
* A timed ownership option. The `Value` field specifies the duration in seconds.
|
|
27889
|
+
*
|
|
27778
27890
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PurchaseOption#TimedOption)
|
|
27779
27891
|
*/
|
|
27780
27892
|
export interface TimedOption extends globalThis.EnumItem {
|
|
@@ -27784,6 +27896,8 @@ declare namespace Enum {
|
|
|
27784
27896
|
}
|
|
27785
27897
|
export const TimedOption: TimedOption;
|
|
27786
27898
|
/**
|
|
27899
|
+
* A permanent ownership purchase option.
|
|
27900
|
+
*
|
|
27787
27901
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/PurchaseOption#Permanent)
|
|
27788
27902
|
*/
|
|
27789
27903
|
export interface Permanent extends globalThis.EnumItem {
|
|
@@ -30338,10 +30452,14 @@ declare namespace Enum {
|
|
|
30338
30452
|
}
|
|
30339
30453
|
export type SafeAreaCompatibility = SafeAreaCompatibility.None | SafeAreaCompatibility.FullscreenExtension;
|
|
30340
30454
|
/**
|
|
30455
|
+
* Filters catalog search results by sales type.
|
|
30456
|
+
*
|
|
30341
30457
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/SalesTypeFilter)
|
|
30342
30458
|
*/
|
|
30343
30459
|
export namespace SalesTypeFilter {
|
|
30344
30460
|
/**
|
|
30461
|
+
* Returns all items regardless of sales type.
|
|
30462
|
+
*
|
|
30345
30463
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/SalesTypeFilter#All)
|
|
30346
30464
|
*/
|
|
30347
30465
|
export interface All extends globalThis.EnumItem {
|
|
@@ -30351,6 +30469,8 @@ declare namespace Enum {
|
|
|
30351
30469
|
}
|
|
30352
30470
|
export const All: All;
|
|
30353
30471
|
/**
|
|
30472
|
+
* Returns only collectible items (Limited and Limited Unique).
|
|
30473
|
+
*
|
|
30354
30474
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/SalesTypeFilter#Collectibles)
|
|
30355
30475
|
*/
|
|
30356
30476
|
export interface Collectibles extends globalThis.EnumItem {
|
|
@@ -30360,6 +30480,8 @@ declare namespace Enum {
|
|
|
30360
30480
|
}
|
|
30361
30481
|
export const Collectibles: Collectibles;
|
|
30362
30482
|
/**
|
|
30483
|
+
* Returns only items with Premium pricing.
|
|
30484
|
+
*
|
|
30363
30485
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/SalesTypeFilter#Premium)
|
|
30364
30486
|
*/
|
|
30365
30487
|
export interface Premium extends globalThis.EnumItem {
|
|
@@ -30369,6 +30491,8 @@ declare namespace Enum {
|
|
|
30369
30491
|
}
|
|
30370
30492
|
export const Premium: Premium;
|
|
30371
30493
|
/**
|
|
30494
|
+
* Returns only items that have timed options available.
|
|
30495
|
+
*
|
|
30372
30496
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/SalesTypeFilter#TimedOptions)
|
|
30373
30497
|
*/
|
|
30374
30498
|
export interface TimedOptions extends globalThis.EnumItem {
|
|
@@ -30901,10 +31025,14 @@ declare namespace Enum {
|
|
|
30901
31025
|
}
|
|
30902
31026
|
export type ScreenOrientation = ScreenOrientation.LandscapeLeft | ScreenOrientation.LandscapeRight | ScreenOrientation.LandscapeSensor | ScreenOrientation.Portrait | ScreenOrientation.Sensor;
|
|
30903
31027
|
/**
|
|
31028
|
+
* Describes the result of a screenshot capture initiated by `CaptureService:TakeScreenshotCaptureAsync()`.
|
|
31029
|
+
*
|
|
30904
31030
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/ScreenshotCaptureResult)
|
|
30905
31031
|
*/
|
|
30906
31032
|
export namespace ScreenshotCaptureResult {
|
|
30907
31033
|
/**
|
|
31034
|
+
* The screenshot capture completed successfully.
|
|
31035
|
+
*
|
|
30908
31036
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/ScreenshotCaptureResult#Success)
|
|
30909
31037
|
*/
|
|
30910
31038
|
export interface Success extends globalThis.EnumItem {
|
|
@@ -30914,6 +31042,8 @@ declare namespace Enum {
|
|
|
30914
31042
|
}
|
|
30915
31043
|
export const Success: Success;
|
|
30916
31044
|
/**
|
|
31045
|
+
* The screenshot capture failed due to an unspecified error.
|
|
31046
|
+
*
|
|
30917
31047
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/ScreenshotCaptureResult#OtherError)
|
|
30918
31048
|
*/
|
|
30919
31049
|
export interface OtherError extends globalThis.EnumItem {
|
|
@@ -30923,6 +31053,8 @@ declare namespace Enum {
|
|
|
30923
31053
|
}
|
|
30924
31054
|
export const OtherError: OtherError;
|
|
30925
31055
|
/**
|
|
31056
|
+
* The device does not support screenshot captures.
|
|
31057
|
+
*
|
|
30926
31058
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/ScreenshotCaptureResult#NoDeviceSupport)
|
|
30927
31059
|
*/
|
|
30928
31060
|
export interface NoDeviceSupport extends globalThis.EnumItem {
|
|
@@ -30932,6 +31064,8 @@ declare namespace Enum {
|
|
|
30932
31064
|
}
|
|
30933
31065
|
export const NoDeviceSupport: NoDeviceSupport;
|
|
30934
31066
|
/**
|
|
31067
|
+
* The device does not have enough storage space to save the screenshot capture.
|
|
31068
|
+
*
|
|
30935
31069
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/ScreenshotCaptureResult#NoSpaceOnDevice)
|
|
30936
31070
|
*/
|
|
30937
31071
|
export interface NoSpaceOnDevice extends globalThis.EnumItem {
|
|
@@ -32196,24 +32330,6 @@ declare namespace Enum {
|
|
|
32196
32330
|
EnumType: typeof globalThis.Enum.SlimTintMode;
|
|
32197
32331
|
}
|
|
32198
32332
|
export const Meshes: Meshes;
|
|
32199
|
-
/**
|
|
32200
|
-
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/SlimTintMode#MeshResourcePtr)
|
|
32201
|
-
*/
|
|
32202
|
-
export interface MeshResourcePtr extends globalThis.EnumItem {
|
|
32203
|
-
Name: "MeshResourcePtr";
|
|
32204
|
-
Value: 3;
|
|
32205
|
-
EnumType: typeof globalThis.Enum.SlimTintMode;
|
|
32206
|
-
}
|
|
32207
|
-
export const MeshResourcePtr: MeshResourcePtr;
|
|
32208
|
-
/**
|
|
32209
|
-
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/SlimTintMode#ContentId)
|
|
32210
|
-
*/
|
|
32211
|
-
export interface ContentId extends globalThis.EnumItem {
|
|
32212
|
-
Name: "ContentId";
|
|
32213
|
-
Value: 4;
|
|
32214
|
-
EnumType: typeof globalThis.Enum.SlimTintMode;
|
|
32215
|
-
}
|
|
32216
|
-
export const ContentId: ContentId;
|
|
32217
32333
|
/**
|
|
32218
32334
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/SlimTintMode#Zone)
|
|
32219
32335
|
*/
|
|
@@ -32227,7 +32343,7 @@ declare namespace Enum {
|
|
|
32227
32343
|
export function FromName(this: globalThis.Enum, name: string): globalThis.Enum.SlimTintMode | undefined;
|
|
32228
32344
|
export function FromValue(this: globalThis.Enum, value: number): globalThis.Enum.SlimTintMode | undefined;
|
|
32229
32345
|
}
|
|
32230
|
-
export type SlimTintMode = SlimTintMode.None | SlimTintMode.LOD | SlimTintMode.Meshes | SlimTintMode.
|
|
32346
|
+
export type SlimTintMode = SlimTintMode.None | SlimTintMode.LOD | SlimTintMode.Meshes | SlimTintMode.Zone;
|
|
32231
32347
|
/**
|
|
32232
32348
|
* [Creator Hub](https://create.roblox.com/docs/reference/engine/enums/SolidPrimitiveType)
|
|
32233
32349
|
*/
|
package/include/roblox.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference no-default-lib="true"/>
|
|
2
2
|
/// <reference path="lua.d.ts" />
|
|
3
3
|
/// <reference path="macro_math.d.ts" />
|
|
4
|
+
/// <reference path="selector.d.ts" />
|
|
4
5
|
/// <reference path="generated/enums.d.ts" />
|
|
5
6
|
/// <reference path="generated/None.d.ts" />
|
|
6
7
|
/// <reference types="@rbxts/compiler-types" />
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the selector strings accepted by `Instance:QueryDescendants()` to the type of the
|
|
5
|
+
* instances they match, so string-literal selectors get a precise return type. The grammar is
|
|
6
|
+
* documented at https://create.roblox.com/docs/reference/engine/classes/Instance#QueryDescendants
|
|
7
|
+
*
|
|
8
|
+
* Only the class named in the last combinator segment affects the result, unioned across
|
|
9
|
+
* comma-separated selectors. `.Tag` and `#Name` carry no class information and resolve to
|
|
10
|
+
* `Instance`; attribute filters and pseudo-classes never change the class. Note that
|
|
11
|
+
* whitespace is not a combinator in this grammar (descendant matching is `>>`), so spaces
|
|
12
|
+
* are ignored rather than treated as separators.
|
|
13
|
+
*/
|
|
14
|
+
declare namespace Selector {
|
|
15
|
+
type Trim<T extends string> = T extends `${infer S} ` ? Trim<S> : T extends ` ${infer S}` ? Trim<S> : T;
|
|
16
|
+
|
|
17
|
+
type SolveHead<Head extends string | undefined> = Head extends string
|
|
18
|
+
? Trim<Head> extends infer C extends keyof Instances
|
|
19
|
+
? Instances[C]
|
|
20
|
+
: Instance
|
|
21
|
+
: Instance;
|
|
22
|
+
|
|
23
|
+
type AddSolvedHead<Result, Head extends string | undefined> = [Result] extends [never]
|
|
24
|
+
? SolveHead<Head>
|
|
25
|
+
: Result | SolveHead<Head>;
|
|
26
|
+
|
|
27
|
+
type HeadBreak = ":" | "." | "#" | "[" | " ";
|
|
28
|
+
|
|
29
|
+
type ReadHead<
|
|
30
|
+
Head extends string | undefined = undefined,
|
|
31
|
+
Done extends boolean = false,
|
|
32
|
+
C extends string = "",
|
|
33
|
+
> = Done extends true
|
|
34
|
+
? [Head, Done]
|
|
35
|
+
: Head extends undefined
|
|
36
|
+
? Trim<C> extends ""
|
|
37
|
+
? [undefined, false]
|
|
38
|
+
: C extends HeadBreak
|
|
39
|
+
? ["", true]
|
|
40
|
+
: [C, false]
|
|
41
|
+
: C extends HeadBreak
|
|
42
|
+
? [Head, true]
|
|
43
|
+
: [`${Head}${C}`, false];
|
|
44
|
+
|
|
45
|
+
type SolveChars<
|
|
46
|
+
S extends string,
|
|
47
|
+
Head extends string | undefined = undefined,
|
|
48
|
+
Done extends boolean = false,
|
|
49
|
+
Result = never,
|
|
50
|
+
Depth extends Array<any> = [],
|
|
51
|
+
> = S extends `${infer C}${infer Rest}`
|
|
52
|
+
? Depth extends []
|
|
53
|
+
? C extends "("
|
|
54
|
+
? SolveChars<Rest, Head, Done, Result, [any]>
|
|
55
|
+
: C extends ","
|
|
56
|
+
? SolveChars<Rest, undefined, false, AddSolvedHead<Result, Head>, Depth>
|
|
57
|
+
: C extends ">"
|
|
58
|
+
? SolveChars<Rest, undefined, false, Result, Depth>
|
|
59
|
+
: ReadHead<Head, Done, C> extends [
|
|
60
|
+
infer NextHead extends string | undefined,
|
|
61
|
+
infer NextDone extends boolean,
|
|
62
|
+
]
|
|
63
|
+
? SolveChars<Rest, NextHead, NextDone, Result, Depth>
|
|
64
|
+
: never
|
|
65
|
+
: C extends "("
|
|
66
|
+
? SolveChars<Rest, Head, Done, Result, [...Depth, any]>
|
|
67
|
+
: C extends ")"
|
|
68
|
+
? SolveChars<Rest, Head, Done, Result, Depth extends [any, ...infer D] ? D : []>
|
|
69
|
+
: SolveChars<Rest, Head, Done, Result, Depth>
|
|
70
|
+
: AddSolvedHead<Result, Head>;
|
|
71
|
+
|
|
72
|
+
// Nested pseudo-classes can contain selector lists, so this path tracks only top-level
|
|
73
|
+
// separators while keeping the subject class from the current segment.
|
|
74
|
+
type SlowSolve<T extends string> = SolveChars<T>;
|
|
75
|
+
|
|
76
|
+
// Only the final combinator segment can determine the subject type.
|
|
77
|
+
type LastSegment<S extends string> = S extends `${string}>${infer R}` ? LastSegment<R> : S;
|
|
78
|
+
|
|
79
|
+
type CutAt<S extends string, D extends string> = S extends `${infer Prefix}${D}${string}` ? Prefix : S;
|
|
80
|
+
|
|
81
|
+
type LeadingClass<S extends string> = CutAt<CutAt<CutAt<CutAt<Trim<S>, ":">, ".">, "#">, " ">;
|
|
82
|
+
|
|
83
|
+
// Filters do not affect the subject class, but their values can contain selector separators.
|
|
84
|
+
type StripFiltersAndParens<S extends string> = S extends `${infer A}[${string}]${infer B}`
|
|
85
|
+
? StripFiltersAndParens<`${A}${B}`>
|
|
86
|
+
: S extends `${infer A}(${string})${infer B}`
|
|
87
|
+
? StripFiltersAndParens<`${A}${B}`>
|
|
88
|
+
: S;
|
|
89
|
+
|
|
90
|
+
type FastClause<S extends string> =
|
|
91
|
+
LeadingClass<LastSegment<S>> extends infer C extends keyof Instances ? Instances[C] : Instance;
|
|
92
|
+
|
|
93
|
+
type FastSolve<S extends string> = S extends `${infer A},${infer B}` ? FastClause<A> | FastSolve<B> : FastClause<S>;
|
|
94
|
+
|
|
95
|
+
type SolveUnquoted<S extends string> = S extends `${string}(${string}(${string})${string})${string}`
|
|
96
|
+
? SlowSolve<S>
|
|
97
|
+
: FastSolve<StripFiltersAndParens<S>>;
|
|
98
|
+
|
|
99
|
+
type StripQuotes<S extends string> = S extends `${infer A}'${string}'${infer B}` ? StripQuotes<`${A}${B}`> : S;
|
|
100
|
+
|
|
101
|
+
// Attribute values are not selector syntax, even when they contain ":" or ",".
|
|
102
|
+
type StripValidationGroups<S extends string> = S extends `${infer A}'${string}'${infer B}`
|
|
103
|
+
? StripValidationGroups<`${A}${B}`>
|
|
104
|
+
: S extends `${infer A}[${string}]${infer B}`
|
|
105
|
+
? StripValidationGroups<`${A}${B}`>
|
|
106
|
+
: S;
|
|
107
|
+
|
|
108
|
+
type SupportedPseudo = "not" | "has";
|
|
109
|
+
|
|
110
|
+
type CheckPseudos<S extends string> = S extends `${string}:${infer R}`
|
|
111
|
+
? R extends `${infer Name}(${infer Rest}`
|
|
112
|
+
? Name extends SupportedPseudo
|
|
113
|
+
? CheckPseudos<Rest>
|
|
114
|
+
: Name
|
|
115
|
+
: R // ':' not followed by 'name(' -> pseudo-classes require arguments
|
|
116
|
+
: never;
|
|
117
|
+
|
|
118
|
+
// The whole-empty selector "" is intentionally allowed.
|
|
119
|
+
type HasEmptyListItem<S extends string> = S extends `${string},${string}` ? CheckListItems<S> : false;
|
|
120
|
+
type CheckListItems<S extends string> = S extends `${infer A},${infer B}`
|
|
121
|
+
? Trim<A> extends ""
|
|
122
|
+
? true
|
|
123
|
+
: CheckListItems<B>
|
|
124
|
+
: Trim<S> extends ""
|
|
125
|
+
? true
|
|
126
|
+
: false;
|
|
127
|
+
|
|
128
|
+
type ValidateUnquoted<S extends string, Q extends string> = Q extends `${string}:${string}`
|
|
129
|
+
? CheckPseudos<Q> extends infer Bad
|
|
130
|
+
? [Bad] extends [never]
|
|
131
|
+
? HasEmptyListItem<Q> extends true
|
|
132
|
+
? `Invalid selector: empty selector in list (check for a stray or trailing comma)`
|
|
133
|
+
: S
|
|
134
|
+
: `Invalid selector: ':${Bad & string}' is not a supported pseudo-class (only ':not()' and ':has()' are allowed)`
|
|
135
|
+
: never
|
|
136
|
+
: Q extends `${string},${string}`
|
|
137
|
+
? HasEmptyListItem<Q> extends true
|
|
138
|
+
? `Invalid selector: empty selector in list (check for a stray or trailing comma)`
|
|
139
|
+
: S
|
|
140
|
+
: S;
|
|
141
|
+
|
|
142
|
+
export type ValidateSelector<S extends string> = string extends S
|
|
143
|
+
? S
|
|
144
|
+
: StripValidationGroups<S> extends infer Q extends string
|
|
145
|
+
? ValidateUnquoted<S, Q>
|
|
146
|
+
: never;
|
|
147
|
+
|
|
148
|
+
// Quoted values are stripped before solving so most selectors can stay on the cheaper path.
|
|
149
|
+
export type Solve<S extends string> = S extends `${string}'${string}`
|
|
150
|
+
? SolveUnquoted<StripQuotes<S>>
|
|
151
|
+
: SolveUnquoted<S>;
|
|
152
|
+
}
|