@effect/platform-browser 4.0.0-beta.66 → 4.0.0-beta.67

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 (84) hide show
  1. package/dist/BrowserHttpClient.d.ts +18 -8
  2. package/dist/BrowserHttpClient.d.ts.map +1 -1
  3. package/dist/BrowserHttpClient.js +45 -8
  4. package/dist/BrowserHttpClient.js.map +1 -1
  5. package/dist/BrowserKeyValueStore.d.ts +13 -6
  6. package/dist/BrowserKeyValueStore.d.ts.map +1 -1
  7. package/dist/BrowserKeyValueStore.js +126 -2
  8. package/dist/BrowserKeyValueStore.js.map +1 -1
  9. package/dist/BrowserPersistence.d.ts +6 -2
  10. package/dist/BrowserPersistence.d.ts.map +1 -1
  11. package/dist/BrowserPersistence.js +6 -2
  12. package/dist/BrowserPersistence.js.map +1 -1
  13. package/dist/BrowserRuntime.d.ts +31 -4
  14. package/dist/BrowserRuntime.d.ts.map +1 -1
  15. package/dist/BrowserRuntime.js +3 -1
  16. package/dist/BrowserRuntime.js.map +1 -1
  17. package/dist/BrowserSocket.d.ts +29 -4
  18. package/dist/BrowserSocket.d.ts.map +1 -1
  19. package/dist/BrowserSocket.js +29 -4
  20. package/dist/BrowserSocket.js.map +1 -1
  21. package/dist/BrowserStream.d.ts +25 -3
  22. package/dist/BrowserStream.d.ts.map +1 -1
  23. package/dist/BrowserStream.js +25 -3
  24. package/dist/BrowserStream.js.map +1 -1
  25. package/dist/BrowserWorker.d.ts +6 -2
  26. package/dist/BrowserWorker.d.ts.map +1 -1
  27. package/dist/BrowserWorker.js +27 -3
  28. package/dist/BrowserWorker.js.map +1 -1
  29. package/dist/BrowserWorkerRunner.d.ts +9 -3
  30. package/dist/BrowserWorkerRunner.d.ts.map +1 -1
  31. package/dist/BrowserWorkerRunner.js +28 -4
  32. package/dist/BrowserWorkerRunner.js.map +1 -1
  33. package/dist/Clipboard.d.ts +30 -6
  34. package/dist/Clipboard.d.ts.map +1 -1
  35. package/dist/Clipboard.js +27 -5
  36. package/dist/Clipboard.js.map +1 -1
  37. package/dist/Geolocation.d.ts +44 -10
  38. package/dist/Geolocation.d.ts.map +1 -1
  39. package/dist/Geolocation.js +38 -8
  40. package/dist/Geolocation.js.map +1 -1
  41. package/dist/IndexedDb.d.ts +38 -11
  42. package/dist/IndexedDb.d.ts.map +1 -1
  43. package/dist/IndexedDb.js +35 -13
  44. package/dist/IndexedDb.js.map +1 -1
  45. package/dist/IndexedDbDatabase.d.ts +57 -10
  46. package/dist/IndexedDbDatabase.d.ts.map +1 -1
  47. package/dist/IndexedDbDatabase.js +36 -3
  48. package/dist/IndexedDbDatabase.js.map +1 -1
  49. package/dist/IndexedDbQueryBuilder.d.ts +103 -28
  50. package/dist/IndexedDbQueryBuilder.d.ts.map +1 -1
  51. package/dist/IndexedDbQueryBuilder.js +56 -26
  52. package/dist/IndexedDbQueryBuilder.js.map +1 -1
  53. package/dist/IndexedDbTable.d.ts +57 -13
  54. package/dist/IndexedDbTable.d.ts.map +1 -1
  55. package/dist/IndexedDbTable.js +21 -1
  56. package/dist/IndexedDbTable.js.map +1 -1
  57. package/dist/IndexedDbVersion.d.ts +37 -7
  58. package/dist/IndexedDbVersion.d.ts.map +1 -1
  59. package/dist/IndexedDbVersion.js +3 -1
  60. package/dist/IndexedDbVersion.js.map +1 -1
  61. package/dist/Permissions.d.ts +35 -8
  62. package/dist/Permissions.d.ts.map +1 -1
  63. package/dist/Permissions.js +31 -6
  64. package/dist/Permissions.js.map +1 -1
  65. package/dist/index.d.ts +12 -12
  66. package/dist/index.js +12 -12
  67. package/package.json +3 -3
  68. package/src/BrowserHttpClient.ts +48 -9
  69. package/src/BrowserKeyValueStore.ts +142 -4
  70. package/src/BrowserPersistence.ts +19 -3
  71. package/src/BrowserRuntime.ts +31 -4
  72. package/src/BrowserSocket.ts +29 -4
  73. package/src/BrowserStream.ts +25 -3
  74. package/src/BrowserWorker.ts +27 -3
  75. package/src/BrowserWorkerRunner.ts +28 -4
  76. package/src/Clipboard.ts +30 -6
  77. package/src/Geolocation.ts +44 -10
  78. package/src/IndexedDb.ts +39 -21
  79. package/src/IndexedDbDatabase.ts +57 -10
  80. package/src/IndexedDbQueryBuilder.ts +172 -58
  81. package/src/IndexedDbTable.ts +57 -13
  82. package/src/IndexedDbVersion.ts +37 -7
  83. package/src/Permissions.ts +35 -8
  84. package/src/index.ts +12 -12
@@ -1,4 +1,22 @@
1
1
  /**
2
+ * Defines typed table descriptors for the browser IndexedDB integration.
3
+ *
4
+ * An `IndexedDbTable` records the object store name, row schema, primary key
5
+ * path, indexes, auto-increment behavior, and transaction durability used by
6
+ * database versions, migrations, and typed queries. These descriptors are
7
+ * useful for local caches, offline-first application state, background queues,
8
+ * drafts, and other browser-persisted data that should be validated through
9
+ * `Schema`.
10
+ *
11
+ * Key paths and index paths must reference encoded schema fields whose values
12
+ * are valid IndexedDB keys, and compound paths are represented as readonly
13
+ * arrays. Tables without a key path use an out-of-line `key` that is added to
14
+ * reads and required for writes, so the row schema itself cannot define a
15
+ * `key` field. Auto-increment tables require a numeric key path; when that key
16
+ * is omitted on write, the module uses a derived schema without the generated
17
+ * key. Declaring indexes here types query builder index selection, but the
18
+ * indexes still need to be created during database migrations.
19
+ *
2
20
  * @since 4.0.0
3
21
  */
4
22
  import { type Pipeable, pipeArguments } from "effect/Pipeable"
@@ -11,8 +29,10 @@ import type * as IndexedDbQueryBuilder from "./IndexedDbQueryBuilder.ts"
11
29
  const TypeId = "~@effect/platform-browser/IndexedDbTable"
12
30
 
13
31
  /**
14
- * @since 4.0.0
32
+ * Typed IndexedDB table definition containing its name, schema, key path, indexes, auto-increment setting, and transaction durability.
33
+ *
15
34
  * @category interface
35
+ * @since 4.0.0
16
36
  */
17
37
  export interface IndexedDbTable<
18
38
  out Name extends string,
@@ -38,16 +58,20 @@ export interface IndexedDbTable<
38
58
  }
39
59
 
40
60
  /**
41
- * @since 4.0.0
61
+ * Schema constraint for table schemas that expose struct fields.
62
+ *
42
63
  * @category models
64
+ * @since 4.0.0
43
65
  */
44
66
  export type AnySchemaStruct = Schema.Top & {
45
67
  readonly fields: Schema.Struct.Fields
46
68
  }
47
69
 
48
70
  /**
49
- * @since 4.0.0
71
+ * Type-erased shape of an `IndexedDbTable` used when table type parameters are not needed.
72
+ *
50
73
  * @category models
74
+ * @since 4.0.0
51
75
  */
52
76
  export interface Any {
53
77
  readonly [TypeId]: typeof TypeId
@@ -62,8 +86,10 @@ export interface Any {
62
86
  }
63
87
 
64
88
  /**
65
- * @since 4.0.0
89
+ * Type-erased `IndexedDbTable` retaining the table interface properties with broad type parameters.
90
+ *
66
91
  * @category models
92
+ * @since 4.0.0
67
93
  */
68
94
  export type AnyWithProps = IndexedDbTable<
69
95
  string,
@@ -74,50 +100,66 @@ export type AnyWithProps = IndexedDbTable<
74
100
  >
75
101
 
76
102
  /**
77
- * @since 4.0.0
103
+ * Extracts the table name type from an `IndexedDbTable`.
104
+ *
78
105
  * @category models
106
+ * @since 4.0.0
79
107
  */
80
108
  export type TableName<Table extends Any> = Table["tableName"]
81
109
  /**
82
- * @since 4.0.0
110
+ * Extracts the key-path type from an `IndexedDbTable`.
111
+ *
83
112
  * @category models
113
+ * @since 4.0.0
84
114
  */
85
115
  export type KeyPath<Table extends Any> = Table["keyPath"]
86
116
 
87
117
  /**
88
- * @since 4.0.0
118
+ * Extracts the auto-increment flag type from an `IndexedDbTable`.
119
+ *
89
120
  * @category models
121
+ * @since 4.0.0
90
122
  */
91
123
  export type AutoIncrement<Table extends Any> = Table["autoIncrement"]
92
124
 
93
125
  /**
94
- * @since 4.0.0
126
+ * Extracts the schema type from an `IndexedDbTable`.
127
+ *
95
128
  * @category models
129
+ * @since 4.0.0
96
130
  */
97
131
  export type TableSchema<Table extends Any> = Table["tableSchema"]
98
132
  /**
99
- * @since 4.0.0
133
+ * Extracts the decoding or encoding service requirements needed by an `IndexedDbTable` schema.
134
+ *
100
135
  * @category models
136
+ * @since 4.0.0
101
137
  */
102
138
  export type Context<Table extends Any> =
103
139
  | Table["tableSchema"]["DecodingServices"]
104
140
  | Table["tableSchema"]["EncodingServices"]
105
141
 
106
142
  /**
107
- * @since 4.0.0
143
+ * Extracts the encoded row type from an `IndexedDbTable` schema.
144
+ *
108
145
  * @category models
146
+ * @since 4.0.0
109
147
  */
110
148
  export type Encoded<Table extends Any> = Table["tableSchema"]["Encoded"]
111
149
 
112
150
  /**
113
- * @since 4.0.0
151
+ * Extracts the index definition map from an `IndexedDbTable`.
152
+ *
114
153
  * @category models
154
+ * @since 4.0.0
115
155
  */
116
156
  export type Indexes<Table extends Any> = Table["indexes"]
117
157
 
118
158
  /**
119
- * @since 4.0.0
159
+ * Selects the table with the given name from a union of `IndexedDbTable` types.
160
+ *
120
161
  * @category models
162
+ * @since 4.0.0
121
163
  */
122
164
  export type WithName<Table extends Any, TableName extends string> = Extract<
123
165
  Table,
@@ -132,8 +174,10 @@ const Proto = {
132
174
  }
133
175
 
134
176
  /**
135
- * @since 4.0.0
177
+ * Creates a typed IndexedDB table definition from its name, schema, optional key path, indexes, auto-increment flag, and durability.
178
+ *
136
179
  * @category constructors
180
+ * @since 4.0.0
137
181
  */
138
182
  export const make = <
139
183
  const Name extends string,
@@ -1,4 +1,20 @@
1
1
  /**
2
+ * Typed IndexedDB schema version definitions.
3
+ *
4
+ * This module represents one logical IndexedDB database version as a non-empty set of `IndexedDbTable` definitions.
5
+ * Versions are consumed by `IndexedDbDatabase.make` and `.add` to type query builders and migration transactions, so
6
+ * applications can describe the tables available after initialization or after each schema upgrade.
7
+ *
8
+ * Use an `IndexedDbVersion` when defining the initial stores for a browser database, adding or removing object stores,
9
+ * changing indexes, or moving data between differently shaped table schemas. The version value is a typed description of
10
+ * the target schema; creating and deleting object stores or indexes still happens explicitly inside the corresponding
11
+ * `IndexedDbDatabase` migration callback.
12
+ *
13
+ * IndexedDB versioning is ordered by the migration chain rather than by a number stored here. Each `.add` step becomes
14
+ * the next browser database version, and only migrations after the browser's current version are run. Include every table
15
+ * that should be queryable in each target version, avoid duplicate table names, and remember that key-path or
16
+ * auto-increment changes usually require creating a new object store and copying data during the upgrade transaction.
17
+ *
2
18
  * @since 4.0.0
3
19
  */
4
20
  import type { NonEmptyReadonlyArray } from "effect/Array"
@@ -9,8 +25,10 @@ import type * as IndexedDbTable from "./IndexedDbTable.ts"
9
25
  const TypeId = "~@effect/platform-browser/IndexedDbVersion"
10
26
 
11
27
  /**
12
- * @since 4.0.0
28
+ * Typed IndexedDB version definition containing the tables available in that schema version.
29
+ *
13
30
  * @category interface
31
+ * @since 4.0.0
14
32
  */
15
33
  export interface IndexedDbVersion<
16
34
  out Tables extends IndexedDbTable.AnyWithProps
@@ -21,28 +39,36 @@ export interface IndexedDbVersion<
21
39
  }
22
40
 
23
41
  /**
24
- * @since 4.0.0
42
+ * Type-erased shape of an `IndexedDbVersion`.
43
+ *
25
44
  * @category models
45
+ * @since 4.0.0
26
46
  */
27
47
  export interface Any {
28
48
  readonly [TypeId]: typeof TypeId
29
49
  }
30
50
 
31
51
  /**
32
- * @since 4.0.0
52
+ * Type-erased `IndexedDbVersion` retaining version properties with broad table types.
53
+ *
33
54
  * @category models
55
+ * @since 4.0.0
34
56
  */
35
57
  export type AnyWithProps = IndexedDbVersion<IndexedDbTable.AnyWithProps>
36
58
 
37
59
  /**
38
- * @since 4.0.0
60
+ * Extracts the table union from an `IndexedDbVersion`.
61
+ *
39
62
  * @category models
63
+ * @since 4.0.0
40
64
  */
41
65
  export type Tables<Db extends Any> = Db extends IndexedDbVersion<infer _Tables> ? _Tables : never
42
66
 
43
67
  /**
44
- * @since 4.0.0
68
+ * Selects a table by name from an `IndexedDbVersion`.
69
+ *
45
70
  * @category models
71
+ * @since 4.0.0
46
72
  */
47
73
  export type TableWithName<
48
74
  Db extends Any,
@@ -50,8 +76,10 @@ export type TableWithName<
50
76
  > = IndexedDbTable.WithName<Tables<Db>, TableName>
51
77
 
52
78
  /**
53
- * @since 4.0.0
79
+ * Extracts the schema for a named table within an `IndexedDbVersion`.
80
+ *
54
81
  * @category models
82
+ * @since 4.0.0
55
83
  */
56
84
  export type SchemaWithName<
57
85
  Db extends Any,
@@ -76,8 +104,10 @@ const makeProto = <Tables extends IndexedDbTable.AnyWithProps>(options: {
76
104
  }
77
105
 
78
106
  /**
79
- * @since 4.0.0
107
+ * Creates an `IndexedDbVersion` from one or more table definitions.
108
+ *
80
109
  * @category constructors
110
+ * @since 4.0.0
81
111
  */
82
112
  export const make = <
83
113
  const Tables extends NonEmptyReadonlyArray<IndexedDbTable.AnyWithProps>
@@ -1,5 +1,22 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Browser Permissions API support for Effect programs.
3
+ *
4
+ * This module provides a `Permissions` service and browser-backed layer for
5
+ * querying `navigator.permissions` from Effect code. Use it to check whether a
6
+ * browser capability is currently `granted`, `prompt`, or `denied` before
7
+ * showing UI for flows such as geolocation, notifications, clipboard access,
8
+ * camera, microphone, or persistent storage.
9
+ *
10
+ * Permission queries do not request access by themselves and should not replace
11
+ * the feature API that actually performs the operation. Browser support for
12
+ * permission names and states is uneven, queries may reject for unsupported or
13
+ * invalid descriptors, and some permissions are only meaningful in secure
14
+ * contexts or after user activation. Returned `PermissionStatus` objects can
15
+ * change when the user updates browser settings or responds to prompts; when
16
+ * watching `change` or `onchange`, account for browser differences and clean up
17
+ * listeners when the surrounding Effect scope ends.
18
+ *
19
+ * @since 4.0.0
3
20
  */
4
21
  import * as Context from "effect/Context"
5
22
  import * as Data from "effect/Data"
@@ -13,8 +30,8 @@ const ErrorTypeId = "~@effect/platform-browser/Permissions/PermissionsError"
13
30
  * Wrapper on the Permission API (`navigator.permissions`) with methods for
14
31
  * querying status of permissions.
15
32
  *
16
- * @since 1.0.0
17
33
  * @category Models
34
+ * @since 4.0.0
18
35
  */
19
36
  export interface Permissions {
20
37
  readonly [TypeId]: typeof TypeId
@@ -33,8 +50,10 @@ export interface Permissions {
33
50
  }
34
51
 
35
52
  /**
36
- * @since 1.0.0
53
+ * Error reason for an `InvalidStateError` raised by the browser Permissions API.
54
+ *
37
55
  * @category errors
56
+ * @since 4.0.0
38
57
  */
39
58
  export class PermissionsInvalidStateError extends Data.TaggedError("InvalidStateError")<{
40
59
  readonly cause: unknown
@@ -45,8 +64,10 @@ export class PermissionsInvalidStateError extends Data.TaggedError("InvalidState
45
64
  }
46
65
 
47
66
  /**
48
- * @since 1.0.0
67
+ * Error reason for a `TypeError` raised by the browser Permissions API.
68
+ *
49
69
  * @category errors
70
+ * @since 4.0.0
50
71
  */
51
72
  export class PermissionsTypeError extends Data.TaggedError("TypeError")<{
52
73
  readonly cause: unknown
@@ -57,14 +78,18 @@ export class PermissionsTypeError extends Data.TaggedError("TypeError")<{
57
78
  }
58
79
 
59
80
  /**
60
- * @since 1.0.0
81
+ * Union of browser Permissions API error reasons represented by the service.
82
+ *
61
83
  * @category errors
84
+ * @since 4.0.0
62
85
  */
63
86
  export type PermissionsErrorReason = PermissionsInvalidStateError | PermissionsTypeError
64
87
 
65
88
  /**
66
- * @since 1.0.0
89
+ * Tagged error wrapping a browser Permissions API failure reason.
90
+ *
67
91
  * @category errors
92
+ * @since 4.0.0
68
93
  */
69
94
  export class PermissionsError extends Data.TaggedError("PermissionsError")<{
70
95
  readonly reason: PermissionsErrorReason
@@ -84,16 +109,18 @@ export class PermissionsError extends Data.TaggedError("PermissionsError")<{
84
109
  }
85
110
 
86
111
  /**
87
- * @since 1.0.0
112
+ * Service tag for the browser `Permissions` service.
113
+ *
88
114
  * @category Service
115
+ * @since 4.0.0
89
116
  */
90
117
  export const Permissions: Context.Service<Permissions, Permissions> = Context.Service<Permissions>(TypeId)
91
118
 
92
119
  /**
93
120
  * A layer that directly interfaces with the `navigator.permissions` api
94
121
  *
95
- * @since 1.0.0
96
122
  * @category Layers
123
+ * @since 4.0.0
97
124
  */
98
125
  export const layer: Layer.Layer<Permissions> = Layer.succeed(
99
126
  Permissions,
package/src/index.ts CHANGED
@@ -1,56 +1,56 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
 
5
5
  // @barrel: Auto-generated exports. Do not edit manually.
6
6
 
7
7
  /**
8
- * @since 1.0.0
8
+ * @since 4.0.0
9
9
  */
10
10
  export * as BrowserHttpClient from "./BrowserHttpClient.ts"
11
11
 
12
12
  /**
13
- * @since 1.0.0
13
+ * @since 4.0.0
14
14
  */
15
15
  export * as BrowserKeyValueStore from "./BrowserKeyValueStore.ts"
16
16
 
17
17
  /**
18
- * @since 1.0.0
18
+ * @since 4.0.0
19
19
  */
20
20
  export * as BrowserPersistence from "./BrowserPersistence.ts"
21
21
 
22
22
  /**
23
- * @since 1.0.0
23
+ * @since 4.0.0
24
24
  */
25
25
  export * as BrowserRuntime from "./BrowserRuntime.ts"
26
26
 
27
27
  /**
28
- * @since 1.0.0
28
+ * @since 4.0.0
29
29
  */
30
30
  export * as BrowserSocket from "./BrowserSocket.ts"
31
31
 
32
32
  /**
33
- * @since 1.0.0
33
+ * @since 4.0.0
34
34
  */
35
35
  export * as BrowserStream from "./BrowserStream.ts"
36
36
 
37
37
  /**
38
- * @since 1.0.0
38
+ * @since 4.0.0
39
39
  */
40
40
  export * as BrowserWorker from "./BrowserWorker.ts"
41
41
 
42
42
  /**
43
- * @since 1.0.0
43
+ * @since 4.0.0
44
44
  */
45
45
  export * as BrowserWorkerRunner from "./BrowserWorkerRunner.ts"
46
46
 
47
47
  /**
48
- * @since 1.0.0
48
+ * @since 4.0.0
49
49
  */
50
50
  export * as Clipboard from "./Clipboard.ts"
51
51
 
52
52
  /**
53
- * @since 1.0.0
53
+ * @since 4.0.0
54
54
  */
55
55
  export * as Geolocation from "./Geolocation.ts"
56
56
 
@@ -80,6 +80,6 @@ export * as IndexedDbTable from "./IndexedDbTable.ts"
80
80
  export * as IndexedDbVersion from "./IndexedDbVersion.ts"
81
81
 
82
82
  /**
83
- * @since 1.0.0
83
+ * @since 4.0.0
84
84
  */
85
85
  export * as Permissions from "./Permissions.ts"