@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.
- package/dist/BrowserHttpClient.d.ts +18 -8
- package/dist/BrowserHttpClient.d.ts.map +1 -1
- package/dist/BrowserHttpClient.js +45 -8
- package/dist/BrowserHttpClient.js.map +1 -1
- package/dist/BrowserKeyValueStore.d.ts +13 -6
- package/dist/BrowserKeyValueStore.d.ts.map +1 -1
- package/dist/BrowserKeyValueStore.js +126 -2
- 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 +29 -4
- package/dist/BrowserSocket.d.ts.map +1 -1
- package/dist/BrowserSocket.js +29 -4
- 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 +6 -2
- package/dist/BrowserWorker.d.ts.map +1 -1
- package/dist/BrowserWorker.js +27 -3
- package/dist/BrowserWorker.js.map +1 -1
- package/dist/BrowserWorkerRunner.d.ts +9 -3
- package/dist/BrowserWorkerRunner.d.ts.map +1 -1
- package/dist/BrowserWorkerRunner.js +28 -4
- package/dist/BrowserWorkerRunner.js.map +1 -1
- package/dist/Clipboard.d.ts +30 -6
- package/dist/Clipboard.d.ts.map +1 -1
- package/dist/Clipboard.js +27 -5
- package/dist/Clipboard.js.map +1 -1
- package/dist/Geolocation.d.ts +44 -10
- package/dist/Geolocation.d.ts.map +1 -1
- package/dist/Geolocation.js +38 -8
- 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 +103 -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 +35 -8
- package/dist/Permissions.d.ts.map +1 -1
- package/dist/Permissions.js +31 -6
- package/dist/Permissions.js.map +1 -1
- package/dist/index.d.ts +12 -12
- package/dist/index.js +12 -12
- package/package.json +3 -3
- package/src/BrowserHttpClient.ts +48 -9
- package/src/BrowserKeyValueStore.ts +142 -4
- package/src/BrowserPersistence.ts +19 -3
- package/src/BrowserRuntime.ts +31 -4
- package/src/BrowserSocket.ts +29 -4
- package/src/BrowserStream.ts +25 -3
- package/src/BrowserWorker.ts +27 -3
- package/src/BrowserWorkerRunner.ts +28 -4
- package/src/Clipboard.ts +30 -6
- package/src/Geolocation.ts +44 -10
- package/src/IndexedDb.ts +39 -21
- package/src/IndexedDbDatabase.ts +57 -10
- package/src/IndexedDbQueryBuilder.ts +172 -58
- package/src/IndexedDbTable.ts +57 -13
- package/src/IndexedDbVersion.ts +37 -7
- package/src/Permissions.ts +35 -8
- package/src/index.ts +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedDbVersion.js","names":["pipeArguments","TypeId","Proto","pipe","arguments","makeProto","options","Version","Object","assign","tables","make","Map","map","table","tableName"],"sources":["../src/IndexedDbVersion.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"file":"IndexedDbVersion.js","names":["pipeArguments","TypeId","Proto","pipe","arguments","makeProto","options","Version","Object","assign","tables","make","Map","map","table","tableName"],"sources":["../src/IndexedDbVersion.ts"],"sourcesContent":[null],"mappings":"AAqBA,SAASA,aAAa,QAAQ,iBAAiB;AAG/C,MAAMC,MAAM,GAAG,4CAA4C;AAgE3D,MAAMC,KAAK,GAAG;EACZ,CAACD,MAAM,GAAGA,MAAM;EAChBE,IAAIA,CAAA;IACF,OAAOH,aAAa,CAAC,IAAI,EAAEI,SAAS,CAAC;EACvC;CACD;AAED,MAAMC,SAAS,GAAgDC,OAE9D,IAA8B;EAC7B;EACA,MAAMC,OAAO;EACbC,MAAM,CAACC,MAAM,CAACF,OAAO,EAAEL,KAAK,CAAC;EAC3BK,OAAe,CAACG,MAAM,GAAGJ,OAAO,CAACI,MAAM;EACzC,OAAOH,OAAc;AACvB,CAAC;AAED;;;;;;AAMA,OAAO,MAAMI,IAAI,GAAGA,CAGlB,GAAGD,MAAc,KAEjBL,SAAS,CAAC;EACRK,MAAM,EAAE,IAAIE,GAAG,CAACF,MAAM,CAACG,GAAG,CAAEC,KAAK,IAAK,CAACA,KAAK,CAACC,SAAS,EAAED,KAAK,CAAC,CAAC;CAChE,CAAC","ignoreList":[]}
|
package/dist/Permissions.d.ts
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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 Effect from "effect/Effect";
|
|
@@ -10,8 +27,8 @@ declare const ErrorTypeId = "~@effect/platform-browser/Permissions/PermissionsEr
|
|
|
10
27
|
* Wrapper on the Permission API (`navigator.permissions`) with methods for
|
|
11
28
|
* querying status of permissions.
|
|
12
29
|
*
|
|
13
|
-
* @since 1.0.0
|
|
14
30
|
* @category Models
|
|
31
|
+
* @since 4.0.0
|
|
15
32
|
*/
|
|
16
33
|
export interface Permissions {
|
|
17
34
|
readonly [TypeId]: typeof TypeId;
|
|
@@ -26,8 +43,10 @@ declare const PermissionsInvalidStateError_base: new <A extends Record<string, a
|
|
|
26
43
|
readonly _tag: "InvalidStateError";
|
|
27
44
|
} & Readonly<A>;
|
|
28
45
|
/**
|
|
29
|
-
*
|
|
46
|
+
* Error reason for an `InvalidStateError` raised by the browser Permissions API.
|
|
47
|
+
*
|
|
30
48
|
* @category errors
|
|
49
|
+
* @since 4.0.0
|
|
31
50
|
*/
|
|
32
51
|
export declare class PermissionsInvalidStateError extends PermissionsInvalidStateError_base<{
|
|
33
52
|
readonly cause: unknown;
|
|
@@ -38,8 +57,10 @@ declare const PermissionsTypeError_base: new <A extends Record<string, any> = {}
|
|
|
38
57
|
readonly _tag: "TypeError";
|
|
39
58
|
} & Readonly<A>;
|
|
40
59
|
/**
|
|
41
|
-
*
|
|
60
|
+
* Error reason for a `TypeError` raised by the browser Permissions API.
|
|
61
|
+
*
|
|
42
62
|
* @category errors
|
|
63
|
+
* @since 4.0.0
|
|
43
64
|
*/
|
|
44
65
|
export declare class PermissionsTypeError extends PermissionsTypeError_base<{
|
|
45
66
|
readonly cause: unknown;
|
|
@@ -47,16 +68,20 @@ export declare class PermissionsTypeError extends PermissionsTypeError_base<{
|
|
|
47
68
|
get message(): string;
|
|
48
69
|
}
|
|
49
70
|
/**
|
|
50
|
-
*
|
|
71
|
+
* Union of browser Permissions API error reasons represented by the service.
|
|
72
|
+
*
|
|
51
73
|
* @category errors
|
|
74
|
+
* @since 4.0.0
|
|
52
75
|
*/
|
|
53
76
|
export type PermissionsErrorReason = PermissionsInvalidStateError | PermissionsTypeError;
|
|
54
77
|
declare const PermissionsError_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]; }>) => import("effect/Cause").YieldableError & {
|
|
55
78
|
readonly _tag: "PermissionsError";
|
|
56
79
|
} & Readonly<A>;
|
|
57
80
|
/**
|
|
58
|
-
*
|
|
81
|
+
* Tagged error wrapping a browser Permissions API failure reason.
|
|
82
|
+
*
|
|
59
83
|
* @category errors
|
|
84
|
+
* @since 4.0.0
|
|
60
85
|
*/
|
|
61
86
|
export declare class PermissionsError extends PermissionsError_base<{
|
|
62
87
|
readonly reason: PermissionsErrorReason;
|
|
@@ -68,15 +93,17 @@ export declare class PermissionsError extends PermissionsError_base<{
|
|
|
68
93
|
get message(): string;
|
|
69
94
|
}
|
|
70
95
|
/**
|
|
71
|
-
*
|
|
96
|
+
* Service tag for the browser `Permissions` service.
|
|
97
|
+
*
|
|
72
98
|
* @category Service
|
|
99
|
+
* @since 4.0.0
|
|
73
100
|
*/
|
|
74
101
|
export declare const Permissions: Context.Service<Permissions, Permissions>;
|
|
75
102
|
/**
|
|
76
103
|
* A layer that directly interfaces with the `navigator.permissions` api
|
|
77
104
|
*
|
|
78
|
-
* @since 1.0.0
|
|
79
105
|
* @category Layers
|
|
106
|
+
* @since 4.0.0
|
|
80
107
|
*/
|
|
81
108
|
export declare const layer: Layer.Layer<Permissions>;
|
|
82
109
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Permissions.d.ts","sourceRoot":"","sources":["../src/Permissions.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Permissions.d.ts","sourceRoot":"","sources":["../src/Permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;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,0CAA0C,CAAA;AACtD,QAAA,MAAM,WAAW,2DAA2D,CAAA;AAE5E;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,MAAM,CAAA;IAEhC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,SAAS,cAAc,EAC1C,IAAI,EAAE,IAAI,KACP,MAAM,CAAC,MAAM,CAGhB,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,GAAG;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,EAC/C,gBAAgB,CACjB,CAAA;CACF;;;;AAED;;;;;GAKG;AACH,qBAAa,4BAA6B,SAAQ,kCAAsC;IACtF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CACxB,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;;;;AAED;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,0BAA8B;IACtE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CACxB,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;AAED;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,4BAA4B,GAAG,oBAAoB,CAAA;;;;AAExF;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,sBAAqC;IACzE,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAA;CACxC,CAAC;gBACY,KAAK,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAA;KAAE;IAO9D,QAAQ,CAAC,CAAC,WAAW,CAAC,4DAAc;IAEpC,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,WAAW,CAAwC,CAAA;AAE1G;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAe1C,CAAA"}
|
package/dist/Permissions.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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";
|
|
@@ -8,8 +25,10 @@ import * as Layer from "effect/Layer";
|
|
|
8
25
|
const TypeId = "~@effect/platform-browser/Permissions";
|
|
9
26
|
const ErrorTypeId = "~@effect/platform-browser/Permissions/PermissionsError";
|
|
10
27
|
/**
|
|
11
|
-
*
|
|
28
|
+
* Error reason for an `InvalidStateError` raised by the browser Permissions API.
|
|
29
|
+
*
|
|
12
30
|
* @category errors
|
|
31
|
+
* @since 4.0.0
|
|
13
32
|
*/
|
|
14
33
|
export class PermissionsInvalidStateError extends /*#__PURE__*/Data.TaggedError("InvalidStateError") {
|
|
15
34
|
get message() {
|
|
@@ -17,8 +36,10 @@ export class PermissionsInvalidStateError extends /*#__PURE__*/Data.TaggedError(
|
|
|
17
36
|
}
|
|
18
37
|
}
|
|
19
38
|
/**
|
|
20
|
-
*
|
|
39
|
+
* Error reason for a `TypeError` raised by the browser Permissions API.
|
|
40
|
+
*
|
|
21
41
|
* @category errors
|
|
42
|
+
* @since 4.0.0
|
|
22
43
|
*/
|
|
23
44
|
export class PermissionsTypeError extends /*#__PURE__*/Data.TaggedError("TypeError") {
|
|
24
45
|
get message() {
|
|
@@ -26,8 +47,10 @@ export class PermissionsTypeError extends /*#__PURE__*/Data.TaggedError("TypeErr
|
|
|
26
47
|
}
|
|
27
48
|
}
|
|
28
49
|
/**
|
|
29
|
-
*
|
|
50
|
+
* Tagged error wrapping a browser Permissions API failure reason.
|
|
51
|
+
*
|
|
30
52
|
* @category errors
|
|
53
|
+
* @since 4.0.0
|
|
31
54
|
*/
|
|
32
55
|
export class PermissionsError extends /*#__PURE__*/Data.TaggedError("PermissionsError") {
|
|
33
56
|
constructor(props) {
|
|
@@ -42,15 +65,17 @@ export class PermissionsError extends /*#__PURE__*/Data.TaggedError("Permissions
|
|
|
42
65
|
}
|
|
43
66
|
}
|
|
44
67
|
/**
|
|
45
|
-
*
|
|
68
|
+
* Service tag for the browser `Permissions` service.
|
|
69
|
+
*
|
|
46
70
|
* @category Service
|
|
71
|
+
* @since 4.0.0
|
|
47
72
|
*/
|
|
48
73
|
export const Permissions = /*#__PURE__*/Context.Service(TypeId);
|
|
49
74
|
/**
|
|
50
75
|
* A layer that directly interfaces with the `navigator.permissions` api
|
|
51
76
|
*
|
|
52
|
-
* @since 1.0.0
|
|
53
77
|
* @category Layers
|
|
78
|
+
* @since 4.0.0
|
|
54
79
|
*/
|
|
55
80
|
export const layer = /*#__PURE__*/Layer.succeed(Permissions, /*#__PURE__*/Permissions.of({
|
|
56
81
|
[TypeId]: TypeId,
|
package/dist/Permissions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Permissions.js","names":["Context","Data","Effect","Layer","TypeId","ErrorTypeId","PermissionsInvalidStateError","TaggedError","message","_tag","PermissionsTypeError","PermissionsError","constructor","props","cause","reason","Permissions","Service","layer","succeed","of","query","name","tryPromise","try","navigator","permissions","catch","DOMException"],"sources":["../src/Permissions.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Permissions.js","names":["Context","Data","Effect","Layer","TypeId","ErrorTypeId","PermissionsInvalidStateError","TaggedError","message","_tag","PermissionsTypeError","PermissionsError","constructor","props","cause","reason","Permissions","Service","layer","succeed","of","query","name","tryPromise","try","navigator","permissions","catch","DOMException"],"sources":["../src/Permissions.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;AAoBA,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,uCAAuC;AACtD,MAAMC,WAAW,GAAG,wDAAwD;AAyB5E;;;;;;AAMA,OAAM,MAAOC,4BAA6B,sBAAQL,IAAI,CAACM,WAAW,CAAC,mBAAmB,CAEpF;EACA,IAAaC,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACC,IAAI;EAClB;;AAGF;;;;;;AAMA,OAAM,MAAOC,oBAAqB,sBAAQT,IAAI,CAACM,WAAW,CAAC,WAAW,CAEpE;EACA,IAAaC,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACC,IAAI;EAClB;;AAWF;;;;;;AAMA,OAAM,MAAOE,gBAAiB,sBAAQV,IAAI,CAACM,WAAW,CAAC,kBAAkB,CAEvE;EACAK,YAAYC,KAAkD;IAC5D,KAAK,CAAC;MACJ,GAAGA,KAAK;MACRC,KAAK,EAAED,KAAK,CAACE,MAAM,CAACD;KACd,CAAC;EACX;EAES,CAACT,WAAW,IAAIA,WAAW;EAEpC,IAAaG,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACO,MAAM,CAACP,OAAO;EAC5B;;AAGF;;;;;;AAMA,OAAO,MAAMQ,WAAW,gBAA8ChB,OAAO,CAACiB,OAAO,CAAcb,MAAM,CAAC;AAE1G;;;;;;AAMA,OAAO,MAAMc,KAAK,gBAA6Bf,KAAK,CAACgB,OAAO,CAC1DH,WAAW,eACXA,WAAW,CAACI,EAAE,CAAC;EACb,CAAChB,MAAM,GAAGA,MAAM;EAChBiB,KAAK,EAAGC,IAAI,IACVpB,MAAM,CAACqB,UAAU,CAAC;IAChBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,WAAW,CAACL,KAAK,CAAC;MAAEC;IAAI,CAAE,CAAiB;IAChEK,KAAK,EAAGb,KAAK,IACX,IAAIH,gBAAgB,CAAC;MACnBI,MAAM,EAAED,KAAK,YAAYc,YAAY,GACjC,IAAItB,4BAA4B,CAAC;QAAEQ;MAAK,CAAE,CAAC,GAC3C,IAAIJ,oBAAoB,CAAC;QAAEI;MAAK,CAAE;KACvC;GACJ;CACJ,CAAC,CACH","ignoreList":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @since
|
|
2
|
+
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* @since
|
|
5
|
+
* @since 4.0.0
|
|
6
6
|
*/
|
|
7
7
|
export * as BrowserHttpClient from "./BrowserHttpClient.ts";
|
|
8
8
|
/**
|
|
9
|
-
* @since
|
|
9
|
+
* @since 4.0.0
|
|
10
10
|
*/
|
|
11
11
|
export * as BrowserKeyValueStore from "./BrowserKeyValueStore.ts";
|
|
12
12
|
/**
|
|
13
|
-
* @since
|
|
13
|
+
* @since 4.0.0
|
|
14
14
|
*/
|
|
15
15
|
export * as BrowserPersistence from "./BrowserPersistence.ts";
|
|
16
16
|
/**
|
|
17
|
-
* @since
|
|
17
|
+
* @since 4.0.0
|
|
18
18
|
*/
|
|
19
19
|
export * as BrowserRuntime from "./BrowserRuntime.ts";
|
|
20
20
|
/**
|
|
21
|
-
* @since
|
|
21
|
+
* @since 4.0.0
|
|
22
22
|
*/
|
|
23
23
|
export * as BrowserSocket from "./BrowserSocket.ts";
|
|
24
24
|
/**
|
|
25
|
-
* @since
|
|
25
|
+
* @since 4.0.0
|
|
26
26
|
*/
|
|
27
27
|
export * as BrowserStream from "./BrowserStream.ts";
|
|
28
28
|
/**
|
|
29
|
-
* @since
|
|
29
|
+
* @since 4.0.0
|
|
30
30
|
*/
|
|
31
31
|
export * as BrowserWorker from "./BrowserWorker.ts";
|
|
32
32
|
/**
|
|
33
|
-
* @since
|
|
33
|
+
* @since 4.0.0
|
|
34
34
|
*/
|
|
35
35
|
export * as BrowserWorkerRunner from "./BrowserWorkerRunner.ts";
|
|
36
36
|
/**
|
|
37
|
-
* @since
|
|
37
|
+
* @since 4.0.0
|
|
38
38
|
*/
|
|
39
39
|
export * as Clipboard from "./Clipboard.ts";
|
|
40
40
|
/**
|
|
41
|
-
* @since
|
|
41
|
+
* @since 4.0.0
|
|
42
42
|
*/
|
|
43
43
|
export * as Geolocation from "./Geolocation.ts";
|
|
44
44
|
/**
|
|
@@ -62,7 +62,7 @@ export * as IndexedDbTable from "./IndexedDbTable.ts";
|
|
|
62
62
|
*/
|
|
63
63
|
export * as IndexedDbVersion from "./IndexedDbVersion.ts";
|
|
64
64
|
/**
|
|
65
|
-
* @since
|
|
65
|
+
* @since 4.0.0
|
|
66
66
|
*/
|
|
67
67
|
export * as Permissions from "./Permissions.ts";
|
|
68
68
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @since
|
|
2
|
+
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
4
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
5
5
|
/**
|
|
6
|
-
* @since
|
|
6
|
+
* @since 4.0.0
|
|
7
7
|
*/
|
|
8
8
|
export * as BrowserHttpClient from "./BrowserHttpClient.js";
|
|
9
9
|
/**
|
|
10
|
-
* @since
|
|
10
|
+
* @since 4.0.0
|
|
11
11
|
*/
|
|
12
12
|
export * as BrowserKeyValueStore from "./BrowserKeyValueStore.js";
|
|
13
13
|
/**
|
|
14
|
-
* @since
|
|
14
|
+
* @since 4.0.0
|
|
15
15
|
*/
|
|
16
16
|
export * as BrowserPersistence from "./BrowserPersistence.js";
|
|
17
17
|
/**
|
|
18
|
-
* @since
|
|
18
|
+
* @since 4.0.0
|
|
19
19
|
*/
|
|
20
20
|
export * as BrowserRuntime from "./BrowserRuntime.js";
|
|
21
21
|
/**
|
|
22
|
-
* @since
|
|
22
|
+
* @since 4.0.0
|
|
23
23
|
*/
|
|
24
24
|
export * as BrowserSocket from "./BrowserSocket.js";
|
|
25
25
|
/**
|
|
26
|
-
* @since
|
|
26
|
+
* @since 4.0.0
|
|
27
27
|
*/
|
|
28
28
|
export * as BrowserStream from "./BrowserStream.js";
|
|
29
29
|
/**
|
|
30
|
-
* @since
|
|
30
|
+
* @since 4.0.0
|
|
31
31
|
*/
|
|
32
32
|
export * as BrowserWorker from "./BrowserWorker.js";
|
|
33
33
|
/**
|
|
34
|
-
* @since
|
|
34
|
+
* @since 4.0.0
|
|
35
35
|
*/
|
|
36
36
|
export * as BrowserWorkerRunner from "./BrowserWorkerRunner.js";
|
|
37
37
|
/**
|
|
38
|
-
* @since
|
|
38
|
+
* @since 4.0.0
|
|
39
39
|
*/
|
|
40
40
|
export * as Clipboard from "./Clipboard.js";
|
|
41
41
|
/**
|
|
42
|
-
* @since
|
|
42
|
+
* @since 4.0.0
|
|
43
43
|
*/
|
|
44
44
|
export * as Geolocation from "./Geolocation.js";
|
|
45
45
|
/**
|
|
@@ -63,7 +63,7 @@ export * as IndexedDbTable from "./IndexedDbTable.js";
|
|
|
63
63
|
*/
|
|
64
64
|
export * as IndexedDbVersion from "./IndexedDbVersion.js";
|
|
65
65
|
/**
|
|
66
|
-
* @since
|
|
66
|
+
* @since 4.0.0
|
|
67
67
|
*/
|
|
68
68
|
export * as Permissions from "./Permissions.js";
|
|
69
69
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/platform-browser",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.67",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Platform specific implementations for the browser",
|
|
7
7
|
"homepage": "https://effect.website",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"provenance": true
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"effect": "^4.0.0-beta.
|
|
48
|
+
"effect": "^4.0.0-beta.67"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"mock-xmlhttprequest": "^8.4.1",
|
|
52
52
|
"fake-indexeddb": "^6.2.5",
|
|
53
|
-
"effect": "^4.0.0-beta.
|
|
53
|
+
"effect": "^4.0.0-beta.67"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"multipasta": "^0.2.7"
|
package/src/BrowserHttpClient.ts
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Browser implementations of the Effect `HttpClient`.
|
|
3
|
+
*
|
|
4
|
+
* This module exposes HTTP client layers for code that runs in a browser. It
|
|
5
|
+
* re-exports the fetch-based client for the common case, where requests should
|
|
6
|
+
* use the platform `fetch` implementation and optional `RequestInit` defaults,
|
|
7
|
+
* and it provides an `XMLHttpRequest`-backed layer for integrations that need
|
|
8
|
+
* XHR semantics such as response type control or environments where XHR is the
|
|
9
|
+
* required transport.
|
|
10
|
+
*
|
|
11
|
+
* Use these layers for single-page applications, browser tests, generated
|
|
12
|
+
* `HttpApiClient`s, and other client-side Effect programs that need HTTP
|
|
13
|
+
* requests to participate in interruption, typed transport / decode errors, and
|
|
14
|
+
* Effect's response body readers.
|
|
15
|
+
*
|
|
16
|
+
* Browser networking rules still apply. Cross-origin requests are subject to
|
|
17
|
+
* CORS preflights and server allowlists, especially when using custom headers,
|
|
18
|
+
* non-simple methods, or non-simple content types. Only CORS-exposed response
|
|
19
|
+
* headers are readable, and cookies / authentication are controlled by the
|
|
20
|
+
* browser and the configured fetch `RequestInit.credentials` policy. The XHR
|
|
21
|
+
* layer uses the browser's `XMLHttpRequest` defaults for credentials.
|
|
22
|
+
*
|
|
23
|
+
* Body handling differs between the transports. Fetch delegates body framing to
|
|
24
|
+
* the Web Fetch implementation. The XHR client sends empty, raw, `Uint8Array`,
|
|
25
|
+
* and `FormData` bodies directly, buffers `Stream` request bodies before
|
|
26
|
+
* sending, defaults responses to text, and can be switched to `ArrayBuffer`
|
|
27
|
+
* responses with `withXHRArrayBuffer`. When sending `FormData`, avoid setting
|
|
28
|
+
* an incompatible `Content-Type` header so the browser can generate the
|
|
29
|
+
* multipart boundary.
|
|
30
|
+
*
|
|
31
|
+
* @since 4.0.0
|
|
3
32
|
*/
|
|
4
33
|
import * as Cause from "effect/Cause"
|
|
5
34
|
import * as Context from "effect/Context"
|
|
@@ -28,18 +57,18 @@ import * as HeaderParser from "multipasta/HeadersParser"
|
|
|
28
57
|
|
|
29
58
|
export {
|
|
30
59
|
/**
|
|
31
|
-
* @since 1.0.0
|
|
32
60
|
* @category Fetch
|
|
61
|
+
* @since 4.0.0
|
|
33
62
|
*/
|
|
34
63
|
Fetch,
|
|
35
64
|
/**
|
|
36
|
-
* @since 1.0.0
|
|
37
65
|
* @category Fetch
|
|
66
|
+
* @since 4.0.0
|
|
38
67
|
*/
|
|
39
68
|
layer as layerFetch,
|
|
40
69
|
/**
|
|
41
|
-
* @since 1.0.0
|
|
42
70
|
* @category Fetch
|
|
71
|
+
* @since 4.0.0
|
|
43
72
|
*/
|
|
44
73
|
RequestInit
|
|
45
74
|
} from "effect/unstable/http/FetchHttpClient"
|
|
@@ -49,14 +78,18 @@ export {
|
|
|
49
78
|
// =============================================================================
|
|
50
79
|
|
|
51
80
|
/**
|
|
52
|
-
*
|
|
81
|
+
* Allowed response body modes for the browser XHR HTTP client.
|
|
82
|
+
*
|
|
53
83
|
* @category Models
|
|
84
|
+
* @since 4.0.0
|
|
54
85
|
*/
|
|
55
86
|
export type XHRResponseType = "arraybuffer" | "text"
|
|
56
87
|
|
|
57
88
|
/**
|
|
58
|
-
*
|
|
89
|
+
* Reference that controls the `XMLHttpRequest.responseType` used by the browser XHR HTTP client, defaulting to `"text"`.
|
|
90
|
+
*
|
|
59
91
|
* @category References
|
|
92
|
+
* @since 4.0.0
|
|
60
93
|
*/
|
|
61
94
|
export const CurrentXHRResponseType: Context.Reference<XHRResponseType> = Context.Reference(
|
|
62
95
|
"@effect/platform-browser/BrowserHttpClient/CurrentXHRResponseType",
|
|
@@ -64,8 +97,10 @@ export const CurrentXHRResponseType: Context.Reference<XHRResponseType> = Contex
|
|
|
64
97
|
)
|
|
65
98
|
|
|
66
99
|
/**
|
|
67
|
-
*
|
|
100
|
+
* Runs an effect with `CurrentXHRResponseType` set to `"arraybuffer"` so the XHR HTTP client receives response bodies as `ArrayBuffer` values.
|
|
101
|
+
*
|
|
68
102
|
* @category References
|
|
103
|
+
* @since 4.0.0
|
|
69
104
|
*/
|
|
70
105
|
export const withXHRArrayBuffer = <A, E, R>(
|
|
71
106
|
self: Effect.Effect<A, E, R>
|
|
@@ -77,8 +112,10 @@ export const withXHRArrayBuffer = <A, E, R>(
|
|
|
77
112
|
)
|
|
78
113
|
|
|
79
114
|
/**
|
|
80
|
-
*
|
|
115
|
+
* Service tag for the `XMLHttpRequest` constructor used by the browser XHR HTTP client.
|
|
116
|
+
*
|
|
81
117
|
* @category Services
|
|
118
|
+
* @since 4.0.0
|
|
82
119
|
*/
|
|
83
120
|
export class XMLHttpRequest extends Context.Service<
|
|
84
121
|
XMLHttpRequest,
|
|
@@ -384,8 +421,10 @@ class ClientResponseImpl extends IncomingMessageImpl<HttpClientError.HttpClientE
|
|
|
384
421
|
}
|
|
385
422
|
|
|
386
423
|
/**
|
|
387
|
-
*
|
|
424
|
+
* Layer that provides an `HttpClient` implementation backed by the browser `XMLHttpRequest` API.
|
|
425
|
+
*
|
|
388
426
|
* @category Layers
|
|
427
|
+
* @since 4.0.0
|
|
389
428
|
*/
|
|
390
429
|
export const layerXMLHttpRequest: Layer.Layer<HttpClient.HttpClient> = HttpClient.layerMergedContext(
|
|
391
430
|
Effect.succeed(makeXmlHttpRequest)
|
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Browser-backed `KeyValueStore` layers for Effect programs.
|
|
3
|
+
*
|
|
4
|
+
* This module provides `KeyValueStore` implementations backed by the browser's
|
|
5
|
+
* synchronous Web Storage APIs: `localStorage` for origin-scoped data that
|
|
6
|
+
* persists across page reloads and browser sessions, and `sessionStorage` for
|
|
7
|
+
* page-session data that is cleared when that tab or window's page session
|
|
8
|
+
* ends. They are useful for small client-side values such as user preferences,
|
|
9
|
+
* feature flags, lightweight caches, persisted drafts, or session-only workflow
|
|
10
|
+
* state.
|
|
11
|
+
*
|
|
12
|
+
* Web Storage is only available in browser environments and is scoped by origin.
|
|
13
|
+
* Browsers may deny access in private modes or restricted contexts, and writes
|
|
14
|
+
* can fail when storage quotas are exceeded. The API stores strings and runs
|
|
15
|
+
* synchronously on the main thread, so prefer it for small payloads and avoid
|
|
16
|
+
* treating it as a database or a secure place for sensitive data.
|
|
17
|
+
*
|
|
18
|
+
* @since 4.0.0
|
|
3
19
|
*/
|
|
4
|
-
import
|
|
20
|
+
import * as Effect from "effect/Effect"
|
|
21
|
+
import * as Layer from "effect/Layer"
|
|
5
22
|
import * as KeyValueStore from "effect/unstable/persistence/KeyValueStore"
|
|
23
|
+
import { IndexedDb } from "./IndexedDb.ts"
|
|
6
24
|
|
|
7
25
|
/**
|
|
8
26
|
* Creates a `KeyValueStore` layer that uses the browser's `localStorage` api.
|
|
9
27
|
*
|
|
10
28
|
* Values are stored between sessions.
|
|
11
29
|
*
|
|
12
|
-
* @since 1.0.0
|
|
13
30
|
* @category Layers
|
|
31
|
+
* @since 4.0.0
|
|
14
32
|
*/
|
|
15
33
|
export const layerLocalStorage: Layer.Layer<KeyValueStore.KeyValueStore> = KeyValueStore.layerStorage(() =>
|
|
16
34
|
globalThis.localStorage
|
|
@@ -21,9 +39,129 @@ export const layerLocalStorage: Layer.Layer<KeyValueStore.KeyValueStore> = KeyVa
|
|
|
21
39
|
*
|
|
22
40
|
* Values are stored only for the current session.
|
|
23
41
|
*
|
|
24
|
-
* @since 1.0.0
|
|
25
42
|
* @category Layers
|
|
43
|
+
* @since 4.0.0
|
|
26
44
|
*/
|
|
27
45
|
export const layerSessionStorage: Layer.Layer<KeyValueStore.KeyValueStore> = KeyValueStore.layerStorage(() =>
|
|
28
46
|
globalThis.sessionStorage
|
|
29
47
|
)
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Creates a `KeyValueStore` layer backed by IndexedDB.
|
|
51
|
+
*
|
|
52
|
+
* @since 4.0.0
|
|
53
|
+
* @category Layers
|
|
54
|
+
*/
|
|
55
|
+
export const layerIndexedDb = (options?: {
|
|
56
|
+
readonly database?: string | undefined
|
|
57
|
+
}): Layer.Layer<KeyValueStore.KeyValueStore, never, IndexedDb> =>
|
|
58
|
+
Layer.effect(KeyValueStore.KeyValueStore)(
|
|
59
|
+
Effect.gen(function*() {
|
|
60
|
+
const db = yield* Effect.acquireRelease(
|
|
61
|
+
openDatabase(options?.database ?? "effect_key_value_store"),
|
|
62
|
+
(db) => Effect.sync(() => db.close())
|
|
63
|
+
).pipe(Effect.orDie)
|
|
64
|
+
|
|
65
|
+
return KeyValueStore.make({
|
|
66
|
+
clear: Effect.suspend(() => {
|
|
67
|
+
const store = getKvsEntriesStore(db, "readwrite")
|
|
68
|
+
return idbRequest({ method: "clear", message: "Failed to clear backing store" }, () => store.clear())
|
|
69
|
+
}),
|
|
70
|
+
get: (key: string) =>
|
|
71
|
+
Effect.map(
|
|
72
|
+
Effect.suspend(() => {
|
|
73
|
+
const store = getKvsEntriesStore(db, "readonly")
|
|
74
|
+
return idbRequest<{ key: string; value: string } | undefined>({
|
|
75
|
+
method: "get",
|
|
76
|
+
message: "Failed to get value from backing store",
|
|
77
|
+
key
|
|
78
|
+
}, () => store.get(key))
|
|
79
|
+
}),
|
|
80
|
+
(found) => typeof found?.value === "string" ? found.value : undefined
|
|
81
|
+
),
|
|
82
|
+
getUint8Array: (key: string) =>
|
|
83
|
+
Effect.map(
|
|
84
|
+
Effect.suspend(() => {
|
|
85
|
+
const store = getKvsEntriesStore(db, "readonly")
|
|
86
|
+
return idbRequest<{ key: string; value: Uint8Array } | undefined>({
|
|
87
|
+
method: "getUint8Array",
|
|
88
|
+
message: "Failed to get value from backing store",
|
|
89
|
+
key
|
|
90
|
+
}, () => store.get(key))
|
|
91
|
+
}),
|
|
92
|
+
(found) => found?.value && found.value instanceof Uint8Array ? found.value : undefined
|
|
93
|
+
),
|
|
94
|
+
set: (key: string, value: string | Uint8Array) =>
|
|
95
|
+
Effect.asVoid(Effect.suspend(() => {
|
|
96
|
+
const store = getKvsEntriesStore(db, "readwrite")
|
|
97
|
+
return idbRequest(
|
|
98
|
+
{ method: "set", message: "Failed to set value in backing store", key },
|
|
99
|
+
() => store.put({ key, value })
|
|
100
|
+
)
|
|
101
|
+
})),
|
|
102
|
+
size: Effect.suspend(() => {
|
|
103
|
+
const store = getKvsEntriesStore(db, "readonly")
|
|
104
|
+
return idbRequest<number>(
|
|
105
|
+
{ method: "size", message: "Failed to get backing store size" },
|
|
106
|
+
() => store.count()
|
|
107
|
+
)
|
|
108
|
+
}),
|
|
109
|
+
remove: (key: string) =>
|
|
110
|
+
Effect.asVoid(Effect.suspend(() => {
|
|
111
|
+
const store = getKvsEntriesStore(db, "readwrite")
|
|
112
|
+
return idbRequest(
|
|
113
|
+
{ method: "remove", message: "Failed to remove value from backing store", key },
|
|
114
|
+
() => store.delete(key)
|
|
115
|
+
)
|
|
116
|
+
}))
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
const databaseVersion = 1
|
|
122
|
+
const entriesStoreName = "entries"
|
|
123
|
+
const openDatabase = Effect.fnUntraced(function*(database: string) {
|
|
124
|
+
const idb = (yield* IndexedDb).indexedDB
|
|
125
|
+
const openRequest = yield* Effect.try({
|
|
126
|
+
try: () => idb.open(database, databaseVersion),
|
|
127
|
+
catch: (cause) =>
|
|
128
|
+
new KeyValueStore.KeyValueStoreError({
|
|
129
|
+
method: "open",
|
|
130
|
+
message: "Failed to open backing store database",
|
|
131
|
+
cause
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
openRequest.onupgradeneeded = () => {
|
|
135
|
+
const db = openRequest.result
|
|
136
|
+
if (!db.objectStoreNames.contains(entriesStoreName)) {
|
|
137
|
+
db.createObjectStore(entriesStoreName, { keyPath: "key" })
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return yield* idbRequest({ method: "open", message: "Failed to open backing store database" }, () => openRequest)
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
const idbRequest = <A>(
|
|
144
|
+
failArgs: { method: string; message: string; key?: string },
|
|
145
|
+
evaluate: () => IDBRequest<A>
|
|
146
|
+
): Effect.Effect<A, KeyValueStore.KeyValueStoreError> =>
|
|
147
|
+
Effect.callback<A, KeyValueStore.KeyValueStoreError>((resume) => {
|
|
148
|
+
const request = evaluate()
|
|
149
|
+
if (request.readyState === "done") {
|
|
150
|
+
return resume(Effect.succeed(request.result))
|
|
151
|
+
}
|
|
152
|
+
request.onsuccess = () => {
|
|
153
|
+
resume(Effect.succeed(request.result))
|
|
154
|
+
}
|
|
155
|
+
request.onerror = () =>
|
|
156
|
+
resume(Effect.fail(
|
|
157
|
+
new KeyValueStore.KeyValueStoreError({
|
|
158
|
+
...failArgs,
|
|
159
|
+
cause: request.error
|
|
160
|
+
})
|
|
161
|
+
))
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
const getKvsEntriesStore = (db: IDBDatabase, mode: IDBTransactionMode) => {
|
|
165
|
+
const transaction = db.transaction(entriesStoreName, mode)
|
|
166
|
+
return transaction.objectStore(entriesStoreName)
|
|
167
|
+
}
|