@ahmadmoussawi/webdb 0.0.0-stage → 0.1.1
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 +386 -2
- package/dist/constants.d.ts +18 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/js/buffer_pool.c.d.ts +142 -0
- package/dist/core/js/buffer_pool.c.d.ts.map +1 -0
- package/dist/core/js/catalog.c.d.ts +186 -0
- package/dist/core/js/catalog.c.d.ts.map +1 -0
- package/dist/core/js/codecs.c.d.ts +32 -0
- package/dist/core/js/codecs.c.d.ts.map +1 -0
- package/dist/core/js/index.d.ts +7 -0
- package/dist/core/js/index.d.ts.map +1 -0
- package/dist/core/js/page.c.d.ts +229 -0
- package/dist/core/js/page.c.d.ts.map +1 -0
- package/dist/core/js/page_table.c.d.ts +48 -0
- package/dist/core/js/page_table.c.d.ts.map +1 -0
- package/dist/core/js/vm.c.d.ts +11 -0
- package/dist/core/js/vm.c.d.ts.map +1 -0
- package/dist/core/js/vm.helpers.c.d.ts +124 -0
- package/dist/core/js/vm.helpers.c.d.ts.map +1 -0
- package/dist/core/types.d.ts +26 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/wasm/embedded_wasm.d.ts +7 -0
- package/dist/core/wasm/embedded_wasm.d.ts.map +1 -0
- package/dist/core/wasm/wasm_core.d.ts +75 -0
- package/dist/core/wasm/wasm_core.d.ts.map +1 -0
- package/dist/host/api/index.d.ts +3 -0
- package/dist/host/api/index.d.ts.map +1 -0
- package/dist/host/api/query_builder.d.ts +216 -0
- package/dist/host/api/query_builder.d.ts.map +1 -0
- package/dist/host/api/webdb.d.ts +172 -0
- package/dist/host/api/webdb.d.ts.map +1 -0
- package/dist/host/compiler/compiler.d.ts +151 -0
- package/dist/host/compiler/compiler.d.ts.map +1 -0
- package/dist/host/compiler/expr_parser.d.ts +87 -0
- package/dist/host/compiler/expr_parser.d.ts.map +1 -0
- package/dist/host/compiler/index.d.ts +4 -0
- package/dist/host/compiler/index.d.ts.map +1 -0
- package/dist/host/compiler/planner/cost.d.ts +23 -0
- package/dist/host/compiler/planner/cost.d.ts.map +1 -0
- package/dist/host/compiler/planner/custom_order.d.ts +16 -0
- package/dist/host/compiler/planner/custom_order.d.ts.map +1 -0
- package/dist/host/compiler/planner/heuristic.d.ts +11 -0
- package/dist/host/compiler/planner/heuristic.d.ts.map +1 -0
- package/dist/host/compiler/planner/index.d.ts +34 -0
- package/dist/host/compiler/planner/index.d.ts.map +1 -0
- package/dist/host/compiler/planner/noop.d.ts +11 -0
- package/dist/host/compiler/planner/noop.d.ts.map +1 -0
- package/dist/host/compiler/planner/types.d.ts +100 -0
- package/dist/host/compiler/planner/types.d.ts.map +1 -0
- package/dist/host/compiler/planner/where_optimizer.d.ts +30 -0
- package/dist/host/compiler/planner/where_optimizer.d.ts.map +1 -0
- package/dist/host/compiler/planner.d.ts +2 -0
- package/dist/host/compiler/planner.d.ts.map +1 -0
- package/dist/host/driver/buffer_pool_driver.d.ts +94 -0
- package/dist/host/driver/buffer_pool_driver.d.ts.map +1 -0
- package/dist/host/driver/crash_recovery.d.ts +24 -0
- package/dist/host/driver/crash_recovery.d.ts.map +1 -0
- package/dist/host/driver/index.d.ts +4 -0
- package/dist/host/driver/index.d.ts.map +1 -0
- package/dist/host/driver/transaction_coordinator.d.ts +166 -0
- package/dist/host/driver/transaction_coordinator.d.ts.map +1 -0
- package/dist/host/storage/crc32.d.ts +24 -0
- package/dist/host/storage/crc32.d.ts.map +1 -0
- package/dist/host/storage/idb.d.ts +27 -0
- package/dist/host/storage/idb.d.ts.map +1 -0
- package/dist/host/storage/index.d.ts +8 -0
- package/dist/host/storage/index.d.ts.map +1 -0
- package/dist/host/storage/io.d.ts +60 -0
- package/dist/host/storage/io.d.ts.map +1 -0
- package/dist/host/storage/memory.d.ts +28 -0
- package/dist/host/storage/memory.d.ts.map +1 -0
- package/dist/host/storage/opfs.d.ts +31 -0
- package/dist/host/storage/opfs.d.ts.map +1 -0
- package/dist/host/storage/vfs.d.ts +36 -0
- package/dist/host/storage/vfs.d.ts.map +1 -0
- package/dist/host/storage/wal_codec.d.ts +56 -0
- package/dist/host/storage/wal_codec.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/layouts/index.d.ts +5 -0
- package/dist/layouts/index.d.ts.map +1 -0
- package/dist/layouts/page_format.d.ts +163 -0
- package/dist/layouts/page_format.d.ts.map +1 -0
- package/dist/layouts/pool_format.d.ts +126 -0
- package/dist/layouts/pool_format.d.ts.map +1 -0
- package/dist/layouts/syspage_format.d.ts +499 -0
- package/dist/layouts/syspage_format.d.ts.map +1 -0
- package/dist/layouts/wal_format.d.ts +197 -0
- package/dist/layouts/wal_format.d.ts.map +1 -0
- package/dist/shared/c_runtime.d.ts +47 -0
- package/dist/shared/c_runtime.d.ts.map +1 -0
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/page_provider.d.ts +12 -0
- package/dist/shared/page_provider.d.ts.map +1 -0
- package/dist/shared/vm_context.d.ts +73 -0
- package/dist/shared/vm_context.d.ts.map +1 -0
- package/dist/types/index.d.ts +338 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/webdb.js +13059 -0
- package/dist/webdb.js.map +1 -0
- package/dist/webdb.umd.cjs +5 -0
- package/dist/webdb.umd.cjs.map +1 -0
- package/package.json +82 -4
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { DataType, ColumnDefinition, ColumnMeta, TableDescriptor, IndexDescriptor, CatalogPageHeader, TableMeta } from '../../types/index.ts';
|
|
2
|
+
import { IPageProvider } from '../../shared/index.ts';
|
|
3
|
+
import { u16, u32, i32, const_u8_ptr } from '../types.ts';
|
|
4
|
+
export declare const MAGIC_BYTES: Uint8Array<ArrayBuffer>;
|
|
5
|
+
/**
|
|
6
|
+
* @export_c
|
|
7
|
+
*/
|
|
8
|
+
export declare function compute_crc32(data: const_u8_ptr, length: u32): u32;
|
|
9
|
+
/**
|
|
10
|
+
* @export_c
|
|
11
|
+
*/
|
|
12
|
+
export declare function compute_page_checksum(view: DataView, page_offset?: u32): u32;
|
|
13
|
+
/**
|
|
14
|
+
* @export_c
|
|
15
|
+
*/
|
|
16
|
+
export declare function compute_page1_checksum(view: DataView, page1_offset?: u32): u32;
|
|
17
|
+
/**
|
|
18
|
+
* @export_c
|
|
19
|
+
* Initializes the Page 1 database file header and clears the catalog area.
|
|
20
|
+
*/
|
|
21
|
+
export declare function catalog_init_page1(view: DataView, page1_offset?: u32): void;
|
|
22
|
+
/**
|
|
23
|
+
* Reads and validates the Page 1 database file header.
|
|
24
|
+
*/
|
|
25
|
+
export declare function catalog_read_page1_header(view: DataView, verify_checksum?: boolean): {
|
|
26
|
+
pageSize: number;
|
|
27
|
+
fileFormatVersion: number;
|
|
28
|
+
minReadVersion: number;
|
|
29
|
+
totalPages: number;
|
|
30
|
+
freePageHead: number;
|
|
31
|
+
schemaVersion: number;
|
|
32
|
+
changeCounter: number;
|
|
33
|
+
storedChecksum: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* @export_c
|
|
37
|
+
*/
|
|
38
|
+
export declare function catalog_get_total_pages(view: DataView, page1_offset?: u32): u32;
|
|
39
|
+
/**
|
|
40
|
+
* @export_c
|
|
41
|
+
*/
|
|
42
|
+
export declare function catalog_set_total_pages(view: DataView, page1_offset: u32, count?: u32): void;
|
|
43
|
+
/**
|
|
44
|
+
* @export_c
|
|
45
|
+
*/
|
|
46
|
+
export declare function catalog_get_free_page_head(view: DataView, page1_offset?: u32): u32;
|
|
47
|
+
/**
|
|
48
|
+
* @export_c
|
|
49
|
+
*/
|
|
50
|
+
export declare function catalog_set_free_page_head(view: DataView, page1_offset: u32, page_id?: u32): void;
|
|
51
|
+
/**
|
|
52
|
+
* @export_c
|
|
53
|
+
*/
|
|
54
|
+
export declare function catalog_get_schema_version(view: DataView, page1_offset?: u32): u32;
|
|
55
|
+
/**
|
|
56
|
+
* @export_c
|
|
57
|
+
*/
|
|
58
|
+
export declare function catalog_increment_schema_version(view: DataView, page1_offset?: u32): u32;
|
|
59
|
+
/**
|
|
60
|
+
* @export_c
|
|
61
|
+
*/
|
|
62
|
+
export declare function catalog_get_change_counter(view: DataView, page1_offset?: u32): u32;
|
|
63
|
+
/**
|
|
64
|
+
* @export_c
|
|
65
|
+
*/
|
|
66
|
+
export declare function catalog_increment_change_counter(view: DataView, page1_offset?: u32): u32;
|
|
67
|
+
/**
|
|
68
|
+
* @export_c
|
|
69
|
+
*/
|
|
70
|
+
export declare function catalog_update_page1_checksum(view: DataView, page1_offset?: u32): u32;
|
|
71
|
+
/**
|
|
72
|
+
* @export_c
|
|
73
|
+
*/
|
|
74
|
+
export declare function catalog_write_fixed_string(view: DataView, offset: u32, str: string, max_len: u32): void;
|
|
75
|
+
/**
|
|
76
|
+
* Reads a fixed-length string from the catalog.
|
|
77
|
+
*/
|
|
78
|
+
export declare function catalog_read_fixed_string(view: DataView, offset: number, max_len: number): string;
|
|
79
|
+
/**
|
|
80
|
+
* Parses SQL type string to DataType enum.
|
|
81
|
+
*/
|
|
82
|
+
export declare function catalog_parse_data_type(type_str: string): DataType;
|
|
83
|
+
/**
|
|
84
|
+
* Reads a TableDescriptor from Page 1 by slot index (0..15).
|
|
85
|
+
*/
|
|
86
|
+
export declare function catalog_read_table_descriptor(view: DataView, slot_idx: number): TableDescriptor | null;
|
|
87
|
+
/**
|
|
88
|
+
* Writes a TableDescriptor into Page 1 at the specified slot index (0..15).
|
|
89
|
+
*/
|
|
90
|
+
export declare function catalog_write_table_descriptor(view: DataView, slot_idx: number, desc: TableDescriptor): void;
|
|
91
|
+
/**
|
|
92
|
+
* Finds a TableDescriptor by name in Page 1, or null if not found.
|
|
93
|
+
*/
|
|
94
|
+
export declare function catalog_find_table_by_name(view: DataView, table_name: string): TableDescriptor | null;
|
|
95
|
+
/**
|
|
96
|
+
* Finds the slot index of an existing table by name, or -1 if not found.
|
|
97
|
+
*/
|
|
98
|
+
export declare function catalog_find_table_slot(view: DataView, table_name: string): number;
|
|
99
|
+
/**
|
|
100
|
+
* @export_c
|
|
101
|
+
* Finds the first free slot index in Page 1's TableDescriptor array.
|
|
102
|
+
*/
|
|
103
|
+
export declare function catalog_find_free_table_slot(view: DataView, page1_offset?: u32): i32;
|
|
104
|
+
/**
|
|
105
|
+
* Lists all active tables defined on Page 1.
|
|
106
|
+
*/
|
|
107
|
+
export declare function catalog_list_table_descriptors(view: DataView): TableDescriptor[];
|
|
108
|
+
/**
|
|
109
|
+
* Reads an IndexDescriptor from Page 1 by slot index.
|
|
110
|
+
*/
|
|
111
|
+
export declare function catalog_read_index_descriptor(view: DataView, slot_idx: number): IndexDescriptor | null;
|
|
112
|
+
/**
|
|
113
|
+
* Writes an IndexDescriptor into Page 1 at the specified slot index.
|
|
114
|
+
*/
|
|
115
|
+
export declare function catalog_write_index_descriptor(view: DataView, slot_idx: number, desc: IndexDescriptor): void;
|
|
116
|
+
export declare const MAX_INDEXES_PAGE1 = 8;
|
|
117
|
+
/**
|
|
118
|
+
* @export_c
|
|
119
|
+
*/
|
|
120
|
+
export declare function catalog_find_free_index_slot(view: DataView, page1_offset?: u32): i32;
|
|
121
|
+
/**
|
|
122
|
+
* Finds an IndexDescriptor by name in Page 1.
|
|
123
|
+
*/
|
|
124
|
+
export declare function catalog_find_index_by_name(view: DataView, name: string): {
|
|
125
|
+
slotIdx: number;
|
|
126
|
+
desc: IndexDescriptor;
|
|
127
|
+
} | null;
|
|
128
|
+
/**
|
|
129
|
+
* Lists all index descriptors for a table.
|
|
130
|
+
*/
|
|
131
|
+
export declare function catalog_list_table_indexes(view: DataView, table_id: number): IndexDescriptor[];
|
|
132
|
+
/**
|
|
133
|
+
* @export_c
|
|
134
|
+
*/
|
|
135
|
+
export declare function catalog_delete_index_descriptor(view: DataView, page1_offset: u32, slot_idx?: u32): i32;
|
|
136
|
+
/**
|
|
137
|
+
* @export_c
|
|
138
|
+
*/
|
|
139
|
+
export declare function catalog_delete_table_descriptor(view: DataView, page1_offset: u32, slot_idx?: u32): i32;
|
|
140
|
+
/**
|
|
141
|
+
* @export_c
|
|
142
|
+
* Initializes a 4KB dedicated column catalog page.
|
|
143
|
+
*/
|
|
144
|
+
export declare function catalog_init_page(view: DataView, page_offset: u32, table_id: u16, start_col_index: u16, next_col_catalog_page_id?: u32): void;
|
|
145
|
+
/**
|
|
146
|
+
* Reads the catalog page header.
|
|
147
|
+
*/
|
|
148
|
+
export declare function catalog_read_page_header(view: DataView, page_offset: number): CatalogPageHeader;
|
|
149
|
+
/**
|
|
150
|
+
* @export_c
|
|
151
|
+
*/
|
|
152
|
+
export declare function catalog_write_page_header(view: DataView, page_offset: u32, col_count_in_page: u16, table_id: u16, start_col_index: u16, next_col_catalog_page_id: u32): void;
|
|
153
|
+
/**
|
|
154
|
+
* Writes a ColumnMeta entry (72 bytes) into a catalog page at inPageSlot (0..55).
|
|
155
|
+
*/
|
|
156
|
+
export declare function catalog_write_column_meta(view: DataView, page_offset: number, in_page_slot: number, meta: ColumnMeta): void;
|
|
157
|
+
/**
|
|
158
|
+
* Reads a ColumnMeta entry (72 bytes) from a catalog page at inPageSlot (0..55).
|
|
159
|
+
*/
|
|
160
|
+
export declare function catalog_read_column_meta(view: DataView, page_offset: number, in_page_slot: number): ColumnMeta;
|
|
161
|
+
/**
|
|
162
|
+
* Calculates cross-page column mapping:
|
|
163
|
+
* page_chain_idx = floor(col_idx / 56)
|
|
164
|
+
* col_idx_in_page = col_idx % 56
|
|
165
|
+
*/
|
|
166
|
+
export declare function catalog_map_column_location(col_idx: number): {
|
|
167
|
+
pageChainIdx: number;
|
|
168
|
+
colIdxInPage: number;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Creates a new table, allocating a root data page and dedicated column catalog page(s).
|
|
172
|
+
*/
|
|
173
|
+
export declare function catalog_create_table(page1_view: DataView, pager: IPageProvider, name: string, column_def: ColumnDefinition[]): TableMeta;
|
|
174
|
+
/**
|
|
175
|
+
* Loads the complete TableMeta (including all columns from chained catalog pages) for a table.
|
|
176
|
+
*/
|
|
177
|
+
export declare function catalog_load_table_meta(page1_view: DataView, pager: {
|
|
178
|
+
getPageBytes(pageId: number): Uint8Array;
|
|
179
|
+
}, table_name: string): TableMeta;
|
|
180
|
+
/**
|
|
181
|
+
* Loads all active tables and their full schemas from Page 1.
|
|
182
|
+
*/
|
|
183
|
+
export declare function catalog_load_all_tables(page1_view: DataView, pager: {
|
|
184
|
+
getPageBytes(pageId: number): Uint8Array;
|
|
185
|
+
}): TableMeta[];
|
|
186
|
+
//# sourceMappingURL=catalog.c.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.c.d.ts","sourceRoot":"","sources":["../../../src/core/js/catalog.c.ts"],"names":[],"mappings":"AA8BA,OAAO,EACL,QAAQ,EAIR,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,SAAS,EAQV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAS/D,eAAO,MAAM,WAAW,yBAAuD,CAAC;AAwBhF;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,GAAG,GAAG,CAQlE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,GAAE,GAAO,GAAG,GAAG,CAQ/E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,GAAE,GAAO,GAAG,GAAG,CAQjF;AAMD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,I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C,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,UAAU,CASZ;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG;IAC5D,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB,CAKA;AAMD;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,QAAQ,EACpB,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,gBAAgB,EAAE,GAC7B,SAAS,CA8MX;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,QAAQ,EAEpB,KAAK,EAAE;IAAE,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,EACnD,UAAU,EAAE,MAAM,GACjB,SAAS,CAyCX;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,QAAQ,EAEpB,KAAK,EAAE;IAAE,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,GAClD,SAAS,EAAE,CASb"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { u32, i32 } from '../types.ts';
|
|
2
|
+
export declare const HEX_CHARS = "0123456789abcdef";
|
|
3
|
+
export declare const CROCKFORD_ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
4
|
+
/**
|
|
5
|
+
* @export_c
|
|
6
|
+
*/
|
|
7
|
+
export declare function uuid_encode(uuid_str: string, target: Uint8Array, offset: u32): i32;
|
|
8
|
+
/**
|
|
9
|
+
* @export_c
|
|
10
|
+
*/
|
|
11
|
+
export declare function uuid_decode(source: Uint8Array, offset: u32, out_str: any): void;
|
|
12
|
+
export declare class UuidCodec {
|
|
13
|
+
/** Packs a 36-char hyphenated UUID string into 16 raw binary bytes */
|
|
14
|
+
static encode(uuid_str: string, target: Uint8Array, offset?: number): void;
|
|
15
|
+
/** Unpacks 16 raw bytes into canonical 36-char hyphenated UUID string */
|
|
16
|
+
static decode(source: Uint8Array, offset?: number): string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @export_c
|
|
20
|
+
*/
|
|
21
|
+
export declare function ulid_encode(ulid_str: string, target: Uint8Array, offset: u32): i32;
|
|
22
|
+
/**
|
|
23
|
+
* @export_c
|
|
24
|
+
*/
|
|
25
|
+
export declare function ulid_decode(source: Uint8Array, offset: u32, out_str: any): void;
|
|
26
|
+
export declare class UlidCodec {
|
|
27
|
+
/** Packs a 26-character Crockford Base32 string into 16 raw bytes */
|
|
28
|
+
static encode(ulid_str: string, target: Uint8Array, offset?: number): void;
|
|
29
|
+
/** Unpacks 16 raw bytes into canonical 26-char Crockford Base32 string */
|
|
30
|
+
static decode(source: Uint8Array, offset?: number): string;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=codecs.c.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs.c.d.ts","sourceRoot":"","sources":["../../../src/core/js/codecs.c.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,GAAG,EAAO,MAAM,aAAa,CAAC;AAK5C,eAAO,MAAM,SAAS,qBAAqB,CAAC;AAC5C,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAqDrE;;GAEG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,GAAG,GACV,GAAG,CAqBL;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,GAAG,GACX,IAAI,CAWN;AAED,qBAAa,SAAS;IACpB,sEAAsE;IACtE,MAAM,CAAC,MAAM,CACX,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,UAAU,EAClB,MAAM,GAAE,MAAU,GACjB,IAAI;IASP,yEAAyE;IACzE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM;CAK9D;AAMD;;GAEG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,GAAG,GACV,GAAG,CAqCL;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,GAAG,GACX,IAAI,CAgCN;AAED,qBAAa,SAAS;IACpB,qEAAqE;IACrE,MAAM,CAAC,MAAM,CACX,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,UAAU,EAClB,MAAM,GAAE,MAAU,GACjB,IAAI;IASP,0EAA0E;IAC1E,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM;CAK9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/js/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { DataType, ColumnMeta, TableMeta, DbRow, DbValue } from '../../types/index.ts';
|
|
2
|
+
import { u8, u16, u32, i32, i64 } from '../types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Initializes a standard 16-byte header 4KB page.
|
|
5
|
+
*
|
|
6
|
+
* Header Layout:
|
|
7
|
+
* [0] uint8_t page_type
|
|
8
|
+
* [1] uint8_t reserved (0x00)
|
|
9
|
+
* [2..3] uint16_t cell_count (0)
|
|
10
|
+
* [4..5] uint16_t cell_content_offset (PAGE_SIZE = 4096)
|
|
11
|
+
* [6..9] uint32_t next_page_id / right_child_page_id / next_free_page_id (0)
|
|
12
|
+
* [10..11] uint16_t free_bytes (0)
|
|
13
|
+
* [12..15] uint32_t checksum (0)
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* @export_c
|
|
17
|
+
* Initializes a 4KB slotted database page header.
|
|
18
|
+
*/
|
|
19
|
+
export declare function page_init(view: DataView, page_offset: u32, page_type?: u8, next_page_id?: u32): void;
|
|
20
|
+
/**
|
|
21
|
+
* @export_c
|
|
22
|
+
* Initializes a 4KB free-list page header.
|
|
23
|
+
*/
|
|
24
|
+
export declare function page_init_free(view: DataView, page_offset: u32, next_free_page_id?: u32): void;
|
|
25
|
+
/**
|
|
26
|
+
* @export_c
|
|
27
|
+
* Returns the page type byte from a page header.
|
|
28
|
+
*/
|
|
29
|
+
export declare function page_get_type(view: DataView, page_offset: u32): u8;
|
|
30
|
+
/**
|
|
31
|
+
* @export_c
|
|
32
|
+
* Sets the page type byte in a page header.
|
|
33
|
+
*/
|
|
34
|
+
export declare function page_set_type(view: DataView, page_offset: u32, type: u8): void;
|
|
35
|
+
/**
|
|
36
|
+
* @export_c
|
|
37
|
+
* Returns the number of cells in the page slot directory.
|
|
38
|
+
*/
|
|
39
|
+
export declare function page_get_cell_count(view: DataView, page_offset: u32): u16;
|
|
40
|
+
/**
|
|
41
|
+
* @export_c
|
|
42
|
+
* Sets the number of cells in the page slot directory.
|
|
43
|
+
*/
|
|
44
|
+
export declare function page_set_cell_count(view: DataView, page_offset: u32, count: u16): void;
|
|
45
|
+
/**
|
|
46
|
+
* @export_c
|
|
47
|
+
* Returns the byte offset within the page where active cell payloads begin.
|
|
48
|
+
*/
|
|
49
|
+
export declare function page_get_cell_content_offset(view: DataView, page_offset: u32): u16;
|
|
50
|
+
/**
|
|
51
|
+
* @export_c
|
|
52
|
+
* Sets the byte offset within the page where active cell payloads begin.
|
|
53
|
+
*/
|
|
54
|
+
export declare function page_set_cell_content_offset(view: DataView, page_offset: u32, offset: u16): void;
|
|
55
|
+
/**
|
|
56
|
+
* @export_c
|
|
57
|
+
* Returns the next page ID (or right child page ID) stored in the page header.
|
|
58
|
+
*/
|
|
59
|
+
export declare function page_get_next_page_id(view: DataView, page_offset: u32): u32;
|
|
60
|
+
/**
|
|
61
|
+
* @export_c
|
|
62
|
+
* Sets the next page ID (or right child page ID) stored in the page header.
|
|
63
|
+
*/
|
|
64
|
+
export declare function page_set_next_page_id(view: DataView, page_offset: u32, next_page_id: u32): void;
|
|
65
|
+
/**
|
|
66
|
+
* @export_c
|
|
67
|
+
* Returns cumulative fragmented unallocated bytes in the page.
|
|
68
|
+
*/
|
|
69
|
+
export declare function page_get_free_bytes(view: DataView, page_offset: u32): u16;
|
|
70
|
+
/**
|
|
71
|
+
* @export_c
|
|
72
|
+
* Sets cumulative fragmented unallocated bytes in the page.
|
|
73
|
+
*/
|
|
74
|
+
export declare function page_set_free_bytes(view: DataView, page_offset: u32, free_bytes: u16): void;
|
|
75
|
+
/**
|
|
76
|
+
* @export_c
|
|
77
|
+
* Returns the checksum stored at bytes 12..15 in the page header.
|
|
78
|
+
*/
|
|
79
|
+
export declare function page_get_checksum(view: DataView, page_offset: u32): u32;
|
|
80
|
+
/**
|
|
81
|
+
* @export_c
|
|
82
|
+
* Sets the checksum stored at bytes 12..15 in the page header.
|
|
83
|
+
*/
|
|
84
|
+
export declare function page_set_checksum(view: DataView, page_offset: u32, checksum: u32): void;
|
|
85
|
+
/**
|
|
86
|
+
* @export_c
|
|
87
|
+
* Returns the cell payload offset for the given slot directory index.
|
|
88
|
+
*/
|
|
89
|
+
export declare function page_get_cell_offset(view: DataView, page_offset: u32, slot_idx: u16): u16;
|
|
90
|
+
/**
|
|
91
|
+
* @export_c
|
|
92
|
+
* Sets the cell payload offset for the given slot directory index.
|
|
93
|
+
*/
|
|
94
|
+
export declare function page_set_cell_offset(view: DataView, page_offset: u32, slot_idx: u16, cell_offset: u16): void;
|
|
95
|
+
/**
|
|
96
|
+
* @export_c
|
|
97
|
+
* Returns contiguous free space between slot directory end and cell content offset.
|
|
98
|
+
*/
|
|
99
|
+
export declare function page_get_contiguous_free_space(view: DataView, page_offset: u32): u16;
|
|
100
|
+
/**
|
|
101
|
+
* @export_c
|
|
102
|
+
* Returns total free space on the page (contiguous + fragmented free_bytes).
|
|
103
|
+
*/
|
|
104
|
+
export declare function page_get_total_free_space(view: DataView, page_offset: u32): u16;
|
|
105
|
+
/**
|
|
106
|
+
* @export_c
|
|
107
|
+
* Defragments a slotted data page using a 4KB staging scratchpad.
|
|
108
|
+
* Collapses fragmented holes to the bottom, rewrites slot directory entries,
|
|
109
|
+
* and sets free_bytes to 0.
|
|
110
|
+
*/
|
|
111
|
+
export declare function page_compact(view: DataView, page_offset: u32, scratchpad_offset?: u32, replacement?: {
|
|
112
|
+
cell_idx: number;
|
|
113
|
+
row_bytes: Uint8Array;
|
|
114
|
+
}): void;
|
|
115
|
+
/**
|
|
116
|
+
* @export_c
|
|
117
|
+
* Calculates row length in bytes from the serialized row at row_offset.
|
|
118
|
+
*/
|
|
119
|
+
export declare function page_get_row_length(view: DataView, row_abs_offset: u32): u16;
|
|
120
|
+
/**
|
|
121
|
+
* Inserts a serialized row record into a slotted data page.
|
|
122
|
+
* Returns the slot index (0-indexed) or -1 if the row cannot fit in this page.
|
|
123
|
+
*/
|
|
124
|
+
export declare function page_insert_row(view: DataView, page_offset: number, row_bytes: Uint8Array, scratchpad_offset?: number): number;
|
|
125
|
+
/**
|
|
126
|
+
* @export_c
|
|
127
|
+
* Deletes a row from a slotted data page.
|
|
128
|
+
* Shifts subsequent slot directory entries left by 2 bytes (memmove) and increments free_bytes.
|
|
129
|
+
*/
|
|
130
|
+
export declare function page_delete_row(view: DataView, page_offset: u32, cell_idx: u16): void;
|
|
131
|
+
/**
|
|
132
|
+
* Updates an existing row in a slotted data page following the 3 scenarios in §4.5.
|
|
133
|
+
* Returns true if update succeeded on this page, or false if it exceeded page capacity (Scenario C).
|
|
134
|
+
*/
|
|
135
|
+
export declare function page_update_row(view: DataView, page_offset: number, cell_idx: number, new_row_bytes: Uint8Array, scratchpad_offset?: number): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Calculates null-bitmap bytes, fixed slice size, and variable column count for row layout.
|
|
138
|
+
*/
|
|
139
|
+
export declare function page_get_table_layout(table_or_columns: TableMeta | ColumnMeta[]): {
|
|
140
|
+
null_bitmap_bytes: number;
|
|
141
|
+
fixed_slice_size: number;
|
|
142
|
+
var_col_count: number;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Serializes a user row into WebDB Phase 1 binary format:
|
|
146
|
+
*
|
|
147
|
+
* [0]: Flags (1B: 0x01 = Active)
|
|
148
|
+
* [1..2]: Row _length (2B uint16 LE)
|
|
149
|
+
* [3..(3 + null_bitmap_bytes - 1)]: _null-_bitmap (ceil(N/8) bytes)
|
|
150
|
+
* Followed by: Fixed Slice (INT32 4B, INT64 8B, FLOAT64 8B, UUID 16B, ULID 16B)
|
|
151
|
+
* Followed by: Var-_offset Table (4B per TEXT/BLOB column: 2B rel_offset, 2B length)
|
|
152
|
+
* Followed by: Var Payloads (raw UTF-8 string or binary bytes)
|
|
153
|
+
*
|
|
154
|
+
* Strict 2048-Byte boundary enforced.
|
|
155
|
+
*/
|
|
156
|
+
export declare function page_serialize_row(table_or_columns: TableMeta | ColumnMeta[], values: Record<string, DbValue>): Uint8Array;
|
|
157
|
+
/**
|
|
158
|
+
* Deserializes a row record from a DataView into a user-facing DbRow object.
|
|
159
|
+
*/
|
|
160
|
+
export declare function page_deserialize_row(arg1: TableMeta | ColumnMeta[] | DataView, arg2: DataView | number, arg3?: number | TableMeta | ColumnMeta[]): DbRow;
|
|
161
|
+
/**
|
|
162
|
+
* @export_c
|
|
163
|
+
* Initializes a Table Interior Page with right_child_page_id.
|
|
164
|
+
*/
|
|
165
|
+
export declare function page_init_interior(view: DataView, page_offset: u32, right_child_page_id?: u32): void;
|
|
166
|
+
/**
|
|
167
|
+
* @export_c
|
|
168
|
+
* Returns right child page ID of a Table Interior Page.
|
|
169
|
+
*/
|
|
170
|
+
export declare function page_get_right_child_page_id(view: DataView, page_offset: u32): u32;
|
|
171
|
+
/**
|
|
172
|
+
* @export_c
|
|
173
|
+
* Sets right child page ID of a Table Interior Page.
|
|
174
|
+
*/
|
|
175
|
+
export declare function page_set_right_child_page_id(view: DataView, page_offset: u32, right_child_page_id: u32): void;
|
|
176
|
+
/**
|
|
177
|
+
* @export_c
|
|
178
|
+
* Inserts a 12-byte routing cell into a Table Interior Page.
|
|
179
|
+
* Returns new cell count or -1 if page has reached max entries (291 entries).
|
|
180
|
+
*/
|
|
181
|
+
export declare function page_insert_interior_cell(view: DataView, page_offset: u32, child_page_id: u32, rowid: i64): i32;
|
|
182
|
+
/**
|
|
183
|
+
* @export_c
|
|
184
|
+
* Performs binary search on a Table Interior Page to route traversal for target_row_id.
|
|
185
|
+
* Returns the child_page_id to traverse.
|
|
186
|
+
*/
|
|
187
|
+
export declare function page_binary_search_interior(view: DataView, page_offset: u32, target_row_id: i64): u32;
|
|
188
|
+
/**
|
|
189
|
+
* Splits a Table Interior Page at median entry (index 145), promoting the median key.
|
|
190
|
+
*/
|
|
191
|
+
export declare function page_split_interior(view: DataView, page_offset: number, new_page_offset: number): {
|
|
192
|
+
median_rowid: bigint;
|
|
193
|
+
promoted_child_page_id: number;
|
|
194
|
+
right_child_page_id: number;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* @export_c
|
|
198
|
+
* Initializes a Secondary Index Leaf Page.
|
|
199
|
+
*/
|
|
200
|
+
export declare function page_init_index_leaf(view: DataView, page_offset: u32, next_page_id?: u32): void;
|
|
201
|
+
/**
|
|
202
|
+
* Compares two index keys according to SQLite 3VL collation order:
|
|
203
|
+
* NULL < -Infinity < Numbers < TEXT (UTF-8) < BLOB
|
|
204
|
+
*/
|
|
205
|
+
export declare function page_compare_index_keys(type_a: DataType, val_a: any, rowid_a: bigint, type_b: DataType, val_b: any, rowid_b: bigint): number;
|
|
206
|
+
/**
|
|
207
|
+
* Inserts a key and rowid into a Secondary Index Leaf Page, maintaining sorted slot directory.
|
|
208
|
+
*/
|
|
209
|
+
export declare function page_insert_index_leaf_cell(view: DataView, page_offset: number, key_type: DataType, key_value: any, rowid: bigint, scratchpad_offset?: number): number;
|
|
210
|
+
/**
|
|
211
|
+
* Deletes an entry at slot_idx from a Secondary Index Leaf Page.
|
|
212
|
+
*/
|
|
213
|
+
export declare function page_delete_index_leaf_cell(view: DataView, page_offset: number, slot_idx: number): void;
|
|
214
|
+
/**
|
|
215
|
+
* Binary searches an Index Leaf Page for target key and optional rowid.
|
|
216
|
+
*/
|
|
217
|
+
export declare function page_binary_search_index_leaf(view: DataView, page_offset: number, target_type: DataType, target_value: any, target_row_id?: bigint): {
|
|
218
|
+
found: boolean;
|
|
219
|
+
slot_idx: number;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Encodes a single column value to a byte array based on its DataType.
|
|
223
|
+
*/
|
|
224
|
+
export declare function serialize_single_key(type: DataType, val: any): Uint8Array;
|
|
225
|
+
/**
|
|
226
|
+
* Serializes a composite key tuple into a deterministic, comparable binary buffer.
|
|
227
|
+
*/
|
|
228
|
+
export declare function serialize_composite_key(columns: ColumnMeta[], col_indices: number[], col_count: number, row: DbRow): Uint8Array;
|
|
229
|
+
//# sourceMappingURL=page.c.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.c.d.ts","sourceRoot":"","sources":["../../../src/core/js/page.c.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,QAAQ,EAER,UAAU,EACV,SAAS,EACT,KAAK,EACL,OAAO,EAIR,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAU1D;;;;;;;;;;;GAWG;AAEH;;;GAGG;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AW,EAAE,MAAM,EACnB,WAAW,EAAE,QAAQ,EACrB,YAAY,EAAE,GAAG,EACjB,aAAa,CAAC,EAAE,MAAM,GACrB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAkEtC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,GAAG,UAAU,CAiCzE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,UAAU,EAAE,EACrB,WAAW,EAAE,MAAM,EAAE,EACrB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,KAAK,GACT,UAAU,CAuBZ"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @export_c
|
|
3
|
+
* Computes a 32-bit multiplicative integer hash for a page ID.
|
|
4
|
+
*
|
|
5
|
+
* @param page_id Positive 1-based page identifier
|
|
6
|
+
* @param mask Bitmask for power-of-two bucket count (bucketCount - 1)
|
|
7
|
+
* @returns Bucket index in range [0, mask]
|
|
8
|
+
*/
|
|
9
|
+
export declare function page_table_hash(page_id: number, mask: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* @export_c
|
|
12
|
+
* Probes the binary open-addressing hash table in shared memory for a page ID.
|
|
13
|
+
*
|
|
14
|
+
* Bucket Layout (8 bytes):
|
|
15
|
+
* - [0..3] uint32_t page_id (0 = empty)
|
|
16
|
+
* - [4..7] uint32_t slot_idx
|
|
17
|
+
*
|
|
18
|
+
* @param view Shared memory DataView
|
|
19
|
+
* @param base_offset Byte offset where the hash table begins
|
|
20
|
+
* @param bucket_count Total number of buckets (must be power of two)
|
|
21
|
+
* @param page_id Positive 1-based page identifier
|
|
22
|
+
* @returns Slot index if resident, or -1 if not found
|
|
23
|
+
*/
|
|
24
|
+
export declare function page_table_get(view: DataView, base_offset: number, bucket_count: number, page_id: number): number;
|
|
25
|
+
/**
|
|
26
|
+
* @export_c
|
|
27
|
+
* Inserts or updates a page_id -> slot_idx mapping in the binary hash table.
|
|
28
|
+
*
|
|
29
|
+
* @param view Shared memory DataView
|
|
30
|
+
* @param base_offset Byte offset where the hash table begins
|
|
31
|
+
* @param bucket_count Total number of buckets (must be power of two)
|
|
32
|
+
* @param page_id Positive 1-based page identifier
|
|
33
|
+
* @param slot_idx Buffer pool cache slot index
|
|
34
|
+
*/
|
|
35
|
+
export declare function page_table_set(view: DataView, base_offset: number, bucket_count: number, page_id: number, slot_idx: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* @export_c
|
|
38
|
+
* Removes a page_id mapping using backward shift deletion (Robin Hood style).
|
|
39
|
+
* This eliminates tombstones and guarantees linear probing chain continuity.
|
|
40
|
+
*
|
|
41
|
+
* @param view Shared memory DataView
|
|
42
|
+
* @param base_offset Byte offset where the hash table begins
|
|
43
|
+
* @param bucket_count Total number of buckets (must be power of two)
|
|
44
|
+
* @param page_id Positive 1-based page identifier
|
|
45
|
+
* @returns True if the page was found and removed, false otherwise
|
|
46
|
+
*/
|
|
47
|
+
export declare function page_table_delete(view: DataView, base_offset: number, bucket_count: number, page_id: number): boolean;
|
|
48
|
+
//# sourceMappingURL=page_table.c.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page_table.c.d.ts","sourceRoot":"","sources":["../../../src/core/js/page_table.c.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAGrE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,CAgBR;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,IAAI,CAeN;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GACd,OAAO,CAgDT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { VmStatus } from '../../types/index.ts';
|
|
2
|
+
import { VmCursor, VmContext, VmKeyInfo, VmSorter, VmSorterEntry, VmAggBucket, createVmContext, resetVmContext } from '../../shared/index.ts';
|
|
3
|
+
export * from './vm.helpers.c.ts';
|
|
4
|
+
export { createVmContext, resetVmContext };
|
|
5
|
+
export type { VmCursor, VmContext, VmKeyInfo, VmSorter, VmSorterEntry, VmAggBucket, };
|
|
6
|
+
/**
|
|
7
|
+
* Synchronous Bytecode VM execution step loop.
|
|
8
|
+
* Runs instructions until STATUS_DONE, STATUS_BUFFER_FULL, or an error.
|
|
9
|
+
*/
|
|
10
|
+
export declare function vm_step(ctx: VmContext, view: DataView, bytecode: Uint8Array): VmStatus;
|
|
11
|
+
//# sourceMappingURL=vm.c.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vm.c.d.ts","sourceRoot":"","sources":["../../../src/core/js/vm.c.ts"],"names":[],"mappings":"AAMA,OAAO,EAAU,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AAUlE,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,eAAe,EACf,cAAc,EACf,MAAM,uBAAuB,CAAC;AAoB/B,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC;AAC3C,YAAY,EACV,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,aAAa,EACb,WAAW,GACZ,CAAC;AAIF;;;GAGG;AACH,wBAAgB,OAAO,CACrB,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,UAAU,GACnB,QAAQ,CAirEV"}
|