@i18nprune/core 0.1.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.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +165 -0
  3. package/dist/adapters-gp1lXp0T.d.ts +12 -0
  4. package/dist/capabilities-x74cD2Hu.d.ts +48 -0
  5. package/dist/cleanup.d.ts +64 -0
  6. package/dist/cleanup.js +3999 -0
  7. package/dist/config.d.ts +201 -0
  8. package/dist/config.js +2865 -0
  9. package/dist/coreContext-DMaWLvmB.d.ts +388 -0
  10. package/dist/fs-BUYD8ZhA.d.ts +20 -0
  11. package/dist/generate.d.ts +487 -0
  12. package/dist/generate.js +9389 -0
  13. package/dist/humanEmit-ygNlYX-S.d.ts +79 -0
  14. package/dist/index-BQuLEQ9b.d.ts +7 -0
  15. package/dist/index-B_ow_Xvr.d.ts +97 -0
  16. package/dist/index-BgG01AKL.d.ts +287 -0
  17. package/dist/index-CIzZl4W8.d.ts +124 -0
  18. package/dist/index-Csm1w7XD.d.ts +58 -0
  19. package/dist/index-DLwTogCo.d.ts +43 -0
  20. package/dist/index-DVT26v11.d.ts +61 -0
  21. package/dist/index-DdjljwMj.d.ts +39 -0
  22. package/dist/index-DeIw-cZd.d.ts +52 -0
  23. package/dist/index-X50E1FIX.d.ts +50 -0
  24. package/dist/index.d.ts +9180 -0
  25. package/dist/index.js +21888 -0
  26. package/dist/init.d.ts +86 -0
  27. package/dist/init.js +848 -0
  28. package/dist/listWindow-XEFxQZi1.d.ts +30 -0
  29. package/dist/localeTargetCodes-BBIQjauw.d.ts +11 -0
  30. package/dist/locales.d.ts +39 -0
  31. package/dist/locales.js +2288 -0
  32. package/dist/missing-BVCvgUC8.d.ts +10 -0
  33. package/dist/missing.d.ts +85 -0
  34. package/dist/missing.js +5892 -0
  35. package/dist/modeResolve-cGVaY5Hh.d.ts +25 -0
  36. package/dist/path-Bfn3SAts.d.ts +11 -0
  37. package/dist/profile-BwOP9WKh.d.ts +9 -0
  38. package/dist/providers-0uMEfT6q.d.ts +82 -0
  39. package/dist/prune-c6hKZCv_.d.ts +33 -0
  40. package/dist/quality.d.ts +36 -0
  41. package/dist/quality.js +3868 -0
  42. package/dist/report-D5-6bVFj.d.ts +8 -0
  43. package/dist/report-schema.d.ts +102 -0
  44. package/dist/report-schema.js +42 -0
  45. package/dist/resumeCandidates-xR13eEwt.d.ts +200 -0
  46. package/dist/root-2-kCaBvQ.d.ts +1110 -0
  47. package/dist/runtime/edge.d.ts +21 -0
  48. package/dist/runtime/edge.js +87 -0
  49. package/dist/runtime/helpers/sync.d.ts +16 -0
  50. package/dist/runtime/helpers/sync.js +117 -0
  51. package/dist/runtime/node.d.ts +24 -0
  52. package/dist/runtime/node.js +204 -0
  53. package/dist/runtime/web.d.ts +21 -0
  54. package/dist/runtime/web.js +84 -0
  55. package/dist/shared.d.ts +1177 -0
  56. package/dist/shared.js +4897 -0
  57. package/dist/sourceContext-1LQg3HiQ.d.ts +36 -0
  58. package/dist/sourceSurface-mDtwGo1E.d.ts +122 -0
  59. package/dist/sync.d.ts +86 -0
  60. package/dist/sync.js +4971 -0
  61. package/dist/syncSegment-Bx6He2Mu.d.ts +149 -0
  62. package/dist/targets-EmtKyr6F.d.ts +23 -0
  63. package/dist/template-CGM-_WLT.d.ts +139 -0
  64. package/dist/translate-CIHYp7wi.d.ts +77 -0
  65. package/dist/types/shared.d.ts +21 -0
  66. package/dist/types/shared.js +1 -0
  67. package/dist/types.d.ts +1345 -0
  68. package/dist/types.js +1 -0
  69. package/dist/validate.d.ts +126 -0
  70. package/dist/validate.js +3717 -0
  71. package/package.json +128 -0
@@ -0,0 +1,61 @@
1
+ import { I as Issue } from './index-X50E1FIX.js';
2
+ import { S as StringLeaf } from './index-BQuLEQ9b.js';
3
+ import { P as ParityPolicy } from './root-2-kCaBvQ.js';
4
+ import { R as RunEmitter } from './index-BgG01AKL.js';
5
+
6
+ /**
7
+ * Types for the **quality** domain (source-identical / parity-adjacent reporting).
8
+ */
9
+
10
+ /** Payload for the `quality` operation JSON envelope (`data` field). */
11
+ type QualityJsonData = {
12
+ total: number;
13
+ perFile: Record<string, number>;
14
+ dynamicKeySites: number;
15
+ sourceLocale: string;
16
+ localesDir: string;
17
+ localeCount: number;
18
+ targetLocaleCount: number;
19
+ files: QualityFileLine[];
20
+ };
21
+ type QualityFileLine = {
22
+ code: string;
23
+ /** Primary segment report key (`fr.json`, `app/fr.json`, …). */
24
+ file: string;
25
+ segmentCount: number;
26
+ segmentRelativePaths: string[];
27
+ leafCount: number;
28
+ isSourceLocale: boolean;
29
+ sourceIdenticalLeafCount: number | null;
30
+ };
31
+ type ComputeEnglishIdenticalCountsInput = {
32
+ /** Source locale string leaves (paths and values). */
33
+ sourceLeaves: readonly StringLeaf[];
34
+ /**
35
+ * One entry per target locale file (basename e.g. `ja.json` and leaves from that file).
36
+ * Order matches CLI iteration over filtered locale files.
37
+ */
38
+ targets: ReadonlyArray<{
39
+ fileBasename: string;
40
+ leaves: readonly StringLeaf[];
41
+ }>;
42
+ /** Same semantics as CLI `config.policies.parity`. */
43
+ parity?: ParityPolicy;
44
+ };
45
+ type QualityRunOptions = {
46
+ /** Report only this locale file (basename without .json); omit for all non-source locales. */
47
+ target?: string;
48
+ };
49
+ type QualityHostHooks = {
50
+ emit?: RunEmitter;
51
+ runId?: string;
52
+ /** Max locale rows in human output (from CLI list window). */
53
+ listLimit?: number;
54
+ };
55
+ type QualityRunResult = {
56
+ payload: QualityJsonData;
57
+ issues: Issue[];
58
+ keyObservationsCount: number;
59
+ };
60
+
61
+ export type { ComputeEnglishIdenticalCountsInput as C, QualityFileLine as Q, QualityJsonData as a, QualityRunOptions as b, QualityHostHooks as c, QualityRunResult as d };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Dynamic (non-literal) translation call sites — shared by validate and `locales dynamic`.
3
+ * Optional fields are omitted when analysis used merged source text (no per-file path).
4
+ */
5
+ type DynamicKeySiteKind = 'non_literal' | 'template_interpolation' | 'empty_call'
6
+ /** First argument appears inside a line or block comment (inactive for runtime). */
7
+ | 'commented';
8
+
9
+ type DynamicKeySite = {
10
+ kind: DynamicKeySiteKind;
11
+ /** Function name as configured (e.g. `t`). */
12
+ functionName: string;
13
+ /** Short excerpt for logs / JSON (single line). */
14
+ preview: string;
15
+ /**
16
+ * Absolute or project-relative path when scanned per file; omitted for merged-text analysis.
17
+ */
18
+ filePath?: string;
19
+ /** 1-based line when `filePath` is set. */
20
+ line?: number;
21
+ /** 1-based column (UTF-16 code unit) at call start when `filePath` is set. */
22
+ column?: number;
23
+ /** True when the matched translation call spans multiple lines. */
24
+ isMultilineCall?: boolean;
25
+ /** True when the call site offset lies inside a line or block comment (TS/JS heuristic). */
26
+ isCommented?: boolean;
27
+ /**
28
+ * True when the file extension is one we treat as executable source for dynamic-key analysis.
29
+ * Non-source extensions are not scanned; this is only set when a provider handled the file.
30
+ */
31
+ isSourceFile?: boolean;
32
+ /**
33
+ * For **`template_interpolation`**: static key prefix up to (but not including) the first
34
+ * `${…}` that cannot be resolved from the const map.
35
+ */
36
+ resolvedPrefix?: string;
37
+ };
38
+
39
+ export type { DynamicKeySite as D, DynamicKeySiteKind as a };
@@ -0,0 +1,52 @@
1
+ import { I as Issue } from './index-X50E1FIX.js';
2
+ import { S as StringLeaf } from './index-BQuLEQ9b.js';
3
+
4
+ type SourcePlaceholderLeaf = {
5
+ path: string;
6
+ value: string;
7
+ };
8
+ type LocalePlaceholderLeaf = SourcePlaceholderLeaf & {
9
+ localeRole: 'source' | 'target';
10
+ localeCode: string;
11
+ localePath?: string;
12
+ };
13
+ declare function sourcePlaceholderValues(configuredPlaceholder: unknown): string[];
14
+ declare function detectSourcePlaceholderLeaves(leaves: readonly StringLeaf[], placeholderValues: readonly string[]): SourcePlaceholderLeaf[];
15
+ declare function detectLocalePlaceholderLeaves(input: {
16
+ leaves: readonly StringLeaf[];
17
+ placeholderValues: readonly string[];
18
+ localeRole: 'source' | 'target';
19
+ localeCode: string;
20
+ localePath?: string;
21
+ }): LocalePlaceholderLeaf[];
22
+ declare function formatSourcePlaceholderMessage(input: {
23
+ count: number;
24
+ samplePaths: readonly string[];
25
+ }): string;
26
+ declare function formatSyncSourcePlaceholderMessage(input: {
27
+ count: number;
28
+ samplePaths: readonly string[];
29
+ }): string;
30
+ declare function formatTargetPlaceholderMessage(input: {
31
+ count: number;
32
+ samplePaths: readonly string[];
33
+ targetLabel?: string;
34
+ }): string;
35
+ declare function issuesFromSourcePlaceholderLeaves(leaves: readonly SourcePlaceholderLeaf[]): Issue[];
36
+ declare function issuesFromTargetPlaceholderLeaves(leaves: readonly LocalePlaceholderLeaf[]): Issue[];
37
+
38
+ type index_LocalePlaceholderLeaf = LocalePlaceholderLeaf;
39
+ type index_SourcePlaceholderLeaf = SourcePlaceholderLeaf;
40
+ declare const index_detectLocalePlaceholderLeaves: typeof detectLocalePlaceholderLeaves;
41
+ declare const index_detectSourcePlaceholderLeaves: typeof detectSourcePlaceholderLeaves;
42
+ declare const index_formatSourcePlaceholderMessage: typeof formatSourcePlaceholderMessage;
43
+ declare const index_formatSyncSourcePlaceholderMessage: typeof formatSyncSourcePlaceholderMessage;
44
+ declare const index_formatTargetPlaceholderMessage: typeof formatTargetPlaceholderMessage;
45
+ declare const index_issuesFromSourcePlaceholderLeaves: typeof issuesFromSourcePlaceholderLeaves;
46
+ declare const index_issuesFromTargetPlaceholderLeaves: typeof issuesFromTargetPlaceholderLeaves;
47
+ declare const index_sourcePlaceholderValues: typeof sourcePlaceholderValues;
48
+ declare namespace index {
49
+ export { type index_LocalePlaceholderLeaf as LocalePlaceholderLeaf, type index_SourcePlaceholderLeaf as SourcePlaceholderLeaf, index_detectLocalePlaceholderLeaves as detectLocalePlaceholderLeaves, index_detectSourcePlaceholderLeaves as detectSourcePlaceholderLeaves, index_formatSourcePlaceholderMessage as formatSourcePlaceholderMessage, index_formatSyncSourcePlaceholderMessage as formatSyncSourcePlaceholderMessage, index_formatTargetPlaceholderMessage as formatTargetPlaceholderMessage, index_issuesFromSourcePlaceholderLeaves as issuesFromSourcePlaceholderLeaves, index_issuesFromTargetPlaceholderLeaves as issuesFromTargetPlaceholderLeaves, index_sourcePlaceholderValues as sourcePlaceholderValues };
50
+ }
51
+
52
+ export { type LocalePlaceholderLeaf as L, type SourcePlaceholderLeaf as S, detectSourcePlaceholderLeaves as a, formatSyncSourcePlaceholderMessage as b, formatTargetPlaceholderMessage as c, detectLocalePlaceholderLeaves as d, issuesFromTargetPlaceholderLeaves as e, formatSourcePlaceholderMessage as f, index as g, issuesFromSourcePlaceholderLeaves as i, sourcePlaceholderValues as s };
@@ -0,0 +1,50 @@
1
+ type IssueSeverity = 'error' | 'warning' | 'info';
2
+ /** Structured finding for automation (CLI `--json` envelope `issues[]`, library `Result`). */
3
+ type Issue = {
4
+ severity: IssueSeverity;
5
+ /** Stable machine id, e.g. `i18nprune.missing_source_locale`. */
6
+ code: string;
7
+ message: string;
8
+ path?: string;
9
+ /**
10
+ * Legacy: path under the repo **`docs/`** tree (no leading slash), e.g. `docs/commands/validate/README`.
11
+ * Prefer **`docHref`** for stable links to the published docs site.
12
+ */
13
+ docPath?: string;
14
+ /** Full HTTPS URL to the documented issue section (e.g. `docs/issues/scan#…`). */
15
+ docHref?: string;
16
+ };
17
+ type ResultMeta = {
18
+ /** Envelope contract version (same value as `RESULT_API_VERSION` in `constants/result.ts`). */
19
+ apiVersion: string;
20
+ schemaVersion?: string;
21
+ cwd?: string;
22
+ };
23
+ /**
24
+ * Unified CLI / library JSON envelope: domain outcome in `ok`, payload in `data`.
25
+ * CLI `--json` mode always serializes this shape; operation-specific payload fields live in `data`.
26
+ */
27
+ type CliJsonEnvelope<K extends string, D> = {
28
+ ok: boolean;
29
+ kind: K;
30
+ data: D;
31
+ issues: Issue[];
32
+ meta: ResultMeta;
33
+ };
34
+ /** Discriminated success variant for programmatic APIs (no `data` on failure). */
35
+ type OkResult<K extends string, D> = {
36
+ ok: true;
37
+ kind: K;
38
+ data: D;
39
+ issues: Issue[];
40
+ meta: ResultMeta;
41
+ };
42
+ type ErrResult = {
43
+ ok: false;
44
+ kind: 'failed';
45
+ issues: Issue[];
46
+ meta: ResultMeta;
47
+ };
48
+ type Result<K extends string, D> = OkResult<K, D> | ErrResult;
49
+
50
+ export type { CliJsonEnvelope as C, ErrResult as E, Issue as I, OkResult as O, Result as R, IssueSeverity as a, ResultMeta as b };