lingo.dev 0.113.6 → 0.113.8
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/build/cli.cjs +400 -119
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +302 -21
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/build/cli.mjs
CHANGED
|
@@ -3637,39 +3637,320 @@ function parsePropertyLine(line) {
|
|
|
3637
3637
|
};
|
|
3638
3638
|
}
|
|
3639
3639
|
|
|
3640
|
+
// src/cli/loaders/xcode-strings/tokenizer.ts
|
|
3641
|
+
var Tokenizer = class {
|
|
3642
|
+
input;
|
|
3643
|
+
pos;
|
|
3644
|
+
line;
|
|
3645
|
+
column;
|
|
3646
|
+
constructor(input2) {
|
|
3647
|
+
this.input = input2;
|
|
3648
|
+
this.pos = 0;
|
|
3649
|
+
this.line = 1;
|
|
3650
|
+
this.column = 1;
|
|
3651
|
+
}
|
|
3652
|
+
tokenize() {
|
|
3653
|
+
const tokens = [];
|
|
3654
|
+
while (this.pos < this.input.length) {
|
|
3655
|
+
const char = this.current();
|
|
3656
|
+
if (this.isWhitespace(char)) {
|
|
3657
|
+
this.advance();
|
|
3658
|
+
continue;
|
|
3659
|
+
}
|
|
3660
|
+
if (char === "/" && this.peek() === "/") {
|
|
3661
|
+
tokens.push(this.scanSingleLineComment());
|
|
3662
|
+
continue;
|
|
3663
|
+
}
|
|
3664
|
+
if (char === "/" && this.peek() === "*") {
|
|
3665
|
+
tokens.push(this.scanMultiLineComment());
|
|
3666
|
+
continue;
|
|
3667
|
+
}
|
|
3668
|
+
if (char === '"') {
|
|
3669
|
+
tokens.push(this.scanString());
|
|
3670
|
+
continue;
|
|
3671
|
+
}
|
|
3672
|
+
if (char === "=") {
|
|
3673
|
+
tokens.push(this.makeToken("EQUALS" /* EQUALS */, "="));
|
|
3674
|
+
this.advance();
|
|
3675
|
+
continue;
|
|
3676
|
+
}
|
|
3677
|
+
if (char === ";") {
|
|
3678
|
+
tokens.push(this.makeToken("SEMICOLON" /* SEMICOLON */, ";"));
|
|
3679
|
+
this.advance();
|
|
3680
|
+
continue;
|
|
3681
|
+
}
|
|
3682
|
+
this.advance();
|
|
3683
|
+
}
|
|
3684
|
+
tokens.push(this.makeToken("EOF" /* EOF */, ""));
|
|
3685
|
+
return tokens;
|
|
3686
|
+
}
|
|
3687
|
+
scanString() {
|
|
3688
|
+
const start = this.getPosition();
|
|
3689
|
+
let value = "";
|
|
3690
|
+
this.advance();
|
|
3691
|
+
while (this.pos < this.input.length) {
|
|
3692
|
+
const char = this.current();
|
|
3693
|
+
if (char === "\\") {
|
|
3694
|
+
this.advance();
|
|
3695
|
+
if (this.pos < this.input.length) {
|
|
3696
|
+
const nextChar = this.current();
|
|
3697
|
+
value += "\\" + nextChar;
|
|
3698
|
+
this.advance();
|
|
3699
|
+
}
|
|
3700
|
+
continue;
|
|
3701
|
+
}
|
|
3702
|
+
if (char === '"') {
|
|
3703
|
+
this.advance();
|
|
3704
|
+
return {
|
|
3705
|
+
type: "STRING" /* STRING */,
|
|
3706
|
+
value,
|
|
3707
|
+
...start
|
|
3708
|
+
};
|
|
3709
|
+
}
|
|
3710
|
+
value += char;
|
|
3711
|
+
this.advance();
|
|
3712
|
+
}
|
|
3713
|
+
return {
|
|
3714
|
+
type: "STRING" /* STRING */,
|
|
3715
|
+
value,
|
|
3716
|
+
...start
|
|
3717
|
+
};
|
|
3718
|
+
}
|
|
3719
|
+
scanSingleLineComment() {
|
|
3720
|
+
const start = this.getPosition();
|
|
3721
|
+
let value = "";
|
|
3722
|
+
this.advance();
|
|
3723
|
+
this.advance();
|
|
3724
|
+
while (this.pos < this.input.length && this.current() !== "\n") {
|
|
3725
|
+
value += this.current();
|
|
3726
|
+
this.advance();
|
|
3727
|
+
}
|
|
3728
|
+
return {
|
|
3729
|
+
type: "COMMENT_SINGLE" /* COMMENT_SINGLE */,
|
|
3730
|
+
value,
|
|
3731
|
+
...start
|
|
3732
|
+
};
|
|
3733
|
+
}
|
|
3734
|
+
scanMultiLineComment() {
|
|
3735
|
+
const start = this.getPosition();
|
|
3736
|
+
let value = "";
|
|
3737
|
+
this.advance();
|
|
3738
|
+
this.advance();
|
|
3739
|
+
while (this.pos < this.input.length) {
|
|
3740
|
+
if (this.current() === "*" && this.peek() === "/") {
|
|
3741
|
+
this.advance();
|
|
3742
|
+
this.advance();
|
|
3743
|
+
return {
|
|
3744
|
+
type: "COMMENT_MULTI" /* COMMENT_MULTI */,
|
|
3745
|
+
value,
|
|
3746
|
+
...start
|
|
3747
|
+
};
|
|
3748
|
+
}
|
|
3749
|
+
value += this.current();
|
|
3750
|
+
this.advance();
|
|
3751
|
+
}
|
|
3752
|
+
return {
|
|
3753
|
+
type: "COMMENT_MULTI" /* COMMENT_MULTI */,
|
|
3754
|
+
value,
|
|
3755
|
+
...start
|
|
3756
|
+
};
|
|
3757
|
+
}
|
|
3758
|
+
current() {
|
|
3759
|
+
return this.input[this.pos];
|
|
3760
|
+
}
|
|
3761
|
+
peek() {
|
|
3762
|
+
if (this.pos + 1 < this.input.length) {
|
|
3763
|
+
return this.input[this.pos + 1];
|
|
3764
|
+
}
|
|
3765
|
+
return null;
|
|
3766
|
+
}
|
|
3767
|
+
advance() {
|
|
3768
|
+
if (this.pos < this.input.length) {
|
|
3769
|
+
if (this.current() === "\n") {
|
|
3770
|
+
this.line++;
|
|
3771
|
+
this.column = 1;
|
|
3772
|
+
} else {
|
|
3773
|
+
this.column++;
|
|
3774
|
+
}
|
|
3775
|
+
this.pos++;
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
isWhitespace(char) {
|
|
3779
|
+
return char === " " || char === " " || char === "\n" || char === "\r";
|
|
3780
|
+
}
|
|
3781
|
+
getPosition() {
|
|
3782
|
+
return {
|
|
3783
|
+
line: this.line,
|
|
3784
|
+
column: this.column
|
|
3785
|
+
};
|
|
3786
|
+
}
|
|
3787
|
+
makeToken(type, value) {
|
|
3788
|
+
return {
|
|
3789
|
+
type,
|
|
3790
|
+
value,
|
|
3791
|
+
...this.getPosition()
|
|
3792
|
+
};
|
|
3793
|
+
}
|
|
3794
|
+
};
|
|
3795
|
+
|
|
3796
|
+
// src/cli/loaders/xcode-strings/escape.ts
|
|
3797
|
+
function unescapeString(raw) {
|
|
3798
|
+
let result = "";
|
|
3799
|
+
let i = 0;
|
|
3800
|
+
while (i < raw.length) {
|
|
3801
|
+
if (raw[i] === "\\" && i + 1 < raw.length) {
|
|
3802
|
+
const nextChar = raw[i + 1];
|
|
3803
|
+
switch (nextChar) {
|
|
3804
|
+
case '"':
|
|
3805
|
+
result += '"';
|
|
3806
|
+
i += 2;
|
|
3807
|
+
break;
|
|
3808
|
+
case "\\":
|
|
3809
|
+
result += "\\";
|
|
3810
|
+
i += 2;
|
|
3811
|
+
break;
|
|
3812
|
+
case "n":
|
|
3813
|
+
result += "\n";
|
|
3814
|
+
i += 2;
|
|
3815
|
+
break;
|
|
3816
|
+
case "t":
|
|
3817
|
+
result += " ";
|
|
3818
|
+
i += 2;
|
|
3819
|
+
break;
|
|
3820
|
+
case "r":
|
|
3821
|
+
result += "\r";
|
|
3822
|
+
i += 2;
|
|
3823
|
+
break;
|
|
3824
|
+
default:
|
|
3825
|
+
result += raw[i];
|
|
3826
|
+
i++;
|
|
3827
|
+
break;
|
|
3828
|
+
}
|
|
3829
|
+
} else {
|
|
3830
|
+
result += raw[i];
|
|
3831
|
+
i++;
|
|
3832
|
+
}
|
|
3833
|
+
}
|
|
3834
|
+
return result;
|
|
3835
|
+
}
|
|
3836
|
+
function escapeString(str) {
|
|
3837
|
+
if (str == null) {
|
|
3838
|
+
return "";
|
|
3839
|
+
}
|
|
3840
|
+
let result = "";
|
|
3841
|
+
for (let i = 0; i < str.length; i++) {
|
|
3842
|
+
const char = str[i];
|
|
3843
|
+
switch (char) {
|
|
3844
|
+
case "\\":
|
|
3845
|
+
result += "\\\\";
|
|
3846
|
+
break;
|
|
3847
|
+
case '"':
|
|
3848
|
+
result += '\\"';
|
|
3849
|
+
break;
|
|
3850
|
+
case "\n":
|
|
3851
|
+
result += "\\n";
|
|
3852
|
+
break;
|
|
3853
|
+
case "\r":
|
|
3854
|
+
result += "\\r";
|
|
3855
|
+
break;
|
|
3856
|
+
case " ":
|
|
3857
|
+
result += "\\t";
|
|
3858
|
+
break;
|
|
3859
|
+
default:
|
|
3860
|
+
result += char;
|
|
3861
|
+
break;
|
|
3862
|
+
}
|
|
3863
|
+
}
|
|
3864
|
+
return result;
|
|
3865
|
+
}
|
|
3866
|
+
|
|
3867
|
+
// src/cli/loaders/xcode-strings/parser.ts
|
|
3868
|
+
var Parser = class {
|
|
3869
|
+
tokens;
|
|
3870
|
+
pos;
|
|
3871
|
+
constructor(tokens) {
|
|
3872
|
+
this.tokens = tokens;
|
|
3873
|
+
this.pos = 0;
|
|
3874
|
+
}
|
|
3875
|
+
parse() {
|
|
3876
|
+
const result = {};
|
|
3877
|
+
while (this.pos < this.tokens.length) {
|
|
3878
|
+
const token = this.current();
|
|
3879
|
+
if (token.type === "COMMENT_SINGLE" /* COMMENT_SINGLE */ || token.type === "COMMENT_MULTI" /* COMMENT_MULTI */) {
|
|
3880
|
+
this.advance();
|
|
3881
|
+
continue;
|
|
3882
|
+
}
|
|
3883
|
+
if (token.type === "EOF" /* EOF */) {
|
|
3884
|
+
break;
|
|
3885
|
+
}
|
|
3886
|
+
if (token.type === "STRING" /* STRING */) {
|
|
3887
|
+
const entry = this.parseEntry();
|
|
3888
|
+
if (entry) {
|
|
3889
|
+
result[entry.key] = entry.value;
|
|
3890
|
+
}
|
|
3891
|
+
continue;
|
|
3892
|
+
}
|
|
3893
|
+
this.advance();
|
|
3894
|
+
}
|
|
3895
|
+
return result;
|
|
3896
|
+
}
|
|
3897
|
+
parseEntry() {
|
|
3898
|
+
const keyToken = this.current();
|
|
3899
|
+
if (keyToken.type !== "STRING" /* STRING */) {
|
|
3900
|
+
return null;
|
|
3901
|
+
}
|
|
3902
|
+
const key = keyToken.value;
|
|
3903
|
+
this.advance();
|
|
3904
|
+
if (!this.expect("EQUALS" /* EQUALS */)) {
|
|
3905
|
+
return null;
|
|
3906
|
+
}
|
|
3907
|
+
const valueToken = this.current();
|
|
3908
|
+
if (valueToken.type !== "STRING" /* STRING */) {
|
|
3909
|
+
return null;
|
|
3910
|
+
}
|
|
3911
|
+
const rawValue = valueToken.value;
|
|
3912
|
+
this.advance();
|
|
3913
|
+
if (!this.expect("SEMICOLON" /* SEMICOLON */)) {
|
|
3914
|
+
}
|
|
3915
|
+
const value = unescapeString(rawValue);
|
|
3916
|
+
return { key, value };
|
|
3917
|
+
}
|
|
3918
|
+
current() {
|
|
3919
|
+
return this.tokens[this.pos];
|
|
3920
|
+
}
|
|
3921
|
+
advance() {
|
|
3922
|
+
if (this.pos < this.tokens.length) {
|
|
3923
|
+
this.pos++;
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3926
|
+
expect(type) {
|
|
3927
|
+
if (this.current()?.type === type) {
|
|
3928
|
+
this.advance();
|
|
3929
|
+
return true;
|
|
3930
|
+
}
|
|
3931
|
+
return false;
|
|
3932
|
+
}
|
|
3933
|
+
};
|
|
3934
|
+
|
|
3640
3935
|
// src/cli/loaders/xcode-strings.ts
|
|
3641
3936
|
function createXcodeStringsLoader() {
|
|
3642
3937
|
return createLoader({
|
|
3643
3938
|
async pull(locale, input2) {
|
|
3644
|
-
const
|
|
3645
|
-
const
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
if (trimmedLine && !trimmedLine.startsWith("//")) {
|
|
3649
|
-
const match2 = trimmedLine.match(/^"(.+)"\s*=\s*"(.+)";$/);
|
|
3650
|
-
if (match2) {
|
|
3651
|
-
const [, key, value] = match2;
|
|
3652
|
-
result[key] = unescapeXcodeString(value);
|
|
3653
|
-
}
|
|
3654
|
-
}
|
|
3655
|
-
}
|
|
3939
|
+
const tokenizer = new Tokenizer(input2);
|
|
3940
|
+
const tokens = tokenizer.tokenize();
|
|
3941
|
+
const parser = new Parser(tokens);
|
|
3942
|
+
const result = parser.parse();
|
|
3656
3943
|
return result;
|
|
3657
3944
|
},
|
|
3658
3945
|
async push(locale, payload) {
|
|
3659
|
-
const lines = Object.entries(payload).map(([key, value]) => {
|
|
3660
|
-
const escapedValue =
|
|
3946
|
+
const lines = Object.entries(payload).filter(([_36, value]) => value != null).map(([key, value]) => {
|
|
3947
|
+
const escapedValue = escapeString(value);
|
|
3661
3948
|
return `"${key}" = "${escapedValue}";`;
|
|
3662
3949
|
});
|
|
3663
3950
|
return lines.join("\n");
|
|
3664
3951
|
}
|
|
3665
3952
|
});
|
|
3666
3953
|
}
|
|
3667
|
-
function unescapeXcodeString(str) {
|
|
3668
|
-
return str.replace(/\\"/g, '"').replace(/\\n/g, "\n").replace(/\\\\/g, "\\");
|
|
3669
|
-
}
|
|
3670
|
-
function escapeXcodeString(str) {
|
|
3671
|
-
return str.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n");
|
|
3672
|
-
}
|
|
3673
3954
|
|
|
3674
3955
|
// src/cli/loaders/xcode-stringsdict.ts
|
|
3675
3956
|
import plist from "plist";
|
|
@@ -13098,7 +13379,7 @@ async function renderHero2() {
|
|
|
13098
13379
|
// package.json
|
|
13099
13380
|
var package_default = {
|
|
13100
13381
|
name: "lingo.dev",
|
|
13101
|
-
version: "0.113.
|
|
13382
|
+
version: "0.113.8",
|
|
13102
13383
|
description: "Lingo.dev CLI",
|
|
13103
13384
|
private: false,
|
|
13104
13385
|
publishConfig: {
|