@lunora/replica 1.0.0-alpha.3 → 1.0.0-alpha.30

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 (57) hide show
  1. package/LICENSE.md +214 -0
  2. package/dist/adapters/better-sqlite3.d.mts +14 -14
  3. package/dist/adapters/better-sqlite3.d.ts +14 -14
  4. package/dist/adapters/better-sqlite3.mjs +1 -29
  5. package/dist/adapters/sqlite-wasm.d.mts +29 -19
  6. package/dist/adapters/sqlite-wasm.d.ts +29 -19
  7. package/dist/adapters/sqlite-wasm.mjs +1 -56
  8. package/dist/adapters/sqljs.d.mts +10 -10
  9. package/dist/adapters/sqljs.d.ts +10 -10
  10. package/dist/adapters/sqljs.mjs +1 -55
  11. package/dist/index.d.mts +644 -574
  12. package/dist/index.d.ts +644 -574
  13. package/dist/index.mjs +1 -20
  14. package/dist/packem_shared/EventEmitter-ovTsLeAj.mjs +1 -0
  15. package/dist/packem_shared/EventLog-DmlRY_4Z.mjs +1 -0
  16. package/dist/packem_shared/EventLogDO-Cb-7iN9w.mjs +1 -0
  17. package/dist/packem_shared/EventLogDOClient-C6gA3b3u.mjs +1 -0
  18. package/dist/packem_shared/EventSource-B5UTlkl9.mjs +1 -0
  19. package/dist/packem_shared/EventsSync-DWyGGZQZ.mjs +1 -0
  20. package/dist/packem_shared/InMemorySnapshotStore-C4taIG5K.mjs +1 -0
  21. package/dist/packem_shared/LocalMirror-Q7cPH_rX.mjs +4 -0
  22. package/dist/packem_shared/MaterializerRuntime-CqGGjSxl.mjs +1 -0
  23. package/dist/packem_shared/SubscriptionManager-CbSjG_GA.mjs +1 -0
  24. package/dist/packem_shared/applyDiff-BUzddc6r.mjs +1 -0
  25. package/dist/packem_shared/applyDiffToDb-1M2I3BHi.mjs +1 -0
  26. package/dist/packem_shared/classifyChanges-IoOGDVVx.mjs +1 -0
  27. package/dist/packem_shared/defineEvents-CJZV8Bgi.mjs +1 -0
  28. package/dist/packem_shared/eventsContext-Dxow9Y7S.mjs +1 -0
  29. package/dist/packem_shared/isClientSeq-DSXBJskD.mjs +1 -0
  30. package/dist/packem_shared/local-mirror.d-CyGOpUES.d.ts +530 -0
  31. package/dist/packem_shared/local-mirror.d-DTavX_y0.d.mts +530 -0
  32. package/dist/packem_shared/subscribeToMirror-Dru_AYBu.mjs +1 -0
  33. package/dist/packem_shared/{types.d-BuAWjEY5.d.mts → types.d-CkMkSwLJ.d.mts} +10 -10
  34. package/dist/packem_shared/{types.d-BuAWjEY5.d.ts → types.d-CkMkSwLJ.d.ts} +10 -10
  35. package/dist/react.d.mts +59 -59
  36. package/dist/react.d.ts +59 -59
  37. package/dist/react.mjs +1 -15
  38. package/package.json +1 -1
  39. package/dist/packem_shared/EventEmitter-CMZfct03.mjs +0 -92
  40. package/dist/packem_shared/EventLog-zMy7AYP4.mjs +0 -162
  41. package/dist/packem_shared/EventLogDO-CZYUvvSr.mjs +0 -235
  42. package/dist/packem_shared/EventLogDOClient-DGiEdi96.mjs +0 -86
  43. package/dist/packem_shared/EventSource-DfV4VoRD.mjs +0 -195
  44. package/dist/packem_shared/EventsSync-DkVbU0WV.mjs +0 -91
  45. package/dist/packem_shared/InMemorySnapshotStore-BHVAD-Bp.mjs +0 -24
  46. package/dist/packem_shared/LocalMirror-GeJ26eNe.mjs +0 -188
  47. package/dist/packem_shared/MaterializerRuntime-HqNXqJxp.mjs +0 -204
  48. package/dist/packem_shared/SubscriptionManager-C5xbw0pg.mjs +0 -75
  49. package/dist/packem_shared/applyDiff-BtbIl1D3.mjs +0 -40
  50. package/dist/packem_shared/applyDiffToDb-DQ1xZp5J.mjs +0 -58
  51. package/dist/packem_shared/classifyChanges-aZmkxgVI.mjs +0 -38
  52. package/dist/packem_shared/defineEvents-DiBkPTh_.mjs +0 -28
  53. package/dist/packem_shared/eventsContext-Bk_p48hj.mjs +0 -6
  54. package/dist/packem_shared/isClientSeq-C46BkzqJ.mjs +0 -5
  55. package/dist/packem_shared/local-mirror.d-BUeOe5KC.d.mts +0 -439
  56. package/dist/packem_shared/local-mirror.d-Cd8tAg-W.d.ts +0 -439
  57. package/dist/packem_shared/subscribeToMirror-CiaM-nQ7.mjs +0 -45
package/LICENSE.md CHANGED
@@ -227,5 +227,219 @@ Repository: git+https://github.com/anolilab/lunora.git
227
227
  >
228
228
  > <!-- DEPENDENCIES -->
229
229
  > <!-- /DEPENDENCIES -->
230
+ >
231
+ >
232
+ >
233
+ > # Licenses of bundled types
234
+ > The published @lunora/server artifact additionally contains code with the following licenses:
235
+ > Apache-2.0
236
+ >
237
+ > # Bundled types:
238
+ > ## @opentelemetry/api
239
+ > License: Apache-2.0
240
+ > By: OpenTelemetry Authors
241
+ > Repository: open-telemetry/opentelemetry-js
242
+ >
243
+ > > Apache License
244
+ > > Version 2.0, January 2004
245
+ > > http://www.apache.org/licenses/
246
+ > >
247
+ > > TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
248
+ > >
249
+ > > 1. Definitions.
250
+ > >
251
+ > > "License" shall mean the terms and conditions for use, reproduction,
252
+ > > and distribution as defined by Sections 1 through 9 of this document.
253
+ > >
254
+ > > "Licensor" shall mean the copyright owner or entity authorized by
255
+ > > the copyright owner that is granting the License.
256
+ > >
257
+ > > "Legal Entity" shall mean the union of the acting entity and all
258
+ > > other entities that control, are controlled by, or are under common
259
+ > > control with that entity. For the purposes of this definition,
260
+ > > "control" means (i) the power, direct or indirect, to cause the
261
+ > > direction or management of such entity, whether by contract or
262
+ > > otherwise, or (ii) ownership of fifty percent (50%) or more of the
263
+ > > outstanding shares, or (iii) beneficial ownership of such entity.
264
+ > >
265
+ > > "You" (or "Your") shall mean an individual or Legal Entity
266
+ > > exercising permissions granted by this License.
267
+ > >
268
+ > > "Source" form shall mean the preferred form for making modifications,
269
+ > > including but not limited to software source code, documentation
270
+ > > source, and configuration files.
271
+ > >
272
+ > > "Object" form shall mean any form resulting from mechanical
273
+ > > transformation or translation of a Source form, including but
274
+ > > not limited to compiled object code, generated documentation,
275
+ > > and conversions to other media types.
276
+ > >
277
+ > > "Work" shall mean the work of authorship, whether in Source or
278
+ > > Object form, made available under the License, as indicated by a
279
+ > > copyright notice that is included in or attached to the work
280
+ > > (an example is provided in the Appendix below).
281
+ > >
282
+ > > "Derivative Works" shall mean any work, whether in Source or Object
283
+ > > form, that is based on (or derived from) the Work and for which the
284
+ > > editorial revisions, annotations, elaborations, or other modifications
285
+ > > represent, as a whole, an original work of authorship. For the purposes
286
+ > > of this License, Derivative Works shall not include works that remain
287
+ > > separable from, or merely link (or bind by name) to the interfaces of,
288
+ > > the Work and Derivative Works thereof.
289
+ > >
290
+ > > "Contribution" shall mean any work of authorship, including
291
+ > > the original version of the Work and any modifications or additions
292
+ > > to that Work or Derivative Works thereof, that is intentionally
293
+ > > submitted to Licensor for inclusion in the Work by the copyright owner
294
+ > > or by an individual or Legal Entity authorized to submit on behalf of
295
+ > > the copyright owner. For the purposes of this definition, "submitted"
296
+ > > means any form of electronic, verbal, or written communication sent
297
+ > > to the Licensor or its representatives, including but not limited to
298
+ > > communication on electronic mailing lists, source code control systems,
299
+ > > and issue tracking systems that are managed by, or on behalf of, the
300
+ > > Licensor for the purpose of discussing and improving the Work, but
301
+ > > excluding communication that is conspicuously marked or otherwise
302
+ > > designated in writing by the copyright owner as "Not a Contribution."
303
+ > >
304
+ > > "Contributor" shall mean Licensor and any individual or Legal Entity
305
+ > > on behalf of whom a Contribution has been received by Licensor and
306
+ > > subsequently incorporated within the Work.
307
+ > >
308
+ > > 2. Grant of Copyright License. Subject to the terms and conditions of
309
+ > > this License, each Contributor hereby grants to You a perpetual,
310
+ > > worldwide, non-exclusive, no-charge, royalty-free, irrevocable
311
+ > > copyright license to reproduce, prepare Derivative Works of,
312
+ > > publicly display, publicly perform, sublicense, and distribute the
313
+ > > Work and such Derivative Works in Source or Object form.
314
+ > >
315
+ > > 3. Grant of Patent License. Subject to the terms and conditions of
316
+ > > this License, each Contributor hereby grants to You a perpetual,
317
+ > > worldwide, non-exclusive, no-charge, royalty-free, irrevocable
318
+ > > (except as stated in this section) patent license to make, have made,
319
+ > > use, offer to sell, sell, import, and otherwise transfer the Work,
320
+ > > where such license applies only to those patent claims licensable
321
+ > > by such Contributor that are necessarily infringed by their
322
+ > > Contribution(s) alone or by combination of their Contribution(s)
323
+ > > with the Work to which such Contribution(s) was submitted. If You
324
+ > > institute patent litigation against any entity (including a
325
+ > > cross-claim or counterclaim in a lawsuit) alleging that the Work
326
+ > > or a Contribution incorporated within the Work constitutes direct
327
+ > > or contributory patent infringement, then any patent licenses
328
+ > > granted to You under this License for that Work shall terminate
329
+ > > as of the date such litigation is filed.
330
+ > >
331
+ > > 4. Redistribution. You may reproduce and distribute copies of the
332
+ > > Work or Derivative Works thereof in any medium, with or without
333
+ > > modifications, and in Source or Object form, provided that You
334
+ > > meet the following conditions:
335
+ > >
336
+ > > (a) You must give any other recipients of the Work or
337
+ > > Derivative Works a copy of this License; and
338
+ > >
339
+ > > (b) You must cause any modified files to carry prominent notices
340
+ > > stating that You changed the files; and
341
+ > >
342
+ > > (c) You must retain, in the Source form of any Derivative Works
343
+ > > that You distribute, all copyright, patent, trademark, and
344
+ > > attribution notices from the Source form of the Work,
345
+ > > excluding those notices that do not pertain to any part of
346
+ > > the Derivative Works; and
347
+ > >
348
+ > > (d) If the Work includes a "NOTICE" text file as part of its
349
+ > > distribution, then any Derivative Works that You distribute must
350
+ > > include a readable copy of the attribution notices contained
351
+ > > within such NOTICE file, excluding those notices that do not
352
+ > > pertain to any part of the Derivative Works, in at least one
353
+ > > of the following places: within a NOTICE text file distributed
354
+ > > as part of the Derivative Works; within the Source form or
355
+ > > documentation, if provided along with the Derivative Works; or,
356
+ > > within a display generated by the Derivative Works, if and
357
+ > > wherever such third-party notices normally appear. The contents
358
+ > > of the NOTICE file are for informational purposes only and
359
+ > > do not modify the License. You may add Your own attribution
360
+ > > notices within Derivative Works that You distribute, alongside
361
+ > > or as an addendum to the NOTICE text from the Work, provided
362
+ > > that such additional attribution notices cannot be construed
363
+ > > as modifying the License.
364
+ > >
365
+ > > You may add Your own copyright statement to Your modifications and
366
+ > > may provide additional or different license terms and conditions
367
+ > > for use, reproduction, or distribution of Your modifications, or
368
+ > > for any such Derivative Works as a whole, provided Your use,
369
+ > > reproduction, and distribution of the Work otherwise complies with
370
+ > > the conditions stated in this License.
371
+ > >
372
+ > > 5. Submission of Contributions. Unless You explicitly state otherwise,
373
+ > > any Contribution intentionally submitted for inclusion in the Work
374
+ > > by You to the Licensor shall be under the terms and conditions of
375
+ > > this License, without any additional terms or conditions.
376
+ > > Notwithstanding the above, nothing herein shall supersede or modify
377
+ > > the terms of any separate license agreement you may have executed
378
+ > > with Licensor regarding such Contributions.
379
+ > >
380
+ > > 6. Trademarks. This License does not grant permission to use the trade
381
+ > > names, trademarks, service marks, or product names of the Licensor,
382
+ > > except as required for reasonable and customary use in describing the
383
+ > > origin of the Work and reproducing the content of the NOTICE file.
384
+ > >
385
+ > > 7. Disclaimer of Warranty. Unless required by applicable law or
386
+ > > agreed to in writing, Licensor provides the Work (and each
387
+ > > Contributor provides its Contributions) on an "AS IS" BASIS,
388
+ > > WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
389
+ > > implied, including, without limitation, any warranties or conditions
390
+ > > of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
391
+ > > PARTICULAR PURPOSE. You are solely responsible for determining the
392
+ > > appropriateness of using or redistributing the Work and assume any
393
+ > > risks associated with Your exercise of permissions under this License.
394
+ > >
395
+ > > 8. Limitation of Liability. In no event and under no legal theory,
396
+ > > whether in tort (including negligence), contract, or otherwise,
397
+ > > unless required by applicable law (such as deliberate and grossly
398
+ > > negligent acts) or agreed to in writing, shall any Contributor be
399
+ > > liable to You for damages, including any direct, indirect, special,
400
+ > > incidental, or consequential damages of any character arising as a
401
+ > > result of this License or out of the use or inability to use the
402
+ > > Work (including but not limited to damages for loss of goodwill,
403
+ > > work stoppage, computer failure or malfunction, or any and all
404
+ > > other commercial damages or losses), even if such Contributor
405
+ > > has been advised of the possibility of such damages.
406
+ > >
407
+ > > 9. Accepting Warranty or Additional Liability. While redistributing
408
+ > > the Work or Derivative Works thereof, You may choose to offer,
409
+ > > and charge a fee for, acceptance of support, warranty, indemnity,
410
+ > > or other liability obligations and/or rights consistent with this
411
+ > > License. However, in accepting such obligations, You may act only
412
+ > > on Your own behalf and on Your sole responsibility, not on behalf
413
+ > > of any other Contributor, and only if You agree to indemnify,
414
+ > > defend, and hold each Contributor harmless for any liability
415
+ > > incurred by, or claims asserted against, such Contributor by reason
416
+ > > of your accepting any such warranty or additional liability.
417
+ > >
418
+ > > END OF TERMS AND CONDITIONS
419
+ > >
420
+ > > APPENDIX: How to apply the Apache License to your work.
421
+ > >
422
+ > > To apply the Apache License to your work, attach the following
423
+ > > boilerplate notice, with the fields enclosed by brackets "[]"
424
+ > > replaced with your own identifying information. (Don't include
425
+ > > the brackets!) The text should be enclosed in the appropriate
426
+ > > comment syntax for the file format. We also recommend that a
427
+ > > file or class name and description of purpose be included on the
428
+ > > same "printed page" as the copyright notice for easier
429
+ > > identification within third-party archives.
430
+ > >
431
+ > > Copyright [yyyy] [name of copyright owner]
432
+ > >
433
+ > > Licensed under the Apache License, Version 2.0 (the "License");
434
+ > > you may not use this file except in compliance with the License.
435
+ > > You may obtain a copy of the License at
436
+ > >
437
+ > > http://www.apache.org/licenses/LICENSE-2.0
438
+ > >
439
+ > > Unless required by applicable law or agreed to in writing, software
440
+ > > distributed under the License is distributed on an "AS IS" BASIS,
441
+ > > WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
442
+ > > See the License for the specific language governing permissions and
443
+ > > limitations under the License.
230
444
 
231
445
  <!-- /TYPE_DEPENDENCIES -->
@@ -1,18 +1,18 @@
1
- import { S as SqliteAdapter } from "../packem_shared/types.d-BuAWjEY5.mjs";
1
+ import { S as SqliteAdapter } from "../packem_shared/types.d-CkMkSwLJ.mjs";
2
2
  /**
3
- * Create a {@link SqliteAdapter} backed by [better-sqlite3](https://github.com/WiseLibs/better-sqlite3)
4
- * (a synchronous SQLite3 binding for Node.js).
5
- *
6
- * The adapter takes a structural projection of better-sqlite3's `Database` so
7
- * the package never imports from `better-sqlite3` directly — consumers install
8
- * it themselves and pass in their database instance.
9
- * @param database An already-initialised better-sqlite3 `Database` instance.
10
- * @param database.close Tear down the database connection.
11
- * @param database.exec Execute one or more SQL statements (no params, no results).
12
- * @param database.prepare Prepare a SQL statement for repeated execution.
13
- * @param database.transaction Wrap a function so its statements run in a transaction.
14
- * @experimental
15
- */
3
+ * Create a {@link SqliteAdapter} backed by [better-sqlite3](https://github.com/WiseLibs/better-sqlite3)
4
+ * (a synchronous SQLite3 binding for Node.js).
5
+ *
6
+ * The adapter takes a structural projection of better-sqlite3's `Database` so
7
+ * the package never imports from `better-sqlite3` directly — consumers install
8
+ * it themselves and pass in their database instance.
9
+ * @param database An already-initialised better-sqlite3 `Database` instance.
10
+ * @param database.close Tear down the database connection.
11
+ * @param database.exec Execute one or more SQL statements (no params, no results).
12
+ * @param database.prepare Prepare a SQL statement for repeated execution.
13
+ * @param database.transaction Wrap a function so its statements run in a transaction.
14
+ * @experimental
15
+ */
16
16
  declare const createBetterSqlite3Adapter: (database: {
17
17
  close: () => void;
18
18
  exec: (sql: string) => void;
@@ -1,18 +1,18 @@
1
- import { S as SqliteAdapter } from "../packem_shared/types.d-BuAWjEY5.js";
1
+ import { S as SqliteAdapter } from "../packem_shared/types.d-CkMkSwLJ.js";
2
2
  /**
3
- * Create a {@link SqliteAdapter} backed by [better-sqlite3](https://github.com/WiseLibs/better-sqlite3)
4
- * (a synchronous SQLite3 binding for Node.js).
5
- *
6
- * The adapter takes a structural projection of better-sqlite3's `Database` so
7
- * the package never imports from `better-sqlite3` directly — consumers install
8
- * it themselves and pass in their database instance.
9
- * @param database An already-initialised better-sqlite3 `Database` instance.
10
- * @param database.close Tear down the database connection.
11
- * @param database.exec Execute one or more SQL statements (no params, no results).
12
- * @param database.prepare Prepare a SQL statement for repeated execution.
13
- * @param database.transaction Wrap a function so its statements run in a transaction.
14
- * @experimental
15
- */
3
+ * Create a {@link SqliteAdapter} backed by [better-sqlite3](https://github.com/WiseLibs/better-sqlite3)
4
+ * (a synchronous SQLite3 binding for Node.js).
5
+ *
6
+ * The adapter takes a structural projection of better-sqlite3's `Database` so
7
+ * the package never imports from `better-sqlite3` directly — consumers install
8
+ * it themselves and pass in their database instance.
9
+ * @param database An already-initialised better-sqlite3 `Database` instance.
10
+ * @param database.close Tear down the database connection.
11
+ * @param database.exec Execute one or more SQL statements (no params, no results).
12
+ * @param database.prepare Prepare a SQL statement for repeated execution.
13
+ * @param database.transaction Wrap a function so its statements run in a transaction.
14
+ * @experimental
15
+ */
16
16
  declare const createBetterSqlite3Adapter: (database: {
17
17
  close: () => void;
18
18
  exec: (sql: string) => void;
@@ -1,29 +1 @@
1
- const createBetterSqlite3Adapter = (database) => {
2
- return {
3
- exec(sql, params) {
4
- if (params && params.length > 0) {
5
- database.prepare(sql).run([...params]);
6
- } else {
7
- database.exec(sql);
8
- }
9
- },
10
- query(sql, params) {
11
- const stmt = database.prepare(sql);
12
- const rows = params && params.length > 0 ? stmt.all([...params]) : stmt.all();
13
- return rows;
14
- },
15
- transaction(function_) {
16
- const wrapped = database.transaction(function_);
17
- wrapped();
18
- },
19
- lastInsertRowId() {
20
- const row = database.prepare("SELECT last_insert_rowid() AS id").get();
21
- return Number(row?.id ?? -1);
22
- },
23
- close() {
24
- database.close();
25
- }
26
- };
27
- };
28
-
29
- export { createBetterSqlite3Adapter };
1
+ const a=r=>({exec(e,t){t&&t.length>0?r.prepare(e).run([...t]):r.exec(e)},query(e,t){const n=r.prepare(e);return t&&t.length>0?n.all([...t]):n.all()},transaction(e){r.transaction(e)()},lastInsertRowId(){const e=r.prepare("SELECT last_insert_rowid() AS id").get();return Number(e?.id??-1)},close(){r.close()}});export{a as createBetterSqlite3Adapter};
@@ -1,26 +1,36 @@
1
- import { S as SqliteAdapter } from "../packem_shared/types.d-BuAWjEY5.mjs";
1
+ import { S as SqliteAdapter } from "../packem_shared/types.d-CkMkSwLJ.mjs";
2
2
  /**
3
- * Create a {@link SqliteAdapter} backed by the [official SQLite Wasm](https://www.npmjs.com/package/@sqlite.org/sqlite-wasm)
4
- * (a WebAssembly build of SQLite that runs in browsers and Node.js).
5
- *
6
- * The adapter takes a structural projection of the OO API (`sqlite3.oo1.DB`) so
7
- * the package never imports from `@sqlite.org/sqlite-wasm` directly — consumers
8
- * install it themselves and pass in their database instance.
9
- * @param database An already-initialised `sqlite3.oo1.DB` instance.
10
- * @param database.close Tear down the database connection.
11
- * @param database.exec Execute SQL with optional bind params and return rows
12
- * as `{ columns, values }` result objects.
13
- * @experimental
14
- */
3
+ * Create a {@link SqliteAdapter} backed by the [official SQLite Wasm](https://www.npmjs.com/package/@sqlite.org/sqlite-wasm)
4
+ * (a WebAssembly build of SQLite that runs in browsers and Node.js).
5
+ *
6
+ * The adapter takes a structural projection of the OO API (`sqlite3.oo1.DB`) so
7
+ * the package never imports from `@sqlite.org/sqlite-wasm` directly — consumers
8
+ * install it themselves and pass in their database instance.
9
+ *
10
+ * IMPORTANT (REPLICA-01): the real `oo1.DB.exec()` does NOT return sql.js's
11
+ * `{ columns, values }[]` result shape with `rowMode: "object"` and
12
+ * `returnValue: "resultRows"` it returns the rows directly, as
13
+ * `Record&lt;string, unknown>[]`. This adapter is written against that real
14
+ * shape; `lastInsertRowId` uses the driver's `selectValue()` convenience
15
+ * method (a single-scalar query helper) rather than parsing a result-row
16
+ * array.
17
+ * @param database An already-initialised `sqlite3.oo1.DB` instance.
18
+ * @param database.close Tear down the database connection.
19
+ * @param database.exec Execute SQL with optional bind params. With
20
+ * `{ returnValue: "resultRows", rowMode: "object" }` it returns the matched
21
+ * rows directly (`Record&lt;string, unknown>[]`); otherwise (DDL/DML/BEGIN/
22
+ * COMMIT/ROLLBACK) its return value is unused here.
23
+ * @param database.selectValue Run a query and return the first column of the
24
+ * first row as a single scalar — used for `SELECT last_insert_rowid()`.
25
+ * @experimental
26
+ */
15
27
  declare const createSqliteWasmAdapter: (database: {
16
28
  close: () => void;
17
29
  exec: (sql: string, options?: {
18
30
  bind?: unknown[];
19
- returnValue?: "resultRows" | "simple";
20
- rowMode?: "array" | "object";
21
- }) => {
22
- columns: string[];
23
- values: unknown[][];
24
- }[];
31
+ returnValue?: "resultRows";
32
+ rowMode?: "object";
33
+ }) => Record<string, unknown>[] | undefined;
34
+ selectValue: (sql: string, bind?: unknown[]) => unknown;
25
35
  }) => SqliteAdapter;
26
36
  export { createSqliteWasmAdapter };
@@ -1,26 +1,36 @@
1
- import { S as SqliteAdapter } from "../packem_shared/types.d-BuAWjEY5.js";
1
+ import { S as SqliteAdapter } from "../packem_shared/types.d-CkMkSwLJ.js";
2
2
  /**
3
- * Create a {@link SqliteAdapter} backed by the [official SQLite Wasm](https://www.npmjs.com/package/@sqlite.org/sqlite-wasm)
4
- * (a WebAssembly build of SQLite that runs in browsers and Node.js).
5
- *
6
- * The adapter takes a structural projection of the OO API (`sqlite3.oo1.DB`) so
7
- * the package never imports from `@sqlite.org/sqlite-wasm` directly — consumers
8
- * install it themselves and pass in their database instance.
9
- * @param database An already-initialised `sqlite3.oo1.DB` instance.
10
- * @param database.close Tear down the database connection.
11
- * @param database.exec Execute SQL with optional bind params and return rows
12
- * as `{ columns, values }` result objects.
13
- * @experimental
14
- */
3
+ * Create a {@link SqliteAdapter} backed by the [official SQLite Wasm](https://www.npmjs.com/package/@sqlite.org/sqlite-wasm)
4
+ * (a WebAssembly build of SQLite that runs in browsers and Node.js).
5
+ *
6
+ * The adapter takes a structural projection of the OO API (`sqlite3.oo1.DB`) so
7
+ * the package never imports from `@sqlite.org/sqlite-wasm` directly — consumers
8
+ * install it themselves and pass in their database instance.
9
+ *
10
+ * IMPORTANT (REPLICA-01): the real `oo1.DB.exec()` does NOT return sql.js's
11
+ * `{ columns, values }[]` result shape with `rowMode: "object"` and
12
+ * `returnValue: "resultRows"` it returns the rows directly, as
13
+ * `Record&lt;string, unknown>[]`. This adapter is written against that real
14
+ * shape; `lastInsertRowId` uses the driver's `selectValue()` convenience
15
+ * method (a single-scalar query helper) rather than parsing a result-row
16
+ * array.
17
+ * @param database An already-initialised `sqlite3.oo1.DB` instance.
18
+ * @param database.close Tear down the database connection.
19
+ * @param database.exec Execute SQL with optional bind params. With
20
+ * `{ returnValue: "resultRows", rowMode: "object" }` it returns the matched
21
+ * rows directly (`Record&lt;string, unknown>[]`); otherwise (DDL/DML/BEGIN/
22
+ * COMMIT/ROLLBACK) its return value is unused here.
23
+ * @param database.selectValue Run a query and return the first column of the
24
+ * first row as a single scalar — used for `SELECT last_insert_rowid()`.
25
+ * @experimental
26
+ */
15
27
  declare const createSqliteWasmAdapter: (database: {
16
28
  close: () => void;
17
29
  exec: (sql: string, options?: {
18
30
  bind?: unknown[];
19
- returnValue?: "resultRows" | "simple";
20
- rowMode?: "array" | "object";
21
- }) => {
22
- columns: string[];
23
- values: unknown[][];
24
- }[];
31
+ returnValue?: "resultRows";
32
+ rowMode?: "object";
33
+ }) => Record<string, unknown>[] | undefined;
34
+ selectValue: (sql: string, bind?: unknown[]) => unknown;
25
35
  }) => SqliteAdapter;
26
36
  export { createSqliteWasmAdapter };
@@ -1,56 +1 @@
1
- const createSqliteWasmAdapter = (database) => {
2
- return {
3
- exec(sql, params) {
4
- if (params && params.length > 0) {
5
- database.exec(sql, { bind: [...params] });
6
- } else {
7
- database.exec(sql);
8
- }
9
- },
10
- query(sql, params) {
11
- const options = params && params.length > 0 ? { bind: [...params], returnValue: "resultRows" } : { returnValue: "resultRows" };
12
- const result = database.exec(sql, options);
13
- const first = result[0];
14
- if (!first) {
15
- return [];
16
- }
17
- const colNames = first.columns;
18
- const rows = [];
19
- for (const row of first.values) {
20
- const object = {};
21
- for (const [i, column] of colNames.entries()) {
22
- object[column] = row[i];
23
- }
24
- rows.push(object);
25
- }
26
- return rows;
27
- },
28
- transaction(function_) {
29
- database.exec("BEGIN");
30
- try {
31
- function_();
32
- database.exec("COMMIT");
33
- } catch (error) {
34
- database.exec("ROLLBACK");
35
- throw error;
36
- }
37
- },
38
- lastInsertRowId() {
39
- const result = database.exec("SELECT last_insert_rowid() AS id", { returnValue: "resultRows" });
40
- const firstRow = result[0];
41
- if (result.length === 0 || !firstRow || firstRow.values.length === 0) {
42
- return -1;
43
- }
44
- const value = firstRow.values[0];
45
- if (!value || value.length === 0) {
46
- return -1;
47
- }
48
- return Number(value[0]);
49
- },
50
- close() {
51
- database.close();
52
- }
53
- };
54
- };
55
-
56
- export { createSqliteWasmAdapter };
1
+ const o=c=>({exec(e,t){t&&t.length>0?c.exec(e,{bind:[...t]}):c.exec(e)},query(e,t){return c.exec(e,{bind:t&&t.length>0?[...t]:void 0,returnValue:"resultRows",rowMode:"object"})??[]},transaction(e){c.exec("BEGIN");try{e(),c.exec("COMMIT")}catch(t){throw c.exec("ROLLBACK"),t}},lastInsertRowId(){const e=c.selectValue("SELECT last_insert_rowid()");return typeof e=="number"?e:typeof e=="bigint"?Number(e):-1},close(){c.close()}});export{o as createSqliteWasmAdapter};
@@ -1,14 +1,14 @@
1
- import { S as SqliteAdapter } from "../packem_shared/types.d-BuAWjEY5.mjs";
1
+ import { S as SqliteAdapter } from "../packem_shared/types.d-CkMkSwLJ.mjs";
2
2
  /**
3
- * Create a {@link SqliteAdapter} backed by [sql.js](https://sql.js.org)
4
- * (a WebAssembly build of SQLite that runs in browsers, Node, and
5
- * React Native).
6
- * @param database An already-initialised sql.js database instance.
7
- * @param database.run Execute a parameterised SQL statement (no results).
8
- * @param database.exec Execute SQL and return result rows.
9
- * @param database.close Tear down the database connection.
10
- * @experimental
11
- */
3
+ * Create a {@link SqliteAdapter} backed by [sql.js](https://sql.js.org)
4
+ * (a WebAssembly build of SQLite that runs in browsers, Node, and
5
+ * React Native).
6
+ * @param database An already-initialised sql.js database instance.
7
+ * @param database.run Execute a parameterised SQL statement (no results).
8
+ * @param database.exec Execute SQL and return result rows.
9
+ * @param database.close Tear down the database connection.
10
+ * @experimental
11
+ */
12
12
  declare const createSqlJsAdapter: (database: {
13
13
  close: () => void;
14
14
  exec: (sql: string, params?: unknown[]) => {
@@ -1,14 +1,14 @@
1
- import { S as SqliteAdapter } from "../packem_shared/types.d-BuAWjEY5.js";
1
+ import { S as SqliteAdapter } from "../packem_shared/types.d-CkMkSwLJ.js";
2
2
  /**
3
- * Create a {@link SqliteAdapter} backed by [sql.js](https://sql.js.org)
4
- * (a WebAssembly build of SQLite that runs in browsers, Node, and
5
- * React Native).
6
- * @param database An already-initialised sql.js database instance.
7
- * @param database.run Execute a parameterised SQL statement (no results).
8
- * @param database.exec Execute SQL and return result rows.
9
- * @param database.close Tear down the database connection.
10
- * @experimental
11
- */
3
+ * Create a {@link SqliteAdapter} backed by [sql.js](https://sql.js.org)
4
+ * (a WebAssembly build of SQLite that runs in browsers, Node, and
5
+ * React Native).
6
+ * @param database An already-initialised sql.js database instance.
7
+ * @param database.run Execute a parameterised SQL statement (no results).
8
+ * @param database.exec Execute SQL and return result rows.
9
+ * @param database.close Tear down the database connection.
10
+ * @experimental
11
+ */
12
12
  declare const createSqlJsAdapter: (database: {
13
13
  close: () => void;
14
14
  exec: (sql: string, params?: unknown[]) => {
@@ -1,55 +1 @@
1
- const createSqlJsAdapter = (database) => {
2
- return {
3
- exec(sql, params) {
4
- if (params && params.length > 0) {
5
- database.run(sql, [...params]);
6
- } else {
7
- database.exec(sql);
8
- }
9
- },
10
- query(sql, params) {
11
- const result = params && params.length > 0 ? database.exec(sql, [...params]) : database.exec(sql);
12
- const first = result[0];
13
- if (!first) {
14
- return [];
15
- }
16
- const colNames = first.columns;
17
- const rows = [];
18
- for (const row of first.values) {
19
- const object = {};
20
- for (const [i, column] of colNames.entries()) {
21
- object[column] = row[i];
22
- }
23
- rows.push(object);
24
- }
25
- return rows;
26
- },
27
- transaction(function_) {
28
- database.run("BEGIN");
29
- try {
30
- function_();
31
- database.run("COMMIT");
32
- } catch (error) {
33
- database.run("ROLLBACK");
34
- throw error;
35
- }
36
- },
37
- lastInsertRowId() {
38
- const result = database.exec("SELECT last_insert_rowid() AS id");
39
- const firstRow = result[0];
40
- if (result.length === 0 || !firstRow || firstRow.values.length === 0) {
41
- return -1;
42
- }
43
- const value = firstRow.values[0];
44
- if (!value || value.length === 0) {
45
- return -1;
46
- }
47
- return Number(value[0]);
48
- },
49
- close() {
50
- database.close();
51
- }
52
- };
53
- };
54
-
55
- export { createSqlJsAdapter };
1
+ const h=n=>({exec(e,t){t&&t.length>0?n.run(e,[...t]):n.exec(e)},query(e,t){const r=(t&&t.length>0?n.exec(e,[...t]):n.exec(e))[0];if(!r)return[];const o=r.columns,s=[];for(const u of r.values){const c={};for(const[l,a]of o.entries())c[a]=u[l];s.push(c)}return s},transaction(e){n.run("BEGIN");try{e(),n.run("COMMIT")}catch(t){throw n.run("ROLLBACK"),t}},lastInsertRowId(){const e=n.exec("SELECT last_insert_rowid() AS id"),t=e[0];if(e.length===0||!t||t.values.length===0)return-1;const r=t.values[0];return!r||r.length===0?-1:Number(r[0])},close(){n.close()}});export{h as createSqlJsAdapter};