@utilix-tech/sdk 0.50.0 → 0.52.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.
@@ -22,6 +22,8 @@
22
22
  * - redos-detector (detectRedos)
23
23
  * - conventional-commit-linter (lintConventionalCommit)
24
24
  * - gitignore-tester (testGitignorePatterns)
25
+ * - editorconfig-validator (validateEditorConfig)
26
+ * - tsconfig-validator (validateTsconfig)
25
27
  */
26
28
  type RegexFlag = 'g' | 'i' | 'm' | 's' | 'u';
27
29
  declare const ALL_FLAGS: RegexFlag[];
@@ -392,6 +394,61 @@ interface GitignoreTestResult {
392
394
  declare function testGitignorePatterns(gitignoreContent: string, paths: string[]): GitignoreTestResult[] | {
393
395
  error: string;
394
396
  };
397
+ interface EditorConfigProperty {
398
+ key: string;
399
+ value: string;
400
+ line: number;
401
+ }
402
+ interface EditorConfigSection {
403
+ glob: string;
404
+ line: number;
405
+ properties: EditorConfigProperty[];
406
+ }
407
+ interface EditorConfigIssue {
408
+ severity: 'error' | 'warning';
409
+ line: number;
410
+ message: string;
411
+ }
412
+ interface EditorConfigValidationResult {
413
+ root: boolean;
414
+ sections: EditorConfigSection[];
415
+ issues: EditorConfigIssue[];
416
+ valid: boolean;
417
+ }
418
+ /**
419
+ * Validate an .editorconfig file: parse it into its root flag and glob
420
+ * sections, and flag structural mistakes against the EditorConfig spec —
421
+ * unknown properties, invalid values for known properties (indent_style,
422
+ * end_of_line, charset, indent_size, tab_width, max_line_length), a `root`
423
+ * declaration outside the file's preamble, and duplicate properties within
424
+ * the same section.
425
+ */
426
+ declare function validateEditorConfig(text: string): EditorConfigValidationResult | {
427
+ error: string;
428
+ };
429
+ interface TsconfigIssue {
430
+ severity: 'error' | 'warning';
431
+ path: string;
432
+ message: string;
433
+ }
434
+ interface TsconfigValidationResult {
435
+ parsed: true;
436
+ topLevelKeys: string[];
437
+ compilerOptionKeys: string[];
438
+ issues: TsconfigIssue[];
439
+ valid: boolean;
440
+ }
441
+ /**
442
+ * Validate a tsconfig.json file: parse it as JSONC (`//` and `/* *\/`
443
+ * comments plus trailing commas are stripped before parsing, matching how
444
+ * `tsc` itself reads the file) and flag structural mistakes — unknown
445
+ * top-level keys, unknown `compilerOptions` keys, wrong types (a boolean
446
+ * option given a string, an enum option given a value outside its known
447
+ * set), and malformed `files`/`include`/`exclude`/`references`/`paths`.
448
+ */
449
+ declare function validateTsconfig(text: string): TsconfigValidationResult | {
450
+ error: string;
451
+ };
395
452
 
396
453
  declare const code_ALL_FLAGS: typeof ALL_FLAGS;
397
454
  type code_ApiEndpoint = ApiEndpoint;
@@ -407,6 +464,10 @@ type code_ConventionalCommitSeverity = ConventionalCommitSeverity;
407
464
  type code_CssResult = CssResult;
408
465
  declare const code_DEFAULT_COMMIT_TYPES: typeof DEFAULT_COMMIT_TYPES;
409
466
  type code_DockerImageRef = DockerImageRef;
467
+ type code_EditorConfigIssue = EditorConfigIssue;
468
+ type code_EditorConfigProperty = EditorConfigProperty;
469
+ type code_EditorConfigSection = EditorConfigSection;
470
+ type code_EditorConfigValidationResult = EditorConfigValidationResult;
410
471
  type code_EnvEntry = EnvEntry;
411
472
  type code_EnvParseResult = EnvParseResult;
412
473
  type code_GitCommandConfig = GitCommandConfig;
@@ -441,6 +502,8 @@ type code_SpecVersion = SpecVersion;
441
502
  type code_SqlDialect = SqlDialect;
442
503
  type code_SqlFormatOptions = SqlFormatOptions;
443
504
  type code_TestPatternResult = TestPatternResult;
505
+ type code_TsconfigIssue = TsconfigIssue;
506
+ type code_TsconfigValidationResult = TsconfigValidationResult;
444
507
  declare const code_buildDockerPull: typeof buildDockerPull;
445
508
  declare const code_buildDockerRun: typeof buildDockerRun;
446
509
  declare const code_buildGitCommand: typeof buildGitCommand;
@@ -486,9 +549,11 @@ declare const code_splitStatements: typeof splitStatements;
486
549
  declare const code_testGitignorePatterns: typeof testGitignorePatterns;
487
550
  declare const code_testPattern: typeof testPattern;
488
551
  declare const code_testRegex: typeof testRegex;
552
+ declare const code_validateEditorConfig: typeof validateEditorConfig;
489
553
  declare const code_validateEnvKey: typeof validateEnvKey;
554
+ declare const code_validateTsconfig: typeof validateTsconfig;
490
555
  declare namespace code {
491
- export { code_ALL_FLAGS as ALL_FLAGS, type code_ApiEndpoint as ApiEndpoint, type code_ApiInfo as ApiInfo, code_CHEATSHEET as CHEATSHEET, type code_CheatsheetEntry as CheatsheetEntry, type code_ConventionalCommitFinding as ConventionalCommitFinding, type code_ConventionalCommitFooter as ConventionalCommitFooter, type code_ConventionalCommitOptions as ConventionalCommitOptions, type code_ConventionalCommitParsed as ConventionalCommitParsed, type code_ConventionalCommitResult as ConventionalCommitResult, type code_ConventionalCommitSeverity as ConventionalCommitSeverity, type code_CssResult as CssResult, code_DEFAULT_COMMIT_TYPES as DEFAULT_COMMIT_TYPES, type code_DockerImageRef as DockerImageRef, type code_EnvEntry as EnvEntry, type code_EnvParseResult as EnvParseResult, type code_GitCommandConfig as GitCommandConfig, type code_GitCommandResult as GitCommandResult, type code_GitOperation as GitOperation, type code_GithubUrlInfo as GithubUrlInfo, type code_GithubUrlType as GithubUrlType, type code_GitignoreTestResult as GitignoreTestResult, type code_GqlFormatResult as GqlFormatResult, type code_HtmlFormatResult as HtmlFormatResult, type code_HtmlMinifyOptions as HtmlMinifyOptions, type code_HtmlMinifyResult as HtmlMinifyResult, type code_JsMinifyOptions as JsMinifyOptions, type code_JsMinifyResult as JsMinifyResult, code_MIME_TABLE as MIME_TABLE, type code_MatchResult as MatchResult, type code_MimeEntry as MimeEntry, type code_MimeLookupResult as MimeLookupResult, code_OPERATIONS as OPERATIONS, type code_ParsedSpec as ParsedSpec, type code_RedosFinding as RedosFinding, type code_RedosResult as RedosResult, type code_RedosSeverity as RedosSeverity, type code_RegexError as RegexError, type code_RegexFlag as RegexFlag, type code_RegexMatch as RegexMatch, type code_RegexResult as RegexResult, type code_RegexSuccess as RegexSuccess, code_SQL_DEFAULT_OPTIONS as SQL_DEFAULT_OPTIONS, type code_Segment as Segment, type code_SpecVersion as SpecVersion, type code_SqlDialect as SqlDialect, type code_SqlFormatOptions as SqlFormatOptions, type code_TestPatternResult as TestPatternResult, code_buildDockerPull as buildDockerPull, code_buildDockerRun as buildDockerRun, code_buildGitCommand as buildGitCommand, code_collapseHtmlWhitespace as collapseHtmlWhitespace, code_collapseJsWhitespace as collapseJsWhitespace, code_countProperties as countProperties, code_countRules as countRules, code_detectDialect as detectDialect, code_detectOperationType as detectOperationType, code_detectRedos as detectRedos, code_envToExport as envToExport, code_envToJson as envToJson, code_formatCss as formatCss, code_formatGql as formatGql, code_formatHtml as formatHtml, code_formatSql as formatSql, code_getEndpointsByTag as getEndpointsByTag, code_getHtmlStats as getHtmlStats, code_getJsStats as getJsStats, code_getMethodColor as getMethodColor, code_isValidTag as isValidTag, code_lintConventionalCommit as lintConventionalCommit, code_lookupMime as lookupMime, code_minifyCss as minifyCss, code_minifyGql as minifyGql, code_minifyHtml as minifyHtml, code_minifyJs as minifyJs, code_minifySql as minifySql, code_normalizeRef as normalizeRef, code_parseDockerImage as parseDockerImage, code_parseEnv as parseEnv, code_parseGitCommand as parseGitCommand, code_parseGithubUrl as parseGithubUrl, code_parseSpec as parseSpec, code_removeConsoleCalls as removeConsoleCalls, code_removeEmptyAttributes as removeEmptyAttributes, code_removeHtmlComments as removeHtmlComments, code_removeJsComments as removeJsComments, code_removeRedundantAttributes as removeRedundantAttributes, code_searchCheatsheet as searchCheatsheet, code_searchEndpoints as searchEndpoints, code_splitStatements as splitStatements, code_testGitignorePatterns as testGitignorePatterns, code_testPattern as testPattern, code_testRegex as testRegex, code_validateEnvKey as validateEnvKey };
556
+ export { code_ALL_FLAGS as ALL_FLAGS, type code_ApiEndpoint as ApiEndpoint, type code_ApiInfo as ApiInfo, code_CHEATSHEET as CHEATSHEET, type code_CheatsheetEntry as CheatsheetEntry, type code_ConventionalCommitFinding as ConventionalCommitFinding, type code_ConventionalCommitFooter as ConventionalCommitFooter, type code_ConventionalCommitOptions as ConventionalCommitOptions, type code_ConventionalCommitParsed as ConventionalCommitParsed, type code_ConventionalCommitResult as ConventionalCommitResult, type code_ConventionalCommitSeverity as ConventionalCommitSeverity, type code_CssResult as CssResult, code_DEFAULT_COMMIT_TYPES as DEFAULT_COMMIT_TYPES, type code_DockerImageRef as DockerImageRef, type code_EditorConfigIssue as EditorConfigIssue, type code_EditorConfigProperty as EditorConfigProperty, type code_EditorConfigSection as EditorConfigSection, type code_EditorConfigValidationResult as EditorConfigValidationResult, type code_EnvEntry as EnvEntry, type code_EnvParseResult as EnvParseResult, type code_GitCommandConfig as GitCommandConfig, type code_GitCommandResult as GitCommandResult, type code_GitOperation as GitOperation, type code_GithubUrlInfo as GithubUrlInfo, type code_GithubUrlType as GithubUrlType, type code_GitignoreTestResult as GitignoreTestResult, type code_GqlFormatResult as GqlFormatResult, type code_HtmlFormatResult as HtmlFormatResult, type code_HtmlMinifyOptions as HtmlMinifyOptions, type code_HtmlMinifyResult as HtmlMinifyResult, type code_JsMinifyOptions as JsMinifyOptions, type code_JsMinifyResult as JsMinifyResult, code_MIME_TABLE as MIME_TABLE, type code_MatchResult as MatchResult, type code_MimeEntry as MimeEntry, type code_MimeLookupResult as MimeLookupResult, code_OPERATIONS as OPERATIONS, type code_ParsedSpec as ParsedSpec, type code_RedosFinding as RedosFinding, type code_RedosResult as RedosResult, type code_RedosSeverity as RedosSeverity, type code_RegexError as RegexError, type code_RegexFlag as RegexFlag, type code_RegexMatch as RegexMatch, type code_RegexResult as RegexResult, type code_RegexSuccess as RegexSuccess, code_SQL_DEFAULT_OPTIONS as SQL_DEFAULT_OPTIONS, type code_Segment as Segment, type code_SpecVersion as SpecVersion, type code_SqlDialect as SqlDialect, type code_SqlFormatOptions as SqlFormatOptions, type code_TestPatternResult as TestPatternResult, type code_TsconfigIssue as TsconfigIssue, type code_TsconfigValidationResult as TsconfigValidationResult, code_buildDockerPull as buildDockerPull, code_buildDockerRun as buildDockerRun, code_buildGitCommand as buildGitCommand, code_collapseHtmlWhitespace as collapseHtmlWhitespace, code_collapseJsWhitespace as collapseJsWhitespace, code_countProperties as countProperties, code_countRules as countRules, code_detectDialect as detectDialect, code_detectOperationType as detectOperationType, code_detectRedos as detectRedos, code_envToExport as envToExport, code_envToJson as envToJson, code_formatCss as formatCss, code_formatGql as formatGql, code_formatHtml as formatHtml, code_formatSql as formatSql, code_getEndpointsByTag as getEndpointsByTag, code_getHtmlStats as getHtmlStats, code_getJsStats as getJsStats, code_getMethodColor as getMethodColor, code_isValidTag as isValidTag, code_lintConventionalCommit as lintConventionalCommit, code_lookupMime as lookupMime, code_minifyCss as minifyCss, code_minifyGql as minifyGql, code_minifyHtml as minifyHtml, code_minifyJs as minifyJs, code_minifySql as minifySql, code_normalizeRef as normalizeRef, code_parseDockerImage as parseDockerImage, code_parseEnv as parseEnv, code_parseGitCommand as parseGitCommand, code_parseGithubUrl as parseGithubUrl, code_parseSpec as parseSpec, code_removeConsoleCalls as removeConsoleCalls, code_removeEmptyAttributes as removeEmptyAttributes, code_removeHtmlComments as removeHtmlComments, code_removeJsComments as removeJsComments, code_removeRedundantAttributes as removeRedundantAttributes, code_searchCheatsheet as searchCheatsheet, code_searchEndpoints as searchEndpoints, code_splitStatements as splitStatements, code_testGitignorePatterns as testGitignorePatterns, code_testPattern as testPattern, code_testRegex as testRegex, code_validateEditorConfig as validateEditorConfig, code_validateEnvKey as validateEnvKey, code_validateTsconfig as validateTsconfig };
492
557
  }
493
558
 
494
- export { collapseJsWhitespace as $, ALL_FLAGS as A, type RedosSeverity as B, CHEATSHEET as C, DEFAULT_COMMIT_TYPES as D, type EnvEntry as E, type RegexError as F, type GitCommandConfig as G, type HtmlFormatResult as H, type RegexFlag as I, type JsMinifyOptions as J, type RegexMatch as K, type RegexResult as L, MIME_TABLE as M, type RegexSuccess as N, OPERATIONS as O, type ParsedSpec as P, type Segment as Q, type RedosFinding as R, SQL_DEFAULT_OPTIONS as S, type SpecVersion as T, type SqlDialect as U, type SqlFormatOptions as V, type TestPatternResult as W, buildDockerPull as X, buildDockerRun as Y, buildGitCommand as Z, collapseHtmlWhitespace as _, type ApiEndpoint as a, countProperties as a0, countRules as a1, detectDialect as a2, detectOperationType as a3, detectRedos as a4, envToExport as a5, envToJson as a6, formatCss as a7, formatGql as a8, formatHtml as a9, splitStatements as aA, testGitignorePatterns as aB, testPattern as aC, testRegex as aD, validateEnvKey as aE, formatSql as aa, getEndpointsByTag as ab, getHtmlStats as ac, getJsStats as ad, getMethodColor as ae, isValidTag as af, lintConventionalCommit as ag, lookupMime as ah, minifyCss as ai, minifyGql as aj, minifyHtml as ak, minifyJs as al, minifySql as am, normalizeRef as an, parseDockerImage as ao, parseEnv as ap, parseGitCommand as aq, parseGithubUrl as ar, parseSpec as as, removeConsoleCalls as at, removeEmptyAttributes as au, removeHtmlComments as av, removeJsComments as aw, removeRedundantAttributes as ax, searchCheatsheet as ay, searchEndpoints as az, type ApiInfo as b, code as c, type CheatsheetEntry as d, type ConventionalCommitFinding as e, type ConventionalCommitFooter as f, type ConventionalCommitOptions as g, type ConventionalCommitParsed as h, type ConventionalCommitResult as i, type ConventionalCommitSeverity as j, type CssResult as k, type DockerImageRef as l, type EnvParseResult as m, type GitCommandResult as n, type GitOperation as o, type GithubUrlInfo as p, type GithubUrlType as q, type GitignoreTestResult as r, type GqlFormatResult as s, type HtmlMinifyOptions as t, type HtmlMinifyResult as u, type JsMinifyResult as v, type MatchResult as w, type MimeEntry as x, type MimeLookupResult as y, type RedosResult as z };
559
+ export { type TsconfigIssue as $, ALL_FLAGS as A, type MatchResult as B, CHEATSHEET as C, DEFAULT_COMMIT_TYPES as D, type EditorConfigIssue as E, type MimeEntry as F, type GitCommandConfig as G, type HtmlFormatResult as H, type MimeLookupResult as I, type JsMinifyOptions as J, type RedosResult as K, type RedosSeverity as L, MIME_TABLE as M, type RegexError as N, OPERATIONS as O, type ParsedSpec as P, type RegexFlag as Q, type RedosFinding as R, type RegexMatch as S, type RegexResult as T, type RegexSuccess as U, SQL_DEFAULT_OPTIONS as V, type Segment as W, type SpecVersion as X, type SqlDialect as Y, type SqlFormatOptions as Z, type TestPatternResult as _, type ApiEndpoint as a, type TsconfigValidationResult as a0, buildDockerPull as a1, buildDockerRun as a2, buildGitCommand as a3, collapseHtmlWhitespace as a4, collapseJsWhitespace as a5, countProperties as a6, countRules as a7, detectDialect as a8, detectOperationType as a9, removeEmptyAttributes as aA, removeHtmlComments as aB, removeJsComments as aC, removeRedundantAttributes as aD, searchCheatsheet as aE, searchEndpoints as aF, splitStatements as aG, testGitignorePatterns as aH, testPattern as aI, testRegex as aJ, validateEditorConfig as aK, validateEnvKey as aL, validateTsconfig as aM, detectRedos as aa, envToExport as ab, envToJson as ac, formatCss as ad, formatGql as ae, formatHtml as af, formatSql as ag, getEndpointsByTag as ah, getHtmlStats as ai, getJsStats as aj, getMethodColor as ak, isValidTag as al, lintConventionalCommit as am, lookupMime as an, minifyCss as ao, minifyGql as ap, minifyHtml as aq, minifyJs as ar, minifySql as as, normalizeRef as at, parseDockerImage as au, parseEnv as av, parseGitCommand as aw, parseGithubUrl as ax, parseSpec as ay, removeConsoleCalls as az, type ApiInfo as b, code as c, type CheatsheetEntry as d, type ConventionalCommitFinding as e, type ConventionalCommitFooter as f, type ConventionalCommitOptions as g, type ConventionalCommitParsed as h, type ConventionalCommitResult as i, type ConventionalCommitSeverity as j, type CssResult as k, type DockerImageRef as l, type EditorConfigProperty as m, type EditorConfigSection as n, type EditorConfigValidationResult as o, type EnvEntry as p, type EnvParseResult as q, type GitCommandResult as r, type GitOperation as s, type GithubUrlInfo as t, type GithubUrlType as u, type GitignoreTestResult as v, type GqlFormatResult as w, type HtmlMinifyOptions as x, type HtmlMinifyResult as y, type JsMinifyResult as z };
package/dist/index.cjs CHANGED
@@ -8229,6 +8229,7 @@ __export(units_exports, {
8229
8229
  COMMON_TAX_RATES: () => COMMON_TAX_RATES,
8230
8230
  COMMON_TIP_PERCENTAGES: () => COMMON_TIP_PERCENTAGES,
8231
8231
  COMMON_VIEWPORTS: () => COMMON_VIEWPORTS,
8232
+ GPA_GRADE_POINTS: () => GPA_GRADE_POINTS,
8232
8233
  USD_DENOMINATIONS: () => USD_DENOMINATIONS,
8233
8234
  applySuccessiveDiscounts: () => applySuccessiveDiscounts,
8234
8235
  autoFormat: () => autoFormat,
@@ -8244,6 +8245,7 @@ __export(units_exports, {
8244
8245
  calculateDepreciationSchedule: () => calculateDepreciationSchedule,
8245
8246
  calculateDiscount: () => calculateDiscount,
8246
8247
  calculateEmi: () => calculateEmi,
8248
+ calculateGpa: () => calculateGpa,
8247
8249
  calculateLoan: () => calculateLoan,
8248
8250
  calculateMarginMarkup: () => calculateMarginMarkup,
8249
8251
  calculateMovingAverages: () => calculateMovingAverages,
@@ -10353,6 +10355,56 @@ function calculateMovingAverages(values, windowSize) {
10353
10355
  latestEma: last.ema
10354
10356
  };
10355
10357
  }
10358
+ var GPA_GRADE_POINTS = {
10359
+ "A+": 4,
10360
+ A: 4,
10361
+ "A-": 3.7,
10362
+ "B+": 3.3,
10363
+ B: 3,
10364
+ "B-": 2.7,
10365
+ "C+": 2.3,
10366
+ C: 2,
10367
+ "C-": 1.7,
10368
+ "D+": 1.3,
10369
+ D: 1,
10370
+ "D-": 0.7,
10371
+ F: 0
10372
+ };
10373
+ function calculateGpa(courses) {
10374
+ if (!Array.isArray(courses) || courses.length === 0) {
10375
+ return { error: "courses must be a non-empty array" };
10376
+ }
10377
+ const round23 = (n) => Math.round(n * 100) / 100;
10378
+ let totalCredits = 0;
10379
+ let totalQualityPoints = 0;
10380
+ const results = [];
10381
+ for (let i = 0; i < courses.length; i++) {
10382
+ const course = courses[i];
10383
+ if (typeof course.credits !== "number" || !Number.isFinite(course.credits) || course.credits <= 0) {
10384
+ return { error: `course ${i + 1}: credits must be a finite number greater than zero` };
10385
+ }
10386
+ const gradeKey = typeof course.grade === "string" ? course.grade.trim().toUpperCase() : "";
10387
+ const points = GPA_GRADE_POINTS[gradeKey];
10388
+ if (points === void 0) {
10389
+ return { error: `course ${i + 1}: unrecognized grade "${course.grade}" (expected one of ${Object.keys(GPA_GRADE_POINTS).join(", ")})` };
10390
+ }
10391
+ const qualityPoints = round23(points * course.credits);
10392
+ totalCredits += course.credits;
10393
+ totalQualityPoints += qualityPoints;
10394
+ results.push({
10395
+ name: course.name?.trim() || `Course ${i + 1}`,
10396
+ grade: gradeKey,
10397
+ credits: course.credits,
10398
+ qualityPoints
10399
+ });
10400
+ }
10401
+ return {
10402
+ courses: results,
10403
+ totalCredits: round23(totalCredits),
10404
+ totalQualityPoints: round23(totalQualityPoints),
10405
+ gpa: round23(totalQualityPoints / totalCredits)
10406
+ };
10407
+ }
10356
10408
 
10357
10409
  // src/tools/network.ts
10358
10410
  var network_exports = {};
@@ -14492,7 +14544,9 @@ __export(code_exports, {
14492
14544
  testGitignorePatterns: () => testGitignorePatterns,
14493
14545
  testPattern: () => testPattern,
14494
14546
  testRegex: () => testRegex,
14495
- validateEnvKey: () => validateEnvKey2
14547
+ validateEditorConfig: () => validateEditorConfig,
14548
+ validateEnvKey: () => validateEnvKey2,
14549
+ validateTsconfig: () => validateTsconfig
14496
14550
  });
14497
14551
  var ALL_FLAGS = ["g", "i", "m", "s", "u"];
14498
14552
  function testRegex(pattern, flags, input) {
@@ -17377,6 +17431,340 @@ function testGitignorePatterns(gitignoreContent, paths) {
17377
17431
  return { path, ignored, matchedPattern, matchedLine };
17378
17432
  });
17379
17433
  }
17434
+ var EDITORCONFIG_ENUM_PROPERTIES = {
17435
+ indent_style: ["tab", "space"],
17436
+ end_of_line: ["lf", "cr", "crlf"],
17437
+ charset: ["latin1", "utf-8", "utf-8-bom", "utf-16be", "utf-16le"],
17438
+ trim_trailing_whitespace: ["true", "false"],
17439
+ insert_final_newline: ["true", "false"]
17440
+ };
17441
+ var EDITORCONFIG_KNOWN_PROPERTIES = /* @__PURE__ */ new Set([
17442
+ "indent_style",
17443
+ "indent_size",
17444
+ "tab_width",
17445
+ "end_of_line",
17446
+ "charset",
17447
+ "trim_trailing_whitespace",
17448
+ "insert_final_newline",
17449
+ "max_line_length",
17450
+ "root"
17451
+ ]);
17452
+ var POSITIVE_INT_RE = /^[1-9][0-9]*$/;
17453
+ function validateEditorConfig(text) {
17454
+ if (!text || !text.trim()) return { error: "Input is empty" };
17455
+ const lines = text.split("\n");
17456
+ const issues = [];
17457
+ const sections = [];
17458
+ let root = false;
17459
+ let rootSeen = false;
17460
+ let currentSection = null;
17461
+ for (let i = 0; i < lines.length; i++) {
17462
+ const lineNum = i + 1;
17463
+ const trimmed = lines[i].trim();
17464
+ if (!trimmed || trimmed.startsWith("#") || trimmed.startsWith(";")) continue;
17465
+ const sectionMatch = trimmed.match(/^\[(.*)\]$/);
17466
+ if (sectionMatch) {
17467
+ const glob = sectionMatch[1];
17468
+ if (!glob) {
17469
+ issues.push({ severity: "warning", line: lineNum, message: 'Section header is empty ("[]" matches no files)' });
17470
+ }
17471
+ if (sections.some((s) => s.glob === glob)) {
17472
+ issues.push({ severity: "warning", line: lineNum, message: `Duplicate section "[${glob}]" (an earlier section already uses this exact glob)` });
17473
+ }
17474
+ currentSection = { glob, line: lineNum, properties: [] };
17475
+ sections.push(currentSection);
17476
+ continue;
17477
+ }
17478
+ const eqIdx = trimmed.indexOf("=");
17479
+ if (eqIdx === -1) {
17480
+ issues.push({ severity: "error", line: lineNum, message: `Malformed line (missing '='): "${trimmed}"` });
17481
+ continue;
17482
+ }
17483
+ const rawKey = trimmed.slice(0, eqIdx).trim();
17484
+ const key = rawKey.toLowerCase();
17485
+ const rawValue = trimmed.slice(eqIdx + 1).trim();
17486
+ const normalizedValue = rawValue.toLowerCase();
17487
+ if (!rawKey) {
17488
+ issues.push({ severity: "error", line: lineNum, message: "Property is missing a name" });
17489
+ continue;
17490
+ }
17491
+ if (key === "root") {
17492
+ if (sections.length > 0) {
17493
+ issues.push({ severity: "error", line: lineNum, message: `"root" must appear before any section, in the file's preamble` });
17494
+ } else if (rootSeen) {
17495
+ issues.push({ severity: "warning", line: lineNum, message: 'Duplicate "root" declaration' });
17496
+ } else if (normalizedValue !== "true" && normalizedValue !== "false") {
17497
+ issues.push({ severity: "error", line: lineNum, message: `"root" must be "true" or "false", got "${rawValue}"` });
17498
+ } else {
17499
+ root = normalizedValue === "true";
17500
+ }
17501
+ rootSeen = true;
17502
+ continue;
17503
+ }
17504
+ if (!currentSection) {
17505
+ issues.push({ severity: "error", line: lineNum, message: `Property "${rawKey}" found before any section header` });
17506
+ continue;
17507
+ }
17508
+ if (currentSection.properties.some((p) => p.key === key)) {
17509
+ issues.push({ severity: "warning", line: lineNum, message: `Duplicate property "${key}" in section "[${currentSection.glob}]"` });
17510
+ }
17511
+ currentSection.properties.push({ key, value: rawValue, line: lineNum });
17512
+ if (!EDITORCONFIG_KNOWN_PROPERTIES.has(key)) {
17513
+ issues.push({ severity: "warning", line: lineNum, message: `Unknown property "${key}"` });
17514
+ continue;
17515
+ }
17516
+ if (key in EDITORCONFIG_ENUM_PROPERTIES) {
17517
+ if (!EDITORCONFIG_ENUM_PROPERTIES[key].includes(normalizedValue)) {
17518
+ issues.push({ severity: "error", line: lineNum, message: `"${key}" must be one of ${EDITORCONFIG_ENUM_PROPERTIES[key].join(", ")}, got "${rawValue}"` });
17519
+ }
17520
+ } else if (key === "indent_size") {
17521
+ if (normalizedValue !== "tab" && !POSITIVE_INT_RE.test(rawValue)) {
17522
+ issues.push({ severity: "error", line: lineNum, message: `"indent_size" must be a positive integer or "tab", got "${rawValue}"` });
17523
+ }
17524
+ } else if (key === "tab_width") {
17525
+ if (!POSITIVE_INT_RE.test(rawValue)) {
17526
+ issues.push({ severity: "error", line: lineNum, message: `"tab_width" must be a positive integer, got "${rawValue}"` });
17527
+ }
17528
+ } else if (key === "max_line_length") {
17529
+ if (normalizedValue !== "off" && !POSITIVE_INT_RE.test(rawValue)) {
17530
+ issues.push({ severity: "error", line: lineNum, message: `"max_line_length" must be a positive integer or "off", got "${rawValue}"` });
17531
+ }
17532
+ }
17533
+ }
17534
+ if (sections.length === 0 && !rootSeen) {
17535
+ issues.push({ severity: "warning", line: 1, message: "File has no section headers and no root declaration" });
17536
+ }
17537
+ const valid = !issues.some((i) => i.severity === "error");
17538
+ return { root, sections, issues, valid };
17539
+ }
17540
+ function stripJsonComments(input) {
17541
+ let out = "";
17542
+ let i = 0;
17543
+ const n = input.length;
17544
+ let inString = false;
17545
+ while (i < n) {
17546
+ const c = input[i];
17547
+ const next = input[i + 1];
17548
+ if (inString) {
17549
+ out += c;
17550
+ if (c === "\\") {
17551
+ out += next ?? "";
17552
+ i += 2;
17553
+ continue;
17554
+ }
17555
+ if (c === '"') inString = false;
17556
+ i++;
17557
+ continue;
17558
+ }
17559
+ if (c === '"') {
17560
+ inString = true;
17561
+ out += c;
17562
+ i++;
17563
+ continue;
17564
+ }
17565
+ if (c === "/" && next === "/") {
17566
+ while (i < n && input[i] !== "\n") i++;
17567
+ continue;
17568
+ }
17569
+ if (c === "/" && next === "*") {
17570
+ i += 2;
17571
+ while (i < n && !(input[i] === "*" && input[i + 1] === "/")) {
17572
+ out += input[i] === "\n" ? "\n" : "";
17573
+ i++;
17574
+ }
17575
+ i += 2;
17576
+ continue;
17577
+ }
17578
+ out += c;
17579
+ i++;
17580
+ }
17581
+ return out;
17582
+ }
17583
+ function stripTrailingCommas(input) {
17584
+ return input.replace(/,(\s*[}\]])/g, "$1");
17585
+ }
17586
+ var TSCONFIG_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
17587
+ "compilerOptions",
17588
+ "files",
17589
+ "include",
17590
+ "exclude",
17591
+ "extends",
17592
+ "references",
17593
+ "compileOnSave",
17594
+ "typeAcquisition",
17595
+ "watchOptions",
17596
+ "buildOptions",
17597
+ "$schema"
17598
+ ]);
17599
+ var TSCONFIG_ENUM_OPTIONS = {
17600
+ target: ["es3", "es5", "es6", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "es2021", "es2022", "es2023", "esnext"],
17601
+ module: ["none", "commonjs", "amd", "umd", "system", "es6", "es2015", "es2020", "es2022", "esnext", "node16", "nodenext", "node18", "preserve"],
17602
+ moduleResolution: ["classic", "node", "node10", "node16", "nodenext", "bundler"],
17603
+ moduleDetection: ["legacy", "auto", "force"],
17604
+ jsx: ["preserve", "react", "react-jsx", "react-jsxdev", "react-native"],
17605
+ newLine: ["crlf", "lf"],
17606
+ importsNotUsedAsValues: ["remove", "preserve", "error"]
17607
+ };
17608
+ var TSCONFIG_BOOLEAN_OPTIONS = /* @__PURE__ */ new Set([
17609
+ "allowJs",
17610
+ "checkJs",
17611
+ "strict",
17612
+ "noImplicitAny",
17613
+ "strictNullChecks",
17614
+ "strictFunctionTypes",
17615
+ "strictBindCallApply",
17616
+ "strictPropertyInitialization",
17617
+ "noImplicitThis",
17618
+ "useUnknownInCatchVariables",
17619
+ "alwaysStrict",
17620
+ "noUnusedLocals",
17621
+ "noUnusedParameters",
17622
+ "exactOptionalPropertyTypes",
17623
+ "noImplicitReturns",
17624
+ "noFallthroughCasesInSwitch",
17625
+ "noUncheckedIndexedAccess",
17626
+ "noImplicitOverride",
17627
+ "noPropertyAccessFromIndexSignature",
17628
+ "esModuleInterop",
17629
+ "allowSyntheticDefaultImports",
17630
+ "forceConsistentCasingInFileNames",
17631
+ "isolatedModules",
17632
+ "verbatimModuleSyntax",
17633
+ "declaration",
17634
+ "declarationMap",
17635
+ "emitDeclarationOnly",
17636
+ "sourceMap",
17637
+ "inlineSourceMap",
17638
+ "inlineSources",
17639
+ "noEmit",
17640
+ "noEmitOnError",
17641
+ "preserveConstEnums",
17642
+ "removeComments",
17643
+ "skipLibCheck",
17644
+ "composite",
17645
+ "incremental",
17646
+ "experimentalDecorators",
17647
+ "emitDecoratorMetadata",
17648
+ "resolveJsonModule",
17649
+ "allowUmdGlobalAccess",
17650
+ "downlevelIteration",
17651
+ "importHelpers",
17652
+ "preserveSymlinks",
17653
+ "allowUnreachableCode",
17654
+ "allowUnusedLabels",
17655
+ "disableSizeLimit",
17656
+ "noResolve",
17657
+ "skipDefaultLibCheck",
17658
+ "suppressImplicitAnyIndexErrors"
17659
+ ]);
17660
+ var TSCONFIG_STRING_OPTIONS = /* @__PURE__ */ new Set([
17661
+ "outDir",
17662
+ "rootDir",
17663
+ "baseUrl",
17664
+ "outFile",
17665
+ "declarationDir",
17666
+ "tsBuildInfoFile",
17667
+ "jsxFactory",
17668
+ "jsxFragmentFactory",
17669
+ "jsxImportSource"
17670
+ ]);
17671
+ var TSCONFIG_ARRAY_OPTIONS = /* @__PURE__ */ new Set(["lib", "types", "typeRoots", "rootDirs"]);
17672
+ function validateTsconfig(text) {
17673
+ if (!text || !text.trim()) return { error: "Input is empty" };
17674
+ const stripped = stripTrailingCommas(stripJsonComments(text));
17675
+ let parsed;
17676
+ try {
17677
+ parsed = JSON.parse(stripped);
17678
+ } catch (e) {
17679
+ return { error: `Invalid JSON: ${e.message}` };
17680
+ }
17681
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
17682
+ return { error: "Root of tsconfig.json must be an object" };
17683
+ }
17684
+ const obj = parsed;
17685
+ const issues = [];
17686
+ const topLevelKeys = Object.keys(obj);
17687
+ for (const key of topLevelKeys) {
17688
+ if (!TSCONFIG_TOP_LEVEL_KEYS.has(key)) {
17689
+ issues.push({ severity: "warning", path: key, message: `Unknown top-level key "${key}"` });
17690
+ }
17691
+ }
17692
+ for (const key of ["files", "include", "exclude"]) {
17693
+ if (key in obj) {
17694
+ const v = obj[key];
17695
+ if (!Array.isArray(v) || !v.every((x) => typeof x === "string")) {
17696
+ issues.push({ severity: "error", path: key, message: `"${key}" must be an array of strings` });
17697
+ }
17698
+ }
17699
+ }
17700
+ if ("extends" in obj) {
17701
+ const v = obj.extends;
17702
+ const validExtends = typeof v === "string" || Array.isArray(v) && v.every((x) => typeof x === "string");
17703
+ if (!validExtends) {
17704
+ issues.push({ severity: "error", path: "extends", message: '"extends" must be a string or an array of strings' });
17705
+ }
17706
+ }
17707
+ if ("references" in obj) {
17708
+ const v = obj.references;
17709
+ const validRefs = Array.isArray(v) && v.every((r) => typeof r === "object" && r !== null && typeof r.path === "string");
17710
+ if (!validRefs) {
17711
+ issues.push({ severity: "error", path: "references", message: '"references" must be an array of objects with a "path" string' });
17712
+ }
17713
+ }
17714
+ let compilerOptionKeys = [];
17715
+ if ("compilerOptions" in obj) {
17716
+ const co = obj.compilerOptions;
17717
+ if (typeof co !== "object" || co === null || Array.isArray(co)) {
17718
+ issues.push({ severity: "error", path: "compilerOptions", message: '"compilerOptions" must be an object' });
17719
+ } else {
17720
+ const coObj = co;
17721
+ compilerOptionKeys = Object.keys(coObj);
17722
+ for (const key of compilerOptionKeys) {
17723
+ const value = coObj[key];
17724
+ const path = `compilerOptions.${key}`;
17725
+ if (key === "paths") {
17726
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
17727
+ issues.push({ severity: "error", path, message: '"paths" must be an object mapping patterns to arrays of strings' });
17728
+ } else {
17729
+ for (const [k, v] of Object.entries(value)) {
17730
+ if (!Array.isArray(v) || !v.every((x) => typeof x === "string")) {
17731
+ issues.push({ severity: "error", path: `${path}.${k}`, message: `"paths.${k}" must be an array of strings` });
17732
+ }
17733
+ }
17734
+ }
17735
+ continue;
17736
+ }
17737
+ if (key in TSCONFIG_ENUM_OPTIONS) {
17738
+ if (typeof value !== "string" || !TSCONFIG_ENUM_OPTIONS[key].includes(value.toLowerCase())) {
17739
+ issues.push({ severity: "error", path, message: `"${key}" must be one of ${TSCONFIG_ENUM_OPTIONS[key].join(", ")}, got ${JSON.stringify(value)}` });
17740
+ }
17741
+ continue;
17742
+ }
17743
+ if (TSCONFIG_BOOLEAN_OPTIONS.has(key)) {
17744
+ if (typeof value !== "boolean") {
17745
+ issues.push({ severity: "error", path, message: `"${key}" must be a boolean, got ${JSON.stringify(value)}` });
17746
+ }
17747
+ continue;
17748
+ }
17749
+ if (TSCONFIG_STRING_OPTIONS.has(key)) {
17750
+ if (typeof value !== "string") {
17751
+ issues.push({ severity: "error", path, message: `"${key}" must be a string, got ${JSON.stringify(value)}` });
17752
+ }
17753
+ continue;
17754
+ }
17755
+ if (TSCONFIG_ARRAY_OPTIONS.has(key)) {
17756
+ if (!Array.isArray(value) || !value.every((x) => typeof x === "string")) {
17757
+ issues.push({ severity: "error", path, message: `"${key}" must be an array of strings, got ${JSON.stringify(value)}` });
17758
+ }
17759
+ continue;
17760
+ }
17761
+ issues.push({ severity: "warning", path, message: `Unknown compilerOption "${key}"` });
17762
+ }
17763
+ }
17764
+ }
17765
+ const valid = !issues.some((i) => i.severity === "error");
17766
+ return { parsed: true, topLevelKeys, compilerOptionKeys, issues, valid };
17767
+ }
17380
17768
 
17381
17769
  // src/tools/color.ts
17382
17770
  var color_exports = {};
package/dist/index.d.cts CHANGED
@@ -5,10 +5,10 @@ export { t as text } from './text-DWUcY8H1.cjs';
5
5
  export { d as data } from './data-BI_007dA.cjs';
6
6
  export { g as generators } from './generators-Du8cBesn.cjs';
7
7
  export { t as time } from './time-KqJjdqII.cjs';
8
- export { u as units } from './units-DNz6YS5D.cjs';
8
+ export { u as units } from './units-y30YVhqI.cjs';
9
9
  export { n as network } from './network-DelcJeJa.cjs';
10
10
  export { a as api } from './api-DmTNE4c1.cjs';
11
- export { c as code } from './code-KXoRsHtl.cjs';
11
+ export { c as code } from './code-B_gDkRAx.cjs';
12
12
  export { c as color } from './color-tPwZCr9H.cjs';
13
13
  export { c as css } from './css-Cf7AMGM-.cjs';
14
14
  export { m as misc } from './misc-CA3N198T.cjs';
package/dist/index.d.ts CHANGED
@@ -5,10 +5,10 @@ export { t as text } from './text-DWUcY8H1.js';
5
5
  export { d as data } from './data-BI_007dA.js';
6
6
  export { g as generators } from './generators-Du8cBesn.js';
7
7
  export { t as time } from './time-KqJjdqII.js';
8
- export { u as units } from './units-DNz6YS5D.js';
8
+ export { u as units } from './units-y30YVhqI.js';
9
9
  export { n as network } from './network-DelcJeJa.js';
10
10
  export { a as api } from './api-DmTNE4c1.js';
11
- export { c as code } from './code-KXoRsHtl.js';
11
+ export { c as code } from './code-B_gDkRAx.js';
12
12
  export { c as color } from './color-tPwZCr9H.js';
13
13
  export { c as css } from './css-Cf7AMGM-.js';
14
14
  export { m as misc } from './misc-CA3N198T.js';
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export { media_exports as media } from './chunk-226EH3ZI.js';
2
- export { units_exports as units } from './chunk-MDREETCH.js';
2
+ export { units_exports as units } from './chunk-ZZJPD366.js';
3
3
  export { network_exports as network } from './chunk-Y7YY733Z.js';
4
4
  export { api_exports as api } from './chunk-52ZDKSIX.js';
5
- export { code_exports as code } from './chunk-JL7YTXRB.js';
5
+ export { code_exports as code } from './chunk-K4ZERKBD.js';
6
6
  export { color_exports as color } from './chunk-BPVAB4P2.js';
7
7
  export { css_exports as css } from './chunk-6YPV2AB5.js';
8
8
  export { misc_exports as misc } from './chunk-GX7H6TAX.js';