url-safe-bitpacking 0.1.2 → 0.1.4
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/README.md +63 -7
- package/dist/enums/dataTypes.d.ts +7 -0
- package/dist/enums/index.d.ts +2 -0
- package/dist/enums/objectGenerationTypes.d.ts +6 -0
- package/dist/factory/booleanFactory.d.ts +2 -0
- package/dist/factory/enumFactory.d.ts +2 -0
- package/dist/factory/factory.d.ts +29 -0
- package/dist/factory/floatFactory.d.ts +2 -0
- package/dist/factory/helperMethod.d.ts +1 -0
- package/dist/factory/index.d.ts +1 -0
- package/dist/factory/intFactory.d.ts +2 -0
- package/dist/factory/versionFactory.d.ts +2 -0
- package/dist/objectmap/index.d.ts +2 -0
- package/dist/objectmap/versionArrayDefinitionToObjectDefintion.d.ts +14 -0
- package/dist/objectmap/versionReading.d.ts +31 -0
- package/dist/objectmap/versionUpdate.d.ts +19 -0
- package/dist/parsers/booleanParser.d.ts +4 -0
- package/dist/parsers/enumParser.d.ts +4 -0
- package/dist/parsers/floatParser.d.ts +5 -0
- package/dist/parsers/index.d.ts +1 -0
- package/dist/parsers/intParser.d.ts +6 -0
- package/dist/parsers/parsers.d.ts +21 -0
- package/dist/parsers/versionParser.d.ts +4 -0
- package/dist/test/arrayDefinition.example.d.ts +14 -0
- package/dist/test/boolean.test.d.ts +1 -0
- package/dist/test/dataParser.test.d.ts +1 -0
- package/dist/test/enum.test.d.ts +1 -0
- package/dist/test/float.test.d.ts +2 -0
- package/dist/test/int.test.d.ts +1 -0
- package/dist/test/parsingArrayDefinition.test.d.ts +1 -0
- package/dist/test/version.test.d.ts +2 -0
- package/dist/types/arrayDefinitions.d.ts +11 -0
- package/dist/types/booleanData.d.ts +4 -0
- package/dist/types/dataEntry.d.ts +33 -0
- package/dist/types/enumData.d.ts +7 -0
- package/dist/types/floatData.d.ts +10 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/intData.d.ts +8 -0
- package/dist/types/semanticlyNestedDataEntry.d.ts +7 -0
- package/dist/types/versionData.d.ts +10 -0
- package/dist/types/versionParser.d.ts +34 -0
- package/dist/update/booleanUpdate.d.ts +2 -0
- package/dist/update/enumUpdate.d.ts +2 -0
- package/dist/update/floatUpdate.d.ts +2 -0
- package/dist/update/index.d.ts +1 -0
- package/dist/update/intUpdate.d.ts +2 -0
- package/dist/update/updateValues.d.ts +2 -0
- package/dist/update/versionUpdate.d.ts +2 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/interpolateData.d.ts +8 -0
- package/dist/utils/relativeValue.d.ts +2 -0
- package/package.json +3 -9
package/README.md
CHANGED
|
@@ -1,15 +1,71 @@
|
|
|
1
1
|
# url-safe-bitpacking
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Package for creating definitions of parametric models that can be stored as compactly as possible in a URL by storing it in a web-safe base-64 string. This pacakge is till very much WIP. Feel free to suggest by making an issue or pull-request [GitHub](https://github.com/JonasWard/url-safe-bitpacking).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
## concept
|
|
6
|
+
|
|
7
|
+
The goal of this library is to offer a flexible, minimal and, variable object definition that can be stored in the browser URL. The main imagined use-case is parametric models that have nested and variable sub-object definitions.
|
|
8
|
+
|
|
9
|
+
The library heavily relies on the bitpacking of custom bitwidth numeric values. Because of that, the biggest trade-off for this library is legibility. Without the related object definition, it would be impossible to reconstruct the state.
|
|
10
|
+
|
|
11
|
+
The big advantage though is the ability to store rather many variables in a very condensed URL, allowing to store all information in rather short urls which then can be used for qr code generation.
|
|
12
|
+
|
|
13
|
+
## data types
|
|
14
|
+
|
|
15
|
+
Currently, there are 4 data types implemented (+1 special case for safety). All data entries have a name that will behave as an attribute name in the object.
|
|
16
|
+
|
|
17
|
+
### bool
|
|
18
|
+
|
|
19
|
+
Bool type values are simple yes or no, 1 or 0s, nothing special
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
DataEntryFactory.createBoolean(false, 'shapePreProcessingWarpabsolute');
|
|
7
23
|
```
|
|
8
24
|
|
|
9
|
-
|
|
25
|
+
### enum
|
|
10
26
|
|
|
11
|
-
|
|
12
|
-
|
|
27
|
+
An enum in this context is a continuous array of integers. The Bitwidth of this data type is defined by the maximum entry. eg. in case you you would need 21 states, the larges value would be 20. The value 20 would require at least five bits (log2(20) ~ 4.32). The maximum bitwidth for enums is right now hardcoded to 8-bit (which would be the range [0, 255] ).
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
DataEntryFactory.createEnum(0, 3, 'footprintType');
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### int
|
|
34
|
+
|
|
35
|
+
An int type is rather similar to the enum, except that it starts at a specific minimum value. The range that then needs to be able to be stored is: max - min. In case you would need values from -30 to 10, you would have to be able to store 10 - 30 + 1 = 51 states. This would require a bitwidth of 6 (log2(51) ~ 5.67). The max bitwidth is now hardcoded to be 12 (which would be the range [minimum, 4095 - minimum])
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
DataEntryFactory.createInt(5, 3, 20, 'circleDivisions');
|
|
13
39
|
```
|
|
14
40
|
|
|
15
|
-
|
|
41
|
+
### float
|
|
42
|
+
|
|
43
|
+
Floating points work very much like the integer type, with the main difference that one can also define a precision to define at what order of magnitude (from -3 to +3) the variable should be considered. The significand can be up to 20 bits, which eg. at precision -3 would allow a range of .001 to 1048.576. Floating points are assumed to be always positive.
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
DataEntryFactory.createFloat(20, 10, 200, -1, 'shapePreProcessingWarptotal');
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### version
|
|
50
|
+
|
|
51
|
+
There is also a Version object which is a special case of the enum data type and has a bitwidth of 4, 6, 8 or, 10 and always occupies the first bits of the bitarray.
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
DataEntryFactory.createVersion(0, 8, 'version');
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## attribute map
|
|
58
|
+
|
|
59
|
+
On a macro level there are two types of data. Either Single Level array objects or Double Nested array objects.
|
|
60
|
+
|
|
61
|
+
Single-level nested objects are arrays in which the entries it contains describe themselves. The Double Nested arrays describe objects that will have a variable size, that depends on the linked data entry that is selected is set in state.
|
|
62
|
+
|
|
63
|
+
For the Double Nested arrays there are currently two variations: either an Optional type, which only accepts two values of which is an empty array and will be toggle on/off in relation to a certain boolean data entry.
|
|
64
|
+
|
|
65
|
+
# Install
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm install url-safe-bitpacking
|
|
69
|
+
yarn install url-safe-bitpacking
|
|
70
|
+
bun install url-safe-bitpacking
|
|
71
|
+
```
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare enum ObjectGenerationOutputStatus {
|
|
2
|
+
DEFAULT = 0,// means that a default value was used to create the object
|
|
3
|
+
FROM_TYPE = 1,// means that the object was created from a type entry (non undefined input)
|
|
4
|
+
PARSED = 2,// means that the object was created by parsing a string
|
|
5
|
+
ERROR_PARSING = 3
|
|
6
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { create as createFloat } from './floatFactory';
|
|
2
|
+
import { create as createInt } from './intFactory';
|
|
3
|
+
import { create as createBoolean } from './booleanFactory';
|
|
4
|
+
import { create as createVersion } from './versionFactory';
|
|
5
|
+
import { create as createEnum } from './enumFactory';
|
|
6
|
+
import { BooleanDescriptionWithValueType, IntDescriptionWithValueType, FloatDescriptionWithValueType, VersionDescriptionWithValueType, FloatDiscriptionType, BooleanDiscriptionType, VersionDiscriptionType, IntDiscriptionType, EnumDiscriptionType, EnumDescriptionWithValueType } from '../types/dataEntry';
|
|
7
|
+
import { PrecisionRangeType } from '../types/floatData';
|
|
8
|
+
import { VersionRangeType } from '../types/versionData';
|
|
9
|
+
export declare class DataRangeDescriptionFactory {
|
|
10
|
+
static createFloat: typeof createFloat;
|
|
11
|
+
static createInt: typeof createInt;
|
|
12
|
+
static createEnum: typeof createEnum;
|
|
13
|
+
static createBoolean: typeof createBoolean;
|
|
14
|
+
static createVersion: typeof createVersion;
|
|
15
|
+
}
|
|
16
|
+
export declare class DataDescriptionFactory {
|
|
17
|
+
static createFloat: (min?: number, max?: number, precision?: PrecisionRangeType, name?: string, index?: number) => FloatDiscriptionType;
|
|
18
|
+
static createInt: (min?: number, max?: number, name?: string, index?: number) => IntDiscriptionType;
|
|
19
|
+
static createEnum: (max?: number, name?: string, index?: number) => EnumDiscriptionType;
|
|
20
|
+
static createBoolean: (name?: string, index?: number) => BooleanDiscriptionType;
|
|
21
|
+
static createVersion: (bits?: VersionRangeType, name?: string, index?: number) => VersionDiscriptionType;
|
|
22
|
+
}
|
|
23
|
+
export declare class DataEntryFactory {
|
|
24
|
+
static createFloat: (value: number, min?: number, max?: number, precision?: PrecisionRangeType, name?: string, index?: number) => FloatDescriptionWithValueType;
|
|
25
|
+
static createInt: (value: number, min?: number, max?: number, name?: string, index?: number) => IntDescriptionWithValueType;
|
|
26
|
+
static createEnum: (value: number, max?: number, name?: string, index?: number) => EnumDescriptionWithValueType;
|
|
27
|
+
static createBoolean: (value: boolean, name?: string, index?: number) => BooleanDescriptionWithValueType;
|
|
28
|
+
static createVersion: (value: number, bits?: VersionRangeType, name?: string, index?: number) => VersionDescriptionWithValueType;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getBitsForIntegerNumber: (number: number, maxBits: number) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './factory';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DataEntry, DefinitionNestedArray, DefinitionNestedGenerationObject, DefinitionSubObject, VersionDefinitionObject } from '../types';
|
|
2
|
+
import { EnumEntryDataType, OptionalEntryDataType, NestedContentType, NestedContentDataType, SingleLevelContentType, VersionArrayDefinitionType } from '../types/arrayDefinitions';
|
|
3
|
+
export declare const isSingleLevelContentType: (data: NestedContentType) => boolean;
|
|
4
|
+
export declare const isDoubleLevelContentType: (data: NestedContentType) => boolean;
|
|
5
|
+
export declare const singleLevelContentTypeIsDataEntry: (data: SingleLevelContentType) => boolean;
|
|
6
|
+
export declare const singleLevelContentTypeIsNestedContentDataType: (data: SingleLevelContentType) => boolean;
|
|
7
|
+
export declare const singleLevelContentTypeIsEnumEntryDataType: (data: NestedContentType) => boolean;
|
|
8
|
+
export declare const singleLevelContentTypeIsOptionalEntryDataType: (data: NestedContentType) => boolean;
|
|
9
|
+
export declare const parseSingleLevelContentTypeToDefinitionSubObject: (data: SingleLevelContentType, currentIndex: number) => [number, DefinitionSubObject];
|
|
10
|
+
export declare const parseNestedContentDataTypeToDefinitionNestedArray: (data: NestedContentDataType, currentIndex: number) => [number, DefinitionNestedArray | DefinitionNestedGenerationObject];
|
|
11
|
+
export declare const parseEnumEntryDataTypeToDefinitionNestedGenerationObject: (data: EnumEntryDataType, name: string, currentIndex: number) => [number, DefinitionNestedGenerationObject];
|
|
12
|
+
export declare const parseOptionalEntryDataTypeToDefinitionNestedGenerationObject: (data: OptionalEntryDataType, name: string, currentIndex: number) => [number, DefinitionNestedGenerationObject];
|
|
13
|
+
export declare const parseDataEntry: (d: DataEntry, currentIndex: number) => [number, DataEntry];
|
|
14
|
+
export declare const parseVersionArrayDefinitionTypeToVersionDefinitionObject: (v: VersionArrayDefinitionType) => VersionDefinitionObject;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DataDescription } from '../types/dataEntry';
|
|
2
|
+
import { SemanticlyNestedDataDescription, SemanticlyNestedDataEntry } from '../types/semanticlyNestedDataEntry';
|
|
3
|
+
import { DefinitionArrayObject, ParserForVersion } from '../types/versionParser';
|
|
4
|
+
/**
|
|
5
|
+
* Method for finding the names of the variable data entries in the DefinitionArrayObject
|
|
6
|
+
* @param definitionArrayObject - DefinitionArrayObject
|
|
7
|
+
* @returns string[] - the key strings
|
|
8
|
+
*/
|
|
9
|
+
export declare const getVariableStrings: (definitionArrayObject: DefinitionArrayObject) => string[];
|
|
10
|
+
/**
|
|
11
|
+
* Method that translates a DefinitionArrayObject into a SemanticlyNestedDataEntry
|
|
12
|
+
* @param definitionArrayObject [DataEntry | [string, DefinitionArrayObject]]
|
|
13
|
+
* @param startIndex
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare const nestedDataEntryArrayToObject: (definitionArrayObject: DefinitionArrayObject, startIndex: number) => SemanticlyNestedDataEntry;
|
|
17
|
+
export declare const parseUrlMethod: (url: string, parserVersions: ParserForVersion[]) => SemanticlyNestedDataEntry;
|
|
18
|
+
export declare const parseDownNestedDataDescription: (nestedDataDescription: SemanticlyNestedDataDescription) => DataDescription[];
|
|
19
|
+
/**
|
|
20
|
+
* Method to get an URL descriptor from a SemanticlyNestedDataEntry
|
|
21
|
+
* @param data: SemanticlyNestedDataEntry
|
|
22
|
+
* @returns base64 string
|
|
23
|
+
*/
|
|
24
|
+
export declare const getURLForData: (data: SemanticlyNestedDataEntry) => string;
|
|
25
|
+
export declare const getTestStringValues: (data: SemanticlyNestedDataEntry) => {
|
|
26
|
+
bitsString: string;
|
|
27
|
+
base64BitString: string;
|
|
28
|
+
base64SplitString: string;
|
|
29
|
+
base64String: string;
|
|
30
|
+
raw: string;
|
|
31
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DataEntry, DataEntryArray } from '../types/dataEntry';
|
|
2
|
+
import { SemanticlyNestedDataEntry } from '../types/semanticlyNestedDataEntry';
|
|
3
|
+
import { DefinitionArrayObject, ParserForVersion } from '../types/versionParser';
|
|
4
|
+
/**
|
|
5
|
+
* Method to parse a definitionArrayObject according to a given dataArray
|
|
6
|
+
* @param definitionArrayObject
|
|
7
|
+
* @param dataArray
|
|
8
|
+
* @returns - new SemanticlyNestedDataEntry
|
|
9
|
+
*/
|
|
10
|
+
export declare const updateDataEntryObject: (definitionArrayObject: DefinitionArrayObject, dataArray: DataEntryArray) => SemanticlyNestedDataEntry;
|
|
11
|
+
export declare const getDefaultObject: (versionObjects: ParserForVersion[], versionindex: number) => SemanticlyNestedDataEntry;
|
|
12
|
+
/**
|
|
13
|
+
* Method that handles the updating of a single value in a SemanticlyNestedDataEntry object
|
|
14
|
+
* @param data SemanticlyNestedDataEntry
|
|
15
|
+
* @param newDataEntry updated DataEntry
|
|
16
|
+
* @param versionObjects version object
|
|
17
|
+
* @returns a newly created object in case of a key data description, otherwise the same object with just the new Data Entry value updated
|
|
18
|
+
*/
|
|
19
|
+
export declare const updateDataEntry: (data: SemanticlyNestedDataEntry, newDataEntry: DataEntry, versionObjects: ParserForVersion[]) => SemanticlyNestedDataEntry;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EnumData } from '../types/enumData';
|
|
2
|
+
export declare const getBitsCount: (versionData: EnumData) => number;
|
|
3
|
+
export declare const rawParser: (rawString: string, versionData: EnumData) => number;
|
|
4
|
+
export declare const rawStringifier: (value: number, versionData: EnumData) => string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FloatData, PrecisionRangeType } from '../types/floatData';
|
|
2
|
+
export declare const getBitsCount: (floatData: FloatData) => number;
|
|
3
|
+
export declare const rawValueParser: (stateString: string, significandBits: number, precision: PrecisionRangeType) => number;
|
|
4
|
+
export declare const rawParser: (stateString: string, floatData: FloatData) => number;
|
|
5
|
+
export declare const rawStringifier: (value: number, floatData: FloatData) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './parsers';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IntData } from '../types/intData';
|
|
2
|
+
export declare const getBitsCount: (intData: IntData) => number;
|
|
3
|
+
export declare const rawValueParser: (stateString: string, bitCount: number) => number;
|
|
4
|
+
export declare const rawParser: (stateString: string, intData: IntData) => number;
|
|
5
|
+
export declare const rawIntStringifier: (value: number, bitCount: number) => string;
|
|
6
|
+
export declare const rawStringifier: (value: number, intData: IntData) => string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DataDescription, DataEntry, DataEntryArray, DataRangeDescription } from '../types/dataEntry';
|
|
2
|
+
export declare const valueBitsParser: (bitString: string, mapData: DataRangeDescription) => number | boolean;
|
|
3
|
+
export declare const dataBitsParser: (rawString: string, mapData: DataDescription) => DataEntry;
|
|
4
|
+
export declare const getBitsCount: (mapData: DataRangeDescription) => number;
|
|
5
|
+
/**
|
|
6
|
+
* Method to convert a bitstring into an array of data entries
|
|
7
|
+
* @param bitString bitstring to parse into bits and then data entries
|
|
8
|
+
* @param mapDataArray Data descriptions to map the bits to data entries
|
|
9
|
+
* @returns array of data entries
|
|
10
|
+
*/
|
|
11
|
+
export declare const dataBitsArrayParser: (bitString: string, mapDataArray: DataDescription[]) => DataEntryArray;
|
|
12
|
+
export declare const dataBitsStringifier: (data: DataEntry) => string;
|
|
13
|
+
export declare const dataEntryCorrecting: (dataEntry: DataEntry) => DataEntry;
|
|
14
|
+
export declare const parseBitsToBase64: (bits: string) => string;
|
|
15
|
+
export declare const parseBase64ToBits: (base64: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Method to convert an array of data entries into a base64 string
|
|
18
|
+
* @param dataArray Data Entries to read to parse into bits and then a base64 string
|
|
19
|
+
* @returns bitstring representation of the data entries
|
|
20
|
+
*/
|
|
21
|
+
export declare const dataArrayStringifier: (dataEntryArray: DataEntryArray) => string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { VersionData } from '../types/versionData';
|
|
2
|
+
export declare const getBitsCount: (versionData: VersionData) => number;
|
|
3
|
+
export declare const rawParser: (rawString: string, versionData: VersionData) => number;
|
|
4
|
+
export declare const rawStringifier: (value: number, versionData: VersionData) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ParserForVersion } from '../types';
|
|
2
|
+
import { NestedContentDataType, OptionalEntryDataType, EnumEntryDataType, VersionArrayDefinitionType, NestedContentType } from '../types/arrayDefinitions';
|
|
3
|
+
export declare const nestedContentDataType: NestedContentDataType;
|
|
4
|
+
export declare const validOptionalEntryType: OptionalEntryDataType;
|
|
5
|
+
export declare const anotherValidOptionalEntryType: OptionalEntryDataType;
|
|
6
|
+
export declare const validEnumEntryType: EnumEntryDataType;
|
|
7
|
+
export declare const generalNestedContentDataType: NestedContentDataType;
|
|
8
|
+
export declare const exampleVersion: VersionArrayDefinitionType;
|
|
9
|
+
export declare const lucernaeTuricumArcExamples: EnumEntryDataType;
|
|
10
|
+
export declare const footprintDefinition: EnumEntryDataType;
|
|
11
|
+
export declare const heightParsingDefinition: NestedContentType;
|
|
12
|
+
export declare const shapePreProcessingDefinition: EnumEntryDataType;
|
|
13
|
+
export declare const lucernaeTurici: VersionArrayDefinitionType;
|
|
14
|
+
export declare const lucernaeTuriciVersions: ParserForVersion[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const values: [boolean, string][];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const values: [number, number, string][];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const values: [number, number, number, string][];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DataEntry, VersionDescriptionWithValueType } from './dataEntry';
|
|
2
|
+
export type SingleLevelContentType = DataEntry | NestedContentDataType;
|
|
3
|
+
export type NestedContentDataType = [string, NestedContentType];
|
|
4
|
+
export type NestedContentType = SingleLevelContentType[] | DoubleLevelContentType;
|
|
5
|
+
export type DoubleLevelContentType = OptionalEntryDataType | EnumEntryDataType;
|
|
6
|
+
export type NonEmptyValidEntryArrayType = [SingleLevelContentType, ...SingleLevelContentType[]];
|
|
7
|
+
export type OptionalEntryDataType = [boolean, NonEmptyValidEntryArrayType, []] | [boolean, [], NonEmptyValidEntryArrayType];
|
|
8
|
+
export type EnumEntryDataType = [number, NonEmptyValidEntryArrayType, NonEmptyValidEntryArrayType, ...SingleLevelContentType[][]];
|
|
9
|
+
export type VersionArrayDefinitionType = [VersionDescriptionWithValueType, ...SingleLevelContentType[]];
|
|
10
|
+
export declare const INDEX_DELIMETER = "$";
|
|
11
|
+
export declare const NAME_DELIMETER = "_";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BooleanData } from './booleanData';
|
|
2
|
+
import { EnumData } from './enumData';
|
|
3
|
+
import { FloatData } from './floatData';
|
|
4
|
+
import { IntData } from './intData';
|
|
5
|
+
import { VersionData } from './versionData';
|
|
6
|
+
export type Prettify<T> = {
|
|
7
|
+
[K in keyof T]: T[K];
|
|
8
|
+
};
|
|
9
|
+
export type DataRangeDescription = VersionData | BooleanData | IntData | EnumData | FloatData;
|
|
10
|
+
interface DataNamingDescription {
|
|
11
|
+
name: string;
|
|
12
|
+
index: number;
|
|
13
|
+
}
|
|
14
|
+
export type BooleanDiscriptionType = Prettify<BooleanData & DataNamingDescription>;
|
|
15
|
+
export type IntDiscriptionType = Prettify<IntData & DataNamingDescription>;
|
|
16
|
+
export type EnumDiscriptionType = Prettify<EnumData & DataNamingDescription>;
|
|
17
|
+
export type FloatDiscriptionType = Prettify<FloatData & DataNamingDescription>;
|
|
18
|
+
export type VersionDiscriptionType = Prettify<VersionData & DataNamingDescription>;
|
|
19
|
+
export type DataDescription = BooleanDiscriptionType | IntDiscriptionType | EnumDiscriptionType | FloatDiscriptionType | VersionDiscriptionType;
|
|
20
|
+
interface DataEntryDescriptionBoolean {
|
|
21
|
+
value: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface DataEntryDescriptionNumeric {
|
|
24
|
+
value: number;
|
|
25
|
+
}
|
|
26
|
+
export type BooleanDescriptionWithValueType = Prettify<BooleanData & DataNamingDescription & DataEntryDescriptionBoolean>;
|
|
27
|
+
export type IntDescriptionWithValueType = Prettify<IntData & DataNamingDescription & DataEntryDescriptionNumeric>;
|
|
28
|
+
export type EnumDescriptionWithValueType = Prettify<EnumData & DataNamingDescription & DataEntryDescriptionNumeric>;
|
|
29
|
+
export type FloatDescriptionWithValueType = Prettify<FloatData & DataNamingDescription & DataEntryDescriptionNumeric>;
|
|
30
|
+
export type VersionDescriptionWithValueType = Prettify<VersionData & DataNamingDescription & DataEntryDescriptionNumeric>;
|
|
31
|
+
export type DataEntry = BooleanDescriptionWithValueType | IntDescriptionWithValueType | EnumDescriptionWithValueType | FloatDescriptionWithValueType | VersionDescriptionWithValueType;
|
|
32
|
+
export type DataEntryArray = DataEntry[];
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DataType } from '../enums/dataTypes';
|
|
2
|
+
export type PrecisionRangeType = -3 | -2 | -1 | 0 | 1 | 2 | 3;
|
|
3
|
+
export declare const SignificandMaxBits = 20;
|
|
4
|
+
export interface FloatData {
|
|
5
|
+
type: DataType.FLOAT;
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
8
|
+
precision: PrecisionRangeType;
|
|
9
|
+
significand: number;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './booleanData';
|
|
2
|
+
export * from './dataEntry';
|
|
3
|
+
export * from './enumData';
|
|
4
|
+
export * from './floatData';
|
|
5
|
+
export * from './intData';
|
|
6
|
+
export * from './semanticlyNestedDataEntry';
|
|
7
|
+
export * from './versionData';
|
|
8
|
+
export * from './versionParser';
|
|
9
|
+
export * from './arrayDefinitions';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DataDescription, DataEntry } from './dataEntry';
|
|
2
|
+
export type SemanticlyNestedDataEntry = {
|
|
3
|
+
[key: string]: SemanticlyNestedDataEntry | DataEntry;
|
|
4
|
+
};
|
|
5
|
+
export type SemanticlyNestedDataDescription = {
|
|
6
|
+
[key: string]: SemanticlyNestedDataDescription | DataDescription;
|
|
7
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DataType } from '../enums/dataTypes';
|
|
2
|
+
export type VersionRangeType = 4 | 6 | 8 | 10;
|
|
3
|
+
export interface VersionData {
|
|
4
|
+
type: DataType.VERSION;
|
|
5
|
+
bits: VersionRangeType;
|
|
6
|
+
}
|
|
7
|
+
export interface GlobalVersion {
|
|
8
|
+
type: DataType.VERSION;
|
|
9
|
+
bits: 8;
|
|
10
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ObjectGenerationOutputStatus } from '../enums/objectGenerationTypes';
|
|
2
|
+
import { DataEntry, VersionDiscriptionType } from './dataEntry';
|
|
3
|
+
import { SemanticlyNestedDataEntry } from './semanticlyNestedDataEntry';
|
|
4
|
+
import { GlobalVersion, VersionRangeType } from './versionData';
|
|
5
|
+
/**
|
|
6
|
+
* A method that generates a nested object based on a set of values
|
|
7
|
+
* @param s - url bit string (optional)
|
|
8
|
+
* @param v - The values to be used to generate the object, can be either a valid value for a dataentry, a bitstring (only 0 or 1 chars) or undefined (default value)
|
|
9
|
+
* @returns [The generated object, the generation status, the index end bit of the bit url (-1 if)]
|
|
10
|
+
*/
|
|
11
|
+
export type ObjectGeneratorMethod = (s?: string, ...v: (DataEntry | undefined)[]) => [SemanticlyNestedDataEntry, ObjectGenerationOutputStatus, number];
|
|
12
|
+
export type DefinitionGenerationObject = (v: DataEntry) => DefinitionArrayObject;
|
|
13
|
+
export type DefinitionNestedArray = [string, DefinitionArrayObject];
|
|
14
|
+
export type DefinitionNestedGenerationObject = [string, DataEntry, DefinitionGenerationObject];
|
|
15
|
+
export type DefinitionSubObject = DataEntry | DefinitionNestedArray | DefinitionNestedGenerationObject;
|
|
16
|
+
export type DefinitionArrayObject = DefinitionSubObject[];
|
|
17
|
+
export type VersionDefinitionObject = [VersionDiscriptionType, ...DefinitionArrayObject];
|
|
18
|
+
export type VersionEnumSemantics = {
|
|
19
|
+
[key: string]: {
|
|
20
|
+
value: number;
|
|
21
|
+
label: string;
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
export type ParserForVersion = {
|
|
25
|
+
version: number;
|
|
26
|
+
versionBitCount: VersionRangeType;
|
|
27
|
+
versionName: string;
|
|
28
|
+
versionEnumSemantics?: VersionEnumSemantics;
|
|
29
|
+
objectGeneratorParameters: VersionDefinitionObject;
|
|
30
|
+
};
|
|
31
|
+
export type VersionParsers = {
|
|
32
|
+
versionRange: GlobalVersion;
|
|
33
|
+
versionParsers: ParserForVersion[];
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './updateValues';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DataEntry } from '../types/dataEntry';
|
|
2
|
+
/**
|
|
3
|
+
* helper method to interpolate a data entry at a given t parameter
|
|
4
|
+
* @param dataEntry - DataEntry to interpolate
|
|
5
|
+
* @param t - number between 0 and 1
|
|
6
|
+
* @returns updated data entry
|
|
7
|
+
*/
|
|
8
|
+
export declare const interpolateEntryAt: (dataEntry: DataEntry, t: number) => DataEntry;
|
package/package.json
CHANGED
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
7
|
-
"dist
|
|
8
|
-
"dist/*.d.ts"
|
|
7
|
+
"dist/*"
|
|
9
8
|
],
|
|
10
9
|
"type": "module",
|
|
11
|
-
"version": "0.1.
|
|
10
|
+
"version": "0.1.4",
|
|
12
11
|
"author": "Jonas Ward",
|
|
13
12
|
"description": "Library for creating web safe base64 objects with custom bith widths and dynamic values.",
|
|
14
13
|
"scripts": {
|
|
@@ -18,12 +17,7 @@
|
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|
|
20
19
|
"bun-types": "latest",
|
|
21
|
-
"rimraf": "^6.0.1"
|
|
22
|
-
},
|
|
23
|
-
"peerDependencies": {
|
|
20
|
+
"rimraf": "^6.0.1",
|
|
24
21
|
"typescript": "^5.0.0"
|
|
25
|
-
},
|
|
26
|
-
"dependencies": {
|
|
27
|
-
"typescript": "^5.6.2"
|
|
28
22
|
}
|
|
29
23
|
}
|