@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,36 @@
1
+ import { C as CoreContext } from './coreContext-DMaWLvmB.js';
2
+ import { R as RuntimePathPort } from './path-Bfn3SAts.js';
3
+
4
+ type LocaleListRow = {
5
+ code: string;
6
+ localePath: string;
7
+ /** On-disk JSON segments for this locale code (e.g. `app/en.json`, `common/en.json`). */
8
+ segmentCount: number;
9
+ segmentRelativePaths: string[];
10
+ leafCount: number;
11
+ englishIdenticalLeafCount: number | null;
12
+ isSourceLocale: boolean;
13
+ };
14
+
15
+ type ResolveResumeTargetCodesFromRawInput = {
16
+ commandName: string;
17
+ /** Non-empty selector string (after `pickTargetSelector`), including `all` or comma-separated codes. */
18
+ raw: string;
19
+ ctx: CoreContext;
20
+ };
21
+
22
+ type AssertGenerateTargetCodesInput = {
23
+ commandName: string;
24
+ codes: readonly string[];
25
+ sourceLocalePath: string;
26
+ path: RuntimePathPort;
27
+ };
28
+
29
+ type SourceLocaleContext = {
30
+ paths: {
31
+ sourceLocale: string;
32
+ };
33
+ path: RuntimePathPort;
34
+ };
35
+
36
+ export type { AssertGenerateTargetCodesInput as A, LocaleListRow as L, ResolveResumeTargetCodesFromRawInput as R, SourceLocaleContext as S };
@@ -0,0 +1,122 @@
1
+ import { D as DynamicKeySite } from './index-DdjljwMj.js';
2
+ import { I as Issue } from './index-X50E1FIX.js';
3
+ import { S as StringLeaf } from './index-BQuLEQ9b.js';
4
+ import { S as StringPresencePolicy } from './root-2-kCaBvQ.js';
5
+ import { R as RunEmitter } from './index-BgG01AKL.js';
6
+
7
+ /**
8
+ * Folded summary of key-site observations for usage detection (`cleanup`, `missing`, reference rules).
9
+ * Built with per-file const maps (avoids cross-file `const` identifier collisions).
10
+ */
11
+ type ProjectLiteralKeyUsage = {
12
+ /** Fully resolved `literal` and `template_resolved` keys. */
13
+ resolvedKeys: ReadonlySet<string>;
14
+ /** Static prefixes from `template_partial` when `uncertainPrefix` is set. */
15
+ uncertainPrefixes: ReadonlySet<string>;
16
+ /** First path segment (or bracket segment) of each resolved or uncertain path — prefix matching for “used under root”. */
17
+ usedRoots: ReadonlySet<string>;
18
+ };
19
+
20
+ type CleanupStringPresenceEvidence = {
21
+ key: string;
22
+ kind: 'guard_skipped' | 'warn_hit';
23
+ locations: string[];
24
+ };
25
+ type ResolveCleanupKeysWithStringPresenceInput = {
26
+ candidates: readonly string[];
27
+ leaves: readonly StringLeaf[];
28
+ stringPresence: StringPresencePolicy;
29
+ stringPresenceMaxHitsPerKey: number;
30
+ skipStringPresenceCheck: boolean;
31
+ stringPresenceAvailable: boolean;
32
+ hasStringPresence: (sample: string) => boolean;
33
+ getStringPresenceLocations: (sample: string, maxHits: number) => string[];
34
+ shouldRunStringPresenceForKey?: (input: {
35
+ key: string;
36
+ value: string;
37
+ }) => boolean;
38
+ };
39
+ /**
40
+ * Pure policy evaluator for cleanup string-presence handling.
41
+ * Host provides the underlying presence probe and optional locations lookup.
42
+ */
43
+ declare function resolveCleanupKeysWithStringPresencePolicy(input: ResolveCleanupKeysWithStringPresenceInput): {
44
+ safeToRemove: string[];
45
+ evidence: CleanupStringPresenceEvidence[];
46
+ };
47
+
48
+ type CleanupJsonRunSummary = {
49
+ durationMs: number;
50
+ command: 'cleanup';
51
+ ok: boolean;
52
+ counts: {
53
+ remove: number;
54
+ dynamicKeySites: number;
55
+ };
56
+ };
57
+ type CleanupJsonOutput = {
58
+ wouldRemove: number;
59
+ keys: string[];
60
+ dynamicKeySites: number;
61
+ uncertainPrefixes: string[];
62
+ /** Present when the CLI emits the final `cleanup` envelope. */
63
+ summary?: CleanupJsonRunSummary;
64
+ };
65
+ type CleanupRunOptions = {
66
+ /** Report candidates only; do not write (CLI `--dry-run`). */
67
+ dryRun?: boolean;
68
+ /** Skip host string-presence (ripgrep) probes — static unused-key list only. */
69
+ skipStringPresenceCheck?: boolean;
70
+ };
71
+ type CleanupHostHooks = {
72
+ emit?: RunEmitter;
73
+ runId?: string;
74
+ isStringPresenceAvailable: () => boolean;
75
+ hasStringPresence: (sample: string) => boolean;
76
+ getStringPresenceLocations: (sample: string, maxHits: number) => string[];
77
+ /**
78
+ * When false, core skips the string-presence guard for this key (CLI sets false for all keys when `--no-rg`).
79
+ * Default: apply guard per {@link reference.stringPresence} when probes are enabled.
80
+ */
81
+ shouldRunStringPresenceForKey?: (input: {
82
+ key: string;
83
+ value: string;
84
+ }) => boolean;
85
+ };
86
+ type CleanupSegmentWrite = {
87
+ sourcePath: string;
88
+ relativePath: string;
89
+ nextSourceJson: unknown;
90
+ removedPaths: string[];
91
+ };
92
+ type CleanupWritePlan = {
93
+ /** Segment file writes (one for flat_file, many for locale_directory layouts). */
94
+ writes: CleanupSegmentWrite[];
95
+ keys: string[];
96
+ /** Primary path for legacy messages (first write). */
97
+ sourcePath: string;
98
+ nextSourceJson: unknown;
99
+ removedPaths: string[];
100
+ };
101
+ type CleanupRunResult = {
102
+ payload: CleanupJsonOutput;
103
+ issues: Issue[];
104
+ writePlan: CleanupWritePlan;
105
+ sourceLeaves: StringLeaf[];
106
+ allKeyPathCount: number;
107
+ candidateKeys: string[];
108
+ safeToRemove: string[];
109
+ excludedUncertain: number;
110
+ dynamicSites: readonly DynamicKeySite[];
111
+ keyObservationsCount: number;
112
+ stringPresenceAvailable: boolean;
113
+ stringPresenceEvidence: CleanupStringPresenceEvidence[];
114
+ };
115
+
116
+ /** One on-disk source locale segment file for cleanup read/write. */
117
+ type CleanupSourceSegmentRef = {
118
+ absolutePath: string;
119
+ relativePath: string;
120
+ };
121
+
122
+ export { type CleanupWritePlan as C, type ProjectLiteralKeyUsage as P, type ResolveCleanupKeysWithStringPresenceInput as R, type CleanupHostHooks as a, type CleanupRunOptions as b, type CleanupRunResult as c, type CleanupSourceSegmentRef as d, type CleanupJsonOutput as e, type CleanupJsonRunSummary as f, type CleanupSegmentWrite as g, type CleanupStringPresenceEvidence as h, resolveCleanupKeysWithStringPresencePolicy as r };
package/dist/sync.d.ts ADDED
@@ -0,0 +1,86 @@
1
+ import { M as MergeToTemplateOptions } from './prune-c6hKZCv_.js';
2
+ export { m as mergeToTemplateShape, p as pruneToTemplateShape } from './prune-c6hKZCv_.js';
3
+ import { a as PreservePolicy } from './root-2-kCaBvQ.js';
4
+ import { C as CoreContext } from './coreContext-DMaWLvmB.js';
5
+ import { L as LocaleMetadataReport } from './index-DLwTogCo.js';
6
+ import { S as SyncHostHooks, a as SyncRunResult, b as SyncRunOptions, c as SyncHumanLeafSummary } from './humanEmit-ygNlYX-S.js';
7
+ export { d as SyncFileLine, e as SyncJsonOutput, f as SyncLocaleDisplayGroup } from './humanEmit-ygNlYX-S.js';
8
+ import { S as StringLeaf } from './index-BQuLEQ9b.js';
9
+ import { p as parseSyncLangSelection } from './targets-EmtKyr6F.js';
10
+ import 'zod';
11
+ import './path-Bfn3SAts.js';
12
+ import './fs-BUYD8ZhA.js';
13
+ import './providers-0uMEfT6q.js';
14
+ import './capabilities-x74cD2Hu.js';
15
+ import './adapters-gp1lXp0T.js';
16
+ import './index-DdjljwMj.js';
17
+ import './index-X50E1FIX.js';
18
+ import './index-BgG01AKL.js';
19
+ import './index-DeIw-cZd.js';
20
+ import './localeTargetCodes-BBIQjauw.js';
21
+
22
+ /**
23
+ * Merge + prune a target locale JSON toward the source template shape (sync semantics).
24
+ * Pure: no filesystem; use in `sync` and tests.
25
+ */
26
+ declare function computeSyncedLocaleJson(template: unknown, cur: unknown, preserve: PreservePolicy | undefined, mergeOpts: MergeToTemplateOptions | undefined): {
27
+ next: unknown;
28
+ wouldChange: boolean;
29
+ };
30
+ /**
31
+ * Convert structured locale terminals (`{ value: string, ... }`) into plain string leaves.
32
+ * Keeps unrelated object/array structure intact.
33
+ */
34
+ declare function stripStructuredLeafMetadata(root: unknown): unknown;
35
+
36
+ /** Per-file `localeMetadataReports` row when sync does not apply a metadata mode. */
37
+ declare function idleLocaleMetadataReportForSkippedSync(totalSourceLeafPaths: number): LocaleMetadataReport;
38
+ declare function emitSyncHumanMessages(host: Pick<SyncHostHooks, 'emit' | 'runId'>, input: {
39
+ result: SyncRunResult;
40
+ dryRun: boolean;
41
+ listLimit: number;
42
+ explicitStripMetadata: boolean;
43
+ explicitMetadata: boolean;
44
+ }): void;
45
+ declare function runSync(ctx: CoreContext, opts: SyncRunOptions, host: SyncHostHooks): SyncRunResult;
46
+
47
+ /**
48
+ * Human-readable leaf string at a source template dotted path (plain terminal or `{ value }` object).
49
+ */
50
+ declare function readLeafDisplayString(root: unknown, pathStr: string): string | undefined;
51
+ /**
52
+ * Map a collected string-leaf path (may end in `.value` for structured leaves) to a template path, if any.
53
+ */
54
+ declare function canonicalTemplatePathForCollectedLeaf(leafPath: string, templatePaths: ReadonlySet<string>): string | null;
55
+ /**
56
+ * Derive **`hydrated` / preserved / pruned-extra** counts for stderr messaging.
57
+ *
58
+ * **`mergedLocaleJson`** should be **`computeSyncedLocaleJson`…`next`** (**before** `--metadata` / `--strip-metadata`)
59
+ * so “extra path removed” reflects template merge/prune, not metadata reshaping alone.
60
+ *
61
+ * - **Hydrated**: template paths with no readable leaf (`string` or structured `.value`) in the locale before sync.
62
+ * - **Preserved**: template paths where a readable leaf already existed beforehand.
63
+ * - **Pruned extras**: logical translation paths from **`collectTranslationSurfaceLeaves(before)`** that do not map to any template path and
64
+ * are absent from **`mergedLocaleJson`** (best-effort; compares raw collected paths).
65
+ */
66
+ declare function summarizeSyncLeavesForHumanLog(sourceLeaves: readonly StringLeaf[], cur: unknown, mergedLocaleJson: unknown): SyncHumanLeafSummary;
67
+
68
+ /** Normalized `sync --target` selection (same as {@link parseSyncLangSelection}). */
69
+ type SyncLangSelection = ReturnType<typeof parseSyncLangSelection>;
70
+ /**
71
+ * Decide which locale JSON files sync should touch, and which requested codes have no file yet.
72
+ * Pure: no I/O. Caller runs {@link assertNotSourceTargetLocale} for each code when `mode === 'codes'`.
73
+ *
74
+ * @param localeJsonBasenames — Every `*.json` basename in `localesDir` (e.g. `en.json`, `fr.json`).
75
+ * @param sourceJsonBasename — Source-of-truth file basename (e.g. `en.json`).
76
+ */
77
+ declare function resolveSyncTargetFiles(input: {
78
+ localeJsonBasenames: readonly string[];
79
+ sourceJsonBasename: string;
80
+ selection: SyncLangSelection;
81
+ }): {
82
+ targetFiles: string[];
83
+ missingLocaleCodes: string[];
84
+ };
85
+
86
+ export { SyncHostHooks, SyncHumanLeafSummary, type SyncLangSelection, SyncRunOptions, SyncRunResult, canonicalTemplatePathForCollectedLeaf, computeSyncedLocaleJson, emitSyncHumanMessages, idleLocaleMetadataReportForSkippedSync, readLeafDisplayString, resolveSyncTargetFiles, runSync, stripStructuredLeafMetadata, summarizeSyncLeavesForHumanLog };