@vocoder/cli 0.13.3 → 0.14.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.
|
@@ -43569,6 +43569,11 @@ var require_brace_expansion = __commonJS({
|
|
|
43569
43569
|
});
|
|
43570
43570
|
|
|
43571
43571
|
// src/utils/api.ts
|
|
43572
|
+
function computeStringsHash(input) {
|
|
43573
|
+
const { createHash } = __require("crypto");
|
|
43574
|
+
const sorted = [...input.texts].sort();
|
|
43575
|
+
return createHash("sha256").update(JSON.stringify({ strings: sorted, appIndustry: input.appIndustry ?? null })).digest("hex");
|
|
43576
|
+
}
|
|
43572
43577
|
function isLimitErrorResponse(value) {
|
|
43573
43578
|
if (!value || typeof value !== "object") {
|
|
43574
43579
|
return false;
|
|
@@ -43722,9 +43727,7 @@ var VocoderAPI = class {
|
|
|
43722
43727
|
async submitTranslation(branch, entries, targetLocales, options, repoIdentity) {
|
|
43723
43728
|
const stringEntries = this.normalizeStringEntries(entries);
|
|
43724
43729
|
const strings = stringEntries.map((entry) => entry.text);
|
|
43725
|
-
const
|
|
43726
|
-
const sortedStrings = [...strings].sort();
|
|
43727
|
-
const stringsHash = crypto.createHash("sha256").update(JSON.stringify(sortedStrings)).digest("hex");
|
|
43730
|
+
const stringsHash = computeStringsHash({ texts: strings, appIndustry: options?.appIndustry ?? null });
|
|
43728
43731
|
return this.request(
|
|
43729
43732
|
"/api/cli/sync",
|
|
43730
43733
|
{
|
|
@@ -51120,34 +51123,64 @@ function buildSelectICU(props) {
|
|
|
51120
51123
|
if (!hasOther) cases.push("other {other}");
|
|
51121
51124
|
return `{value, select, ${cases.join(" ")}}`;
|
|
51122
51125
|
}
|
|
51123
|
-
function extractTextContentFromNodes(children,
|
|
51126
|
+
function extractTextContentFromNodes(children, ctx) {
|
|
51124
51127
|
let text = "";
|
|
51125
51128
|
for (const child of children) {
|
|
51129
|
+
if (ctx.bail) return text;
|
|
51126
51130
|
if (child.type === "JSXText") {
|
|
51127
51131
|
text += child.value;
|
|
51128
51132
|
} else if (child.type === "JSXExpressionContainer") {
|
|
51129
51133
|
const expr = child.expression;
|
|
51130
51134
|
if (expr.type === "Identifier") {
|
|
51135
|
+
ctx.namedVars.add(expr.name);
|
|
51131
51136
|
text += `{${expr.name}}`;
|
|
51132
51137
|
} else if (expr.type === "StringLiteral") {
|
|
51133
51138
|
text += expr.value;
|
|
51139
|
+
} else if (expr.type === "NumericLiteral") {
|
|
51140
|
+
text += String(expr.value);
|
|
51141
|
+
} else if (expr.type === "BooleanLiteral" || expr.type === "NullLiteral") {
|
|
51134
51142
|
} else if (expr.type === "TemplateLiteral") {
|
|
51135
51143
|
for (let i = 0; i < expr.quasis.length; i++) {
|
|
51136
51144
|
text += expr.quasis[i].value.raw;
|
|
51137
51145
|
if (i < expr.expressions.length) {
|
|
51138
51146
|
const e = expr.expressions[i];
|
|
51139
|
-
|
|
51147
|
+
if (e.type === "Identifier") {
|
|
51148
|
+
ctx.namedVars.add(e.name);
|
|
51149
|
+
text += `{${e.name}}`;
|
|
51150
|
+
} else if (e.type === "NumericLiteral") {
|
|
51151
|
+
text += String(e.value);
|
|
51152
|
+
} else if (e.type === "BooleanLiteral" || e.type === "NullLiteral") {
|
|
51153
|
+
} else if (e.type === "ConditionalExpression" || e.type === "LogicalExpression") {
|
|
51154
|
+
ctx.bail = true;
|
|
51155
|
+
return text;
|
|
51156
|
+
} else {
|
|
51157
|
+
const key = ctx.complexCount++;
|
|
51158
|
+
ctx.complexExprs.push({ key, start: e.start, end: e.end });
|
|
51159
|
+
text += `{${key}}`;
|
|
51160
|
+
}
|
|
51140
51161
|
}
|
|
51141
51162
|
}
|
|
51163
|
+
} else if (expr.type === "ConditionalExpression" || expr.type === "LogicalExpression") {
|
|
51164
|
+
ctx.bail = true;
|
|
51165
|
+
return text;
|
|
51166
|
+
} else {
|
|
51167
|
+
const key = ctx.complexCount++;
|
|
51168
|
+
ctx.complexExprs.push({ key, start: expr.start, end: expr.end });
|
|
51169
|
+
text += `{${key}}`;
|
|
51142
51170
|
}
|
|
51143
51171
|
} else if (child.type === "JSXElement") {
|
|
51144
|
-
const
|
|
51172
|
+
const childTagName = child.openingElement.name.type === "JSXIdentifier" ? child.openingElement.name.name : null;
|
|
51173
|
+
if (childTagName && ctx.tComponentNames.has(childTagName)) {
|
|
51174
|
+
ctx.bail = true;
|
|
51175
|
+
return text;
|
|
51176
|
+
}
|
|
51177
|
+
const idx = ctx.elementCount++;
|
|
51145
51178
|
const isSelfClosing = child.openingElement.selfClosing;
|
|
51146
51179
|
if (isSelfClosing) {
|
|
51147
|
-
text +=
|
|
51180
|
+
text += `<${idx}/>`;
|
|
51148
51181
|
} else {
|
|
51149
|
-
const innerText = extractTextContentFromNodes(child.children,
|
|
51150
|
-
text +=
|
|
51182
|
+
const innerText = extractTextContentFromNodes(child.children, ctx);
|
|
51183
|
+
text += `<${idx}>${innerText}</${idx}>`;
|
|
51151
51184
|
}
|
|
51152
51185
|
}
|
|
51153
51186
|
}
|
|
@@ -51359,7 +51392,16 @@ function _extractFromContent(filePath, content) {
|
|
|
51359
51392
|
if (pluralSelectICU) {
|
|
51360
51393
|
text = pluralSelectICU;
|
|
51361
51394
|
} else {
|
|
51362
|
-
|
|
51395
|
+
const extractCtx = {
|
|
51396
|
+
elementCount: 0,
|
|
51397
|
+
complexCount: 0,
|
|
51398
|
+
namedVars: /* @__PURE__ */ new Set(),
|
|
51399
|
+
complexExprs: [],
|
|
51400
|
+
bail: false,
|
|
51401
|
+
tComponentNames: new Set(vocoderImports.keys())
|
|
51402
|
+
};
|
|
51403
|
+
text = extractTextContentFromNodes(path2.node.children, extractCtx);
|
|
51404
|
+
if (extractCtx.bail) return;
|
|
51363
51405
|
}
|
|
51364
51406
|
}
|
|
51365
51407
|
if (!text || text.trim().length === 0) return;
|
|
@@ -51500,4 +51542,4 @@ export {
|
|
|
51500
51542
|
loadVocoderConfig,
|
|
51501
51543
|
StringExtractor
|
|
51502
51544
|
};
|
|
51503
|
-
//# sourceMappingURL=chunk-
|
|
51545
|
+
//# sourceMappingURL=chunk-T4BLNDJ3.mjs.map
|