firebird-wasm 0.1.1 → 0.3.0
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/CHANGELOG.md +203 -0
- package/README.md +4 -1
- package/dist/.tsbuildinfo.build +1 -1
- package/dist/browser/engine-transport.d.ts +56 -5
- package/dist/browser/engine-transport.d.ts.map +1 -1
- package/dist/browser/engine-transport.js +271 -8
- package/dist/browser/engine-transport.js.map +1 -1
- package/dist/browser/firebird-browser.d.ts +282 -9
- package/dist/browser/firebird-browser.d.ts.map +1 -1
- package/dist/browser/firebird-browser.js +435 -42
- package/dist/browser/firebird-browser.js.map +1 -1
- package/dist/browser/index.d.ts +12 -2
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +23 -3
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/leader-election.d.ts +55 -0
- package/dist/browser/leader-election.d.ts.map +1 -0
- package/dist/browser/leader-election.js +64 -0
- package/dist/browser/leader-election.js.map +1 -0
- package/dist/browser/opfs-fs.d.ts +72 -0
- package/dist/browser/opfs-fs.d.ts.map +1 -0
- package/dist/browser/opfs-fs.js +249 -0
- package/dist/browser/opfs-fs.js.map +1 -0
- package/dist/browser/shared-transport.d.ts +134 -0
- package/dist/browser/shared-transport.d.ts.map +1 -0
- package/dist/browser/shared-transport.js +366 -0
- package/dist/browser/shared-transport.js.map +1 -0
- package/dist/browser/statement-types.d.ts +18 -0
- package/dist/browser/statement-types.d.ts.map +1 -0
- package/dist/browser/statement-types.js +39 -0
- package/dist/browser/statement-types.js.map +1 -0
- package/dist/browser/value-types.d.ts +173 -0
- package/dist/browser/value-types.d.ts.map +1 -0
- package/dist/browser/value-types.js +222 -0
- package/dist/browser/value-types.js.map +1 -0
- package/dist/browser/worker-entry.d.ts.map +1 -1
- package/dist/browser/worker-entry.js +38 -1
- package/dist/browser/worker-entry.js.map +1 -1
- package/dist/browser/worker-protocol.d.ts +1 -1
- package/dist/browser/worker-protocol.d.ts.map +1 -1
- package/dist/browser/worker-transport.d.ts +8 -2
- package/dist/browser/worker-transport.d.ts.map +1 -1
- package/dist/browser/worker-transport.js +26 -2
- package/dist/browser/worker-transport.js.map +1 -1
- package/dist/firebird.d.ts +58 -5
- package/dist/firebird.d.ts.map +1 -1
- package/dist/firebird.js +161 -52
- package/dist/firebird.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/sql-tag.d.ts +184 -0
- package/dist/sql-tag.d.ts.map +1 -0
- package/dist/sql-tag.js +287 -0
- package/dist/sql-tag.js.map +1 -0
- package/dist/statement-types.d.ts +23 -0
- package/dist/statement-types.d.ts.map +1 -0
- package/dist/statement-types.js +44 -0
- package/dist/statement-types.js.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/wasm/firebird-embedded.js +1 -1
- package/dist/wasm/firebird-embedded.wasm +0 -0
- package/dist/wasm-loader.d.ts +38 -2
- package/dist/wasm-loader.d.ts.map +1 -1
- package/dist/wasm-loader.js.map +1 -1
- package/package.json +3 -2
|
@@ -23,7 +23,79 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import type { IndexedDBVFSOptions } from './indexeddb-vfs';
|
|
25
25
|
import type { EngineHandle, EngineTransport } from './engine-transport';
|
|
26
|
-
import type {
|
|
26
|
+
import type { TypeOptions } from './value-types';
|
|
27
|
+
import type { SqlFragment } from '../sql-tag';
|
|
28
|
+
import type { ArrayRow, QueryResult, QueryDescription, QueryOptions, Row, QueryParams, RowMode, TransactionOptions } from '../types';
|
|
29
|
+
/** `QueryOptions` with the array mode pinned, for the overloads below. */
|
|
30
|
+
type ArrayModeOptions = QueryOptions & {
|
|
31
|
+
rowMode: 'array';
|
|
32
|
+
};
|
|
33
|
+
/** A running subscription. Returned by {@link FirebirdBrowser.listen}. */
|
|
34
|
+
export interface EventSubscription {
|
|
35
|
+
/** Stop listening and release the subscription. Safe to call twice. */
|
|
36
|
+
unsubscribe(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
/** Options for {@link FirebirdBrowser.listen}. */
|
|
39
|
+
export interface ListenOptions {
|
|
40
|
+
/**
|
|
41
|
+
* How often to ask the engine whether anything fired, in milliseconds.
|
|
42
|
+
*
|
|
43
|
+
* This is a poll because the engine's callback runs on an engine thread and
|
|
44
|
+
* re-arming has to happen off it — see `fb_events_poll`. The cost of a tick
|
|
45
|
+
* that finds nothing is one round trip to the Worker.
|
|
46
|
+
*
|
|
47
|
+
* @default 250
|
|
48
|
+
*/
|
|
49
|
+
pollIntervalMs?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Called when a poll or a handler throws.
|
|
52
|
+
*
|
|
53
|
+
* A subscription outlives the call that created it, so an error has nowhere
|
|
54
|
+
* else to go. Defaults to `console.error`; polling continues, because one
|
|
55
|
+
* failure does not mean the next will fail.
|
|
56
|
+
*/
|
|
57
|
+
onError?: (error: Error) => void;
|
|
58
|
+
}
|
|
59
|
+
/** Options for {@link FirebirdBrowser.live}. */
|
|
60
|
+
export interface LiveQueryOptions {
|
|
61
|
+
/**
|
|
62
|
+
* Event names to watch, as posted by `POST_EVENT`.
|
|
63
|
+
*
|
|
64
|
+
* Required, and deliberately not inferred from the statement. Firebird
|
|
65
|
+
* delivers events a trigger chose to post; nothing connects them to the
|
|
66
|
+
* tables a query reads, so guessing which events matter would be guessing.
|
|
67
|
+
*/
|
|
68
|
+
events: string[];
|
|
69
|
+
/** Parameters for the statement, as `query()` takes them. */
|
|
70
|
+
params?: QueryParams;
|
|
71
|
+
/**
|
|
72
|
+
* How often to ask the engine whether anything fired, in milliseconds.
|
|
73
|
+
*
|
|
74
|
+
* This is a poll because the engine's callback runs on an engine thread and
|
|
75
|
+
* re-arming has to happen off it — see `fb_events_poll`. The cost of a tick
|
|
76
|
+
* that finds nothing is one round trip to the Worker.
|
|
77
|
+
*
|
|
78
|
+
* @default 250
|
|
79
|
+
*/
|
|
80
|
+
pollIntervalMs?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Called when a refresh fails.
|
|
83
|
+
*
|
|
84
|
+
* A live query outlives the call that created it, so an error has nowhere
|
|
85
|
+
* else to go. Defaults to `console.error`; polling continues, because one
|
|
86
|
+
* failed refresh — a lock conflict, say — does not mean the next will fail.
|
|
87
|
+
*/
|
|
88
|
+
onError?: (error: Error) => void;
|
|
89
|
+
}
|
|
90
|
+
/** A running live query. Returned by {@link FirebirdBrowser.live}. */
|
|
91
|
+
export interface LiveQuery<T> {
|
|
92
|
+
/** The most recent rows. Replaced, not mutated, on each refresh. */
|
|
93
|
+
readonly rows: T[];
|
|
94
|
+
/** Re-run the statement now, without waiting for an event. */
|
|
95
|
+
refresh(): Promise<void>;
|
|
96
|
+
/** Stop watching and release the subscription. Safe to call twice. */
|
|
97
|
+
unsubscribe(): Promise<void>;
|
|
98
|
+
}
|
|
27
99
|
/** What a statement did. Returned by `exec()`. */
|
|
28
100
|
export interface ExecResult {
|
|
29
101
|
/** Rows affected — for INSERT, UPDATE and DELETE. 0 for DDL. */
|
|
@@ -53,8 +125,12 @@ export interface FirebirdBrowserOptions {
|
|
|
53
125
|
*
|
|
54
126
|
* Omit it only where blocking the calling thread is acceptable, such as
|
|
55
127
|
* Node or a test harness driving a stub engine.
|
|
128
|
+
*
|
|
129
|
+
* With `multiTab: 'shared'` this must be a **factory**. It is called only
|
|
130
|
+
* if this tab wins the election, so a follower never downloads and
|
|
131
|
+
* instantiates a 9 MB engine to sit idle beside the one already running.
|
|
56
132
|
*/
|
|
57
|
-
worker?: Worker;
|
|
133
|
+
worker?: Worker | (() => Worker);
|
|
58
134
|
/**
|
|
59
135
|
* Use a transport of your own. Takes precedence over `worker`; mainly a
|
|
60
136
|
* seam for tests.
|
|
@@ -97,12 +173,16 @@ export interface FirebirdBrowserOptions {
|
|
|
97
173
|
*
|
|
98
174
|
* - `'exclusive'` (default) takes a cross-tab lock and fails with
|
|
99
175
|
* {@link DatabaseLockedError} if another tab will not release it in time.
|
|
176
|
+
* - `'shared'` elects one tab to run the engine and serves the others from
|
|
177
|
+
* it, so every tab sees the same live database. Needs `worker` to be a
|
|
178
|
+
* factory rather than an instance — a follower must not build an engine it
|
|
179
|
+
* will never use.
|
|
100
180
|
* - `'allow-unsafe'` skips the lock. Only sound when at most one of the
|
|
101
181
|
* tabs writes.
|
|
102
182
|
*
|
|
103
183
|
* @default 'exclusive'
|
|
104
184
|
*/
|
|
105
|
-
multiTab?: 'exclusive' | 'allow-unsafe';
|
|
185
|
+
multiTab?: 'exclusive' | 'shared' | 'allow-unsafe';
|
|
106
186
|
/**
|
|
107
187
|
* How long to wait for another tab to release the database, in
|
|
108
188
|
* milliseconds. `Infinity` waits indefinitely.
|
|
@@ -110,6 +190,33 @@ export interface FirebirdBrowserOptions {
|
|
|
110
190
|
* @default 5000
|
|
111
191
|
*/
|
|
112
192
|
lockTimeoutMs?: number;
|
|
193
|
+
/**
|
|
194
|
+
* Convert result values to richer JavaScript types.
|
|
195
|
+
*
|
|
196
|
+
* Off by default: every conversion trades something away, and values as
|
|
197
|
+
* returned today are correct, just awkward. See {@link TypeOptions} for what
|
|
198
|
+
* each one costs — `dates` in particular loses precision and has to choose a
|
|
199
|
+
* time zone Firebird did not store.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* new FirebirdBrowser('mydb', { worker, types: { bigint: true, binary: true } })
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
types?: TypeOptions;
|
|
207
|
+
/**
|
|
208
|
+
* Initial contents for the database, as the bytes {@link
|
|
209
|
+
* FirebirdBrowser.dumpDataDir} produced.
|
|
210
|
+
*
|
|
211
|
+
* Used **only when there is no database yet** — a stored one always wins.
|
|
212
|
+
* That is deliberate and is the difference between seeding and destroying:
|
|
213
|
+
* an application passes this on every load, so a seed that replaced what was
|
|
214
|
+
* there would reset the user's data to the snapshot on every page reload.
|
|
215
|
+
*
|
|
216
|
+
* To load a snapshot regardless of what is stored, open it as an ephemeral
|
|
217
|
+
* database: `new FirebirdBrowser('memory://', { loadDataDir: bytes })`.
|
|
218
|
+
*/
|
|
219
|
+
loadDataDir?: Uint8Array;
|
|
113
220
|
}
|
|
114
221
|
/**
|
|
115
222
|
* Browser-side Firebird database backed by WASM + IndexedDB.
|
|
@@ -119,6 +226,21 @@ export interface FirebirdBrowserOptions {
|
|
|
119
226
|
*/
|
|
120
227
|
export declare class FirebirdBrowser {
|
|
121
228
|
private readonly dbName;
|
|
229
|
+
/** True for a `memory://` database: never stored, discarded on close. */
|
|
230
|
+
private readonly ephemeral;
|
|
231
|
+
/** True for an `opfs://` database: the engine writes its pages straight to a file. */
|
|
232
|
+
private readonly opfs;
|
|
233
|
+
/** Path the engine opens. Set by the OPFS mount, which chooses it. */
|
|
234
|
+
private opfsPath;
|
|
235
|
+
/**
|
|
236
|
+
* Name of the file inside the engine's own filesystem.
|
|
237
|
+
*
|
|
238
|
+
* The same as `dbName` for a stored database. For an ephemeral one it is
|
|
239
|
+
* made unique per instance, so two `memory://` databases in one page cannot
|
|
240
|
+
* land on the same path — the WASM module, and therefore its filesystem, is
|
|
241
|
+
* shared by every instance in a tab.
|
|
242
|
+
*/
|
|
243
|
+
private readonly fileName;
|
|
122
244
|
private readonly options;
|
|
123
245
|
private readonly vfs;
|
|
124
246
|
private readonly engine;
|
|
@@ -138,14 +260,38 @@ export declare class FirebirdBrowser {
|
|
|
138
260
|
private readonly lockTimeoutMs;
|
|
139
261
|
/** Held for the connection's lifetime; released by close(). */
|
|
140
262
|
private lock;
|
|
263
|
+
/** Live queries to tear down with the connection. */
|
|
264
|
+
private readonly liveQueries;
|
|
265
|
+
/** Set only in shared mode; owns the election and the channel. */
|
|
266
|
+
private shared;
|
|
141
267
|
/**
|
|
142
268
|
* @param dbName Logical database name. Used as the IndexedDB store name
|
|
143
269
|
* and the filename inside Emscripten's virtual FS.
|
|
144
270
|
* @param options Optional configuration.
|
|
145
271
|
*/
|
|
146
272
|
constructor(dbName: string, options?: FirebirdBrowserOptions);
|
|
273
|
+
/** Build the real engine for this tab: a Worker if given one, else direct. */
|
|
274
|
+
private createLocalEngine;
|
|
275
|
+
private createEngine;
|
|
276
|
+
/**
|
|
277
|
+
* Whether this tab is the one actually running the engine.
|
|
278
|
+
*
|
|
279
|
+
* Always true unless `multiTab: 'shared'`, where exactly one tab owns the
|
|
280
|
+
* engine and the rest are served by it. Useful for deciding which tab should
|
|
281
|
+
* do work that must happen once — an import, a migration, a scheduled
|
|
282
|
+
* cleanup — rather than once per open tab.
|
|
283
|
+
*/
|
|
284
|
+
get isLeader(): boolean;
|
|
147
285
|
/** Path of the database inside Emscripten's filesystem. */
|
|
148
286
|
private get dbPath();
|
|
287
|
+
/**
|
|
288
|
+
* Run any configured serializers over outgoing parameters.
|
|
289
|
+
*
|
|
290
|
+
* Here rather than in the encoder because the encoder may be on the far side
|
|
291
|
+
* of a Worker, where the serializer functions cannot follow — see
|
|
292
|
+
* {@link applySerializers}.
|
|
293
|
+
*/
|
|
294
|
+
private serialize;
|
|
149
295
|
/**
|
|
150
296
|
* Execute one or more statements that do not return rows.
|
|
151
297
|
*
|
|
@@ -162,17 +308,90 @@ export declare class FirebirdBrowser {
|
|
|
162
308
|
*
|
|
163
309
|
* @returns one result per statement, in order.
|
|
164
310
|
*/
|
|
165
|
-
exec(sql: string, params?: QueryParams): Promise<ExecResult[]>;
|
|
311
|
+
exec(sql: string | SqlFragment, params?: QueryParams): Promise<ExecResult[]>;
|
|
166
312
|
/**
|
|
167
313
|
* Execute a SQL query and return the result rows.
|
|
168
314
|
*
|
|
169
|
-
* Parameters are bound with `?` placeholders, as in the Node.js backend
|
|
315
|
+
* Parameters are bound with `?` placeholders, as in the Node.js backend, or
|
|
316
|
+
* interpolated into a `` sql`…` `` fragment:
|
|
170
317
|
*
|
|
171
318
|
* ```ts
|
|
172
319
|
* await db.query('SELECT * FROM items WHERE id = ?', [1]);
|
|
320
|
+
* await db.query(sql`SELECT * FROM items WHERE id = ${1}`);
|
|
173
321
|
* ```
|
|
174
322
|
*/
|
|
175
|
-
query
|
|
323
|
+
query(sql: SqlFragment, options: ArrayModeOptions): Promise<QueryResult<ArrayRow>>;
|
|
324
|
+
query(sql: string | SqlFragment, params: QueryParams | undefined, options: ArrayModeOptions): Promise<QueryResult<ArrayRow>>;
|
|
325
|
+
query<T extends Row = Row>(sql: SqlFragment, options?: QueryOptions): Promise<QueryResult<T>>;
|
|
326
|
+
query<T extends Row = Row>(sql: string, params?: QueryParams, options?: QueryOptions): Promise<QueryResult<T>>;
|
|
327
|
+
query<T extends Row = Row>(sql: string | SqlFragment, params?: QueryParams, options?: QueryOptions): Promise<QueryResult<T>>;
|
|
328
|
+
/**
|
|
329
|
+
* Re-run a query whenever named events fire.
|
|
330
|
+
*
|
|
331
|
+
* ```ts
|
|
332
|
+
* // A trigger does the posting:
|
|
333
|
+
* // CREATE TRIGGER items_ai FOR items AFTER INSERT
|
|
334
|
+
* // AS BEGIN POST_EVENT 'items_changed'; END
|
|
335
|
+
*
|
|
336
|
+
* const live = await db.live(
|
|
337
|
+
* 'SELECT id, name FROM items ORDER BY id',
|
|
338
|
+
* { events: ['items_changed'] },
|
|
339
|
+
* (rows) => render(rows),
|
|
340
|
+
* );
|
|
341
|
+
* // …later
|
|
342
|
+
* await live.unsubscribe();
|
|
343
|
+
* ```
|
|
344
|
+
*
|
|
345
|
+
* `onChange` is called once immediately with the current rows, so it is the
|
|
346
|
+
* only place results need handling — there is no separate "initial value" to
|
|
347
|
+
* deal with differently.
|
|
348
|
+
*
|
|
349
|
+
* Firebird delivers events **after the posting transaction commits**, so a
|
|
350
|
+
* refresh only ever sees data that survived. That is worth more than
|
|
351
|
+
* immediacy: a live query that showed uncommitted rows would show rows that
|
|
352
|
+
* can vanish.
|
|
353
|
+
*
|
|
354
|
+
* The event names are the caller's to supply. Nothing in Firebird connects a
|
|
355
|
+
* posted event to the tables a statement reads, so inferring them would be
|
|
356
|
+
* guesswork dressed as convenience.
|
|
357
|
+
*/
|
|
358
|
+
listen(names: string | string[], onEvent: (counts: Record<string, number>) => void, options?: ListenOptions): Promise<EventSubscription>;
|
|
359
|
+
/**
|
|
360
|
+
* Post an event, without writing a trigger to do it.
|
|
361
|
+
*
|
|
362
|
+
* ```ts
|
|
363
|
+
* await db.notify('items_changed');
|
|
364
|
+
* ```
|
|
365
|
+
*
|
|
366
|
+
* The event is delivered **after the transaction posting it commits**, which
|
|
367
|
+
* here is the statement's own auto-commit — so listeners hear about it only
|
|
368
|
+
* once it has actually happened.
|
|
369
|
+
*
|
|
370
|
+
* A trigger remains the better place for anything tied to data changing:
|
|
371
|
+
* `POST_EVENT` in an `AFTER INSERT` fires however the row arrived, including
|
|
372
|
+
* from another connection, while this fires only where it is called.
|
|
373
|
+
*/
|
|
374
|
+
notify(name: string): Promise<void>;
|
|
375
|
+
live<T extends Row = Row>(sql: string | SqlFragment, options: LiveQueryOptions, onChange: (rows: T[], result: QueryResult<T>) => void): Promise<LiveQuery<T>>;
|
|
376
|
+
/**
|
|
377
|
+
* Describe a statement's shape without running it.
|
|
378
|
+
*
|
|
379
|
+
* ```ts
|
|
380
|
+
* const shape = await db.describeQuery('SELECT id, name FROM items WHERE id = ?');
|
|
381
|
+
* // shape.params → [{ type: 496, typeName: 'INTEGER', … }]
|
|
382
|
+
* // shape.fields → [{ name: 'ID', … }, { name: 'NAME', … }]
|
|
383
|
+
* // shape.statementType → 'SELECT'
|
|
384
|
+
* ```
|
|
385
|
+
*
|
|
386
|
+
* The statement is prepared and dropped, so nothing happens: describing an
|
|
387
|
+
* `INSERT` inserts nothing. Preparing is not free — the engine parses and
|
|
388
|
+
* plans — but it is the only way to learn a shape, and the alternative,
|
|
389
|
+
* running the statement to see what comes back, is not one.
|
|
390
|
+
*
|
|
391
|
+
* A `` sql`…` `` fragment is accepted and its values ignored; only the text
|
|
392
|
+
* decides the shape, and a fragment is often what a caller has to hand.
|
|
393
|
+
*/
|
|
394
|
+
describeQuery(sql: string | SqlFragment): Promise<QueryDescription>;
|
|
176
395
|
/**
|
|
177
396
|
* Run a function inside an explicit transaction.
|
|
178
397
|
*/
|
|
@@ -181,6 +400,25 @@ export declare class FirebirdBrowser {
|
|
|
181
400
|
* Persist the in-memory database pages to IndexedDB.
|
|
182
401
|
* Call this periodically or before the page unloads to avoid data loss.
|
|
183
402
|
*/
|
|
403
|
+
/**
|
|
404
|
+
* The database as bytes, ready to be stored, sent, or handed to
|
|
405
|
+
* {@link FirebirdBrowserOptions.loadDataDir}.
|
|
406
|
+
*
|
|
407
|
+
* ```ts
|
|
408
|
+
* const bytes = await db.dumpDataDir();
|
|
409
|
+
* const url = URL.createObjectURL(new Blob([bytes]));
|
|
410
|
+
* ```
|
|
411
|
+
*
|
|
412
|
+
* Read from the **live** database rather than from IndexedDB, which matters
|
|
413
|
+
* twice over: writes that have not been persisted yet are included, and an
|
|
414
|
+
* ephemeral `memory://` database has no stored copy to read at all. It is
|
|
415
|
+
* the same image `persist()` writes, taken the same way.
|
|
416
|
+
*
|
|
417
|
+
* A `Uint8Array` rather than a `Blob` — a `Blob` is one constructor away and
|
|
418
|
+
* exists only in a browser, while this class also runs in Node against a
|
|
419
|
+
* direct transport.
|
|
420
|
+
*/
|
|
421
|
+
dumpDataDir(): Promise<Uint8Array>;
|
|
184
422
|
persist(): Promise<void>;
|
|
185
423
|
/**
|
|
186
424
|
* Close the database and release all resources.
|
|
@@ -188,6 +426,15 @@ export declare class FirebirdBrowser {
|
|
|
188
426
|
close(): Promise<void>;
|
|
189
427
|
/** Release the cross-tab lock, if this instance holds one. */
|
|
190
428
|
private releaseLock;
|
|
429
|
+
/**
|
|
430
|
+
* Whether this tab may write the database image to IndexedDB.
|
|
431
|
+
*
|
|
432
|
+
* In shared mode only the leader may: a follower has no engine, and its
|
|
433
|
+
* `readFile` would fetch the image across the channel only to race the
|
|
434
|
+
* leader writing the same store — reintroducing the whole-image overwrite
|
|
435
|
+
* that multi-tab safety exists to prevent.
|
|
436
|
+
*/
|
|
437
|
+
private get mayPersist();
|
|
191
438
|
/** Note that the database has changed and schedule a persist. */
|
|
192
439
|
private markDirty;
|
|
193
440
|
private cancelScheduledPersist;
|
|
@@ -213,6 +460,27 @@ export declare class FirebirdBrowser {
|
|
|
213
460
|
private readonly onPageHide;
|
|
214
461
|
private ensureReady;
|
|
215
462
|
private init;
|
|
463
|
+
/**
|
|
464
|
+
* Restore the stored image if this tab owns the engine, then attach.
|
|
465
|
+
*
|
|
466
|
+
* Separate from init() because it has to run again whenever the engine
|
|
467
|
+
* changes underneath us — in shared mode a leadership change replaces the
|
|
468
|
+
* engine, and every handle it issued dies with it.
|
|
469
|
+
*
|
|
470
|
+
* The restore is guarded by {@link mayPersist} for the same reason
|
|
471
|
+
* persistence is: a follower writing its IndexedDB snapshot into the
|
|
472
|
+
* filesystem would be overwriting the leader's *live* database with a
|
|
473
|
+
* possibly older image.
|
|
474
|
+
*/
|
|
475
|
+
private openDatabase;
|
|
476
|
+
/**
|
|
477
|
+
* The engine behind this connection was replaced; attach to the new one.
|
|
478
|
+
*
|
|
479
|
+
* Called on every tab after a leadership change, promoted or not. Silence
|
|
480
|
+
* here would leave the caller holding a handle from an engine that no longer
|
|
481
|
+
* exists, and writes through it would go nowhere — visibly succeeding.
|
|
482
|
+
*/
|
|
483
|
+
private reopenAfterEngineChange;
|
|
216
484
|
}
|
|
217
485
|
/**
|
|
218
486
|
* A handle to an active transaction in the browser WASM engine.
|
|
@@ -224,8 +492,9 @@ export declare class FirebirdBrowserTransaction {
|
|
|
224
492
|
private readonly engine;
|
|
225
493
|
private readonly dbHandle;
|
|
226
494
|
private readonly txHandle;
|
|
495
|
+
private readonly types?;
|
|
227
496
|
private finished;
|
|
228
|
-
constructor(engine: EngineTransport, dbHandle: EngineHandle, txHandle: EngineHandle);
|
|
497
|
+
constructor(engine: EngineTransport, dbHandle: EngineHandle, txHandle: EngineHandle, types?: TypeOptions | undefined);
|
|
229
498
|
/** Whether this transaction has already been rolled back. */
|
|
230
499
|
get isFinished(): boolean;
|
|
231
500
|
/**
|
|
@@ -242,8 +511,12 @@ export declare class FirebirdBrowserTransaction {
|
|
|
242
511
|
*
|
|
243
512
|
* @returns the number of rows affected.
|
|
244
513
|
*/
|
|
245
|
-
exec(sql: string, params?: QueryParams): Promise<ExecResult>;
|
|
514
|
+
exec(sql: string | SqlFragment, params?: QueryParams): Promise<ExecResult>;
|
|
246
515
|
/** Execute a SELECT inside this transaction and return rows. */
|
|
247
|
-
query
|
|
516
|
+
query(sql: string | SqlFragment, params: QueryParams | undefined, options: ArrayModeOptions): Promise<QueryResult<ArrayRow>>;
|
|
517
|
+
query<T extends Row = Row>(sql: string | SqlFragment, params?: QueryParams, options?: {
|
|
518
|
+
rowMode?: RowMode;
|
|
519
|
+
}): Promise<QueryResult<T>>;
|
|
248
520
|
}
|
|
521
|
+
export {};
|
|
249
522
|
//# sourceMappingURL=firebird-browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebird-browser.d.ts","sourceRoot":"","sources":["../../src/browser/firebird-browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"firebird-browser.d.ts","sourceRoot":"","sources":["../../src/browser/firebird-browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAKxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAKjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KA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