@localheroai/cli 0.0.82 → 0.0.83-rc.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/utils/translation-processor.js +27 -7
- package/dist/utils/translation-processor.js.map +1 -1
- package/package.json +1 -1
- package/dist/api/auth.d.ts +0 -2
- package/dist/api/client.d.ts +0 -3
- package/dist/api/imports.d.ts +0 -5
- package/dist/api/projects.d.ts +0 -2
- package/dist/api/translation-jobs.js +0 -28
- package/dist/api/translation-jobs.js.map +0 -1
- package/dist/api/translations.d.ts +0 -15
- package/dist/cli.d.ts +0 -2
- package/dist/commands/_sync.js +0 -22
- package/dist/commands/_sync.js.map +0 -1
- package/dist/commands/_translate.js +0 -3
- package/dist/commands/_translate.js.map +0 -1
- package/dist/commands/github-action.js +0 -111
- package/dist/commands/github-action.js.map +0 -1
- package/dist/commands/init.d.ts +0 -1
- package/dist/commands/login.d.ts +0 -16
- package/dist/commands/sync.d.ts +0 -20
- package/dist/commands/sync.js +0 -22
- package/dist/commands/sync.js.map +0 -1
- package/dist/commands/translate.d.ts +0 -14
- package/dist/document-formats/markdown.js +0 -519
- package/dist/document-formats/markdown.js.map +0 -1
- package/dist/document-formats/types.js +0 -11
- package/dist/document-formats/types.js.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/types/index.d.ts +0 -75
- package/dist/types/translate/index.js +0 -2
- package/dist/types/translate/index.js.map +0 -1
- package/dist/utils/auth.d.ts +0 -2
- package/dist/utils/chunked-json-processor.js +0 -52
- package/dist/utils/chunked-json-processor.js.map +0 -1
- package/dist/utils/common.js +0 -9
- package/dist/utils/common.js.map +0 -1
- package/dist/utils/config.d.ts +0 -23
- package/dist/utils/errors.js +0 -37
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/files.d.ts +0 -32
- package/dist/utils/git-diff.js +0 -251
- package/dist/utils/git-diff.js.map +0 -1
- package/dist/utils/git.d.ts +0 -21
- package/dist/utils/github.d.ts +0 -241
- package/dist/utils/import-service.d.ts +0 -4
- package/dist/utils/po-utils-fallback.js +0 -254
- package/dist/utils/po-utils-fallback.js.map +0 -1
- package/dist/utils/prompt-service.d.ts +0 -44
- package/dist/utils/streaming-json-processor.js +0 -125
- package/dist/utils/streaming-json-processor.js.map +0 -1
- package/dist/utils/sync-service.d.ts +0 -58
- package/dist/utils/translation-updater/common.d.ts +0 -6
- package/dist/utils/translation-updater/index.d.ts +0 -5
- package/dist/utils/translation-updater/json-handler.d.ts +0 -5
- package/dist/utils/translation-updater/yaml-handler.d.ts +0 -5
- package/dist/utils/translation-utils.d.ts +0 -30
- package/dist/utils/updater.js +0 -38
- package/dist/utils/updater.js.map +0 -1
|
@@ -1,519 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { fromMarkdown } from 'mdast-util-from-markdown';
|
|
3
|
-
import { frontmatter } from 'micromark-extension-frontmatter';
|
|
4
|
-
import { frontmatterFromMarkdown } from 'mdast-util-frontmatter';
|
|
5
|
-
import { gfm } from 'micromark-extension-gfm';
|
|
6
|
-
import { gfmFromMarkdown } from 'mdast-util-gfm';
|
|
7
|
-
import yaml from 'yaml';
|
|
8
|
-
import { DocumentFormatError } from './types.js';
|
|
9
|
-
const FORMAT = 'markdown';
|
|
10
|
-
const FORMAT_VERSION = 1;
|
|
11
|
-
const RESERVED_PLACEHOLDER_PREFIX = '__LOCALHERO_MD_';
|
|
12
|
-
const RESERVED_PLACEHOLDER_PATTERN = /__LOCALHERO_MD_U\d{4}_P\d{4}_[0-9A-F]{8}__/g;
|
|
13
|
-
function sha256(value) {
|
|
14
|
-
return createHash('sha256').update(value, 'utf8').digest('hex');
|
|
15
|
-
}
|
|
16
|
-
function parseMarkdown(source) {
|
|
17
|
-
const offsetBase = source.charCodeAt(0) === 0xfeff ? 1 : 0;
|
|
18
|
-
const root = fromMarkdown(source.slice(offsetBase), {
|
|
19
|
-
extensions: [gfm(), frontmatter(['yaml'])],
|
|
20
|
-
mdastExtensions: [gfmFromMarkdown(), frontmatterFromMarkdown(['yaml'])]
|
|
21
|
-
});
|
|
22
|
-
return { root, offsetBase };
|
|
23
|
-
}
|
|
24
|
-
function nodeRange(node, offsetBase) {
|
|
25
|
-
const start = node.position?.start.offset;
|
|
26
|
-
const end = node.position?.end.offset;
|
|
27
|
-
if (start === undefined || end === undefined)
|
|
28
|
-
return null;
|
|
29
|
-
return { start: start + offsetBase, end: end + offsetBase };
|
|
30
|
-
}
|
|
31
|
-
function childContentRange(node, offsetBase) {
|
|
32
|
-
const positionedChildren = (node.children ?? [])
|
|
33
|
-
.map(child => nodeRange(child, offsetBase))
|
|
34
|
-
.filter((range) => range !== null);
|
|
35
|
-
if (positionedChildren.length === 0)
|
|
36
|
-
return null;
|
|
37
|
-
return {
|
|
38
|
-
start: positionedChildren[0].start,
|
|
39
|
-
end: positionedChildren[positionedChildren.length - 1].end
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function walk(node, visit) {
|
|
43
|
-
visit(node);
|
|
44
|
-
for (const child of node.children ?? []) {
|
|
45
|
-
walk(child, visit);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function plainText(node) {
|
|
49
|
-
const values = [];
|
|
50
|
-
walk(node, child => {
|
|
51
|
-
if ((child.type === 'text' || child.type === 'inlineCode') && child.value) {
|
|
52
|
-
values.push(child.value);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return values.join('').trim();
|
|
56
|
-
}
|
|
57
|
-
function collectSemanticNodes(root, offsetBase) {
|
|
58
|
-
const nodes = [];
|
|
59
|
-
const collect = (node) => {
|
|
60
|
-
if (node.type === 'heading' || node.type === 'paragraph' || node.type === 'tableCell') {
|
|
61
|
-
if (childContentRange(node, offsetBase))
|
|
62
|
-
nodes.push(node);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (node.type === 'code' || node.type === 'html' || node.type === 'yaml')
|
|
66
|
-
return;
|
|
67
|
-
for (const child of node.children ?? [])
|
|
68
|
-
collect(child);
|
|
69
|
-
};
|
|
70
|
-
collect(root);
|
|
71
|
-
return nodes.sort((left, right) => {
|
|
72
|
-
const leftStart = nodeRange(left, offsetBase)?.start ?? 0;
|
|
73
|
-
const rightStart = nodeRange(right, offsetBase)?.start ?? 0;
|
|
74
|
-
return leftStart - rightStart;
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
function roleForNode(node) {
|
|
78
|
-
if (node.type === 'heading')
|
|
79
|
-
return 'heading';
|
|
80
|
-
if (node.type === 'tableCell')
|
|
81
|
-
return 'table-cell';
|
|
82
|
-
return 'paragraph';
|
|
83
|
-
}
|
|
84
|
-
function addWholeNodeRange(ranges, node, offsetBase, unitRange, kind) {
|
|
85
|
-
const range = nodeRange(node, offsetBase);
|
|
86
|
-
if (!range || range.start < unitRange.start || range.end > unitRange.end)
|
|
87
|
-
return;
|
|
88
|
-
ranges.push({ ...range, kind });
|
|
89
|
-
}
|
|
90
|
-
function addWrapperRanges(ranges, node, offsetBase, unitRange, kind) {
|
|
91
|
-
const range = nodeRange(node, offsetBase);
|
|
92
|
-
const contents = childContentRange(node, offsetBase);
|
|
93
|
-
if (!range || !contents || range.start < unitRange.start || range.end > unitRange.end)
|
|
94
|
-
return;
|
|
95
|
-
if (range.start < contents.start) {
|
|
96
|
-
ranges.push({ start: range.start, end: contents.start, kind: `${kind}-open` });
|
|
97
|
-
}
|
|
98
|
-
if (contents.end < range.end) {
|
|
99
|
-
ranges.push({ start: contents.end, end: range.end, kind: `${kind}-close` });
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
function isAutolink(node, source, offsetBase) {
|
|
103
|
-
if (node.type !== 'link' || !node.url)
|
|
104
|
-
return false;
|
|
105
|
-
const range = nodeRange(node, offsetBase);
|
|
106
|
-
if (!range)
|
|
107
|
-
return false;
|
|
108
|
-
const raw = source.slice(range.start, range.end);
|
|
109
|
-
const anchor = plainText(node);
|
|
110
|
-
return anchor === node.url && (raw === node.url || raw === `<${node.url}>`);
|
|
111
|
-
}
|
|
112
|
-
function normalizeProtectedRanges(ranges) {
|
|
113
|
-
const sorted = [...ranges].sort((left, right) => left.start - right.start || right.end - left.end);
|
|
114
|
-
const normalized = [];
|
|
115
|
-
for (const range of sorted) {
|
|
116
|
-
if (range.start === range.end)
|
|
117
|
-
continue;
|
|
118
|
-
const previous = normalized[normalized.length - 1];
|
|
119
|
-
if (!previous || range.start >= previous.end) {
|
|
120
|
-
normalized.push(range);
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
if (range.end <= previous.end)
|
|
124
|
-
continue;
|
|
125
|
-
throw new DocumentFormatError('overlapping_protected_ranges', 'Markdown parser produced partially overlapping protected ranges.');
|
|
126
|
-
}
|
|
127
|
-
return normalized;
|
|
128
|
-
}
|
|
129
|
-
function protectedRangesForNode(node, source, offsetBase, unitRange) {
|
|
130
|
-
const ranges = [];
|
|
131
|
-
const atomicTypes = new Set([
|
|
132
|
-
'inlineCode',
|
|
133
|
-
'html',
|
|
134
|
-
'image',
|
|
135
|
-
'imageReference',
|
|
136
|
-
'footnoteReference',
|
|
137
|
-
'break'
|
|
138
|
-
]);
|
|
139
|
-
const wrapperTypes = new Set(['emphasis', 'strong', 'delete', 'linkReference']);
|
|
140
|
-
walk(node, child => {
|
|
141
|
-
if (atomicTypes.has(child.type)) {
|
|
142
|
-
addWholeNodeRange(ranges, child, offsetBase, unitRange, child.type);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
if (child.type === 'link') {
|
|
146
|
-
if (isAutolink(child, source, offsetBase)) {
|
|
147
|
-
addWholeNodeRange(ranges, child, offsetBase, unitRange, 'autolink');
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
addWrapperRanges(ranges, child, offsetBase, unitRange, 'link');
|
|
151
|
-
}
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
if (wrapperTypes.has(child.type)) {
|
|
155
|
-
addWrapperRanges(ranges, child, offsetBase, unitRange, child.type);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
const original = source.slice(unitRange.start, unitRange.end);
|
|
159
|
-
const newlinePattern = /(?:\r\n|\r|\n)[ \t]*(?:(?:>[ \t]?)+)?/g;
|
|
160
|
-
for (const match of original.matchAll(newlinePattern)) {
|
|
161
|
-
const relativeStart = match.index;
|
|
162
|
-
ranges.push({
|
|
163
|
-
start: unitRange.start + relativeStart,
|
|
164
|
-
end: unitRange.start + relativeStart + match[0].length,
|
|
165
|
-
kind: 'line-break'
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
return normalizeProtectedRanges(ranges);
|
|
169
|
-
}
|
|
170
|
-
function makePlaceholder(unitIndex, fragmentIndex, value) {
|
|
171
|
-
const digest = sha256(value).slice(0, 8).toUpperCase();
|
|
172
|
-
return `${RESERVED_PLACEHOLDER_PREFIX}U${String(unitIndex + 1).padStart(4, '0')}_P${String(fragmentIndex + 1).padStart(4, '0')}_${digest}__`;
|
|
173
|
-
}
|
|
174
|
-
function templateWithPlaceholders(source, unitRange, protectedRanges, unitIndex) {
|
|
175
|
-
let template = source.slice(unitRange.start, unitRange.end);
|
|
176
|
-
const placeholders = [];
|
|
177
|
-
const fragments = [];
|
|
178
|
-
protectedRanges.forEach((range, fragmentIndex) => {
|
|
179
|
-
const value = source.slice(range.start, range.end);
|
|
180
|
-
const token = makePlaceholder(unitIndex, fragmentIndex, value);
|
|
181
|
-
placeholders.push({ token, kind: range.kind });
|
|
182
|
-
fragments.push({ token, value });
|
|
183
|
-
});
|
|
184
|
-
for (let index = protectedRanges.length - 1; index >= 0; index--) {
|
|
185
|
-
const range = protectedRanges[index];
|
|
186
|
-
const relativeStart = range.start - unitRange.start;
|
|
187
|
-
const relativeEnd = range.end - unitRange.start;
|
|
188
|
-
template = template.slice(0, relativeStart) + placeholders[index].token + template.slice(relativeEnd);
|
|
189
|
-
}
|
|
190
|
-
return { template, placeholders, fragments };
|
|
191
|
-
}
|
|
192
|
-
function hasTranslatableText(template) {
|
|
193
|
-
const withoutPlaceholders = template.replace(RESERVED_PLACEHOLDER_PATTERN, '');
|
|
194
|
-
return /[\p{L}\p{N}]/u.test(withoutPlaceholders);
|
|
195
|
-
}
|
|
196
|
-
function yamlInnerRange(source, range) {
|
|
197
|
-
const raw = source.slice(range.start, range.end);
|
|
198
|
-
const opening = /^---[ \t]*(?:\r\n|\n|\r)/.exec(raw);
|
|
199
|
-
const closing = /(?:\r\n|\n|\r)---[ \t]*$/.exec(raw);
|
|
200
|
-
if (!opening || !closing || closing.index < opening[0].length) {
|
|
201
|
-
throw new DocumentFormatError('invalid_frontmatter', 'Could not locate YAML frontmatter fences.');
|
|
202
|
-
}
|
|
203
|
-
return {
|
|
204
|
-
start: range.start + opening[0].length,
|
|
205
|
-
end: range.start + closing.index
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
function rangeFromYamlNode(node) {
|
|
209
|
-
if (!node || typeof node !== 'object' || !('range' in node))
|
|
210
|
-
return null;
|
|
211
|
-
const range = node.range;
|
|
212
|
-
return Array.isArray(range) && range.length === 3 ? range : null;
|
|
213
|
-
}
|
|
214
|
-
function frontmatterDrafts(source, parsed, fields) {
|
|
215
|
-
if (fields.length === 0)
|
|
216
|
-
return [];
|
|
217
|
-
const yamlNode = parsed.root.children?.find(child => child.type === 'yaml');
|
|
218
|
-
if (!yamlNode)
|
|
219
|
-
return [];
|
|
220
|
-
const frontmatterRange = nodeRange(yamlNode, parsed.offsetBase);
|
|
221
|
-
if (!frontmatterRange)
|
|
222
|
-
return [];
|
|
223
|
-
const innerRange = yamlInnerRange(source, frontmatterRange);
|
|
224
|
-
const inner = source.slice(innerRange.start, innerRange.end);
|
|
225
|
-
const document = yaml.parseDocument(inner, { keepSourceTokens: true, strict: true });
|
|
226
|
-
if (document.errors.length > 0) {
|
|
227
|
-
throw new DocumentFormatError('invalid_frontmatter', `YAML frontmatter could not be parsed: ${document.errors[0].message}`);
|
|
228
|
-
}
|
|
229
|
-
if (!document.contents || !yaml.isMap(document.contents)) {
|
|
230
|
-
throw new DocumentFormatError('invalid_frontmatter', 'YAML frontmatter must be a mapping.');
|
|
231
|
-
}
|
|
232
|
-
const drafts = [];
|
|
233
|
-
for (const field of new Set(fields)) {
|
|
234
|
-
const valueNode = document.get(field, true);
|
|
235
|
-
if (valueNode === undefined)
|
|
236
|
-
continue;
|
|
237
|
-
if (!yaml.isScalar(valueNode) || typeof valueNode.value !== 'string') {
|
|
238
|
-
throw new DocumentFormatError('unsupported_frontmatter_value', `Configured frontmatter field "${field}" must be a string scalar.`);
|
|
239
|
-
}
|
|
240
|
-
if (valueNode.tag) {
|
|
241
|
-
throw new DocumentFormatError('unsupported_frontmatter_value', `Configured frontmatter field "${field}" may not use a YAML tag.`);
|
|
242
|
-
}
|
|
243
|
-
if (valueNode.type === 'BLOCK_FOLDED' || valueNode.type === 'BLOCK_LITERAL') {
|
|
244
|
-
throw new DocumentFormatError('unsupported_frontmatter_style', `Configured frontmatter field "${field}" uses a block scalar, which is not supported yet.`);
|
|
245
|
-
}
|
|
246
|
-
if (valueNode.value.includes('\n') || valueNode.value.includes('\r')) {
|
|
247
|
-
throw new DocumentFormatError('unsupported_frontmatter_style', `Configured frontmatter field "${field}" contains a multiline value, which is not supported yet.`);
|
|
248
|
-
}
|
|
249
|
-
const scalarRange = rangeFromYamlNode(valueNode);
|
|
250
|
-
if (!scalarRange) {
|
|
251
|
-
throw new DocumentFormatError('invalid_frontmatter', `Configured frontmatter field "${field}" has no source range.`);
|
|
252
|
-
}
|
|
253
|
-
const absoluteRange = {
|
|
254
|
-
start: innerRange.start + scalarRange[0],
|
|
255
|
-
end: innerRange.start + scalarRange[1]
|
|
256
|
-
};
|
|
257
|
-
drafts.push({
|
|
258
|
-
role: 'frontmatter',
|
|
259
|
-
range: absoluteRange,
|
|
260
|
-
source: valueNode.value,
|
|
261
|
-
context: { headingPath: [], frontmatterField: field },
|
|
262
|
-
placeholders: [],
|
|
263
|
-
protectedFragments: [],
|
|
264
|
-
serialization: 'yaml-scalar',
|
|
265
|
-
yamlScalarType: valueNode.type
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
return drafts;
|
|
269
|
-
}
|
|
270
|
-
function markdownDrafts(source, parsed, unitOffset) {
|
|
271
|
-
const drafts = [];
|
|
272
|
-
const headingStack = [];
|
|
273
|
-
for (const node of collectSemanticNodes(parsed.root, parsed.offsetBase)) {
|
|
274
|
-
const range = childContentRange(node, parsed.offsetBase);
|
|
275
|
-
if (!range)
|
|
276
|
-
continue;
|
|
277
|
-
const role = roleForNode(node);
|
|
278
|
-
const ranges = protectedRangesForNode(node, source, parsed.offsetBase, range);
|
|
279
|
-
const templated = templateWithPlaceholders(source, range, ranges, unitOffset + drafts.length);
|
|
280
|
-
if (hasTranslatableText(templated.template)) {
|
|
281
|
-
drafts.push({
|
|
282
|
-
role,
|
|
283
|
-
range,
|
|
284
|
-
source: templated.template,
|
|
285
|
-
context: { headingPath: headingStack.map(heading => heading.title) },
|
|
286
|
-
placeholders: templated.placeholders,
|
|
287
|
-
protectedFragments: templated.fragments,
|
|
288
|
-
serialization: 'markdown'
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
if (node.type === 'heading' && node.depth) {
|
|
292
|
-
const title = plainText(node);
|
|
293
|
-
const depth = node.depth;
|
|
294
|
-
while (headingStack.length > 0 && headingStack.at(-1).depth >= depth)
|
|
295
|
-
headingStack.pop();
|
|
296
|
-
headingStack.push({ depth, title });
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
return drafts;
|
|
300
|
-
}
|
|
301
|
-
function serializeYamlScalar(value, existingType) {
|
|
302
|
-
if (value.includes('\n') || value.includes('\r')) {
|
|
303
|
-
throw new DocumentFormatError('unsupported_frontmatter_translation', 'Multiline frontmatter translations are not supported yet.');
|
|
304
|
-
}
|
|
305
|
-
const document = new yaml.Document();
|
|
306
|
-
document.contents = document.createNode({});
|
|
307
|
-
const root = document.contents;
|
|
308
|
-
const key = '__localhero_scalar__';
|
|
309
|
-
if (!value.includes('\n') && (existingType === 'QUOTE_SINGLE' || existingType === 'QUOTE_DOUBLE')) {
|
|
310
|
-
const scalar = new yaml.Scalar(value);
|
|
311
|
-
scalar.type = existingType;
|
|
312
|
-
root.set(key, scalar);
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
root.set(key, document.createNode(value));
|
|
316
|
-
}
|
|
317
|
-
const emitted = document.toString({ indent: 2, lineWidth: 0 });
|
|
318
|
-
const prefix = `${key}: `;
|
|
319
|
-
const prefixIndex = emitted.indexOf(prefix);
|
|
320
|
-
if (prefixIndex < 0) {
|
|
321
|
-
throw new DocumentFormatError('yaml_serialization_failed', 'Could not serialize a frontmatter value.');
|
|
322
|
-
}
|
|
323
|
-
return emitted.slice(prefixIndex + prefix.length).replace(/\n$/, '');
|
|
324
|
-
}
|
|
325
|
-
function countOccurrences(value, needle) {
|
|
326
|
-
let count = 0;
|
|
327
|
-
let offset = 0;
|
|
328
|
-
while ((offset = value.indexOf(needle, offset)) !== -1) {
|
|
329
|
-
count++;
|
|
330
|
-
offset += needle.length;
|
|
331
|
-
}
|
|
332
|
-
return count;
|
|
333
|
-
}
|
|
334
|
-
function restoreMarkdownTranslation(translation, patch, unitId) {
|
|
335
|
-
const expectedTokens = new Set(patch.protectedFragments.map(fragment => fragment.token));
|
|
336
|
-
const seenTokens = translation.match(RESERVED_PLACEHOLDER_PATTERN) ?? [];
|
|
337
|
-
for (const token of seenTokens) {
|
|
338
|
-
if (!expectedTokens.has(token)) {
|
|
339
|
-
throw new DocumentFormatError('unknown_placeholder', `Translation for ${unitId} contains an unknown Localhero placeholder.`, unitId);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
for (const fragment of patch.protectedFragments) {
|
|
343
|
-
if (countOccurrences(translation, fragment.token) !== 1) {
|
|
344
|
-
throw new DocumentFormatError('invalid_placeholder_count', `Translation for ${unitId} must contain placeholder ${fragment.token} exactly once.`, unitId);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
if (/[\r\n]/.test(translation)) {
|
|
348
|
-
throw new DocumentFormatError('unexpected_line_break', `Translation for ${unitId} introduced an unprotected line break.`, unitId);
|
|
349
|
-
}
|
|
350
|
-
let restored = translation;
|
|
351
|
-
for (const fragment of patch.protectedFragments) {
|
|
352
|
-
restored = restored.replace(fragment.token, fragment.value);
|
|
353
|
-
}
|
|
354
|
-
return restored;
|
|
355
|
-
}
|
|
356
|
-
function structuralSignature(source) {
|
|
357
|
-
const { root } = parseMarkdown(source);
|
|
358
|
-
const shape = [];
|
|
359
|
-
const protectedValues = [];
|
|
360
|
-
walk(root, node => {
|
|
361
|
-
if (node.type === 'root' || node.type === 'text' || node.type === 'yaml')
|
|
362
|
-
return;
|
|
363
|
-
const properties = { type: node.type };
|
|
364
|
-
if (node.depth !== undefined)
|
|
365
|
-
properties.depth = node.depth;
|
|
366
|
-
if (node.lang !== undefined)
|
|
367
|
-
properties.lang = node.lang;
|
|
368
|
-
if (node.meta !== undefined)
|
|
369
|
-
properties.meta = node.meta;
|
|
370
|
-
if (node.ordered !== undefined)
|
|
371
|
-
properties.ordered = node.ordered;
|
|
372
|
-
if (node.start !== undefined)
|
|
373
|
-
properties.start = node.start;
|
|
374
|
-
if (node.checked !== undefined)
|
|
375
|
-
properties.checked = node.checked;
|
|
376
|
-
if (node.align !== undefined)
|
|
377
|
-
properties.align = node.align;
|
|
378
|
-
shape.push(JSON.stringify(properties));
|
|
379
|
-
if (node.value !== undefined ||
|
|
380
|
-
node.url !== undefined ||
|
|
381
|
-
node.title !== undefined ||
|
|
382
|
-
node.identifier !== undefined ||
|
|
383
|
-
node.label !== undefined) {
|
|
384
|
-
protectedValues.push(JSON.stringify({
|
|
385
|
-
type: node.type,
|
|
386
|
-
value: node.type === 'code' || node.type === 'inlineCode' || node.type === 'html'
|
|
387
|
-
? node.value
|
|
388
|
-
: undefined,
|
|
389
|
-
url: node.url,
|
|
390
|
-
title: node.title,
|
|
391
|
-
identifier: node.identifier,
|
|
392
|
-
label: node.label
|
|
393
|
-
}));
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
return { shape, protectedValues: protectedValues.sort() };
|
|
397
|
-
}
|
|
398
|
-
function assertSameStructure(source, output) {
|
|
399
|
-
const before = structuralSignature(source);
|
|
400
|
-
const after = structuralSignature(output);
|
|
401
|
-
if (JSON.stringify(before) !== JSON.stringify(after)) {
|
|
402
|
-
throw new DocumentFormatError('markdown_structure_changed', 'Translated Markdown changed protected document structure.');
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
function assertNonOverlappingPatches(patches) {
|
|
406
|
-
const sorted = [...patches].sort((left, right) => left.range.start - right.range.start);
|
|
407
|
-
for (let index = 1; index < sorted.length; index++) {
|
|
408
|
-
if (sorted[index].range.start < sorted[index - 1].range.end) {
|
|
409
|
-
throw new DocumentFormatError('overlapping_patches', 'Document apply plan contains overlapping patches.');
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
export class MarkdownDocumentAdapter {
|
|
414
|
-
format = FORMAT;
|
|
415
|
-
version = FORMAT_VERSION;
|
|
416
|
-
extract(source, options = {}) {
|
|
417
|
-
if (source.includes(RESERVED_PLACEHOLDER_PREFIX)) {
|
|
418
|
-
throw new DocumentFormatError('reserved_placeholder_collision', `Source contains the reserved placeholder prefix ${RESERVED_PLACEHOLDER_PREFIX}.`);
|
|
419
|
-
}
|
|
420
|
-
const parsed = parseMarkdown(source);
|
|
421
|
-
const frontmatter = frontmatterDrafts(source, parsed, options.translateFrontmatterFields ?? []);
|
|
422
|
-
const markdown = markdownDrafts(source, parsed, frontmatter.length);
|
|
423
|
-
const drafts = [...frontmatter, ...markdown].sort((left, right) => left.range.start - right.range.start);
|
|
424
|
-
const sourceSha256 = sha256(source);
|
|
425
|
-
const units = [];
|
|
426
|
-
const patches = [];
|
|
427
|
-
drafts.forEach((draft, index) => {
|
|
428
|
-
const id = `u${String(index + 1).padStart(4, '0')}`;
|
|
429
|
-
units.push({
|
|
430
|
-
id,
|
|
431
|
-
role: draft.role,
|
|
432
|
-
source: draft.source,
|
|
433
|
-
sourceHash: sha256(draft.source),
|
|
434
|
-
context: draft.context,
|
|
435
|
-
placeholders: draft.placeholders
|
|
436
|
-
});
|
|
437
|
-
patches.push({
|
|
438
|
-
unitId: id,
|
|
439
|
-
range: draft.range,
|
|
440
|
-
original: source.slice(draft.range.start, draft.range.end),
|
|
441
|
-
protectedFragments: draft.protectedFragments,
|
|
442
|
-
serialization: draft.serialization,
|
|
443
|
-
yamlScalarType: draft.yamlScalarType
|
|
444
|
-
});
|
|
445
|
-
});
|
|
446
|
-
const manifest = {
|
|
447
|
-
format: this.format,
|
|
448
|
-
formatVersion: this.version,
|
|
449
|
-
sourceSha256,
|
|
450
|
-
units
|
|
451
|
-
};
|
|
452
|
-
return {
|
|
453
|
-
manifest,
|
|
454
|
-
plan: { sourceSha256, patches }
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
apply(source, extraction, translations) {
|
|
458
|
-
const actualSha = sha256(source);
|
|
459
|
-
if (actualSha !== extraction.manifest.sourceSha256 || actualSha !== extraction.plan.sourceSha256) {
|
|
460
|
-
throw new DocumentFormatError('stale_source', 'Source changed after document units were extracted.');
|
|
461
|
-
}
|
|
462
|
-
if (extraction.manifest.format !== this.format || extraction.manifest.formatVersion !== this.version) {
|
|
463
|
-
throw new DocumentFormatError('unsupported_contract', 'Extraction uses an unsupported document contract.');
|
|
464
|
-
}
|
|
465
|
-
assertNonOverlappingPatches(extraction.plan.patches);
|
|
466
|
-
const unitsById = new Map(extraction.manifest.units.map(unit => [unit.id, unit]));
|
|
467
|
-
const patchesById = new Map(extraction.plan.patches.map(patch => [patch.unitId, patch]));
|
|
468
|
-
if (unitsById.size !== extraction.manifest.units.length || patchesById.size !== extraction.plan.patches.length) {
|
|
469
|
-
throw new DocumentFormatError('invalid_extraction', 'Extraction contains duplicate unit IDs.');
|
|
470
|
-
}
|
|
471
|
-
if (unitsById.size !== patchesById.size || [...unitsById.keys()].some(id => !patchesById.has(id))) {
|
|
472
|
-
throw new DocumentFormatError('invalid_extraction', 'Manifest units do not match the private apply plan.');
|
|
473
|
-
}
|
|
474
|
-
const translationsById = new Map();
|
|
475
|
-
for (const translation of translations) {
|
|
476
|
-
if (translationsById.has(translation.id)) {
|
|
477
|
-
throw new DocumentFormatError('duplicate_translation', `Translation ID ${translation.id} appears more than once.`, translation.id);
|
|
478
|
-
}
|
|
479
|
-
if (!unitsById.has(translation.id)) {
|
|
480
|
-
throw new DocumentFormatError('unknown_translation', `Translation ID ${translation.id} is not part of this extraction.`, translation.id);
|
|
481
|
-
}
|
|
482
|
-
translationsById.set(translation.id, translation.text);
|
|
483
|
-
}
|
|
484
|
-
for (const unit of extraction.manifest.units) {
|
|
485
|
-
if (!translationsById.has(unit.id)) {
|
|
486
|
-
throw new DocumentFormatError('missing_translation', `Translation is missing for unit ${unit.id}.`, unit.id);
|
|
487
|
-
}
|
|
488
|
-
if (sha256(unit.source) !== unit.sourceHash) {
|
|
489
|
-
throw new DocumentFormatError('invalid_extraction', `Source hash is invalid for unit ${unit.id}.`, unit.id);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
const replacements = [];
|
|
493
|
-
for (const unit of extraction.manifest.units) {
|
|
494
|
-
const patch = patchesById.get(unit.id);
|
|
495
|
-
if (source.slice(patch.range.start, patch.range.end) !== patch.original) {
|
|
496
|
-
throw new DocumentFormatError('stale_source', `Source range changed for unit ${unit.id}.`, unit.id);
|
|
497
|
-
}
|
|
498
|
-
const translated = translationsById.get(unit.id);
|
|
499
|
-
if (translated === unit.source)
|
|
500
|
-
continue;
|
|
501
|
-
const value = patch.serialization === 'yaml-scalar'
|
|
502
|
-
? serializeYamlScalar(translated, patch.yamlScalarType)
|
|
503
|
-
: restoreMarkdownTranslation(translated, patch, unit.id);
|
|
504
|
-
replacements.push({ range: patch.range, value });
|
|
505
|
-
}
|
|
506
|
-
if (replacements.length === 0)
|
|
507
|
-
return source;
|
|
508
|
-
let output = source;
|
|
509
|
-
replacements
|
|
510
|
-
.sort((left, right) => right.range.start - left.range.start)
|
|
511
|
-
.forEach(replacement => {
|
|
512
|
-
output = output.slice(0, replacement.range.start) + replacement.value + output.slice(replacement.range.end);
|
|
513
|
-
});
|
|
514
|
-
assertSameStructure(source, output);
|
|
515
|
-
return output;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
export const markdownDocumentAdapter = new MarkdownDocumentAdapter();
|
|
519
|
-
//# sourceMappingURL=markdown.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/document-formats/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAGL,mBAAmB,EAMpB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,GAAG,UAAU,CAAC;AAC1B,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,2BAA2B,GAAG,iBAAiB,CAAC;AACtD,MAAM,4BAA4B,GAAG,6CAA6C,CAAC;AA+EnF,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,aAAa,CAAC,MAAc;IACnC,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,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KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,MAAM,CAAC;QAC7C,IAAI,MAAM,GAAG,MAAM,CAAC;QACpB,YAAY;aACT,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;aAC3D,OAAO,CAAC,WAAW,CAAC,EAAE;YACrB,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9G,CAAC,CAAC,CAAC;QAEL,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACpC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,uBAAuB,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/document-formats/types.ts"],"names":[],"mappings":"AAqDA,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAE1B;IAEA;IAHlB,YACkB,IAAY,EAC5B,OAAe,EACC,MAAe;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,SAAI,GAAJ,IAAI,CAAQ;QAEZ,WAAM,GAAN,MAAM,CAAS;QAG/B,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF"}
|
package/dist/index.d.ts
DELETED
package/dist/types/index.d.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
export interface AuthConfig {
|
|
2
|
-
api_key: string;
|
|
3
|
-
last_verified: string;
|
|
4
|
-
}
|
|
5
|
-
export interface TranslationFile {
|
|
6
|
-
paths: string[];
|
|
7
|
-
ignore?: string[];
|
|
8
|
-
}
|
|
9
|
-
export interface ProjectConfig {
|
|
10
|
-
schemaVersion: string;
|
|
11
|
-
projectId: string;
|
|
12
|
-
sourceLocale: string;
|
|
13
|
-
outputLocales: string[];
|
|
14
|
-
translationFiles: TranslationFile;
|
|
15
|
-
lastSyncedAt: string | null;
|
|
16
|
-
}
|
|
17
|
-
export interface ApiError {
|
|
18
|
-
code: string;
|
|
19
|
-
message: string;
|
|
20
|
-
}
|
|
21
|
-
export interface Project {
|
|
22
|
-
id: string;
|
|
23
|
-
name: string;
|
|
24
|
-
}
|
|
25
|
-
export interface Organization {
|
|
26
|
-
name: string;
|
|
27
|
-
projects: Project[];
|
|
28
|
-
}
|
|
29
|
-
export interface VerifyApiKeyResult {
|
|
30
|
-
error?: ApiError;
|
|
31
|
-
organization?: Organization;
|
|
32
|
-
}
|
|
33
|
-
export interface TranslationOptions {
|
|
34
|
-
verbose?: boolean;
|
|
35
|
-
commit?: boolean;
|
|
36
|
-
}
|
|
37
|
-
export interface SyncOptions {
|
|
38
|
-
verbose?: boolean;
|
|
39
|
-
}
|
|
40
|
-
export interface FsDependencies {
|
|
41
|
-
readFile: (path: string, options: {
|
|
42
|
-
encoding: string;
|
|
43
|
-
}) => Promise<string>;
|
|
44
|
-
writeFile: (path: string, data: string, options?: any) => Promise<void>;
|
|
45
|
-
mkdir: (path: string, options?: any) => Promise<void>;
|
|
46
|
-
readdir: (path: string) => Promise<string[]>;
|
|
47
|
-
stat: (path: string) => Promise<any>;
|
|
48
|
-
access: (path: string, mode?: number) => Promise<void>;
|
|
49
|
-
}
|
|
50
|
-
export interface ConsoleDependencies {
|
|
51
|
-
log: (message?: any, ...optionalParams: any[]) => void;
|
|
52
|
-
error: (message?: any, ...optionalParams: any[]) => void;
|
|
53
|
-
warn: (message?: any, ...optionalParams: any[]) => void;
|
|
54
|
-
}
|
|
55
|
-
export interface ApiRequestOptions {
|
|
56
|
-
method?: string;
|
|
57
|
-
headers?: Record<string, string>;
|
|
58
|
-
body?: any;
|
|
59
|
-
apiKey?: string;
|
|
60
|
-
}
|
|
61
|
-
export interface ApiClientConfig {
|
|
62
|
-
baseUrl?: string;
|
|
63
|
-
apiKey?: string;
|
|
64
|
-
}
|
|
65
|
-
export interface TranslationData {
|
|
66
|
-
[locale: string]: {
|
|
67
|
-
[key: string]: string | TranslationData;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
export interface TranslationUpdateResult {
|
|
71
|
-
added: number;
|
|
72
|
-
updated: number;
|
|
73
|
-
unchanged: number;
|
|
74
|
-
errors: string[];
|
|
75
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/translate/index.ts"],"names":[],"mappings":""}
|