@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,8 @@
1
+ /** `ProjectReportDocument.kind` wire value (see `@i18nprune/core/report-schema`). */
2
+ declare const PROJECT_REPORT_KIND: "i18nprune.projectReport";
3
+ /** `ProjectReportDocument.schemaVersion` for hosted report ingest. */
4
+ declare const PROJECT_REPORT_SCHEMA_VERSION: 1;
5
+ /** Placeholder in built HTML before the CLI inlines the JSON payload. */
6
+ declare const REPORT_INLINE_PAYLOAD_PLACEHOLDER: "__I18NPRUNE_REPORT__";
7
+
8
+ export { PROJECT_REPORT_KIND as P, REPORT_INLINE_PAYLOAD_PLACEHOLDER as R, PROJECT_REPORT_SCHEMA_VERSION as a };
@@ -0,0 +1,102 @@
1
+ import { P as PROJECT_REPORT_KIND, a as PROJECT_REPORT_SCHEMA_VERSION } from './report-D5-6bVFj.js';
2
+ export { R as REPORT_INLINE_PAYLOAD_PLACEHOLDER } from './report-D5-6bVFj.js';
3
+ import { z } from 'zod';
4
+
5
+ /**
6
+ * Canonical project-report Zod schema (source of truth for `@i18nprune/core/report-schema`).
7
+ *
8
+ * Published `@i18nprune/core`
9
+ * and root `i18nprune` bundles include it at build time.
10
+ */
11
+ declare const projectReportDocumentSchema: z.ZodObject<{
12
+ kind: z.ZodLiteral<"i18nprune.projectReport">;
13
+ schemaVersion: z.ZodLiteral<1>;
14
+ generatedAt: z.ZodString;
15
+ toolVersion: z.ZodString;
16
+ project: z.ZodObject<{
17
+ cwd: z.ZodString;
18
+ sourceLocalePath: z.ZodString;
19
+ localesDir: z.ZodString;
20
+ srcRoot: z.ZodString;
21
+ sourceLocaleTag: z.ZodOptional<z.ZodString>;
22
+ environment: z.ZodOptional<z.ZodObject<{
23
+ platform: z.ZodString;
24
+ arch: z.ZodString;
25
+ nodeVersion: z.ZodString;
26
+ osRelease: z.ZodString;
27
+ distro: z.ZodOptional<z.ZodString>;
28
+ wslDistroName: z.ZodOptional<z.ZodString>;
29
+ runtimeFamily: z.ZodOptional<z.ZodEnum<{
30
+ windows: "windows";
31
+ darwin: "darwin";
32
+ linux: "linux";
33
+ "linux-wsl": "linux-wsl";
34
+ "edge-worker": "edge-worker";
35
+ }>>;
36
+ }, z.core.$strip>>;
37
+ }, z.core.$strip>;
38
+ summary: z.ZodObject<{
39
+ missingKeysCount: z.ZodNumber;
40
+ dynamicSitesCount: z.ZodNumber;
41
+ keyObservationsCount: z.ZodNumber;
42
+ sourceFilesScannedCount: z.ZodOptional<z.ZodNumber>;
43
+ ok: z.ZodBoolean;
44
+ }, z.core.$strip>;
45
+ details: z.ZodObject<{
46
+ missingKeys: z.ZodArray<z.ZodString>;
47
+ dynamicSites: z.ZodArray<z.ZodUnknown>;
48
+ keyObservations: z.ZodArray<z.ZodUnknown>;
49
+ }, z.core.$strip>;
50
+ }, z.core.$strip>;
51
+ type ParsedProjectReportDocument = z.infer<typeof projectReportDocumentSchema>;
52
+
53
+ type ProjectReportSummary = {
54
+ missingKeysCount: number;
55
+ dynamicSitesCount: number;
56
+ keyObservationsCount: number;
57
+ /**
58
+ * Source files scanned under `project.srcRoot` (same scope as key-site and dynamic scans).
59
+ * Omitted in older embedded JSON.
60
+ */
61
+ sourceFilesScannedCount?: number;
62
+ /** True when every scanned literal key exists in the source locale JSON. */
63
+ ok: boolean;
64
+ };
65
+ /** Where `i18nprune report` ran; drives stable editor deep links in the HTML UI. */
66
+ type ProjectReportEnvironment = {
67
+ platform: string;
68
+ arch: string;
69
+ nodeVersion: string;
70
+ osRelease: string;
71
+ distro?: string;
72
+ /** Set when the scan ran inside WSL (`WSL_DISTRO_NAME`). Required for `linux-wsl` → Windows editor UNC paths. */
73
+ wslDistroName?: string;
74
+ /**
75
+ * Distinguishes native Linux from WSL. Omitted in older reports (inferred from `wslDistroName` when possible).
76
+ */
77
+ runtimeFamily?: 'windows' | 'darwin' | 'linux' | 'linux-wsl' | 'edge-worker';
78
+ };
79
+ type ProjectReportProjectMeta = {
80
+ cwd: string;
81
+ sourceLocalePath: string;
82
+ localesDir: string;
83
+ srcRoot: string;
84
+ sourceLocaleTag?: string;
85
+ /** Present when generated by a recent CLI; older JSON may omit this. */
86
+ environment?: ProjectReportEnvironment;
87
+ };
88
+ type ProjectReportDocument = {
89
+ kind: typeof PROJECT_REPORT_KIND;
90
+ schemaVersion: typeof PROJECT_REPORT_SCHEMA_VERSION;
91
+ generatedAt: string;
92
+ toolVersion: string;
93
+ project: ProjectReportProjectMeta;
94
+ summary: ProjectReportSummary;
95
+ details: {
96
+ missingKeys: string[];
97
+ dynamicSites: unknown[];
98
+ keyObservations: unknown[];
99
+ };
100
+ };
101
+
102
+ export { PROJECT_REPORT_KIND, PROJECT_REPORT_SCHEMA_VERSION, type ParsedProjectReportDocument, type ProjectReportDocument, type ProjectReportEnvironment, type ProjectReportProjectMeta, type ProjectReportSummary, projectReportDocumentSchema };
@@ -0,0 +1,42 @@
1
+ import { z } from 'zod';
2
+
3
+ // src/shared/constants/report.ts
4
+ var PROJECT_REPORT_KIND = "i18nprune.projectReport";
5
+ var PROJECT_REPORT_SCHEMA_VERSION = 1;
6
+ var REPORT_INLINE_PAYLOAD_PLACEHOLDER = "__I18NPRUNE_REPORT__";
7
+ var projectReportDocumentSchema = z.object({
8
+ kind: z.literal(PROJECT_REPORT_KIND),
9
+ schemaVersion: z.literal(PROJECT_REPORT_SCHEMA_VERSION),
10
+ generatedAt: z.string(),
11
+ toolVersion: z.string(),
12
+ project: z.object({
13
+ cwd: z.string(),
14
+ sourceLocalePath: z.string(),
15
+ localesDir: z.string(),
16
+ srcRoot: z.string(),
17
+ sourceLocaleTag: z.string().optional(),
18
+ environment: z.object({
19
+ platform: z.string(),
20
+ arch: z.string(),
21
+ nodeVersion: z.string(),
22
+ osRelease: z.string(),
23
+ distro: z.string().optional(),
24
+ wslDistroName: z.string().optional(),
25
+ runtimeFamily: z.enum(["windows", "darwin", "linux", "linux-wsl", "edge-worker"]).optional()
26
+ }).optional()
27
+ }),
28
+ summary: z.object({
29
+ missingKeysCount: z.number(),
30
+ dynamicSitesCount: z.number(),
31
+ keyObservationsCount: z.number(),
32
+ sourceFilesScannedCount: z.number().int().nonnegative().optional(),
33
+ ok: z.boolean()
34
+ }),
35
+ details: z.object({
36
+ missingKeys: z.array(z.string()),
37
+ dynamicSites: z.array(z.unknown()),
38
+ keyObservations: z.array(z.unknown())
39
+ })
40
+ });
41
+
42
+ export { PROJECT_REPORT_KIND, PROJECT_REPORT_SCHEMA_VERSION, REPORT_INLINE_PAYLOAD_PLACEHOLDER, projectReportDocumentSchema };
@@ -0,0 +1,200 @@
1
+ import { T as TranslateConfigInput } from './translate-CIHYp7wi.js';
2
+ import { R as RuntimeAdapters } from './adapters-gp1lXp0T.js';
3
+ import { a as TranslatorEnv, b as CacheWarning, T as TranslationSurfaceLeaf } from './coreContext-DMaWLvmB.js';
4
+ import { T as TranslationProviderId } from './providers-0uMEfT6q.js';
5
+ import { I as Issue } from './index-X50E1FIX.js';
6
+ import { T as TranslationResult, a as TranslationLeafMeta, L as LeafDecision } from './index-B_ow_Xvr.js';
7
+ import { E as EffectiveReferenceConfig, a as PreservePolicy, P as ParityPolicy } from './root-2-kCaBvQ.js';
8
+
9
+ type TranslateContext = {
10
+ /** Translate-block config (provider list, primary, policy, workers). */
11
+ readonly config: TranslateConfigInput;
12
+ /** Runtime adapters — required, no Node default. Hosts pass theirs in (CLI: createNodeRuntimeAdapters). */
13
+ readonly adapters: RuntimeAdapters;
14
+ /** Env map — required, no `process.*` access in core. Hosts pass theirs in (CLI: process.env). */
15
+ readonly env: TranslatorEnv;
16
+ };
17
+
18
+ /**
19
+ * Stats captured when translation stops before all planned leaves finished — surfaced on
20
+ * **`TranslateRunInterruptedError`** so a fallback provider can resume without re-translating
21
+ * already-completed leaves.
22
+ */
23
+ type TranslateRunPartialStats = {
24
+ readonly requestAttempts: number;
25
+ readonly retriesMade: number;
26
+ readonly successfulLeaves: number;
27
+ readonly failedRequests: number;
28
+ /** Leaves served from L1 or L2 without a provider network call. */
29
+ readonly cacheHits: number;
30
+ };
31
+
32
+ type TranslateFailureOutcome = 'rate_limited' | 'quota_exceeded' | 'transient_network' | 'provider_unavailable' | 'auth_failure' | 'malformed_response' | 'unknown_hard_stop';
33
+ type ProviderAttemptOutcome = 'success' | 'rate_limited' | 'network_error' | 'non_retryable_error';
34
+
35
+ type HandoffEligibilityRow = {
36
+ readonly id: TranslationProviderId;
37
+ /** True only when this row is first in the eligible list and is `google`. */
38
+ readonly recommended: boolean;
39
+ };
40
+ type HandoffCatalogBuildResult = {
41
+ readonly eligibleRows: readonly HandoffEligibilityRow[];
42
+ /** Human-readable reason per provider id filtered out (for empty-pool messages). */
43
+ readonly ineligibleReasons: Readonly<Record<string, string>>;
44
+ };
45
+
46
+ type IdentitySample = {
47
+ readonly sourceText: string;
48
+ readonly translatedText: string;
49
+ readonly path: string;
50
+ };
51
+ type IdentityStreakState = {
52
+ consecutiveIdentity: number;
53
+ lastPath: string;
54
+ };
55
+ type IdentityStreakInteractive = () => boolean;
56
+ type IdentityStreakConfirmInput = {
57
+ command: string;
58
+ target: string;
59
+ count: number;
60
+ latestPath: string;
61
+ samples: readonly IdentitySample[];
62
+ };
63
+ type IdentityStreakConfirmFn = (input: IdentityStreakConfirmInput) => Promise<boolean>;
64
+ type IdentityStreakGuardOptions = {
65
+ command: string;
66
+ target: string;
67
+ threshold?: number;
68
+ interactive?: IdentityStreakInteractive;
69
+ confirm?: IdentityStreakConfirmFn;
70
+ };
71
+
72
+ type IdentityStreakGuard = {
73
+ onTranslated: (sourceText: string, translatedText: string, path: string) => Promise<void>;
74
+ flushIssues: () => Issue[];
75
+ };
76
+
77
+ /**
78
+ * Translation **`tickProgress`** contract for **`generate`** (orchestration → host UI).
79
+ * Hosts map ticks to TTY / JSON / quiet; core stays I/O-free.
80
+ */
81
+ /**
82
+ * How **`tickProgress`** should interpret the numeric index for strict vs parallel phases.
83
+ */
84
+ type TranslationProgressPhase = 'strict' | 'parallel_pool';
85
+ /**
86
+ * Honest snapshot while a bounded **`translateLeaf`** pool runs (worker slots are stable 0..N-1).
87
+ */
88
+ type TranslationPoolProgressSnapshot = {
89
+ /** Finished **`translateLeaf`** jobs in this pool (monotonic). */
90
+ readonly completed: number;
91
+ /** Total **`translateLeaf`** jobs in this pool. */
92
+ readonly total: number;
93
+ /** In-flight jobs: path per worker slot (slot order). */
94
+ readonly activeBySlot: readonly {
95
+ readonly slot: number;
96
+ readonly path: string;
97
+ }[];
98
+ };
99
+ type TranslationTickProgressOptions = {
100
+ readonly phase?: TranslationProgressPhase;
101
+ /** Present during **`parallel_pool`** when the host should show pool-accurate bar / keys. */
102
+ readonly pool?: TranslationPoolProgressSnapshot;
103
+ };
104
+ type TranslationTickProgressFn = (index: number, total: number, path: string, options?: TranslationTickProgressOptions) => void;
105
+
106
+ /** Inputs for {@link buildTranslateCacheKey} (L1; includes target language in digest). */
107
+ type BuildTranslateCacheKeyInput = {
108
+ sourceText: string;
109
+ sourceLang: string;
110
+ targetLang: string;
111
+ providerId: TranslationProviderId;
112
+ translateConfigEpoch: string;
113
+ };
114
+ /** Inputs for per-locale L2 file keys (target language is the file name). */
115
+ type BuildTranslateCacheKeyForLocaleFileInput = {
116
+ sourceText: string;
117
+ sourceLang: string;
118
+ providerId: TranslationProviderId;
119
+ translateConfigEpoch: string;
120
+ };
121
+ /** One persisted L2 translation row (text-level; no leaf path). */
122
+ type TranslationCacheEntry = {
123
+ text: string;
124
+ leafMeta: TranslationLeafMeta;
125
+ decision?: LeafDecision;
126
+ providerId: TranslationProviderId;
127
+ createdAt: string;
128
+ };
129
+ /** On-disk `translations/<code>.json` envelope (target lang is the file name). */
130
+ type TranslationLocaleCacheFile = {
131
+ version: number;
132
+ updatedAt: string;
133
+ targetLang: string;
134
+ translateConfigEpoch: string;
135
+ inputFilesEpoch: string;
136
+ entries: Record<string, TranslationCacheEntry>;
137
+ };
138
+ type TranslateCacheHitLayer = false | 'l1' | 'l2';
139
+ type TranslateLeafWithL1Result = {
140
+ result: TranslationResult;
141
+ cacheHit: TranslateCacheHitLayer;
142
+ };
143
+ /** In-process L1 memo surface used by {@link translateLeafWithGenerateCache}. */
144
+ type TranslateCacheL1Port = {
145
+ readonly translateConfigEpoch: string;
146
+ get(key: string): TranslationResult | undefined;
147
+ set(key: string, value: TranslationResult): void;
148
+ buildKey(input: {
149
+ sourceText: string;
150
+ sourceLang: string;
151
+ targetLang: string;
152
+ providerId: TranslationProviderId;
153
+ }): string;
154
+ };
155
+ /** Per-target L2 disk store surface (`translations/<code>.json`). */
156
+ type TranslateCacheL2Port = {
157
+ readonly targetLang: string;
158
+ get(key: string): TranslationResult | undefined;
159
+ set(key: string, result: TranslationResult, providerId: TranslationProviderId): void;
160
+ buildKey(input: {
161
+ sourceText: string;
162
+ sourceLang: string;
163
+ providerId: TranslationProviderId;
164
+ }): string;
165
+ flush(): CacheWarning | undefined;
166
+ };
167
+ /** Per-run L1 memo plus optional per-target L2 store for generate. */
168
+ type GenerateTranslateCache = {
169
+ l1?: TranslateCacheL1Port;
170
+ l2?: TranslateCacheL2Port;
171
+ };
172
+ /** L1-only slice shared across targets until L2 is bound per locale. */
173
+ type GenerateTranslateCacheBase = {
174
+ l1?: TranslateCacheL1Port;
175
+ };
176
+ /** Options for {@link openTranslateCacheL2ForTarget}. */
177
+ type OpenTranslateCacheL2Options = {
178
+ /** When true, skip L2 reads (e.g. `generate --force`). */
179
+ bypassL2?: boolean;
180
+ };
181
+
182
+ /**
183
+ * Types for **`generate --resume`** (review-leaf top-up); shared with resume translation helpers.
184
+ */
185
+
186
+ /** Subset of key-reference context used for resume eligibility guards. */
187
+ type GenerateResumeRefContext = {
188
+ uncertainPrefixes: readonly string[];
189
+ };
190
+ /** Inputs for {@link import('../../generate/resume/eligibleResumeLeaves.js').isResumeCandidateLeaf}. */
191
+ type GenerateResumeCandidateLeafInput = {
192
+ leaf: TranslationSurfaceLeaf;
193
+ sourceMap: ReadonlyMap<string, string>;
194
+ refCtx: GenerateResumeRefContext;
195
+ eff: EffectiveReferenceConfig;
196
+ preserve?: PreservePolicy;
197
+ parity?: ParityPolicy;
198
+ };
199
+
200
+ export type { BuildTranslateCacheKeyForLocaleFileInput as B, GenerateResumeRefContext as G, HandoffEligibilityRow as H, IdentityStreakGuard as I, OpenTranslateCacheL2Options as O, ProviderAttemptOutcome as P, TranslateContext as T, TranslationTickProgressOptions as a, TranslationTickProgressFn as b, TranslateFailureOutcome as c, TranslateRunPartialStats as d, GenerateTranslateCache as e, GenerateResumeCandidateLeafInput as f, BuildTranslateCacheKeyInput as g, GenerateTranslateCacheBase as h, HandoffCatalogBuildResult as i, IdentitySample as j, IdentityStreakConfirmFn as k, IdentityStreakConfirmInput as l, IdentityStreakGuardOptions as m, IdentityStreakInteractive as n, IdentityStreakState as o, TranslateCacheHitLayer as p, TranslateCacheL1Port as q, TranslateCacheL2Port as r, TranslateLeafWithL1Result as s, TranslationCacheEntry as t, TranslationLocaleCacheFile as u };