@effect/platform-browser 4.0.0-beta.7 → 4.0.0-beta.71
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 +81 -0
- package/dist/BrowserCrypto.d.ts.map +1 -0
- package/dist/BrowserCrypto.js +119 -0
- package/dist/BrowserCrypto.js.map +1 -0
- package/dist/BrowserHttpClient.d.ts +40 -16
- package/dist/BrowserHttpClient.d.ts.map +1 -1
- package/dist/BrowserHttpClient.js +74 -18
- package/dist/BrowserHttpClient.js.map +1 -1
- package/dist/BrowserKeyValueStore.d.ts +37 -14
- package/dist/BrowserKeyValueStore.d.ts.map +1 -1
- package/dist/BrowserKeyValueStore.js +185 -10
- package/dist/BrowserKeyValueStore.js.map +1 -1
- package/dist/BrowserPersistence.d.ts +40 -0
- package/dist/BrowserPersistence.d.ts.map +1 -0
- package/dist/BrowserPersistence.js +207 -0
- package/dist/BrowserPersistence.js.map +1 -0
- package/dist/BrowserRuntime.d.ts +79 -4
- package/dist/BrowserRuntime.d.ts.map +1 -1
- package/dist/BrowserRuntime.js +19 -1
- package/dist/BrowserRuntime.js.map +1 -1
- package/dist/BrowserSocket.d.ts +64 -6
- package/dist/BrowserSocket.d.ts.map +1 -1
- package/dist/BrowserSocket.js +64 -6
- package/dist/BrowserSocket.js.map +1 -1
- package/dist/BrowserStream.d.ts +48 -5
- package/dist/BrowserStream.d.ts.map +1 -1
- package/dist/BrowserStream.js +48 -5
- package/dist/BrowserStream.js.map +1 -1
- package/dist/BrowserWorker.d.ts +25 -4
- package/dist/BrowserWorker.d.ts.map +1 -1
- package/dist/BrowserWorker.js +62 -6
- package/dist/BrowserWorker.js.map +1 -1
- package/dist/BrowserWorkerRunner.d.ts +31 -6
- package/dist/BrowserWorkerRunner.d.ts.map +1 -1
- package/dist/BrowserWorkerRunner.js +65 -10
- package/dist/BrowserWorkerRunner.js.map +1 -1
- package/dist/Clipboard.d.ts +77 -13
- package/dist/Clipboard.d.ts.map +1 -1
- package/dist/Clipboard.js +57 -11
- package/dist/Clipboard.js.map +1 -1
- package/dist/Geolocation.d.ts +101 -24
- package/dist/Geolocation.d.ts.map +1 -1
- package/dist/Geolocation.js +69 -16
- package/dist/Geolocation.js.map +1 -1
- package/dist/IndexedDb.d.ts +89 -0
- package/dist/IndexedDb.d.ts.map +1 -0
- package/dist/IndexedDb.js +99 -0
- package/dist/IndexedDb.js.map +1 -0
- package/dist/IndexedDbDatabase.d.ts +169 -0
- package/dist/IndexedDbDatabase.d.ts.map +1 -0
- package/dist/IndexedDbDatabase.js +343 -0
- package/dist/IndexedDbDatabase.js.map +1 -0
- package/dist/IndexedDbQueryBuilder.d.ts +438 -0
- package/dist/IndexedDbQueryBuilder.d.ts.map +1 -0
- package/dist/IndexedDbQueryBuilder.js +935 -0
- package/dist/IndexedDbQueryBuilder.js.map +1 -0
- package/dist/IndexedDbTable.d.ts +191 -0
- package/dist/IndexedDbTable.d.ts.map +1 -0
- package/dist/IndexedDbTable.js +96 -0
- package/dist/IndexedDbTable.js.map +1 -0
- package/dist/IndexedDbVersion.d.ts +94 -0
- package/dist/IndexedDbVersion.d.ts.map +1 -0
- package/dist/IndexedDbVersion.js +39 -0
- package/dist/IndexedDbVersion.js.map +1 -0
- package/dist/Permissions.d.ts +76 -16
- package/dist/Permissions.d.ts.map +1 -1
- package/dist/Permissions.js +66 -11
- package/dist/Permissions.js.map +1 -1
- package/dist/index.d.ts +38 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -10
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/BrowserCrypto.ts +129 -0
- package/src/BrowserHttpClient.ts +84 -24
- package/src/BrowserKeyValueStore.ts +201 -12
- package/src/BrowserPersistence.ts +376 -0
- package/src/BrowserRuntime.ts +79 -4
- package/src/BrowserSocket.ts +64 -6
- package/src/BrowserStream.ts +48 -5
- package/src/BrowserWorker.ts +62 -6
- package/src/BrowserWorkerRunner.ts +65 -10
- package/src/Clipboard.ts +74 -13
- package/src/Geolocation.ts +97 -20
- package/src/IndexedDb.ts +127 -0
- package/src/IndexedDbDatabase.ts +664 -0
- package/src/IndexedDbQueryBuilder.ts +2048 -0
- package/src/IndexedDbTable.ts +285 -0
- package/src/IndexedDbVersion.ts +133 -0
- package/src/Permissions.ts +71 -14
- package/src/index.ts +45 -10
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Runner-side browser platform for Effect worker handlers.
|
|
3
|
+
*
|
|
4
|
+
* This module is for code already executing inside a browser worker, or for
|
|
5
|
+
* tests and adapters that pass a `MessagePort` or `Window` endpoint directly.
|
|
6
|
+
* It provides the `WorkerRunnerPlatform` used by `WorkerRunner` and protocols
|
|
7
|
+
* such as `RpcServer.layerProtocolWorkerRunner` to receive parent or client
|
|
8
|
+
* requests, run Effect handlers, and post responses back through the browser
|
|
9
|
+
* messaging channel.
|
|
10
|
+
*
|
|
11
|
+
* **Mental model**
|
|
12
|
+
*
|
|
13
|
+
* Dedicated workers use the ambient `self` endpoint. Shared workers receive one
|
|
14
|
+
* `MessagePort` per `onconnect` event, and this module caches ports that arrive
|
|
15
|
+
* before the runner layer starts. `layer` reads from the global worker `self`;
|
|
16
|
+
* `make` and `layerMessagePort` are for explicit endpoints supplied by tests,
|
|
17
|
+
* custom channels, or adapter code.
|
|
18
|
+
*
|
|
19
|
+
* **Common tasks**
|
|
20
|
+
*
|
|
21
|
+
* Pair this module with `BrowserWorker` in the parent page when moving RPC
|
|
22
|
+
* handlers, CPU-bound computations, or browser-only services into a dedicated
|
|
23
|
+
* worker or shared worker. Use `layer` in normal worker entry points and
|
|
24
|
+
* `layerMessagePort` when a test or integration already owns the transport.
|
|
25
|
+
*
|
|
26
|
+
* **Gotchas**
|
|
27
|
+
*
|
|
28
|
+
* Payloads and transfer lists must satisfy the browser structured-clone
|
|
29
|
+
* algorithm. `messageerror` and `error` events fail the runner, and each
|
|
30
|
+
* connected `MessagePort` is closed when its scope finalizes.
|
|
31
|
+
*
|
|
32
|
+
* @since 4.0.0
|
|
3
33
|
*/
|
|
4
34
|
import * as Cause from "effect/Cause";
|
|
5
35
|
import * as Deferred from "effect/Deferred";
|
|
@@ -20,8 +50,10 @@ if (typeof self !== "undefined" && "onconnect" in self) {
|
|
|
20
50
|
self.onconnect = globalHandleConnect;
|
|
21
51
|
}
|
|
22
52
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
53
|
+
* Creates a `WorkerRunnerPlatform` service that runs worker handlers over a `MessagePort` or `Window`.
|
|
54
|
+
*
|
|
55
|
+
* @category constructors
|
|
56
|
+
* @since 4.0.0
|
|
25
57
|
*/
|
|
26
58
|
export const make = self => ({
|
|
27
59
|
start: Effect.fnUntraced(function* () {
|
|
@@ -35,7 +67,7 @@ export const make = self => ({
|
|
|
35
67
|
const run = handler => Effect.scopedWith(Effect.fnUntraced(function* (scope) {
|
|
36
68
|
const closeLatch = Deferred.makeUnsafe();
|
|
37
69
|
const trackFiber = Fiber.runIn(scope);
|
|
38
|
-
const services = yield* Effect.
|
|
70
|
+
const services = yield* Effect.context();
|
|
39
71
|
const runFork = Effect.runForkWith(services);
|
|
40
72
|
const onExit = exit => {
|
|
41
73
|
if (exit._tag === "Failure" && !Cause.hasInterruptsOnly(exit.cause)) {
|
|
@@ -71,7 +103,7 @@ export const make = self => ({
|
|
|
71
103
|
message: "An messageerror event was emitted",
|
|
72
104
|
cause: error.data
|
|
73
105
|
})
|
|
74
|
-
})
|
|
106
|
+
}));
|
|
75
107
|
}
|
|
76
108
|
function onError(error) {
|
|
77
109
|
Deferred.doneUnsafe(closeLatch, new WorkerError({
|
|
@@ -79,7 +111,7 @@ export const make = self => ({
|
|
|
79
111
|
message: "An error event was emitted",
|
|
80
112
|
cause: error.data
|
|
81
113
|
})
|
|
82
|
-
})
|
|
114
|
+
}));
|
|
83
115
|
}
|
|
84
116
|
function handlePort(port) {
|
|
85
117
|
const portScope = Scope.forkUnsafe(scope);
|
|
@@ -131,13 +163,36 @@ export const make = self => ({
|
|
|
131
163
|
})
|
|
132
164
|
});
|
|
133
165
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
166
|
+
* Layer that provides a browser `WorkerRunnerPlatform` using the global `self` worker context.
|
|
167
|
+
*
|
|
168
|
+
* **When to use**
|
|
169
|
+
*
|
|
170
|
+
* Use when a browser worker entry point uses the ambient `self` object as the
|
|
171
|
+
* worker transport.
|
|
172
|
+
*
|
|
173
|
+
* **Details**
|
|
174
|
+
*
|
|
175
|
+
* Delegates to `make(self)` and provides the runner-side platform used by
|
|
176
|
+
* protocols such as `RpcServer.layerProtocolWorkerRunner`.
|
|
177
|
+
*
|
|
178
|
+
* **Gotchas**
|
|
179
|
+
*
|
|
180
|
+
* This layer depends on the browser worker global `self`. Use
|
|
181
|
+
* `layerMessagePort` when the transport is an explicit `MessagePort` or
|
|
182
|
+
* `Window`.
|
|
183
|
+
*
|
|
184
|
+
* @see {@link make} for constructing a runner platform from an explicit endpoint
|
|
185
|
+
* @see {@link layerMessagePort} for providing a platform from an explicit endpoint
|
|
186
|
+
*
|
|
187
|
+
* @category layers
|
|
188
|
+
* @since 4.0.0
|
|
136
189
|
*/
|
|
137
190
|
export const layer = /*#__PURE__*/Layer.sync(WorkerRunner.WorkerRunnerPlatform)(() => make(self));
|
|
138
191
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
192
|
+
* Layer that provides a `WorkerRunnerPlatform` using the supplied `MessagePort` or `Window`.
|
|
193
|
+
*
|
|
194
|
+
* @category layers
|
|
195
|
+
* @since 4.0.0
|
|
141
196
|
*/
|
|
142
197
|
export const layerMessagePort = port => Layer.succeed(WorkerRunner.WorkerRunnerPlatform)(make(port));
|
|
143
198
|
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,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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,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,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser clipboard integration for Effect programs.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a `Clipboard` service backed by `navigator.clipboard`.
|
|
5
|
+
* It keeps copy, paste, clear, and rich clipboard operations inside the Effect
|
|
6
|
+
* environment so browser UI code can require clipboard capability without
|
|
7
|
+
* calling the global API directly. Text helpers cover portable copy and paste
|
|
8
|
+
* flows, while `read`, `write`, and `writeBlob` expose `ClipboardItem` payloads
|
|
9
|
+
* for browsers that support richer MIME types.
|
|
10
|
+
*
|
|
11
|
+
* **Mental model**
|
|
12
|
+
*
|
|
13
|
+
* `Clipboard` is a capability service. Application code depends on the service
|
|
14
|
+
* tag, {@link layer} supplies the live browser implementation, and {@link make}
|
|
15
|
+
* builds custom implementations for tests, unsupported browsers, or constrained
|
|
16
|
+
* capabilities. Browser failures are converted to {@link ClipboardError}.
|
|
17
|
+
*
|
|
18
|
+
* **Common tasks**
|
|
19
|
+
*
|
|
20
|
+
* - Provide {@link layer} near the browser application edge.
|
|
21
|
+
* - Use `writeString` for copy buttons and generated text.
|
|
22
|
+
* - Use `readString` for paste or import workflows.
|
|
23
|
+
* - Use `write` or `writeBlob` for rich clipboard payloads when
|
|
24
|
+
* `ClipboardItem` is available.
|
|
25
|
+
* - Use `clear` to replace the clipboard with an empty string.
|
|
26
|
+
*
|
|
27
|
+
* **Gotchas**
|
|
28
|
+
*
|
|
29
|
+
* Clipboard access requires a secure context in modern browsers and may also
|
|
30
|
+
* require user activation, permissions, and a focused document. Support differs
|
|
31
|
+
* between reads, writes, text, and custom MIME payloads, so feature detection or
|
|
32
|
+
* graceful fallback is often needed around `ClipboardItem` usage.
|
|
33
|
+
*
|
|
34
|
+
* @since 4.0.0
|
|
35
|
+
*/
|
|
36
|
+
import * as Context from "effect/Context";
|
|
1
37
|
import * as Effect from "effect/Effect";
|
|
2
38
|
import * as Layer from "effect/Layer";
|
|
3
|
-
import * as ServiceMap from "effect/ServiceMap";
|
|
4
39
|
declare const TypeId = "~@effect/platform-browser/Clipboard";
|
|
5
40
|
declare const ErrorTypeId = "~@effect/platform-browser/Clipboard/ClipboardError";
|
|
6
41
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
42
|
+
* Service interface for reading from, writing to, and clearing the browser clipboard.
|
|
43
|
+
*
|
|
44
|
+
* **Details**
|
|
45
|
+
*
|
|
46
|
+
* `read` and `write` work with `ClipboardItem` arrays. `readString` and
|
|
47
|
+
* `writeString` use text, `writeBlob` writes one `Blob`, and `clear` writes an
|
|
48
|
+
* empty string.
|
|
49
|
+
*
|
|
50
|
+
* **Gotchas**
|
|
51
|
+
*
|
|
52
|
+
* Clipboard access generally requires a secure context and may require user
|
|
53
|
+
* activation, permissions, or a focused document. `ClipboardItem` and non-text
|
|
54
|
+
* MIME type support varies by browser. Failed browser operations are surfaced
|
|
55
|
+
* as `ClipboardError`.
|
|
56
|
+
*
|
|
57
|
+
* @category models
|
|
58
|
+
* @since 4.0.0
|
|
9
59
|
*/
|
|
10
60
|
export interface Clipboard {
|
|
11
61
|
readonly [TypeId]: typeof TypeId;
|
|
@@ -16,12 +66,14 @@ export interface Clipboard {
|
|
|
16
66
|
readonly writeBlob: (blob: Blob) => Effect.Effect<void, ClipboardError>;
|
|
17
67
|
readonly clear: Effect.Effect<void, ClipboardError>;
|
|
18
68
|
}
|
|
19
|
-
declare const ClipboardError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
69
|
+
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
70
|
readonly _tag: "ClipboardError";
|
|
21
71
|
} & Readonly<A>;
|
|
22
72
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
73
|
+
* Tagged error raised when a browser clipboard operation fails.
|
|
74
|
+
*
|
|
75
|
+
* @category errors
|
|
76
|
+
* @since 4.0.0
|
|
25
77
|
*/
|
|
26
78
|
export declare class ClipboardError extends ClipboardError_base<{
|
|
27
79
|
readonly message: string;
|
|
@@ -30,20 +82,32 @@ export declare class ClipboardError extends ClipboardError_base<{
|
|
|
30
82
|
readonly [ErrorTypeId] = "~@effect/platform-browser/Clipboard/ClipboardError";
|
|
31
83
|
}
|
|
32
84
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
85
|
+
* Service tag for the browser `Clipboard` service.
|
|
86
|
+
*
|
|
87
|
+
* **When to use**
|
|
88
|
+
*
|
|
89
|
+
* Use when an Effect needs to require or provide clipboard capabilities through
|
|
90
|
+
* the context.
|
|
91
|
+
*
|
|
92
|
+
* @see {@link make} for building a custom clipboard service
|
|
93
|
+
* @see {@link layer} for providing the browser-backed clipboard service
|
|
94
|
+
*
|
|
95
|
+
* @category services
|
|
96
|
+
* @since 4.0.0
|
|
35
97
|
*/
|
|
36
|
-
export declare const Clipboard:
|
|
98
|
+
export declare const Clipboard: Context.Service<Clipboard, Clipboard>;
|
|
37
99
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
100
|
+
* Builds a `Clipboard` service from primitive read and write operations, deriving `clear` and `writeBlob` helpers.
|
|
101
|
+
*
|
|
102
|
+
* @category constructors
|
|
103
|
+
* @since 4.0.0
|
|
40
104
|
*/
|
|
41
105
|
export declare const make: (impl: Omit<Clipboard, "clear" | "writeBlob" | typeof TypeId>) => Clipboard;
|
|
42
106
|
/**
|
|
43
107
|
* A layer that directly interfaces with the navigator.clipboard api
|
|
44
108
|
*
|
|
45
|
-
* @
|
|
46
|
-
* @
|
|
109
|
+
* @category layers
|
|
110
|
+
* @since 4.0.0
|
|
47
111
|
*/
|
|
48
112
|
export declare const layer: Layer.Layer<Clipboard>;
|
|
49
113
|
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"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,QAAA,MAAM,MAAM,wCAAwC,CAAA;AACpD,QAAA,MAAM,WAAW,uDAAuD,CAAA;AAExE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,MAAM,CAAA;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,cAAc,CAAC,CAAA;IAC5D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAC1D,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAA;IAC9E,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAA;IAC3E,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAA;IACvE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAA;CACpD;;;;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,oBAAmC;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CACxB,CAAC;IACA,QAAQ,CAAC,CAAC,WAAW,CAAC,wDAAc;CACrC;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAsC,CAAA;AAElG;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GACf,MAAM,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,WAAW,GAAG,OAAO,MAAM,CAAC,KAC3D,SAMC,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAsCxC,CAAA"}
|
package/dist/Clipboard.js
CHANGED
|
@@ -1,27 +1,73 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Browser clipboard integration for Effect programs.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a `Clipboard` service backed by `navigator.clipboard`.
|
|
5
|
+
* It keeps copy, paste, clear, and rich clipboard operations inside the Effect
|
|
6
|
+
* environment so browser UI code can require clipboard capability without
|
|
7
|
+
* calling the global API directly. Text helpers cover portable copy and paste
|
|
8
|
+
* flows, while `read`, `write`, and `writeBlob` expose `ClipboardItem` payloads
|
|
9
|
+
* for browsers that support richer MIME types.
|
|
10
|
+
*
|
|
11
|
+
* **Mental model**
|
|
12
|
+
*
|
|
13
|
+
* `Clipboard` is a capability service. Application code depends on the service
|
|
14
|
+
* tag, {@link layer} supplies the live browser implementation, and {@link make}
|
|
15
|
+
* builds custom implementations for tests, unsupported browsers, or constrained
|
|
16
|
+
* capabilities. Browser failures are converted to {@link ClipboardError}.
|
|
17
|
+
*
|
|
18
|
+
* **Common tasks**
|
|
19
|
+
*
|
|
20
|
+
* - Provide {@link layer} near the browser application edge.
|
|
21
|
+
* - Use `writeString` for copy buttons and generated text.
|
|
22
|
+
* - Use `readString` for paste or import workflows.
|
|
23
|
+
* - Use `write` or `writeBlob` for rich clipboard payloads when
|
|
24
|
+
* `ClipboardItem` is available.
|
|
25
|
+
* - Use `clear` to replace the clipboard with an empty string.
|
|
26
|
+
*
|
|
27
|
+
* **Gotchas**
|
|
28
|
+
*
|
|
29
|
+
* Clipboard access requires a secure context in modern browsers and may also
|
|
30
|
+
* require user activation, permissions, and a focused document. Support differs
|
|
31
|
+
* between reads, writes, text, and custom MIME payloads, so feature detection or
|
|
32
|
+
* graceful fallback is often needed around `ClipboardItem` usage.
|
|
33
|
+
*
|
|
34
|
+
* @since 4.0.0
|
|
3
35
|
*/
|
|
36
|
+
import * as Context from "effect/Context";
|
|
4
37
|
import * as Data from "effect/Data";
|
|
5
38
|
import * as Effect from "effect/Effect";
|
|
6
39
|
import * as Layer from "effect/Layer";
|
|
7
|
-
import * as ServiceMap from "effect/ServiceMap";
|
|
8
40
|
const TypeId = "~@effect/platform-browser/Clipboard";
|
|
9
41
|
const ErrorTypeId = "~@effect/platform-browser/Clipboard/ClipboardError";
|
|
10
42
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
43
|
+
* Tagged error raised when a browser clipboard operation fails.
|
|
44
|
+
*
|
|
45
|
+
* @category errors
|
|
46
|
+
* @since 4.0.0
|
|
13
47
|
*/
|
|
14
48
|
export class ClipboardError extends /*#__PURE__*/Data.TaggedError("ClipboardError") {
|
|
15
49
|
[ErrorTypeId] = ErrorTypeId;
|
|
16
50
|
}
|
|
17
51
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
52
|
+
* Service tag for the browser `Clipboard` service.
|
|
53
|
+
*
|
|
54
|
+
* **When to use**
|
|
55
|
+
*
|
|
56
|
+
* Use when an Effect needs to require or provide clipboard capabilities through
|
|
57
|
+
* the context.
|
|
58
|
+
*
|
|
59
|
+
* @see {@link make} for building a custom clipboard service
|
|
60
|
+
* @see {@link layer} for providing the browser-backed clipboard service
|
|
61
|
+
*
|
|
62
|
+
* @category services
|
|
63
|
+
* @since 4.0.0
|
|
20
64
|
*/
|
|
21
|
-
export const Clipboard = /*#__PURE__*/
|
|
65
|
+
export const Clipboard = /*#__PURE__*/Context.Service(TypeId);
|
|
22
66
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
67
|
+
* Builds a `Clipboard` service from primitive read and write operations, deriving `clear` and `writeBlob` helpers.
|
|
68
|
+
*
|
|
69
|
+
* @category constructors
|
|
70
|
+
* @since 4.0.0
|
|
25
71
|
*/
|
|
26
72
|
export const make = impl => Clipboard.of({
|
|
27
73
|
...impl,
|
|
@@ -34,8 +80,8 @@ export const make = impl => Clipboard.of({
|
|
|
34
80
|
/**
|
|
35
81
|
* A layer that directly interfaces with the navigator.clipboard api
|
|
36
82
|
*
|
|
37
|
-
* @
|
|
38
|
-
* @
|
|
83
|
+
* @category layers
|
|
84
|
+
* @since 4.0.0
|
|
39
85
|
*/
|
|
40
86
|
export const layer = /*#__PURE__*/Layer.succeed(Clipboard, /*#__PURE__*/make({
|
|
41
87
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,OAAO,KAAKA,OA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AGC,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,70 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Browser geolocation integration for Effect programs.
|
|
3
|
+
*
|
|
4
|
+
* This module exposes a `Geolocation` service backed by
|
|
5
|
+
* `navigator.geolocation`. Use it for browser features that need a single
|
|
6
|
+
* position fix, such as nearby search or delivery estimates, or a stream of
|
|
7
|
+
* position updates for navigation, tracking, and location-aware interfaces.
|
|
8
|
+
* Browser failures are represented as typed `GeolocationError` values instead
|
|
9
|
+
* of raw callback errors.
|
|
10
|
+
*
|
|
11
|
+
* **Mental model**
|
|
12
|
+
*
|
|
13
|
+
* - The service delegates to the browser Geolocation API and follows the
|
|
14
|
+
* browser's permission, privacy, origin, and secure-context rules.
|
|
15
|
+
* - `getCurrentPosition` reads one position fix from the service.
|
|
16
|
+
* - {@link watchPosition} turns browser position callbacks into a `Stream` and
|
|
17
|
+
* clears the underlying browser watch when the stream is finalized.
|
|
18
|
+
*
|
|
19
|
+
* **Common tasks**
|
|
20
|
+
*
|
|
21
|
+
* - Provide the live browser implementation with {@link layer}.
|
|
22
|
+
* - Read a one-shot position from the `Geolocation` service.
|
|
23
|
+
* - Stream position updates with {@link watchPosition}.
|
|
24
|
+
* - Handle denied permissions, timeouts, and unavailable position data with
|
|
25
|
+
* {@link GeolocationError}.
|
|
26
|
+
*
|
|
27
|
+
* **Gotchas**
|
|
28
|
+
*
|
|
29
|
+
* - Browsers may prompt the user, reject access outside secure contexts, block
|
|
30
|
+
* access by permissions policy, or report that position data is unavailable.
|
|
31
|
+
* - {@link watchPosition} uses a sliding buffer; increase `bufferSize` if slow
|
|
32
|
+
* consumers must not skip older positions.
|
|
33
|
+
*
|
|
34
|
+
* @since 4.0.0
|
|
3
35
|
*/
|
|
4
36
|
import * as Cause from "effect/Cause";
|
|
37
|
+
import * as Context from "effect/Context";
|
|
5
38
|
import * as Effect from "effect/Effect";
|
|
6
39
|
import * as Layer from "effect/Layer";
|
|
7
|
-
import * as ServiceMap from "effect/ServiceMap";
|
|
8
40
|
import * as Stream from "effect/Stream";
|
|
9
41
|
declare const TypeId = "~@effect/platform-browser/Geolocation";
|
|
10
42
|
declare const ErrorTypeId = "~@effect/platform-browser/Geolocation/GeolocationError";
|
|
11
43
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
44
|
+
* Service interface for browser geolocation, providing effects for the current position and streams of watched positions.
|
|
45
|
+
*
|
|
46
|
+
* **When to use**
|
|
47
|
+
*
|
|
48
|
+
* Use when browser code needs a typed Effect service for one-shot location
|
|
49
|
+
* reads or streamed location updates.
|
|
50
|
+
*
|
|
51
|
+
* **Details**
|
|
52
|
+
*
|
|
53
|
+
* `getCurrentPosition` returns one position effect. `watchPosition` returns a
|
|
54
|
+
* stream and accepts the browser `PositionOptions` plus an optional sliding
|
|
55
|
+
* `bufferSize`.
|
|
56
|
+
*
|
|
57
|
+
* **Gotchas**
|
|
58
|
+
*
|
|
59
|
+
* Browser permission prompts, denied permissions, timeouts, unavailable
|
|
60
|
+
* position data, secure-context restrictions, and policy restrictions are
|
|
61
|
+
* surfaced as `GeolocationError`.
|
|
62
|
+
*
|
|
63
|
+
* @see {@link GeolocationError} for represented browser geolocation failures
|
|
64
|
+
* @see {@link layer} for the browser-backed service implementation
|
|
65
|
+
*
|
|
66
|
+
* @category models
|
|
67
|
+
* @since 4.0.0
|
|
14
68
|
*/
|
|
15
69
|
export interface Geolocation {
|
|
16
70
|
readonly [TypeId]: typeof TypeId;
|
|
@@ -20,16 +74,27 @@ export interface Geolocation {
|
|
|
20
74
|
} | undefined) => Stream.Stream<GeolocationPosition, GeolocationError>;
|
|
21
75
|
}
|
|
22
76
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
77
|
+
* Service tag for the browser `Geolocation` service.
|
|
78
|
+
*
|
|
79
|
+
* **When to use**
|
|
80
|
+
*
|
|
81
|
+
* Use when an Effect needs to access or provide geolocation capabilities
|
|
82
|
+
* through the context.
|
|
83
|
+
*
|
|
84
|
+
* @see {@link layer} for providing the browser-backed geolocation service
|
|
85
|
+
*
|
|
86
|
+
* @category services
|
|
87
|
+
* @since 4.0.0
|
|
25
88
|
*/
|
|
26
|
-
export declare const Geolocation:
|
|
27
|
-
declare const GeolocationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
89
|
+
export declare const Geolocation: Context.Service<Geolocation, Geolocation>;
|
|
90
|
+
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
91
|
readonly _tag: "GeolocationError";
|
|
29
92
|
} & Readonly<A>;
|
|
30
93
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
94
|
+
* Tagged error wrapping a browser geolocation failure reason.
|
|
95
|
+
*
|
|
96
|
+
* @category errors
|
|
97
|
+
* @since 4.0.0
|
|
33
98
|
*/
|
|
34
99
|
export declare class GeolocationError extends GeolocationError_base<{
|
|
35
100
|
readonly reason: GeolocationErrorReason;
|
|
@@ -40,36 +105,42 @@ export declare class GeolocationError extends GeolocationError_base<{
|
|
|
40
105
|
readonly [ErrorTypeId] = "~@effect/platform-browser/Geolocation/GeolocationError";
|
|
41
106
|
get message(): string;
|
|
42
107
|
}
|
|
43
|
-
declare const PositionUnavailable_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
108
|
+
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
109
|
readonly _tag: "PositionUnavailable";
|
|
45
110
|
} & Readonly<A>;
|
|
46
111
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
112
|
+
* Error reason for the browser geolocation `POSITION_UNAVAILABLE` failure.
|
|
113
|
+
*
|
|
114
|
+
* @category errors
|
|
115
|
+
* @since 4.0.0
|
|
49
116
|
*/
|
|
50
117
|
export declare class PositionUnavailable extends PositionUnavailable_base<{
|
|
51
118
|
readonly cause: unknown;
|
|
52
119
|
}> {
|
|
53
120
|
get message(): string;
|
|
54
121
|
}
|
|
55
|
-
declare const PermissionDenied_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
122
|
+
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
123
|
readonly _tag: "PermissionDenied";
|
|
57
124
|
} & Readonly<A>;
|
|
58
125
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
126
|
+
* Error reason for the browser geolocation `PERMISSION_DENIED` failure.
|
|
127
|
+
*
|
|
128
|
+
* @category errors
|
|
129
|
+
* @since 4.0.0
|
|
61
130
|
*/
|
|
62
131
|
export declare class PermissionDenied extends PermissionDenied_base<{
|
|
63
132
|
readonly cause: unknown;
|
|
64
133
|
}> {
|
|
65
134
|
get message(): string;
|
|
66
135
|
}
|
|
67
|
-
declare const Timeout_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
136
|
+
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
137
|
readonly _tag: "Timeout";
|
|
69
138
|
} & Readonly<A>;
|
|
70
139
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
140
|
+
* Error reason for the browser geolocation `TIMEOUT` failure.
|
|
141
|
+
*
|
|
142
|
+
* @category errors
|
|
143
|
+
* @since 4.0.0
|
|
73
144
|
*/
|
|
74
145
|
export declare class Timeout extends Timeout_base<{
|
|
75
146
|
readonly cause: unknown;
|
|
@@ -77,18 +148,24 @@ export declare class Timeout extends Timeout_base<{
|
|
|
77
148
|
get message(): string;
|
|
78
149
|
}
|
|
79
150
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
151
|
+
* Union of browser geolocation error reasons represented by the service.
|
|
152
|
+
*
|
|
153
|
+
* @category errors
|
|
154
|
+
* @since 4.0.0
|
|
82
155
|
*/
|
|
83
156
|
export type GeolocationErrorReason = PositionUnavailable | PermissionDenied | Timeout;
|
|
84
157
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
158
|
+
* Layer that provides `Geolocation` using `navigator.geolocation`, with watched positions buffered in a sliding queue.
|
|
159
|
+
*
|
|
160
|
+
* @category layers
|
|
161
|
+
* @since 4.0.0
|
|
87
162
|
*/
|
|
88
163
|
export declare const layer: Layer.Layer<Geolocation>;
|
|
89
164
|
/**
|
|
90
|
-
*
|
|
165
|
+
* Streams positions from the `Geolocation` service using `watchPosition`, with an optional sliding buffer size.
|
|
166
|
+
*
|
|
91
167
|
* @category Accessors
|
|
168
|
+
* @since 4.0.0
|
|
92
169
|
*/
|
|
93
170
|
export declare const watchPosition: (options?: (PositionOptions & {
|
|
94
171
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;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;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;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;CAC1D;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,WAAW,CAAwC,CAAA;;;;AAE1G;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,sBAAqC;IACzE,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAA;CACxC,C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