url-safe-bitpacking 0.1.1 → 0.1.3

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.
Files changed (55) hide show
  1. package/README.md +63 -7
  2. package/dist/enums/dataTypes.d.ts +7 -0
  3. package/dist/enums/index.d.ts +2 -0
  4. package/dist/enums/objectGenerationTypes.d.ts +6 -0
  5. package/dist/factory/booleanFactory.d.ts +2 -0
  6. package/dist/factory/enumFactory.d.ts +2 -0
  7. package/dist/factory/factory.d.ts +29 -0
  8. package/dist/factory/floatFactory.d.ts +2 -0
  9. package/dist/factory/helperMethod.d.ts +1 -0
  10. package/dist/factory/index.d.ts +1 -0
  11. package/dist/factory/intFactory.d.ts +2 -0
  12. package/dist/factory/versionFactory.d.ts +2 -0
  13. package/dist/index.d.ts +7 -7
  14. package/dist/index.js +0 -97
  15. package/dist/objectmap/index.d.ts +2 -0
  16. package/dist/objectmap/versionArrayDefinitionToObjectDefintion.d.ts +14 -0
  17. package/dist/objectmap/versionReading.d.ts +31 -0
  18. package/dist/objectmap/versionUpdate.d.ts +19 -0
  19. package/dist/parsers/booleanParser.d.ts +4 -0
  20. package/dist/parsers/enumParser.d.ts +4 -0
  21. package/dist/parsers/floatParser.d.ts +5 -0
  22. package/dist/parsers/index.d.ts +1 -0
  23. package/dist/parsers/intParser.d.ts +6 -0
  24. package/dist/parsers/parsers.d.ts +21 -0
  25. package/dist/parsers/versionParser.d.ts +4 -0
  26. package/dist/test/arrayDefinition.example.d.ts +12 -0
  27. package/dist/test/boolean.test.d.ts +1 -0
  28. package/dist/test/dataParser.test.d.ts +1 -0
  29. package/dist/test/enum.test.d.ts +1 -0
  30. package/dist/test/float.test.d.ts +2 -0
  31. package/dist/test/int.test.d.ts +1 -0
  32. package/dist/test/parsingArrayDefinition.test.d.ts +1 -0
  33. package/dist/test/version.test.d.ts +2 -0
  34. package/dist/types/arrayDefinitions.d.ts +11 -0
  35. package/dist/types/booleanData.d.ts +4 -0
  36. package/dist/types/dataEntry.d.ts +33 -0
  37. package/dist/types/enumData.d.ts +7 -0
  38. package/dist/types/floatData.d.ts +10 -0
  39. package/dist/types/index.d.ts +9 -0
  40. package/dist/types/intData.d.ts +8 -0
  41. package/dist/types/semanticlyNestedDataEntry.d.ts +7 -0
  42. package/dist/types/versionData.d.ts +10 -0
  43. package/dist/types/versionParser.d.ts +33 -0
  44. package/dist/update/booleanUpdate.d.ts +2 -0
  45. package/dist/update/enumUpdate.d.ts +2 -0
  46. package/dist/update/floatUpdate.d.ts +2 -0
  47. package/dist/update/index.d.ts +1 -0
  48. package/dist/update/intUpdate.d.ts +2 -0
  49. package/dist/update/updateValues.d.ts +2 -0
  50. package/dist/update/versionUpdate.d.ts +2 -0
  51. package/dist/utils/index.d.ts +2 -0
  52. package/dist/utils/interpolateData.d.ts +8 -0
  53. package/dist/utils/relativeValue.d.ts +2 -0
  54. package/package.json +3 -4
  55. package/dist/bundle.js +0 -577
package/README.md CHANGED
@@ -1,15 +1,71 @@
1
1
  # url-safe-bitpacking
2
2
 
3
- To install dependencies:
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.
4
4
 
5
- ```bash
6
- bun install
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
- To run:
25
+ ### enum
10
26
 
11
- ```bash
12
- bun run index.ts
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
- This project was created using `bun init` in bun v1.0.7. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
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,7 @@
1
+ export declare enum DataType {
2
+ VERSION = 0,
3
+ BOOLEAN = 1,
4
+ ENUM = 2,
5
+ INT = 3,
6
+ FLOAT = 4
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from './dataTypes';
2
+ export * from './objectGenerationTypes';
@@ -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,2 @@
1
+ import { BooleanData } from '../types/booleanData';
2
+ export declare const create: () => BooleanData;
@@ -0,0 +1,2 @@
1
+ import { EnumData } from '../types/enumData';
2
+ export declare const create: (max: number) => EnumData;
@@ -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,2 @@
1
+ import { FloatData, PrecisionRangeType } from '../types/floatData';
2
+ export declare const create: (min: number, max: number, precision: PrecisionRangeType) => FloatData;
@@ -0,0 +1 @@
1
+ export declare const getBitsForIntegerNumber: (number: number, maxBits: number) => number;
@@ -0,0 +1 @@
1
+ export * from './factory';
@@ -0,0 +1,2 @@
1
+ import { IntData } from '../types/intData';
2
+ export declare const create: (min: number, max: number) => IntData;
@@ -0,0 +1,2 @@
1
+ import { VersionRangeType, VersionData } from '../types/versionData';
2
+ export declare const create: (bits: VersionRangeType) => VersionData;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export * from './enums';
2
- export * from './factory';
3
- export * from './objectmap';
4
- export * from './parsers';
5
- export * from './types';
6
- export * from './update';
7
- export * from './utils';
1
+ export { ObjectGenerationOutputStatus, DataType } from './enums';
2
+ export { DataRangeDescriptionFactory, DataDescriptionFactory, DataEntryFactory } from './factory';
3
+ export { getDefaultObject, updateDataEntry } from './objectmap';
4
+ export { valueBitsParser, dataBitsParser, getBitsCount, dataBitsArrayParser, dataBitsStringifier, dataEntryCorrecting, parseBitsToBase64, parseBase64ToBits, dataArrayStringifier, } from './parsers';
5
+ export { SingleLevelContentType, NestedContentDataType, NestedContentType, DoubleLevelContentType, NonEmptyValidEntryArrayType, OptionalEntryDataType, EnumEntryDataType, VersionArrayDefinitionType, PrecisionRangeType, SignificandMaxBits, FloatData, IntegerMaxBits, IntData, VersionRangeType, VersionData, GlobalVersion, BooleanData, DataRangeDescription, BooleanDiscriptionType, IntDiscriptionType, EnumDiscriptionType, FloatDiscriptionType, VersionDiscriptionType, DataDescription, BooleanDescriptionWithValueType, IntDescriptionWithValueType, EnumDescriptionWithValueType, FloatDescriptionWithValueType, VersionDescriptionWithValueType, DataEntry, DataEntryArray, SemanticlyNestedDataEntry, SemanticlyNestedDataDescription, ObjectGeneratorMethod, DefinitionGenerationObject, DefinitionNestedArray, DefinitionNestedGenerationObject, DefinitionSubObject, DefinitionArrayObject, VersionDefinitionObject, VersionEnumSemantics, ParserForVersion, VersionParsers, } from './types';
6
+ export {} from './update';
7
+ export { interpolateEntryAt, getRelativeValue } from './utils';
package/dist/index.js CHANGED
@@ -310,18 +310,6 @@ var dataArrayStringifier = (dataEntryArray) => {
310
310
 
311
311
  // src/objectmap/versionReading.ts
312
312
  var parameterOffset = 100;
313
- var getVariableStrings = (definitionArrayObject) => {
314
- const keys = [];
315
- definitionArrayObject.forEach((value) => {
316
- if (Array.isArray(value)) {
317
- if (value.length === 2)
318
- keys.push(...getVariableStrings(value[1]));
319
- if (value.length === 3)
320
- keys.push(value[1].name);
321
- }
322
- });
323
- return keys;
324
- };
325
313
  var nestedDataEntryArrayToObject = (definitionArrayObject, startIndex) => {
326
314
  const baseIndex = startIndex * parameterOffset;
327
315
  return Object.fromEntries(definitionArrayObject.map((value, i) => {
@@ -334,60 +322,6 @@ var nestedDataEntryArrayToObject = (definitionArrayObject, startIndex) => {
334
322
  return [value.name, { ...value, index: baseIndex + i }];
335
323
  }));
336
324
  };
337
- var definitionArrayObjectParser = (bitString, v, orderIndex) => {
338
- const [key, values] = v;
339
- const [nestedSemanticObject, objectGenerationStatus, localEndIndex] = parsingDefinitionArrayObject(bitString, values, orderIndex);
340
- return [[key, nestedSemanticObject], objectGenerationStatus, localEndIndex];
341
- };
342
- var methodParser = (bitString, v, orderIndex) => {
343
- const [key, keyDataDescription, methodGenerator] = v;
344
- const [keyDataEntry, status, bitWidth] = dataEntryParser(bitString, keyDataDescription, orderIndex);
345
- const [result, localStatus, localEndIndex] = definitionArrayObjectParser(bitString, [key, methodGenerator(keyDataEntry)], orderIndex);
346
- return [result, localStatus !== ObjectGenerationOutputStatus.PARSED ? localStatus : status, localEndIndex];
347
- };
348
- var dataEntryParser = (bitString, v, baseOrderIndex) => {
349
- const bitWidth = getBitsCount6(v);
350
- const value = dataBitsParser(bitString.slice(0, bitWidth), v);
351
- return [{ ...value, index: baseOrderIndex }, ObjectGenerationOutputStatus.PARSED, bitWidth];
352
- };
353
- var parsingDefinitionArrayObject = (bitString, definitionArrayObject, orderIndex) => {
354
- const baseOrderIndex = orderIndex * parameterOffset;
355
- let startIndex = 0;
356
- let objectGenerationStatus = ObjectGenerationOutputStatus.PARSED;
357
- return [
358
- Object.fromEntries(definitionArrayObject.map((value, i) => {
359
- if (Array.isArray(value)) {
360
- if (value.length === 2) {
361
- const [[key, nestedSemanticObject], status, localEndIndex] = definitionArrayObjectParser(bitString.slice(startIndex), value, baseOrderIndex + i);
362
- startIndex += localEndIndex;
363
- ObjectGenerationOutputStatus.PARSED;
364
- return [key, nestedSemanticObject];
365
- } else {
366
- const [[key, nestedSemanticObject], status, localEndIndex] = methodParser(bitString.slice(startIndex), value, baseOrderIndex + i);
367
- startIndex += localEndIndex;
368
- ObjectGenerationOutputStatus.PARSED;
369
- return [key, nestedSemanticObject];
370
- }
371
- } else {
372
- const [dataEntry, status, localEndIndex] = dataEntryParser(bitString.slice(startIndex), value, baseOrderIndex + i);
373
- startIndex += localEndIndex;
374
- ObjectGenerationOutputStatus.PARSED;
375
- return [dataEntry.name, dataEntry];
376
- }
377
- })),
378
- objectGenerationStatus,
379
- startIndex
380
- ];
381
- };
382
- var readingVersion = (bitstring) => dataBitsArrayParser(bitstring, [DataDescriptionFactory.createVersion(8)])[0];
383
- var parseUrlMethod = (url, parserVersions) => {
384
- const bitString = parseBase64ToBits(url);
385
- const version = readingVersion(bitString);
386
- const versionParser = parserVersions[version.value];
387
- if (!versionParser)
388
- throw new Error(`No parser for version ${version.value}`);
389
- return parsingDefinitionArrayObject(bitString, versionParser.objectGeneratorParameters, 0)[0];
390
- };
391
325
  var parseDownNestedDataDescription = (nestedDataDescription) => {
392
326
  const dataDescriptions = [];
393
327
  Object.values(nestedDataDescription).forEach((value) => {
@@ -398,28 +332,6 @@ var parseDownNestedDataDescription = (nestedDataDescription) => {
398
332
  });
399
333
  return dataDescriptions.sort();
400
334
  };
401
- var getURLForData = (data) => {
402
- const dataEntryArray = parseDownNestedDataDescription(data);
403
- const bitstring = dataArrayStringifier(dataEntryArray);
404
- return parseBitsToBase64(bitstring);
405
- };
406
- var getTestStringValues = (data) => {
407
- const dataEntryArray = parseDownNestedDataDescription(data);
408
- const bitstring = dataArrayStringifier(dataEntryArray);
409
- const url = parseBitsToBase64(bitstring);
410
- const dataValueStrings = dataEntryArray.map((dataEntry) => dataBitsStringifier(dataEntry));
411
- const singleString = dataValueStrings.join("");
412
- const base64bitStringArray = singleString.match(/.{1,6}/g)?.map((c) => c.padEnd(6, "0")) ?? [];
413
- const base64valueArray = url.split("").map((c) => c.padStart(6, "_"));
414
- const raw = JSON.stringify(parseDownNestedDataDescription(data), undefined, 1);
415
- return {
416
- bitsString: dataValueStrings.join("-"),
417
- base64BitString: base64bitStringArray.join("-"),
418
- base64SplitString: base64valueArray.join("-"),
419
- base64String: url,
420
- raw
421
- };
422
- };
423
335
  // src/update/floatUpdate.ts
424
336
  var updateValue = (original, update) => {
425
337
  const value = Math.max(Math.min(update.value, original.max), original.min);
@@ -565,18 +477,10 @@ var getRelativeValue = (dataEntry2) => {
565
477
  };
566
478
  export {
567
479
  valueBitsParser,
568
- updateValue6 as updateValue,
569
- updateDataEntryObject,
570
480
  updateDataEntry,
571
- parseUrlMethod,
572
- parseDownNestedDataDescription,
573
481
  parseBitsToBase64,
574
482
  parseBase64ToBits,
575
- nestedDataEntryArrayToObject,
576
483
  interpolateEntryAt,
577
- getVariableStrings,
578
- getURLForData,
579
- getTestStringValues,
580
484
  getRelativeValue,
581
485
  getDefaultObject,
582
486
  getBitsCount6 as getBitsCount,
@@ -588,7 +492,6 @@ export {
588
492
  SignificandMaxBits,
589
493
  ObjectGenerationOutputStatus,
590
494
  IntegerMaxBits,
591
- EnumMaxBits,
592
495
  DataType,
593
496
  DataRangeDescriptionFactory,
594
497
  DataEntryFactory,
@@ -0,0 +1,2 @@
1
+ export * from './versionReading';
2
+ export * from './versionUpdate';
@@ -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
+ export declare const getBitsCount: () => number;
2
+ export declare const rawValueParser: (stateString: string) => boolean;
3
+ export declare const rawParser: (stateString: string) => boolean;
4
+ export declare const rawStringifier: (value: boolean) => string;
@@ -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,12 @@
1
+ import { NestedContentDataType, OptionalEntryDataType, EnumEntryDataType, VersionArrayDefinitionType, NestedContentType } from '../types/arrayDefinitions';
2
+ export declare const nestedContentDataType: NestedContentDataType;
3
+ export declare const validOptionalEntryType: OptionalEntryDataType;
4
+ export declare const anotherValidOptionalEntryType: OptionalEntryDataType;
5
+ export declare const validEnumEntryType: EnumEntryDataType;
6
+ export declare const generalNestedContentDataType: NestedContentDataType;
7
+ export declare const exampleVersion: VersionArrayDefinitionType;
8
+ export declare const lucernaeTuricumArcExamples: EnumEntryDataType;
9
+ export declare const footprintDefinition: EnumEntryDataType;
10
+ export declare const heightParsingDefinition: NestedContentType;
11
+ export declare const shapePreProcessingDefinition: EnumEntryDataType;
12
+ export declare const lucernaeTurici: VersionArrayDefinitionType;
@@ -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,2 @@
1
+ import { PrecisionRangeType } from '../types';
2
+ export declare const values: [number, number, number, PrecisionRangeType, string][];
@@ -0,0 +1 @@
1
+ export declare const values: [number, number, number, string][];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { VersionRangeType } from '../types';
2
+ export declare const values: [number, VersionRangeType, string][];
@@ -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,4 @@
1
+ import { DataType } from '../enums/dataTypes';
2
+ export interface BooleanData {
3
+ type: DataType.BOOLEAN;
4
+ }
@@ -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,7 @@
1
+ import { DataType } from '../enums/dataTypes';
2
+ export declare const EnumMaxBits = 8;
3
+ export interface EnumData {
4
+ type: DataType.ENUM;
5
+ max: number;
6
+ bits: number;
7
+ }
@@ -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,8 @@
1
+ import { DataType } from '../enums/dataTypes';
2
+ export declare const IntegerMaxBits = 12;
3
+ export interface IntData {
4
+ type: DataType.INT;
5
+ min: number;
6
+ max: number;
7
+ bits: number;
8
+ }
@@ -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,33 @@
1
+ import { ObjectGenerationOutputStatus } from '../enums/objectGenerationTypes';
2
+ import { DataEntry, VersionDiscriptionType } from './dataEntry';
3
+ import { SemanticlyNestedDataEntry } from './semanticlyNestedDataEntry';
4
+ import { GlobalVersion } 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
+ versionName: string;
27
+ versionEnumSemantics?: VersionEnumSemantics;
28
+ objectGeneratorParameters: VersionDefinitionObject;
29
+ };
30
+ export type VersionParsers = {
31
+ versionRange: GlobalVersion;
32
+ versionParsers: ParserForVersion[];
33
+ };