codama-renderers-dart 0.5.4 → 0.5.5
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.browser.cjs +22 -22
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +22 -22
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +22 -22
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +22 -22
- package/dist/index.node.js.map +1 -1
- package/dist/index.react-native.js +22 -22
- package/dist/index.react-native.js.map +1 -1
- package/package.json +5 -5
- package/src/visitors/getTypeManifestVisitor.ts +30 -15
- package/LICENSE +0 -21
package/package.json
CHANGED
|
@@ -53,9 +53,6 @@
|
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
55
|
"repository": "https://github.com/openbudgetfun/solana_kit/tree/main/packages/codama-renderers-dart",
|
|
56
|
-
"type": "module",
|
|
57
|
-
"types": "./dist/types/index.d.ts",
|
|
58
|
-
"version": "0.5.4",
|
|
59
56
|
"scripts": {
|
|
60
57
|
"build": "pnpm exec rimraf dist && pnpm exec tsup && pnpm exec tsc -p tsconfig.declarations.json",
|
|
61
58
|
"lint": "eslint --ext .ts src",
|
|
@@ -63,5 +60,8 @@
|
|
|
63
60
|
"test:coverage": "pnpm exec vitest run --coverage.enabled --coverage.reporter=lcov",
|
|
64
61
|
"test:watch": "pnpm exec vitest",
|
|
65
62
|
"typecheck": "pnpm exec tsc --noEmit"
|
|
66
|
-
}
|
|
67
|
-
|
|
63
|
+
},
|
|
64
|
+
"type": "module",
|
|
65
|
+
"types": "./dist/types/index.d.ts",
|
|
66
|
+
"version": "0.5.5"
|
|
67
|
+
}
|
|
@@ -209,8 +209,8 @@ export function getTypeManifestVisitor(input: {
|
|
|
209
209
|
|
|
210
210
|
visitArrayType(node: ArrayTypeNode, { self }) {
|
|
211
211
|
const itemManifest = visit(node.item, self);
|
|
212
|
-
const encoderSizeExpr = getArraySizeExpression(node, "Encoder");
|
|
213
|
-
const decoderSizeExpr = getArraySizeExpression(node, "Decoder");
|
|
212
|
+
const encoderSizeExpr = getArraySizeExpression(node, "Encoder", self);
|
|
213
|
+
const decoderSizeExpr = getArraySizeExpression(node, "Decoder", self);
|
|
214
214
|
const itemType = fragmentFromString(itemManifest.type.content);
|
|
215
215
|
const itemEncoder = fragment`${use(
|
|
216
216
|
"transformEncoder",
|
|
@@ -235,8 +235,8 @@ export function getTypeManifestVisitor(input: {
|
|
|
235
235
|
visitMapType(node: MapTypeNode, { self }) {
|
|
236
236
|
const keyManifest = visit(node.key, self);
|
|
237
237
|
const valueManifest = visit(node.value, self);
|
|
238
|
-
const encoderSizeExpr = getMapSizeExpression(node, "Encoder");
|
|
239
|
-
const decoderSizeExpr = getMapSizeExpression(node, "Decoder");
|
|
238
|
+
const encoderSizeExpr = getMapSizeExpression(node, "Encoder", self);
|
|
239
|
+
const decoderSizeExpr = getMapSizeExpression(node, "Decoder", self);
|
|
240
240
|
|
|
241
241
|
return {
|
|
242
242
|
type: fragment`Map<${keyManifest.type}, ${valueManifest.type}>`,
|
|
@@ -255,8 +255,8 @@ export function getTypeManifestVisitor(input: {
|
|
|
255
255
|
|
|
256
256
|
visitSetType(node: SetTypeNode, { self }) {
|
|
257
257
|
const itemManifest = visit(node.item, self);
|
|
258
|
-
const encoderSizeExpr = getSetSizeExpression(node, "Encoder");
|
|
259
|
-
const decoderSizeExpr = getSetSizeExpression(node, "Decoder");
|
|
258
|
+
const encoderSizeExpr = getSetSizeExpression(node, "Encoder", self);
|
|
259
|
+
const decoderSizeExpr = getSetSizeExpression(node, "Decoder", self);
|
|
260
260
|
|
|
261
261
|
return {
|
|
262
262
|
type: fragment`Set<${itemManifest.type}>`,
|
|
@@ -772,6 +772,7 @@ function getNumberCodecExpression(
|
|
|
772
772
|
function getArraySizeExpression(
|
|
773
773
|
node: ArrayTypeNode,
|
|
774
774
|
codecType: "Encoder" | "Decoder",
|
|
775
|
+
self: Visitor<TypeManifest>,
|
|
775
776
|
): string | Fragment {
|
|
776
777
|
if (!("count" in node) || !node.count) return "";
|
|
777
778
|
const count = node.count;
|
|
@@ -781,11 +782,15 @@ function getArraySizeExpression(
|
|
|
781
782
|
case "remainderCountNode":
|
|
782
783
|
return ", size: RemainderArraySize()";
|
|
783
784
|
case "prefixedCountNode": {
|
|
784
|
-
|
|
785
|
-
|
|
785
|
+
if (
|
|
786
|
+
count.prefix.kind === "numberTypeNode" &&
|
|
787
|
+
count.prefix.format === "u32" &&
|
|
788
|
+
(!count.prefix.endian || count.prefix.endian === "le")
|
|
789
|
+
) {
|
|
786
790
|
return ""; // Default
|
|
787
791
|
}
|
|
788
|
-
|
|
792
|
+
const prefix = visit(count.prefix, self);
|
|
793
|
+
return fragment`, size: PrefixedArraySize(${codecType === "Encoder" ? prefix.encoder : prefix.decoder})`;
|
|
789
794
|
}
|
|
790
795
|
default:
|
|
791
796
|
return "";
|
|
@@ -795,6 +800,7 @@ function getArraySizeExpression(
|
|
|
795
800
|
function getMapSizeExpression(
|
|
796
801
|
node: MapTypeNode,
|
|
797
802
|
codecType: "Encoder" | "Decoder",
|
|
803
|
+
self: Visitor<TypeManifest>,
|
|
798
804
|
): string | Fragment {
|
|
799
805
|
if (!("count" in node) || !node.count) return "";
|
|
800
806
|
const count = node.count;
|
|
@@ -804,11 +810,15 @@ function getMapSizeExpression(
|
|
|
804
810
|
case "remainderCountNode":
|
|
805
811
|
return ", size: RemainderArraySize()";
|
|
806
812
|
case "prefixedCountNode": {
|
|
807
|
-
|
|
808
|
-
|
|
813
|
+
if (
|
|
814
|
+
count.prefix.kind === "numberTypeNode" &&
|
|
815
|
+
count.prefix.format === "u32" &&
|
|
816
|
+
(!count.prefix.endian || count.prefix.endian === "le")
|
|
817
|
+
) {
|
|
809
818
|
return "";
|
|
810
819
|
}
|
|
811
|
-
|
|
820
|
+
const prefix = visit(count.prefix, self);
|
|
821
|
+
return fragment`, size: PrefixedArraySize(${codecType === "Encoder" ? prefix.encoder : prefix.decoder})`;
|
|
812
822
|
}
|
|
813
823
|
default:
|
|
814
824
|
return "";
|
|
@@ -818,6 +828,7 @@ function getMapSizeExpression(
|
|
|
818
828
|
function getSetSizeExpression(
|
|
819
829
|
node: SetTypeNode,
|
|
820
830
|
codecType: "Encoder" | "Decoder",
|
|
831
|
+
self: Visitor<TypeManifest>,
|
|
821
832
|
): string | Fragment {
|
|
822
833
|
if (!("count" in node) || !node.count) return "";
|
|
823
834
|
const count = node.count;
|
|
@@ -827,11 +838,15 @@ function getSetSizeExpression(
|
|
|
827
838
|
case "remainderCountNode":
|
|
828
839
|
return ", size: RemainderArraySize()";
|
|
829
840
|
case "prefixedCountNode": {
|
|
830
|
-
|
|
831
|
-
|
|
841
|
+
if (
|
|
842
|
+
count.prefix.kind === "numberTypeNode" &&
|
|
843
|
+
count.prefix.format === "u32" &&
|
|
844
|
+
(!count.prefix.endian || count.prefix.endian === "le")
|
|
845
|
+
) {
|
|
832
846
|
return "";
|
|
833
847
|
}
|
|
834
|
-
|
|
848
|
+
const prefix = visit(count.prefix, self);
|
|
849
|
+
return fragment`, size: PrefixedArraySize(${codecType === "Encoder" ? prefix.encoder : prefix.decoder})`;
|
|
835
850
|
}
|
|
836
851
|
default:
|
|
837
852
|
return "";
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Ifiok Jr.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|