@livestore/utils 0.4.0-dev.2 → 0.4.0-dev.20
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/.tsbuildinfo.json +1 -1
- package/dist/NoopTracer.d.ts.map +1 -1
- package/dist/NoopTracer.js +1 -0
- package/dist/NoopTracer.js.map +1 -1
- package/dist/browser/Opfs/Opfs.d.ts +51 -0
- package/dist/browser/Opfs/Opfs.d.ts.map +1 -0
- package/dist/browser/Opfs/Opfs.js +345 -0
- package/dist/browser/Opfs/Opfs.js.map +1 -0
- package/dist/browser/Opfs/debug-utils.d.ts +20 -0
- package/dist/browser/Opfs/debug-utils.d.ts.map +1 -0
- package/dist/browser/Opfs/debug-utils.js +94 -0
- package/dist/browser/Opfs/debug-utils.js.map +1 -0
- package/dist/browser/Opfs/mod.d.ts +4 -0
- package/dist/browser/Opfs/mod.d.ts.map +1 -0
- package/dist/browser/Opfs/mod.js +4 -0
- package/dist/browser/Opfs/mod.js.map +1 -0
- package/dist/browser/Opfs/utils.d.ts +68 -0
- package/dist/browser/Opfs/utils.d.ts.map +1 -0
- package/dist/browser/Opfs/utils.js +206 -0
- package/dist/browser/Opfs/utils.js.map +1 -0
- package/dist/browser/QuotaExceededError.d.ts +59 -0
- package/dist/browser/QuotaExceededError.d.ts.map +1 -0
- package/dist/browser/QuotaExceededError.js +2 -0
- package/dist/browser/QuotaExceededError.js.map +1 -0
- package/dist/browser/WebChannelBrowser.d.ts +22 -0
- package/dist/browser/WebChannelBrowser.d.ts.map +1 -0
- package/dist/browser/WebChannelBrowser.js +76 -0
- package/dist/browser/WebChannelBrowser.js.map +1 -0
- package/dist/browser/WebError.d.ts +425 -0
- package/dist/browser/WebError.d.ts.map +1 -0
- package/dist/browser/WebError.js +414 -0
- package/dist/browser/WebError.js.map +1 -0
- package/dist/browser/WebError.test.d.ts +2 -0
- package/dist/browser/WebError.test.d.ts.map +1 -0
- package/dist/browser/WebError.test.js +46 -0
- package/dist/browser/WebError.test.js.map +1 -0
- package/dist/browser/WebLock.d.ts.map +1 -0
- package/dist/browser/WebLock.js.map +1 -0
- package/dist/{browser.d.ts → browser/detect.d.ts} +1 -1
- package/dist/browser/detect.d.ts.map +1 -0
- package/dist/{browser.js → browser/detect.js} +1 -1
- package/dist/browser/detect.js.map +1 -0
- package/dist/browser/mod.d.ts +8 -0
- package/dist/browser/mod.d.ts.map +1 -0
- package/dist/browser/mod.js +8 -0
- package/dist/browser/mod.js.map +1 -0
- package/dist/effect/Debug.d.ts +38 -0
- package/dist/effect/Debug.d.ts.map +1 -0
- package/dist/effect/Debug.js +287 -0
- package/dist/effect/Debug.js.map +1 -0
- package/dist/effect/Effect.d.ts +9 -3
- package/dist/effect/Effect.d.ts.map +1 -1
- package/dist/effect/Effect.js +4 -2
- package/dist/effect/Effect.js.map +1 -1
- package/dist/effect/Error.d.ts +1 -1
- package/dist/effect/Error.js.map +1 -1
- package/dist/effect/Logger.d.ts +4 -1
- package/dist/effect/Logger.d.ts.map +1 -1
- package/dist/effect/Logger.js +12 -3
- package/dist/effect/Logger.js.map +1 -1
- package/dist/effect/OtelTracer.d.ts +5 -0
- package/dist/effect/OtelTracer.d.ts.map +1 -0
- package/dist/effect/OtelTracer.js +8 -0
- package/dist/effect/OtelTracer.js.map +1 -0
- package/dist/effect/RpcClient.d.ts +32 -0
- package/dist/effect/RpcClient.d.ts.map +1 -0
- package/dist/effect/RpcClient.js +149 -0
- package/dist/effect/RpcClient.js.map +1 -0
- package/dist/effect/Schema/index.d.ts +2 -2
- package/dist/effect/Schema/index.d.ts.map +1 -1
- package/dist/effect/Schema/index.js +12 -2
- package/dist/effect/Schema/index.js.map +1 -1
- package/dist/effect/Stream.d.ts +73 -2
- package/dist/effect/Stream.d.ts.map +1 -1
- package/dist/effect/Stream.js +68 -1
- package/dist/effect/Stream.js.map +1 -1
- package/dist/effect/Stream.test.d.ts +2 -0
- package/dist/effect/Stream.test.d.ts.map +1 -0
- package/dist/effect/Stream.test.js +84 -0
- package/dist/effect/Stream.test.js.map +1 -0
- package/dist/effect/SubscriptionRef.d.ts +2 -2
- package/dist/effect/SubscriptionRef.d.ts.map +1 -1
- package/dist/effect/SubscriptionRef.js +6 -1
- package/dist/effect/SubscriptionRef.js.map +1 -1
- package/dist/effect/WebChannel/WebChannel.d.ts +2 -21
- package/dist/effect/WebChannel/WebChannel.d.ts.map +1 -1
- package/dist/effect/WebChannel/WebChannel.js +5 -81
- package/dist/effect/WebChannel/WebChannel.js.map +1 -1
- package/dist/effect/WebChannel/WebChannel.test.js +1 -1
- package/dist/effect/WebChannel/WebChannel.test.js.map +1 -1
- package/dist/effect/WebChannel/common.d.ts +1 -1
- package/dist/effect/WebChannel/common.d.ts.map +1 -1
- package/dist/effect/WebSocket.d.ts.map +1 -1
- package/dist/effect/WebSocket.js +12 -12
- package/dist/effect/WebSocket.js.map +1 -1
- package/dist/effect/mod.d.ts +32 -0
- package/dist/effect/mod.d.ts.map +1 -0
- package/dist/effect/mod.js +35 -0
- package/dist/effect/mod.js.map +1 -0
- package/dist/global.d.ts +1 -0
- package/dist/global.d.ts.map +1 -1
- package/dist/global.js.map +1 -1
- package/dist/misc.js +1 -1
- package/dist/misc.js.map +1 -1
- package/dist/mod.d.ts +3 -1
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +5 -1
- package/dist/mod.js.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessRunner.d.ts.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessRunner.js +66 -10
- package/dist/node/ChildProcessRunner/ChildProcessRunner.js.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessRunnerTest/ChildProcessRunner.test.js +177 -3
- package/dist/node/ChildProcessRunner/ChildProcessRunnerTest/ChildProcessRunner.test.js.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessRunnerTest/schema.d.ts +14 -5
- package/dist/node/ChildProcessRunner/ChildProcessRunnerTest/schema.d.ts.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessRunnerTest/schema.js +7 -1
- package/dist/node/ChildProcessRunner/ChildProcessRunnerTest/schema.js.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessRunnerTest/serializedWorker.js +13 -3
- package/dist/node/ChildProcessRunner/ChildProcessRunnerTest/serializedWorker.js.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessWorker.d.ts +16 -0
- package/dist/node/ChildProcessRunner/ChildProcessWorker.d.ts.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessWorker.js +98 -2
- package/dist/node/ChildProcessRunner/ChildProcessWorker.js.map +1 -1
- package/dist/node/mod.d.ts +8 -2
- package/dist/node/mod.d.ts.map +1 -1
- package/dist/node/mod.js +11 -3
- package/dist/node/mod.js.map +1 -1
- package/dist/qr.d.ts +38 -0
- package/dist/qr.d.ts.map +1 -0
- package/dist/qr.js +109 -0
- package/dist/qr.js.map +1 -0
- package/package.json +54 -44
- package/src/NoopTracer.ts +1 -0
- package/src/browser/Opfs/Opfs.ts +428 -0
- package/src/browser/Opfs/debug-utils.ts +151 -0
- package/src/browser/Opfs/mod.ts +3 -0
- package/src/browser/Opfs/utils.ts +270 -0
- package/src/browser/QuotaExceededError.ts +59 -0
- package/src/browser/WebChannelBrowser.ts +131 -0
- package/src/browser/WebError.test.ts +66 -0
- package/src/browser/WebError.ts +599 -0
- package/src/browser/mod.ts +8 -0
- package/src/effect/Debug.ts +375 -0
- package/src/effect/Effect.ts +31 -4
- package/src/effect/Error.ts +1 -1
- package/src/effect/Logger.ts +14 -4
- package/src/effect/OtelTracer.ts +11 -0
- package/src/effect/RpcClient.ts +212 -0
- package/src/effect/Schema/index.ts +17 -3
- package/src/effect/Stream.test.ts +127 -0
- package/src/effect/Stream.ts +111 -2
- package/src/effect/SubscriptionRef.ts +14 -2
- package/src/effect/WebChannel/WebChannel.test.ts +1 -1
- package/src/effect/WebChannel/WebChannel.ts +13 -135
- package/src/effect/WebChannel/common.ts +1 -1
- package/src/effect/WebSocket.ts +11 -10
- package/src/effect/{index.ts → mod.ts} +42 -15
- package/src/global.ts +1 -0
- package/src/misc.ts +1 -1
- package/src/mod.ts +10 -1
- package/src/node/ChildProcessRunner/ChildProcessRunner.ts +71 -10
- package/src/node/ChildProcessRunner/ChildProcessRunnerTest/ChildProcessRunner.test.ts +258 -3
- package/src/node/ChildProcessRunner/ChildProcessRunnerTest/schema.ts +14 -1
- package/src/node/ChildProcessRunner/ChildProcessRunnerTest/serializedWorker.ts +16 -3
- package/src/node/ChildProcessRunner/ChildProcessWorker.ts +111 -3
- package/src/node/mod.ts +13 -6
- package/src/qr.ts +125 -0
- package/dist/browser.d.ts.map +0 -1
- package/dist/browser.js.map +0 -1
- package/dist/effect/Schema/msgpack.d.ts +0 -3
- package/dist/effect/Schema/msgpack.d.ts.map +0 -1
- package/dist/effect/Schema/msgpack.js +0 -7
- package/dist/effect/Schema/msgpack.js.map +0 -1
- package/dist/effect/WebLock.d.ts.map +0 -1
- package/dist/effect/WebLock.js.map +0 -1
- package/dist/effect/index.d.ts +0 -27
- package/dist/effect/index.d.ts.map +0 -1
- package/dist/effect/index.js +0 -31
- package/dist/effect/index.js.map +0 -1
- package/src/effect/Schema/msgpack.ts +0 -8
- /package/dist/{effect → browser}/WebLock.d.ts +0 -0
- /package/dist/{effect → browser}/WebLock.js +0 -0
- /package/src/{effect → browser}/WebLock.ts +0 -0
- /package/src/{browser.ts → browser/detect.ts} +0 -0
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import "./QuotaExceededError.js";
|
|
2
|
+
import { Either, ParseResult, Predicate, Schema } from 'effect';
|
|
3
|
+
/**
|
|
4
|
+
* Unique identifier for web errors.
|
|
5
|
+
*/
|
|
6
|
+
export const TypeId = '@livestore/utils/WebError';
|
|
7
|
+
/**
|
|
8
|
+
* Type guard to check if a value is a web error.
|
|
9
|
+
*
|
|
10
|
+
* @param u - The value to check
|
|
11
|
+
* @returns `true` if the value is an `WebError`, `false` otherwise
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { WebError } from "@livestore/utils/effect"
|
|
16
|
+
*
|
|
17
|
+
* const someError = new Error("generic error")
|
|
18
|
+
* const webError = new WebError.UnknownError({
|
|
19
|
+
* module: "Test",
|
|
20
|
+
* method: "example"
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* console.log(WebError.isWebError(someError)) // false
|
|
24
|
+
* console.log(WebError.isWebError(webError)) // true
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export const isWebError = (u) => Predicate.hasProperty(u, TypeId);
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// Simple Exception Errors
|
|
30
|
+
// ============================================================================
|
|
31
|
+
//
|
|
32
|
+
// [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#standard_error_types)
|
|
33
|
+
// [Specification](https://webidl.spec.whatwg.org/#dfn-simple-exception)
|
|
34
|
+
/**
|
|
35
|
+
* Error for the web standard "EvalError" simple exception.
|
|
36
|
+
*
|
|
37
|
+
* Thrown when the `eval` function is used in a way that violates its usage restrictions.
|
|
38
|
+
*
|
|
39
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Evalerror | MDN Reference}
|
|
40
|
+
* @see {@link https://webidl.spec.whatwg.org/#exceptiondef-evalerror | Specification}
|
|
41
|
+
*/
|
|
42
|
+
export class EvalError extends Schema.TaggedError()('@livestore/utils/Web/EvalError', {
|
|
43
|
+
cause: Schema.instanceOf(globalThis.EvalError),
|
|
44
|
+
}) {
|
|
45
|
+
[TypeId] = TypeId;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Error for the web standard "RangeError" simple exception.
|
|
49
|
+
*
|
|
50
|
+
* Indicates that a numeric value is outside the permitted range.
|
|
51
|
+
*
|
|
52
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Rangeerror | MDN Reference}
|
|
53
|
+
* @see {@link https://webidl.spec.whatwg.org/#exceptiondef-rangeerror | Specification}
|
|
54
|
+
*/
|
|
55
|
+
export class RangeError extends Schema.TaggedError()('@livestore/utils/Web/RangeError', {
|
|
56
|
+
cause: Schema.instanceOf(globalThis.RangeError),
|
|
57
|
+
}) {
|
|
58
|
+
[TypeId] = TypeId;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Error for the web standard "ReferenceError" simple exception.
|
|
62
|
+
*
|
|
63
|
+
* Raised when code references an identifier that has not been defined.
|
|
64
|
+
*
|
|
65
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Referenceerror | MDN Reference}
|
|
66
|
+
* @see {@link https://webidl.spec.whatwg.org/#exceptiondef-referenceerror | Specification}
|
|
67
|
+
*/
|
|
68
|
+
export class ReferenceError extends Schema.TaggedError()('@livestore/utils/Web/ReferenceError', {
|
|
69
|
+
cause: Schema.instanceOf(globalThis.ReferenceError),
|
|
70
|
+
}) {
|
|
71
|
+
[TypeId] = TypeId;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Error for the web standard "TypeError" simple exception.
|
|
75
|
+
*
|
|
76
|
+
* Occurs when an operation is applied to a value of an inappropriate type.
|
|
77
|
+
*
|
|
78
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Typeerror | MDN Reference}
|
|
79
|
+
* @see {@link https://webidl.spec.whatwg.org/#exceptiondef-typeerror | Specification}
|
|
80
|
+
*/
|
|
81
|
+
export class TypeError extends Schema.TaggedError()('@livestore/utils/Web/TypeError', {
|
|
82
|
+
cause: Schema.instanceOf(globalThis.TypeError),
|
|
83
|
+
}) {
|
|
84
|
+
[TypeId] = TypeId;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Error for the web standard "URIError" simple exception.
|
|
88
|
+
*
|
|
89
|
+
* Signals incorrect usage of global URI handling functions such as `decodeURI` or `encodeURI`.
|
|
90
|
+
*
|
|
91
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIerror | MDN Reference}
|
|
92
|
+
* @see {@link https://webidl.spec.whatwg.org/#exceptiondef-urierror | Specification}
|
|
93
|
+
*/
|
|
94
|
+
export class URIError extends Schema.TaggedError()('@livestore/utils/Web/URIError', {
|
|
95
|
+
cause: Schema.instanceOf(globalThis.URIError),
|
|
96
|
+
}) {
|
|
97
|
+
[TypeId] = TypeId;
|
|
98
|
+
}
|
|
99
|
+
// ============================================================================
|
|
100
|
+
// Predefined DOMException Errors
|
|
101
|
+
// ============================================================================
|
|
102
|
+
//
|
|
103
|
+
// [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/DOMException)
|
|
104
|
+
// [Specification](https://webidl.spec.whatwg.org/#idl-DOMException-derived-predefineds)
|
|
105
|
+
const domExceptionWithName = (expectedName) => Schema.instanceOf(DOMException).pipe(Schema.filter((a, options) => ParseResult.validateEither(Schema.Struct({
|
|
106
|
+
name: Schema.Literal(expectedName),
|
|
107
|
+
}))(a, options).pipe(Either.flip, Either.getOrUndefined)));
|
|
108
|
+
/**
|
|
109
|
+
* Error for the web standard "QuotaExceededError" DOMException-derived error.
|
|
110
|
+
*
|
|
111
|
+
* The quota has been exceeded.
|
|
112
|
+
*
|
|
113
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/QuotaExceededError | MDN Reference}
|
|
114
|
+
* @see {@link https://webidl.spec.whatwg.org/#quotaexceedederror | Specification}
|
|
115
|
+
*/
|
|
116
|
+
export class QuotaExceededError extends Schema.TaggedError()('@livestore/utils/Web/QuotaExceededError', {
|
|
117
|
+
cause: Schema.Union(typeof globalThis.QuotaExceededError === 'function'
|
|
118
|
+
? Schema.instanceOf(globalThis.QuotaExceededError)
|
|
119
|
+
: Schema.Never,
|
|
120
|
+
// Deprecated but still in use in some browsers
|
|
121
|
+
domExceptionWithName('QuotaExceededError')),
|
|
122
|
+
}) {
|
|
123
|
+
[TypeId] = TypeId;
|
|
124
|
+
get message() {
|
|
125
|
+
return this.cause.message;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// ============================================================================
|
|
129
|
+
// Base DOMException Errors
|
|
130
|
+
// ============================================================================
|
|
131
|
+
//
|
|
132
|
+
// [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/DOMException#error_names)
|
|
133
|
+
// [Specification](https://webidl.spec.whatwg.org/#idl-DOMException-error-names)
|
|
134
|
+
/**
|
|
135
|
+
* Error for the web standard "NoModificationAllowedError" DOMException.
|
|
136
|
+
*
|
|
137
|
+
* The object can not be modified.
|
|
138
|
+
*
|
|
139
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#nomodificationallowederror | MDN Reference}
|
|
140
|
+
* @see {@link https://webidl.spec.whatwg.org/#nomodificationallowederror | Specification}
|
|
141
|
+
*/
|
|
142
|
+
export class NoModificationAllowedError extends Schema.TaggedError()('@livestore/utils/Web/NoModificationAllowedError', {
|
|
143
|
+
cause: domExceptionWithName('NoModificationAllowedError'),
|
|
144
|
+
}) {
|
|
145
|
+
[TypeId] = TypeId;
|
|
146
|
+
get message() {
|
|
147
|
+
return this.cause.message;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Error for the web standard "NotFoundError" DOMException
|
|
152
|
+
*
|
|
153
|
+
* The object can not be found here.
|
|
154
|
+
*
|
|
155
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#notfounderror | MDN Reference}
|
|
156
|
+
* @see {@link https://webidl.spec.whatwg.org/#notfounderror | Specification}
|
|
157
|
+
*/
|
|
158
|
+
export class NotFoundError extends Schema.TaggedError()('@livestore/utils/Web/NotFoundError', {
|
|
159
|
+
cause: domExceptionWithName('NotFoundError'),
|
|
160
|
+
}) {
|
|
161
|
+
[TypeId] = TypeId;
|
|
162
|
+
get message() {
|
|
163
|
+
return this.cause.message;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Error for the web standard "NotAllowedError" DOMException
|
|
168
|
+
*
|
|
169
|
+
* The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
|
|
170
|
+
*
|
|
171
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#notallowederror | MDN Reference}
|
|
172
|
+
* @see {@link https://webidl.spec.whatwg.org/#notallowederror | Specification}
|
|
173
|
+
*/
|
|
174
|
+
export class NotAllowedError extends Schema.TaggedError()('@livestore/utils/Web/NotAllowedError', {
|
|
175
|
+
cause: domExceptionWithName('NotAllowedError'),
|
|
176
|
+
}) {
|
|
177
|
+
[TypeId] = TypeId;
|
|
178
|
+
get message() {
|
|
179
|
+
return this.cause.message;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Error for the web standard "TypeMismatchError" DOMException.
|
|
184
|
+
*
|
|
185
|
+
* The object can not be converted to the expected type.
|
|
186
|
+
*
|
|
187
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#typemismatcherror | MDN Reference}
|
|
188
|
+
* @see {@link https://webidl.spec.whatwg.org/#typemismatcherror | Specification}
|
|
189
|
+
*/
|
|
190
|
+
export class TypeMismatchError extends Schema.TaggedError()('@livestore/utils/Web/TypeMismatchError', {
|
|
191
|
+
cause: domExceptionWithName('TypeMismatchError'),
|
|
192
|
+
}) {
|
|
193
|
+
[TypeId] = TypeId;
|
|
194
|
+
get message() {
|
|
195
|
+
return this.cause.message;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Error for the web standard "InvalidStateError" DOMException.
|
|
200
|
+
*
|
|
201
|
+
* The object is in an invalid state.
|
|
202
|
+
*
|
|
203
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#invalidstateerror | MDN Reference}
|
|
204
|
+
* @see {@link https://webidl.spec.whatwg.org/#invalidstateerror | Specification}
|
|
205
|
+
*/
|
|
206
|
+
export class InvalidStateError extends Schema.TaggedError()('@livestore/utils/Web/InvalidStateError', {
|
|
207
|
+
cause: domExceptionWithName('InvalidStateError'),
|
|
208
|
+
}) {
|
|
209
|
+
[TypeId] = TypeId;
|
|
210
|
+
get message() {
|
|
211
|
+
return this.cause.message;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Error for the web standard "AbortError" DOMException.
|
|
216
|
+
*
|
|
217
|
+
* The operation was aborted.
|
|
218
|
+
*
|
|
219
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#aborterror | MDN Reference}
|
|
220
|
+
* @see {@link https://webidl.spec.whatwg.org/#aborterror | Specification}
|
|
221
|
+
*/
|
|
222
|
+
export class AbortError extends Schema.TaggedError()('@livestore/utils/Web/AbortError', {
|
|
223
|
+
cause: domExceptionWithName('AbortError'),
|
|
224
|
+
}) {
|
|
225
|
+
[TypeId] = TypeId;
|
|
226
|
+
get message() {
|
|
227
|
+
return this.cause.message;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Error for the web standard "InvalidModificationError" DOMException.
|
|
232
|
+
*
|
|
233
|
+
* The object can not be modified in this way.
|
|
234
|
+
*
|
|
235
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#invalidmodificationerror | MDN Reference}
|
|
236
|
+
* @see {@link https://webidl.spec.whatwg.org/#invalidmodificationerror | Specification}
|
|
237
|
+
*/
|
|
238
|
+
export class InvalidModificationError extends Schema.TaggedError()('@livestore/utils/Web/InvalidModificationError', {
|
|
239
|
+
cause: domExceptionWithName('InvalidModificationError'),
|
|
240
|
+
}) {
|
|
241
|
+
[TypeId] = TypeId;
|
|
242
|
+
get message() {
|
|
243
|
+
return this.cause.message;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Error for the web standard "SecurityError" DOMException.
|
|
248
|
+
*
|
|
249
|
+
* The operation is insecure.
|
|
250
|
+
*
|
|
251
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#securityerror | MDN Reference}
|
|
252
|
+
* @see {@link https://webidl.spec.whatwg.org/#securityerror | Specification}
|
|
253
|
+
*/
|
|
254
|
+
export class SecurityError extends Schema.TaggedError()('@livestore/utils/Web/SecurityError', {
|
|
255
|
+
cause: domExceptionWithName('SecurityError'),
|
|
256
|
+
}) {
|
|
257
|
+
[TypeId] = TypeId;
|
|
258
|
+
get message() {
|
|
259
|
+
return this.cause.message;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Error for the web standard "DataCloneError" DOMException.
|
|
264
|
+
*
|
|
265
|
+
* The object can not be cloned.
|
|
266
|
+
*
|
|
267
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#datacloneerror | MDN Reference}
|
|
268
|
+
* @see {@link https://webidl.spec.whatwg.org/#datacloneerror | Specification}
|
|
269
|
+
*/
|
|
270
|
+
export class DataCloneError extends Schema.TaggedError()('@livestore/utils/Web/DataCloneError', {
|
|
271
|
+
cause: domExceptionWithName('DataCloneError'),
|
|
272
|
+
}) {
|
|
273
|
+
[TypeId] = TypeId;
|
|
274
|
+
get message() {
|
|
275
|
+
return this.cause.message;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
// ============================================================================
|
|
279
|
+
// Custom Errors
|
|
280
|
+
// ============================================================================
|
|
281
|
+
/**
|
|
282
|
+
* Catch-all error for unexpected runtime errors in web environments.
|
|
283
|
+
*
|
|
284
|
+
* This error is used when an unexpected exception occurs that doesn't fit
|
|
285
|
+
* into the other specific error categories. It provides context about where
|
|
286
|
+
* the error occurred and preserves the original cause for debugging.
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```ts
|
|
290
|
+
* import { WebError } from "@livestore/utils/effect"
|
|
291
|
+
* import { Effect } from "effect"
|
|
292
|
+
*
|
|
293
|
+
* const riskyOperation = () => {
|
|
294
|
+
* try {
|
|
295
|
+
* // Some operation that might throw
|
|
296
|
+
* throw new Error("Unexpected runtime issue")
|
|
297
|
+
* } catch (cause) {
|
|
298
|
+
* return Effect.fail(new WebError.UnknownError({
|
|
299
|
+
* module: "JSON",
|
|
300
|
+
* method: "parse",
|
|
301
|
+
* description: "Could not parse string as JSON",
|
|
302
|
+
* cause
|
|
303
|
+
* }))
|
|
304
|
+
* }
|
|
305
|
+
* }
|
|
306
|
+
*
|
|
307
|
+
* const program = riskyOperation().pipe(
|
|
308
|
+
* Effect.catchTag("@livestore/utils/Web/UnknownError", (error) => {
|
|
309
|
+
* console.log(error.message)
|
|
310
|
+
* // "JSON.parse: Could not parse string as JSON"
|
|
311
|
+
* return Effect.succeed("JSON parsing not possible")
|
|
312
|
+
* })
|
|
313
|
+
* )
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
export class UnknownError extends Schema.TaggedError()('@livestore/utils/Web/UnknownError', {
|
|
317
|
+
module: Schema.optional(Schema.String),
|
|
318
|
+
method: Schema.optional(Schema.String),
|
|
319
|
+
description: Schema.optional(Schema.String),
|
|
320
|
+
cause: Schema.optional(Schema.Defect),
|
|
321
|
+
}) {
|
|
322
|
+
[TypeId] = TypeId;
|
|
323
|
+
get message() {
|
|
324
|
+
const messageEnd = Predicate.isUndefined(this.description) ? 'A web error occurred' : this.description;
|
|
325
|
+
const moduleMethod = Predicate.isString(this.module) && Predicate.isString(this.method) ? `${this.module}.${this.method}` : undefined;
|
|
326
|
+
return Predicate.isUndefined(moduleMethod) ? messageEnd : `${moduleMethod}: ${messageEnd}`;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Schema for validating and parsing web errors.
|
|
331
|
+
*
|
|
332
|
+
* This schema can be used to decode unknown values into properly typed web
|
|
333
|
+
* errors, ensuring type safety when handling errors from external sources or
|
|
334
|
+
* serialized data.
|
|
335
|
+
*/
|
|
336
|
+
export const WebError = Schema.Union(
|
|
337
|
+
// Simple Exception Errors
|
|
338
|
+
EvalError, RangeError, ReferenceError, TypeError, URIError,
|
|
339
|
+
// Predefined DOMException Errors
|
|
340
|
+
QuotaExceededError,
|
|
341
|
+
// Base DOMException Errors
|
|
342
|
+
NoModificationAllowedError, NotFoundError, NotAllowedError, TypeMismatchError, InvalidStateError, AbortError, InvalidModificationError, SecurityError, DataCloneError,
|
|
343
|
+
// Custom Errors
|
|
344
|
+
UnknownError);
|
|
345
|
+
/**
|
|
346
|
+
* Schema transform for converting unknown values to WebError instances.
|
|
347
|
+
*
|
|
348
|
+
* This transform handles various web error types and converts them to
|
|
349
|
+
* properly typed WebError instances while preserving the original cause.
|
|
350
|
+
*/
|
|
351
|
+
const WebErrorFromUnknown = Schema.transform(Schema.Unknown, WebError, {
|
|
352
|
+
strict: true,
|
|
353
|
+
decode: (value) => {
|
|
354
|
+
// Already a WebError
|
|
355
|
+
if (isWebError(value))
|
|
356
|
+
return value;
|
|
357
|
+
// Simple Exception Errors
|
|
358
|
+
if (value instanceof globalThis.EvalError)
|
|
359
|
+
return new EvalError({ cause: value });
|
|
360
|
+
if (value instanceof globalThis.RangeError)
|
|
361
|
+
return new RangeError({ cause: value });
|
|
362
|
+
if (value instanceof globalThis.ReferenceError)
|
|
363
|
+
return new ReferenceError({ cause: value });
|
|
364
|
+
if (value instanceof globalThis.TypeError)
|
|
365
|
+
return new TypeError({ cause: value });
|
|
366
|
+
if (value instanceof globalThis.URIError)
|
|
367
|
+
return new URIError({ cause: value });
|
|
368
|
+
// Predefined DOMException Errors
|
|
369
|
+
if (typeof globalThis.QuotaExceededError === 'function' && value instanceof globalThis.QuotaExceededError) {
|
|
370
|
+
return new QuotaExceededError({ cause: value });
|
|
371
|
+
}
|
|
372
|
+
// Base DOMException Errors
|
|
373
|
+
if (value instanceof DOMException) {
|
|
374
|
+
switch (value.name) {
|
|
375
|
+
case 'QuotaExceededError':
|
|
376
|
+
return new QuotaExceededError({ cause: value });
|
|
377
|
+
case 'NoModificationAllowedError':
|
|
378
|
+
return new NoModificationAllowedError({ cause: value });
|
|
379
|
+
case 'NotFoundError':
|
|
380
|
+
return new NotFoundError({ cause: value });
|
|
381
|
+
case 'NotAllowedError':
|
|
382
|
+
return new NotAllowedError({ cause: value });
|
|
383
|
+
case 'TypeMismatchError':
|
|
384
|
+
return new TypeMismatchError({ cause: value });
|
|
385
|
+
case 'InvalidStateError':
|
|
386
|
+
return new InvalidStateError({ cause: value });
|
|
387
|
+
case 'AbortError':
|
|
388
|
+
return new AbortError({ cause: value });
|
|
389
|
+
case 'InvalidModificationError':
|
|
390
|
+
return new InvalidModificationError({ cause: value });
|
|
391
|
+
case 'SecurityError':
|
|
392
|
+
return new SecurityError({ cause: value });
|
|
393
|
+
case 'DataCloneError':
|
|
394
|
+
return new DataCloneError({ cause: value });
|
|
395
|
+
default:
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (value instanceof Error)
|
|
400
|
+
return new UnknownError({ description: value.message, cause: value });
|
|
401
|
+
return new UnknownError({ cause: value });
|
|
402
|
+
},
|
|
403
|
+
encode: (webError) => webError,
|
|
404
|
+
});
|
|
405
|
+
export function parseWebError(value, expected = []) {
|
|
406
|
+
const parsed = Schema.decodeUnknownSync(WebErrorFromUnknown)(value);
|
|
407
|
+
if (expected.length === 0)
|
|
408
|
+
return parsed;
|
|
409
|
+
const expectedTags = new Set(expected.map((ErrorConstructor) => ErrorConstructor._tag));
|
|
410
|
+
if (expectedTags.has(parsed._tag))
|
|
411
|
+
return parsed;
|
|
412
|
+
return parsed instanceof UnknownError ? parsed : new UnknownError({ cause: parsed });
|
|
413
|
+
}
|
|
414
|
+
//# sourceMappingURL=WebError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebError.js","sourceRoot":"","sources":["../../src/browser/WebError.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA;AAChC,OAAO,EAAE,MAAM,EAAE,WAA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AAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;QAEjG,OAAO,IAAI,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;IAC3C,CAAC;IACD,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ;CAC/B,CAAC,CAAA;AA8CF,MAAM,UAAU,aAAa,CAAC,KAAc,EAAE,WAA2C,EAAE;IACzF,MAAM,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC,KAAK,CAAC,CAAA;IAEnE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAA;IAExC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAA;IACvF,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAA;IAEhD,OAAO,MAAM,YAAY,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;AACtF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebError.test.d.ts","sourceRoot":"","sources":["../../src/browser/WebError.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as Vitest from '@effect/vitest';
|
|
2
|
+
import * as WebError from "./WebError.js";
|
|
3
|
+
Vitest.describe('parseWebError', () => {
|
|
4
|
+
Vitest.it('returns a WebError instance unchanged when no expectations are provided', () => {
|
|
5
|
+
const domException = new DOMException('missing node', 'NotFoundError');
|
|
6
|
+
const webError = new WebError.NotFoundError({ cause: domException });
|
|
7
|
+
const result = WebError.parseWebError(webError);
|
|
8
|
+
Vitest.expect(result).toBeInstanceOf(WebError.NotFoundError);
|
|
9
|
+
Vitest.expect(result.cause).toBe(domException);
|
|
10
|
+
});
|
|
11
|
+
Vitest.it('maps native errors to the corresponding WebError when expected', () => {
|
|
12
|
+
const nativeError = new globalThis.TypeError('unsupported type');
|
|
13
|
+
const result = WebError.parseWebError(nativeError, [WebError.TypeError]);
|
|
14
|
+
Vitest.expect(result).toBeInstanceOf(WebError.TypeError);
|
|
15
|
+
Vitest.expect(result.cause).toBe(nativeError);
|
|
16
|
+
});
|
|
17
|
+
Vitest.it('wraps parsed errors that are not in the expected list in UnknownError', () => {
|
|
18
|
+
const nativeError = new globalThis.RangeError('value out of range');
|
|
19
|
+
const result = WebError.parseWebError(nativeError, [WebError.TypeError]);
|
|
20
|
+
Vitest.expect(result).toBeInstanceOf(WebError.UnknownError);
|
|
21
|
+
Vitest.expect(result.cause).toBeInstanceOf(WebError.RangeError);
|
|
22
|
+
});
|
|
23
|
+
Vitest.it('translates DOMException names into the matching WebError variant', () => {
|
|
24
|
+
const domException = new DOMException('permission denied', 'NotAllowedError');
|
|
25
|
+
const result = WebError.parseWebError(domException, [WebError.NotAllowedError]);
|
|
26
|
+
Vitest.expect(result).toBeInstanceOf(WebError.NotAllowedError);
|
|
27
|
+
Vitest.expect(result.cause).toBe(domException);
|
|
28
|
+
});
|
|
29
|
+
Vitest.it('produces UnknownError for non-error values with the default message', () => {
|
|
30
|
+
const value = { reason: 'unexpected' };
|
|
31
|
+
const result = WebError.parseWebError(value);
|
|
32
|
+
Vitest.expect(result).toBeInstanceOf(WebError.UnknownError);
|
|
33
|
+
Vitest.expect(result.cause).toBeDefined();
|
|
34
|
+
Vitest.expect(result.message).toBe('A web error occurred');
|
|
35
|
+
});
|
|
36
|
+
Vitest.it('returns UnknownError instances without altering their payload when expectations are provided', () => {
|
|
37
|
+
const existing = new WebError.UnknownError({ description: 'pre-parsed' });
|
|
38
|
+
const result = WebError.parseWebError(existing, [WebError.TypeError]);
|
|
39
|
+
Vitest.expect(result).toBeInstanceOf(WebError.UnknownError);
|
|
40
|
+
if (!(result instanceof WebError.UnknownError)) {
|
|
41
|
+
throw new Error('Expected an UnknownError instance');
|
|
42
|
+
}
|
|
43
|
+
Vitest.expect(result.description).toBe('pre-parsed');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=WebError.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebError.test.js","sourceRoot":"","sources":["../../src/browser/WebError.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAExC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IACpC,MAAM,CAAC,EAAE,CAAC,yEAAyE,EAAE,GAAG,EAAE;QACxF,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,cAAc,EAAE,eAAe,CAAC,CAAA;QACtE,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAA;QAEpE,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAE/C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;QAC5D,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QAC/E,MAAM,WAAW,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAA;QAEhE,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAA;QAExE,MAAM,CAAC,MAAM,CA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,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAChG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAElB,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC5B,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACf,IACE,KAAK,CAAC,IAAI,KAAK,EAAE;YACjB,CAAC,KAAK,CAAC,OAAO,KAAK,kCAAkC;gBACnD,KAAK,CAAC,OAAO,KAAK,yDAAyD,CAAC,EAC9E,CAAC;YACD,2EAA2E;YAC3E,sCAAsC;YACtC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAC5B,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,0DAA0D,EAAE,KAAK,CAAC,CAAA;YAChF,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../src/browser/detect.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;AAE1G,eAAO,MAAM,iBAAiB,EAAE,MAAM,eA6BrC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../../src/browser/detect.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAA0B,GAAG,EAAE;IAC3D,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;QACzB,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,MAAM,OAAO,GAAG,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAClD,MAAM,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAA;IACnE,MAAM,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAA;IACpE,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;IACzD,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;IAE7F,+BAA+B;IAE/B,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAA;IAChB,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,MAAM,CAAA;IACf,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import '../global.ts';
|
|
2
|
+
export { BrowserWorker, BrowserWorkerRunner } from '@effect/platform-browser';
|
|
3
|
+
export * as WebSocket from '../effect/WebSocket.ts';
|
|
4
|
+
export * as Opfs from './Opfs/mod.ts';
|
|
5
|
+
export * as WebChannelBrowser from './WebChannelBrowser.ts';
|
|
6
|
+
export * as WebError from './WebError.ts';
|
|
7
|
+
export * as WebLock from './WebLock.ts';
|
|
8
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/browser/mod.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC7E,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAA;AACnD,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAC3D,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "../global.js";
|
|
2
|
+
export { BrowserWorker, BrowserWorkerRunner } from '@effect/platform-browser';
|
|
3
|
+
export * as WebSocket from "../effect/WebSocket.js";
|
|
4
|
+
export * as Opfs from "./Opfs/mod.js";
|
|
5
|
+
export * as WebChannelBrowser from "./WebChannelBrowser.js";
|
|
6
|
+
export * as WebError from "./WebError.js";
|
|
7
|
+
export * as WebLock from "./WebLock.js";
|
|
8
|
+
//# sourceMappingURL=mod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/browser/mod.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC7E,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAA;AACnD,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAC3D,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type * as Domain from '@effect/experimental/DevTools/Domain';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import * as Graph from 'effect/Graph';
|
|
4
|
+
import * as Layer from 'effect/Layer';
|
|
5
|
+
interface SpanNodeInfo {
|
|
6
|
+
readonly span: Domain.ParentSpan;
|
|
7
|
+
readonly events: readonly Domain.SpanEvent[];
|
|
8
|
+
}
|
|
9
|
+
export type SpanNodeGraph = Graph.Graph<SpanNodeInfo, any>;
|
|
10
|
+
declare const DebugInfo_base: Effect.Service.Class<DebugInfo, "@mattiamanzati/debug/DebugInfo", {
|
|
11
|
+
readonly effect: Effect.Effect<{
|
|
12
|
+
mutableGraph: Graph.MutableGraph<SpanNodeInfo, any, "directed">;
|
|
13
|
+
nodeIdBySpanId: Map<string, number>;
|
|
14
|
+
}, never, never>;
|
|
15
|
+
}>;
|
|
16
|
+
declare class DebugInfo extends DebugInfo_base {
|
|
17
|
+
}
|
|
18
|
+
export declare const layerDebug: Layer.Layer<DebugInfo, never, never>;
|
|
19
|
+
export interface LogTreeOptions {
|
|
20
|
+
readonly regex?: RegExp;
|
|
21
|
+
readonly title?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const logTree: (options?: LogTreeOptions) => Effect.Effect<void, never, never>;
|
|
24
|
+
export interface LogPerformanceTraceOptions {
|
|
25
|
+
readonly regex?: RegExp;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Logs the span tree in Chrome Performance Trace Event Format.
|
|
29
|
+
* The output can be loaded in Chrome DevTools Performance tab or chrome://tracing
|
|
30
|
+
*
|
|
31
|
+
* @see https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
|
|
32
|
+
*/
|
|
33
|
+
export declare const logPerformanceTrace: (options?: LogPerformanceTraceOptions) => Effect.Effect<void, never, never>;
|
|
34
|
+
export declare const logScopeState: ({ label }: {
|
|
35
|
+
label: string;
|
|
36
|
+
}) => Effect.Effect<void, never, import("effect/Scope").Scope>;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=Debug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Debug.d.ts","sourceRoot":"","sources":["../../src/effect/Debug.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,MAAM,sCAAsC,CAAA;AAGnE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAGrC,UAAU,YAAY;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAA;IAChC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,CAAC,SAAS,EAAE,CAAA;CAC7C;AAED,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,GAAG,CAAC,CAAA;;;;;;;AAE1D,cAAM,SAAU,SAAQ,cAKtB;CAAG;AA2DL,eAAO,MAAM,UAAU,sCAMtB,CAAA;AAgLD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,eAAO,MAAM,OAAO,GAAI,UAAS,cAAmB,sCAiDhD,CAAA;AAEJ,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,UAAS,0BAA+B,sCAoCxE,CAAA;AAEJ,eAAO,MAAM,aAAa,GAAI,WAAW;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,6DAOtD,CAAA"}
|