s2cfgtojson 4.4.0 → 5.0.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/Struct.mts +97 -2
- package/Struct.test.mts +8 -0
- package/enums.mts +13 -140
- package/package.json +1 -1
- package/readme.md +1 -1
- package/types.mts +17559 -3583
- package/utility-types.mts +1891 -0
package/Struct.mts
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
export * from "./types.mts";
|
|
2
2
|
export * from "./enums.mts";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
export type Internal =
|
|
5
|
+
| "__internal__"
|
|
6
|
+
| "fork"
|
|
7
|
+
| "removeNode"
|
|
8
|
+
| "addNode"
|
|
9
|
+
| "clone"
|
|
10
|
+
| "entries"
|
|
11
|
+
| "forEach"
|
|
12
|
+
| "filter"
|
|
13
|
+
| "map"
|
|
14
|
+
| "fromJson"
|
|
15
|
+
| "toJson"
|
|
16
|
+
| "toString"
|
|
17
|
+
| "fromString";
|
|
18
|
+
|
|
19
|
+
export interface DefaultEntries {
|
|
20
|
+
bpatch?: boolean;
|
|
21
|
+
bskipref?: boolean;
|
|
22
|
+
isArray?: boolean;
|
|
23
|
+
isRoot?: boolean;
|
|
24
|
+
rawName?: string;
|
|
25
|
+
refkey?: string | number;
|
|
26
|
+
refurl?: string;
|
|
27
|
+
useAsterisk?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type GetStructType<In> =
|
|
31
|
+
In extends Array<any>
|
|
32
|
+
? Struct & { [key: `${number}`]: GetStructType<In[typeof key]> }
|
|
33
|
+
: In extends Record<any, any>
|
|
34
|
+
? Struct & { [key in keyof In]: GetStructType<In[key]> }
|
|
35
|
+
: In extends string
|
|
36
|
+
? In
|
|
37
|
+
: In extends number
|
|
38
|
+
? number
|
|
39
|
+
: In extends boolean
|
|
40
|
+
? boolean
|
|
41
|
+
: In;
|
|
4
42
|
|
|
5
43
|
const TAB = " ";
|
|
6
44
|
const WILDCARD = "_wildcard";
|
|
@@ -345,7 +383,8 @@ export function createDynamicClassInstance<T extends Struct = Struct>(
|
|
|
345
383
|
rawName: string,
|
|
346
384
|
index?: number,
|
|
347
385
|
): T {
|
|
348
|
-
const
|
|
386
|
+
const parsedName = parseStructName(rawName) || `UnnamedStruct${index}`;
|
|
387
|
+
const name = makeSafeClassName(parsedName);
|
|
349
388
|
return new (new Function(
|
|
350
389
|
"parent",
|
|
351
390
|
"Refs",
|
|
@@ -492,6 +531,62 @@ function parseStructName(name: string): string {
|
|
|
492
531
|
.replace(/^_+/, "");
|
|
493
532
|
}
|
|
494
533
|
|
|
534
|
+
const RESERVED_IDENTIFIERS = new Set([
|
|
535
|
+
"break",
|
|
536
|
+
"case",
|
|
537
|
+
"catch",
|
|
538
|
+
"class",
|
|
539
|
+
"const",
|
|
540
|
+
"continue",
|
|
541
|
+
"debugger",
|
|
542
|
+
"default",
|
|
543
|
+
"delete",
|
|
544
|
+
"do",
|
|
545
|
+
"else",
|
|
546
|
+
"export",
|
|
547
|
+
"extends",
|
|
548
|
+
"finally",
|
|
549
|
+
"for",
|
|
550
|
+
"function",
|
|
551
|
+
"if",
|
|
552
|
+
"import",
|
|
553
|
+
"in",
|
|
554
|
+
"instanceof",
|
|
555
|
+
"new",
|
|
556
|
+
"return",
|
|
557
|
+
"super",
|
|
558
|
+
"switch",
|
|
559
|
+
"this",
|
|
560
|
+
"throw",
|
|
561
|
+
"try",
|
|
562
|
+
"typeof",
|
|
563
|
+
"var",
|
|
564
|
+
"void",
|
|
565
|
+
"while",
|
|
566
|
+
"with",
|
|
567
|
+
"yield",
|
|
568
|
+
"enum",
|
|
569
|
+
"await",
|
|
570
|
+
"implements",
|
|
571
|
+
"package",
|
|
572
|
+
"protected",
|
|
573
|
+
"static",
|
|
574
|
+
"interface",
|
|
575
|
+
"private",
|
|
576
|
+
"public",
|
|
577
|
+
"let",
|
|
578
|
+
]);
|
|
579
|
+
|
|
580
|
+
function makeSafeClassName(name: string): string {
|
|
581
|
+
if (
|
|
582
|
+
!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) ||
|
|
583
|
+
RESERVED_IDENTIFIERS.has(name)
|
|
584
|
+
) {
|
|
585
|
+
return `_${name}`;
|
|
586
|
+
}
|
|
587
|
+
return name;
|
|
588
|
+
}
|
|
589
|
+
|
|
495
590
|
function maybeMinifyKey(key: string, minify: boolean) {
|
|
496
591
|
return minify &&
|
|
497
592
|
(INTERNAL_PROPS.has(key as any) || REF_INTERNAL_PROPS.has(key as any))
|
package/Struct.test.mts
CHANGED
|
@@ -91,6 +91,14 @@ struct.end`,
|
|
|
91
91
|
`DynamicClass : struct.begin\n\nstruct.end`,
|
|
92
92
|
);
|
|
93
93
|
});
|
|
94
|
+
|
|
95
|
+
test("reserved keyword name", () => {
|
|
96
|
+
const instance = createDynamicClassInstance("default");
|
|
97
|
+
instance.__internal__.isRoot = true;
|
|
98
|
+
|
|
99
|
+
expect(instance).toBeInstanceOf(Struct);
|
|
100
|
+
expect(instance.toString()).toBe(`default : struct.begin\n\nstruct.end`);
|
|
101
|
+
});
|
|
94
102
|
});
|
|
95
103
|
|
|
96
104
|
describe("fromString()", () => {
|
package/enums.mts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
// noinspection JSUnusedGlobalSymbols
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
Caliber,
|
|
5
|
+
Experienced,
|
|
6
|
+
Master,
|
|
7
|
+
Newbie,
|
|
8
|
+
Permutations3,
|
|
9
|
+
Veteran,
|
|
10
|
+
} from "./utility-types.mts";
|
|
11
|
+
|
|
12
|
+
export type PanningRule = `PanningRule::${
|
|
13
|
+
| "PanningRule_Headphones"
|
|
14
|
+
| "PanningRule_Speakers"}`;
|
|
15
|
+
|
|
3
16
|
export type EAIConstraintType = `EAIConstraintType::${"PrepareForEmission"}`;
|
|
4
17
|
|
|
5
18
|
export type EAIMovementPose = `EAIMovementPose::${"Stand"}`;
|
|
@@ -76,23 +89,6 @@ export type EAimAssistWeightType = `EAimAssistWeightType::${
|
|
|
76
89
|
| "Angle"
|
|
77
90
|
| "DistanceFromApex"}`;
|
|
78
91
|
|
|
79
|
-
export type Caliber =
|
|
80
|
-
| "A012"
|
|
81
|
-
| "A045"
|
|
82
|
-
| "A545"
|
|
83
|
-
| "A556"
|
|
84
|
-
| "A762"
|
|
85
|
-
| "A762NATO"
|
|
86
|
-
| "A762Sniper"
|
|
87
|
-
| "A918"
|
|
88
|
-
| "A919"
|
|
89
|
-
| "A939"
|
|
90
|
-
| "AGA"
|
|
91
|
-
| "AHEDP"
|
|
92
|
-
| "APG7V"
|
|
93
|
-
| "AVOG"
|
|
94
|
-
| "None";
|
|
95
|
-
|
|
96
92
|
export type EAmmoCaliber = `EAmmoCaliber::${Caliber}`;
|
|
97
93
|
|
|
98
94
|
export type EAmmoType = `EAmmoType::${
|
|
@@ -1610,25 +1606,6 @@ export type ERadiationPreset = `ERadiationPreset::${
|
|
|
1610
1606
|
| "Strong"
|
|
1611
1607
|
| "Topaz"}`;
|
|
1612
1608
|
|
|
1613
|
-
export type Rank = "Newbie" | "Experienced" | "Veteran" | "Master";
|
|
1614
|
-
type Newbie = "ERank::Newbie";
|
|
1615
|
-
type Experienced = "ERank::Experienced";
|
|
1616
|
-
type Veteran = "ERank::Veteran";
|
|
1617
|
-
type Master = "ERank::Master";
|
|
1618
|
-
type Permutations2<A, B> = A extends string
|
|
1619
|
-
? B extends string
|
|
1620
|
-
? A | B | `${A}, ${B}`
|
|
1621
|
-
: A
|
|
1622
|
-
: never;
|
|
1623
|
-
|
|
1624
|
-
type Permutations3<A, B, C> = A extends string
|
|
1625
|
-
? B extends string
|
|
1626
|
-
? C extends string
|
|
1627
|
-
? Permutations2<A, B> | Permutations2<B, C> | `${A}, ${B}, ${C}`
|
|
1628
|
-
: Permutations2<A, B>
|
|
1629
|
-
: A
|
|
1630
|
-
: never;
|
|
1631
|
-
|
|
1632
1609
|
export type ERank =
|
|
1633
1610
|
| Permutations3<Newbie, Experienced, Veteran>
|
|
1634
1611
|
| Permutations3<Experienced, Veteran, Master>
|
|
@@ -1969,10 +1946,6 @@ export type EZombificationType = `EZombificationType::${
|
|
|
1969
1946
|
| "AliveHuman"
|
|
1970
1947
|
| "CorpseHuman"}`;
|
|
1971
1948
|
|
|
1972
|
-
export type PanningRule = `PanningRule::${
|
|
1973
|
-
| "PanningRule_Headphones"
|
|
1974
|
-
| "PanningRule_Speakers"}`;
|
|
1975
|
-
|
|
1976
1949
|
export type ESoundEffectSubtype = `ESoundEffectSubtype::${
|
|
1977
1950
|
| "PlaySoundAttached"
|
|
1978
1951
|
| "SetParameter"
|
|
@@ -1995,106 +1968,6 @@ export type EActionType = `EActionType::${
|
|
|
1995
1968
|
| "Vault"
|
|
1996
1969
|
| "ThrowItem"}`;
|
|
1997
1970
|
|
|
1998
|
-
export type Reactions =
|
|
1999
|
-
| "Enemy"
|
|
2000
|
-
| "Disaffection"
|
|
2001
|
-
| "Neutral"
|
|
2002
|
-
| "Friend"
|
|
2003
|
-
| "Self";
|
|
2004
|
-
|
|
2005
|
-
export type Factions =
|
|
2006
|
-
| ""
|
|
2007
|
-
| "Humanoid"
|
|
2008
|
-
| "Player"
|
|
2009
|
-
| "Bandits"
|
|
2010
|
-
| "Monolith"
|
|
2011
|
-
| "FreeStalkers"
|
|
2012
|
-
| "Army"
|
|
2013
|
-
| "Duty"
|
|
2014
|
-
| "Freedom"
|
|
2015
|
-
| "Varta"
|
|
2016
|
-
| "Neutrals"
|
|
2017
|
-
| "Militaries"
|
|
2018
|
-
| "Noon"
|
|
2019
|
-
| "Scientists"
|
|
2020
|
-
| "Mercenaries"
|
|
2021
|
-
| "Flame"
|
|
2022
|
-
| "Law"
|
|
2023
|
-
| "Spark"
|
|
2024
|
-
| "Corpus"
|
|
2025
|
-
| "WildBandits"
|
|
2026
|
-
| "GarmataMilitaries"
|
|
2027
|
-
| "SphereMilitaries"
|
|
2028
|
-
| "NeutralBandits"
|
|
2029
|
-
| "VaranBandits"
|
|
2030
|
-
| "RooseveltBandits"
|
|
2031
|
-
| "ShahBandits"
|
|
2032
|
-
| "LokotBandits"
|
|
2033
|
-
| "DepoBandits"
|
|
2034
|
-
| "DepoVictims"
|
|
2035
|
-
| "DocentBandits"
|
|
2036
|
-
| "VaranStashBandits"
|
|
2037
|
-
| "Diggers"
|
|
2038
|
-
| "KosakBandits"
|
|
2039
|
-
| "AzimutVarta"
|
|
2040
|
-
| "UdavMercenaries"
|
|
2041
|
-
| "SafariHunters"
|
|
2042
|
-
| "AzimuthMilitaries"
|
|
2043
|
-
| "SultanBandits"
|
|
2044
|
-
| "ShevchenkoStalkers"
|
|
2045
|
-
| "VartaLesnichestvo"
|
|
2046
|
-
| "SparkLesnichestvo"
|
|
2047
|
-
| "IkarVarta"
|
|
2048
|
-
| "KabanBandits"
|
|
2049
|
-
| "CrazyGuardians"
|
|
2050
|
-
| "ArenaEnemy"
|
|
2051
|
-
| "ArenaFriend"
|
|
2052
|
-
| "DrozdMilitaries"
|
|
2053
|
-
| "EnemyVarta"
|
|
2054
|
-
| "NeutralMSOP"
|
|
2055
|
-
| "YanovCorpus"
|
|
2056
|
-
| "MoleStalkers"
|
|
2057
|
-
| "Mutant"
|
|
2058
|
-
| "Controller"
|
|
2059
|
-
| "Poltergeist"
|
|
2060
|
-
| "Bloodsucker"
|
|
2061
|
-
| "Zombie"
|
|
2062
|
-
| "Chimera"
|
|
2063
|
-
| "Burer"
|
|
2064
|
-
| "Pseudogiant"
|
|
2065
|
-
| "Anamorph"
|
|
2066
|
-
| "Sinister"
|
|
2067
|
-
| "Pseudobear"
|
|
2068
|
-
| "Snork"
|
|
2069
|
-
| "Pseudodog"
|
|
2070
|
-
| "Boar"
|
|
2071
|
-
| "Flesh"
|
|
2072
|
-
| "Beaver"
|
|
2073
|
-
| "Ratwolf"
|
|
2074
|
-
| "Deer"
|
|
2075
|
-
| "Rat"
|
|
2076
|
-
| "Tushkan"
|
|
2077
|
-
| "Stickman"
|
|
2078
|
-
| "Blinddog"
|
|
2079
|
-
| "Bayun"
|
|
2080
|
-
| "CorpusStorm"
|
|
2081
|
-
| "DocileLabMutants"
|
|
2082
|
-
| "VartaSIRCAA"
|
|
2083
|
-
| "YantarZombie"
|
|
2084
|
-
| "FriendlyBlinddog"
|
|
2085
|
-
| "Lessy"
|
|
2086
|
-
| "AlliedMutants"
|
|
2087
|
-
| "NoahLesya"
|
|
2088
|
-
| "KlenMercenaries"
|
|
2089
|
-
| "SIRCAA_Scientist"
|
|
2090
|
-
| "MALACHITE_Scientist"
|
|
2091
|
-
| "NoonFaustians"
|
|
2092
|
-
| "SQ89_SidorMercs"
|
|
2093
|
-
| "ScarBoss_Faction"
|
|
2094
|
-
| "KorshunovBoss_Faction"
|
|
2095
|
-
| "StrelokBoss_Faction"
|
|
2096
|
-
| "FaustBoss_Faction";
|
|
2097
|
-
|
|
2098
1971
|
export type EObjBoolParams = `EObjBoolParams::${
|
|
2099
1972
|
| "IsOffsetAimingEnabled"
|
|
2100
1973
|
| "IsNightVisionEnabled"
|
package/package.json
CHANGED
package/readme.md
CHANGED