protobuf-fastdsl 0.1.1 → 0.1.2
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/index.js +43 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -418,6 +418,24 @@ function buildSingularBlock(field, index) {
|
|
|
418
418
|
]
|
|
419
419
|
};
|
|
420
420
|
}
|
|
421
|
+
if (typeName === "sint_32") {
|
|
422
|
+
return {
|
|
423
|
+
declare: [` const ${valueVar} = obj.${name};`],
|
|
424
|
+
size: [
|
|
425
|
+
` if (${valueVar} != null && ${valueVar} !== 0) {`,
|
|
426
|
+
` const _val = ((${valueVar} << 1) ^ (${valueVar} >> 31)) >>> 0;`,
|
|
427
|
+
` size += ${tagLength};`,
|
|
428
|
+
varintSize("_val", " "),
|
|
429
|
+
` }`
|
|
430
|
+
],
|
|
431
|
+
write: [
|
|
432
|
+
` if (${valueVar} != null && ${valueVar} !== 0) {`,
|
|
433
|
+
writeTag(fieldNumber, 0, " "),
|
|
434
|
+
writeVarint(`((${valueVar} << 1) ^ (${valueVar} >> 31)) >>> 0`, " "),
|
|
435
|
+
` }`
|
|
436
|
+
]
|
|
437
|
+
};
|
|
438
|
+
}
|
|
421
439
|
if (wireType === 0 /* Varint */) {
|
|
422
440
|
return {
|
|
423
441
|
declare: [` const ${valueVar} = obj.${name};`],
|
|
@@ -639,6 +657,28 @@ function buildRepeatedBlock(field, index) {
|
|
|
639
657
|
]
|
|
640
658
|
};
|
|
641
659
|
}
|
|
660
|
+
if (typeName === "sint_32") {
|
|
661
|
+
return {
|
|
662
|
+
declare: [` const ${arrayVar} = obj.${name};`],
|
|
663
|
+
size: [
|
|
664
|
+
` if (${arrayVar} != null && ${arrayVar}.length > 0) {`,
|
|
665
|
+
` for (let _i = 0; _i < ${arrayVar}.length; _i++) {`,
|
|
666
|
+
` const _val = ((${arrayVar}[_i] << 1) ^ (${arrayVar}[_i] >> 31)) >>> 0;`,
|
|
667
|
+
` size += ${tagLength};`,
|
|
668
|
+
varintSize("_val", " "),
|
|
669
|
+
` }`,
|
|
670
|
+
` }`
|
|
671
|
+
],
|
|
672
|
+
write: [
|
|
673
|
+
` if (${arrayVar} != null && ${arrayVar}.length > 0) {`,
|
|
674
|
+
` for (let _i = 0; _i < ${arrayVar}.length; _i++) {`,
|
|
675
|
+
writeTag(fieldNumber, 0, " "),
|
|
676
|
+
writeVarint(`((${arrayVar}[_i] << 1) ^ (${arrayVar}[_i] >> 31)) >>> 0`, " "),
|
|
677
|
+
` }`,
|
|
678
|
+
` }`
|
|
679
|
+
]
|
|
680
|
+
};
|
|
681
|
+
}
|
|
642
682
|
if (wireType === 0 /* Varint */) {
|
|
643
683
|
return {
|
|
644
684
|
declare: [` const ${arrayVar} = obj.${name};`],
|
|
@@ -845,6 +885,9 @@ function decodeField(field, index) {
|
|
|
845
885
|
} else {
|
|
846
886
|
L.push(assign(`__zigZagDecode64(_val)`));
|
|
847
887
|
}
|
|
888
|
+
} else if (typeName === "sint_32") {
|
|
889
|
+
L.push(varintDec("_val", I));
|
|
890
|
+
L.push(assign(`(_val >>> 1) ^ -(_val & 1)`));
|
|
848
891
|
} else if (wireType === 0 /* Varint */) {
|
|
849
892
|
L.push(varintDec("_val", I));
|
|
850
893
|
L.push(assign(`_val >>> 0`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "protobuf-fastdsl",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"typescript": "^5.5.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"vite": "^5.0.0 || ^6.0.0"
|
|
30
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^25.4.0",
|