Skip to content

Commit 68eed46

Browse files
authored
fix: made types exportable (#139)
* fix: made types exportable * fix: exported sahpool
1 parent 18f57d4 commit 68eed46

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

src/index.d.ts

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** Types of values that can be passed to/retrieved from SQLite. */
2-
declare type SqlValue =
2+
export type SqlValue =
33
| string
44
| number
55
| null
@@ -9,13 +9,13 @@ declare type SqlValue =
99
| ArrayBuffer;
1010

1111
/** A PreparedStatement or a WASM pointer to one. */
12-
declare type StmtPtr = PreparedStatement | WasmPointer;
12+
export type StmtPtr = PreparedStatement | WasmPointer;
1313

1414
/** A Database or a WASM pointer to one. */
15-
declare type DbPtr = Database | WasmPointer;
15+
export type DbPtr = Database | WasmPointer;
1616

1717
/** An integer result code from a SQLite C API call. */
18-
declare type Sqlite3Result =
18+
export type Sqlite3Result =
1919
| CAPI['SQLITE_OK']
2020
| CAPI['SQLITE_ERROR']
2121
| CAPI['SQLITE_INTERNAL']
@@ -122,31 +122,31 @@ declare type Sqlite3Result =
122122
| CAPI['SQLITE_OK_LOAD_PERMANENTLY'];
123123

124124
/** A destructor for a BLOB or TEXT binding. */
125-
declare type DtorType =
125+
export type DtorType =
126126
| (() => void)
127127
| WasmPointer
128128
| CAPI['SQLITE_STATIC']
129129
| CAPI['SQLITE_TRANSIENT']
130130
| CAPI['SQLITE_WASM_DEALLOC'];
131131

132132
/** Types of values that can be passed to SQLite. */
133-
declare type BindableValue =
133+
export type BindableValue =
134134
| SqlValue
135135
/** Converted to NULL */
136136
| undefined
137137
/** Converted to INTEGER */
138138
| boolean;
139139

140140
/** Internal data types supported by SQLite3. */
141-
declare type SQLiteDataType =
141+
export type SQLiteDataType =
142142
| CAPI['SQLITE_INTEGER']
143143
| CAPI['SQLITE_FLOAT']
144144
| CAPI['SQLITE_TEXT']
145145
| CAPI['SQLITE_BLOB']
146146
| CAPI['SQLITE_NULL'];
147147

148148
/** Specifies parameter bindings. */
149-
declare type BindingSpec =
149+
export type BindingSpec =
150150
| readonly BindableValue[]
151151
| { [paramName: string]: BindableValue }
152152
/** Assumed to have binding index `1` */
@@ -161,7 +161,7 @@ declare type BindingSpec =
161161
* which take filename strings, and similar "small" strings, do not use this
162162
* feature.
163163
*/
164-
declare type FlexibleString =
164+
export type FlexibleString =
165165
| string
166166
/** WASM C-string pointer, passed on to WASM as-is. */
167167
| WasmPointer
@@ -198,7 +198,7 @@ declare type FlexibleString =
198198
* stmt.finalize();
199199
* }
200200
*/
201-
declare class PreparedStatement {
201+
export class PreparedStatement {
202202
/** Binds one more values to its bindable parameters. */
203203
bind(binding: BindingSpec): this;
204204

@@ -424,7 +424,7 @@ declare class PreparedStatement {
424424
pointer: WasmPointer | undefined;
425425
}
426426

427-
declare type ExecOptions = {
427+
export type ExecOptions = {
428428
/**
429429
* The SQL to run (unless it's provided as the first argument). The SQL may
430430
* contain any number of statements.
@@ -533,42 +533,42 @@ declare type ExecOptions = {
533533
* Derivate type of ExecOptions to be used as base mixin for method overloads on
534534
* `exec`
535535
*/
536-
declare type ExecBaseOptions = Omit<
536+
export type ExecBaseOptions = Omit<
537537
ExecOptions,
538538
'callback' | 'resultRows' | 'rowMode' | 'returnValue' | 'sql'
539539
>;
540540

541-
declare type ExecReturnThisOptions = {
541+
export type ExecReturnThisOptions = {
542542
returnValue?: 'this';
543543
};
544544

545-
declare type ExecReturnResultRowsOptions = {
545+
export type ExecReturnResultRowsOptions = {
546546
returnValue: 'resultRows';
547547
};
548548

549-
declare type ExecReturnSaveSqlOptions = {
549+
export type ExecReturnSaveSqlOptions = {
550550
returnValue: 'saveSql';
551551
};
552552

553-
declare type ExecRowModeArrayOptions = {
553+
export type ExecRowModeArrayOptions = {
554554
callback?: (row: SqlValue[]) => void | false;
555555
resultRows?: SqlValue[][];
556556
rowMode?: 'array';
557557
};
558558

559-
declare type ExecRowModeObjectOptions = {
559+
export type ExecRowModeObjectOptions = {
560560
callback?: (row: { [columnName: string]: SqlValue }) => void | false;
561561
resultRows?: { [columnName: string]: SqlValue }[];
562562
rowMode: 'object';
563563
};
564564

565-
declare type ExecRowModeStmtOptions = {
565+
export type ExecRowModeStmtOptions = {
566566
callback?: (row: PreparedStatement) => void | false;
567567
resultRows?: undefined;
568568
rowMode: 'stmt';
569569
};
570570

571-
declare type ExecRowModeScalarOptions = {
571+
export type ExecRowModeScalarOptions = {
572572
callback?: (row: SqlValue) => void | false;
573573
resultRows?: SqlValue[];
574574

@@ -587,7 +587,7 @@ declare type ExecRowModeScalarOptions = {
587587
};
588588

589589
/** Options for creating a user-defined function that can be called from SQL. */
590-
declare type FunctionOptions = {
590+
export type FunctionOptions = {
591591
/**
592592
* Number of arguments which SQL calls to this function expect or require. The
593593
* default value is `X.length` MINUS 1, where X is either `xFunc` or `xStep`,
@@ -676,12 +676,12 @@ declare type FunctionOptions = {
676676
xDestroy?: (pAppPtr: WasmPointer) => void;
677677
};
678678

679-
declare type ScalarFunctionOptions = FunctionOptions & {
679+
export type ScalarFunctionOptions = FunctionOptions & {
680680
/** Scalar function to be defined. */
681681
xFunc: (ctxPtr: number, ...args: SqlValue[]) => SqlValue;
682682
};
683683

684-
declare type AggregateFunctionOptions = FunctionOptions & {
684+
export type AggregateFunctionOptions = FunctionOptions & {
685685
/**
686686
* 'Step' callback for an aggregate function.
687687
*
@@ -701,7 +701,7 @@ declare type AggregateFunctionOptions = FunctionOptions & {
701701
xFinal: (ctxPtr: number) => SqlValue;
702702
};
703703

704-
declare type WindowFunctionOptions = FunctionOptions & {
704+
export type WindowFunctionOptions = FunctionOptions & {
705705
/**
706706
* 'Step' callback for a window function.
707707
*
@@ -756,7 +756,7 @@ declare type WindowFunctionOptions = FunctionOptions & {
756756
* }
757757
* ```;
758758
*/
759-
declare class Database {
759+
export class Database {
760760
/**
761761
* Creates a connection to the given file, optionally creating it if needed.
762762
*
@@ -1287,7 +1287,7 @@ declare class Database {
12871287
* When the sqlite3 API is installed in the main thread, the class is added,
12881288
* which simplifies usage of the kvvfs.
12891289
*/
1290-
declare class JsStorageDb extends Database {
1290+
export class JsStorageDb extends Database {
12911291
/** Create a new kvvfs-backed database in local or session storage. */
12921292
constructor(options?: { filename?: 'local' | 'session'; flags?: string });
12931293
constructor(mode: 'local' | 'session');
@@ -1355,7 +1355,7 @@ declare class JsStorageDb extends Database {
13551355
*
13561356
* How to emit those headers depends on the underlying web server.
13571357
*/
1358-
declare class OpfsDatabase extends Database {
1358+
export class OpfsDatabase extends Database {
13591359
/**
13601360
* Creates a connection to the given file, optionally creating it if needed.
13611361
*
@@ -1395,11 +1395,11 @@ declare class OpfsDatabase extends Database {
13951395
): Promise<number>;
13961396
}
13971397

1398-
declare class OpfsSAHPoolDatabase extends OpfsDatabase {
1398+
export class OpfsSAHPoolDatabase extends OpfsDatabase {
13991399
constructor(filename: string);
14001400
}
14011401

1402-
type SAHPoolUtil = {
1402+
export type SAHPoolUtil = {
14031403
OpfsSAHPoolDb: typeof OpfsSAHPoolDatabase;
14041404

14051405
/**
@@ -1556,23 +1556,23 @@ type SAHPoolUtil = {
15561556
};
15571557

15581558
/** Exception class for reporting WASM-side allocation errors. */
1559-
declare class WasmAllocError extends Error {
1559+
export class WasmAllocError extends Error {
15601560
constructor(message: string);
15611561
toss: any;
15621562
}
15631563

15641564
/** Exception class used primarily by the oo1 API. */
1565-
declare class SQLite3Error extends Error {
1565+
export class SQLite3Error extends Error {
15661566
constructor(message: string);
15671567
resultCode: number;
15681568
}
15691569

15701570
/** A pointer to a location in WASM heap memory. */
1571-
declare type WasmPointer = number;
1571+
export type WasmPointer = number;
15721572

1573-
declare type NullPointer = 0 | null | undefined;
1573+
export type NullPointer = 0 | null | undefined;
15741574

1575-
declare type StructPtrMapper<T> = {
1575+
export type StructPtrMapper<T> = {
15761576
StructType: T;
15771577
/**
15781578
* Creates a new StructType object, writes its `pointer` value to the given
@@ -1625,7 +1625,7 @@ declare type StructPtrMapper<T> = {
16251625
dispose: (ptr: WasmPointer) => void;
16261626
};
16271627

1628-
declare class SQLiteStruct {
1628+
export class SQLiteStruct {
16291629
/**
16301630
* Calling a constructor with no arguments creates a new instance in the WASM
16311631
* heap in order to connect it to C. In this case, client JavaScript code owns
@@ -1789,7 +1789,7 @@ declare class SQLiteStruct {
17891789
): this;
17901790
}
17911791

1792-
declare class sqlite3_vfs extends SQLiteStruct {
1792+
export class sqlite3_vfs extends SQLiteStruct {
17931793
$iVersion: number;
17941794
$szOsFile: number;
17951795
$mxPathname: number;
@@ -1855,7 +1855,7 @@ declare class sqlite3_vfs extends SQLiteStruct {
18551855
xNextSystemCall: (vfsPtr: WasmPointer, zName: WasmPointer) => WasmPointer;
18561856
}
18571857

1858-
declare class sqlite3_io_methods extends SQLiteStruct {
1858+
export class sqlite3_io_methods extends SQLiteStruct {
18591859
iVersion: number;
18601860

18611861
constructor(pointer?: WasmPointer);
@@ -1912,7 +1912,7 @@ declare class sqlite3_io_methods extends SQLiteStruct {
19121912
xUnfetch: (file: WasmPointer, iOfst: number, p: WasmPointer) => Sqlite3Result;
19131913
}
19141914

1915-
declare class sqlite3_file extends SQLiteStruct {
1915+
export class sqlite3_file extends SQLiteStruct {
19161916
$pMethods: WasmPointer;
19171917
structInfo: {
19181918
sizeof: number;
@@ -1931,21 +1931,21 @@ declare class sqlite3_file extends SQLiteStruct {
19311931
constructor(pointer?: WasmPointer);
19321932
}
19331933

1934-
declare class sqlite3_vtab extends SQLiteStruct {
1934+
export class sqlite3_vtab extends SQLiteStruct {
19351935
pModule: WasmPointer;
19361936
nRef: number;
19371937
zErrMsg: WasmPointer;
19381938

19391939
constructor(pointer?: WasmPointer);
19401940
}
19411941

1942-
declare class sqlite3_vtab_cursor extends SQLiteStruct {
1942+
export class sqlite3_vtab_cursor extends SQLiteStruct {
19431943
pVtab: WasmPointer;
19441944

19451945
constructor(pointer?: WasmPointer);
19461946
}
19471947

1948-
declare class sqlite3_module extends SQLiteStruct {
1948+
export class sqlite3_module extends SQLiteStruct {
19491949
iVersion: number;
19501950

19511951
constructor(pointer?: WasmPointer);
@@ -2014,7 +2014,7 @@ declare class sqlite3_module extends SQLiteStruct {
20142014
xShadowName: (tableName: WasmPointer) => Sqlite3Result;
20152015
}
20162016

2017-
declare class sqlite3_index_constraint extends SQLiteStruct {
2017+
export class sqlite3_index_constraint extends SQLiteStruct {
20182018
iColumn: number;
20192019
op: number;
20202020
usable: number;
@@ -2023,21 +2023,21 @@ declare class sqlite3_index_constraint extends SQLiteStruct {
20232023
constructor(pointer?: WasmPointer);
20242024
}
20252025

2026-
declare class sqlite3_index_constraint_usage extends SQLiteStruct {
2026+
export class sqlite3_index_constraint_usage extends SQLiteStruct {
20272027
argvIndex: number;
20282028
omit: number;
20292029

20302030
constructor(pointer?: WasmPointer);
20312031
}
20322032

2033-
declare class sqlite3_index_orderby extends SQLiteStruct {
2033+
export class sqlite3_index_orderby extends SQLiteStruct {
20342034
iColumn: number;
20352035
desc: number;
20362036

20372037
constructor(pointer?: WasmPointer);
20382038
}
20392039

2040-
declare class sqlite3_index_info extends SQLiteStruct {
2040+
export class sqlite3_index_info extends SQLiteStruct {
20412041
nConstraint: number;
20422042
aConstraint: WasmPointer;
20432043
nOrderBy: number;
@@ -2058,7 +2058,7 @@ declare class sqlite3_index_info extends SQLiteStruct {
20582058
constructor(pointer?: WasmPointer);
20592059
}
20602060

2061-
declare type Sqlite3Static = {
2061+
export type Sqlite3Static = {
20622062
/** The namespace for the C-style APIs. */
20632063
capi: CAPI;
20642064

@@ -2406,12 +2406,12 @@ declare type Sqlite3Static = {
24062406
*/
24072407
export default function init(): Promise<Sqlite3Static>;
24082408

2409-
declare type ListLike<T> = {
2409+
export type ListLike<T> = {
24102410
length: number;
24112411
forEach: (cb: (val: T) => void) => void;
24122412
};
24132413

2414-
declare type WASM_API = {
2414+
export type WASM_API = {
24152415
/**
24162416
* The `sqlite3.wasm.exports` namespace object is a WASM-standard part of the
24172417
* WASM module file and contains all "exported" C functions which are built
@@ -3539,7 +3539,7 @@ declare type WASM_API = {
35393539
};
35403540

35413541
// generated by Object.keys(sqlite3.capi).map(k => `${k}: any;`).join('\n')
3542-
declare type CAPI = {
3542+
export type CAPI = {
35433543
sqlite3_vfs: typeof sqlite3_vfs;
35443544
sqlite3_io_methods: typeof sqlite3_io_methods;
35453545
sqlite3_file: typeof sqlite3_file;

0 commit comments

Comments
 (0)