@effect/platform-browser 4.0.0-beta.77 → 4.0.0-beta.79

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 (73) hide show
  1. package/dist/BrowserCrypto.d.ts +0 -37
  2. package/dist/BrowserCrypto.d.ts.map +1 -1
  3. package/dist/BrowserCrypto.js +0 -37
  4. package/dist/BrowserCrypto.js.map +1 -1
  5. package/dist/BrowserHttpClient.d.ts.map +1 -1
  6. package/dist/BrowserHttpClient.js +5 -25
  7. package/dist/BrowserHttpClient.js.map +1 -1
  8. package/dist/BrowserKeyValueStore.d.ts.map +1 -1
  9. package/dist/BrowserKeyValueStore.js +2 -43
  10. package/dist/BrowserKeyValueStore.js.map +1 -1
  11. package/dist/BrowserPersistence.d.ts.map +1 -1
  12. package/dist/BrowserPersistence.js.map +1 -1
  13. package/dist/BrowserRuntime.d.ts +4 -19
  14. package/dist/BrowserRuntime.d.ts.map +1 -1
  15. package/dist/BrowserRuntime.js.map +1 -1
  16. package/dist/BrowserSocket.d.ts +4 -35
  17. package/dist/BrowserSocket.d.ts.map +1 -1
  18. package/dist/BrowserSocket.js +4 -35
  19. package/dist/BrowserSocket.js.map +1 -1
  20. package/dist/BrowserStream.d.ts +4 -35
  21. package/dist/BrowserStream.d.ts.map +1 -1
  22. package/dist/BrowserStream.js +4 -35
  23. package/dist/BrowserStream.js.map +1 -1
  24. package/dist/BrowserWorker.d.ts.map +1 -1
  25. package/dist/BrowserWorker.js +5 -33
  26. package/dist/BrowserWorker.js.map +1 -1
  27. package/dist/BrowserWorkerRunner.d.ts.map +1 -1
  28. package/dist/BrowserWorkerRunner.js +5 -27
  29. package/dist/BrowserWorkerRunner.js.map +1 -1
  30. package/dist/Clipboard.d.ts +5 -29
  31. package/dist/Clipboard.d.ts.map +1 -1
  32. package/dist/Clipboard.js +5 -29
  33. package/dist/Clipboard.js.map +1 -1
  34. package/dist/Geolocation.d.ts +6 -29
  35. package/dist/Geolocation.d.ts.map +1 -1
  36. package/dist/Geolocation.js +6 -29
  37. package/dist/Geolocation.js.map +1 -1
  38. package/dist/IndexedDb.d.ts +0 -14
  39. package/dist/IndexedDb.d.ts.map +1 -1
  40. package/dist/IndexedDb.js +0 -14
  41. package/dist/IndexedDb.js.map +1 -1
  42. package/dist/IndexedDbDatabase.d.ts +3 -19
  43. package/dist/IndexedDbDatabase.d.ts.map +1 -1
  44. package/dist/IndexedDbDatabase.js +3 -19
  45. package/dist/IndexedDbDatabase.js.map +1 -1
  46. package/dist/IndexedDbQueryBuilder.d.ts +5 -21
  47. package/dist/IndexedDbQueryBuilder.d.ts.map +1 -1
  48. package/dist/IndexedDbQueryBuilder.js.map +1 -1
  49. package/dist/IndexedDbTable.d.ts +2 -27
  50. package/dist/IndexedDbTable.d.ts.map +1 -1
  51. package/dist/IndexedDbTable.js +2 -27
  52. package/dist/IndexedDbTable.js.map +1 -1
  53. package/dist/Permissions.d.ts +5 -29
  54. package/dist/Permissions.d.ts.map +1 -1
  55. package/dist/Permissions.js +5 -29
  56. package/dist/Permissions.js.map +1 -1
  57. package/package.json +3 -3
  58. package/src/BrowserCrypto.ts +0 -37
  59. package/src/BrowserHttpClient.ts +5 -25
  60. package/src/BrowserKeyValueStore.ts +2 -43
  61. package/src/BrowserPersistence.ts +5 -47
  62. package/src/BrowserRuntime.ts +4 -19
  63. package/src/BrowserSocket.ts +4 -35
  64. package/src/BrowserStream.ts +4 -35
  65. package/src/BrowserWorker.ts +5 -33
  66. package/src/BrowserWorkerRunner.ts +5 -27
  67. package/src/Clipboard.ts +5 -29
  68. package/src/Geolocation.ts +6 -29
  69. package/src/IndexedDb.ts +0 -14
  70. package/src/IndexedDbDatabase.ts +3 -19
  71. package/src/IndexedDbQueryBuilder.ts +5 -21
  72. package/src/IndexedDbTable.ts +2 -27
  73. package/src/Permissions.ts +5 -29
@@ -6,49 +6,8 @@
6
6
  * origin-scoped values that should survive reloads and browser restarts, use
7
7
  * {@link layerSessionStorage} for tab / page-session state, and use
8
8
  * {@link layerIndexedDb} when the store should be asynchronous and backed by
9
- * IndexedDB.
10
- *
11
- * ## Mental model
12
- *
13
- * All exports provide the same `KeyValueStore.KeyValueStore` service; the layer
14
- * chooses the browser storage backend. The Web Storage layers delegate to
15
- * `globalThis.localStorage` or `globalThis.sessionStorage` and adapt the
16
- * string-only API, encoding `Uint8Array` values as base64. The IndexedDB layer
17
- * stores strings and `Uint8Array` values in an object store and requires the
18
- * browser `IndexedDb` service to open the database.
19
- *
20
- * ## Common tasks
21
- *
22
- * - Persist user preferences, lightweight caches, or drafts with
23
- * {@link layerLocalStorage}.
24
- * - Keep tab-scoped workflow state with {@link layerSessionStorage}.
25
- * - Avoid blocking the main thread for larger client-side stores by using
26
- * {@link layerIndexedDb}.
27
- *
28
- * ## Gotchas
29
- *
30
- * These layers only work where browser storage APIs are available. Browsers may
31
- * deny storage in private modes, sandboxed frames, disabled-storage settings, or
32
- * quota-limited contexts. Web Storage is synchronous and origin-scoped, so keep
33
- * payloads small and do not use it as a secure store for secrets. IndexedDB is
34
- * asynchronous but can still be blocked by permissions, quota limits, version
35
- * upgrades, or other open tabs.
36
- *
37
- * **Example** (Provide localStorage to a program)
38
- *
39
- * ```ts
40
- * import { BrowserKeyValueStore } from "@effect/platform-browser"
41
- * import { Effect } from "effect"
42
- * import { KeyValueStore } from "effect/unstable/persistence"
43
- *
44
- * const program = Effect.gen(function*() {
45
- * const store = yield* KeyValueStore.KeyValueStore
46
- * yield* store.set("theme", "dark")
47
- * return yield* store.get("theme")
48
- * }).pipe(
49
- * Effect.provide(BrowserKeyValueStore.layerLocalStorage)
50
- * )
51
- * ```
9
+ * IndexedDB. The IndexedDB layer requires the browser `IndexedDb` service and
10
+ * accepts an optional database name.
52
11
  *
53
12
  * @since 4.0.0
54
13
  */
@@ -1,53 +1,11 @@
1
1
  /**
2
2
  * IndexedDB-backed persistence layers for browser Effect programs.
3
3
  *
4
- * `BrowserPersistence` connects the unstable persistence services to the
5
- * browser's IndexedDB storage. Use it for client-side caches that should
6
- * survive page reloads, offline-capable workflows, remembered query results,
7
- * and other application-managed values that can be recomputed or invalidated
8
- * when storage is unavailable.
9
- *
10
- * **Mental model**
11
- *
12
- * - {@link layerIndexedDb} provides the higher-level `Persistence` service by
13
- * composing the IndexedDB backing layer with the core persistence layer.
14
- * - {@link layerBackingIndexedDb} provides only `BackingPersistence` for code
15
- * that composes persistence services manually.
16
- * - Entries live in one IndexedDB database, defaulting to
17
- * `"effect_persistence"`, and one object store keyed by `[storeId, key]`.
18
- * - The `storeId` namespaces persisted request results; the key identifies one
19
- * entry inside that store.
20
- * - Finite TTLs are stored as expiration timestamps and expired entries are
21
- * removed lazily when they are read.
22
- *
23
- * **Common tasks**
24
- *
25
- * - Provide browser persistence to `PersistedCache` or other persistence
26
- * workflows with {@link layerIndexedDb}.
27
- * - Isolate tests, apps, or migrations by passing a custom `database` option.
28
- * - Use {@link layerBackingIndexedDb} when another layer should decide how to
29
- * construct the higher-level `Persistence` service.
30
- *
31
- * **Gotchas**
32
- *
33
- * - This module requires browser IndexedDB and stores data per origin.
34
- * - Opening IndexedDB is defected during layer acquisition if the database
35
- * cannot be opened; later store operations report `PersistenceError`.
36
- * - Values must be structured-cloneable objects, and writes can fail because of
37
- * quota limits, browser settings, private browsing modes, or user-cleared
38
- * storage.
39
- * - Lazy TTL cleanup makes this suitable for caches, not for authoritative or
40
- * security-sensitive state.
41
- *
42
- * **Example** (Providing browser persistence)
43
- *
44
- * ```ts
45
- * import { BrowserPersistence } from "@effect/platform-browser"
46
- *
47
- * export const PersistenceLive = BrowserPersistence.layerIndexedDb({
48
- * database: "my-app-cache"
49
- * })
50
- * ```
4
+ * This module provides a low-level `BackingPersistence` layer and a higher-level
5
+ * `Persistence` layer that store object values in IndexedDB. Values are stored
6
+ * by persistence store id and key, and reads check TTL expiration before
7
+ * returning stored data. The database name can be customized and defaults to
8
+ * `"effect_persistence"`.
51
9
  *
52
10
  * @since 4.0.0
53
11
  */
@@ -1,24 +1,9 @@
1
1
  /**
2
- * Browser entry-point helpers for running Effect programs.
2
+ * Browser helper for running a root Effect program.
3
3
  *
4
- * This module exposes `runMain`, a browser-oriented main runner for launching
5
- * an Effect as the root program of a page, single-page application, demo, or
6
- * browser test harness. It delegates execution to the core Effect runtime while
7
- * adding the browser lifecycle hook needed to interrupt the main fiber when the
8
- * page receives `beforeunload`.
9
- *
10
- * `BrowserRuntime` does not provide application services by itself. Provide
11
- * any required layers, such as browser HTTP, storage, worker, geolocation, or
12
- * permission services, before passing the effect to `runMain`. Keep long-lived
13
- * browser resources scoped so interruption can run their finalizers while the
14
- * page is still active.
15
- *
16
- * Browser unload is more constrained than a process signal. Finalizers that
17
- * need the network, timers, prompts, or long asynchronous work may not complete
18
- * once navigation or tab close has started, and browsers do not expose a
19
- * process exit status. Use `runMain` to connect the page lifecycle to Effect
20
- * interruption, and use browser-specific persistence or delivery APIs for work
21
- * that must survive page teardown.
4
+ * This module exports `runMain`, a browser version of the main Effect runner.
5
+ * It forwards runner options to the core runtime and adds a `beforeunload`
6
+ * listener that interrupts the main fiber when the page is unloading.
22
7
  *
23
8
  * @since 4.0.0
24
9
  */
@@ -1,40 +1,9 @@
1
1
  /**
2
- * Provide Effect sockets backed by the browser `WebSocket` implementation.
2
+ * Browser WebSocket layers for Effect sockets.
3
3
  *
4
- * This module is the browser entry point for Effect's socket abstraction. Use
5
- * {@link layerWebSocket} when a client-side Effect program needs a complete
6
- * `Socket.Socket` connected to a WebSocket URL. Use
7
- * {@link layerWebSocketConstructor} when lower-level socket code only needs the
8
- * browser-backed constructor service.
9
- *
10
- * ## Mental model
11
- *
12
- * `layerWebSocket` delegates socket behavior to Effect's WebSocket support and
13
- * supplies `globalThis.WebSocket` as the constructor. Incoming browser messages
14
- * are normalized to strings or binary `Uint8Array` values. Browser `Blob`
15
- * messages are read into bytes before they reach the socket consumer.
16
- *
17
- * Outgoing data should already be serialized to a string or bytes. To close the
18
- * underlying browser socket with a specific code and reason, send a
19
- * `CloseEvent` value so the close metadata is preserved.
20
- *
21
- * ## Common tasks
22
- *
23
- * - Connect RPC transports, browser tests, or realtime UI features to a
24
- * WebSocket URL with {@link layerWebSocket}.
25
- * - Provide only the browser constructor service with
26
- * {@link layerWebSocketConstructor} when another socket layer builds the
27
- * connection.
28
- * - Customize `closeCodeIsError` for protocols that treat specific close codes
29
- * as normal completion instead of socket failure.
30
- *
31
- * ## Gotchas
32
- *
33
- * Browser WebSocket rules still apply. URL schemes, subprotocol negotiation,
34
- * mixed-content blocking, cookies, authentication, server origin checks, and
35
- * extension negotiation are controlled by the browser and server rather than by
36
- * Effect. Close events become socket errors unless `closeCodeIsError`
37
- * classifies the close code as clean.
4
+ * `layerWebSocket` creates a `Socket.Socket` connected to a WebSocket URL using
5
+ * the browser `WebSocket` constructor. `layerWebSocketConstructor` provides
6
+ * only the browser-backed constructor service for lower-level socket code.
38
7
  *
39
8
  * @since 4.0.0
40
9
  */
@@ -1,40 +1,9 @@
1
1
  /**
2
- * Convert browser DOM events into Effect streams.
2
+ * Browser DOM event streams.
3
3
  *
4
- * This module provides typed constructors for listening to `window` and
5
- * `document` events from Effect programs. Use {@link fromEventListenerWindow}
6
- * for viewport, network, focus, pointer, keyboard, and other `Window` events,
7
- * and use {@link fromEventListenerDocument} for document lifecycle,
8
- * visibility, selection, fullscreen, and other `Document` events.
9
- *
10
- * ## Mental model
11
- *
12
- * Each constructor registers a DOM `addEventListener` callback when the stream
13
- * is consumed and removes it when the stream is finalized. Browser events are
14
- * push-based `EventTarget` notifications, so the browser does not slow down the
15
- * event source when downstream stream processing is busy. Events are buffered
16
- * inside the stream until a consumer pulls them.
17
- *
18
- * ## Common tasks
19
- *
20
- * - Track browser state such as resize, online / offline, focus, visibility, or
21
- * pointer activity with Effect stream operators.
22
- * - Scope DOM listeners to a fiber so they are removed when the consuming
23
- * effect is interrupted or completes.
24
- * - Set `bufferSize` for bursty event sources before applying sampling,
25
- * throttling, debouncing, or dropping logic downstream.
26
- *
27
- * ## Gotchas
28
- *
29
- * The default buffer is unbounded. High-frequency sources such as `scroll`,
30
- * `pointermove`, or `mousemove` should usually specify `bufferSize` and reduce
31
- * the event rate with stream operators.
32
- *
33
- * These helpers are for DOM events, not for `ReadableStream` request or
34
- * response bodies. Fetch bodies follow Web Streams rules such as
35
- * single-consumer locking and disturbed bodies after reads. When using the DOM
36
- * `once` option, also use `Stream.take(1)` if the consuming code needs a finite
37
- * stream.
4
+ * This module provides typed constructors that turn `window.addEventListener`
5
+ * and `document.addEventListener` events into Effect `Stream` values. Both
6
+ * helpers accept the usual listener options and an optional stream buffer size.
38
7
  *
39
8
  * @since 4.0.0
40
9
  */
@@ -1,38 +1,10 @@
1
1
  /**
2
- * Parent-side browser platform for running Effect workers.
2
+ * Parent-side browser platform for Effect workers.
3
3
  *
4
- * This module provides the `WorkerPlatform` used by browser code that spawns or
5
- * connects to `Worker`, `SharedWorker`, and `MessagePort` endpoints through
6
- * Effect's worker protocol. Pair it with `BrowserWorkerRunner` in the worker
7
- * entrypoint when building worker-backed RPC clients, moving CPU-bound work off
8
- * the main thread, isolating browser-only services, or adapting an existing
9
- * `MessageChannel` in tests.
10
- *
11
- * **Mental model**
12
- *
13
- * Browser worker communication is normalized to a message port. Dedicated
14
- * workers post messages on the worker object itself, shared workers post
15
- * through `worker.port`, and raw `MessagePort` values can be supplied directly.
16
- * `layerPlatform` provides only the browser platform, while `layer` combines
17
- * the platform with a `Spawner` that creates a worker endpoint for each worker
18
- * id.
19
- *
20
- * **Common tasks**
21
- *
22
- * Use `layer` when parent code should both provide browser worker messaging and
23
- * define how workers are spawned. Use `layerPlatform` when a spawner is already
24
- * provided elsewhere. Return a `MessagePort` from the spawner for tests or
25
- * custom channels, a `Worker` for dedicated workers, or a `SharedWorker` when
26
- * multiple browser contexts should share one worker runtime.
27
- *
28
- * **Gotchas**
29
- *
30
- * Messages use the browser structured-clone algorithm, so payloads and transfer
31
- * lists must be accepted by the target runtime. Transferring an `ArrayBuffer` or
32
- * `MessagePort` moves ownership away from the sender. Scope finalization sends
33
- * the worker close signal over the port, but code that created a dedicated
34
- * `Worker` remains responsible for broader lifecycle concerns such as
35
- * terminating it.
4
+ * `layerPlatform` provides the `WorkerPlatform` used to communicate with a
5
+ * browser `Worker`, `SharedWorker`, or `MessagePort` through Effect's worker
6
+ * protocol. `layer` combines that platform with a `Spawner` built from a
7
+ * callback that creates or returns the worker endpoint for each worker id.
36
8
  *
37
9
  * @since 4.0.0
38
10
  */
@@ -1,33 +1,11 @@
1
1
  /**
2
2
  * Runner-side browser platform for Effect worker handlers.
3
3
  *
4
- * This module is for code already executing inside a browser worker, or for
5
- * tests and adapters that pass a `MessagePort` or `Window` endpoint directly.
6
- * It provides the `WorkerRunnerPlatform` used by `WorkerRunner` and protocols
7
- * such as `RpcServer.layerProtocolWorkerRunner` to receive parent or client
8
- * requests, run Effect handlers, and post responses back through the browser
9
- * messaging channel.
10
- *
11
- * **Mental model**
12
- *
13
- * Dedicated workers use the ambient `self` endpoint. Shared workers receive one
14
- * `MessagePort` per `onconnect` event, and this module caches ports that arrive
15
- * before the runner layer starts. `layer` reads from the global worker `self`;
16
- * `make` and `layerMessagePort` are for explicit endpoints supplied by tests,
17
- * custom channels, or adapter code.
18
- *
19
- * **Common tasks**
20
- *
21
- * Pair this module with `BrowserWorker` in the parent page when moving RPC
22
- * handlers, CPU-bound computations, or browser-only services into a dedicated
23
- * worker or shared worker. Use `layer` in normal worker entry points and
24
- * `layerMessagePort` when a test or integration already owns the transport.
25
- *
26
- * **Gotchas**
27
- *
28
- * Payloads and transfer lists must satisfy the browser structured-clone
29
- * algorithm. `messageerror` and `error` events fail the runner, and each
30
- * connected `MessagePort` is closed when its scope finalizes.
4
+ * `make` builds a `WorkerRunnerPlatform` over a `MessagePort` or `Window`.
5
+ * `layer` provides the platform from the global worker `self`, and
6
+ * `layerMessagePort` provides it from an explicit endpoint. The platform
7
+ * receives parent or client messages, runs Effect handlers, and posts responses
8
+ * back through the browser messaging channel.
31
9
  *
32
10
  * @since 4.0.0
33
11
  */
package/src/Clipboard.ts CHANGED
@@ -1,35 +1,11 @@
1
1
  /**
2
2
  * Browser clipboard integration for Effect programs.
3
3
  *
4
- * This module provides a `Clipboard` service backed by `navigator.clipboard`.
5
- * It keeps copy, paste, clear, and rich clipboard operations inside the Effect
6
- * environment so browser UI code can require clipboard capability without
7
- * calling the global API directly. Text helpers cover portable copy and paste
8
- * flows, while `read`, `write`, and `writeBlob` expose `ClipboardItem` payloads
9
- * for browsers that support richer MIME types.
10
- *
11
- * **Mental model**
12
- *
13
- * `Clipboard` is a capability service. Application code depends on the service
14
- * tag, {@link layer} supplies the live browser implementation, and {@link make}
15
- * builds custom implementations for tests, unsupported browsers, or constrained
16
- * capabilities. Browser failures are converted to {@link ClipboardError}.
17
- *
18
- * **Common tasks**
19
- *
20
- * - Provide {@link layer} near the browser application edge.
21
- * - Use `writeString` for copy buttons and generated text.
22
- * - Use `readString` for paste or import workflows.
23
- * - Use `write` or `writeBlob` for rich clipboard payloads when
24
- * `ClipboardItem` is available.
25
- * - Use `clear` to replace the clipboard with an empty string.
26
- *
27
- * **Gotchas**
28
- *
29
- * Clipboard access requires a secure context in modern browsers and may also
30
- * require user activation, permissions, and a focused document. Support differs
31
- * between reads, writes, text, and custom MIME payloads, so feature detection or
32
- * graceful fallback is often needed around `ClipboardItem` usage.
4
+ * This module defines the `Clipboard` service, the `ClipboardError` raised by
5
+ * failed browser operations, a `make` constructor for custom implementations,
6
+ * and a browser-backed `layer` that uses `navigator.clipboard`. The service
7
+ * supports reading and writing text, reading and writing `ClipboardItem`
8
+ * payloads, writing one `Blob`, and clearing the clipboard.
33
9
  *
34
10
  * @since 4.0.0
35
11
  */
@@ -1,35 +1,12 @@
1
1
  /**
2
2
  * Browser geolocation integration for Effect programs.
3
3
  *
4
- * This module exposes a `Geolocation` service backed by
5
- * `navigator.geolocation`. Use it for browser features that need a single
6
- * position fix, such as nearby search or delivery estimates, or a stream of
7
- * position updates for navigation, tracking, and location-aware interfaces.
8
- * Browser failures are represented as typed `GeolocationError` values instead
9
- * of raw callback errors.
10
- *
11
- * **Mental model**
12
- *
13
- * - The service delegates to the browser Geolocation API and follows the
14
- * browser's permission, privacy, origin, and secure-context rules.
15
- * - `getCurrentPosition` reads one position fix from the service.
16
- * - {@link watchPosition} turns browser position callbacks into a `Stream` and
17
- * clears the underlying browser watch when the stream is finalized.
18
- *
19
- * **Common tasks**
20
- *
21
- * - Provide the live browser implementation with {@link layer}.
22
- * - Read a one-shot position from the `Geolocation` service.
23
- * - Stream position updates with {@link watchPosition}.
24
- * - Handle denied permissions, timeouts, and unavailable position data with
25
- * {@link GeolocationError}.
26
- *
27
- * **Gotchas**
28
- *
29
- * - Browsers may prompt the user, reject access outside secure contexts, block
30
- * access by permissions policy, or report that position data is unavailable.
31
- * - {@link watchPosition} uses a sliding buffer; increase `bufferSize` if slow
32
- * consumers must not skip older positions.
4
+ * This module defines a `Geolocation` service backed by
5
+ * `navigator.geolocation`. The service can read one current position or stream
6
+ * watched position updates with a sliding buffer. Browser callback failures are
7
+ * represented as `GeolocationError` values with `PositionUnavailable`,
8
+ * `PermissionDenied`, or `Timeout` reasons. The module also provides the
9
+ * browser-backed layer and a `watchPosition` accessor.
33
10
  *
34
11
  * @since 4.0.0
35
12
  */
package/src/IndexedDb.ts CHANGED
@@ -7,20 +7,6 @@
7
7
  * wiring those primitives from `window`, and schemas for the key shapes accepted
8
8
  * by IndexedDB object stores and indexes.
9
9
  *
10
- * Use it when building typed local persistence for browser caches,
11
- * offline-first state, background queues, drafts, or other client-side data
12
- * that should be validated before it reaches IndexedDB. Higher-level database,
13
- * version, table, and query modules build on these primitives for migrations
14
- * and typed transactions.
15
- *
16
- * IndexedDB still follows the browser rules: schema changes happen only during
17
- * version upgrades, upgrades may be blocked by other open tabs or connections,
18
- * and reads or writes must run in transactions scoped to the object stores they
19
- * touch. The `layerWindow` constructor should be used only where browser
20
- * globals are available, and code that also runs during SSR or in restricted
21
- * browser contexts should account for `indexedDB` or `IDBKeyRange` being
22
- * missing.
23
- *
24
10
  * @since 4.0.0
25
11
  */
26
12
  import * as Context from "effect/Context"
@@ -4,25 +4,9 @@
4
4
  * This module turns an `IndexedDbVersion` migration chain into an
5
5
  * `IndexedDbDatabase` layer. The layer opens the browser database, runs any
6
6
  * pending upgrade migrations, provides a query builder for the current schema,
7
- * and exposes a `rebuild` effect that deletes and reopens the database. It is
8
- * the database-level companion to the table, version, and query builder
9
- * modules.
10
- *
11
- * Use it for browser-local persistence such as offline-first application
12
- * state, cached server data, background queues, drafts, and other client-side
13
- * stores that need typed reads and writes backed by IndexedDB transactions.
14
- *
15
- * IndexedDB schema changes can only happen inside upgrade transactions, so
16
- * every call to `make` or `.add` represents the next browser database version
17
- * and only migrations after the existing browser version are run. Table and
18
- * index definitions type the migration and query APIs, but object stores and
19
- * indexes still need to be created or removed explicitly with the migration
20
- * transaction helpers. Include the complete target table set in each version,
21
- * create indexes before querying them, and treat key path or auto-increment
22
- * changes as store migrations that copy data into a replacement object store.
23
- * Upgrades can be blocked by other open connections, and all migration reads,
24
- * writes, store changes, and index changes share the single upgrade
25
- * transaction supplied by the browser.
7
+ * and exposes a `rebuild` effect that deletes and reopens the database.
8
+ * Migration transactions can create or delete object stores and indexes, and
9
+ * database failures are represented as `IndexedDbDatabaseError` values.
26
10
  *
27
11
  * @since 4.0.0
28
12
  */
@@ -3,27 +3,11 @@
3
3
  *
4
4
  * An `IndexedDbQueryBuilder` is created from an open database and a version's
5
5
  * table descriptors, then exposes `from(tableName)` as the entry point for
6
- * table operations. The resulting query objects can select, count, delete,
7
- * insert, upsert, clear tables, stream paged reads, react to invalidations, and
8
- * run multiple effects in a shared `IDBTransaction` with `withTransaction`.
9
- *
10
- * Use this module for local browser persistence such as caches, offline-first
11
- * state, background queues, drafts, and other client-side data where writes
12
- * should be encoded through `Schema` and reads should be decoded before they
13
- * reach application code.
14
- *
15
- * Index and range helpers are thinly typed wrappers around IndexedDB object
16
- * stores, indexes, `IDBKeyRange`, and cursors. Index names must be declared on
17
- * the table and created during migrations; without an index, queries use the
18
- * object store key path. Range values are encoded IndexedDB key values, and
19
- * compound key paths must follow the declared key order. Filters, offsets,
20
- * reverse reads, out-of-line keys, and limited deletes require cursor-based
21
- * scans, while simpler selects can use `getAll`.
22
- *
23
- * Table schema details affect runtime behavior: auto-increment writes may omit
24
- * the generated numeric key, stores without a key path require an out-of-line
25
- * `key` for writes and add that `key` back to selected rows, and schema
26
- * mismatches surface as `EncodeError` or `DecodeError` query failures.
6
+ * table operations. Query objects can select, count, delete, insert, upsert,
7
+ * clear tables, stream paged reads, react to invalidations, and run multiple
8
+ * effects in a shared `IDBTransaction` with `withTransaction`. Reads decode
9
+ * stored rows with the table schema, and writes encode input values before
10
+ * sending them to IndexedDB.
27
11
  *
28
12
  * @since 4.0.0
29
13
  */
@@ -4,33 +4,8 @@
4
4
  * An {@link IndexedDbTable} is the schema-backed description of one IndexedDB
5
5
  * object store. It carries the store name, row schema, key path, index key
6
6
  * paths, auto-increment mode, and transaction durability used by database
7
- * versions, migrations, and typed queries.
8
- *
9
- * **Mental model**
10
- *
11
- * A table value is metadata. `make` does not create an object store; it gives
12
- * database versions, migration helpers, and the query builder the information
13
- * they need to type table names, validate rows, and choose schemas for reads
14
- * and writes. The stored values are the encoded schema values accepted by
15
- * IndexedDB, with derived schemas for out-of-line keys and generated
16
- * auto-increment keys.
17
- *
18
- * **Common tasks**
19
- *
20
- * - Define object stores for browser caches, offline state, drafts, and
21
- * background queues.
22
- * - Reuse the same table descriptor in database versions, migrations, and
23
- * typed queries.
24
- * - Declare index key paths so query builders can restrict index names and key
25
- * values.
26
- *
27
- * **Gotchas**
28
- *
29
- * Key paths and index paths point at encoded schema fields whose values must be
30
- * valid IndexedDB keys. Tables without an inline key path use an out-of-line
31
- * `key`, so the row schema cannot define a `key` field. Auto-increment tables
32
- * require a numeric key path, and declared indexes still have to be created in
33
- * migrations.
7
+ * versions, migrations, and typed queries. The `make` constructor also derives
8
+ * the read, array, and auto-increment write schemas used by the query builder.
34
9
  *
35
10
  * @see {@link make} for constructing table descriptors.
36
11
  *
@@ -1,35 +1,11 @@
1
1
  /**
2
2
  * Effect service for the browser Permissions API.
3
3
  *
4
- * This module wraps `navigator.permissions` in a `Permissions` service and a
5
- * browser-backed layer. It lets browser programs query whether a capability is
6
- * currently `granted`, `prompt`, or `denied` before deciding which UI or
7
- * feature flow to show for geolocation, notifications, clipboard access,
8
- * camera, microphone, persistent storage, and other browser-gated features.
9
- *
10
- * **Mental model**
11
- *
12
- * A permission query is a status read, not an access request. The service
13
- * delegates to `navigator.permissions.query({ name })` and returns the browser's
14
- * `PermissionStatus`, while browser rejections are represented as
15
- * `PermissionsError` values.
16
- *
17
- * **Common tasks**
18
- *
19
- * - Check whether a feature is already available before rendering a prompt or
20
- * settings path.
21
- * - Require permission querying through Effect context instead of reaching for
22
- * the ambient `navigator` in application code.
23
- * - Provide the live browser implementation with `layer`.
24
- *
25
- * **Gotchas**
26
- *
27
- * Browser support for permission names and states is uneven, and unsupported or
28
- * invalid descriptors may reject. Some permissions are only meaningful in
29
- * secure contexts or after user activation. Returned `PermissionStatus` objects
30
- * can change when the user updates browser settings or responds to prompts; if
31
- * you subscribe to `change` or `onchange`, clean up listeners with the
32
- * surrounding Effect scope.
4
+ * This module defines a `Permissions` service backed by
5
+ * `navigator.permissions`. The service exposes `query`, which returns the
6
+ * browser `PermissionStatus` for a permission name. Failed browser operations
7
+ * are represented as `PermissionsError` values with `InvalidStateError` or
8
+ * `TypeError` reasons, and `layer` provides the browser-backed service.
33
9
  *
34
10
  * @since 4.0.0
35
11
  */