@effect/platform-browser 4.0.0-beta.66 → 4.0.0-beta.68
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 +23 -0
- package/dist/BrowserCrypto.d.ts.map +1 -0
- package/dist/BrowserCrypto.js +61 -0
- package/dist/BrowserCrypto.js.map +1 -0
- package/dist/BrowserHttpClient.d.ts +23 -13
- package/dist/BrowserHttpClient.d.ts.map +1 -1
- package/dist/BrowserHttpClient.js +49 -12
- package/dist/BrowserHttpClient.js.map +1 -1
- package/dist/BrowserKeyValueStore.d.ts +15 -8
- package/dist/BrowserKeyValueStore.d.ts.map +1 -1
- package/dist/BrowserKeyValueStore.js +128 -4
- package/dist/BrowserKeyValueStore.js.map +1 -1
- package/dist/BrowserPersistence.d.ts +6 -2
- package/dist/BrowserPersistence.d.ts.map +1 -1
- package/dist/BrowserPersistence.js +6 -2
- package/dist/BrowserPersistence.js.map +1 -1
- package/dist/BrowserRuntime.d.ts +31 -4
- package/dist/BrowserRuntime.d.ts.map +1 -1
- package/dist/BrowserRuntime.js +3 -1
- package/dist/BrowserRuntime.js.map +1 -1
- package/dist/BrowserSocket.d.ts +31 -6
- package/dist/BrowserSocket.d.ts.map +1 -1
- package/dist/BrowserSocket.js +31 -6
- package/dist/BrowserSocket.js.map +1 -1
- package/dist/BrowserStream.d.ts +25 -3
- package/dist/BrowserStream.d.ts.map +1 -1
- package/dist/BrowserStream.js +25 -3
- package/dist/BrowserStream.js.map +1 -1
- package/dist/BrowserWorker.d.ts +8 -4
- package/dist/BrowserWorker.d.ts.map +1 -1
- package/dist/BrowserWorker.js +29 -5
- package/dist/BrowserWorker.js.map +1 -1
- package/dist/BrowserWorkerRunner.d.ts +12 -6
- package/dist/BrowserWorkerRunner.d.ts.map +1 -1
- package/dist/BrowserWorkerRunner.js +31 -7
- package/dist/BrowserWorkerRunner.js.map +1 -1
- package/dist/Clipboard.d.ts +35 -11
- package/dist/Clipboard.d.ts.map +1 -1
- package/dist/Clipboard.js +31 -9
- package/dist/Clipboard.js.map +1 -1
- package/dist/Geolocation.d.ts +52 -18
- package/dist/Geolocation.d.ts.map +1 -1
- package/dist/Geolocation.js +44 -14
- package/dist/Geolocation.js.map +1 -1
- package/dist/IndexedDb.d.ts +38 -11
- package/dist/IndexedDb.d.ts.map +1 -1
- package/dist/IndexedDb.js +35 -13
- package/dist/IndexedDb.js.map +1 -1
- package/dist/IndexedDbDatabase.d.ts +57 -10
- package/dist/IndexedDbDatabase.d.ts.map +1 -1
- package/dist/IndexedDbDatabase.js +36 -3
- package/dist/IndexedDbDatabase.js.map +1 -1
- package/dist/IndexedDbQueryBuilder.d.ts +102 -28
- package/dist/IndexedDbQueryBuilder.d.ts.map +1 -1
- package/dist/IndexedDbQueryBuilder.js +56 -26
- package/dist/IndexedDbQueryBuilder.js.map +1 -1
- package/dist/IndexedDbTable.d.ts +57 -13
- package/dist/IndexedDbTable.d.ts.map +1 -1
- package/dist/IndexedDbTable.js +21 -1
- package/dist/IndexedDbTable.js.map +1 -1
- package/dist/IndexedDbVersion.d.ts +37 -7
- package/dist/IndexedDbVersion.d.ts.map +1 -1
- package/dist/IndexedDbVersion.js +3 -1
- package/dist/IndexedDbVersion.js.map +1 -1
- package/dist/Permissions.d.ts +38 -11
- package/dist/Permissions.d.ts.map +1 -1
- package/dist/Permissions.js +33 -8
- package/dist/Permissions.js.map +1 -1
- package/dist/index.d.ts +334 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +334 -11
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/BrowserCrypto.ts +71 -0
- package/src/BrowserHttpClient.ts +53 -14
- package/src/BrowserKeyValueStore.ts +144 -6
- package/src/BrowserPersistence.ts +19 -3
- package/src/BrowserRuntime.ts +31 -4
- package/src/BrowserSocket.ts +31 -6
- package/src/BrowserStream.ts +25 -3
- package/src/BrowserWorker.ts +29 -5
- package/src/BrowserWorkerRunner.ts +31 -7
- package/src/Clipboard.ts +35 -11
- package/src/Geolocation.ts +52 -18
- package/src/IndexedDb.ts +39 -21
- package/src/IndexedDbDatabase.ts +57 -10
- package/src/IndexedDbQueryBuilder.ts +171 -58
- package/src/IndexedDbTable.ts +57 -13
- package/src/IndexedDbVersion.ts +37 -7
- package/src/Permissions.ts +38 -11
- package/src/index.ts +335 -11
package/dist/Clipboard.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Browser clipboard service for Effect programs.
|
|
3
|
+
*
|
|
4
|
+
* This module wraps the browser `navigator.clipboard` API in a `Clipboard`
|
|
5
|
+
* service so client-side applications can read, write, and clear clipboard
|
|
6
|
+
* contents as typed Effects. It is useful for common UI workflows such as copy
|
|
7
|
+
* buttons, paste/import actions, sharing generated text, and moving rich
|
|
8
|
+
* clipboard payloads like `Blob`-backed `ClipboardItem`s through an Effect
|
|
9
|
+
* environment.
|
|
10
|
+
*
|
|
11
|
+
* Browser clipboard rules still apply. Clipboard access generally requires a
|
|
12
|
+
* secure context, and browsers may require a user gesture, permission prompt, or
|
|
13
|
+
* active focused document before reads or writes are allowed. Support also
|
|
14
|
+
* varies by operation and payload type: text helpers are the most portable,
|
|
15
|
+
* while `ClipboardItem` and non-text MIME types may be unavailable or restricted
|
|
16
|
+
* in some browsers. Failed browser operations are surfaced as `ClipboardError`.
|
|
17
|
+
*
|
|
18
|
+
* @since 4.0.0
|
|
3
19
|
*/
|
|
4
20
|
import * as Context from "effect/Context";
|
|
5
21
|
import * as Effect from "effect/Effect";
|
|
@@ -7,8 +23,10 @@ import * as Layer from "effect/Layer";
|
|
|
7
23
|
declare const TypeId = "~@effect/platform-browser/Clipboard";
|
|
8
24
|
declare const ErrorTypeId = "~@effect/platform-browser/Clipboard/ClipboardError";
|
|
9
25
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
26
|
+
* Service interface for reading from, writing to, and clearing the browser clipboard.
|
|
27
|
+
*
|
|
28
|
+
* @category models
|
|
29
|
+
* @since 4.0.0
|
|
12
30
|
*/
|
|
13
31
|
export interface Clipboard {
|
|
14
32
|
readonly [TypeId]: typeof TypeId;
|
|
@@ -23,8 +41,10 @@ declare const ClipboardError_base: new <A extends Record<string, any> = {}>(args
|
|
|
23
41
|
readonly _tag: "ClipboardError";
|
|
24
42
|
} & Readonly<A>;
|
|
25
43
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
44
|
+
* Tagged error raised when a browser clipboard operation fails.
|
|
45
|
+
*
|
|
46
|
+
* @category errors
|
|
47
|
+
* @since 4.0.0
|
|
28
48
|
*/
|
|
29
49
|
export declare class ClipboardError extends ClipboardError_base<{
|
|
30
50
|
readonly message: string;
|
|
@@ -33,20 +53,24 @@ export declare class ClipboardError extends ClipboardError_base<{
|
|
|
33
53
|
readonly [ErrorTypeId] = "~@effect/platform-browser/Clipboard/ClipboardError";
|
|
34
54
|
}
|
|
35
55
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
56
|
+
* Service tag for the browser `Clipboard` service.
|
|
57
|
+
*
|
|
58
|
+
* @category services
|
|
59
|
+
* @since 4.0.0
|
|
38
60
|
*/
|
|
39
61
|
export declare const Clipboard: Context.Service<Clipboard, Clipboard>;
|
|
40
62
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
63
|
+
* Builds a `Clipboard` service from primitive read and write operations, deriving `clear` and `writeBlob` helpers.
|
|
64
|
+
*
|
|
65
|
+
* @category constructors
|
|
66
|
+
* @since 4.0.0
|
|
43
67
|
*/
|
|
44
68
|
export declare const make: (impl: Omit<Clipboard, "clear" | "writeBlob" | typeof TypeId>) => Clipboard;
|
|
45
69
|
/**
|
|
46
70
|
* A layer that directly interfaces with the navigator.clipboard api
|
|
47
71
|
*
|
|
48
|
-
* @
|
|
49
|
-
* @
|
|
72
|
+
* @category layers
|
|
73
|
+
* @since 4.0.0
|
|
50
74
|
*/
|
|
51
75
|
export declare const layer: Layer.Layer<Clipboard>;
|
|
52
76
|
export {};
|
package/dist/Clipboard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clipboard.d.ts","sourceRoot":"","sources":["../src/Clipboard.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Clipboard.d.ts","sourceRoot":"","sources":["../src/Clipboard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,QAAA,MAAM,MAAM,wCAAwC,CAAA;AACpD,QAAA,MAAM,WAAW,uDAAuD,CAAA;AAExE;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,MAAM,CAAA;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,cAAc,CAAC,CAAA;IAC5D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAC1D,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAA;IAC9E,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAA;IAC3E,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAA;IACvE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAA;CACpD;;;;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,oBAAmC;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CACxB,CAAC;IACA,QAAQ,CAAC,CAAC,WAAW,CAAC,wDAAc;CACrC;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAsC,CAAA;AAElG;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GACf,MAAM,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,WAAW,GAAG,OAAO,MAAM,CAAC,KAC3D,SAMC,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAsCxC,CAAA"}
|
package/dist/Clipboard.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Browser clipboard service for Effect programs.
|
|
3
|
+
*
|
|
4
|
+
* This module wraps the browser `navigator.clipboard` API in a `Clipboard`
|
|
5
|
+
* service so client-side applications can read, write, and clear clipboard
|
|
6
|
+
* contents as typed Effects. It is useful for common UI workflows such as copy
|
|
7
|
+
* buttons, paste/import actions, sharing generated text, and moving rich
|
|
8
|
+
* clipboard payloads like `Blob`-backed `ClipboardItem`s through an Effect
|
|
9
|
+
* environment.
|
|
10
|
+
*
|
|
11
|
+
* Browser clipboard rules still apply. Clipboard access generally requires a
|
|
12
|
+
* secure context, and browsers may require a user gesture, permission prompt, or
|
|
13
|
+
* active focused document before reads or writes are allowed. Support also
|
|
14
|
+
* varies by operation and payload type: text helpers are the most portable,
|
|
15
|
+
* while `ClipboardItem` and non-text MIME types may be unavailable or restricted
|
|
16
|
+
* in some browsers. Failed browser operations are surfaced as `ClipboardError`.
|
|
17
|
+
*
|
|
18
|
+
* @since 4.0.0
|
|
3
19
|
*/
|
|
4
20
|
import * as Context from "effect/Context";
|
|
5
21
|
import * as Data from "effect/Data";
|
|
@@ -8,20 +24,26 @@ import * as Layer from "effect/Layer";
|
|
|
8
24
|
const TypeId = "~@effect/platform-browser/Clipboard";
|
|
9
25
|
const ErrorTypeId = "~@effect/platform-browser/Clipboard/ClipboardError";
|
|
10
26
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
27
|
+
* Tagged error raised when a browser clipboard operation fails.
|
|
28
|
+
*
|
|
29
|
+
* @category errors
|
|
30
|
+
* @since 4.0.0
|
|
13
31
|
*/
|
|
14
32
|
export class ClipboardError extends /*#__PURE__*/Data.TaggedError("ClipboardError") {
|
|
15
33
|
[ErrorTypeId] = ErrorTypeId;
|
|
16
34
|
}
|
|
17
35
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
36
|
+
* Service tag for the browser `Clipboard` service.
|
|
37
|
+
*
|
|
38
|
+
* @category services
|
|
39
|
+
* @since 4.0.0
|
|
20
40
|
*/
|
|
21
41
|
export const Clipboard = /*#__PURE__*/Context.Service(TypeId);
|
|
22
42
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
43
|
+
* Builds a `Clipboard` service from primitive read and write operations, deriving `clear` and `writeBlob` helpers.
|
|
44
|
+
*
|
|
45
|
+
* @category constructors
|
|
46
|
+
* @since 4.0.0
|
|
25
47
|
*/
|
|
26
48
|
export const make = impl => Clipboard.of({
|
|
27
49
|
...impl,
|
|
@@ -34,8 +56,8 @@ export const make = impl => Clipboard.of({
|
|
|
34
56
|
/**
|
|
35
57
|
* A layer that directly interfaces with the navigator.clipboard api
|
|
36
58
|
*
|
|
37
|
-
* @
|
|
38
|
-
* @
|
|
59
|
+
* @category layers
|
|
60
|
+
* @since 4.0.0
|
|
39
61
|
*/
|
|
40
62
|
export const layer = /*#__PURE__*/Layer.succeed(Clipboard, /*#__PURE__*/make({
|
|
41
63
|
read: /*#__PURE__*/Effect.tryPromise({
|
package/dist/Clipboard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clipboard.js","names":["Context","Data","Effect","Layer","TypeId","ErrorTypeId","ClipboardError","TaggedError","Clipboard","Service","make","impl","of","clear","writeString","writeBlob","blob","write","ClipboardItem","type","layer","succeed","read","tryPromise","try","navigator","clipboard","catch","cause","s","readString","readText","text","writeText"],"sources":["../src/Clipboard.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Clipboard.js","names":["Context","Data","Effect","Layer","TypeId","ErrorTypeId","ClipboardError","TaggedError","Clipboard","Service","make","impl","of","clear","writeString","writeBlob","blob","write","ClipboardItem","type","layer","succeed","read","tryPromise","try","navigator","clipboard","catch","cause","s","readString","readText","text","writeText"],"sources":["../src/Clipboard.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;AAmBA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AAErC,MAAMC,MAAM,GAAG,qCAAqC;AACpD,MAAMC,WAAW,GAAG,oDAAoD;AAkBxE;;;;;;AAMA,OAAM,MAAOC,cAAe,sBAAQL,IAAI,CAACM,WAAW,CAAC,gBAAgB,CAGnE;EACS,CAACF,WAAW,IAAIA,WAAW;;AAGtC;;;;;;AAMA,OAAO,MAAMG,SAAS,gBAA0CR,OAAO,CAACS,OAAO,CAAYL,MAAM,CAAC;AAElG;;;;;;AAMA,OAAO,MAAMM,IAAI,GACfC,IAA4D,IAE5DH,SAAS,CAACI,EAAE,CAAC;EACX,GAAGD,IAAI;EACP,CAACP,MAAM,GAAGA,MAAM;EAChBS,KAAK,EAAEF,IAAI,CAACG,WAAW,CAAC,EAAE,CAAC;EAC3BC,SAAS,EAAGC,IAAU,IAAKL,IAAI,CAACM,KAAK,CAAC,CAAC,IAAIC,aAAa,CAAC;IAAE,CAACF,IAAI,CAACG,IAAI,GAAGH;EAAI,CAAE,CAAC,CAAC;CACjF,CAAC;AAEJ;;;;;;AAMA,OAAO,MAAMI,KAAK,gBAA2BjB,KAAK,CAACkB,OAAO,CACxDb,SAAS,eACTE,IAAI,CAAC;EACHY,IAAI,eAAEpB,MAAM,CAACqB,UAAU,CAAC;IACtBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACJ,IAAI,EAAE;IACrCK,KAAK,EAAGC,KAAK,IACX,IAAItB,cAAc,CAAC;MACjBsB,KAAK;MACL,SAAS,EAAE;KACZ;GACJ,CAAC;EACFX,KAAK,EAAGY,CAAuB,IAC7B3B,MAAM,CAACqB,UAAU,CAAC;IAChBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACT,KAAK,CAACY,CAAC,CAAC;IACvCF,KAAK,EAAGC,KAAK,IACX,IAAItB,cAAc,CAAC;MACjBsB,KAAK;MACL,SAAS,EAAE;KACZ;GACJ,CAAC;EACJE,UAAU,eAAE5B,MAAM,CAACqB,UAAU,CAAC;IAC5BC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACK,QAAQ,EAAE;IACzCJ,KAAK,EAAGC,KAAK,IACX,IAAItB,cAAc,CAAC;MACjBsB,KAAK;MACL,SAAS,EAAE;KACZ;GACJ,CAAC;EACFd,WAAW,EAAGkB,IAAY,IACxB9B,MAAM,CAACqB,UAAU,CAAC;IAChBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACO,SAAS,CAACD,IAAI,CAAC;IAC9CL,KAAK,EAAGC,KAAK,IACX,IAAItB,cAAc,CAAC;MACjBsB,KAAK;MACL,SAAS,EAAE;KACZ;GACJ;CACJ,CAAC,CACH","ignoreList":[]}
|
package/dist/Geolocation.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Browser geolocation support for Effect programs.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a `Geolocation` service and browser-backed layer for
|
|
5
|
+
* reading device location through `navigator.geolocation`. Use
|
|
6
|
+
* `getCurrentPosition` when an application needs one location fix, such as a
|
|
7
|
+
* nearby-search, check-in, or delivery estimate, and `watchPosition` when it
|
|
8
|
+
* needs a stream of updates for navigation, tracking, or location-aware UI.
|
|
9
|
+
*
|
|
10
|
+
* The implementation is browser-only and relies on the browser permission and
|
|
11
|
+
* policy model for geolocation. Calls may prompt the user, fail when permission
|
|
12
|
+
* is denied, time out, or report that position data is unavailable because of
|
|
13
|
+
* device, browser, privacy, origin, or secure-context restrictions. Watched
|
|
14
|
+
* positions are scoped so the underlying browser watch is cleared when the
|
|
15
|
+
* stream is finalized, and slow consumers should account for the sliding
|
|
16
|
+
* buffer used by `watchPosition`.
|
|
17
|
+
*
|
|
18
|
+
* @since 4.0.0
|
|
3
19
|
*/
|
|
4
20
|
import * as Cause from "effect/Cause";
|
|
5
21
|
import * as Context from "effect/Context";
|
|
@@ -9,8 +25,10 @@ import * as Stream from "effect/Stream";
|
|
|
9
25
|
declare const TypeId = "~@effect/platform-browser/Geolocation";
|
|
10
26
|
declare const ErrorTypeId = "~@effect/platform-browser/Geolocation/GeolocationError";
|
|
11
27
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
28
|
+
* Service interface for browser geolocation, providing effects for the current position and streams of watched positions.
|
|
29
|
+
*
|
|
30
|
+
* @category models
|
|
31
|
+
* @since 4.0.0
|
|
14
32
|
*/
|
|
15
33
|
export interface Geolocation {
|
|
16
34
|
readonly [TypeId]: typeof TypeId;
|
|
@@ -20,16 +38,20 @@ export interface Geolocation {
|
|
|
20
38
|
} | undefined) => Stream.Stream<GeolocationPosition, GeolocationError>;
|
|
21
39
|
}
|
|
22
40
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
41
|
+
* Service tag for the browser `Geolocation` service.
|
|
42
|
+
*
|
|
43
|
+
* @category services
|
|
44
|
+
* @since 4.0.0
|
|
25
45
|
*/
|
|
26
46
|
export declare const Geolocation: Context.Service<Geolocation, Geolocation>;
|
|
27
47
|
declare const GeolocationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
28
48
|
readonly _tag: "GeolocationError";
|
|
29
49
|
} & Readonly<A>;
|
|
30
50
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
51
|
+
* Tagged error wrapping a browser geolocation failure reason.
|
|
52
|
+
*
|
|
53
|
+
* @category errors
|
|
54
|
+
* @since 4.0.0
|
|
33
55
|
*/
|
|
34
56
|
export declare class GeolocationError extends GeolocationError_base<{
|
|
35
57
|
readonly reason: GeolocationErrorReason;
|
|
@@ -44,8 +66,10 @@ declare const PositionUnavailable_base: new <A extends Record<string, any> = {}>
|
|
|
44
66
|
readonly _tag: "PositionUnavailable";
|
|
45
67
|
} & Readonly<A>;
|
|
46
68
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
69
|
+
* Error reason for the browser geolocation `POSITION_UNAVAILABLE` failure.
|
|
70
|
+
*
|
|
71
|
+
* @category errors
|
|
72
|
+
* @since 4.0.0
|
|
49
73
|
*/
|
|
50
74
|
export declare class PositionUnavailable extends PositionUnavailable_base<{
|
|
51
75
|
readonly cause: unknown;
|
|
@@ -56,8 +80,10 @@ declare const PermissionDenied_base: new <A extends Record<string, any> = {}>(ar
|
|
|
56
80
|
readonly _tag: "PermissionDenied";
|
|
57
81
|
} & Readonly<A>;
|
|
58
82
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
83
|
+
* Error reason for the browser geolocation `PERMISSION_DENIED` failure.
|
|
84
|
+
*
|
|
85
|
+
* @category errors
|
|
86
|
+
* @since 4.0.0
|
|
61
87
|
*/
|
|
62
88
|
export declare class PermissionDenied extends PermissionDenied_base<{
|
|
63
89
|
readonly cause: unknown;
|
|
@@ -68,8 +94,10 @@ declare const Timeout_base: new <A extends Record<string, any> = {}>(args: impor
|
|
|
68
94
|
readonly _tag: "Timeout";
|
|
69
95
|
} & Readonly<A>;
|
|
70
96
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
97
|
+
* Error reason for the browser geolocation `TIMEOUT` failure.
|
|
98
|
+
*
|
|
99
|
+
* @category errors
|
|
100
|
+
* @since 4.0.0
|
|
73
101
|
*/
|
|
74
102
|
export declare class Timeout extends Timeout_base<{
|
|
75
103
|
readonly cause: unknown;
|
|
@@ -77,18 +105,24 @@ export declare class Timeout extends Timeout_base<{
|
|
|
77
105
|
get message(): string;
|
|
78
106
|
}
|
|
79
107
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
108
|
+
* Union of browser geolocation error reasons represented by the service.
|
|
109
|
+
*
|
|
110
|
+
* @category errors
|
|
111
|
+
* @since 4.0.0
|
|
82
112
|
*/
|
|
83
113
|
export type GeolocationErrorReason = PositionUnavailable | PermissionDenied | Timeout;
|
|
84
114
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
115
|
+
* Layer that provides `Geolocation` using `navigator.geolocation`, with watched positions buffered in a sliding queue.
|
|
116
|
+
*
|
|
117
|
+
* @category layers
|
|
118
|
+
* @since 4.0.0
|
|
87
119
|
*/
|
|
88
120
|
export declare const layer: Layer.Layer<Geolocation>;
|
|
89
121
|
/**
|
|
90
|
-
*
|
|
122
|
+
* Streams positions from the `Geolocation` service using `watchPosition`, with an optional sliding buffer size.
|
|
123
|
+
*
|
|
91
124
|
* @category Accessors
|
|
125
|
+
* @since 4.0.0
|
|
92
126
|
*/
|
|
93
127
|
export declare const watchPosition: (options?: (PositionOptions & {
|
|
94
128
|
readonly bufferSize?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Geolocation.d.ts","sourceRoot":"","sources":["../src/Geolocation.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Geolocation.d.ts","sourceRoot":"","sources":["../src/Geolocation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;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,CAAA;CACxB,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;;;;AAED;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,sBAAqC;IACzE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CACxB,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;;;;AAED;;;;;GAKG;AACH,qBAAa,OAAQ,SAAQ,aAA4B;IACvD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CACxB,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;AAED;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,GAAG,gBAAgB,GAAG,OAAO,CAAA;AAyCrF;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAe1C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,UACE,CAAE,eAAe,GAAG;IAClB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACzC,IACC,SAAS,KACZ,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,gBAAgB,EAAE,WAAW,CAI/D,CAAA"}
|
package/dist/Geolocation.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Browser geolocation support for Effect programs.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a `Geolocation` service and browser-backed layer for
|
|
5
|
+
* reading device location through `navigator.geolocation`. Use
|
|
6
|
+
* `getCurrentPosition` when an application needs one location fix, such as a
|
|
7
|
+
* nearby-search, check-in, or delivery estimate, and `watchPosition` when it
|
|
8
|
+
* needs a stream of updates for navigation, tracking, or location-aware UI.
|
|
9
|
+
*
|
|
10
|
+
* The implementation is browser-only and relies on the browser permission and
|
|
11
|
+
* policy model for geolocation. Calls may prompt the user, fail when permission
|
|
12
|
+
* is denied, time out, or report that position data is unavailable because of
|
|
13
|
+
* device, browser, privacy, origin, or secure-context restrictions. Watched
|
|
14
|
+
* positions are scoped so the underlying browser watch is cleared when the
|
|
15
|
+
* stream is finalized, and slow consumers should account for the sliding
|
|
16
|
+
* buffer used by `watchPosition`.
|
|
17
|
+
*
|
|
18
|
+
* @since 4.0.0
|
|
3
19
|
*/
|
|
4
20
|
import * as Cause from "effect/Cause";
|
|
5
21
|
import * as Context from "effect/Context";
|
|
@@ -11,13 +27,17 @@ import * as Stream from "effect/Stream";
|
|
|
11
27
|
const TypeId = "~@effect/platform-browser/Geolocation";
|
|
12
28
|
const ErrorTypeId = "~@effect/platform-browser/Geolocation/GeolocationError";
|
|
13
29
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
30
|
+
* Service tag for the browser `Geolocation` service.
|
|
31
|
+
*
|
|
32
|
+
* @category services
|
|
33
|
+
* @since 4.0.0
|
|
16
34
|
*/
|
|
17
35
|
export const Geolocation = /*#__PURE__*/Context.Service(TypeId);
|
|
18
36
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
37
|
+
* Tagged error wrapping a browser geolocation failure reason.
|
|
38
|
+
*
|
|
39
|
+
* @category errors
|
|
40
|
+
* @since 4.0.0
|
|
21
41
|
*/
|
|
22
42
|
export class GeolocationError extends /*#__PURE__*/Data.TaggedError("GeolocationError") {
|
|
23
43
|
constructor(props) {
|
|
@@ -32,8 +52,10 @@ export class GeolocationError extends /*#__PURE__*/Data.TaggedError("Geolocation
|
|
|
32
52
|
}
|
|
33
53
|
}
|
|
34
54
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
55
|
+
* Error reason for the browser geolocation `POSITION_UNAVAILABLE` failure.
|
|
56
|
+
*
|
|
57
|
+
* @category errors
|
|
58
|
+
* @since 4.0.0
|
|
37
59
|
*/
|
|
38
60
|
export class PositionUnavailable extends /*#__PURE__*/Data.TaggedError("PositionUnavailable") {
|
|
39
61
|
get message() {
|
|
@@ -41,8 +63,10 @@ export class PositionUnavailable extends /*#__PURE__*/Data.TaggedError("Position
|
|
|
41
63
|
}
|
|
42
64
|
}
|
|
43
65
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
66
|
+
* Error reason for the browser geolocation `PERMISSION_DENIED` failure.
|
|
67
|
+
*
|
|
68
|
+
* @category errors
|
|
69
|
+
* @since 4.0.0
|
|
46
70
|
*/
|
|
47
71
|
export class PermissionDenied extends /*#__PURE__*/Data.TaggedError("PermissionDenied") {
|
|
48
72
|
get message() {
|
|
@@ -50,8 +74,10 @@ export class PermissionDenied extends /*#__PURE__*/Data.TaggedError("PermissionD
|
|
|
50
74
|
}
|
|
51
75
|
}
|
|
52
76
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
77
|
+
* Error reason for the browser geolocation `TIMEOUT` failure.
|
|
78
|
+
*
|
|
79
|
+
* @category errors
|
|
80
|
+
* @since 4.0.0
|
|
55
81
|
*/
|
|
56
82
|
export class Timeout extends /*#__PURE__*/Data.TaggedError("Timeout") {
|
|
57
83
|
get message() {
|
|
@@ -83,8 +109,10 @@ const makeQueue = options => Queue.sliding(options?.bufferSize ?? 16).pipe(Effec
|
|
|
83
109
|
}
|
|
84
110
|
}, options)), handleId => Effect.sync(() => navigator.geolocation.clearWatch(handleId)))));
|
|
85
111
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
112
|
+
* Layer that provides `Geolocation` using `navigator.geolocation`, with watched positions buffered in a sliding queue.
|
|
113
|
+
*
|
|
114
|
+
* @category layers
|
|
115
|
+
* @since 4.0.0
|
|
88
116
|
*/
|
|
89
117
|
export const layer = /*#__PURE__*/Layer.succeed(Geolocation, /*#__PURE__*/Geolocation.of({
|
|
90
118
|
[TypeId]: TypeId,
|
|
@@ -92,8 +120,10 @@ export const layer = /*#__PURE__*/Layer.succeed(Geolocation, /*#__PURE__*/Geoloc
|
|
|
92
120
|
watchPosition: options => makeQueue(options).pipe(Effect.map(Stream.fromQueue), Stream.unwrap)
|
|
93
121
|
}));
|
|
94
122
|
/**
|
|
95
|
-
*
|
|
123
|
+
* Streams positions from the `Geolocation` service using `watchPosition`, with an optional sliding buffer size.
|
|
124
|
+
*
|
|
96
125
|
* @category Accessors
|
|
126
|
+
* @since 4.0.0
|
|
97
127
|
*/
|
|
98
128
|
export const watchPosition = options => Stream.unwrap(Effect.map(Effect.service(Geolocation), geolocation => geolocation.watchPosition(options)));
|
|
99
129
|
//# sourceMappingURL=Geolocation.js.map
|
package/dist/Geolocation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Geolocation.js","names":["Cause","Context","Data","Effect","Layer","Queue","Stream","TypeId","ErrorTypeId","Geolocation","Service","GeolocationError","TaggedError","constructor","props","cause","reason","message","PositionUnavailable","_tag","PermissionDenied","Timeout","makeQueue","options","sliding","bufferSize","pipe","tap","queue","acquireRelease","sync","navigator","geolocation","watchPosition","position","offerUnsafe","code","PERMISSION_DENIED","error","failCauseUnsafe","fail","TIMEOUT","POSITION_UNAVAILABLE","handleId","clearWatch","layer","succeed","of","getCurrentPosition","flatMap","take","scoped","map","fromQueue","unwrap","service"],"sources":["../src/Geolocation.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Geolocation.js","names":["Cause","Context","Data","Effect","Layer","Queue","Stream","TypeId","ErrorTypeId","Geolocation","Service","GeolocationError","TaggedError","constructor","props","cause","reason","message","PositionUnavailable","_tag","PermissionDenied","Timeout","makeQueue","options","sliding","bufferSize","pipe","tap","queue","acquireRelease","sync","navigator","geolocation","watchPosition","position","offerUnsafe","code","PERMISSION_DENIED","error","failCauseUnsafe","fail","TIMEOUT","POSITION_UNAVAILABLE","handleId","clearWatch","layer","succeed","of","getCurrentPosition","flatMap","take","scoped","map","fromQueue","unwrap","service"],"sources":["../src/Geolocation.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;AAmBA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,O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,QAAQ,CAAC,CAAC,CAC5E,CACF,CACF;AAEH;;;;;;AAMA,OAAO,MAAME,KAAK,gBAA6BzC,KAAK,CAAC0C,OAAO,CAC1DrC,WAAW,eACXA,WAAW,CAACsC,EAAE,CAAC;EACb,CAACxC,MAAM,GAAGA,MAAM;EAChByC,kBAAkB,EAAGzB,OAAO,IAC1BD,SAAS,CAACC,OAAO,CAAC,CAACG,IAAI,CACrBvB,MAAM,CAAC8C,OAAO,CAAC5C,KAAK,CAAC6C,IAAI,CAAC,EAC1B/C,MAAM,CAACgD,MAAM,CACd;EACHlB,aAAa,EAAGV,OAAO,IACrBD,SAAS,CAACC,OAAO,CAAC,CAACG,IAAI,CACrBvB,MAAM,CAACiD,GAAG,CAAC9C,MAAM,CAAC+C,SAAS,CAAC,EAC5B/C,MAAM,CAACgD,MAAM;CAElB,CAAC,CACH;AAED;;;;;;AAMA,OAAO,MAAMrB,aAAa,GACxBV,OAIa,IAEbjB,MAAM,CAACgD,MAAM,CAACnD,MAAM,CAACiD,GAAG,CACtBjD,MAAM,CAACoD,OAAO,CAAC9C,WAAW,CAAC,EAC1BuB,WAAW,IAAKA,WAAW,CAACC,aAAa,CAACV,OAAO,CAAC,CACpD,CAAC","ignoreList":[]}
|
package/dist/IndexedDb.d.ts
CHANGED
|
@@ -1,14 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Browser IndexedDB primitives and key schemas for Effect applications.
|
|
3
|
+
*
|
|
4
|
+
* This module is the low-level bridge used by the platform-browser IndexedDB
|
|
5
|
+
* integration. It provides an `IndexedDb` service around the browser
|
|
6
|
+
* `indexedDB` factory and `IDBKeyRange` constructor, a `layerWindow` layer for
|
|
7
|
+
* wiring those primitives from `window`, and schemas for the key shapes accepted
|
|
8
|
+
* by IndexedDB object stores and indexes.
|
|
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
|
+
*
|
|
2
24
|
* @since 4.0.0
|
|
3
25
|
*/
|
|
4
|
-
import * as Config from "effect/Config";
|
|
5
26
|
import * as Context from "effect/Context";
|
|
6
27
|
import * as Layer from "effect/Layer";
|
|
7
28
|
import * as Schema from "effect/Schema";
|
|
8
29
|
declare const TypeId = "~@effect/platform-browser/IndexedDb";
|
|
9
30
|
/**
|
|
10
|
-
*
|
|
31
|
+
* Service interface that provides the browser `indexedDB` factory and `IDBKeyRange` constructor.
|
|
32
|
+
*
|
|
11
33
|
* @category models
|
|
34
|
+
* @since 4.0.0
|
|
12
35
|
*/
|
|
13
36
|
export interface IndexedDb {
|
|
14
37
|
readonly [TypeId]: typeof TypeId;
|
|
@@ -16,35 +39,39 @@ export interface IndexedDb {
|
|
|
16
39
|
readonly IDBKeyRange: typeof globalThis.IDBKeyRange;
|
|
17
40
|
}
|
|
18
41
|
/**
|
|
19
|
-
*
|
|
42
|
+
* Service tag for browser IndexedDB primitives.
|
|
43
|
+
*
|
|
20
44
|
* @category tag
|
|
45
|
+
* @since 4.0.0
|
|
21
46
|
*/
|
|
22
47
|
export declare const IndexedDb: Context.Service<IndexedDb, IndexedDb>;
|
|
23
48
|
/**
|
|
24
|
-
* Schema for
|
|
49
|
+
* Schema for IndexedDB keys: strings, non-NaN numbers, valid dates, buffer sources, or arrays of those flat key values.
|
|
25
50
|
*
|
|
26
|
-
* @since 4.0.0
|
|
27
51
|
* @category schemas
|
|
52
|
+
* @since 4.0.0
|
|
28
53
|
*/
|
|
29
54
|
export declare const IDBValidKey: Schema.Union<readonly [Schema.Union<readonly [Schema.String, Schema.Number, Schema.DateValid, Schema.declare<BufferSource, unknown>]>, Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number, Schema.DateValid, Schema.declare<BufferSource, unknown>]>>]>;
|
|
30
55
|
/**
|
|
31
|
-
* Schema for
|
|
56
|
+
* Schema for auto-incremented IndexedDB keys, accepting integers from 1 through `2 ** 53`.
|
|
32
57
|
*
|
|
33
|
-
* @since 4.0.0
|
|
34
58
|
* @category schemas
|
|
59
|
+
* @since 4.0.0
|
|
35
60
|
*/
|
|
36
61
|
export declare const AutoIncrement: Schema.Int;
|
|
37
62
|
/**
|
|
63
|
+
* Creates an `IndexedDb` service from an `IDBFactory` and `IDBKeyRange` constructor.
|
|
64
|
+
*
|
|
65
|
+
* @category constructors
|
|
38
66
|
* @since 4.0.0
|
|
39
|
-
* @category constructor
|
|
40
67
|
*/
|
|
41
68
|
export declare const make: (impl: Omit<IndexedDb, typeof TypeId>) => IndexedDb;
|
|
42
69
|
/**
|
|
43
|
-
*
|
|
70
|
+
* Layer that provides `IndexedDb` from `window.indexedDB` and `window.IDBKeyRange`, failing with a config error when they are unavailable.
|
|
44
71
|
*
|
|
45
|
-
* @since 4.0.0
|
|
46
72
|
* @category constructors
|
|
73
|
+
* @since 4.0.0
|
|
47
74
|
*/
|
|
48
|
-
export declare const layerWindow: Layer.Layer<IndexedDb
|
|
75
|
+
export declare const layerWindow: Layer.Layer<IndexedDb>;
|
|
49
76
|
export {};
|
|
50
77
|
//# sourceMappingURL=IndexedDb.d.ts.map
|
package/dist/IndexedDb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedDb.d.ts","sourceRoot":"","sources":["../src/IndexedDb.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"IndexedDb.d.ts","sourceRoot":"","sources":["../src/IndexedDb.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,QAAA,MAAM,MAAM,wCAAwC,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,MAAM,CAAA;IAChC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,UAAU,CAAA;IACzC,QAAQ,CAAC,WAAW,EAAE,OAAO,UAAU,CAAC,WAAW,CAAA;CACpD;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAiD,CAAA;AAc7G;;;;;GAKG;AACH,eAAO,MAAM,WAAW,wQAAuD,CAAA;AAE/E;;;;;GAKG;AACH,eAAO,MAAM,aAAa,YAMxB,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,MAAM,IAAI,CAAC,SAAS,EAAE,OAAO,MAAM,CAAC,KAAG,SAAwD,CAAA;AAEpH;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAc9C,CAAA"}
|
package/dist/IndexedDb.js
CHANGED
|
@@ -1,32 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Browser IndexedDB primitives and key schemas for Effect applications.
|
|
3
|
+
*
|
|
4
|
+
* This module is the low-level bridge used by the platform-browser IndexedDB
|
|
5
|
+
* integration. It provides an `IndexedDb` service around the browser
|
|
6
|
+
* `indexedDB` factory and `IDBKeyRange` constructor, a `layerWindow` layer for
|
|
7
|
+
* wiring those primitives from `window`, and schemas for the key shapes accepted
|
|
8
|
+
* by IndexedDB object stores and indexes.
|
|
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
|
+
*
|
|
2
24
|
* @since 4.0.0
|
|
3
25
|
*/
|
|
4
|
-
import * as Config from "effect/Config";
|
|
5
26
|
import * as Context from "effect/Context";
|
|
6
27
|
import * as Effect from "effect/Effect";
|
|
7
28
|
import * as Layer from "effect/Layer";
|
|
8
29
|
import * as Schema from "effect/Schema";
|
|
9
|
-
import * as SchemaIssue from "effect/SchemaIssue";
|
|
10
30
|
const TypeId = "~@effect/platform-browser/IndexedDb";
|
|
11
31
|
/**
|
|
12
|
-
*
|
|
32
|
+
* Service tag for browser IndexedDB primitives.
|
|
33
|
+
*
|
|
13
34
|
* @category tag
|
|
35
|
+
* @since 4.0.0
|
|
14
36
|
*/
|
|
15
37
|
export const IndexedDb = /*#__PURE__*/Context.Service(TypeId);
|
|
16
38
|
/** @internal */
|
|
17
39
|
const IDBFlatKey = /*#__PURE__*/Schema.Union([Schema.String, /*#__PURE__*/Schema.Number.check(/*#__PURE__*/Schema.makeFilter(input => !Number.isNaN(input))), Schema.DateValid, /*#__PURE__*/Schema.declare(input => input instanceof ArrayBuffer || ArrayBuffer.isView(input) && input.buffer instanceof ArrayBuffer)]);
|
|
18
40
|
/**
|
|
19
|
-
* Schema for
|
|
41
|
+
* Schema for IndexedDB keys: strings, non-NaN numbers, valid dates, buffer sources, or arrays of those flat key values.
|
|
20
42
|
*
|
|
21
|
-
* @since 4.0.0
|
|
22
43
|
* @category schemas
|
|
44
|
+
* @since 4.0.0
|
|
23
45
|
*/
|
|
24
46
|
export const IDBValidKey = /*#__PURE__*/Schema.Union([IDBFlatKey, /*#__PURE__*/Schema.Array(IDBFlatKey)]);
|
|
25
47
|
/**
|
|
26
|
-
* Schema for
|
|
48
|
+
* Schema for auto-incremented IndexedDB keys, accepting integers from 1 through `2 ** 53`.
|
|
27
49
|
*
|
|
28
|
-
* @since 4.0.0
|
|
29
50
|
* @category schemas
|
|
51
|
+
* @since 4.0.0
|
|
30
52
|
*/
|
|
31
53
|
export const AutoIncrement = /*#__PURE__*/Schema.Int.check(Schema.isBetween({
|
|
32
54
|
minimum: 1,
|
|
@@ -37,18 +59,20 @@ export const AutoIncrement = /*#__PURE__*/Schema.Int.check(Schema.isBetween({
|
|
|
37
59
|
description: "Defines a valid autoIncrement key path for the IndexedDb table"
|
|
38
60
|
});
|
|
39
61
|
/**
|
|
62
|
+
* Creates an `IndexedDb` service from an `IDBFactory` and `IDBKeyRange` constructor.
|
|
63
|
+
*
|
|
64
|
+
* @category constructors
|
|
40
65
|
* @since 4.0.0
|
|
41
|
-
* @category constructor
|
|
42
66
|
*/
|
|
43
67
|
export const make = impl => IndexedDb.of({
|
|
44
68
|
[TypeId]: TypeId,
|
|
45
69
|
...impl
|
|
46
70
|
});
|
|
47
71
|
/**
|
|
48
|
-
*
|
|
72
|
+
* Layer that provides `IndexedDb` from `window.indexedDB` and `window.IDBKeyRange`, failing with a config error when they are unavailable.
|
|
49
73
|
*
|
|
50
|
-
* @since 4.0.0
|
|
51
74
|
* @category constructors
|
|
75
|
+
* @since 4.0.0
|
|
52
76
|
*/
|
|
53
77
|
export const layerWindow = /*#__PURE__*/Layer.effect(IndexedDb, /*#__PURE__*/Effect.suspend(() => {
|
|
54
78
|
if (window.indexedDB && window.IDBKeyRange) {
|
|
@@ -57,9 +81,7 @@ export const layerWindow = /*#__PURE__*/Layer.effect(IndexedDb, /*#__PURE__*/Eff
|
|
|
57
81
|
IDBKeyRange: window.IDBKeyRange
|
|
58
82
|
}));
|
|
59
83
|
} else {
|
|
60
|
-
return Effect.
|
|
61
|
-
messageMissingKey: "window.indexedDB is not available"
|
|
62
|
-
}))));
|
|
84
|
+
return Effect.die(new Error("window.indexedDB is not available"));
|
|
63
85
|
}
|
|
64
86
|
}));
|
|
65
87
|
//# sourceMappingURL=IndexedDb.js.map
|
package/dist/IndexedDb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedDb.js","names":["
|
|
1
|
+
{"version":3,"file":"IndexedDb.js","names":["Context","Effect","Layer","Schema","TypeId","IndexedDb","Service","IDBFlatKey","Union","String","Number","check","makeFilter","input","isNaN","DateValid","declare","ArrayBuffer","isView","buffer","IDBValidKey","Array","AutoIncrement","Int","isBetween","minimum","maximum","annotate","identifier","title","description","make","impl","of","layerWindow","effect","suspend","window","indexedDB","IDBKeyRange","succeed","die","Error"],"sources":["../src/IndexedDb.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,MAAMC,MAAM,GAAG,qCAAqC;AAcpD;;;;;;AAMA,OAAO,MAAMC,SAAS,gBAA0CL,OAAO,CAACM,OAAO,CAAuBF,MAAM,CAAC;AAE7G;AACA,MAAMG,UAAU,gBAAGJ,MAAM,CAACK,KAAK,CAAC,CAC9BL,MAAM,CAACM,MAAM,eACbN,MAAM,CAACO,MAAM,CAACC,KAAK,cAACR,MAAM,CAACS,UAAU,CAAEC,KAAK,IAAK,CAACH,MAAM,CAACI,KAAK,CAACD,KAA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