@enbox/browser 0.3.82 → 0.3.84

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
@@ -23,38 +23,41 @@ bun add @enbox/browser
23
23
  wallet connect handler, and DWeb helpers:
24
24
 
25
25
  ```ts
26
- import {
27
- BrowserConnectHandler,
28
- createConnectionStore,
29
- defineApplicationManifest,
30
- } from '@enbox/browser';
31
-
32
- const application = defineApplicationManifest({
33
- protocols: [NotesProtocol],
34
- } as const);
35
- const store = createConnectionStore({
36
- application,
37
- connectHandler: BrowserConnectHandler({ appName: 'Notes' }),
38
- monitor: { autoRefresh: {} },
26
+ import { createApplication } from '@enbox/browser';
27
+ import { NotesStore } from './features/notes/store.js';
28
+
29
+ const application = createApplication({
30
+ stores: { notes: NotesStore },
31
+ wallet: { appName: 'Notes' },
32
+ connection: { monitor: { autoRefresh: {} } },
39
33
  });
40
34
 
41
- await store.initialize();
35
+ await application.initialize();
42
36
 
43
- // Invoke directly from a click or other user action so the wallet popup opens.
37
+ // Invoke directly from a user action so the wallet popup opens.
44
38
  async function connect(): Promise<void> {
45
- const snapshot = await store.connect();
39
+ const snapshot = await application.connection.connect();
46
40
  if (snapshot.phase !== 'connected') {
47
41
  throw snapshot.error ?? new Error('Connection was not established.');
48
42
  }
49
- const enbox = snapshot.enbox;
50
- // ...use enbox...
43
+ const notes = application.store(NotesStore);
44
+ // Subscribe to notes' resources or run its domain commands.
51
45
  }
52
46
  ```
53
47
 
54
- Create one store for the application lifetime. It owns session restoration,
55
- protocol readiness, grant refresh, facade replacement, and teardown. Call
56
- `disconnect()` on sign-out and `dispose()` when the store is permanently
57
- released.
48
+ Keep one application for the browser lifetime. It derives the manifest from
49
+ feature protocols and owns the connection, session-scoped resources, commands,
50
+ and cleanup. `application.connection.disconnect()` signs out;
51
+ `application.dispose()` permanently tears down the owner. React binds the same
52
+ runtime through `EnboxProvider application={application}`.
53
+
54
+ For a custom host, supply `connectHandler` instead of `wallet`, or supply a
55
+ `connection: manifest => nativeConnection` factory that owns all native
56
+ configuration. The headless `@enbox/api` constructor requires that factory;
57
+ the browser constructor supplies browser defaults around the same runtime.
58
+ Native connection, record, and context primitives remain available for custom
59
+ flows. `defineStore`'s `observe()` factory owns all native view types through
60
+ one subscription and cleanup mechanism.
58
61
 
59
62
  ## Browser runtime
60
63