@effect/platform-browser 0.48.21 → 0.48.23
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/Permissions/package.json +6 -0
- package/dist/cjs/Permissions.js +63 -0
- package/dist/cjs/Permissions.js.map +1 -0
- package/dist/cjs/index.js +3 -1
- package/dist/dts/Permissions.d.ts +67 -0
- package/dist/dts/Permissions.d.ts.map +1 -0
- package/dist/dts/index.d.ts +4 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/esm/Permissions.js +53 -0
- package/dist/esm/Permissions.js.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +11 -3
- package/src/Permissions.ts +100 -0
- package/src/index.ts +5 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.layer = exports.TypeId = exports.PermissionsError = exports.Permissions = exports.ErrorTypeId = void 0;
|
|
7
|
+
var _Error = require("@effect/platform/Error");
|
|
8
|
+
var Context = _interopRequireWildcard(require("effect/Context"));
|
|
9
|
+
var Effect = _interopRequireWildcard(require("effect/Effect"));
|
|
10
|
+
var Layer = _interopRequireWildcard(require("effect/Layer"));
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
/**
|
|
14
|
+
* @since 1.0.0
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
* @category type ids
|
|
20
|
+
*/
|
|
21
|
+
const TypeId = exports.TypeId = /*#__PURE__*/Symbol.for("@effect/platform-browser/Permissions");
|
|
22
|
+
/**
|
|
23
|
+
* @since 1.0.0
|
|
24
|
+
* @category type ids
|
|
25
|
+
*/
|
|
26
|
+
const ErrorTypeId = exports.ErrorTypeId = /*#__PURE__*/Symbol.for("@effect/platform-browser/Permissions/PermissionsError");
|
|
27
|
+
/**
|
|
28
|
+
* @since 1.0.0
|
|
29
|
+
* @category errors
|
|
30
|
+
*/
|
|
31
|
+
class PermissionsError extends /*#__PURE__*/(0, _Error.TypeIdError)(ErrorTypeId, "PermissionsError") {
|
|
32
|
+
get message() {
|
|
33
|
+
return this.reason;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @since 1.0.0
|
|
38
|
+
* @category tags
|
|
39
|
+
*/
|
|
40
|
+
exports.PermissionsError = PermissionsError;
|
|
41
|
+
const Permissions = exports.Permissions = /*#__PURE__*/Context.GenericTag("@effect/platform-browser/Permissions");
|
|
42
|
+
/**
|
|
43
|
+
* A layer that directly interfaces with the `navigator.permissions` api
|
|
44
|
+
*
|
|
45
|
+
* @since 1.0.0
|
|
46
|
+
* @category layers
|
|
47
|
+
*/
|
|
48
|
+
const layer = exports.layer = /*#__PURE__*/Layer.succeed(Permissions, /*#__PURE__*/Permissions.of({
|
|
49
|
+
[TypeId]: TypeId,
|
|
50
|
+
query: name => Effect.tryPromise({
|
|
51
|
+
try: () => navigator.permissions.query({
|
|
52
|
+
name
|
|
53
|
+
}),
|
|
54
|
+
catch: cause => new PermissionsError({
|
|
55
|
+
reason: cause instanceof DOMException ? "InvalidStateError" : "TypeError",
|
|
56
|
+
cause
|
|
57
|
+
})
|
|
58
|
+
}).pipe(Effect.map(status => ({
|
|
59
|
+
...status,
|
|
60
|
+
name
|
|
61
|
+
})))
|
|
62
|
+
}));
|
|
63
|
+
//# sourceMappingURL=Permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Permissions.js","names":["_Error","require","Context","_interopRequireWildcard","Effect","Layer","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","TypeId","exports","Symbol","for","ErrorTypeId","PermissionsError","TypeIdError","message","reason","Permissions","GenericTag","layer","succeed","of","query","name","tryPromise","try","navigator","permissions","catch","cause","DOMException","pipe","map","status"],"sources":["../../src/Permissions.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,uBAAA,CAAAF,OAAA;AACA,IAAAI,KAAA,GAAAF,uBAAA,CAAAF,OAAA;AAAqC,SAAAK,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,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EAAGC,IAAI,IACVrC,MAAM,CAACsC,UAAU,CAAC;IAChBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,WAAW,CAACL,KAAK,CAAC;MAAEC;IAAI,CAAE,CAAC;IAChDK,KAAK,EAAGC,KAAK,IACX,IAAIhB,gBAAgB,CAAC;MACnBG,MAAM,EAAEa,KAAK,YAAYC,YAAY,GAAG,mBAAmB,GAAG,WAAW;MACzED;KACD;GACJ,CAAC,CAACE,IAAI,CACL7C,MAAM,CAAC8C,GAAG,CAAEC,MAAM,KAAM;IAAE,GAAGA,MAAM;IAAEV;EAAI,CAAE,CAAC,CAAC;CAElD,CAAC,CACH","ignoreList":[]}
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.Geolocation = exports.Clipboard = exports.BrowserWorkerRunner = exports.BrowserWorker = exports.BrowserStream = exports.BrowserSocket = exports.BrowserRuntime = exports.BrowserKeyValueStore = exports.BrowserHttpClient = void 0;
|
|
6
|
+
exports.Permissions = exports.Geolocation = exports.Clipboard = exports.BrowserWorkerRunner = exports.BrowserWorker = exports.BrowserStream = exports.BrowserSocket = exports.BrowserRuntime = exports.BrowserKeyValueStore = exports.BrowserHttpClient = void 0;
|
|
7
7
|
var _BrowserHttpClient = _interopRequireWildcard(require("./BrowserHttpClient.js"));
|
|
8
8
|
exports.BrowserHttpClient = _BrowserHttpClient;
|
|
9
9
|
var _BrowserKeyValueStore = _interopRequireWildcard(require("./BrowserKeyValueStore.js"));
|
|
@@ -22,6 +22,8 @@ var _Clipboard = _interopRequireWildcard(require("./Clipboard.js"));
|
|
|
22
22
|
exports.Clipboard = _Clipboard;
|
|
23
23
|
var _Geolocation = _interopRequireWildcard(require("./Geolocation.js"));
|
|
24
24
|
exports.Geolocation = _Geolocation;
|
|
25
|
+
var _Permissions = _interopRequireWildcard(require("./Permissions.js"));
|
|
26
|
+
exports.Permissions = _Permissions;
|
|
25
27
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
26
28
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
27
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
/**
|
|
5
|
+
* @since 1.0.0
|
|
6
|
+
* @category type ids
|
|
7
|
+
*/
|
|
8
|
+
export declare const TypeId: unique symbol;
|
|
9
|
+
/**
|
|
10
|
+
* @since 1.0.0
|
|
11
|
+
* @category type ids
|
|
12
|
+
*/
|
|
13
|
+
export type TypeId = typeof TypeId;
|
|
14
|
+
/**
|
|
15
|
+
* Wrapper on the Permission API (`navigator.permissions`)
|
|
16
|
+
* with methods for querying status of permissions.
|
|
17
|
+
*
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
* @category interface
|
|
20
|
+
*/
|
|
21
|
+
export interface Permissions {
|
|
22
|
+
readonly [TypeId]: TypeId;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the state of a user permission on the global scope.
|
|
25
|
+
*/
|
|
26
|
+
readonly query: <Name extends PermissionName>(name: Name) => Effect.Effect<Omit<PermissionStatus, "name"> & {
|
|
27
|
+
name: Name;
|
|
28
|
+
}, PermissionsError>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @since 1.0.0
|
|
32
|
+
* @category type ids
|
|
33
|
+
*/
|
|
34
|
+
export declare const ErrorTypeId: unique symbol;
|
|
35
|
+
/**
|
|
36
|
+
* @since 1.0.0
|
|
37
|
+
* @category type ids
|
|
38
|
+
*/
|
|
39
|
+
export type ErrorTypeId = typeof ErrorTypeId;
|
|
40
|
+
declare const PermissionsError_base: new <A extends Record<string, any>>(args: import("effect/Types").Simplify<A>) => import("effect/Cause").YieldableError & Record<typeof ErrorTypeId, typeof ErrorTypeId> & {
|
|
41
|
+
readonly _tag: "PermissionsError";
|
|
42
|
+
} & Readonly<A>;
|
|
43
|
+
/**
|
|
44
|
+
* @since 1.0.0
|
|
45
|
+
* @category errors
|
|
46
|
+
*/
|
|
47
|
+
export declare class PermissionsError extends PermissionsError_base<{
|
|
48
|
+
/** https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query#exceptions */
|
|
49
|
+
readonly reason: "InvalidStateError" | "TypeError";
|
|
50
|
+
readonly cause: unknown;
|
|
51
|
+
}> {
|
|
52
|
+
get message(): "InvalidStateError" | "TypeError";
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @since 1.0.0
|
|
56
|
+
* @category tags
|
|
57
|
+
*/
|
|
58
|
+
export declare const Permissions: Context.Tag<Permissions, Permissions>;
|
|
59
|
+
/**
|
|
60
|
+
* A layer that directly interfaces with the `navigator.permissions` api
|
|
61
|
+
*
|
|
62
|
+
* @since 1.0.0
|
|
63
|
+
* @category layers
|
|
64
|
+
*/
|
|
65
|
+
export declare const layer: Layer.Layer<Permissions>;
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=Permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Permissions.d.ts","sourceRoot":"","sources":["../../src/Permissions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,MAA2D,CAAA;AAEvF;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAA;AAElC;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IAEzB;;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;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,OAAO,MAA4E,CAAA;AAE7G;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAA;;;;AAE5C;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,sBAA6C;IACjF,oFAAoF;IACpF,QAAQ,CAAC,MAAM,EAAE,mBAAmB,GAAG,WAAW,CAAA;IAClD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CACxB,CAAC;IACA,IAAI,OAAO,sCAEV;CACF;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,CAE7D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAgB1C,CAAA"}
|
package/dist/dts/index.d.ts
CHANGED
package/dist/dts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH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0
|
|
3
|
+
*/
|
|
4
|
+
import { TypeIdError } from "@effect/platform/Error";
|
|
5
|
+
import * as Context from "effect/Context";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Layer from "effect/Layer";
|
|
8
|
+
/**
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
* @category type ids
|
|
11
|
+
*/
|
|
12
|
+
export const TypeId = /*#__PURE__*/Symbol.for("@effect/platform-browser/Permissions");
|
|
13
|
+
/**
|
|
14
|
+
* @since 1.0.0
|
|
15
|
+
* @category type ids
|
|
16
|
+
*/
|
|
17
|
+
export const ErrorTypeId = /*#__PURE__*/Symbol.for("@effect/platform-browser/Permissions/PermissionsError");
|
|
18
|
+
/**
|
|
19
|
+
* @since 1.0.0
|
|
20
|
+
* @category errors
|
|
21
|
+
*/
|
|
22
|
+
export class PermissionsError extends /*#__PURE__*/TypeIdError(ErrorTypeId, "PermissionsError") {
|
|
23
|
+
get message() {
|
|
24
|
+
return this.reason;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @since 1.0.0
|
|
29
|
+
* @category tags
|
|
30
|
+
*/
|
|
31
|
+
export const Permissions = /*#__PURE__*/Context.GenericTag("@effect/platform-browser/Permissions");
|
|
32
|
+
/**
|
|
33
|
+
* A layer that directly interfaces with the `navigator.permissions` api
|
|
34
|
+
*
|
|
35
|
+
* @since 1.0.0
|
|
36
|
+
* @category layers
|
|
37
|
+
*/
|
|
38
|
+
export const layer = /*#__PURE__*/Layer.succeed(Permissions, /*#__PURE__*/Permissions.of({
|
|
39
|
+
[TypeId]: TypeId,
|
|
40
|
+
query: name => Effect.tryPromise({
|
|
41
|
+
try: () => navigator.permissions.query({
|
|
42
|
+
name
|
|
43
|
+
}),
|
|
44
|
+
catch: cause => new PermissionsError({
|
|
45
|
+
reason: cause instanceof DOMException ? "InvalidStateError" : "TypeError",
|
|
46
|
+
cause
|
|
47
|
+
})
|
|
48
|
+
}).pipe(Effect.map(status => ({
|
|
49
|
+
...status,
|
|
50
|
+
name
|
|
51
|
+
})))
|
|
52
|
+
}));
|
|
53
|
+
//# sourceMappingURL=Permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Permissions.js","names":["TypeIdError","Context","Effect","Layer","TypeId","Symbol","for","ErrorTypeId","PermissionsError","message","reason","Permissions","GenericTag","layer","succeed","of","query","name","tryPromise","try","navigator","permissions","catch","cause","DOMException","pipe","map","status"],"sources":["../../src/Permissions.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,SAASA,WAAW,QAAQ,wBAAwB;AACpD,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AAErC;;;;AAIA,OAAO,MAAMC,MAAM,gBAAkBC,MAAM,CAACC,GAAG,CAAC,sCAAsC,CAAC;AA+BvF;;;;AAIA,OAAO,MAAMC,WAAW,gBAAkBF,MAAM,CAACC,GAAG,CAAC,uDAAuD,CAAC;AAQ7G;;;;AAIA,OAAM,MAAOE,gBAAiB,sBAAQR,WAAW,CAACO,WAAW,EAAE,kBAAkB,CAI/E;EACA,IAAIE,OAAOA,CAAA;IACT,OAAO,IAAI,CAACC,MAAM;EACpB;;AAGF;;;;AAIA,OAAO,MAAMC,WAAW,gBAA0CV,OAAO,CAACW,UAAU,CAClF,sCAAsC,CACvC;AAED;;;;;;AAMA,OAAO,MAAMC,KAAK,gBAA6BV,KAAK,CAACW,OAAO,CAC1DH,WAAW,eACXA,WAAW,CAACI,EAAE,CAAC;EACb,CAACX,MAAM,GAAGA,MAAM;EAChBY,KAAK,EAAGC,IAAI,IACVf,MAAM,CAACgB,UAAU,CAAC;IAChBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,WAAW,CAACL,KAAK,CAAC;MAAEC;IAAI,CAAE,CAAC;IAChDK,KAAK,EAAGC,KAAK,IACX,IAAIf,gBAAgB,CAAC;MACnBE,MAAM,EAAEa,KAAK,YAAYC,YAAY,GAAG,mBAAmB,GAAG,WAAW;MACzED;KACD;GACJ,CAAC,CAACE,IAAI,CACLvB,MAAM,CAACwB,GAAG,CAAEC,MAAM,KAAM;IAAE,GAAGA,MAAM;IAAEV;EAAI,CAAE,CAAC,CAAC;CAElD,CAAC,CACH","ignoreList":[]}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["BrowserHttpClient","BrowserKeyValueStore","BrowserRuntime","BrowserSocket","BrowserStream","BrowserWorker","BrowserWorkerRunner","Clipboard","Geolocation"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,iBAAiB,MAAM,wBAAwB;AAE3D;;;AAGA,OAAO,KAAKC,oBAAoB,MAAM,2BAA2B;AAEjE;;;AAGA,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AAErD;;;AAGA,OAAO,KAAKC,aAAa,MAAM,oBAAoB;AAEnD;;;AAGA,OAAO,KAAKC,aAAa,MAAM,oBAAoB;AAEnD;;;AAGA,OAAO,KAAKC,aAAa,MAAM,oBAAoB;AAEnD;;;AAGA,OAAO,KAAKC,mBAAmB,MAAM,0BAA0B;AAE/D;;;AAGA,OAAO,KAAKC,SAAS,MAAM,gBAAgB;AAE3C;;;AAGA,OAAO,KAAKC,WAAW,MAAM,kBAAkB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["BrowserHttpClient","BrowserKeyValueStore","BrowserRuntime","BrowserSocket","BrowserStream","BrowserWorker","BrowserWorkerRunner","Clipboard","Geolocation","Permissions"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,iBAAiB,MAAM,wBAAwB;AAE3D;;;AAGA,OAAO,KAAKC,oBAAoB,MAAM,2BAA2B;AAEjE;;;AAGA,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AAErD;;;AAGA,OAAO,KAAKC,aAAa,MAAM,oBAAoB;AAEnD;;;AAGA,OAAO,KAAKC,aAAa,MAAM,oBAAoB;AAEnD;;;AAGA,OAAO,KAAKC,aAAa,MAAM,oBAAoB;AAEnD;;;AAGA,OAAO,KAAKC,mBAAmB,MAAM,0BAA0B;AAE/D;;;AAGA,OAAO,KAAKC,SAAS,MAAM,gBAAgB;AAE3C;;;AAGA,OAAO,KAAKC,WAAW,MAAM,kBAAkB;AAE/C;;;AAGA,OAAO,KAAKC,WAAW,MAAM,kBAAkB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/platform-browser",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.23",
|
|
4
4
|
"description": "Platform specific implementations for the browser",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"multipasta": "^0.2.5"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"@effect/platform": "^0.69.
|
|
17
|
-
"effect": "^3.10.
|
|
16
|
+
"@effect/platform": "^0.69.23",
|
|
17
|
+
"effect": "^3.10.15"
|
|
18
18
|
},
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"provenance": true
|
|
@@ -73,6 +73,11 @@
|
|
|
73
73
|
"types": "./dist/dts/Geolocation.d.ts",
|
|
74
74
|
"import": "./dist/esm/Geolocation.js",
|
|
75
75
|
"default": "./dist/cjs/Geolocation.js"
|
|
76
|
+
},
|
|
77
|
+
"./Permissions": {
|
|
78
|
+
"types": "./dist/dts/Permissions.d.ts",
|
|
79
|
+
"import": "./dist/esm/Permissions.js",
|
|
80
|
+
"default": "./dist/cjs/Permissions.js"
|
|
76
81
|
}
|
|
77
82
|
},
|
|
78
83
|
"typesVersions": {
|
|
@@ -103,6 +108,9 @@
|
|
|
103
108
|
],
|
|
104
109
|
"Geolocation": [
|
|
105
110
|
"./dist/dts/Geolocation.d.ts"
|
|
111
|
+
],
|
|
112
|
+
"Permissions": [
|
|
113
|
+
"./dist/dts/Permissions.d.ts"
|
|
106
114
|
]
|
|
107
115
|
}
|
|
108
116
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
*/
|
|
4
|
+
import { TypeIdError } from "@effect/platform/Error"
|
|
5
|
+
import * as Context from "effect/Context"
|
|
6
|
+
import * as Effect from "effect/Effect"
|
|
7
|
+
import * as Layer from "effect/Layer"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @since 1.0.0
|
|
11
|
+
* @category type ids
|
|
12
|
+
*/
|
|
13
|
+
export const TypeId: unique symbol = Symbol.for("@effect/platform-browser/Permissions")
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @since 1.0.0
|
|
17
|
+
* @category type ids
|
|
18
|
+
*/
|
|
19
|
+
export type TypeId = typeof TypeId
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Wrapper on the Permission API (`navigator.permissions`)
|
|
23
|
+
* with methods for querying status of permissions.
|
|
24
|
+
*
|
|
25
|
+
* @since 1.0.0
|
|
26
|
+
* @category interface
|
|
27
|
+
*/
|
|
28
|
+
export interface Permissions {
|
|
29
|
+
readonly [TypeId]: TypeId
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns the state of a user permission on the global scope.
|
|
33
|
+
*/
|
|
34
|
+
readonly query: <Name extends PermissionName>(
|
|
35
|
+
name: Name
|
|
36
|
+
) => Effect.Effect<
|
|
37
|
+
// `name` is identical to the name passed to Permissions.query
|
|
38
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus
|
|
39
|
+
Omit<PermissionStatus, "name"> & { name: Name },
|
|
40
|
+
PermissionsError
|
|
41
|
+
>
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @since 1.0.0
|
|
46
|
+
* @category type ids
|
|
47
|
+
*/
|
|
48
|
+
export const ErrorTypeId: unique symbol = Symbol.for("@effect/platform-browser/Permissions/PermissionsError")
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @since 1.0.0
|
|
52
|
+
* @category type ids
|
|
53
|
+
*/
|
|
54
|
+
export type ErrorTypeId = typeof ErrorTypeId
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @since 1.0.0
|
|
58
|
+
* @category errors
|
|
59
|
+
*/
|
|
60
|
+
export class PermissionsError extends TypeIdError(ErrorTypeId, "PermissionsError")<{
|
|
61
|
+
/** https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query#exceptions */
|
|
62
|
+
readonly reason: "InvalidStateError" | "TypeError"
|
|
63
|
+
readonly cause: unknown
|
|
64
|
+
}> {
|
|
65
|
+
get message() {
|
|
66
|
+
return this.reason
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @since 1.0.0
|
|
72
|
+
* @category tags
|
|
73
|
+
*/
|
|
74
|
+
export const Permissions: Context.Tag<Permissions, Permissions> = Context.GenericTag<Permissions>(
|
|
75
|
+
"@effect/platform-browser/Permissions"
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A layer that directly interfaces with the `navigator.permissions` api
|
|
80
|
+
*
|
|
81
|
+
* @since 1.0.0
|
|
82
|
+
* @category layers
|
|
83
|
+
*/
|
|
84
|
+
export const layer: Layer.Layer<Permissions> = Layer.succeed(
|
|
85
|
+
Permissions,
|
|
86
|
+
Permissions.of({
|
|
87
|
+
[TypeId]: TypeId,
|
|
88
|
+
query: (name) =>
|
|
89
|
+
Effect.tryPromise({
|
|
90
|
+
try: () => navigator.permissions.query({ name }),
|
|
91
|
+
catch: (cause) =>
|
|
92
|
+
new PermissionsError({
|
|
93
|
+
reason: cause instanceof DOMException ? "InvalidStateError" : "TypeError",
|
|
94
|
+
cause
|
|
95
|
+
})
|
|
96
|
+
}).pipe(
|
|
97
|
+
Effect.map((status) => ({ ...status, name }))
|
|
98
|
+
)
|
|
99
|
+
})
|
|
100
|
+
)
|