@symbiote-native/sqlite 0.1.2 → 0.1.3

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 (40) hide show
  1. package/README.md +75 -45
  2. package/build/angular/sqlite.service.js +1 -1
  3. package/build/core/import-database-from-asset.d.ts +3 -0
  4. package/build/core/import-database-from-asset.js +15 -0
  5. package/build/core/index.d.ts +2 -1
  6. package/build/core/index.js +1 -0
  7. package/build/core/native-module.d.ts +2 -0
  8. package/build/core/sqlite-database.d.ts +1 -1
  9. package/build/core/sqlite-database.js +9 -2
  10. package/build/core/types.d.ts +9 -0
  11. package/build/react/sqlite-context.js +3 -8
  12. package/build/solid/sqlite-context.js +2 -1
  13. package/build/svelte/SQLiteProvider.svelte +2 -3
  14. package/build/vue/sqlite-context.js +2 -4
  15. package/build-ngc/angular/sqlite.service.js +1 -1
  16. package/build-ngc/angular/sqlite.service.js.map +1 -1
  17. package/build-ngc/core/import-database-from-asset.d.ts +3 -0
  18. package/build-ngc/core/import-database-from-asset.js +16 -0
  19. package/build-ngc/core/import-database-from-asset.js.map +1 -0
  20. package/build-ngc/core/index.d.ts +2 -1
  21. package/build-ngc/core/index.js +1 -0
  22. package/build-ngc/core/index.js.map +1 -1
  23. package/build-ngc/core/native-module.d.ts +2 -0
  24. package/build-ngc/core/native-module.js.map +1 -1
  25. package/build-ngc/core/sqlite-database.d.ts +1 -1
  26. package/build-ngc/core/sqlite-database.js +9 -2
  27. package/build-ngc/core/sqlite-database.js.map +1 -1
  28. package/build-ngc/core/types.d.ts +9 -0
  29. package/package.json +7 -6
  30. package/src/angular/sqlite.service.ts +1 -1
  31. package/src/core/import-database-from-asset.ts +28 -0
  32. package/src/core/index.ts +3 -0
  33. package/src/core/native-module.ts +6 -0
  34. package/src/core/sqlite-database.ts +12 -2
  35. package/src/core/types.ts +10 -0
  36. package/src/react/sqlite-context.tsx +3 -8
  37. package/src/solid/sqlite-context.ts +2 -1
  38. package/src/svelte/SQLiteProvider.svelte +2 -3
  39. package/src/svelte/svelte-compile.test-helper.ts +53 -15
  40. package/src/vue/sqlite-context.ts +2 -4
package/README.md CHANGED
@@ -2,19 +2,19 @@
2
2
 
3
3
  A wrapper package for [SymbioteNative](../../README.md) that makes
4
4
  [`expo-sqlite`](https://github.com/expo/expo/tree/main/packages/expo-sqlite) usable from every
5
- adapter — `Database`, `Statement`, `Session` (transactions and changesets), a Bun-style SQL
5
+ adapter - `Database`, `Statement`, `Session` (transactions and changesets), a Bun-style SQL
6
6
  tagged-template helper, and a SQLite-backed key-value store. Built the same way as
7
7
  [`@symbiote-native/secure-store`](../secure-store): an `expo-modules-core`-based wrapper (see the
8
- `symbiote-expo-native-module` project skill for the full mechanism — why `expo-modules-core` is
8
+ `symbiote-expo-native-module` project skill for the full mechanism - why `expo-modules-core` is
9
9
  depended on directly and never the `expo` meta-package, why the upstream JS is hand-ported into
10
10
  `core/` rather than imported, and how autolinking picks up the native module).
11
11
 
12
- Every adapter — React, Vue, Svelte, Solid, Angular — ships its own idiomatic `<SQLiteProvider>` /
12
+ Every adapter - React, Vue, Svelte, Solid, Angular - ships its own idiomatic `<SQLiteProvider>` /
13
13
  `useSQLiteContext` equivalent (see "Provider / context" below), reachable from its own subpath.
14
14
  Each subpath re-exports the full `src/core/` barrel too, so importing from `@symbiote-native/sqlite/react`
15
15
  (etc.) is a strict superset of importing from the package root.
16
16
 
17
- expo-sqlite's native classes — `NativeDatabase`, `NativeStatement`, `NativeSession` — are **plain
17
+ expo-sqlite's native classes - `NativeDatabase`, `NativeStatement`, `NativeSession` - are **plain
18
18
  constructors** exposed as properties on the required native module (`new
19
19
  ExpoSQLite.NativeDatabase(...)`), unlike `@symbiote-native/audio`'s JSI-backed `SharedObject`
20
20
  subclasses. There is nothing to subclass here: this package's `SQLiteDatabase` /
@@ -35,24 +35,24 @@ npx @symbiote-native/cli new my-app --sqlite
35
35
  npx @symbiote-native/cli add --sqlite
36
36
  ```
37
37
 
38
- Either way: installs `@symbiote-native/sqlite` and wires the native autolinking automatically — see
38
+ Either way: installs `@symbiote-native/sqlite` and wires the native autolinking automatically - see
39
39
  [`@symbiote-native/cli`](../cli).
40
40
 
41
41
  <details>
42
- <summary>Manual install (no CLI — installing and wiring native autolinking by hand)</summary>
42
+ <summary>Manual install (no CLI - installing and wiring native autolinking by hand)</summary>
43
43
 
44
44
  ```bash
45
45
  npm install @symbiote-native/sqlite
46
46
  ```
47
47
 
48
48
  `expo-sqlite` and `expo-modules-core` come along as regular dependencies, pinned to exact
49
- versions — never install either yourself, and never add the `expo` meta-package to your project
49
+ versions - never install either yourself, and never add the `expo` meta-package to your project
50
50
  (it bundles its own Metro/Babel pipeline, which conflicts with this project's own). `await-lock`
51
51
  is a real runtime dependency of the kv-store (see "Shape" below), not a native-only placeholder.
52
52
 
53
53
  ### Required one-time step: native autolinking wiring
54
54
 
55
- Same one-time step as every other `expo-modules-core` package this project ships — see
55
+ Same one-time step as every other `expo-modules-core` package this project ships - see
56
56
  [`@symbiote-native/local-auth`'s README](../local-auth/README.md#required-one-time-step-native-autolinking-wiring)
57
57
  and the `symbiote-expo-native-module` project skill. Nothing package-specific: iOS autolinks the
58
58
  `Expo` pod automatically; Android's Gradle project + native-module map entry is generated by
@@ -60,7 +60,7 @@ and the `symbiote-expo-native-module` project skill. Nothing package-specific: i
60
60
  `native-link.json` on every install.
61
61
 
62
62
  expo-sqlite compiles its own vendored SQLite amalgamation from source per platform (it does not
63
- link the OS's system `libsqlite3`) — expect `pod install`/the first Android build touching this
63
+ link the OS's system `libsqlite3`) - expect `pod install`/the first Android build touching this
64
64
  package to be noticeably heavier than a package that only links a prebuilt framework. That is
65
65
  expected, not a broken build.
66
66
 
@@ -69,19 +69,19 @@ expected, not a broken build.
69
69
  ## Shape
70
70
 
71
71
  ```
72
- src/core/ native-database.ts / native-statement.ts / native-session.ts — the ambient
72
+ src/core/ native-database.ts / native-statement.ts / native-session.ts - the ambient
73
73
  `declare class` surface expo-sqlite's native module exposes, ported type-only.
74
- native-module.ts — resolves `ExpoSQLite` via expo-modules-core's requireNativeModule.
75
- sqlite-database.ts / sqlite-statement.ts / sqlite-session.ts — the real wrapper
74
+ native-module.ts - resolves `ExpoSQLite` via expo-modules-core's requireNativeModule.
75
+ sqlite-database.ts / sqlite-statement.ts / sqlite-session.ts - the real wrapper
76
76
  classes, holding a native instance and forwarding to it.
77
- sqlite-tagged-query.ts — the `db.sql`...`` tagged-template helper.
78
- storage.ts — SQLiteStorage, the SQLite-backed key-value store (its own subpath, see
79
- below). query-utils.ts / path-utils.ts / param-utils.ts — framework/native-free
77
+ sqlite-tagged-query.ts - the `db.sql`...`` tagged-template helper.
78
+ storage.ts - SQLiteStorage, the SQLite-backed key-value store (its own subpath, see
79
+ below). query-utils.ts / path-utils.ts / param-utils.ts - framework/native-free
80
80
  helpers (SQL-shape parsing, database-path joining, bind-param normalization).
81
81
  ```
82
82
 
83
83
  `@symbiote-native/sqlite/kv-store` is a **separate subpath**, not re-exported from the package
84
- root — `SQLiteStorage`/`AsyncStorage`/`Storage` pull in `await-lock` and open their own database
84
+ root - `SQLiteStorage`/`AsyncStorage`/`Storage` pull in `await-lock` and open their own database
85
85
  lazily on first use; an app that only wants `Database`/`Statement`/`sql` should not pay for that
86
86
  by importing it transitively.
87
87
 
@@ -125,11 +125,11 @@ await AsyncStorage.setItem('token', 'secret');
125
125
  const token = await AsyncStorage.getItem('token'); // string | null
126
126
  ```
127
127
 
128
- ### `onInit` — a deliberate deviation from upstream
128
+ ### `onInit` - a deliberate deviation from upstream
129
129
 
130
130
  Upstream only exposes `onInit` as a `SQLiteProviderProps` field, called by its React
131
131
  `<SQLiteProvider>` after opening, before rendering children. Here `onInit` is exposed directly on
132
- `openDatabaseAsync`/`openDatabaseSync` instead — called once, right after the native handle opens,
132
+ `openDatabaseAsync`/`openDatabaseSync` instead - called once, right after the native handle opens,
133
133
  before the function returns:
134
134
 
135
135
  ```ts
@@ -140,8 +140,8 @@ const db = await openDatabaseAsync('app.db', {
140
140
  });
141
141
  ```
142
142
 
143
- This gives an adapter with no view-tree context — a plain module-scope call, or Angular's
144
- `SqliteService` — a "run this once right after open" hook without needing a Provider to exist
143
+ This gives an adapter with no view-tree context - a plain module-scope call, or Angular's
144
+ `SqliteService` - a "run this once right after open" hook without needing a Provider to exist
145
145
  first. Every Provider above forwards its own `onInit` prop straight into `openDatabaseAsync`
146
146
  rather than calling it a second time. `openDatabaseSync` rejects (throws) if its `onInit` returns
147
147
  a `Promise`, rather than silently racing it.
@@ -152,8 +152,8 @@ Each adapter's Provider opens the database once (closing and reopening if its co
152
152
  change), renders nothing until it resolves, and hands the open `SQLiteDatabase` to descendants.
153
153
  On failure it calls `onError` if given, else the failure propagates through whatever error
154
154
  channel is idiomatic to that framework (a rethrow, an unhandled rejection, a resource-read
155
- throw — see each adapter's own source comment for the exact mechanism). `onInit` is forwarded to
156
- `openDatabaseAsync` (which already runs it — see below), not called a second time.
155
+ throw - see each adapter's own source comment for the exact mechanism). `onInit` is forwarded to
156
+ `openDatabaseAsync` (which already runs it - see below), not called a second time.
157
157
 
158
158
  **React** (`@symbiote-native/sqlite/react`):
159
159
 
@@ -170,7 +170,7 @@ function Main() {
170
170
  }
171
171
  ```
172
172
 
173
- `useSuspense` is also supported (React's own primitive — `<Suspense>` shows its fallback instead
173
+ `useSuspense` is also supported (React's own primitive - `<Suspense>` shows its fallback instead
174
174
  of the Provider rendering `null`).
175
175
 
176
176
  **Vue** (`@symbiote-native/sqlite/vue`):
@@ -203,7 +203,7 @@ import { SQLiteProvider, useSQLiteContext } from '@symbiote-native/sqlite/solid'
203
203
  </SQLiteProvider>;
204
204
  ```
205
205
 
206
- **Angular** (`@symbiote-native/sqlite/angular`) — DI, not a template Provider (this project's
206
+ **Angular** (`@symbiote-native/sqlite/angular`) - DI, not a template Provider (this project's
207
207
  established Angular idiom, see `@symbiote-native/navigation`'s own context service):
208
208
 
209
209
  ```ts
@@ -214,19 +214,43 @@ provideSqliteDatabase({ databaseName: 'app.db', onInit: migrate });
214
214
 
215
215
  // any component/service:
216
216
  constructor(private readonly sqlite: SqliteService) {}
217
- // this.sqlite.database() — an Angular `resource()`-backed signal
217
+ // this.sqlite.database() - an Angular `resource()`-backed signal
218
218
  ```
219
219
 
220
- None of the five ports upstream's `assetSource` option (see "Deliberately out of scope" below).
221
- React's `useSuspense` has no equivalent on the other four — Vue/Solid have their own native
220
+ Upstream's `assetSource` (bundling a database from a `require()`'d asset) is not a separate
221
+ Provider prop here - pass it through the existing `options` prop instead, e.g.
222
+ `options={{ assetSource: { assetId: require('./assets/db.db') } }}`, and every one of the five
223
+ Providers picks it up for free, since each already forwards `options` straight into
224
+ `openDatabaseAsync` (see "Bundling a database from an asset" below).
225
+
226
+ React's `useSuspense` has no equivalent on the other four - Vue/Solid have their own native
222
227
  `<Suspense>`/`createResource` primitives an app can compose around the Provider itself if wanted;
223
228
  Svelte and Angular have none, and none of the four non-React Providers builds a second opt-in
224
- code path for it (a deliberate framework-idiom divergence, not a gap — each adapter's own source
229
+ code path for it (a deliberate framework-idiom divergence, not a gap - each adapter's own source
225
230
  file says so at the top).
226
231
 
232
+ ## Bundling a database from an asset
233
+
234
+ `openDatabaseAsync`'s `assetSource` option (and the standalone `importDatabaseFromAssetAsync` it
235
+ calls) mirror upstream's `SQLiteProvider assetSource` prop, ported against
236
+ `@symbiote-native/asset`'s `Asset` class instead of `expo-asset` directly (same pattern as
237
+ `@symbiote-native/font`/`@symbiote-native/audio`):
238
+
239
+ ```ts
240
+ import { openDatabaseAsync } from '@symbiote-native/sqlite';
241
+
242
+ const db = await openDatabaseAsync('app.db', {
243
+ assetSource: { assetId: require('./assets/app.db'), forceOverwrite: false },
244
+ });
245
+ ```
246
+
247
+ `Asset.fromModule(assetId).downloadAsync()` runs first, then the downloaded file is copied into
248
+ place before the database opens - async only: `openDatabaseSync` throws if given `assetSource`,
249
+ since the asset download itself is unavoidably async.
250
+
227
251
  ## Error handling
228
252
 
229
- Native errors surface as a plain thrown `Error`/rejected `Promise` — upstream's ~12 native
253
+ Native errors surface as a plain thrown `Error`/rejected `Promise` - upstream's ~12 native
230
254
  `Exception`/`GenericException` JS classes are not ported, same convention as every other
231
255
  module-only package this project ships. Trigger conditions, from the vendored native source
232
256
  (`.vendors/expo` @ `origin/sdk-57`, `packages/expo-sqlite/{android,ios}`):
@@ -240,42 +264,48 @@ module-only package this project ships. Trigger conditions, from the vendored na
240
264
  | `Access to closed resource` | Any call on a `SQLiteDatabase`/`SQLiteStatement`/`SQLiteSession` after `close*`/`finalize*`. |
241
265
  | `Invalid bind parameter` | A bind value's type SQLite's C binding layer cannot marshal. |
242
266
  | `Invalid arguments: ...` | A malformed call into the native layer (wrong argument shape). |
243
- | `ERR_INTERNAL_SQLITE_ERROR` (code) / raw SQLite message | SQLite itself rejected the statement — malformed SQL, constraint violation, etc. |
267
+ | `ERR_INTERNAL_SQLITE_ERROR` (code) / raw SQLite message | SQLite itself rejected the statement - malformed SQL, constraint violation, etc. |
244
268
  | `Unsupported operations` | An operation the current build (e.g. a non-libSQL build calling `syncLibSQL()`) does not support. |
245
269
 
246
270
  ## Deliberately out of scope
247
271
 
248
- - **The `assetSource` bundled-database-file option**
249
- (`openDatabaseAsync(name, options, { assetSource })`) — needs `expo-asset`'s
250
- `Asset.fromModule`, which this project deliberately does not depend on (same exclusion class as
251
- `@symbiote-native/audio`'s `Asset`-instance form of `AudioSource` — see that package's README).
252
- A file-copy-based alternative through [`@symbiote-native/file-system`](../file-system)'s
253
- `File`/`Directory` API is possible but not wired here.
254
- - **The `expo-sqlite/plugin` config plugin** (libSQL / `sqlite-vec` extension bundling config) —
272
+ - **The `expo-sqlite/plugin` config plugin** (libSQL / `sqlite-vec` extension bundling config):
255
273
  manual per-app native configuration, same convention as
256
274
  [`@symbiote-native/notifications`'s README](../notifications/README.md) documenting manual
257
275
  Firebase/entitlement setup. `bundledExtensions`/`loadExtensionAsync`/`loadExtensionSync` are
258
276
  still exported and work against whatever extensions your app's own native build actually
259
- bundles — they just require you to wire that bundling yourself.
260
- - **`importAssetDatabaseAsync`** — copies a bundled asset database into place at first launch;
261
- layers on top of the `assetSource` exclusion above, so it is out of scope for the same reason.
262
- - **Web-only surfaces** (`ExpoSQLite.web.ts`, `WebStorage.ts`) — this project targets iOS +
277
+ bundles - they just require you to wire that bundling yourself.
278
+ - **Web-only surfaces** (`ExpoSQLite.web.ts`, `WebStorage.ts`) - this project targets iOS +
263
279
  Android only.
264
- - **expo-sqlite's own DevTools-browser-extension wiring** (`SQLiteDevToolsClient.ts`) — this
280
+ - **expo-sqlite's own DevTools-browser-extension wiring** (`SQLiteDevToolsClient.ts`) - this
265
281
  project has no equivalent of Expo's DevTools plugin.
266
282
 
283
+ ## Common questions
284
+
285
+ - **"Error code 5: database is locked".** Two connections to one file raced for a write lock. Open
286
+ the database once and share the handle; do not reopen it per request.
287
+ - **Concurrent reads return wrong rows.** Reported upstream for a prepared statement shared by
288
+ concurrent reads; prepare per call or serialize.
289
+ - **Pre-populated database?** `assetSource` on `openDatabaseAsync` (async only).
290
+ - **WAL?** Run `PRAGMA journal_mode = WAL` right after opening.
291
+
292
+ Sources: [Expo docs: SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite/),
293
+ [expo/expo#49786](https://github.com/expo/expo/issues/49786),
294
+ [expo/expo#33754](https://github.com/expo/expo/issues/33754),
295
+ [expo/expo#10881](https://github.com/expo/expo/issues/10881).
296
+
267
297
  ## Test it
268
298
 
269
299
  ```bash
270
300
  pnpm vitest run packages/sqlite
271
301
  ```
272
302
 
273
- The core tests fake the native module in place of `requireNativeModule`'s runtime resolution —
303
+ The core tests fake the native module in place of `requireNativeModule`'s runtime resolution:
274
304
  `ExpoSQLite` only exists on a device, so a headless run would otherwise throw at import. Unlike
275
305
  this project's other `expo-modules-core` wrappers, the fake here (`src/core/native-fakes.ts`)
276
306
  wraps a **real [`better-sqlite3`](https://github.com/WiseLibs/better-sqlite3) database** rather
277
- than a hand-rolled stub, so tests exercise genuine SQL behavior — real transactions, real
278
- constraint errors, real column shapes — not a guess at what SQLite would do. `better-sqlite3` is
307
+ than a hand-rolled stub, so tests exercise genuine SQL behavior - real transactions, real
308
+ constraint errors, real column shapes - not a guess at what SQLite would do. `better-sqlite3` is
279
309
  a devDependency only; it is never shipped to a consumer and is excluded from the published
280
310
  tarball alongside the fakes themselves.
281
311
 
@@ -17,7 +17,7 @@
17
17
  // `error()` rather than throwing, exactly like `SQLiteProviderNonSuspense`'s `onError` branch
18
18
  // parks it in React state instead of re-throwing.
19
19
  //
20
- // Deliberately excluded, same as `../core`: `assetSource` (needs `expo-asset`, out of scope).
20
+ // `assetSource` reaches `openDatabaseAsync` via `ISqliteConfig.options`, forwarded below.
21
21
  // No Suspense equivalent — Angular has none.
22
22
  var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
23
23
  function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
@@ -0,0 +1,3 @@
1
+ import type { ISQLiteAssetSource } from './types';
2
+ /** Downloads `assetSource`'s bundled database and copies it into place as `databaseName`. */
3
+ export declare function importDatabaseFromAssetAsync(databaseName: string, assetSource: ISQLiteAssetSource, directory?: string): Promise<void>;
@@ -0,0 +1,15 @@
1
+ // Ported from expo-sqlite's hooks.tsx's importDatabaseFromAssetAsync (.vendors/expo @
2
+ // origin/sdk-57), against @symbiote-native/asset's Asset class instead of importing expo-asset
3
+ // directly (same pattern as packages/font, packages/audio).
4
+ import { Asset } from '@symbiote-native/asset';
5
+ import { expoSQLite } from './native-module.js';
6
+ import { createDatabasePath } from './path-utils.js';
7
+ /** Downloads `assetSource`'s bundled database and copies it into place as `databaseName`. */
8
+ export async function importDatabaseFromAssetAsync(databaseName, assetSource, directory) {
9
+ const asset = await Asset.fromModule(assetSource.assetId).downloadAsync();
10
+ if (!asset.localUri) {
11
+ throw new Error(`Unable to get the localUri from asset ${assetSource.assetId}`);
12
+ }
13
+ const path = createDatabasePath(databaseName, directory);
14
+ await expoSQLite.importAssetDatabaseAsync(path, asset.localUri, assetSource.forceOverwrite ?? false);
15
+ }
@@ -1,5 +1,6 @@
1
1
  export { SQLiteDatabase, defaultDatabaseDirectory, bundledExtensions, openDatabaseAsync, openDatabaseSync, deserializeDatabaseAsync, deserializeDatabaseSync, deleteDatabaseAsync, deleteDatabaseSync, backupDatabaseAsync, backupDatabaseSync, addDatabaseChangeListener, } from './sqlite-database';
2
- export type { ISQLiteOpenOptions, IDatabaseChangeEvent, IOnInitCallback, IOpenDatabaseOptions, } from './sqlite-database';
2
+ export type { ISQLiteOpenOptions, IDatabaseChangeEvent, IOnInitCallback, IOpenDatabaseOptions, ISQLiteAssetSource, } from './sqlite-database';
3
+ export { importDatabaseFromAssetAsync } from './import-database-from-asset';
3
4
  export { SQLiteStatement } from './sqlite-statement';
4
5
  export type { ISQLiteBindParams, ISQLiteBindValue, ISQLiteExecuteAsyncResult, ISQLiteExecuteSyncResult, ISQLiteRunResult, ISQLiteVariadicBindParams, } from './sqlite-statement';
5
6
  export { SQLiteSession } from './sqlite-session';
@@ -1,4 +1,5 @@
1
1
  export { SQLiteDatabase, defaultDatabaseDirectory, bundledExtensions, openDatabaseAsync, openDatabaseSync, deserializeDatabaseAsync, deserializeDatabaseSync, deleteDatabaseAsync, deleteDatabaseSync, backupDatabaseAsync, backupDatabaseSync, addDatabaseChangeListener, } from './sqlite-database.js';
2
+ export { importDatabaseFromAssetAsync } from './import-database-from-asset.js';
2
3
  export { SQLiteStatement } from './sqlite-statement.js';
3
4
  export { SQLiteSession } from './sqlite-session.js';
4
5
  export { SQLiteTaggedQuery } from './sqlite-tagged-query.js';
@@ -16,6 +16,8 @@ export type INativeSQLiteModule = {
16
16
  } | undefined>;
17
17
  ensureDatabasePathExistsAsync(databasePath: string): Promise<void>;
18
18
  ensureDatabasePathExistsSync(databasePath: string): void;
19
+ /** Copies `assetDatabasePath` (a downloaded `Asset.localUri`) to `databasePath`. */
20
+ importAssetDatabaseAsync(databasePath: string, assetDatabasePath: string, forceOverwrite: boolean): Promise<void>;
19
21
  deleteDatabaseAsync(databasePath: string): Promise<void>;
20
22
  deleteDatabaseSync(databasePath: string): void;
21
23
  backupDatabaseAsync(destDatabase: NativeDatabase, destDatabaseName: string, sourceDatabase: NativeDatabase, sourceDatabaseName: string): Promise<void>;
@@ -7,7 +7,7 @@ import type { ISQLiteBindParams, ISQLiteRunResult, ISQLiteVariadicBindParams } f
7
7
  import { SQLiteTaggedQuery } from './sqlite-tagged-query';
8
8
  import type { IDatabaseChangeEvent, IOpenDatabaseOptions } from './types';
9
9
  export type { ISQLiteOpenOptions } from './native-database';
10
- export type { IDatabaseChangeEvent, IOnInitCallback, IOpenDatabaseOptions, } from './types';
10
+ export type { IDatabaseChangeEvent, IOnInitCallback, IOpenDatabaseOptions, ISQLiteAssetSource, } from './types';
11
11
  /** A SQLite database. */
12
12
  export declare class SQLiteDatabase {
13
13
  readonly databasePath: string;
@@ -11,6 +11,7 @@ import { SQLiteSession } from './sqlite-session.js';
11
11
  import { SQLiteStatement } from './sqlite-statement.js';
12
12
  import { SQLiteTaggedQuery } from './sqlite-tagged-query.js';
13
13
  import { createDatabasePath } from './path-utils.js';
14
+ import { importDatabaseFromAssetAsync } from './import-database-from-asset.js';
14
15
  /** A SQLite database. */
15
16
  export class SQLiteDatabase {
16
17
  databasePath;
@@ -325,7 +326,10 @@ async function runOnInit(db, onInit) {
325
326
  * `defaultDatabaseDirectory`.
326
327
  */
327
328
  export async function openDatabaseAsync(databaseName, options, directory) {
328
- const { onInit, ...openOptions } = options ?? {};
329
+ const { onInit, assetSource, ...openOptions } = options ?? {};
330
+ if (assetSource != null) {
331
+ await importDatabaseFromAssetAsync(databaseName, assetSource, directory);
332
+ }
329
333
  const databasePath = createDatabasePath(databaseName, directory);
330
334
  await expoSQLite.ensureDatabasePathExistsAsync(databasePath);
331
335
  const nativeDatabase = new expoSQLite.NativeDatabase(databasePath, flattenOpenOptions(openOptions));
@@ -339,7 +343,10 @@ export async function openDatabaseAsync(databaseName, options, directory) {
339
343
  * > **Note:** Running heavy tasks with this function can block the JavaScript thread.
340
344
  */
341
345
  export function openDatabaseSync(databaseName, options, directory) {
342
- const { onInit, ...openOptions } = options ?? {};
346
+ const { onInit, assetSource, ...openOptions } = options ?? {};
347
+ if (assetSource != null) {
348
+ throw new Error('assetSource needs Asset.downloadAsync(), which is async — use openDatabaseAsync instead');
349
+ }
343
350
  const databasePath = createDatabasePath(databaseName, directory);
344
351
  expoSQLite.ensureDatabasePathExistsSync(databasePath);
345
352
  const nativeDatabase = new expoSQLite.NativeDatabase(databasePath, flattenOpenOptions(openOptions));
@@ -25,6 +25,15 @@ export type IDatabaseChangeEvent = {
25
25
  * callback itself; that choice is left to that later pass.
26
26
  */
27
27
  export type IOnInitCallback = (db: SQLiteDatabase) => Promise<void> | void;
28
+ /** A bundled database file to import on first open, via `@symbiote-native/asset`. */
29
+ export type ISQLiteAssetSource = {
30
+ /** The asset id from `require('./assets/db.db')`. */
31
+ assetId: number;
32
+ /** Overwrite the local database file even if it already exists. @default false */
33
+ forceOverwrite?: boolean;
34
+ };
28
35
  export type IOpenDatabaseOptions = ISQLiteOpenOptions & {
29
36
  onInit?: IOnInitCallback;
37
+ /** Async-only — see `importDatabaseFromAssetAsync`; ignored by `openDatabaseSync`. */
38
+ assetSource?: ISQLiteAssetSource;
30
39
  };
@@ -1,12 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- // React <SQLiteProvider> + useSQLiteContext(), ported from expo-sqlite's hooks.tsx (sdk-57,
3
- // .vendors/expo) onto this package's own openDatabaseAsync/SQLiteDatabase. Deliberately excludes
4
- // `assetSource` (bundling a database from a require()'d asset needs expo-asset, out of scope for
5
- // this pass — see the README). React 19's built-in `use()` replaces upstream's private
6
- // Suspense-promise polyfill (~40 LOC of `ReactUsePromise` plumbing, unnecessary now that the
7
- // peer range is react >=19.0.0). Unlike upstream, `onInit` is NOT invoked here — this package's
8
- // own `openDatabaseAsync` already runs it internally before resolving (see
9
- // `IOnInitCallback`'s doc comment in `core/types.ts`), so the provider only has to forward it.
2
+ // React <SQLiteProvider> + useSQLiteContext(), ported from expo-sqlite's hooks.tsx (sdk-57).
3
+ // `assetSource` reaches `openDatabaseAsync` via the `options` prop — see the README.
4
+ // `onInit` is forwarded, not invoked — `openDatabaseAsync` already runs it (core/types.ts).
10
5
  import { createContext, memo, use, useContext, useEffect, useRef, useState, } from 'react';
11
6
  import { openDatabaseAsync, } from '../core/index.js';
12
7
  const SQLiteContext = createContext(null);
@@ -26,7 +26,8 @@
26
26
  // variable (not read through the resource accessor) so `onCleanup` never has to read a possibly
27
27
  // -errored resource, which would itself throw during teardown.
28
28
  //
29
- // assetSource is deliberately NOT ported: it needs expo-asset, out of scope (see the README).
29
+ // assetSource reaches openDatabaseAsync via the options prop, forwarded below — not a separate
30
+ // prop here.
30
31
  // useSuspense is deliberately NOT offered: Solid's own <Suspense> already composes with a plain
31
32
  // createResource-backed component with zero extra code (any ancestor <Suspense> defers on this
32
33
  // resource for free), so there is no second, opt-in code path to build the way React needs one —
@@ -11,9 +11,8 @@
11
11
  // resolves later, so the getter is handed out immediately and its underlying `$state` is
12
12
  // written once the effect settles.
13
13
  //
14
- // Deliberately excludes `assetSource` (needs `expo-asset`, out of scope for this package — see
15
- // the core layer's own IOnInitCallback doc comment) and `useSuspense` (Svelte has no built-in
16
- // Suspense primitive).
14
+ // `assetSource` reaches `openDatabaseAsync` via `options`, forwarded below — not a separate
15
+ // prop here. `useSuspense` is not offered: Svelte has no built-in Suspense primitive.
17
16
  //
18
17
  // Unlike upstream, `onInit` is not called from here — this package's own `openDatabaseAsync`
19
18
  // already runs it internally before resolving (see `IOnInitCallback`'s doc comment in
@@ -4,11 +4,9 @@
4
4
  // Vue's own provide/inject, following packages/navigation/src/vue/navigation-context.ts's shape
5
5
  // (a symbol-keyed InjectionKey, a `require*` getter that throws with a hook-scoped message).
6
6
  //
7
- // Deliberately excluded, mirroring core's own `IOpenDatabaseOptions` (see core/types.ts):
8
- // `assetSource` — needs `expo-asset`, out of scope for this package.
7
+ // `assetSource` reaches `openDatabaseAsync` via the `options` prop, not a separate prop here.
9
8
  // Deliberately excluded, this pass only: Suspense integration (`useSuspense`). Vue has its own
10
- // `<Suspense>` + async `setup()` idiom instead of React's `use()`; wiring this Provider into it is
11
- // a separate, later decision, not a straight port of React's `useSuspense` flag.
9
+ // `<Suspense>`/async `setup()` idiom instead of React's `use()`; wiring it in is a later decision.
12
10
  import { defineComponent, inject, onUnmounted, provide, shallowRef, watch, } from '@vue/runtime-core';
13
11
  import { openDatabaseAsync } from '../core/index.js';
14
12
  const SQLITE_CONTEXT_KEY = Symbol('sqlite-context');
@@ -17,7 +17,7 @@
17
17
  // `error()` rather than throwing, exactly like `SQLiteProviderNonSuspense`'s `onError` branch
18
18
  // parks it in React state instead of re-throwing.
19
19
  //
20
- // Deliberately excluded, same as `../core`: `assetSource` (needs `expo-asset`, out of scope).
20
+ // `assetSource` reaches `openDatabaseAsync` via `ISqliteConfig.options`, forwarded below.
21
21
  // No Suspense equivalent — Angular has none.
22
22
  import { Injectable, InjectionToken, effect, inject, resource, signal, } from '@angular/core';
23
23
  import { openDatabaseAsync } from '../core';
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite.service.js","sourceRoot":"","sources":["../../src/angular/sqlite.service.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,+FAA+F;AAC/F,uEAAuE;AACvE,EAAE;AACF,kEAAkE;AAClE,iFAAiF;AACjF,6FAA6F;AAC7F,gGAAgG;AAChG,2FAA2F;AAC3F,oCAAoC;AACpC,EAAE;AACF,6FAA6F;AAC7F,0FAA0F;AAC1F,iGAAiG;AACjG,6FAA6F;AAC7F,iGAAiG;AACjG,8FAA8F;AAC9F,kDAAkD;AAClD,EAAE;AACF,8FAA8F;AAC9F,6CAA6C;AAE7C,OAAO,EACL,UAAU,EACV,cAAc,EACd,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,GAGP,MAA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AAI,CAAC,cAAc,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,mEAAmE;IACnE,IAAI,CAAC,MAAqB;QACxB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,qFAAqF;IACrF,4FAA4F;IAC5F,+FAA+F;IAC/F,8DAA8D;IAC9D,WAAW;QACT,wFAAwF;QACxF,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE;YAAE,OAAO;QACxC,KAAK,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,UAAU,EAAE,CAAC;IAC5C,CAAC;uGAjDU,aAAa;2GAAb,aAAa,cADA,MAAM;;2FACnB,aAAa;kBADzB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
@@ -0,0 +1,3 @@
1
+ import type { ISQLiteAssetSource } from './types';
2
+ /** Downloads `assetSource`'s bundled database and copies it into place as `databaseName`. */
3
+ export declare function importDatabaseFromAssetAsync(databaseName: string, assetSource: ISQLiteAssetSource, directory?: string): Promise<void>;
@@ -0,0 +1,16 @@
1
+ // Ported from expo-sqlite's hooks.tsx's importDatabaseFromAssetAsync (.vendors/expo @
2
+ // origin/sdk-57), against @symbiote-native/asset's Asset class instead of importing expo-asset
3
+ // directly (same pattern as packages/font, packages/audio).
4
+ import { Asset } from '@symbiote-native/asset';
5
+ import { expoSQLite } from './native-module';
6
+ import { createDatabasePath } from './path-utils';
7
+ /** Downloads `assetSource`'s bundled database and copies it into place as `databaseName`. */
8
+ export async function importDatabaseFromAssetAsync(databaseName, assetSource, directory) {
9
+ const asset = await Asset.fromModule(assetSource.assetId).downloadAsync();
10
+ if (!asset.localUri) {
11
+ throw new Error(`Unable to get the localUri from asset ${assetSource.assetId}`);
12
+ }
13
+ const path = createDatabasePath(databaseName, directory);
14
+ await expoSQLite.importAssetDatabaseAsync(path, asset.localUri, assetSource.forceOverwrite ?? false);
15
+ }
16
+ //# sourceMappingURL=import-database-from-asset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-database-from-asset.js","sourceRoot":"","sources":["../../src/core/import-database-from-asset.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,+FAA+F;AAC/F,4DAA4D;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGlD,6FAA6F;AAC7F,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,YAAoB,EACpB,WAA+B,EAC/B,SAAkB;IAElB,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,CAAC;IAC1E,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,yCAAyC,WAAW,CAAC,OAAO,EAAE,CAC/D,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,GAAG,kBAAkB,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IACzD,MAAM,UAAU,CAAC,wBAAwB,CACvC,IAAI,EACJ,KAAK,CAAC,QAAQ,EACd,WAAW,CAAC,cAAc,IAAI,KAAK,CACpC,CAAC;AACJ,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export { SQLiteDatabase, defaultDatabaseDirectory, bundledExtensions, openDatabaseAsync, openDatabaseSync, deserializeDatabaseAsync, deserializeDatabaseSync, deleteDatabaseAsync, deleteDatabaseSync, backupDatabaseAsync, backupDatabaseSync, addDatabaseChangeListener, } from './sqlite-database';
2
- export type { ISQLiteOpenOptions, IDatabaseChangeEvent, IOnInitCallback, IOpenDatabaseOptions, } from './sqlite-database';
2
+ export type { ISQLiteOpenOptions, IDatabaseChangeEvent, IOnInitCallback, IOpenDatabaseOptions, ISQLiteAssetSource, } from './sqlite-database';
3
+ export { importDatabaseFromAssetAsync } from './import-database-from-asset';
3
4
  export { SQLiteStatement } from './sqlite-statement';
4
5
  export type { ISQLiteBindParams, ISQLiteBindValue, ISQLiteExecuteAsyncResult, ISQLiteExecuteSyncResult, ISQLiteRunResult, ISQLiteVariadicBindParams, } from './sqlite-statement';
5
6
  export { SQLiteSession } from './sqlite-session';
@@ -1,4 +1,5 @@
1
1
  export { SQLiteDatabase, defaultDatabaseDirectory, bundledExtensions, openDatabaseAsync, openDatabaseSync, deserializeDatabaseAsync, deserializeDatabaseSync, deleteDatabaseAsync, deleteDatabaseSync, backupDatabaseAsync, backupDatabaseSync, addDatabaseChangeListener, } from './sqlite-database';
2
+ export { importDatabaseFromAssetAsync } from './import-database-from-asset';
2
3
  export { SQLiteStatement } from './sqlite-statement';
3
4
  export { SQLiteSession } from './sqlite-session';
4
5
  export { SQLiteTaggedQuery } from './sqlite-tagged-query';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAQ3B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAUrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAS3B,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAUrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC"}
@@ -16,6 +16,8 @@ export type INativeSQLiteModule = {
16
16
  } | undefined>;
17
17
  ensureDatabasePathExistsAsync(databasePath: string): Promise<void>;
18
18
  ensureDatabasePathExistsSync(databasePath: string): void;
19
+ /** Copies `assetDatabasePath` (a downloaded `Asset.localUri`) to `databasePath`. */
20
+ importAssetDatabaseAsync(databasePath: string, assetDatabasePath: string, forceOverwrite: boolean): Promise<void>;
19
21
  deleteDatabaseAsync(databasePath: string): Promise<void>;
20
22
  deleteDatabaseSync(databasePath: string): void;
21
23
  backupDatabaseAsync(destDatabase: NativeDatabase, destDatabaseName: string, sourceDatabase: NativeDatabase, sourceDatabaseName: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"native-module.js","sourceRoot":"","sources":["../../src/core/native-module.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,4EAA4E;AAC5E,gGAAgG;AAChG,2FAA2F;AAC3F,4CAA4C;AAC5C,8FAA8F;AAC9F,EAAE;AACF,6FAA6F;AAC7F,6FAA6F;AAC7F,oFAAoF;AACpF,mCAAmC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAmC7C,MAAM,CAAC,MAAM,UAAU,GAAG,mBAAmB,CAC3C,uBAAuB,CACxB,CAAC"}
1
+ {"version":3,"file":"native-module.js","sourceRoot":"","sources":["../../src/core/native-module.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,4EAA4E;AAC5E,gGAAgG;AAChG,2FAA2F;AAC3F,4CAA4C;AAC5C,8FAA8F;AAC9F,EAAE;AACF,6FAA6F;AAC7F,6FAA6F;AAC7F,oFAAoF;AACpF,mCAAmC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAyC7C,MAAM,CAAC,MAAM,UAAU,GAAG,mBAAmB,CAC3C,uBAAuB,CACxB,CAAC"}
@@ -7,7 +7,7 @@ import type { ISQLiteBindParams, ISQLiteRunResult, ISQLiteVariadicBindParams } f
7
7
  import { SQLiteTaggedQuery } from './sqlite-tagged-query';
8
8
  import type { IDatabaseChangeEvent, IOpenDatabaseOptions } from './types';
9
9
  export type { ISQLiteOpenOptions } from './native-database';
10
- export type { IDatabaseChangeEvent, IOnInitCallback, IOpenDatabaseOptions, } from './types';
10
+ export type { IDatabaseChangeEvent, IOnInitCallback, IOpenDatabaseOptions, ISQLiteAssetSource, } from './types';
11
11
  /** A SQLite database. */
12
12
  export declare class SQLiteDatabase {
13
13
  readonly databasePath: string;
@@ -11,6 +11,7 @@ import { SQLiteSession } from './sqlite-session';
11
11
  import { SQLiteStatement } from './sqlite-statement';
12
12
  import { SQLiteTaggedQuery } from './sqlite-tagged-query';
13
13
  import { createDatabasePath } from './path-utils';
14
+ import { importDatabaseFromAssetAsync } from './import-database-from-asset';
14
15
  /** A SQLite database. */
15
16
  export class SQLiteDatabase {
16
17
  databasePath;
@@ -325,7 +326,10 @@ async function runOnInit(db, onInit) {
325
326
  * `defaultDatabaseDirectory`.
326
327
  */
327
328
  export async function openDatabaseAsync(databaseName, options, directory) {
328
- const { onInit, ...openOptions } = options ?? {};
329
+ const { onInit, assetSource, ...openOptions } = options ?? {};
330
+ if (assetSource != null) {
331
+ await importDatabaseFromAssetAsync(databaseName, assetSource, directory);
332
+ }
329
333
  const databasePath = createDatabasePath(databaseName, directory);
330
334
  await expoSQLite.ensureDatabasePathExistsAsync(databasePath);
331
335
  const nativeDatabase = new expoSQLite.NativeDatabase(databasePath, flattenOpenOptions(openOptions));
@@ -339,7 +343,10 @@ export async function openDatabaseAsync(databaseName, options, directory) {
339
343
  * > **Note:** Running heavy tasks with this function can block the JavaScript thread.
340
344
  */
341
345
  export function openDatabaseSync(databaseName, options, directory) {
342
- const { onInit, ...openOptions } = options ?? {};
346
+ const { onInit, assetSource, ...openOptions } = options ?? {};
347
+ if (assetSource != null) {
348
+ throw new Error('assetSource needs Asset.downloadAsync(), which is async — use openDatabaseAsync instead');
349
+ }
343
350
  const databasePath = createDatabasePath(databaseName, directory);
344
351
  expoSQLite.ensureDatabasePathExistsSync(databasePath);
345
352
  const nativeDatabase = new expoSQLite.NativeDatabase(databasePath, flattenOpenOptions(openOptions));
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite-database.js","sourceRoot":"","sources":["../../src/core/sqlite-database.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,+FAA+F;AAC/F,EAAE;AACF,sFAAsF;AACtF,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;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAA+C;IAE/C,OAAO,UAAU,CAAC,WAAW,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,MAAM,iBAAkB,SAAQ,cAAc;IACrC,MAAM,CAAC,KAAK,CAAC,WAAW,CAC7B,EAAkB;QAElB,MAAM,OAAO,GAAuB;YAClC,GAAG,EAAE,CAAC,OAAO;YACb,gBAAgB,EAAE,IAAI;SACvB,CAAC;QACF,MAAM,cAAc,GAAG,IAAI,UAAU,CAAC,cAAc,CAClD,EAAE,CAAC,YAAY,EACf,kBAAkB,CAAC,OAAO,CAAC,CAC5B,CAAC;QACF,MAAM,cAAc,CAAC,SAAS,EAAE,CAAC;QACjC,OAAO,IAAI,iBAAiB,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IACzE,CAAC;CACF"}
@@ -25,6 +25,15 @@ export type IDatabaseChangeEvent = {
25
25
  * callback itself; that choice is left to that later pass.
26
26
  */
27
27
  export type IOnInitCallback = (db: SQLiteDatabase) => Promise<void> | void;
28
+ /** A bundled database file to import on first open, via `@symbiote-native/asset`. */
29
+ export type ISQLiteAssetSource = {
30
+ /** The asset id from `require('./assets/db.db')`. */
31
+ assetId: number;
32
+ /** Overwrite the local database file even if it already exists. @default false */
33
+ forceOverwrite?: boolean;
34
+ };
28
35
  export type IOpenDatabaseOptions = ISQLiteOpenOptions & {
29
36
  onInit?: IOnInitCallback;
37
+ /** Async-only — see `importDatabaseFromAssetAsync`; ignored by `openDatabaseSync`. */
38
+ assetSource?: ISQLiteAssetSource;
30
39
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbiote-native/sqlite",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "expo-sqlite wrapped for SymbioteNative — one framework-agnostic core, built once and reachable from the React, Vue, Svelte, Solid, and Angular adapters. Database / Statement / Session (transactions, changesets), a Bun-style SQL tagged-template helper, and a SQLite-backed key-value store.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -76,8 +76,9 @@
76
76
  },
77
77
  "dependencies": {
78
78
  "expo-sqlite": "57.0.2",
79
- "expo-modules-core": "57.0.5",
80
- "await-lock": "^2.2.2"
79
+ "expo-modules-core": "57.0.20",
80
+ "await-lock": "^2.2.2",
81
+ "@symbiote-native/asset": "0.1.1"
81
82
  },
82
83
  "peerDependencies": {
83
84
  "react-native": ">=0.86",
@@ -128,9 +129,9 @@
128
129
  "@angular/common": "~22.0.8",
129
130
  "@angular/compiler": "~22.0.8",
130
131
  "@angular/compiler-cli": "~22.0.8",
131
- "@symbiote-native/svelte": "3.0.4",
132
- "@symbiote-native/engine": "1.3.1",
133
- "@symbiote-native/test-utils": "0.4.4"
132
+ "@symbiote-native/svelte": "3.1.0",
133
+ "@symbiote-native/engine": "1.5.0",
134
+ "@symbiote-native/test-utils": "0.4.6"
134
135
  },
135
136
  "scripts": {
136
137
  "clean": "rm -rf build-ngc",
@@ -17,7 +17,7 @@
17
17
  // `error()` rather than throwing, exactly like `SQLiteProviderNonSuspense`'s `onError` branch
18
18
  // parks it in React state instead of re-throwing.
19
19
  //
20
- // Deliberately excluded, same as `../core`: `assetSource` (needs `expo-asset`, out of scope).
20
+ // `assetSource` reaches `openDatabaseAsync` via `ISqliteConfig.options`, forwarded below.
21
21
  // No Suspense equivalent — Angular has none.
22
22
 
23
23
  import {
@@ -0,0 +1,28 @@
1
+ // Ported from expo-sqlite's hooks.tsx's importDatabaseFromAssetAsync (.vendors/expo @
2
+ // origin/sdk-57), against @symbiote-native/asset's Asset class instead of importing expo-asset
3
+ // directly (same pattern as packages/font, packages/audio).
4
+ import { Asset } from '@symbiote-native/asset';
5
+
6
+ import { expoSQLite } from './native-module';
7
+ import { createDatabasePath } from './path-utils';
8
+ import type { ISQLiteAssetSource } from './types';
9
+
10
+ /** Downloads `assetSource`'s bundled database and copies it into place as `databaseName`. */
11
+ export async function importDatabaseFromAssetAsync(
12
+ databaseName: string,
13
+ assetSource: ISQLiteAssetSource,
14
+ directory?: string,
15
+ ): Promise<void> {
16
+ const asset = await Asset.fromModule(assetSource.assetId).downloadAsync();
17
+ if (!asset.localUri) {
18
+ throw new Error(
19
+ `Unable to get the localUri from asset ${assetSource.assetId}`,
20
+ );
21
+ }
22
+ const path = createDatabasePath(databaseName, directory);
23
+ await expoSQLite.importAssetDatabaseAsync(
24
+ path,
25
+ asset.localUri,
26
+ assetSource.forceOverwrite ?? false,
27
+ );
28
+ }
package/src/core/index.ts CHANGED
@@ -17,8 +17,11 @@ export type {
17
17
  IDatabaseChangeEvent,
18
18
  IOnInitCallback,
19
19
  IOpenDatabaseOptions,
20
+ ISQLiteAssetSource,
20
21
  } from './sqlite-database';
21
22
 
23
+ export { importDatabaseFromAssetAsync } from './import-database-from-asset';
24
+
22
25
  export { SQLiteStatement } from './sqlite-statement';
23
26
  export type {
24
27
  ISQLiteBindParams,
@@ -32,6 +32,12 @@ export type INativeSQLiteModule = {
32
32
  >;
33
33
  ensureDatabasePathExistsAsync(databasePath: string): Promise<void>;
34
34
  ensureDatabasePathExistsSync(databasePath: string): void;
35
+ /** Copies `assetDatabasePath` (a downloaded `Asset.localUri`) to `databasePath`. */
36
+ importAssetDatabaseAsync(
37
+ databasePath: string,
38
+ assetDatabasePath: string,
39
+ forceOverwrite: boolean,
40
+ ): Promise<void>;
35
41
  deleteDatabaseAsync(databasePath: string): Promise<void>;
36
42
  deleteDatabaseSync(databasePath: string): void;
37
43
  backupDatabaseAsync(
@@ -21,6 +21,7 @@ import type {
21
21
  } from './sqlite-statement';
22
22
  import { SQLiteTaggedQuery } from './sqlite-tagged-query';
23
23
  import { createDatabasePath } from './path-utils';
24
+ import { importDatabaseFromAssetAsync } from './import-database-from-asset';
24
25
  import type {
25
26
  IDatabaseChangeEvent,
26
27
  IOnInitCallback,
@@ -32,6 +33,7 @@ export type {
32
33
  IDatabaseChangeEvent,
33
34
  IOnInitCallback,
34
35
  IOpenDatabaseOptions,
36
+ ISQLiteAssetSource,
35
37
  } from './types';
36
38
 
37
39
  /** A SQLite database. */
@@ -496,7 +498,10 @@ export async function openDatabaseAsync(
496
498
  options?: IOpenDatabaseOptions,
497
499
  directory?: string,
498
500
  ): Promise<SQLiteDatabase> {
499
- const { onInit, ...openOptions } = options ?? {};
501
+ const { onInit, assetSource, ...openOptions } = options ?? {};
502
+ if (assetSource != null) {
503
+ await importDatabaseFromAssetAsync(databaseName, assetSource, directory);
504
+ }
500
505
  const databasePath = createDatabasePath(databaseName, directory);
501
506
  await expoSQLite.ensureDatabasePathExistsAsync(databasePath);
502
507
  const nativeDatabase = new expoSQLite.NativeDatabase(
@@ -522,7 +527,12 @@ export function openDatabaseSync(
522
527
  options?: IOpenDatabaseOptions,
523
528
  directory?: string,
524
529
  ): SQLiteDatabase {
525
- const { onInit, ...openOptions } = options ?? {};
530
+ const { onInit, assetSource, ...openOptions } = options ?? {};
531
+ if (assetSource != null) {
532
+ throw new Error(
533
+ 'assetSource needs Asset.downloadAsync(), which is async — use openDatabaseAsync instead',
534
+ );
535
+ }
526
536
  const databasePath = createDatabasePath(databaseName, directory);
527
537
  expoSQLite.ensureDatabasePathExistsSync(databasePath);
528
538
  const nativeDatabase = new expoSQLite.NativeDatabase(
package/src/core/types.ts CHANGED
@@ -28,6 +28,16 @@ export type IDatabaseChangeEvent = {
28
28
  */
29
29
  export type IOnInitCallback = (db: SQLiteDatabase) => Promise<void> | void;
30
30
 
31
+ /** A bundled database file to import on first open, via `@symbiote-native/asset`. */
32
+ export type ISQLiteAssetSource = {
33
+ /** The asset id from `require('./assets/db.db')`. */
34
+ assetId: number;
35
+ /** Overwrite the local database file even if it already exists. @default false */
36
+ forceOverwrite?: boolean;
37
+ };
38
+
31
39
  export type IOpenDatabaseOptions = ISQLiteOpenOptions & {
32
40
  onInit?: IOnInitCallback;
41
+ /** Async-only — see `importDatabaseFromAssetAsync`; ignored by `openDatabaseSync`. */
42
+ assetSource?: ISQLiteAssetSource;
33
43
  };
@@ -1,11 +1,6 @@
1
- // React <SQLiteProvider> + useSQLiteContext(), ported from expo-sqlite's hooks.tsx (sdk-57,
2
- // .vendors/expo) onto this package's own openDatabaseAsync/SQLiteDatabase. Deliberately excludes
3
- // `assetSource` (bundling a database from a require()'d asset needs expo-asset, out of scope for
4
- // this pass — see the README). React 19's built-in `use()` replaces upstream's private
5
- // Suspense-promise polyfill (~40 LOC of `ReactUsePromise` plumbing, unnecessary now that the
6
- // peer range is react >=19.0.0). Unlike upstream, `onInit` is NOT invoked here — this package's
7
- // own `openDatabaseAsync` already runs it internally before resolving (see
8
- // `IOnInitCallback`'s doc comment in `core/types.ts`), so the provider only has to forward it.
1
+ // React <SQLiteProvider> + useSQLiteContext(), ported from expo-sqlite's hooks.tsx (sdk-57).
2
+ // `assetSource` reaches `openDatabaseAsync` via the `options` prop — see the README.
3
+ // `onInit` is forwarded, not invoked — `openDatabaseAsync` already runs it (core/types.ts).
9
4
 
10
5
  import {
11
6
  createContext,
@@ -26,7 +26,8 @@
26
26
  // variable (not read through the resource accessor) so `onCleanup` never has to read a possibly
27
27
  // -errored resource, which would itself throw during teardown.
28
28
  //
29
- // assetSource is deliberately NOT ported: it needs expo-asset, out of scope (see the README).
29
+ // assetSource reaches openDatabaseAsync via the options prop, forwarded below — not a separate
30
+ // prop here.
30
31
  // useSuspense is deliberately NOT offered: Solid's own <Suspense> already composes with a plain
31
32
  // createResource-backed component with zero extra code (any ancestor <Suspense> defers on this
32
33
  // resource for free), so there is no second, opt-in code path to build the way React needs one —
@@ -11,9 +11,8 @@
11
11
  // resolves later, so the getter is handed out immediately and its underlying `$state` is
12
12
  // written once the effect settles.
13
13
  //
14
- // Deliberately excludes `assetSource` (needs `expo-asset`, out of scope for this package — see
15
- // the core layer's own IOnInitCallback doc comment) and `useSuspense` (Svelte has no built-in
16
- // Suspense primitive).
14
+ // `assetSource` reaches `openDatabaseAsync` via `options`, forwarded below — not a separate
15
+ // prop here. `useSuspense` is not offered: Svelte has no built-in Suspense primitive.
17
16
  //
18
17
  // Unlike upstream, `onInit` is not called from here — this package's own `openDatabaseAsync`
19
18
  // already runs it internally before resolving (see `IOnInitCallback`'s doc comment in
@@ -20,6 +20,7 @@
20
20
  import { compile } from 'svelte/compiler';
21
21
  import { basename, dirname, join, relative, resolve } from 'node:path';
22
22
  import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
23
+ import { createRequire } from 'node:module';
23
24
  import { pathToFileURL } from 'node:url';
24
25
  // The real Metro pipeline's own `.svelte.ts` compile step (TS-strip, then `compileModule` to
25
26
  // desugar the runes). Reused rather than reimplemented. Default-imported because it is a `.cjs`
@@ -38,6 +39,55 @@ const COMPILE_OPTIONS = {
38
39
  css: 'external',
39
40
  } as const;
40
41
  const SVELTE_SPECIFIER_PATTERN = /(['"])(\.{1,2}\/[^'"]*\.svelte)\1/g;
42
+ const BARE_SPECIFIER_PATTERN = /(\b(?:from|import)\s*)(['"])([^./'"][^'"]*)\2/g;
43
+ const RUNE_MODULE_SUFFIX = '.svelte.ts';
44
+
45
+ function relativeSpecifier(fromFile: string, target: string): string {
46
+ const specifier = relative(dirname(fromFile), target);
47
+ return specifier.startsWith('..') ? specifier : `./${specifier}`;
48
+ }
49
+
50
+ // A bare specifier that lands on a `.svelte.ts` file (Metro's transformer compiles those from any
51
+ // package). Returns the path without `.ts`, the shape `compileFile` expects, or null otherwise
52
+ function resolveRuneModule(specifier: string, fromFile: string): string | null {
53
+ try {
54
+ const resolved = createRequire(fromFile).resolve(specifier);
55
+ return resolved.endsWith(RUNE_MODULE_SUFFIX)
56
+ ? resolved.slice(0, -'.ts'.length)
57
+ : null;
58
+ } catch {
59
+ return null;
60
+ }
61
+ }
62
+
63
+ function rewriteBareRuneImports(
64
+ code: string,
65
+ outPath: string,
66
+ compileFile: (sveltePath: string) => string,
67
+ ): string {
68
+ return code.replace(
69
+ BARE_SPECIFIER_PATTERN,
70
+ (match, keyword: string, quote: string, spec: string) => {
71
+ const runeModule = resolveRuneModule(spec, outPath);
72
+ if (runeModule === null) return match;
73
+ return `${keyword}${quote}${relativeSpecifier(outPath, compileFile(runeModule))}${quote}`;
74
+ },
75
+ );
76
+ }
77
+
78
+ function rewriteAliases(
79
+ code: string,
80
+ outPath: string,
81
+ aliases: Readonly<Record<string, string>>,
82
+ ): string {
83
+ let rewritten = code;
84
+ for (const [specifier, target] of Object.entries(aliases)) {
85
+ const relativeTarget = relativeSpecifier(outPath, target);
86
+ rewritten = rewritten.split(`'${specifier}'`).join(`'${relativeTarget}'`);
87
+ rewritten = rewritten.split(`"${specifier}"`).join(`"${relativeTarget}"`);
88
+ }
89
+ return rewritten;
90
+ }
41
91
 
42
92
  export type ISvelteHarness = {
43
93
  // Compile a real `.svelte` file plus everything it imports; returns the compiled entry path.
@@ -59,13 +109,8 @@ export function createSvelteHarness(
59
109
  return join(dirname(sveltePath), `.smoke-compiled-${id}-${stem}.mjs`);
60
110
  }
61
111
 
62
- function relativeSpecifier(fromFile: string, target: string): string {
63
- const specifier = relative(dirname(fromFile), target);
64
- return specifier.startsWith('..') ? specifier : `./${specifier}`;
65
- }
66
-
67
112
  function rewrite(code: string, outPath: string): string {
68
- let rewritten = code.replace(
113
+ const withSvelte = code.replace(
69
114
  SVELTE_SPECIFIER_PATTERN,
70
115
  (_match, quote: string, spec: string) => {
71
116
  const childSource = resolve(dirname(outPath), spec);
@@ -73,15 +118,8 @@ export function createSvelteHarness(
73
118
  return `${quote}${relativeSpecifier(outPath, childOut)}${quote}`;
74
119
  },
75
120
  );
76
- for (const [specifier, target] of Object.entries(aliases)) {
77
- rewritten = rewritten
78
- .split(`'${specifier}'`)
79
- .join(`'${relativeSpecifier(outPath, target)}'`);
80
- rewritten = rewritten
81
- .split(`"${specifier}"`)
82
- .join(`"${relativeSpecifier(outPath, target)}"`);
83
- }
84
- return rewritten;
121
+ const withRunes = rewriteBareRuneImports(withSvelte, outPath, compileFile);
122
+ return rewriteAliases(withRunes, outPath, aliases);
85
123
  }
86
124
 
87
125
  function emit(
@@ -4,11 +4,9 @@
4
4
  // Vue's own provide/inject, following packages/navigation/src/vue/navigation-context.ts's shape
5
5
  // (a symbol-keyed InjectionKey, a `require*` getter that throws with a hook-scoped message).
6
6
  //
7
- // Deliberately excluded, mirroring core's own `IOpenDatabaseOptions` (see core/types.ts):
8
- // `assetSource` — needs `expo-asset`, out of scope for this package.
7
+ // `assetSource` reaches `openDatabaseAsync` via the `options` prop, not a separate prop here.
9
8
  // Deliberately excluded, this pass only: Suspense integration (`useSuspense`). Vue has its own
10
- // `<Suspense>` + async `setup()` idiom instead of React's `use()`; wiring this Provider into it is
11
- // a separate, later decision, not a straight port of React's `useSuspense` flag.
9
+ // `<Suspense>`/async `setup()` idiom instead of React's `use()`; wiring it in is a later decision.
12
10
 
13
11
  import {
14
12
  defineComponent,