@k67/kaitai-struct-ts 0.9.0 → 0.10.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.
- package/dist/browser/index.mjs +272 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/cli.js +568 -53
- package/dist/index.d.mts +46 -6
- package/dist/index.d.ts +46 -6
- package/dist/index.js +529 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +529 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -3
package/dist/index.d.mts
CHANGED
@@ -782,9 +782,10 @@ declare class TypeInterpreter {
|
|
782
782
|
* @param stream - Binary stream to parse
|
783
783
|
* @param parent - Parent object (for nested types)
|
784
784
|
* @param typeArgs - Arguments for parametric types
|
785
|
+
* @param root - Root object of the parse tree (for nested types)
|
785
786
|
* @returns Parsed object
|
786
787
|
*/
|
787
|
-
parse(stream: KaitaiStream, parent?: unknown, typeArgs?: Array<string | number | boolean
|
788
|
+
parse(stream: KaitaiStream, parent?: unknown, typeArgs?: Array<string | number | boolean>, root?: unknown): Record<string, unknown>;
|
788
789
|
/**
|
789
790
|
* Set up lazy-evaluated instance getters.
|
790
791
|
* Instances are computed on first access and cached.
|
@@ -852,6 +853,25 @@ declare class TypeInterpreter {
|
|
852
853
|
* @private
|
853
854
|
*/
|
854
855
|
private parseType;
|
856
|
+
/**
|
857
|
+
* Parse parameterized type syntax and extract type name and arguments.
|
858
|
+
* Supports: type_name(arg1, arg2, ...) or just type_name
|
859
|
+
*
|
860
|
+
* @param typeSpec - Type specification string
|
861
|
+
* @param context - Execution context for evaluating argument expressions
|
862
|
+
* @returns Object with typeName and evaluated args
|
863
|
+
* @private
|
864
|
+
*/
|
865
|
+
private parseParameterizedType;
|
866
|
+
/**
|
867
|
+
* Parse and evaluate a single type argument.
|
868
|
+
*
|
869
|
+
* @param arg - Argument string
|
870
|
+
* @param context - Execution context
|
871
|
+
* @returns Evaluated argument value
|
872
|
+
* @private
|
873
|
+
*/
|
874
|
+
private parseArgument;
|
855
875
|
/**
|
856
876
|
* Parse a switch type (type selection based on expression).
|
857
877
|
*
|
@@ -894,7 +914,7 @@ declare class TypeInterpreter {
|
|
894
914
|
private readFloat;
|
895
915
|
/**
|
896
916
|
* Apply processing transformation to data.
|
897
|
-
*
|
917
|
+
* Delegates to the process utility module.
|
898
918
|
*
|
899
919
|
* @param data - Data to process
|
900
920
|
* @param process - Processing specification
|
@@ -902,6 +922,15 @@ declare class TypeInterpreter {
|
|
902
922
|
* @private
|
903
923
|
*/
|
904
924
|
private applyProcessing;
|
925
|
+
/**
|
926
|
+
* Evaluate expression-based endianness (switch-on).
|
927
|
+
*
|
928
|
+
* @param endianExpr - Endianness expression with switch-on and cases
|
929
|
+
* @param context - Execution context
|
930
|
+
* @returns Resolved endianness ('le' or 'be')
|
931
|
+
* @private
|
932
|
+
*/
|
933
|
+
private evaluateEndianExpression;
|
905
934
|
/**
|
906
935
|
* Evaluate a value that can be an expression or literal.
|
907
936
|
*
|
@@ -932,7 +961,18 @@ declare class TypeInterpreter {
|
|
932
961
|
*/
|
933
962
|
declare class KaitaiError extends Error {
|
934
963
|
position?: number | undefined;
|
935
|
-
|
964
|
+
context?: Uint8Array | undefined;
|
965
|
+
constructor(message: string, position?: number | undefined, context?: Uint8Array | undefined);
|
966
|
+
/**
|
967
|
+
* Format error message with position and context.
|
968
|
+
* @private
|
969
|
+
*/
|
970
|
+
private static formatMessage;
|
971
|
+
/**
|
972
|
+
* Format hex dump context around error position.
|
973
|
+
* @private
|
974
|
+
*/
|
975
|
+
private static formatHexContext;
|
936
976
|
}
|
937
977
|
/**
|
938
978
|
* Error thrown when validation fails.
|
@@ -946,7 +986,7 @@ declare class KaitaiError extends Error {
|
|
946
986
|
* ```
|
947
987
|
*/
|
948
988
|
declare class ValidationError extends KaitaiError {
|
949
|
-
constructor(message: string, position?: number);
|
989
|
+
constructor(message: string, position?: number, context?: Uint8Array);
|
950
990
|
}
|
951
991
|
/**
|
952
992
|
* Error thrown when parsing fails.
|
@@ -960,7 +1000,7 @@ declare class ValidationError extends KaitaiError {
|
|
960
1000
|
* ```
|
961
1001
|
*/
|
962
1002
|
declare class ParseError extends KaitaiError {
|
963
|
-
constructor(message: string, position?: number);
|
1003
|
+
constructor(message: string, position?: number, context?: Uint8Array);
|
964
1004
|
}
|
965
1005
|
/**
|
966
1006
|
* Error thrown when end of stream is reached unexpectedly.
|
@@ -974,7 +1014,7 @@ declare class ParseError extends KaitaiError {
|
|
974
1014
|
* ```
|
975
1015
|
*/
|
976
1016
|
declare class EOFError extends KaitaiError {
|
977
|
-
constructor(message?: string, position?: number);
|
1017
|
+
constructor(message?: string, position?: number, context?: Uint8Array);
|
978
1018
|
}
|
979
1019
|
/**
|
980
1020
|
* Error thrown when a required feature is not yet implemented.
|
package/dist/index.d.ts
CHANGED
@@ -782,9 +782,10 @@ declare class TypeInterpreter {
|
|
782
782
|
* @param stream - Binary stream to parse
|
783
783
|
* @param parent - Parent object (for nested types)
|
784
784
|
* @param typeArgs - Arguments for parametric types
|
785
|
+
* @param root - Root object of the parse tree (for nested types)
|
785
786
|
* @returns Parsed object
|
786
787
|
*/
|
787
|
-
parse(stream: KaitaiStream, parent?: unknown, typeArgs?: Array<string | number | boolean
|
788
|
+
parse(stream: KaitaiStream, parent?: unknown, typeArgs?: Array<string | number | boolean>, root?: unknown): Record<string, unknown>;
|
788
789
|
/**
|
789
790
|
* Set up lazy-evaluated instance getters.
|
790
791
|
* Instances are computed on first access and cached.
|
@@ -852,6 +853,25 @@ declare class TypeInterpreter {
|
|
852
853
|
* @private
|
853
854
|
*/
|
854
855
|
private parseType;
|
856
|
+
/**
|
857
|
+
* Parse parameterized type syntax and extract type name and arguments.
|
858
|
+
* Supports: type_name(arg1, arg2, ...) or just type_name
|
859
|
+
*
|
860
|
+
* @param typeSpec - Type specification string
|
861
|
+
* @param context - Execution context for evaluating argument expressions
|
862
|
+
* @returns Object with typeName and evaluated args
|
863
|
+
* @private
|
864
|
+
*/
|
865
|
+
private parseParameterizedType;
|
866
|
+
/**
|
867
|
+
* Parse and evaluate a single type argument.
|
868
|
+
*
|
869
|
+
* @param arg - Argument string
|
870
|
+
* @param context - Execution context
|
871
|
+
* @returns Evaluated argument value
|
872
|
+
* @private
|
873
|
+
*/
|
874
|
+
private parseArgument;
|
855
875
|
/**
|
856
876
|
* Parse a switch type (type selection based on expression).
|
857
877
|
*
|
@@ -894,7 +914,7 @@ declare class TypeInterpreter {
|
|
894
914
|
private readFloat;
|
895
915
|
/**
|
896
916
|
* Apply processing transformation to data.
|
897
|
-
*
|
917
|
+
* Delegates to the process utility module.
|
898
918
|
*
|
899
919
|
* @param data - Data to process
|
900
920
|
* @param process - Processing specification
|
@@ -902,6 +922,15 @@ declare class TypeInterpreter {
|
|
902
922
|
* @private
|
903
923
|
*/
|
904
924
|
private applyProcessing;
|
925
|
+
/**
|
926
|
+
* Evaluate expression-based endianness (switch-on).
|
927
|
+
*
|
928
|
+
* @param endianExpr - Endianness expression with switch-on and cases
|
929
|
+
* @param context - Execution context
|
930
|
+
* @returns Resolved endianness ('le' or 'be')
|
931
|
+
* @private
|
932
|
+
*/
|
933
|
+
private evaluateEndianExpression;
|
905
934
|
/**
|
906
935
|
* Evaluate a value that can be an expression or literal.
|
907
936
|
*
|
@@ -932,7 +961,18 @@ declare class TypeInterpreter {
|
|
932
961
|
*/
|
933
962
|
declare class KaitaiError extends Error {
|
934
963
|
position?: number | undefined;
|
935
|
-
|
964
|
+
context?: Uint8Array | undefined;
|
965
|
+
constructor(message: string, position?: number | undefined, context?: Uint8Array | undefined);
|
966
|
+
/**
|
967
|
+
* Format error message with position and context.
|
968
|
+
* @private
|
969
|
+
*/
|
970
|
+
private static formatMessage;
|
971
|
+
/**
|
972
|
+
* Format hex dump context around error position.
|
973
|
+
* @private
|
974
|
+
*/
|
975
|
+
private static formatHexContext;
|
936
976
|
}
|
937
977
|
/**
|
938
978
|
* Error thrown when validation fails.
|
@@ -946,7 +986,7 @@ declare class KaitaiError extends Error {
|
|
946
986
|
* ```
|
947
987
|
*/
|
948
988
|
declare class ValidationError extends KaitaiError {
|
949
|
-
constructor(message: string, position?: number);
|
989
|
+
constructor(message: string, position?: number, context?: Uint8Array);
|
950
990
|
}
|
951
991
|
/**
|
952
992
|
* Error thrown when parsing fails.
|
@@ -960,7 +1000,7 @@ declare class ValidationError extends KaitaiError {
|
|
960
1000
|
* ```
|
961
1001
|
*/
|
962
1002
|
declare class ParseError extends KaitaiError {
|
963
|
-
constructor(message: string, position?: number);
|
1003
|
+
constructor(message: string, position?: number, context?: Uint8Array);
|
964
1004
|
}
|
965
1005
|
/**
|
966
1006
|
* Error thrown when end of stream is reached unexpectedly.
|
@@ -974,7 +1014,7 @@ declare class ParseError extends KaitaiError {
|
|
974
1014
|
* ```
|
975
1015
|
*/
|
976
1016
|
declare class EOFError extends KaitaiError {
|
977
|
-
constructor(message?: string, position?: number);
|
1017
|
+
constructor(message?: string, position?: number, context?: Uint8Array);
|
978
1018
|
}
|
979
1019
|
/**
|
980
1020
|
* Error thrown when a required feature is not yet implemented.
|