snapback4-expo 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,8 +11,6 @@ import { createLocalClient } from "snapback4/local";
11
11
  import { createClient } from "snapback4/client";
12
12
  import { nativeAvailable, nativeDevice } from "snapback4-expo";
13
13
 
14
- const safe = (name: string) => name.replace(/[^A-Za-z0-9._-]/g, "_"); // store and session names carry the URL and the viewer
15
- const sqliteStore = { open: async (name: string, schema: unknown) => openSqlite(expoSqliteDriver(await SQLite.openDatabaseAsync(`${safe(name)}.db`)), schema) };
16
14
  const client = nativeAvailable()
17
15
  ? await createLocalClient({ url, guest: true, sessionStore, device: nativeDevice })
18
16
  : createClient({ url, session }); // Expo Go: the online tier, with a session the app keeps
@@ -27,11 +25,13 @@ Expo Go loads no custom native code, so the module is present only in a
27
25
  development or production build: add `expo-dev-client`, then
28
26
  `npx expo run:ios` (the module autolinks; nothing to configure). The
29
27
  Rust library ships in the package as `ios/Snapback4Device.xcframework`
30
- (9.1 MB, a 4.8 MB archive a slice, built by `scripts/build-xcframework.sh`
31
- from `crates/snapback4-device`); it costs an app 1.7 MB linked, SQLite
32
- included, and a module call takes about a millisecond.
28
+ (about 13.2 MB in 0.2.1, a 6.6 MB archive per slice, built by
29
+ `scripts/build-xcframework.sh` from `crates/snapback4-device`). It includes
30
+ SQLite and the native-query Wasm host. The earlier module measured 1.7 MB
31
+ linked and about a millisecond per call; those measurements predate the
32
+ native-query host.
33
33
 
34
- Proved on the iOS simulator by the repository's witness in a development
34
+ Earlier iOS simulator evidence from the repository's witness in a development
35
35
  build (`WITNESS_DEV_CLIENT=1 node witness/expo.mjs`, recorded in
36
36
  `metrics/witness.jsonl` as `dev-client-native`): a cold sync of 303 rows
37
37
  in 31 ms, a reopen in 6 ms, a cold start with no network answering the
@@ -9,9 +9,13 @@
9
9
  * Ops: state, adopt {backend}, apply {page, first}, query {name, viewer, args, now},
10
10
  * predict {name, viewer, args, now, newIds, entropy}, withdraw {predicted},
11
11
  * enqueue {entry}, queued, next_submission, dequeue {id}, meta {key},
12
- * set_meta {key, value}, clear_rows. Nothing panics across this boundary;
13
- * every answer is JSON the caller frees. A device is not thread-safe: one
14
- * caller at a time, as the store is one transaction at a time.
12
+ * set_meta {key, value}, clear_rows. Nothing unwinds across this boundary:
13
+ * unwind builds translate an internal panic to E_STORE; production uses
14
+ * panic=abort and terminates before unwinding. Every answer is JSON the
15
+ * caller frees. A device is not thread-safe: one caller at a time, as the
16
+ * store is one transaction at a time.
17
+ * `apply.first` must be true on the first page of a snapshot. It defaults
18
+ * to false so an omitted marker cannot discard a snapshot already staged.
15
19
  */
16
20
  #ifndef SNAPBACK4_H
17
21
  #define SNAPBACK4_H
@@ -26,7 +30,10 @@ typedef struct sb4_device sb4_device;
26
30
  * (ask `sb4_open_reason` why). */
27
31
  sb4_device *sb4_open(const char *path, const char *backend_json);
28
32
 
29
- /* Why `sb4_open` would refuse, as JSON to free: {"ok":true} when it would open. */
33
+ /* Take the refusal recorded by the most recent failed `sb4_open` on this
34
+ * thread, as JSON to free. This diagnoses that attempt without opening or
35
+ * mutating the store a second time. The arguments are retained for ABI
36
+ * compatibility. */
30
37
  char *sb4_open_reason(const char *path, const char *backend_json);
31
38
 
32
39
  /* One call; the answer is JSON to free with `sb4_free`. */
@@ -9,9 +9,13 @@
9
9
  * Ops: state, adopt {backend}, apply {page, first}, query {name, viewer, args, now},
10
10
  * predict {name, viewer, args, now, newIds, entropy}, withdraw {predicted},
11
11
  * enqueue {entry}, queued, next_submission, dequeue {id}, meta {key},
12
- * set_meta {key, value}, clear_rows. Nothing panics across this boundary;
13
- * every answer is JSON the caller frees. A device is not thread-safe: one
14
- * caller at a time, as the store is one transaction at a time.
12
+ * set_meta {key, value}, clear_rows. Nothing unwinds across this boundary:
13
+ * unwind builds translate an internal panic to E_STORE; production uses
14
+ * panic=abort and terminates before unwinding. Every answer is JSON the
15
+ * caller frees. A device is not thread-safe: one caller at a time, as the
16
+ * store is one transaction at a time.
17
+ * `apply.first` must be true on the first page of a snapshot. It defaults
18
+ * to false so an omitted marker cannot discard a snapshot already staged.
15
19
  */
16
20
  #ifndef SNAPBACK4_H
17
21
  #define SNAPBACK4_H
@@ -26,7 +30,10 @@ typedef struct sb4_device sb4_device;
26
30
  * (ask `sb4_open_reason` why). */
27
31
  sb4_device *sb4_open(const char *path, const char *backend_json);
28
32
 
29
- /* Why `sb4_open` would refuse, as JSON to free: {"ok":true} when it would open. */
33
+ /* Take the refusal recorded by the most recent failed `sb4_open` on this
34
+ * thread, as JSON to free. This diagnoses that attempt without opening or
35
+ * mutating the store a second time. The arguments are retained for ABI
36
+ * compatibility. */
30
37
  char *sb4_open_reason(const char *path, const char *backend_json);
31
38
 
32
39
  /* One call; the answer is JSON to free with `sb4_free`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snapback4-expo",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "description": "Snapback 4's native module for Expo: the device in Rust (the partition in its own SQLite, the stream applied, the outbox kept, queries and predictions answered) behind one JSON call, and the opener `snapback4/native` takes.",
6
6
  "main": "src/index.ts",