fix: optimize daletpack strings, update types.ts

This commit is contained in:
Artemy Egorov 2024-08-05 19:17:40 +03:00
parent dc12c44895
commit 6a693821a9
4 changed files with 33 additions and 40 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "@txtdot/dalet", "name": "@txtdot/dalet",
"version": "1.0.0-pre2", "version": "1.0.0-pre3",
"description": "Dalet implementation in typescript", "description": "Dalet implementation in typescript",
"main": "dist/lib.js", "main": "dist/lib.js",
"types": "dist/lib.d.ts", "types": "dist/lib.d.ts",

View file

@ -1,4 +1,6 @@
export type Page = Tag[]; export interface Page {
data: Tag[];
}
export type Body = string | Tag[] | null; export type Body = string | Tag[] | null;
export type Argument = string | number | null; export type Argument = string | number | null;

View file

@ -6,10 +6,12 @@ Daletl is data representation of serialized/deserialized [DaletPack](./daletpack
### Page ### Page
Daletl page is array of tags. For convenience, we will use the typescript notation. Daletl page is struct. For convenience, we will use the typescript notation.
```typescript ```typescript
type Page = Tag[]; interface Page = {
data: Tag[]
}
``` ```
### Tag ### Tag

View file

@ -34,16 +34,15 @@ Mime type: `application/dalet-pack`
| name | id | | name | id |
| ------------------------ | --- | | ------------------------ | --- |
| int 8 | 1 | | str end | 0 |
| str 8 | 4 | | str | 1 |
| str 16 | 5 | | int | 2 |
| str 32 | 6 | | tag array | 3 |
| tag array | 7 | | tag array end | 4 |
| tag array end | 8 | | tag (id) | 5 |
| tag (id) | 12 | | tag (id, body) | 6 |
| tag (id, body) | 13 | | tag (id, argument) | 7 |
| tag (id, argument) | 14 | | tag (id, body, argument) | 8 |
| tag (id, body, argument) | 15 |
### Notation in diagrams ### Notation in diagrams
@ -66,7 +65,17 @@ variable number of objects stored in DaletPack format:
X - unknown bit X - unknown bit
``` ```
### Integer format ### Str format
```txt
str:
+--------+=========+--------+
| 1 | utf-8 | 0 |
+--------+=========+--------+
```
### Int format
```txt ```txt
+--------+----------+ +--------+----------+
@ -74,32 +83,12 @@ X - unknown bit
+--------+----------+ +--------+----------+
``` ```
### String format
```txt
str 8 (up to 256 bytes):
+--------+----------+=========+
| 4 | XXXXXXXX | utf-8 |
+--------+----------+=========+
str 16 (up to 2^16 bytes):
+--------+----------+----------+=========+
| 5 | XXXXXXXX | XXXXXXXX | utf-8 |
+--------+----------+----------+=========+
str 32 (up to 2^32 bytes):
+--------+----------+----------+----------+----------+=========+
| 6 | XXXXXXXX | XXXXXXXX | XXXXXXXX | XXXXXXXX | utf-8 |
+--------+----------+----------+----------+----------+=========+
```
### Tag array format ### Tag array format
```txt ```txt
tag array: tag array:
+--------+~~~~~~~~~~~~+------+ +--------+~~~~~~~~~~~~+------+
| 7 | elements | 8 | | 3 | elements | 4 |
+--------+~~~~~~~~~~~~+------+ +--------+~~~~~~~~~~~~+------+
``` ```
@ -111,21 +100,21 @@ id = XXXXX (5 bits) (can change before release)
tag (id): tag (id):
+--------+----+ +--------+----+
| 12 | id | | 5 | id |
+--------+----+ +--------+----+
tag (id, body): tag (id, body):
+--------+----+~~~~~~~~+ +--------+----+~~~~~~~~+
| 13 | id | body | | 6 | id | body |
+--------+----+~~~~~~~~+ +--------+----+~~~~~~~~+
tag (id, argument): tag (id, argument):
+--------+----+~~~~~~~~~~~~+ +--------+----+~~~~~~~~~~~~+
| 14 | id | argument | | 7 | id | argument |
+--------+----+~~~~~~~~~~~~+ +--------+----+~~~~~~~~~~~~+
tag (id, body, argument): tag (id, body, argument):
+--------+----+~~~~~~~~+~~~~~~~~~~~~+ +--------+----+~~~~~~~~+~~~~~~~~~~~~+
| 15 | id | body | argument | | 8 | id | body | argument |
+--------+----+~~~~~~~~+~~~~~~~~~~~~+ +--------+----+~~~~~~~~+~~~~~~~~~~~~+
``` ```