@effect/platform-browser 4.0.0-beta.7 → 4.0.0-beta.70
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 +32 -16
- package/dist/BrowserHttpClient.d.ts.map +1 -1
- package/dist/BrowserHttpClient.js +66 -18
- package/dist/BrowserHttpClient.js.map +1 -1
- package/dist/BrowserKeyValueStore.d.ts +17 -14
- package/dist/BrowserKeyValueStore.d.ts.map +1 -1
- package/dist/BrowserKeyValueStore.js +130 -10
- package/dist/BrowserKeyValueStore.js.map +1 -1
- package/dist/BrowserPersistence.d.ts +21 -0
- package/dist/BrowserPersistence.d.ts.map +1 -0
- package/dist/BrowserPersistence.js +188 -0
- package/dist/BrowserPersistence.js.map +1 -0
- 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 +33 -5
- package/dist/BrowserStream.d.ts.map +1 -1
- package/dist/BrowserStream.js +33 -5
- 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 +30 -6
- 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 +34 -10
- package/dist/BrowserWorkerRunner.js.map +1 -1
- package/dist/Clipboard.d.ts +40 -13
- package/dist/Clipboard.d.ts.map +1 -1
- package/dist/Clipboard.js +33 -11
- package/dist/Clipboard.js.map +1 -1
- package/dist/Geolocation.d.ts +58 -24
- package/dist/Geolocation.d.ts.map +1 -1
- package/dist/Geolocation.js +46 -16
- package/dist/Geolocation.js.map +1 -1
- package/dist/IndexedDb.d.ts +77 -0
- package/dist/IndexedDb.d.ts.map +1 -0
- package/dist/IndexedDb.js +87 -0
- package/dist/IndexedDb.js.map +1 -0
- package/dist/IndexedDbDatabase.d.ts +150 -0
- package/dist/IndexedDbDatabase.d.ts.map +1 -0
- package/dist/IndexedDbDatabase.js +324 -0
- package/dist/IndexedDbDatabase.js.map +1 -0
- package/dist/IndexedDbQueryBuilder.d.ts +430 -0
- package/dist/IndexedDbQueryBuilder.d.ts.map +1 -0
- package/dist/IndexedDbQueryBuilder.js +927 -0
- package/dist/IndexedDbQueryBuilder.js.map +1 -0
- package/dist/IndexedDbTable.d.ts +153 -0
- package/dist/IndexedDbTable.d.ts.map +1 -0
- package/dist/IndexedDbTable.js +58 -0
- package/dist/IndexedDbTable.js.map +1 -0
- package/dist/IndexedDbVersion.d.ts +80 -0
- package/dist/IndexedDbVersion.d.ts.map +1 -0
- package/dist/IndexedDbVersion.js +25 -0
- package/dist/IndexedDbVersion.js.map +1 -0
- package/dist/Permissions.d.ts +45 -15
- package/dist/Permissions.d.ts.map +1 -1
- package/dist/Permissions.js +35 -10
- package/dist/Permissions.js.map +1 -1
- package/dist/index.d.ts +357 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +357 -10
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/BrowserCrypto.ts +71 -0
- package/src/BrowserHttpClient.ts +76 -24
- package/src/BrowserKeyValueStore.ts +146 -12
- package/src/BrowserPersistence.ts +319 -0
- package/src/BrowserRuntime.ts +31 -4
- package/src/BrowserSocket.ts +31 -6
- package/src/BrowserStream.ts +33 -5
- package/src/BrowserWorker.ts +30 -6
- package/src/BrowserWorkerRunner.ts +34 -10
- package/src/Clipboard.ts +37 -13
- package/src/Geolocation.ts +54 -20
- package/src/IndexedDb.ts +115 -0
- package/src/IndexedDbDatabase.ts +645 -0
- package/src/IndexedDbQueryBuilder.ts +2040 -0
- package/src/IndexedDbTable.ts +247 -0
- package/src/IndexedDbVersion.ts +119 -0
- package/src/Permissions.ts +40 -13
- package/src/index.ts +364 -10
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import * as Layer from "effect/Layer";
|
|
2
2
|
import * as WorkerRunner from "effect/unstable/workers/WorkerRunner";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Creates a `WorkerRunnerPlatform` service that runs worker handlers over a `MessagePort` or `Window`.
|
|
5
|
+
*
|
|
6
|
+
* @category constructors
|
|
7
|
+
* @since 4.0.0
|
|
6
8
|
*/
|
|
7
9
|
export declare const make: (self: MessagePort | Window) => WorkerRunner.WorkerRunnerPlatform["Service"];
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
+
* Layer that provides a browser `WorkerRunnerPlatform` using the global `self` worker context.
|
|
12
|
+
*
|
|
13
|
+
* @category layers
|
|
14
|
+
* @since 4.0.0
|
|
11
15
|
*/
|
|
12
16
|
export declare const layer: Layer.Layer<WorkerRunner.WorkerRunnerPlatform>;
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
18
|
+
* Layer that provides a `WorkerRunnerPlatform` using the supplied `MessagePort` or `Window`.
|
|
19
|
+
*
|
|
20
|
+
* @category layers
|
|
21
|
+
* @since 4.0.0
|
|
16
22
|
*/
|
|
17
23
|
export declare const layerMessagePort: (port: MessagePort | Window) => Layer.Layer<WorkerRunner.WorkerRunnerPlatform>;
|
|
18
24
|
//# sourceMappingURL=BrowserWorkerRunner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserWorkerRunner.d.ts","sourceRoot":"","sources":["../src/BrowserWorkerRunner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BrowserWorkerRunner.d.ts","sourceRoot":"","sources":["../src/BrowserWorkerRunner.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAIrC,OAAO,KAAK,YAAY,MAAM,sCAAsC,CAAA;AAUpE;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,MAAM,WAAW,GAAG,MAAM,KAAG,YAAY,CAAC,oBAAoB,CAAC,SAAS,CA2H3F,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,oBAAoB,CAEhE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,WAAW,GAAG,MAAM,KAAG,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,oBAAoB,CAC7C,CAAA"}
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Browser runtime support for Effect worker runners.
|
|
3
|
+
*
|
|
4
|
+
* This module is intended for code that is already executing in a browser
|
|
5
|
+
* worker context, or for tests and adapters that supply a `MessagePort` or
|
|
6
|
+
* `Window` endpoint directly. It provides the `WorkerRunnerPlatform` used by
|
|
7
|
+
* `WorkerRunner` and `RpcServer.layerProtocolWorkerRunner` to receive parent
|
|
8
|
+
* or client requests, run Effect handlers, and send responses through the
|
|
9
|
+
* browser `postMessage` channel.
|
|
10
|
+
*
|
|
11
|
+
* Use it with `BrowserWorker` when a browser application needs to move RPC
|
|
12
|
+
* handlers, CPU-bound computations, or browser-only services into a dedicated
|
|
13
|
+
* worker or shared worker. Dedicated workers communicate through the current
|
|
14
|
+
* `self` endpoint; shared workers accept multiple `onconnect` ports and cache
|
|
15
|
+
* ports that connect before the runner layer starts. Messages still use the
|
|
16
|
+
* browser structured-clone algorithm, so payload schemas, transfer lists,
|
|
17
|
+
* `messageerror` events, and the lifetime of each `MessagePort` must be
|
|
18
|
+
* considered when crossing worker boundaries.
|
|
19
|
+
*
|
|
20
|
+
* @since 4.0.0
|
|
3
21
|
*/
|
|
4
22
|
import * as Cause from "effect/Cause";
|
|
5
23
|
import * as Deferred from "effect/Deferred";
|
|
@@ -20,8 +38,10 @@ if (typeof self !== "undefined" && "onconnect" in self) {
|
|
|
20
38
|
self.onconnect = globalHandleConnect;
|
|
21
39
|
}
|
|
22
40
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
41
|
+
* Creates a `WorkerRunnerPlatform` service that runs worker handlers over a `MessagePort` or `Window`.
|
|
42
|
+
*
|
|
43
|
+
* @category constructors
|
|
44
|
+
* @since 4.0.0
|
|
25
45
|
*/
|
|
26
46
|
export const make = self => ({
|
|
27
47
|
start: Effect.fnUntraced(function* () {
|
|
@@ -35,7 +55,7 @@ export const make = self => ({
|
|
|
35
55
|
const run = handler => Effect.scopedWith(Effect.fnUntraced(function* (scope) {
|
|
36
56
|
const closeLatch = Deferred.makeUnsafe();
|
|
37
57
|
const trackFiber = Fiber.runIn(scope);
|
|
38
|
-
const services = yield* Effect.
|
|
58
|
+
const services = yield* Effect.context();
|
|
39
59
|
const runFork = Effect.runForkWith(services);
|
|
40
60
|
const onExit = exit => {
|
|
41
61
|
if (exit._tag === "Failure" && !Cause.hasInterruptsOnly(exit.cause)) {
|
|
@@ -71,7 +91,7 @@ export const make = self => ({
|
|
|
71
91
|
message: "An messageerror event was emitted",
|
|
72
92
|
cause: error.data
|
|
73
93
|
})
|
|
74
|
-
})
|
|
94
|
+
}));
|
|
75
95
|
}
|
|
76
96
|
function onError(error) {
|
|
77
97
|
Deferred.doneUnsafe(closeLatch, new WorkerError({
|
|
@@ -79,7 +99,7 @@ export const make = self => ({
|
|
|
79
99
|
message: "An error event was emitted",
|
|
80
100
|
cause: error.data
|
|
81
101
|
})
|
|
82
|
-
})
|
|
102
|
+
}));
|
|
83
103
|
}
|
|
84
104
|
function handlePort(port) {
|
|
85
105
|
const portScope = Scope.forkUnsafe(scope);
|
|
@@ -131,13 +151,17 @@ export const make = self => ({
|
|
|
131
151
|
})
|
|
132
152
|
});
|
|
133
153
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
154
|
+
* Layer that provides a browser `WorkerRunnerPlatform` using the global `self` worker context.
|
|
155
|
+
*
|
|
156
|
+
* @category layers
|
|
157
|
+
* @since 4.0.0
|
|
136
158
|
*/
|
|
137
159
|
export const layer = /*#__PURE__*/Layer.sync(WorkerRunner.WorkerRunnerPlatform)(() => make(self));
|
|
138
160
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
161
|
+
* Layer that provides a `WorkerRunnerPlatform` using the supplied `MessagePort` or `Window`.
|
|
162
|
+
*
|
|
163
|
+
* @category layers
|
|
164
|
+
* @since 4.0.0
|
|
141
165
|
*/
|
|
142
166
|
export const layerMessagePort = port => Layer.succeed(WorkerRunner.WorkerRunnerPlatform)(make(port));
|
|
143
167
|
//# sourceMappingURL=BrowserWorkerRunner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserWorkerRunner.js","names":["Cause","Deferred","Effect","Exit","Fiber","identity","Layer","Queue","Scope","WorkerError","WorkerReceiveError","WorkerRunner","cachedPorts","Set","globalHandleConnect","event","add","ports","self","onconnect","make","start","fnUntraced","disconnects","currentPortId","Map","sendUnsafe","portId","message","transfer","get","postMessage","send","sync","run","handler","scopedWith","scope","closeLatch","makeUnsafe","trackFiber","runIn","services","runFork","runForkWith","onExit","exit","_tag","hasInterruptsOnly","cause","logError","onMessage","data","result","isEffect","fiber","addObserver","port","size","doneUnsafe","void","delete","close","onMessageError","error","reason","
|
|
1
|
+
{"version":3,"file":"BrowserWorkerRunner.js","names":["Cause","Deferred","Effect","Exit","Fiber","identity","Layer","Queue","Scope","WorkerError","WorkerReceiveError","WorkerRunner","cachedPorts","Set","globalHandleConnect","event","add","ports","self","onconnect","make","start","fnUntraced","disconnects","currentPortId","Map","sendUnsafe","portId","message","transfer","get","postMessage","send","sync","run","handler","scopedWith","scope","closeLatch","makeUnsafe","trackFiber","runIn","services","context","runFork","runForkWith","onExit","exit","_tag","hasInterruptsOnly","cause","logError","onMessage","data","result","isEffect","fiber","addObserver","port","size","doneUnsafe","void","delete","close","onMessageError","error","reason","onError","handlePort","portScope","forkUnsafe","set","onMsg","addEventListener","runSync","addFinalizer","removeEventListener","prevOnConnect","clear","await","layer","WorkerRunnerPlatform","layerMessagePort","succeed"],"sources":["../src/BrowserWorkerRunner.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;AAqBA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,SAASC,WAAW,EAAEC,kBAAkB,QAAQ,qCAAqC;AACrF,OAAO,KAAKC,YAAY,MAAM,sCAAsC;AAEpE,MAAMC,WAAW,gBAAG,IAAIC,GAAG,EAAe;AAC1C,SAASC,mBAAmBA,CAACC,KAAmB;EAC9CH,WAAW,CAACI,GAAG,CAAED,KAAsB,CAACE,KAAK,CAAC,CAAC,CAAC,CAAC;AACnD;AACA,IAAI,OAAOC,IAAI,KAAK,WAAW,IAAI,WAAW,IAAIA,IAAI,EAAE;EACtDA,IAAI,CAACC,SAAS,GAAGL,mBAAmB;AACtC;AAEA;;;;;;AAMA,OAAO,MAAMM,IAAI,GAAIF,IAA0B,KAAoD;EACjGG,KAAK,EAAEnB,MAAM,CAACoB,UAAU,CAAC,aAAS;IAChC,MAAMC,WAAW,GAAG,OAAOhB,KAAK,CAACa,IAAI,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,CAACV,IAAI,CAAC;QAClB;QACA9C,WAAW,CAACkE,KAAK,EAAE;MACrB,CAAC,MAAM;QACLV,UAAU,CAAClD,IAAW,CAAC;MACzB;MACA,OAAOV,KAAK,CAACmE,YAAY,CACvBtC,KAAK,EACLnC,MAAM,CAAC+B,IAAI,CAAC,MAAK;QACff,IAAI,CAAC0D,mBAAmB,CAAC,OAAO,EAAET,OAAO,CAAC;QAC1C,IAAI,WAAW,IAAIjD,IAAI,EAAE;UACvBA,IAAI,CAAC6C,KAAK,EAAE;UACZ7C,IAAI,CAACC,SAAS,GAAG0D,aAAa;QAChC;MACF,CAAC,CAAC,CACH;MAED,OAAO5E,QAAQ,CAAC8E,KAAK,CAACzC,UAAU,CAAC;IACnC,CAAC,CAAC,CAAC;IAEL,OAAOjC,QAAQ,CAAkC;MAAE6B,GAAG;MAAEF,IAAI;MAAEN,UAAU;MAAEH;IAAW,CAAE,CAAC;EAC1F,CAAC;CACF,CAAC;AAEF;;;;;;AAMA,OAAO,MAAMyD,KAAK,gBAAmD1E,KAAK,CAAC2B,IAAI,CAACtB,YAAY,CAACsE,oBAAoB,CAAC,CAAC,MACjH7D,IAAI,CAACF,IAAI,CAAC,CACX;AAED;;;;;;AAMA,OAAO,MAAMgE,gBAAgB,GAAIxB,IAA0B,IACzDpD,KAAK,CAAC6E,OAAO,CAACxE,YAAY,CAACsE,oBAAoB,CAAC,CAAC7D,IAAI,CAACsC,IAAI,CAAC,CAAC","ignoreList":[]}
|
package/dist/Clipboard.d.ts
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
|
+
/**
|
|
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
|
|
19
|
+
*/
|
|
20
|
+
import * as Context from "effect/Context";
|
|
1
21
|
import * as Effect from "effect/Effect";
|
|
2
22
|
import * as Layer from "effect/Layer";
|
|
3
|
-
import * as ServiceMap from "effect/ServiceMap";
|
|
4
23
|
declare const TypeId = "~@effect/platform-browser/Clipboard";
|
|
5
24
|
declare const ErrorTypeId = "~@effect/platform-browser/Clipboard/ClipboardError";
|
|
6
25
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
26
|
+
* Service interface for reading from, writing to, and clearing the browser clipboard.
|
|
27
|
+
*
|
|
28
|
+
* @category models
|
|
29
|
+
* @since 4.0.0
|
|
9
30
|
*/
|
|
10
31
|
export interface Clipboard {
|
|
11
32
|
readonly [TypeId]: typeof TypeId;
|
|
@@ -16,12 +37,14 @@ export interface Clipboard {
|
|
|
16
37
|
readonly writeBlob: (blob: Blob) => Effect.Effect<void, ClipboardError>;
|
|
17
38
|
readonly clear: Effect.Effect<void, ClipboardError>;
|
|
18
39
|
}
|
|
19
|
-
declare const ClipboardError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
40
|
+
declare const ClipboardError_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 & {
|
|
20
41
|
readonly _tag: "ClipboardError";
|
|
21
42
|
} & Readonly<A>;
|
|
22
43
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
44
|
+
* Tagged error raised when a browser clipboard operation fails.
|
|
45
|
+
*
|
|
46
|
+
* @category errors
|
|
47
|
+
* @since 4.0.0
|
|
25
48
|
*/
|
|
26
49
|
export declare class ClipboardError extends ClipboardError_base<{
|
|
27
50
|
readonly message: string;
|
|
@@ -30,20 +53,24 @@ export declare class ClipboardError extends ClipboardError_base<{
|
|
|
30
53
|
readonly [ErrorTypeId] = "~@effect/platform-browser/Clipboard/ClipboardError";
|
|
31
54
|
}
|
|
32
55
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
56
|
+
* Service tag for the browser `Clipboard` service.
|
|
57
|
+
*
|
|
58
|
+
* @category services
|
|
59
|
+
* @since 4.0.0
|
|
35
60
|
*/
|
|
36
|
-
export declare const Clipboard:
|
|
61
|
+
export declare const Clipboard: Context.Service<Clipboard, Clipboard>;
|
|
37
62
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
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
|
|
40
67
|
*/
|
|
41
68
|
export declare const make: (impl: Omit<Clipboard, "clear" | "writeBlob" | typeof TypeId>) => Clipboard;
|
|
42
69
|
/**
|
|
43
70
|
* A layer that directly interfaces with the navigator.clipboard api
|
|
44
71
|
*
|
|
45
|
-
* @
|
|
46
|
-
* @
|
|
72
|
+
* @category layers
|
|
73
|
+
* @since 4.0.0
|
|
47
74
|
*/
|
|
48
75
|
export declare const layer: Layer.Layer<Clipboard>;
|
|
49
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":"
|
|
1
|
+
{"version":3,"file":"Clipboard.d.ts","sourceRoot":"","sources":["../src/Clipboard.ts"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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,27 +1,49 @@
|
|
|
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
|
*/
|
|
20
|
+
import * as Context from "effect/Context";
|
|
4
21
|
import * as Data from "effect/Data";
|
|
5
22
|
import * as Effect from "effect/Effect";
|
|
6
23
|
import * as Layer from "effect/Layer";
|
|
7
|
-
import * as ServiceMap from "effect/ServiceMap";
|
|
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
|
-
export const Clipboard = /*#__PURE__*/
|
|
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":["Data","Effect","Layer","
|
|
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,16 +1,34 @@
|
|
|
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";
|
|
21
|
+
import * as Context from "effect/Context";
|
|
5
22
|
import * as Effect from "effect/Effect";
|
|
6
23
|
import * as Layer from "effect/Layer";
|
|
7
|
-
import * as ServiceMap from "effect/ServiceMap";
|
|
8
24
|
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
|
-
export declare const Geolocation:
|
|
27
|
-
declare const GeolocationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
46
|
+
export declare const Geolocation: Context.Service<Geolocation, Geolocation>;
|
|
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;
|
|
@@ -40,36 +62,42 @@ export declare class GeolocationError extends GeolocationError_base<{
|
|
|
40
62
|
readonly [ErrorTypeId] = "~@effect/platform-browser/Geolocation/GeolocationError";
|
|
41
63
|
get message(): string;
|
|
42
64
|
}
|
|
43
|
-
declare const PositionUnavailable_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
65
|
+
declare const PositionUnavailable_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 & {
|
|
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;
|
|
52
76
|
}> {
|
|
53
77
|
get message(): string;
|
|
54
78
|
}
|
|
55
|
-
declare const PermissionDenied_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
79
|
+
declare const PermissionDenied_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 & {
|
|
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;
|
|
64
90
|
}> {
|
|
65
91
|
get message(): string;
|
|
66
92
|
}
|
|
67
|
-
declare const Timeout_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
93
|
+
declare const Timeout_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 & {
|
|
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;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,QAAA,MAAM,MAAM,0CAA0C,CAAA;AACtD,QAAA,MAAM,WAAW,2DAA2D,CAAA;AAE5E;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,MAAM,CAAA;IAChC,QAAQ,CAAC,kBAAkB,EAAE,CAC3B,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,KAClC,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAA;IACzD,QAAQ,CAAC,aAAa,EAAE,CACtB,OAAO,CAAC,EACJ,eAAe,GAAG;QAClB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KACzC,GACC,SAAS,KACV,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAA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CAAA"}
|
package/dist/Geolocation.js
CHANGED
|
@@ -1,23 +1,43 @@
|
|
|
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";
|
|
21
|
+
import * as Context from "effect/Context";
|
|
5
22
|
import * as Data from "effect/Data";
|
|
6
23
|
import * as Effect from "effect/Effect";
|
|
7
24
|
import * as Layer from "effect/Layer";
|
|
8
25
|
import * as Queue from "effect/Queue";
|
|
9
|
-
import * as ServiceMap from "effect/ServiceMap";
|
|
10
26
|
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
|
-
export const Geolocation = /*#__PURE__*/
|
|
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","Data","Effect","Layer","Queue","
|
|
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,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,MAAMC,MAAM,GAAG,uCAAuC;AACtD,MAAMC,WAAW,GAAG,wDAAwD;AAsB5E;;;;;;AAMA,OAAO,MAAMC,WAAW,gBAA8CR,OAAO,CAACS,OAAO,CAAcH,MAAM,CAAC;AAE1G;;;;;;AAMA,OAAM,MAAOI,gBAAiB,sBAAQT,IAAI,CAACU,WAAW,CAAC,kBAAkB,CAEvE;EACAC,YAAYC,KAEX;IACC,KAAK,CAAC;MACJ,GAAGA,KAAK;MACRC,KAAK,EAAED,KAAK,CAACE,MAAM,CAACD;KACd,CAAC;EACX;EAES,CAACP,WAAW,IAAIA,WAAW;EAEpC,IAAaS,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACD,MAAM,CAACC,OAAO;EAC5B;;AAGF;;;;;;AAMA,OAAM,MAAOC,mBAAoB,sBAAQhB,IAAI,CAACU,WAAW,CAAC,qBAAqB,CAE7E;EACA,IAAaK,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACE,IAAI;EAClB;;AAGF;;;;;;AAMA,OAAM,MAAOC,gBAAiB,sBAAQlB,IAAI,CAACU,WAAW,CAAC,kBAAkB,CAEvE;EACA,IAAaK,OAA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