@effect/platform-browser 4.0.0-beta.70 → 4.0.0-beta.72
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/dist/BrowserCrypto.d.ts +67 -4
- package/dist/BrowserCrypto.d.ts.map +1 -1
- package/dist/BrowserCrypto.js +67 -4
- package/dist/BrowserCrypto.js.map +1 -1
- package/dist/BrowserHttpClient.d.ts +16 -3
- package/dist/BrowserHttpClient.d.ts.map +1 -1
- package/dist/BrowserHttpClient.js +16 -3
- package/dist/BrowserHttpClient.js.map +1 -1
- package/dist/BrowserKeyValueStore.d.ts +20 -0
- package/dist/BrowserKeyValueStore.d.ts.map +1 -1
- package/dist/BrowserKeyValueStore.js +70 -15
- package/dist/BrowserKeyValueStore.js.map +1 -1
- package/dist/BrowserPersistence.d.ts +19 -0
- package/dist/BrowserPersistence.d.ts.map +1 -1
- package/dist/BrowserPersistence.js +19 -0
- package/dist/BrowserPersistence.js.map +1 -1
- package/dist/BrowserRuntime.d.ts +48 -0
- package/dist/BrowserRuntime.d.ts.map +1 -1
- package/dist/BrowserRuntime.js +16 -0
- package/dist/BrowserRuntime.js.map +1 -1
- package/dist/BrowserSocket.d.ts +55 -22
- package/dist/BrowserSocket.d.ts.map +1 -1
- package/dist/BrowserSocket.js +55 -22
- package/dist/BrowserSocket.js.map +1 -1
- package/dist/BrowserStream.d.ts +36 -21
- package/dist/BrowserStream.d.ts.map +1 -1
- package/dist/BrowserStream.js +36 -21
- package/dist/BrowserStream.js.map +1 -1
- package/dist/BrowserWorker.d.ts +17 -0
- package/dist/BrowserWorker.d.ts.map +1 -1
- package/dist/BrowserWorker.js +50 -18
- package/dist/BrowserWorker.js.map +1 -1
- package/dist/BrowserWorkerRunner.d.ts +19 -0
- package/dist/BrowserWorkerRunner.d.ts.map +1 -1
- package/dist/BrowserWorkerRunner.js +45 -14
- package/dist/BrowserWorkerRunner.js.map +1 -1
- package/dist/Clipboard.d.ts +55 -18
- package/dist/Clipboard.d.ts.map +1 -1
- package/dist/Clipboard.js +39 -15
- package/dist/Clipboard.js.map +1 -1
- package/dist/Geolocation.d.ts +63 -19
- package/dist/Geolocation.d.ts.map +1 -1
- package/dist/Geolocation.js +42 -18
- package/dist/Geolocation.js.map +1 -1
- package/dist/IndexedDb.d.ts +12 -0
- package/dist/IndexedDb.d.ts.map +1 -1
- package/dist/IndexedDb.js +12 -0
- package/dist/IndexedDb.js.map +1 -1
- package/dist/IndexedDbDatabase.d.ts +19 -0
- package/dist/IndexedDbDatabase.d.ts.map +1 -1
- package/dist/IndexedDbDatabase.js +19 -0
- package/dist/IndexedDbDatabase.js.map +1 -1
- package/dist/IndexedDbQueryBuilder.d.ts +8 -0
- package/dist/IndexedDbQueryBuilder.d.ts.map +1 -1
- package/dist/IndexedDbQueryBuilder.js +8 -0
- package/dist/IndexedDbQueryBuilder.js.map +1 -1
- package/dist/IndexedDbTable.d.ts +55 -17
- package/dist/IndexedDbTable.d.ts.map +1 -1
- package/dist/IndexedDbTable.js +55 -17
- package/dist/IndexedDbTable.js.map +1 -1
- package/dist/IndexedDbVersion.d.ts +14 -0
- package/dist/IndexedDbVersion.d.ts.map +1 -1
- package/dist/IndexedDbVersion.js +14 -0
- package/dist/IndexedDbVersion.js.map +1 -1
- package/dist/Permissions.d.ts +48 -18
- package/dist/Permissions.d.ts.map +1 -1
- package/dist/Permissions.js +48 -18
- package/dist/Permissions.js.map +1 -1
- package/dist/index.d.ts +0 -319
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -319
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/BrowserCrypto.ts +67 -4
- package/src/BrowserHttpClient.ts +16 -3
- package/src/BrowserKeyValueStore.ts +70 -15
- package/src/BrowserPersistence.ts +66 -9
- package/src/BrowserRuntime.ts +48 -0
- package/src/BrowserSocket.ts +55 -22
- package/src/BrowserStream.ts +33 -18
- package/src/BrowserWorker.ts +50 -18
- package/src/BrowserWorkerRunner.ts +45 -14
- package/src/Clipboard.ts +55 -18
- package/src/Geolocation.ts +63 -19
- package/src/IndexedDb.ts +12 -0
- package/src/IndexedDbDatabase.ts +19 -0
- package/src/IndexedDbQueryBuilder.ts +8 -0
- package/src/IndexedDbTable.ts +55 -17
- package/src/IndexedDbVersion.ts +14 -0
- package/src/Permissions.ts +48 -18
- package/src/index.ts +0 -319
package/src/Geolocation.ts
CHANGED
|
@@ -1,19 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Browser geolocation
|
|
3
|
-
*
|
|
4
|
-
* This module
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
2
|
+
* Browser geolocation integration for Effect programs.
|
|
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.
|
|
17
33
|
*
|
|
18
34
|
* @since 4.0.0
|
|
19
35
|
*/
|
|
@@ -29,7 +45,27 @@ const TypeId = "~@effect/platform-browser/Geolocation"
|
|
|
29
45
|
const ErrorTypeId = "~@effect/platform-browser/Geolocation/GeolocationError"
|
|
30
46
|
|
|
31
47
|
/**
|
|
32
|
-
*
|
|
48
|
+
* Defines the service interface for browser geolocation, providing effects for the current position and streams of watched positions.
|
|
49
|
+
*
|
|
50
|
+
* **When to use**
|
|
51
|
+
*
|
|
52
|
+
* Use when browser code needs a typed Effect service for one-shot location
|
|
53
|
+
* reads or streamed location updates.
|
|
54
|
+
*
|
|
55
|
+
* **Details**
|
|
56
|
+
*
|
|
57
|
+
* `getCurrentPosition` returns one position effect. `watchPosition` returns a
|
|
58
|
+
* stream and accepts the browser `PositionOptions` plus an optional sliding
|
|
59
|
+
* `bufferSize`.
|
|
60
|
+
*
|
|
61
|
+
* **Gotchas**
|
|
62
|
+
*
|
|
63
|
+
* Browser permission prompts, denied permissions, timeouts, unavailable
|
|
64
|
+
* position data, secure-context restrictions, and policy restrictions are
|
|
65
|
+
* surfaced as `GeolocationError`.
|
|
66
|
+
*
|
|
67
|
+
* @see {@link GeolocationError} for represented browser geolocation failures
|
|
68
|
+
* @see {@link layer} for the browser-backed service implementation
|
|
33
69
|
*
|
|
34
70
|
* @category models
|
|
35
71
|
* @since 4.0.0
|
|
@@ -49,7 +85,14 @@ export interface Geolocation {
|
|
|
49
85
|
}
|
|
50
86
|
|
|
51
87
|
/**
|
|
52
|
-
* Service tag for
|
|
88
|
+
* Service tag for browser geolocation capabilities.
|
|
89
|
+
*
|
|
90
|
+
* **When to use**
|
|
91
|
+
*
|
|
92
|
+
* Use when an Effect needs to access or provide geolocation capabilities
|
|
93
|
+
* through the context.
|
|
94
|
+
*
|
|
95
|
+
* @see {@link layer} for providing the browser-backed geolocation service
|
|
53
96
|
*
|
|
54
97
|
* @category services
|
|
55
98
|
* @since 4.0.0
|
|
@@ -194,9 +237,10 @@ export const layer: Layer.Layer<Geolocation> = Layer.succeed(
|
|
|
194
237
|
)
|
|
195
238
|
|
|
196
239
|
/**
|
|
197
|
-
*
|
|
240
|
+
* Reads geolocation positions from the `Geolocation` service as a stream, with
|
|
241
|
+
* an optional sliding buffer size.
|
|
198
242
|
*
|
|
199
|
-
* @category
|
|
243
|
+
* @category accessors
|
|
200
244
|
* @since 4.0.0
|
|
201
245
|
*/
|
|
202
246
|
export const watchPosition = (
|
package/src/IndexedDb.ts
CHANGED
|
@@ -73,6 +73,18 @@ export const IDBValidKey = Schema.Union([IDBFlatKey, Schema.Array(IDBFlatKey)])
|
|
|
73
73
|
/**
|
|
74
74
|
* Schema for auto-incremented IndexedDB keys, accepting integers from 1 through `2 ** 53`.
|
|
75
75
|
*
|
|
76
|
+
* **When to use**
|
|
77
|
+
*
|
|
78
|
+
* Use when defining numeric key-path fields for `IndexedDbTable` definitions
|
|
79
|
+
* that use IndexedDB auto-increment keys.
|
|
80
|
+
*
|
|
81
|
+
* **Details**
|
|
82
|
+
*
|
|
83
|
+
* The schema accepts integer values from `1` through `2 ** 53`, matching the
|
|
84
|
+
* range used for generated IndexedDB auto-increment keys.
|
|
85
|
+
*
|
|
86
|
+
* @see {@link IDBValidKey} for the broader IndexedDB key schema
|
|
87
|
+
*
|
|
76
88
|
* @category schemas
|
|
77
89
|
* @since 4.0.0
|
|
78
90
|
*/
|
package/src/IndexedDbDatabase.ts
CHANGED
|
@@ -123,6 +123,25 @@ export class IndexedDbDatabaseError extends Data.TaggedError(
|
|
|
123
123
|
/**
|
|
124
124
|
* Service tag for an open IndexedDB database, its `IDBKeyRange` constructor, reactivity service, and rebuild effect.
|
|
125
125
|
*
|
|
126
|
+
* **When to use**
|
|
127
|
+
*
|
|
128
|
+
* Use when an effect needs access to the live database service after an
|
|
129
|
+
* `IndexedDbSchema` layer has been provided, especially for `rebuild` or
|
|
130
|
+
* lower-level database primitives.
|
|
131
|
+
*
|
|
132
|
+
* **Details**
|
|
133
|
+
*
|
|
134
|
+
* `database` is a mutable reference to the current `IDBDatabase`. `IDBKeyRange`
|
|
135
|
+
* and `reactivity` are shared with query builders created from the schema.
|
|
136
|
+
*
|
|
137
|
+
* **Gotchas**
|
|
138
|
+
*
|
|
139
|
+
* `rebuild` closes and deletes the browser database, then reopens it and reruns
|
|
140
|
+
* migrations. Records not recreated by migrations are removed.
|
|
141
|
+
*
|
|
142
|
+
* @see {@link IndexedDb.IndexedDb} for the lower-level browser IndexedDB primitives
|
|
143
|
+
* @see {@link make} for creating a schema that provides this service as a layer
|
|
144
|
+
*
|
|
126
145
|
* @category models
|
|
127
146
|
* @since 4.0.0
|
|
128
147
|
*/
|
|
@@ -84,6 +84,14 @@ export type ErrorReason =
|
|
|
84
84
|
/**
|
|
85
85
|
* Tagged error for IndexedDB query operations, carrying a query error reason and the original cause.
|
|
86
86
|
*
|
|
87
|
+
* **Details**
|
|
88
|
+
*
|
|
89
|
+
* `reason` is the query failure category, `cause` preserves the underlying
|
|
90
|
+
* schema, IndexedDB request, transaction, or user callback failure, and
|
|
91
|
+
* `message` is set to the reason.
|
|
92
|
+
*
|
|
93
|
+
* @see {@link ErrorReason} for the supported failure categories
|
|
94
|
+
*
|
|
87
95
|
* @category errors
|
|
88
96
|
* @since 4.0.0
|
|
89
97
|
*/
|
package/src/IndexedDbTable.ts
CHANGED
|
@@ -1,21 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* An
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
2
|
+
* Typed object-store descriptors for the browser IndexedDB integration.
|
|
3
|
+
*
|
|
4
|
+
* An {@link IndexedDbTable} is the schema-backed description of one IndexedDB
|
|
5
|
+
* object store. It carries the store name, row schema, key path, index key
|
|
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.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link make} for constructing table descriptors.
|
|
19
36
|
*
|
|
20
37
|
* @since 4.0.0
|
|
21
38
|
*/
|
|
@@ -176,6 +193,27 @@ const Proto = {
|
|
|
176
193
|
/**
|
|
177
194
|
* Creates a typed IndexedDB table definition from its name, schema, optional key path, indexes, auto-increment flag, and durability.
|
|
178
195
|
*
|
|
196
|
+
* **When to use**
|
|
197
|
+
*
|
|
198
|
+
* Use to define a typed object-store descriptor for inclusion in an
|
|
199
|
+
* `IndexedDbVersion` and for migration or query APIs.
|
|
200
|
+
*
|
|
201
|
+
* **Details**
|
|
202
|
+
*
|
|
203
|
+
* `autoIncrement` defaults to `false` and `durability` defaults to `"relaxed"`.
|
|
204
|
+
* Tables without a key path get a read schema that includes an out-of-line
|
|
205
|
+
* `key`, while auto-increment tables use a write schema where the generated key
|
|
206
|
+
* may be omitted.
|
|
207
|
+
*
|
|
208
|
+
* **Gotchas**
|
|
209
|
+
*
|
|
210
|
+
* Tables without a key path cannot define a `key` field in their row schema.
|
|
211
|
+
* Key paths and index paths must point to encoded fields whose values are valid
|
|
212
|
+
* IndexedDB keys, and declared indexes still need to be created during
|
|
213
|
+
* database migrations.
|
|
214
|
+
*
|
|
215
|
+
* @see `IndexedDbVersion.make` for grouping table definitions into a schema version
|
|
216
|
+
*
|
|
179
217
|
* @category constructors
|
|
180
218
|
* @since 4.0.0
|
|
181
219
|
*/
|
package/src/IndexedDbVersion.ts
CHANGED
|
@@ -106,6 +106,20 @@ const makeProto = <Tables extends IndexedDbTable.AnyWithProps>(options: {
|
|
|
106
106
|
/**
|
|
107
107
|
* Creates an `IndexedDbVersion` from one or more table definitions.
|
|
108
108
|
*
|
|
109
|
+
* **Details**
|
|
110
|
+
*
|
|
111
|
+
* The returned version exposes a `tables` map keyed by each table's
|
|
112
|
+
* `tableName`, and its type is the union of the supplied table definitions.
|
|
113
|
+
*
|
|
114
|
+
* **Gotchas**
|
|
115
|
+
*
|
|
116
|
+
* This constructor only describes the target schema; object stores and indexes
|
|
117
|
+
* still need to be created in the corresponding `IndexedDbDatabase` migration.
|
|
118
|
+
* Duplicate table names are not rejected, and the runtime map keeps the later
|
|
119
|
+
* table for a repeated key.
|
|
120
|
+
*
|
|
121
|
+
* @see {@link IndexedDbTable.make} for creating table definitions consumed by this constructor
|
|
122
|
+
*
|
|
109
123
|
* @category constructors
|
|
110
124
|
* @since 4.0.0
|
|
111
125
|
*/
|
package/src/Permissions.ts
CHANGED
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* This module
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* camera, microphone,
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* permission
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
2
|
+
* Effect service for the browser Permissions API.
|
|
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.
|
|
18
33
|
*
|
|
19
34
|
* @since 4.0.0
|
|
20
35
|
*/
|
|
@@ -109,7 +124,12 @@ export class PermissionsError extends Data.TaggedError("PermissionsError")<{
|
|
|
109
124
|
}
|
|
110
125
|
|
|
111
126
|
/**
|
|
112
|
-
* Service tag for
|
|
127
|
+
* Service tag for browser permission querying.
|
|
128
|
+
*
|
|
129
|
+
* **When to use**
|
|
130
|
+
*
|
|
131
|
+
* Use when an Effect needs to require or provide browser permission querying
|
|
132
|
+
* through the context.
|
|
113
133
|
*
|
|
114
134
|
* @category services
|
|
115
135
|
* @since 4.0.0
|
|
@@ -117,7 +137,17 @@ export class PermissionsError extends Data.TaggedError("PermissionsError")<{
|
|
|
117
137
|
export const Permissions: Context.Service<Permissions, Permissions> = Context.Service<Permissions>(TypeId)
|
|
118
138
|
|
|
119
139
|
/**
|
|
120
|
-
*
|
|
140
|
+
* Provides the `Permissions` service using the browser `navigator.permissions` API.
|
|
141
|
+
*
|
|
142
|
+
* **When to use**
|
|
143
|
+
*
|
|
144
|
+
* Use when browser programs need a live `Permissions` service backed by the
|
|
145
|
+
* ambient `navigator.permissions` implementation.
|
|
146
|
+
*
|
|
147
|
+
* **Details**
|
|
148
|
+
*
|
|
149
|
+
* `query` delegates to `navigator.permissions.query({ name })` and wraps
|
|
150
|
+
* rejected browser operations in `PermissionsError`.
|
|
121
151
|
*
|
|
122
152
|
* @category layers
|
|
123
153
|
* @since 4.0.0
|