koffing 1.0.0 → 2.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/dist/index.cjs ADDED
@@ -0,0 +1,441 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_data = require("./data-CP51LAc9.cjs");
3
+ //#region src/parse.ts
4
+ const stats$1 = {
5
+ hp: "hp",
6
+ atk: "atk",
7
+ attack: "atk",
8
+ def: "def",
9
+ defense: "def",
10
+ spa: "spa",
11
+ spatk: "spa",
12
+ specialattack: "spa",
13
+ spd: "spd",
14
+ spdef: "spd",
15
+ specialdefense: "spd",
16
+ spe: "spe",
17
+ speed: "spe"
18
+ };
19
+ const numericFields = /* @__PURE__ */ new Map([
20
+ ["level", "level"],
21
+ ["happiness", "happiness"],
22
+ ["friendship", "happiness"],
23
+ ["dynamax level", "dynamaxLevel"]
24
+ ]);
25
+ const stringFields = /* @__PURE__ */ new Map([
26
+ ["ability", "ability"],
27
+ ["trait", "ability"],
28
+ ["item", "item"],
29
+ ["nickname", "name"],
30
+ ["species", "species"],
31
+ ["tera type", "teraType"],
32
+ ["hidden power", "hpType"],
33
+ ["pokeball", "pokeball"],
34
+ ["ball", "pokeball"]
35
+ ]);
36
+ const natureStats = [
37
+ "atk",
38
+ "def",
39
+ "spe",
40
+ "spa",
41
+ "spd"
42
+ ];
43
+ const natures = [
44
+ [
45
+ "Hardy",
46
+ "Lonely",
47
+ "Brave",
48
+ "Adamant",
49
+ "Naughty"
50
+ ],
51
+ [
52
+ "Bold",
53
+ "Docile",
54
+ "Relaxed",
55
+ "Impish",
56
+ "Lax"
57
+ ],
58
+ [
59
+ "Timid",
60
+ "Hasty",
61
+ "Serious",
62
+ "Jolly",
63
+ "Naive"
64
+ ],
65
+ [
66
+ "Modest",
67
+ "Mild",
68
+ "Quiet",
69
+ "Bashful",
70
+ "Rash"
71
+ ],
72
+ [
73
+ "Calm",
74
+ "Gentle",
75
+ "Sassy",
76
+ "Careful",
77
+ "Quirky"
78
+ ]
79
+ ];
80
+ const controlCharacters = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f\u2028\u2029]/;
81
+ /** Parse Showdown text without silently clamping values or dropping extra moves. */
82
+ function parse(input, options = {}) {
83
+ const limits = require_data.resolveLimits(options);
84
+ require_data.checkInput(input, limits);
85
+ const hasControls = controlCharacters.test(input);
86
+ const hasTabs = input.includes(" ");
87
+ const hasPipes = input.includes("|");
88
+ const teams = [];
89
+ const diagnostics = [];
90
+ let team;
91
+ let pokemon;
92
+ let count = 0;
93
+ let seen = /* @__PURE__ */ new Set();
94
+ let explicitHpType = false;
95
+ let explicitHappiness = false;
96
+ let explicitNature = false;
97
+ let increased;
98
+ let decreased;
99
+ let lineNumber = 0;
100
+ const warn = (code, message) => {
101
+ require_data.report(diagnostics, {
102
+ code,
103
+ message,
104
+ severity: "warning",
105
+ line: lineNumber
106
+ }, limits);
107
+ };
108
+ const duplicate = (key) => {
109
+ if (seen.has(key)) warn("duplicate-field", `Repeated ${key}; the last value takes precedence`);
110
+ seen.add(key);
111
+ };
112
+ const addTeam = (value) => {
113
+ if (teams.length >= limits.maxTeams) require_data.fail("team-limit", "Too many teams", lineNumber);
114
+ teams.push(value);
115
+ team = value;
116
+ };
117
+ const move = (value) => {
118
+ if (!pokemon) return;
119
+ if (!value) {
120
+ warn("invalid-move", "Move name is empty");
121
+ return;
122
+ }
123
+ if (pokemon.moves.length >= limits.maxMoves) require_data.fail("move-limit", "Too many moves", lineNumber);
124
+ const hidden = /^Hidden Power\s*\[([^\]]+)\]$/i.exec(value);
125
+ if (hidden) {
126
+ value = `Hidden Power ${hidden[1].trim()}`;
127
+ if (!explicitHpType) pokemon.hpType = hidden[1].trim();
128
+ }
129
+ pokemon.moves.push(value);
130
+ if (pokemon.moves.length === 5) warn("move-count", "More than four moves; all moves were preserved");
131
+ if (/^Frustration$/i.test(value) && !explicitHappiness) pokemon.happiness = 0;
132
+ };
133
+ let nextCR = input.indexOf("\r");
134
+ let nextLF = input.indexOf("\n");
135
+ for (let start = 0; start <= input.length;) {
136
+ let end = nextLF < 0 ? input.length : nextLF;
137
+ if (nextCR >= 0 && nextCR < end) end = nextCR;
138
+ lineNumber++;
139
+ if (end - start > limits.maxLineLength) require_data.fail("line-limit", "Line is too long", lineNumber);
140
+ const rawLine = input.slice(start, end);
141
+ const line = (hasTabs ? rawLine.replace(/\t/g, " ") : rawLine).trim();
142
+ const separator = input[end];
143
+ start = end + (separator === "\r" && input[end + 1] === "\n" ? 2 : 1);
144
+ if (nextCR >= 0 && nextCR < start) nextCR = input.indexOf("\r", start);
145
+ if (nextLF >= 0 && nextLF < start) nextLF = input.indexOf("\n", start);
146
+ if (hasControls && controlCharacters.test(rawLine)) {
147
+ warn("invalid-character", "Control characters are not allowed");
148
+ continue;
149
+ }
150
+ if (!line || /^-{3,}$/.test(line)) {
151
+ pokemon = void 0;
152
+ continue;
153
+ }
154
+ if (hasPipes && line.includes("|")) require_data.fail("unsupported-packed-format", "Packed teams are not supported; import Showdown text instead", lineNumber);
155
+ if (pokemon && (line[0] === "-" || line[0] === "~")) {
156
+ move(line.slice(1).trimStart());
157
+ continue;
158
+ }
159
+ const header = line[0] === "=" ? /^===\s*(.*?)\s*===$/.exec(line) : null;
160
+ if (header) {
161
+ const value = { pokemon: [] };
162
+ let title = header[1].trim();
163
+ const format = /^\[([^\]]+)\]\s*/.exec(title);
164
+ if (format) {
165
+ value.format = format[1].trim();
166
+ title = title.slice(format[0].length);
167
+ }
168
+ const slash = title.lastIndexOf("/");
169
+ if (slash >= 0) {
170
+ value.folder = title.slice(0, slash).trim();
171
+ title = title.slice(slash + 1).trim();
172
+ }
173
+ if (title) value.name = title;
174
+ addTeam(value);
175
+ pokemon = void 0;
176
+ continue;
177
+ }
178
+ if (line.startsWith("===")) {
179
+ warn("invalid-header", "Malformed team header");
180
+ pokemon = void 0;
181
+ continue;
182
+ }
183
+ const colon = line.indexOf(":");
184
+ const hasDetail = colon > 0;
185
+ const nature = hasDetail || line.includes("@") || !/\sNature$/i.test(line) ? null : /^(.*?)\s+Nature$/i.exec(line);
186
+ const bare = !hasDetail && /^(Shiny|Gigantamax)$/i.test(line);
187
+ if (!pokemon) {
188
+ const typeNullHeader = hasDetail && /^(?:[^:]*\()?Type: Null\)?(?:\s+\([MFN]\))?(?:\s+\[[^\]]+\])?(?:\s+@\s+.+)?$/i.test(line);
189
+ if (line.startsWith("-") || hasDetail && !typeNullHeader || nature || bare) {
190
+ warn("orphan-detail", "Pokémon detail appears before a Pokémon header");
191
+ continue;
192
+ }
193
+ let identity = line;
194
+ let item;
195
+ const at = identity.lastIndexOf(" @ ");
196
+ if (at >= 0) {
197
+ item = identity.slice(at + 3).trim();
198
+ identity = identity.slice(0, at).trim();
199
+ }
200
+ let ability;
201
+ const bracket = /\s*\[([^\]]+)\]$/.exec(identity);
202
+ if (bracket) {
203
+ ability = bracket[1].trim();
204
+ identity = identity.slice(0, bracket.index).trim();
205
+ }
206
+ let gender;
207
+ const sex = /\s*\(([MFN])\)$/.exec(identity);
208
+ if (sex) {
209
+ gender = sex[1];
210
+ identity = identity.slice(0, sex.index).trim();
211
+ }
212
+ const named = /^(.*?)\s*\(([^()]+)\)$/.exec(identity);
213
+ const species = (named ? named[2] : identity).trim();
214
+ if (!species || /[\[\]@()=]/.test(species)) {
215
+ warn("invalid-header", "Malformed Pokémon header");
216
+ continue;
217
+ }
218
+ if (count >= limits.maxPokemon) require_data.fail("pokemon-limit", "Too many Pokémon", lineNumber);
219
+ count++;
220
+ pokemon = {
221
+ species,
222
+ moves: []
223
+ };
224
+ if (named?.[1]?.trim()) pokemon.name = named[1].trim();
225
+ if (item && !/^No Item$/i.test(item)) pokemon.item = item;
226
+ if (ability) pokemon.ability = ability;
227
+ if (gender) pokemon.gender = gender;
228
+ if (!team) addTeam({ pokemon: [] });
229
+ team.pokemon.push(pokemon);
230
+ seen.clear();
231
+ seen.add("species");
232
+ if (pokemon.name !== void 0) seen.add("name");
233
+ if (pokemon.item !== void 0) seen.add("item");
234
+ if (pokemon.ability !== void 0) seen.add("ability");
235
+ if (pokemon.gender !== void 0) seen.add("gender");
236
+ explicitHpType = false;
237
+ explicitHappiness = false;
238
+ explicitNature = false;
239
+ increased = void 0;
240
+ decreased = void 0;
241
+ continue;
242
+ }
243
+ const bracketDetail = line[0] === "[" ? /^\[([^\]]+)\](?:\s*@\s*(.+))?$/.exec(line) : null;
244
+ if (bracketDetail) {
245
+ duplicate("ability");
246
+ pokemon.ability = bracketDetail[1].trim();
247
+ if (bracketDetail[2]) {
248
+ duplicate("item");
249
+ if (/^No Item$/i.test(bracketDetail[2])) delete pokemon.item;
250
+ else pokemon.item = bracketDetail[2].trim();
251
+ }
252
+ continue;
253
+ }
254
+ if (nature) {
255
+ duplicate("nature");
256
+ pokemon.nature = nature[1].trim();
257
+ explicitNature = true;
258
+ continue;
259
+ }
260
+ const key = (hasDetail ? line.slice(0, colon).trim() : bare ? line : "").toLowerCase();
261
+ const value = hasDetail ? line.slice(colon + 1).trim() : "Yes";
262
+ if (key === "move") {
263
+ move(value);
264
+ continue;
265
+ }
266
+ if (key === "evs" || key === "ivs") {
267
+ duplicate(key);
268
+ const values = {};
269
+ let conflictingModifiers = false;
270
+ if (key === "evs") {
271
+ increased = void 0;
272
+ decreased = void 0;
273
+ if (!explicitNature) delete pokemon.nature;
274
+ }
275
+ for (const entry of value.split("/")) {
276
+ const match = /^\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)([+-]?)\s+([a-z .]+)\s*$/i.exec(entry);
277
+ const statName = match?.[3].toLowerCase().replace(/[ .]/g, "");
278
+ const stat = statName && Object.hasOwn(stats$1, statName) ? stats$1[statName] : void 0;
279
+ if (!match || !stat || !Number.isFinite(Number(match[1]))) {
280
+ warn("invalid-stat", `Invalid ${key} entry: ${entry.trim()}`);
281
+ continue;
282
+ }
283
+ if (values[stat] !== void 0) warn("duplicate-stat", `Repeated ${stat}; the last value takes precedence`);
284
+ values[stat] = Number(match[1]);
285
+ const max = key === "ivs" ? 31 : 255;
286
+ if (!Number.isInteger(values[stat]) || values[stat] < 0 || values[stat] > max) warn("stat-range", `${stat} is outside the traditional ${key} range; value preserved`);
287
+ if (match[2]) {
288
+ if (key !== "evs" || stat === "hp") warn("invalid-nature-modifier", "Nature modifiers apply only to non-HP EVs");
289
+ else if (match[2] === "+") {
290
+ if (increased) {
291
+ conflictingModifiers = true;
292
+ warn("invalid-nature-modifier", "More than one increased stat");
293
+ }
294
+ increased = stat;
295
+ } else {
296
+ if (decreased) {
297
+ conflictingModifiers = true;
298
+ warn("invalid-nature-modifier", "More than one decreased stat");
299
+ }
300
+ decreased = stat;
301
+ }
302
+ }
303
+ }
304
+ pokemon[key] = values;
305
+ if (key === "evs" && Object.values(values).reduce((sum, number) => sum + number, 0) > 510) warn("ev-total", "EV total exceeds 510; values preserved");
306
+ if (key === "evs" && increased && increased === decreased) {
307
+ conflictingModifiers = true;
308
+ warn("invalid-nature-modifier", "The same stat cannot be increased and decreased");
309
+ }
310
+ if (key === "evs" && !explicitNature && !conflictingModifiers && increased && decreased) pokemon.nature = natures[natureStats.indexOf(increased)][natureStats.indexOf(decreased)];
311
+ continue;
312
+ }
313
+ const numberKey = numericFields.get(key);
314
+ if (numberKey) {
315
+ duplicate(numberKey);
316
+ const number = Number(value);
317
+ if (!value || !Number.isFinite(number)) {
318
+ warn("invalid-number", `Invalid ${key}`);
319
+ continue;
320
+ }
321
+ pokemon[numberKey] = number;
322
+ if (numberKey === "happiness") explicitHappiness = true;
323
+ const min = numberKey === "level" ? 1 : 0;
324
+ const max = numberKey === "level" ? 100 : numberKey === "happiness" ? 255 : 10;
325
+ if (!Number.isInteger(number) || number < min || number > max) warn("number-range", `${key} is outside its traditional range; value preserved`);
326
+ continue;
327
+ }
328
+ if (key === "shiny" || key === "gigantamax") {
329
+ duplicate(key);
330
+ if (!/^(yes|no|true|false)$/i.test(value)) warn("invalid-boolean", `Invalid ${key}`);
331
+ else pokemon[key] = /^(yes|true)$/i.test(value);
332
+ continue;
333
+ }
334
+ if (key === "gender") {
335
+ duplicate("gender");
336
+ if (value === "M" || value === "F" || value === "N" || value === "") pokemon.gender = value;
337
+ else warn("invalid-gender", "Gender must be M, F, N or empty");
338
+ continue;
339
+ }
340
+ const stringKey = stringFields.get(key);
341
+ if (stringKey) {
342
+ duplicate(stringKey);
343
+ if (!value) {
344
+ warn("empty-field", `Empty ${key}`);
345
+ continue;
346
+ }
347
+ if (stringKey === "item" && /^No Item$/i.test(value)) delete pokemon.item;
348
+ else pokemon[stringKey] = value;
349
+ if (stringKey === "hpType") explicitHpType = true;
350
+ continue;
351
+ }
352
+ warn("unknown-line", `Unrecognized line: ${line}`);
353
+ }
354
+ require_data.finish(diagnostics, options);
355
+ return {
356
+ teams,
357
+ diagnostics
358
+ };
359
+ }
360
+ //#endregion
361
+ //#region src/serialize.ts
362
+ const stats = [
363
+ ["hp", "HP"],
364
+ ["atk", "Atk"],
365
+ ["def", "Def"],
366
+ ["spa", "SpA"],
367
+ ["spd", "SpD"],
368
+ ["spe", "Spe"]
369
+ ];
370
+ function decimal(value) {
371
+ const source = String(value);
372
+ if (!/[eE]/u.test(source)) return source;
373
+ const [mantissa, exponentText] = source.split(/[eE]/u);
374
+ const negative = mantissa.startsWith("-");
375
+ const [whole, fraction = ""] = (negative ? mantissa.slice(1) : mantissa).split(".");
376
+ const digits = whole + fraction;
377
+ const point = whole.length + Number(exponentText);
378
+ const expanded = point <= 0 ? `0.${"0".repeat(-point)}${digits}` : point >= digits.length ? `${digits}${"0".repeat(point - digits.length)}` : `${digits.slice(0, point)}.${digits.slice(point)}`;
379
+ return `${negative ? "-" : ""}${expanded}`;
380
+ }
381
+ function serializeSet(set) {
382
+ let title = set.name ? `${set.name} (${set.species})` : set.species;
383
+ if (set.gender === "M" || set.gender === "F") title += ` (${set.gender})`;
384
+ if (set.item) title += ` @ ${set.item}`;
385
+ let output = title;
386
+ const append = (label, value) => {
387
+ if (value !== void 0 && (typeof value !== "number" || Number.isFinite(value))) output += `\n${label}: ${value}`;
388
+ };
389
+ append("Ability", set.ability);
390
+ append("Level", set.level);
391
+ if (set.gender === "N" || set.gender === "") append("Gender", set.gender);
392
+ if (set.shiny !== void 0) append("Shiny", set.shiny ? "Yes" : "No");
393
+ append("Happiness", set.happiness);
394
+ append("Pokeball", set.pokeball);
395
+ append("Hidden Power", set.hpType);
396
+ append("Dynamax Level", set.dynamaxLevel);
397
+ if (set.gigantamax !== void 0) append("Gigantamax", set.gigantamax ? "Yes" : "No");
398
+ append("Tera Type", set.teraType);
399
+ const appendStats = (label, values) => {
400
+ if (values === void 0) return;
401
+ let entries = "";
402
+ for (const [key, name] of stats) {
403
+ const value = values[key];
404
+ if (value !== void 0 && Number.isFinite(value)) {
405
+ if (entries) entries += " / ";
406
+ entries += `${decimal(value)} ${name}`;
407
+ }
408
+ }
409
+ if (entries) append(label, entries);
410
+ };
411
+ appendStats("EVs", set.evs);
412
+ if (set.nature) output += `\n${set.nature} Nature`;
413
+ appendStats("IVs", set.ivs);
414
+ for (const move of set.moves) {
415
+ const hidden = /^Hidden Power ([a-z]+)$/iu.exec(move);
416
+ output += `\n- ${hidden ? `Hidden Power [${hidden[1]}]` : move}`;
417
+ }
418
+ return output;
419
+ }
420
+ /** Format trusted typed sets, like Showdown. Use parseJSON separately for untrusted data. */
421
+ function exportTeam(pokemon) {
422
+ return pokemon.map(serializeSet).join("\n\n");
423
+ }
424
+ /** Collection export always includes headers, preserving team boundaries. */
425
+ function exportTeams(teams) {
426
+ return teams.map((team) => {
427
+ const metadata = `${team.format ? `[${team.format}] ` : ""}${team.folder ? `${team.folder}/` : ""}${team.name ?? ""}`;
428
+ const body = team.pokemon.map(serializeSet).join("\n\n");
429
+ if (teams.length === 1 && !metadata && body) return body;
430
+ return `=== ${metadata} ===${body ? `\n\n${body}` : ""}`;
431
+ }).join("\n\n");
432
+ }
433
+ //#endregion
434
+ exports.DEFAULT_LIMITS = require_data.DEFAULT_LIMITS;
435
+ exports.KoffingError = require_data.KoffingError;
436
+ exports.exportTeam = exportTeam;
437
+ exports.exportTeams = exportTeams;
438
+ exports.parse = parse;
439
+ exports.parseJSON = require_data.parseJSON;
440
+ exports.sanitizeTeam = require_data.sanitizeTeam;
441
+ exports.validateTeam = require_data.validateTeam;
@@ -0,0 +1,29 @@
1
+ import { a as PokemonSet, c as Stats, i as ParseResult, l as Team, n as Limits, o as SanitizeOptions, r as Options, s as StatID, t as Diagnostic } from "./types-BVzP_Ko4.cjs";
2
+ //#region src/parse.d.ts
3
+ /** Parse Showdown text without silently clamping values or dropping extra moves. */
4
+ export declare function parse(input: string, options?: Options): ParseResult;
5
+ //#endregion
6
+ //#region src/data.d.ts
7
+ /** Decode and copy known data only. Shape errors are fatal; unknown fields are diagnosed. */
8
+ export declare function parseJSON(input: unknown, options?: Options): ParseResult;
9
+ export declare function validateTeam(pokemon: readonly PokemonSet[], options?: Options): Diagnostic[];
10
+ /** Explicit, deterministic traditional-range sanitization; never mutates its input. */
11
+ export declare function sanitizeTeam(pokemon: readonly PokemonSet[], options?: SanitizeOptions): {
12
+ pokemon: PokemonSet[];
13
+ diagnostics: Diagnostic[];
14
+ };
15
+ //#endregion
16
+ //#region src/serialize.d.ts
17
+ /** Format trusted typed sets, like Showdown. Use parseJSON separately for untrusted data. */
18
+ export declare function exportTeam(pokemon: readonly PokemonSet[]): string;
19
+ /** Collection export always includes headers, preserving team boundaries. */
20
+ export declare function exportTeams(teams: readonly Team[]): string;
21
+ //#endregion
22
+ //#region src/limits.d.ts
23
+ export declare const DEFAULT_LIMITS: Readonly<Limits>;
24
+ export declare class KoffingError extends Error {
25
+ readonly diagnostics: Diagnostic[];
26
+ constructor(message: string, diagnostics: Diagnostic[]);
27
+ }
28
+ //#endregion
29
+ export type { Diagnostic, Limits, Options, ParseResult, PokemonSet, SanitizeOptions, StatID, Stats, Team };
package/dist/index.d.ts CHANGED
@@ -1,106 +1,29 @@
1
- type PokemonStats = {
2
- hp: number;
3
- atk: number;
4
- def: number;
5
- spa: number;
6
- spd: number;
7
- spe: number;
1
+ import { a as PokemonSet, c as Stats, i as ParseResult, l as Team, n as Limits, o as SanitizeOptions, r as Options, s as StatID, t as Diagnostic } from "./types-BVzP_Ko4.js";
2
+ //#region src/parse.d.ts
3
+ /** Parse Showdown text without silently clamping values or dropping extra moves. */
4
+ export declare function parse(input: string, options?: Options): ParseResult;
5
+ //#endregion
6
+ //#region src/data.d.ts
7
+ /** Decode and copy known data only. Shape errors are fatal; unknown fields are diagnosed. */
8
+ export declare function parseJSON(input: unknown, options?: Options): ParseResult;
9
+ export declare function validateTeam(pokemon: readonly PokemonSet[], options?: Options): Diagnostic[];
10
+ /** Explicit, deterministic traditional-range sanitization; never mutates its input. */
11
+ export declare function sanitizeTeam(pokemon: readonly PokemonSet[], options?: SanitizeOptions): {
12
+ pokemon: PokemonSet[];
13
+ diagnostics: Diagnostic[];
8
14
  };
9
- type PokemonGender = 'M' | 'F';
10
- declare class Pokemon {
11
- name: string | undefined;
12
- nickname: string | undefined;
13
- gender: PokemonGender | undefined;
14
- item: string | undefined;
15
- pokeball: string | undefined;
16
- ability: string | undefined;
17
- level: number | undefined;
18
- shiny: boolean | undefined;
19
- happiness: number | undefined;
20
- nature: string | undefined;
21
- evs: PokemonStats | undefined;
22
- ivs: PokemonStats | undefined;
23
- dynamaxLevel: number | undefined;
24
- gigantamax: boolean | undefined;
25
- teraType: string | undefined;
26
- moves: string[];
27
- static fromObject(obj: Pokemon | Record<string, any>): Pokemon;
28
- toJson(indentation?: number): string;
29
- toShowdown(): string;
30
- toString(): string;
15
+ //#endregion
16
+ //#region src/serialize.d.ts
17
+ /** Format trusted typed sets, like Showdown. Use parseJSON separately for untrusted data. */
18
+ export declare function exportTeam(pokemon: readonly PokemonSet[]): string;
19
+ /** Collection export always includes headers, preserving team boundaries. */
20
+ export declare function exportTeams(teams: readonly Team[]): string;
21
+ //#endregion
22
+ //#region src/limits.d.ts
23
+ export declare const DEFAULT_LIMITS: Readonly<Limits>;
24
+ export declare class KoffingError extends Error {
25
+ readonly diagnostics: Diagnostic[];
26
+ constructor(message: string, diagnostics: Diagnostic[]);
31
27
  }
32
-
33
- declare class PokemonTeam {
34
- name: string;
35
- format: string;
36
- folder: string | undefined;
37
- pokemon: Pokemon[];
38
- constructor(format?: string, name?: string, folder?: string | undefined);
39
- static fromObject(obj: PokemonTeam | Record<string, any>): PokemonTeam;
40
- toJson(indentation?: number): string;
41
- toShowdown(): string;
42
- toString(): string;
43
- }
44
-
45
- declare class PokemonTeamSet {
46
- teams: PokemonTeam[];
47
- constructor(teams?: PokemonTeam[]);
48
- static fromObject(obj: PokemonTeamSet | Record<string, any>): PokemonTeamSet;
49
- toJson(indentation?: number): string;
50
- toShowdown(): string;
51
- toString(): string;
52
- }
53
-
54
- type ParserState = {
55
- team: PokemonTeam | null;
56
- pokemon: Pokemon | null;
57
- };
58
- /**
59
- * Ported from Pokemon Showdown Client's exportTeam/importTeam functions.
60
- *
61
- * @see https://github.com/Zarel/Pokemon-Showdown-Client/blob/master/js/storage.js
62
- */
63
- declare class ShowdownParser {
64
- static regexes: Record<string, RegExp>;
65
- code: string;
66
- constructor(code: string);
67
- parse(): PokemonTeamSet;
68
- _parseTeam(line: string, team: PokemonTeam): void;
69
- _parseNameLine(line: string, pokemon: Pokemon): void;
70
- _parseEvsIvs(line: string, pokemon: Pokemon | any): boolean;
71
- _parseKeyValuePairs(line: string, pokemon: Pokemon | any): boolean;
72
- /**
73
- * Saves the current state of the parsed team.
74
- */
75
- _saveCurrent(teams: PokemonTeam[], current: ParserState): ShowdownParser;
76
- /**
77
- * Sanitizes and re-formats / prettifies the Showdown code
78
- */
79
- format(): ShowdownParser;
80
- /**
81
- * @returns {string}
82
- */
83
- toString(): string;
84
- }
85
-
86
- type DataType = string | Pokemon | PokemonTeam | PokemonTeamSet | ShowdownParser;
87
- declare class Koffing {
88
- /**
89
- * Converts from Showdown to a PokemonTeamSet object.
90
- */
91
- static parse(data: DataType): Pokemon | PokemonTeam | PokemonTeamSet;
92
- /**
93
- * Prettifies and sanitizes the given Showdown code.
94
- */
95
- static format(data: DataType): string;
96
- /**
97
- * Converts from Showdown to JSON code.
98
- */
99
- static toJson(data: DataType): string;
100
- /**
101
- * Converts from JSON string or JSON object to Showdown code.
102
- */
103
- static toShowdown(data: DataType | object): string;
104
- }
105
-
106
- export { Koffing, Pokemon, PokemonGender, PokemonStats, PokemonTeam, PokemonTeamSet, ShowdownParser };
28
+ //#endregion
29
+ export type { Diagnostic, Limits, Options, ParseResult, PokemonSet, SanitizeOptions, StatID, Stats, Team };