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.
Files changed (68) hide show
  1. package/CHANGELOG.md +203 -0
  2. package/README.md +4 -1
  3. package/dist/.tsbuildinfo.build +1 -1
  4. package/dist/browser/engine-transport.d.ts +56 -5
  5. package/dist/browser/engine-transport.d.ts.map +1 -1
  6. package/dist/browser/engine-transport.js +271 -8
  7. package/dist/browser/engine-transport.js.map +1 -1
  8. package/dist/browser/firebird-browser.d.ts +282 -9
  9. package/dist/browser/firebird-browser.d.ts.map +1 -1
  10. package/dist/browser/firebird-browser.js +435 -42
  11. package/dist/browser/firebird-browser.js.map +1 -1
  12. package/dist/browser/index.d.ts +12 -2
  13. package/dist/browser/index.d.ts.map +1 -1
  14. package/dist/browser/index.js +23 -3
  15. package/dist/browser/index.js.map +1 -1
  16. package/dist/browser/leader-election.d.ts +55 -0
  17. package/dist/browser/leader-election.d.ts.map +1 -0
  18. package/dist/browser/leader-election.js +64 -0
  19. package/dist/browser/leader-election.js.map +1 -0
  20. package/dist/browser/opfs-fs.d.ts +72 -0
  21. package/dist/browser/opfs-fs.d.ts.map +1 -0
  22. package/dist/browser/opfs-fs.js +249 -0
  23. package/dist/browser/opfs-fs.js.map +1 -0
  24. package/dist/browser/shared-transport.d.ts +134 -0
  25. package/dist/browser/shared-transport.d.ts.map +1 -0
  26. package/dist/browser/shared-transport.js +366 -0
  27. package/dist/browser/shared-transport.js.map +1 -0
  28. package/dist/browser/statement-types.d.ts +18 -0
  29. package/dist/browser/statement-types.d.ts.map +1 -0
  30. package/dist/browser/statement-types.js +39 -0
  31. package/dist/browser/statement-types.js.map +1 -0
  32. package/dist/browser/value-types.d.ts +173 -0
  33. package/dist/browser/value-types.d.ts.map +1 -0
  34. package/dist/browser/value-types.js +222 -0
  35. package/dist/browser/value-types.js.map +1 -0
  36. package/dist/browser/worker-entry.d.ts.map +1 -1
  37. package/dist/browser/worker-entry.js +38 -1
  38. package/dist/browser/worker-entry.js.map +1 -1
  39. package/dist/browser/worker-protocol.d.ts +1 -1
  40. package/dist/browser/worker-protocol.d.ts.map +1 -1
  41. package/dist/browser/worker-transport.d.ts +8 -2
  42. package/dist/browser/worker-transport.d.ts.map +1 -1
  43. package/dist/browser/worker-transport.js +26 -2
  44. package/dist/browser/worker-transport.js.map +1 -1
  45. package/dist/firebird.d.ts +58 -5
  46. package/dist/firebird.d.ts.map +1 -1
  47. package/dist/firebird.js +161 -52
  48. package/dist/firebird.js.map +1 -1
  49. package/dist/index.d.ts +4 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +9 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/sql-tag.d.ts +184 -0
  54. package/dist/sql-tag.d.ts.map +1 -0
  55. package/dist/sql-tag.js +287 -0
  56. package/dist/sql-tag.js.map +1 -0
  57. package/dist/statement-types.d.ts +23 -0
  58. package/dist/statement-types.d.ts.map +1 -0
  59. package/dist/statement-types.js +44 -0
  60. package/dist/statement-types.js.map +1 -0
  61. package/dist/types.d.ts +62 -0
  62. package/dist/types.d.ts.map +1 -1
  63. package/dist/wasm/firebird-embedded.js +1 -1
  64. package/dist/wasm/firebird-embedded.wasm +0 -0
  65. package/dist/wasm-loader.d.ts +38 -2
  66. package/dist/wasm-loader.d.ts.map +1 -1
  67. package/dist/wasm-loader.js.map +1 -1
  68. package/package.json +3 -2
@@ -0,0 +1,173 @@
1
+ /**
2
+ * value-types.ts – opt-in conversion of result values to richer JavaScript types.
3
+ *
4
+ * The wire format hands back values that are always *correct* and sometimes
5
+ * awkward: a `BIGINT` past 2⁵³ is an exact decimal string, a binary `BLOB` is
6
+ * base64, a `TIMESTAMP` is ISO-8601 text. Nothing is lost, but nothing is
7
+ * directly usable either.
8
+ *
9
+ * These conversions are opt-in rather than default because each one trades
10
+ * something away, and a database library that quietly changes what `rows`
11
+ * contains is not one to trust. See {@link TypeOptions} for what each costs.
12
+ */
13
+ import type { FieldInfo, QueryParams, QueryResult, RowMode } from '../types';
14
+ /**
15
+ * Convert one incoming column value.
16
+ *
17
+ * Called once per cell of a column it is registered for, never for `null` —
18
+ * see {@link TypeOptions.parsers}. `field` carries the column's `subType`,
19
+ * `scale` and `length`, which is what separates a `NUMERIC` from a `BIGINT`
20
+ * or a text BLOB from a binary one when the type code alone does not.
21
+ */
22
+ export type Parser = (value: unknown, field: FieldInfo) => unknown;
23
+ /**
24
+ * Convert one outgoing parameter to the text Firebird will parse.
25
+ *
26
+ * Return `undefined` to decline, leaving the value to the next serializer and
27
+ * finally to the built-in encoder. Return a string to bind that text, or
28
+ * `null` to bind SQL NULL.
29
+ */
30
+ export type Serializer = (value: unknown) => string | null | undefined;
31
+ /**
32
+ * Which values to convert. Everything defaults to off.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const db = new FirebirdBrowser('mydb', {
37
+ * worker,
38
+ * types: { bigint: true, binary: true },
39
+ * });
40
+ * ```
41
+ */
42
+ export interface TypeOptions {
43
+ /**
44
+ * `BIGINT` as `bigint`.
45
+ *
46
+ * Applies to every `BIGINT`, not only those past 2⁵³. The default rule —
47
+ * `number` when it fits, `string` when it does not — means `typeof row.ID`
48
+ * depends on how large the id happens to be, which is worse than either type
49
+ * on its own.
50
+ *
51
+ * Does **not** apply to `NUMERIC`/`DECIMAL`, which Firebird also stores as a
52
+ * scaled 64-bit integer: those keep their exact decimal string, because a
53
+ * `bigint` would silently drop the scale.
54
+ */
55
+ bigint?: boolean;
56
+ /**
57
+ * `DATE` and `TIMESTAMP` as `Date`.
58
+ *
59
+ * Two costs, both unavoidable rather than incidental:
60
+ *
61
+ * - **Precision.** Firebird keeps 100 µs; `Date` keeps 1 ms. `11:22:33.4567`
62
+ * becomes `11:22:33.456`. The fourth digit is gone.
63
+ * - **Time zone.** Firebird's `DATE` and `TIMESTAMP` carry no zone — they are
64
+ * wall-clock values — while `Date` is an absolute instant, so a zone has to
65
+ * be chosen. **UTC** is used, so the same stored value yields the same
66
+ * `Date` on every machine. Left to JavaScript's own parsing it would be
67
+ * local for `TIMESTAMP` and UTC for `DATE`, which is both machine-dependent
68
+ * and inconsistent between the two types.
69
+ *
70
+ * `TIME`, `TIME WITH TIME ZONE` and `TIMESTAMP WITH TIME ZONE` are **never**
71
+ * converted: `new Date('11:22:33')` is `Invalid Date`, and `Date` has nowhere
72
+ * to keep a named zone like `Europe/Bucharest`. They stay strings.
73
+ */
74
+ dates?: boolean;
75
+ /**
76
+ * Binary `BLOB` as `Uint8Array` rather than base64.
77
+ *
78
+ * The one conversion with no downside: base64 is 33% larger than the bytes it
79
+ * encodes and has to be decoded before use. Text BLOBs are unaffected — the
80
+ * engine already returns those as strings.
81
+ */
82
+ binary?: boolean;
83
+ /**
84
+ * Convert incoming values yourself, keyed by Firebird SQL type code.
85
+ *
86
+ * ```ts
87
+ * const SQL_TIMESTAMP = 510;
88
+ * new FirebirdBrowser('mydb', {
89
+ * worker,
90
+ * types: { parsers: { [SQL_TIMESTAMP]: (v) => Temporal.PlainDateTime.from(v as string) } },
91
+ * });
92
+ * ```
93
+ *
94
+ * The code is the one {@link FieldInfo.type} reports — `firebirdTypeName()`
95
+ * names them, and they are listed in `field-types.ts`.
96
+ *
97
+ * A parser **replaces** the built-in conversion for its type rather than
98
+ * running alongside it, so `parsers` is also how `bigint` or `dates` gets
99
+ * overridden. Two conversions for one column would otherwise need an order,
100
+ * and no order is obviously right.
101
+ *
102
+ * **Never called for `null`.** A parser that had to guard every value would
103
+ * be all guard, and the alternative — every parser crashing on the first
104
+ * nullable column — is worse. A column's nulls stay null.
105
+ *
106
+ * The type code alone does not always identify a type: `NUMERIC` and
107
+ * `BIGINT` share `SQL_INT64` (580) and differ by `scale`, and BLOBs differ
108
+ * by `subType`. Both reach the parser on `field`, so a parser registered for
109
+ * a shared code has to check — the built-in conversions do exactly that.
110
+ *
111
+ * A code may be registered with or without the nullable flag in its low bit
112
+ * — `580` and `581` name the same type, and both are published. Registering
113
+ * *both* throws, because one of them could only ever be dead.
114
+ *
115
+ * A parser that throws is not caught: the query rejects, since returning
116
+ * half-converted rows would be worse. The error names the column, the type
117
+ * code and the offending value, and keeps the original as its `cause`.
118
+ */
119
+ parsers?: Record<number, Parser>;
120
+ /**
121
+ * Convert outgoing parameters yourself.
122
+ *
123
+ * ```ts
124
+ * new FirebirdBrowser('mydb', {
125
+ * worker,
126
+ * types: { serializers: [(v) => (v instanceof Decimal ? v.toFixed() : undefined)] },
127
+ * });
128
+ * ```
129
+ *
130
+ * A list rather than a map keyed by type, because there is no type to key
131
+ * on: parameters carry no declared type on the way out. Every value crosses
132
+ * as text and Firebird converts it to whatever the column actually is, which
133
+ * is what lets one path serve integers, dates and strings alike. So a
134
+ * serializer is selected by looking at the *value*, and each one declines by
135
+ * returning `undefined`.
136
+ *
137
+ * Consulted **before** the built-in encoder, so these also override how a
138
+ * `Date` or a `number` is rendered. Like {@link TypeOptions.parsers}, they
139
+ * are never called for `null` or `undefined`, both of which are already SQL
140
+ * NULL.
141
+ */
142
+ serializers?: Serializer[];
143
+ }
144
+ /**
145
+ * True if any incoming conversion is switched on.
146
+ *
147
+ * Serializers are deliberately not counted: they apply to parameters going
148
+ * out, and this gates {@link applyTypes}, which only ever looks at rows
149
+ * coming back.
150
+ */
151
+ export declare function hasTypeOptions(options: TypeOptions | undefined): boolean;
152
+ /**
153
+ * Apply {@link TypeOptions} to a result set, in place.
154
+ *
155
+ * Returns the same object. Columns needing no conversion are never visited, so
156
+ * a result set with nothing convertible costs one pass over the field list and
157
+ * nothing per row.
158
+ */
159
+ export declare function applyTypes<T>(result: QueryResult<T>, options: TypeOptions | undefined, rowMode?: RowMode): QueryResult<T>;
160
+ /**
161
+ * Run {@link TypeOptions.serializers} over a parameter list.
162
+ *
163
+ * Returns a new array — the caller's is not theirs to modify — or the original
164
+ * when there is nothing to do, so the common case allocates nothing.
165
+ *
166
+ * This has to happen here rather than in the parameter encoder, for the same
167
+ * reason {@link applyTypes} does: with a Worker transport the encoder runs on
168
+ * the other side of `postMessage`, and a function cannot be structured-cloned.
169
+ * Serializing before the values cross means the Worker only ever receives
170
+ * strings, which clone fine.
171
+ */
172
+ export declare function applySerializers(params: QueryParams, serializers: Serializer[] | undefined): QueryParams;
173
+ //# sourceMappingURL=value-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-types.d.ts","sourceRoot":"","sources":["../../src/browser/value-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAO,OAAO,EAAE,MAAM,UAAU,CAAC;AAWlF;;;;;;;GAOG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC;AAEnE;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAEvE;;;;;;;;;;GAUG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,CAQxE;AAqHD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EACtB,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,OAAO,GAAE,OAAkB,GAC1B,WAAW,CAAC,CAAC,CAAC,CAoDhB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,WAAW,EACnB,WAAW,EAAE,UAAU,EAAE,GAAG,SAAS,GACpC,WAAW,CAgBb"}
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+ /**
3
+ * value-types.ts – opt-in conversion of result values to richer JavaScript types.
4
+ *
5
+ * The wire format hands back values that are always *correct* and sometimes
6
+ * awkward: a `BIGINT` past 2⁵³ is an exact decimal string, a binary `BLOB` is
7
+ * base64, a `TIMESTAMP` is ISO-8601 text. Nothing is lost, but nothing is
8
+ * directly usable either.
9
+ *
10
+ * These conversions are opt-in rather than default because each one trades
11
+ * something away, and a database library that quietly changes what `rows`
12
+ * contains is not one to trust. See {@link TypeOptions} for what each costs.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.hasTypeOptions = hasTypeOptions;
16
+ exports.applyTypes = applyTypes;
17
+ exports.applySerializers = applySerializers;
18
+ // Firebird type codes, from firebird/impl/sqlda_pub.h.
19
+ const SQL_TIMESTAMP = 510;
20
+ const SQL_BLOB = 520;
21
+ const SQL_TYPE_DATE = 570;
22
+ const SQL_INT64 = 580;
23
+ /** Binary BLOBs are sub-type 0; 1 is text, and the engine already decodes it. */
24
+ const BLOB_SUBTYPE_BINARY = 0;
25
+ /**
26
+ * True if any incoming conversion is switched on.
27
+ *
28
+ * Serializers are deliberately not counted: they apply to parameters going
29
+ * out, and this gates {@link applyTypes}, which only ever looks at rows
30
+ * coming back.
31
+ */
32
+ function hasTypeOptions(options) {
33
+ return Boolean(options &&
34
+ (options.bigint ||
35
+ options.dates ||
36
+ options.binary ||
37
+ (options.parsers && Object.keys(options.parsers).length > 0)));
38
+ }
39
+ /** Decode base64 to bytes, in either a browser or Node. */
40
+ function base64ToBytes(value) {
41
+ const binary = atob(value);
42
+ const bytes = new Uint8Array(binary.length);
43
+ for (let i = 0; i < binary.length; i++) {
44
+ bytes[i] = binary.charCodeAt(i);
45
+ }
46
+ return bytes;
47
+ }
48
+ /**
49
+ * Index {@link TypeOptions.parsers} by type code with the nullable flag cleared.
50
+ *
51
+ * The flag is the low bit. The engine reports it clear — Firebird ORs it in
52
+ * only when filling a legacy XSQLDA — but the codes are published both ways,
53
+ * and a parser registered as `{ 581: fn }` for a nullable `BIGINT` would
54
+ * otherwise never fire: no conversion, no error, and a column that silently
55
+ * keeps its raw form. Normalising the *registration* keys is what makes that
56
+ * work; masking the lookup alone cannot, because the engine's code is already
57
+ * even.
58
+ *
59
+ * @throws if two keys normalise to the same code, which means one of them is
60
+ * silently unreachable.
61
+ */
62
+ function normaliseParsers(parsers) {
63
+ if (!parsers)
64
+ return null;
65
+ const byType = new Map();
66
+ for (const [key, parser] of Object.entries(parsers)) {
67
+ const code = Number(key) & ~1;
68
+ if (byType.has(code)) {
69
+ throw new TypeError(`types.parsers has two entries for SQL type ${code}: ${key} and its ` +
70
+ 'counterpart with the nullable bit differing. Keep one — they name ' +
71
+ 'the same type');
72
+ }
73
+ byType.set(code, parser);
74
+ }
75
+ return byType;
76
+ }
77
+ /**
78
+ * A converter for one column, or null when the column needs none.
79
+ *
80
+ * Chosen once per result set from {@link FieldInfo} rather than per value: the
81
+ * type of a column does not vary row to row, and deciding per value would put
82
+ * a branch in the hot path for every cell.
83
+ */
84
+ function converterFor(field, options, parsers) {
85
+ const type = field.type;
86
+ if (type === undefined)
87
+ return null;
88
+ const parser = parsers?.get(type & ~1);
89
+ if (parser) {
90
+ // Wins over the built-ins below, which is what makes `parsers` the way to
91
+ // override `dates` rather than a second conversion fighting it.
92
+ return (value) => {
93
+ if (value === null || value === undefined)
94
+ return value;
95
+ try {
96
+ return parser(value, field);
97
+ }
98
+ catch (err) {
99
+ // A parser is application code and can throw on a value it did not
100
+ // expect. Unwrapped, the error names neither the column nor the type
101
+ // code that selected the parser, and the whole query rejects — the
102
+ // rows are gone, so there is nothing to inspect afterwards either.
103
+ const wrapped = new Error(`parser for column ${field.name} (type ${type}) failed on ` +
104
+ `${typeof value === 'string' ? JSON.stringify(value) : String(value)}: ` +
105
+ `${err instanceof Error ? err.message : String(err)}`);
106
+ // Assigned rather than passed as `new Error(msg, { cause })`, which
107
+ // needs lib ES2022 — this project targets ES2020, and bumping the
108
+ // whole compilation for one property is the wrong trade. The original
109
+ // error and its stack are kept either way.
110
+ wrapped.cause = err;
111
+ throw wrapped;
112
+ }
113
+ };
114
+ }
115
+ if (options.bigint && type === SQL_INT64 && field.scale === 0) {
116
+ // scale 0 is what separates a BIGINT from a NUMERIC stored in the same
117
+ // 64-bit integer. A scaled value converted to bigint would lose its
118
+ // decimal point without saying so.
119
+ return (value) => value === null || value === undefined ? value : BigInt(value);
120
+ }
121
+ if (options.dates && (type === SQL_TIMESTAMP || type === SQL_TYPE_DATE)) {
122
+ return (value) => {
123
+ if (typeof value !== 'string')
124
+ return value;
125
+ // 'Z' makes the interpretation UTC and explicit. Without it a bare
126
+ // date-time is local and a bare date is UTC — see TypeOptions.dates.
127
+ const parsed = new Date(`${value}Z`);
128
+ // A value the engine produced should always parse; if it somehow does
129
+ // not, the string is more useful to a caller than an Invalid Date.
130
+ return Number.isNaN(parsed.getTime()) ? value : parsed;
131
+ };
132
+ }
133
+ if (options.binary && type === SQL_BLOB && field.subType === BLOB_SUBTYPE_BINARY) {
134
+ return (value) => (typeof value === 'string' ? base64ToBytes(value) : value);
135
+ }
136
+ return null;
137
+ }
138
+ /**
139
+ * Apply {@link TypeOptions} to a result set, in place.
140
+ *
141
+ * Returns the same object. Columns needing no conversion are never visited, so
142
+ * a result set with nothing convertible costs one pass over the field list and
143
+ * nothing per row.
144
+ */
145
+ function applyTypes(result, options, rowMode = 'object') {
146
+ if (!hasTypeOptions(options) || result.rows.length === 0) {
147
+ return result;
148
+ }
149
+ const parsers = normaliseParsers(options.parsers);
150
+ if (rowMode === 'array') {
151
+ // Positional rows need positional converters, and get the simpler job of
152
+ // the two: one converter per column, with no names to collide, so the
153
+ // shadowing rule below does not arise.
154
+ const byIndex = result.fields.map((field) => converterFor(field, options, parsers));
155
+ if (byIndex.every((convert) => convert === null))
156
+ return result;
157
+ for (const row of result.rows) {
158
+ const target = row;
159
+ for (let i = 0; i < byIndex.length; i++) {
160
+ const convert = byIndex[i];
161
+ if (convert)
162
+ target[i] = convert(target[i]);
163
+ }
164
+ }
165
+ return result;
166
+ }
167
+ // Keyed by column name rather than accumulated per field, because a result
168
+ // set can name two columns the same — `SELECT a.ID, b.ID` — while a row
169
+ // holds one `ID`. Both row builders keep the *last* such column, so the
170
+ // last converter is the one that matches the value actually there; a Map
171
+ // gives exactly that, and running two converters over one cell would
172
+ // otherwise feed the second the first's output.
173
+ const converters = new Map();
174
+ for (const field of result.fields) {
175
+ const convert = converterFor(field, options, parsers);
176
+ if (convert)
177
+ converters.set(field.name, convert);
178
+ // A column with no conversion still shadows an earlier one of the same
179
+ // name, whose converter would otherwise run on this column's value.
180
+ else
181
+ converters.delete(field.name);
182
+ }
183
+ if (converters.size === 0)
184
+ return result;
185
+ for (const row of result.rows) {
186
+ const target = row;
187
+ for (const [name, convert] of converters) {
188
+ target[name] = convert(target[name]);
189
+ }
190
+ }
191
+ return result;
192
+ }
193
+ /**
194
+ * Run {@link TypeOptions.serializers} over a parameter list.
195
+ *
196
+ * Returns a new array — the caller's is not theirs to modify — or the original
197
+ * when there is nothing to do, so the common case allocates nothing.
198
+ *
199
+ * This has to happen here rather than in the parameter encoder, for the same
200
+ * reason {@link applyTypes} does: with a Worker transport the encoder runs on
201
+ * the other side of `postMessage`, and a function cannot be structured-cloned.
202
+ * Serializing before the values cross means the Worker only ever receives
203
+ * strings, which clone fine.
204
+ */
205
+ function applySerializers(params, serializers) {
206
+ if (!serializers || serializers.length === 0 || params.length === 0) {
207
+ return params;
208
+ }
209
+ return params.map((value) => {
210
+ // null and undefined are already SQL NULL; a serializer that had to
211
+ // recognise them would be writing the encoder's job out again.
212
+ if (value === null || value === undefined)
213
+ return value;
214
+ for (const serialize of serializers) {
215
+ const serialized = serialize(value);
216
+ if (serialized !== undefined)
217
+ return serialized;
218
+ }
219
+ return value;
220
+ });
221
+ }
222
+ //# sourceMappingURL=value-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-types.js","sourceRoot":"","sources":["../../src/browser/value-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AA6JH,wCAQC;AA4HD,gCAwDC;AAcD,4CAmBC;AAtXD,uDAAuD;AACvD,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,iFAAiF;AACjF,MAAM,mBAAmB,GAAG,CAAC,CAAC;AA2I9B;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,OAAgC;IAC7D,OAAO,OAAO,CACZ,OAAO;QACL,CAAC,OAAO,CAAC,MAAM;YACb,OAAO,CAAC,KAAK;YACb,OAAO,CAAC,MAAM;YACd,CAAC,OAAO,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAClE,CAAC;AACJ,CAAC;AAED,2DAA2D;AAC3D,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;IACD,O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,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1B,oEAAoE;QACpE,+DAA+D;QAC/D,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAExD,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE,CAAC;YACpC,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,UAAU,KAAK,SAAS;gBAAE,OAAO,UAAU,CAAC;QAClD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"worker-entry.d.ts","sourceRoot":"","sources":["../../src/browser/worker-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAA0B,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,mBAAmB,CAAC;AAEvE;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAC/D,gBAAgB,CACd,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,aAAa,CAAC,KAAK,IAAI,GACrD,IAAI,CAAC;CACT;AAOD;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,iBAAiB,EACxB,SAAS,EAAE,eAAe,GACzB,IAAI,CAiCN"}
1
+ {"version":3,"file":"worker-entry.d.ts","sourceRoot":"","sources":["../../src/browser/worker-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAA0B,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,mBAAmB,CAAC;AAEvE;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAC/D,gBAAgB,CACd,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,aAAa,CAAC,KAAK,IAAI,GACrD,IAAI,CAAC;CACT;AAqCD;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,iBAAiB,EACxB,SAAS,EAAE,eAAe,GACzB,IAAI,CAwCN"}
@@ -25,6 +25,36 @@
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.serveEngine = serveEngine;
27
27
  const engine_transport_1 = require("./engine-transport");
28
+ /**
29
+ * Every distinct ArrayBuffer behind a Uint8Array in a query result.
30
+ *
31
+ * Only query results are walked, and only one level into each row: a value is
32
+ * either a blob or it is not, and scanning arbitrary structures on every reply
33
+ * would cost more than the transfer saves.
34
+ *
35
+ * De-duplicated because transferring the same buffer twice throws
36
+ * DataCloneError, and two rows can hold views on one buffer if the same blob
37
+ * appeared twice.
38
+ */
39
+ function collectBlobBuffers(result) {
40
+ if (typeof result !== 'object' || result === null)
41
+ return [];
42
+ const rows = result.rows;
43
+ if (!Array.isArray(rows))
44
+ return [];
45
+ const buffers = new Set();
46
+ for (const row of rows) {
47
+ if (typeof row !== 'object' || row === null)
48
+ continue;
49
+ // Rows are arrays in rowMode 'array' and plain objects otherwise;
50
+ // Object.values covers both.
51
+ for (const value of Object.values(row)) {
52
+ if (value instanceof Uint8Array)
53
+ buffers.add(value.buffer);
54
+ }
55
+ }
56
+ return [...buffers];
57
+ }
28
58
  /**
29
59
  * Wire a transport up to a Worker scope.
30
60
  *
@@ -35,7 +65,14 @@ function serveEngine(scope, transport) {
35
65
  const reply = (response) => {
36
66
  // Transfer the buffer for readFile rather than copying it: a database
37
67
  // image is measured in megabytes and this runs on every persist.
38
- const transfer = response.result instanceof Uint8Array ? [response.result.buffer] : [];
68
+ //
69
+ // The same applies to binary BLOBs coming back from a query, which arrive
70
+ // as Uint8Arrays inside the rows. Structured cloning would copy every one
71
+ // of them across the boundary — the cost a base64 string could never avoid
72
+ // and the reason the side channel is worth having at all.
73
+ const transfer = response.result instanceof Uint8Array
74
+ ? [response.result.buffer]
75
+ : collectBlobBuffers(response.result);
39
76
  scope.postMessage(response, transfer);
40
77
  };
41
78
  scope.addEventListener('message', (event) => {
@@ -1 +1 @@
1
- {"version":3,"file":"worker-entry.js","sourceRoot":"","sources":["../../src/browser/worker-entry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;AAiCH,kCAoCC;AAnED,yDAAqD;AAyBrD;;;;;GAKG;AACH,SAAgB,WAAW,CACzB,KAAwB,EACxB,SAA0B;IAE1B,MAAM,KAAK,GAAG,CAAC,QAAwB,EAAQ,EAAE;QAC/C,sEAAsE;QACtE,iEAAiE;QACjE,MAAM,QAAQ,GACZ,QAAQ,CAAC,MAAM,YAAY,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACxE,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,QAA0B,CAAC,CAAC;IAC1D,CAAC,CAAC;IAEF,KAAK,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAkC,EAAE,EAAE;QACvE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;QAEpC,KAAK,CAAC,KAAK,IAAI,EAAE;YACf,IAAI,CAAC;gBACH,sEAAsE;gBACtE,oEAAoE;gBACpE,MAAM,EAAE,GAAI,SAA8E,CAAC,EAAE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7E,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,yEAAyE;QACzE,6DAA6D;QAC7D,IAAI,CAAC,WAAW,CAAC;YACf,EAAE,EAAE,CAAC,CAAC;YACN,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SACxD,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -8,7 +8,7 @@
8
8
  import type { Row, QueryResult } from '../types';
9
9
  import type { EngineHandle } from './engine-transport';
10
10
  /** Operations the Worker understands. One per EngineTransport method. */
11
- export type EngineOp = 'init' | 'createDatabase' | 'attachDatabase' | 'detachDatabase' | 'execute' | 'query' | 'startTransaction' | 'commit' | 'rollback' | 'mkdir' | 'exists' | 'readFile' | 'writeFile';
11
+ export type EngineOp = 'init' | 'createDatabase' | 'attachDatabase' | 'detachDatabase' | 'execute' | 'query' | 'describe' | 'startTransaction' | 'commit' | 'rollback' | 'mkdir' | 'exists' | 'readFile' | 'writeFile' | 'unlink' | 'mountOpfs' | 'eventsSubscribe' | 'eventsPoll' | 'eventsCancel';
12
12
  /** A call from the main thread to the Worker. */
13
13
  export interface EngineRequest {
14
14
  id: number;
@@ -1 +1 @@
1
- {"version":3,"file":"worker-protocol.d.ts","sourceRoot":"","sources":["../../src/browser/worker-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,0EAA0E;AAC1E,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,SAAS,GACT,OAAO,GACP,kBAAkB,GAClB,QAAQ,GACR,UAAU,GACV,OAAO,GACP,QAAQ,GACR,UAAU,GACV,WA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AC5E,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,OAAO,CAAC;IACZ,yBAAyB;IACzB,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAChF;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,mFAAmF;AACnF,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,CAAC,CAAC,CAAC;IACP,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -9,7 +9,7 @@
9
9
  * The Worker also owns Emscripten's filesystem, which is why the filesystem
10
10
  * operations are part of the transport rather than being done by the caller.
11
11
  */
12
- import type { Row, QueryResult, QueryParams, TransactionOptions } from '../types';
12
+ import type { Row, QueryResult, QueryDescription, QueryParams, RowMode, TransactionOptions } from '../types';
13
13
  import type { EngineHandle, EngineTransport } from './engine-transport';
14
14
  /** Options accepted by {@link WorkerTransport}. */
15
15
  export interface WorkerTransportOptions {
@@ -50,7 +50,8 @@ export declare class WorkerTransport implements EngineTransport {
50
50
  attachDatabase(path: string): Promise<EngineHandle>;
51
51
  detachDatabase(dbHandle: EngineHandle): Promise<void>;
52
52
  execute(dbHandle: EngineHandle, txHandle: EngineHandle, sql: string, params?: QueryParams): Promise<number>;
53
- query<T extends Row = Row>(dbHandle: EngineHandle, txHandle: EngineHandle, sql: string, params?: QueryParams): Promise<QueryResult<T>>;
53
+ query<T = Row>(dbHandle: EngineHandle, txHandle: EngineHandle, sql: string, params?: QueryParams, rowMode?: RowMode, binaryBlobs?: boolean): Promise<QueryResult<T>>;
54
+ describe(dbHandle: EngineHandle, txHandle: EngineHandle, sql: string): Promise<QueryDescription>;
54
55
  startTransaction(dbHandle: EngineHandle, options?: TransactionOptions): Promise<EngineHandle>;
55
56
  commit(txHandle: EngineHandle): Promise<void>;
56
57
  rollback(txHandle: EngineHandle): Promise<void>;
@@ -58,6 +59,11 @@ export declare class WorkerTransport implements EngineTransport {
58
59
  exists(path: string): Promise<boolean>;
59
60
  readFile(path: string): Promise<Uint8Array>;
60
61
  writeFile(path: string, data: Uint8Array): Promise<void>;
62
+ unlink(path: string): Promise<void>;
63
+ eventsSubscribe(dbHandle: EngineHandle, names: string[]): Promise<number>;
64
+ eventsPoll(subscription: number): Promise<Record<string, number>>;
65
+ eventsCancel(subscription: number): Promise<void>;
66
+ mountOpfs(dbName: string): Promise<string>;
61
67
  dispose(): Promise<void>;
62
68
  }
63
69
  //# sourceMappingURL=worker-transport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-transport.d.ts","sourceRoot":"","sources":["../../src/browser/worker-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGxE,mDAAmD;AACnD,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAUD;;;;;;;;GAQG;AACH,qBAAa,eAAgB,YAAW,eAAe;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IACtD,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,OAAO,CAAsB;gBAEzB,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B;IAQhE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAqBxB;IAEF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAEtB;IAEF,8DAA8D;IAC9D,OAAO,CAAC,IAAI;IASZ,OAAO,CAAC,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,CAAC,IAAI,CAAC;CAM/B"}
@@ -98,8 +98,16 @@ class WorkerTransport {
98
98
  execute(dbHandle, txHandle, sql, params = []) {
99
99
  return this.call('execute', dbHandle, txHandle, sql, params);
100
100
  }
101
- query(dbHandle, txHandle, sql, params = []) {
102
- return this.call('query', dbHandle, txHandle, sql, params);
101
+ query(dbHandle, txHandle, sql, params = [], rowMode = 'object', binaryBlobs = false) {
102
+ // Decoding happens on the far side, so both of these have to travel with
103
+ // the call rather than being applied to what comes back. They are a string
104
+ // and a boolean, so they survive structured cloning like the rest of the
105
+ // arguments — and the Uint8Arrays that come back from a side-channelled
106
+ // BLOB survive it too, which is what made this placement possible.
107
+ return this.call('query', dbHandle, txHandle, sql, params, rowMode, binaryBlobs);
108
+ }
109
+ describe(dbHandle, txHandle, sql) {
110
+ return this.call('describe', dbHandle, txHandle, sql);
103
111
  }
104
112
  startTransaction(dbHandle, options = {}) {
105
113
  // Plain data, so it survives structured cloning to the Worker as-is.
@@ -123,6 +131,22 @@ class WorkerTransport {
123
131
  writeFile(path, data) {
124
132
  return this.call('writeFile', path, data);
125
133
  }
134
+ unlink(path) {
135
+ return this.call('unlink', path);
136
+ }
137
+ eventsSubscribe(dbHandle, names) {
138
+ return this.call('eventsSubscribe', dbHandle, names);
139
+ }
140
+ eventsPoll(subscription) {
141
+ return this.call('eventsPoll', subscription);
142
+ }
143
+ eventsCancel(subscription) {
144
+ return this.call('eventsCancel', subscription);
145
+ }
146
+ mountOpfs(dbName) {
147
+ // The mount happens on the far side; only the resulting path comes back.
148
+ return this.call('mountOpfs', dbName);
149
+ }
126
150
  async dispose() {
127
151
  this.worker.removeEventListener('message', this.onMessage);
128
152
  this.worker.removeEventListener('error', this.onError);
@@ -1 +1 @@
1
- {"version":3,"file":"worker-transport.js","sourceRoot":"","sources":["../../src/browser/worker-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAoBH,MAAM,kBAAkB,GAAG,MAAO,CAAC;AAQnC;;;;;;;;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