ui-strings 0.1.2 → 0.1.3
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/cli.js +13 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -95,6 +95,16 @@ var URLISH = /^(https?:\/\/|mailto:|tel:|www\.|[./#~@])/;
|
|
|
95
95
|
var HEX_COLOR = /^#[0-9a-fA-F]{3,8}$/;
|
|
96
96
|
var IDENTIFIER_TOKEN = /^[A-Za-z0-9]+([-_][A-Za-z0-9\[\]%./:#]+)+$/;
|
|
97
97
|
var CONSTANT_TOKEN = /^[A-Z0-9_]+$/;
|
|
98
|
+
var CODE_LINE = /^(import|export|const|let|var|function|return|type|interface|if|for|while|switch)\b|^["']use (client|server)["']|[{};]$|^[})\]]|=>/;
|
|
99
|
+
var looksLikeCode = (text) => {
|
|
100
|
+
const lines = text.split(`
|
|
101
|
+
`).map((line) => line.trim()).filter((line) => line !== "");
|
|
102
|
+
if (lines.length < 3) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
const codeLines = lines.filter((line) => CODE_LINE.test(line)).length;
|
|
106
|
+
return codeLines / lines.length >= 0.5;
|
|
107
|
+
};
|
|
98
108
|
var hasNonLatinLetter = (text) => {
|
|
99
109
|
for (const ch of text) {
|
|
100
110
|
const code = ch.codePointAt(0) ?? 0;
|
|
@@ -142,6 +152,9 @@ var withoutPlaceholders = (text) => text.replace(/\{[^{}]*\}/g, "");
|
|
|
142
152
|
var lexical = (text) => hasNonLatinLetter(text) || looksLikeEnglishCopy(text);
|
|
143
153
|
var isCopyEn = (text, context) => {
|
|
144
154
|
const { kind, attr, callee, key } = context;
|
|
155
|
+
if (looksLikeCode(text)) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
145
158
|
if (hasNonLatinLetter(text)) {
|
|
146
159
|
return true;
|
|
147
160
|
}
|