@dxos/effect 0.8.4-main.fd6878d → 0.8.4-staging.ac66bdf99f
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/lib/browser/chunk-CGS2ULMK.mjs +11 -0
- package/dist/lib/browser/chunk-CGS2ULMK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +515 -238
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing.mjs +39 -0
- package/dist/lib/browser/testing.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +515 -238
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing.mjs +39 -0
- package/dist/lib/node-esm/testing.mjs.map +7 -0
- package/dist/types/src/Performance.d.ts +25 -0
- package/dist/types/src/Performance.d.ts.map +1 -0
- package/dist/types/src/RuntimeProvider.d.ts +21 -0
- package/dist/types/src/RuntimeProvider.d.ts.map +1 -0
- package/dist/types/src/ast.d.ts +36 -22
- package/dist/types/src/ast.d.ts.map +1 -1
- package/dist/types/src/async-task-tagging.d.ts +6 -0
- package/dist/types/src/async-task-tagging.d.ts.map +1 -0
- package/dist/types/src/atom-kvs.d.ts +19 -0
- package/dist/types/src/atom-kvs.d.ts.map +1 -0
- package/dist/types/src/context.d.ts +2 -1
- package/dist/types/src/context.d.ts.map +1 -1
- package/dist/types/src/dynamic-runtime.d.ts +56 -0
- package/dist/types/src/dynamic-runtime.d.ts.map +1 -0
- package/dist/types/src/dynamic-runtime.test.d.ts +2 -0
- package/dist/types/src/dynamic-runtime.test.d.ts.map +1 -0
- package/dist/types/src/errors.d.ts +43 -1
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +7 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/interrupt.test.d.ts +2 -0
- package/dist/types/src/interrupt.test.d.ts.map +1 -0
- package/dist/types/src/{jsonPath.d.ts → json-path.d.ts} +12 -4
- package/dist/types/src/json-path.d.ts.map +1 -0
- package/dist/types/src/json-path.test.d.ts +2 -0
- package/dist/types/src/json-path.test.d.ts.map +1 -0
- package/dist/types/src/otel.d.ts +17 -0
- package/dist/types/src/otel.d.ts.map +1 -0
- package/dist/types/src/otel.test.d.ts +2 -0
- package/dist/types/src/otel.test.d.ts.map +1 -0
- package/dist/types/src/resource.d.ts +6 -2
- package/dist/types/src/resource.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +28 -4
- package/dist/types/src/testing.d.ts.map +1 -1
- package/dist/types/src/url.d.ts +3 -1
- package/dist/types/src/url.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -10
- package/src/Performance.ts +45 -0
- package/src/RuntimeProvider.ts +35 -0
- package/src/ast.test.ts +37 -9
- package/src/ast.ts +135 -96
- package/src/async-task-tagging.ts +47 -0
- package/src/atom-kvs.ts +35 -0
- package/src/context.ts +2 -1
- package/src/dynamic-runtime.test.ts +465 -0
- package/src/dynamic-runtime.ts +195 -0
- package/src/errors.test.ts +1 -1
- package/src/errors.ts +142 -28
- package/src/index.ts +7 -3
- package/src/interrupt.test.ts +35 -0
- package/src/{jsonPath.test.ts → json-path.test.ts} +47 -8
- package/src/{jsonPath.ts → json-path.ts} +29 -4
- package/src/layers.test.ts +10 -4
- package/src/otel.test.ts +126 -0
- package/src/otel.ts +45 -0
- package/src/resource.test.ts +3 -3
- package/src/resource.ts +10 -5
- package/src/sanity.test.ts +30 -15
- package/src/testing.ts +38 -5
- package/src/url.test.ts +1 -1
- package/src/url.ts +5 -2
- package/dist/types/src/jsonPath.d.ts.map +0 -1
- package/dist/types/src/jsonPath.test.d.ts +0 -2
- package/dist/types/src/jsonPath.test.d.ts.map +0 -1
|
@@ -1,70 +1,73 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
|
+
import {
|
|
3
|
+
__export
|
|
4
|
+
} from "./chunk-CGS2ULMK.mjs";
|
|
2
5
|
|
|
3
6
|
// src/ast.ts
|
|
4
|
-
import
|
|
5
|
-
import
|
|
7
|
+
import * as Function from "effect/Function";
|
|
8
|
+
import * as Option from "effect/Option";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
10
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
6
11
|
import { invariant } from "@dxos/invariant";
|
|
7
12
|
import { isNonNullable } from "@dxos/util";
|
|
8
13
|
var __dxlog_file = "/__w/dxos/dxos/packages/common/effect/src/ast.ts";
|
|
9
|
-
var
|
|
10
|
-
if (SchemaAST.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return "enum";
|
|
24
|
-
}
|
|
25
|
-
if (SchemaAST.isLiteral(node)) {
|
|
26
|
-
return "literal";
|
|
14
|
+
var reduceRefinements = (type, refinements = []) => {
|
|
15
|
+
if (SchemaAST.isRefinement(type)) {
|
|
16
|
+
const filter = type.filter;
|
|
17
|
+
const nextType = {
|
|
18
|
+
...type.from,
|
|
19
|
+
annotations: {
|
|
20
|
+
...type.from.annotations,
|
|
21
|
+
...type.annotations
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return reduceRefinements(nextType, [
|
|
25
|
+
...refinements,
|
|
26
|
+
filter
|
|
27
|
+
]);
|
|
27
28
|
}
|
|
29
|
+
return {
|
|
30
|
+
type,
|
|
31
|
+
refinements
|
|
32
|
+
};
|
|
28
33
|
};
|
|
29
|
-
var
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return {};
|
|
44
|
-
}
|
|
45
|
-
default: {
|
|
46
|
-
throw new Error(`Unsupported type for default value: ${type}`);
|
|
34
|
+
var getBaseType = (prop) => {
|
|
35
|
+
const encoded = SchemaAST.encodedBoundAST(prop.type);
|
|
36
|
+
const unwrapped = prop.isOptional && encoded._tag === "Union" ? encoded.types[0] : encoded;
|
|
37
|
+
return reduceRefinements(unwrapped);
|
|
38
|
+
};
|
|
39
|
+
var getProperties = (ast) => {
|
|
40
|
+
const properties = SchemaAST.getPropertySignatures(ast);
|
|
41
|
+
return properties.map((prop) => {
|
|
42
|
+
const { type, refinements } = getBaseType(prop);
|
|
43
|
+
const mergedType = prop.annotations && Reflect.ownKeys(prop.annotations).length > 0 ? {
|
|
44
|
+
...type,
|
|
45
|
+
annotations: {
|
|
46
|
+
...type.annotations,
|
|
47
|
+
...prop.annotations
|
|
47
48
|
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
} : type;
|
|
50
|
+
return {
|
|
51
|
+
type: mergedType,
|
|
52
|
+
refinements,
|
|
53
|
+
name: prop.name,
|
|
54
|
+
isOptional: prop.isOptional,
|
|
55
|
+
isReadonly: prop.isReadonly
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
var VisitResult = /* @__PURE__ */ (function(VisitResult2) {
|
|
52
60
|
VisitResult2[VisitResult2["CONTINUE"] = 0] = "CONTINUE";
|
|
53
61
|
VisitResult2[VisitResult2["SKIP"] = 1] = "SKIP";
|
|
54
62
|
VisitResult2[VisitResult2["EXIT"] = 2] = "EXIT";
|
|
55
63
|
return VisitResult2;
|
|
56
|
-
}({});
|
|
57
|
-
var defaultTest = isSimpleType;
|
|
64
|
+
})({});
|
|
58
65
|
var visit = (node, testOrVisitor, visitor) => {
|
|
59
|
-
|
|
60
|
-
visitNode(node, defaultTest, testOrVisitor);
|
|
61
|
-
} else {
|
|
62
|
-
visitNode(node, testOrVisitor, visitor);
|
|
63
|
-
}
|
|
66
|
+
visitNode(node, testOrVisitor, visitor);
|
|
64
67
|
};
|
|
65
68
|
var visitNode = (node, test, visitor, path = [], depth = 0) => {
|
|
66
|
-
const
|
|
67
|
-
const result =
|
|
69
|
+
const $result = test?.(node, path, depth);
|
|
70
|
+
const result = $result === void 0 ? 0 : typeof $result === "boolean" ? $result ? 0 : 1 : $result;
|
|
68
71
|
if (result === 2) {
|
|
69
72
|
return result;
|
|
70
73
|
}
|
|
@@ -117,6 +120,12 @@ var findNode = (node, test) => {
|
|
|
117
120
|
return child;
|
|
118
121
|
}
|
|
119
122
|
}
|
|
123
|
+
for (const prop of getIndexSignatures(node)) {
|
|
124
|
+
const child = findNode(prop.type, test);
|
|
125
|
+
if (child) {
|
|
126
|
+
return child;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
120
129
|
} else if (SchemaAST.isTupleType(node)) {
|
|
121
130
|
for (const [_, element] of node.elements.entries()) {
|
|
122
131
|
const child = findNode(element.type, test);
|
|
@@ -125,12 +134,13 @@ var findNode = (node, test) => {
|
|
|
125
134
|
}
|
|
126
135
|
}
|
|
127
136
|
} else if (SchemaAST.isUnion(node)) {
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
if (isLiteralUnion(node)) {
|
|
138
|
+
return void 0;
|
|
139
|
+
}
|
|
140
|
+
for (const type of node.types) {
|
|
141
|
+
const child = findNode(type, test);
|
|
142
|
+
if (child) {
|
|
143
|
+
return child;
|
|
134
144
|
}
|
|
135
145
|
}
|
|
136
146
|
} else if (SchemaAST.isRefinement(node)) {
|
|
@@ -163,21 +173,21 @@ var findProperty = (schema, path) => {
|
|
|
163
173
|
return getProp(schema.ast, path.split("."));
|
|
164
174
|
};
|
|
165
175
|
var defaultAnnotations = {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
};
|
|
171
|
-
var
|
|
172
|
-
const id = pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);
|
|
173
|
-
const value = pipe(SchemaAST.getAnnotation(annotationId)(node), Option.getOrUndefined);
|
|
176
|
+
ObjectKeyword: SchemaAST.objectKeyword,
|
|
177
|
+
StringKeyword: SchemaAST.stringKeyword,
|
|
178
|
+
NumberKeyword: SchemaAST.numberKeyword,
|
|
179
|
+
BooleanKeyword: SchemaAST.booleanKeyword
|
|
180
|
+
};
|
|
181
|
+
var getAnnotation2 = (annotationId, noDefault = true) => (node) => {
|
|
182
|
+
const id = Function.pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);
|
|
183
|
+
const value = Function.pipe(SchemaAST.getAnnotation(annotationId)(node), Option.getOrUndefined);
|
|
174
184
|
if (noDefault && (value === defaultAnnotations[node._tag]?.annotations[annotationId] || value === id)) {
|
|
175
185
|
return void 0;
|
|
176
186
|
}
|
|
177
187
|
return value;
|
|
178
188
|
};
|
|
179
189
|
var findAnnotation = (node, annotationId, noDefault = true) => {
|
|
180
|
-
const getAnnotationById =
|
|
190
|
+
const getAnnotationById = getAnnotation2(annotationId, noDefault);
|
|
181
191
|
const getBaseAnnotation = (node2) => {
|
|
182
192
|
const value = getAnnotationById(node2);
|
|
183
193
|
if (value !== void 0) {
|
|
@@ -197,13 +207,22 @@ var isOption = (node) => {
|
|
|
197
207
|
var isLiteralUnion = (node) => {
|
|
198
208
|
return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);
|
|
199
209
|
};
|
|
210
|
+
var isArrayType = (node) => {
|
|
211
|
+
return SchemaAST.isTupleType(node) && node.elements.length === 0 && node.rest.length === 1;
|
|
212
|
+
};
|
|
213
|
+
var getArrayElementType = (node) => {
|
|
214
|
+
return isArrayType(node) ? node.rest.at(0)?.type : void 0;
|
|
215
|
+
};
|
|
216
|
+
var isTupleType2 = (node) => {
|
|
217
|
+
return SchemaAST.isTupleType(node) && node.elements.length > 0;
|
|
218
|
+
};
|
|
200
219
|
var isDiscriminatedUnion = (node) => {
|
|
201
220
|
return SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;
|
|
202
221
|
};
|
|
203
222
|
var getDiscriminatingProps = (node) => {
|
|
204
223
|
invariant(SchemaAST.isUnion(node), void 0, {
|
|
205
224
|
F: __dxlog_file,
|
|
206
|
-
L:
|
|
225
|
+
L: 365,
|
|
207
226
|
S: void 0,
|
|
208
227
|
A: [
|
|
209
228
|
"SchemaAST.isUnion(node)",
|
|
@@ -221,7 +240,7 @@ var getDiscriminatingProps = (node) => {
|
|
|
221
240
|
var getDiscriminatedType = (node, value = {}) => {
|
|
222
241
|
invariant(SchemaAST.isUnion(node), void 0, {
|
|
223
242
|
F: __dxlog_file,
|
|
224
|
-
L:
|
|
243
|
+
L: 389,
|
|
225
244
|
S: void 0,
|
|
226
245
|
A: [
|
|
227
246
|
"SchemaAST.isUnion(node)",
|
|
@@ -230,7 +249,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
230
249
|
});
|
|
231
250
|
invariant(value, void 0, {
|
|
232
251
|
F: __dxlog_file,
|
|
233
|
-
L:
|
|
252
|
+
L: 390,
|
|
234
253
|
S: void 0,
|
|
235
254
|
A: [
|
|
236
255
|
"value",
|
|
@@ -245,7 +264,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
245
264
|
const match = SchemaAST.getPropertySignatures(type).filter((prop) => props?.includes(prop.name.toString())).every((prop) => {
|
|
246
265
|
invariant(SchemaAST.isLiteral(prop.type), void 0, {
|
|
247
266
|
F: __dxlog_file,
|
|
248
|
-
L:
|
|
267
|
+
L: 401,
|
|
249
268
|
S: void 0,
|
|
250
269
|
A: [
|
|
251
270
|
"SchemaAST.isLiteral(prop.type)",
|
|
@@ -263,7 +282,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
263
282
|
const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop);
|
|
264
283
|
invariant(SchemaAST.isLiteral(literal.type), void 0, {
|
|
265
284
|
F: __dxlog_file,
|
|
266
|
-
L:
|
|
285
|
+
L: 419,
|
|
267
286
|
S: void 0,
|
|
268
287
|
A: [
|
|
269
288
|
"SchemaAST.isLiteral(literal.type)",
|
|
@@ -280,10 +299,14 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
280
299
|
const schema = Schema.Struct(fields);
|
|
281
300
|
return schema.ast;
|
|
282
301
|
};
|
|
302
|
+
var isNestedType = (node) => {
|
|
303
|
+
return SchemaAST.isDeclaration(node) || SchemaAST.isObjectKeyword(node) || SchemaAST.isTypeLiteral(node) || // TODO(wittjosiah): Tuples are actually arrays.
|
|
304
|
+
isTupleType2(node) || isDiscriminatedUnion(node);
|
|
305
|
+
};
|
|
283
306
|
var mapAst = (ast, f) => {
|
|
284
307
|
switch (ast._tag) {
|
|
285
308
|
case "TypeLiteral": {
|
|
286
|
-
return new SchemaAST.TypeLiteral(ast.propertySignatures.map((prop) => new SchemaAST.PropertySignature(prop.name, f(prop.type, prop.name), prop.isOptional, prop.isReadonly, prop.annotations)), ast.indexSignatures);
|
|
309
|
+
return new SchemaAST.TypeLiteral(ast.propertySignatures.map((prop) => new SchemaAST.PropertySignature(prop.name, f(prop.type, prop.name), prop.isOptional, prop.isReadonly, prop.annotations)), ast.indexSignatures, ast.annotations);
|
|
287
310
|
}
|
|
288
311
|
case "Union": {
|
|
289
312
|
return SchemaAST.Union.make(ast.types.map(f), ast.annotations);
|
|
@@ -300,16 +323,313 @@ var mapAst = (ast, f) => {
|
|
|
300
323
|
}
|
|
301
324
|
}
|
|
302
325
|
};
|
|
303
|
-
var
|
|
304
|
-
|
|
326
|
+
var getIndexSignatures = (ast) => {
|
|
327
|
+
const annotation = SchemaAST.getSurrogateAnnotation(ast);
|
|
328
|
+
if (Option.isSome(annotation)) {
|
|
329
|
+
return getIndexSignatures(annotation.value);
|
|
330
|
+
}
|
|
331
|
+
switch (ast._tag) {
|
|
332
|
+
case "TypeLiteral":
|
|
333
|
+
return ast.indexSignatures.slice();
|
|
334
|
+
case "Suspend":
|
|
335
|
+
return getIndexSignatures(ast.f());
|
|
336
|
+
case "Refinement":
|
|
337
|
+
return getIndexSignatures(ast.from);
|
|
338
|
+
}
|
|
339
|
+
return [];
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
// src/atom-kvs.ts
|
|
343
|
+
import { Atom } from "@effect-atom/atom-react";
|
|
344
|
+
import * as BrowserKeyValueStore from "@effect/platform-browser/BrowserKeyValueStore";
|
|
345
|
+
var defaultRuntime = Atom.runtime(BrowserKeyValueStore.layerLocalStorage);
|
|
346
|
+
var createKvsStore = (options) => {
|
|
347
|
+
const runtime2 = options.runtime ?? defaultRuntime;
|
|
348
|
+
return Atom.kvs({
|
|
349
|
+
runtime: runtime2,
|
|
350
|
+
key: options.key,
|
|
351
|
+
schema: options.schema,
|
|
352
|
+
defaultValue: options.defaultValue
|
|
353
|
+
}).pipe(Atom.keepAlive);
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
// src/context.ts
|
|
357
|
+
import * as Effect from "effect/Effect";
|
|
358
|
+
import { Context } from "@dxos/context";
|
|
359
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/effect/src/context.ts";
|
|
360
|
+
var contextFromScope = () => Effect.gen(function* () {
|
|
361
|
+
const ctx = new Context(void 0, {
|
|
362
|
+
F: __dxlog_file2,
|
|
363
|
+
L: 13
|
|
364
|
+
});
|
|
365
|
+
yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));
|
|
366
|
+
return ctx;
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// src/dynamic-runtime.ts
|
|
370
|
+
var dynamic_runtime_exports = {};
|
|
371
|
+
__export(dynamic_runtime_exports, {
|
|
372
|
+
make: () => make
|
|
373
|
+
});
|
|
374
|
+
import * as Context2 from "effect/Context";
|
|
375
|
+
import * as Effect3 from "effect/Effect";
|
|
376
|
+
import * as Exit2 from "effect/Exit";
|
|
377
|
+
import * as Option3 from "effect/Option";
|
|
378
|
+
import * as Runtime2 from "effect/Runtime";
|
|
379
|
+
|
|
380
|
+
// src/errors.ts
|
|
381
|
+
import * as Cause from "effect/Cause";
|
|
382
|
+
import * as Chunk from "effect/Chunk";
|
|
383
|
+
import * as Effect2 from "effect/Effect";
|
|
384
|
+
import * as Exit from "effect/Exit";
|
|
385
|
+
import * as GlobalValue from "effect/GlobalValue";
|
|
386
|
+
import * as Option2 from "effect/Option";
|
|
387
|
+
import * as Runtime from "effect/Runtime";
|
|
388
|
+
var spanSymbol = /* @__PURE__ */ Symbol.for("effect/SpanAnnotation");
|
|
389
|
+
var spanToTrace = GlobalValue.globalValue("effect/Tracer/spanToTrace", () => /* @__PURE__ */ new WeakMap());
|
|
390
|
+
var locationRegex = /\((.*)\)/g;
|
|
391
|
+
var prettyErrorStack = (error, appendStacks = []) => {
|
|
392
|
+
if (typeof error !== "object" || error === null) {
|
|
393
|
+
return error;
|
|
394
|
+
}
|
|
395
|
+
const span = error[spanSymbol];
|
|
396
|
+
const lines = typeof error.stack === "string" ? error.stack.split("\n") : [];
|
|
397
|
+
const out = [];
|
|
398
|
+
let atStack = false, inCore = false, passedScheduler = false;
|
|
399
|
+
for (let i = 0; i < lines.length; i++) {
|
|
400
|
+
if (!atStack && !lines[i].startsWith(" at ")) {
|
|
401
|
+
out.push(lines[i]);
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
atStack = true;
|
|
405
|
+
if (lines[i].includes(" at new BaseEffectError") || lines[i].includes(" at new YieldableError")) {
|
|
406
|
+
i++;
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
if (lines[i].includes("Generator.next")) {
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
if (lines[i].includes("effect_internal_function")) {
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
const filename = lines[i].match(/\/([a-zA-Z0-9_\-.]+):\d+:\d+\)$/)?.[1];
|
|
416
|
+
if (!inCore && [
|
|
417
|
+
"core-effect.ts"
|
|
418
|
+
].includes(filename)) {
|
|
419
|
+
inCore = true;
|
|
420
|
+
}
|
|
421
|
+
if (inCore && !passedScheduler && [
|
|
422
|
+
"Scheduler.ts"
|
|
423
|
+
].includes(filename)) {
|
|
424
|
+
passedScheduler = true;
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
if (passedScheduler && ![
|
|
428
|
+
"Scheduler.ts"
|
|
429
|
+
].includes(filename)) {
|
|
430
|
+
inCore = false;
|
|
431
|
+
}
|
|
432
|
+
if (inCore) {
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
out.push(lines[i].replace(/at .*effect_instruction_i.*\((.*)\)/, "at $1").replace(/EffectPrimitive\.\w+/, "<anonymous>").replace(/at Arguments\./, "at "));
|
|
436
|
+
}
|
|
437
|
+
if (span) {
|
|
438
|
+
let current = span;
|
|
439
|
+
let i = 0;
|
|
440
|
+
while (current && current._tag === "Span" && i < 10) {
|
|
441
|
+
const stackFn = spanToTrace.get(current);
|
|
442
|
+
if (typeof stackFn === "function") {
|
|
443
|
+
const stack = stackFn();
|
|
444
|
+
if (typeof stack === "string") {
|
|
445
|
+
const locationMatchAll = stack.matchAll(locationRegex);
|
|
446
|
+
let match = false;
|
|
447
|
+
for (const [, location] of locationMatchAll) {
|
|
448
|
+
match = true;
|
|
449
|
+
out.push(` at ${current.name} (${location})`);
|
|
450
|
+
}
|
|
451
|
+
if (!match) {
|
|
452
|
+
out.push(` at ${current.name} (${stack.replace(/^at /, "")})`);
|
|
453
|
+
}
|
|
454
|
+
} else {
|
|
455
|
+
out.push(` at ${current.name}`);
|
|
456
|
+
}
|
|
457
|
+
} else {
|
|
458
|
+
out.push(` at ${current.name}`);
|
|
459
|
+
}
|
|
460
|
+
current = Option2.getOrUndefined(current.parent);
|
|
461
|
+
i++;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
out.push(...appendStacks);
|
|
465
|
+
error = Cause.originalError(error);
|
|
466
|
+
if (error.cause) {
|
|
467
|
+
error.cause = prettyErrorStack(error.cause);
|
|
468
|
+
}
|
|
469
|
+
Object.defineProperty(error, "stack", {
|
|
470
|
+
value: out.join("\n"),
|
|
471
|
+
writable: true,
|
|
472
|
+
enumerable: false,
|
|
473
|
+
configurable: true
|
|
474
|
+
});
|
|
475
|
+
return error;
|
|
476
|
+
};
|
|
477
|
+
var causeToError = (cause) => {
|
|
478
|
+
if (Cause.isEmpty(cause)) {
|
|
479
|
+
return new Error("Fiber failed without a cause");
|
|
480
|
+
} else if (Cause.isInterruptedOnly(cause)) {
|
|
481
|
+
return new Error("Fiber was interrupted");
|
|
482
|
+
} else {
|
|
483
|
+
const errors = [
|
|
484
|
+
...Chunk.toArray(Cause.failures(cause)),
|
|
485
|
+
...Chunk.toArray(Cause.defects(cause))
|
|
486
|
+
];
|
|
487
|
+
const getStackFrames = () => {
|
|
488
|
+
const o = new Error();
|
|
489
|
+
Error.captureStackTrace(o, causeToError);
|
|
490
|
+
return o.stack.split("\n").slice(1);
|
|
491
|
+
};
|
|
492
|
+
const stackFrames = getStackFrames();
|
|
493
|
+
const newErrors = errors.map((error) => prettyErrorStack(error, stackFrames));
|
|
494
|
+
if (newErrors.length === 1) {
|
|
495
|
+
return newErrors[0];
|
|
496
|
+
} else {
|
|
497
|
+
return new AggregateError(newErrors);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
var throwCause = (cause) => {
|
|
502
|
+
throw causeToError(cause);
|
|
503
|
+
};
|
|
504
|
+
var unwrapExit = (exit2) => {
|
|
505
|
+
if (Exit.isSuccess(exit2)) {
|
|
506
|
+
return exit2.value;
|
|
507
|
+
}
|
|
508
|
+
return throwCause(exit2.cause);
|
|
509
|
+
};
|
|
510
|
+
var runAndForwardErrors = async (effect, options) => {
|
|
511
|
+
const exit2 = await Effect2.runPromiseExit(effect, options);
|
|
512
|
+
return unwrapExit(exit2);
|
|
513
|
+
};
|
|
514
|
+
var runInRuntime = (...args) => {
|
|
515
|
+
if (args.length === 1) {
|
|
516
|
+
const [runtime2] = args;
|
|
517
|
+
return async (effect, options) => {
|
|
518
|
+
const exit2 = await Runtime.runPromiseExit(runtime2, effect, options);
|
|
519
|
+
return unwrapExit(exit2);
|
|
520
|
+
};
|
|
521
|
+
} else {
|
|
522
|
+
const [runtime2, effect, options] = args;
|
|
523
|
+
return (async () => {
|
|
524
|
+
const exit2 = await Runtime.runPromiseExit(runtime2, effect, options);
|
|
525
|
+
return unwrapExit(exit2);
|
|
526
|
+
})();
|
|
527
|
+
}
|
|
305
528
|
};
|
|
306
|
-
var
|
|
529
|
+
var promiseWithCauseCapture = (evaluate) => Effect2.promise(async (signal) => {
|
|
530
|
+
try {
|
|
531
|
+
const result = await evaluate(signal);
|
|
532
|
+
return Effect2.succeed(result);
|
|
533
|
+
} catch (err) {
|
|
534
|
+
return Effect2.die(err);
|
|
535
|
+
}
|
|
536
|
+
}).pipe(Effect2.flatten);
|
|
537
|
+
|
|
538
|
+
// src/dynamic-runtime.ts
|
|
539
|
+
var validateTags = (context, tags) => Effect3.gen(function* () {
|
|
540
|
+
const missingTags = [];
|
|
541
|
+
for (const tag of tags) {
|
|
542
|
+
const option = Context2.getOption(context, tag);
|
|
543
|
+
if (Option3.isNone(option)) {
|
|
544
|
+
missingTags.push(tag.key);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (missingTags.length > 0) {
|
|
548
|
+
return yield* Effect3.die(new Error(`Missing required tags in runtime: ${missingTags.join(", ")}`));
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
function make(managedRuntime, tags) {
|
|
552
|
+
const managedRuntimeAny = managedRuntime;
|
|
553
|
+
let cachedRuntime;
|
|
554
|
+
let validatedRuntimePromise;
|
|
555
|
+
const getValidatedRuntimeAsync = async () => {
|
|
556
|
+
if (!validatedRuntimePromise) {
|
|
557
|
+
validatedRuntimePromise = managedRuntimeAny.runPromise(Effect3.gen(function* () {
|
|
558
|
+
const rt = yield* managedRuntimeAny.runtimeEffect;
|
|
559
|
+
yield* validateTags(rt.context, tags);
|
|
560
|
+
return rt;
|
|
561
|
+
}));
|
|
562
|
+
}
|
|
563
|
+
return validatedRuntimePromise;
|
|
564
|
+
};
|
|
565
|
+
const getValidatedRuntime = () => {
|
|
566
|
+
const validationExit = managedRuntimeAny.runSyncExit(Effect3.gen(function* () {
|
|
567
|
+
const rt = yield* managedRuntimeAny.runtimeEffect;
|
|
568
|
+
yield* validateTags(rt.context, tags);
|
|
569
|
+
return rt;
|
|
570
|
+
}));
|
|
571
|
+
return unwrapExit(validationExit);
|
|
572
|
+
};
|
|
573
|
+
return {
|
|
574
|
+
managedRuntime: managedRuntimeAny,
|
|
575
|
+
runPromise: async (effect) => {
|
|
576
|
+
const runtime2 = await getValidatedRuntimeAsync();
|
|
577
|
+
return Runtime2.runPromise(runtime2)(effect);
|
|
578
|
+
},
|
|
579
|
+
runSync: (effect) => {
|
|
580
|
+
const runtime2 = getValidatedRuntime();
|
|
581
|
+
return Runtime2.runSync(runtime2)(effect);
|
|
582
|
+
},
|
|
583
|
+
runSyncExit: (effect) => {
|
|
584
|
+
const validationExit = managedRuntimeAny.runSyncExit(Effect3.gen(function* () {
|
|
585
|
+
const rt = yield* managedRuntimeAny.runtimeEffect;
|
|
586
|
+
yield* validateTags(rt.context, tags);
|
|
587
|
+
return rt;
|
|
588
|
+
}));
|
|
589
|
+
if (Exit2.isSuccess(validationExit)) {
|
|
590
|
+
const runtime2 = validationExit.value;
|
|
591
|
+
return Runtime2.runSyncExit(runtime2)(effect);
|
|
592
|
+
}
|
|
593
|
+
return validationExit;
|
|
594
|
+
},
|
|
595
|
+
runPromiseExit: async (effect) => {
|
|
596
|
+
try {
|
|
597
|
+
const runtime2 = await getValidatedRuntimeAsync();
|
|
598
|
+
return Runtime2.runPromiseExit(runtime2)(effect);
|
|
599
|
+
} catch (error) {
|
|
600
|
+
return Exit2.die(error);
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
runFork: (effect) => {
|
|
604
|
+
const runtime2 = getValidatedRuntime();
|
|
605
|
+
return Runtime2.runFork(runtime2)(effect);
|
|
606
|
+
},
|
|
607
|
+
runtimeEffect: Effect3.gen(function* () {
|
|
608
|
+
if (cachedRuntime) {
|
|
609
|
+
return cachedRuntime;
|
|
610
|
+
}
|
|
611
|
+
const rt = yield* managedRuntimeAny.runtimeEffect;
|
|
612
|
+
yield* validateTags(rt.context, tags);
|
|
613
|
+
const runtime2 = rt;
|
|
614
|
+
cachedRuntime = runtime2;
|
|
615
|
+
return runtime2;
|
|
616
|
+
}).pipe(Effect3.catchAll(() => (
|
|
617
|
+
// This should never happen since validateTags uses Effect.die
|
|
618
|
+
Effect3.die(new Error("Unexpected error in runtimeEffect validation"))
|
|
619
|
+
))),
|
|
620
|
+
dispose: async () => {
|
|
621
|
+
await managedRuntimeAny.dispose();
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
}
|
|
307
625
|
|
|
308
|
-
// src/
|
|
309
|
-
import
|
|
626
|
+
// src/json-path.ts
|
|
627
|
+
import * as Option4 from "effect/Option";
|
|
628
|
+
import * as Schema2 from "effect/Schema";
|
|
310
629
|
import { JSONPath } from "jsonpath-plus";
|
|
311
630
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
312
|
-
|
|
631
|
+
import { getDeep, setDeep } from "@dxos/util";
|
|
632
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/effect/src/json-path.ts";
|
|
313
633
|
var PATH_REGEX = /^($|[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*|\[\d+\](?:\.)?)*$)/;
|
|
314
634
|
var PROP_REGEX = /^\w+$/;
|
|
315
635
|
var JsonPath = Schema2.String.pipe(Schema2.pattern(PATH_REGEX)).annotations({
|
|
@@ -320,7 +640,7 @@ var JsonProp = Schema2.NonEmptyString.pipe(Schema2.pattern(PROP_REGEX, {
|
|
|
320
640
|
message: () => "Property name must contain only letters, numbers, and underscores"
|
|
321
641
|
}));
|
|
322
642
|
var isJsonPath = (value) => {
|
|
323
|
-
return
|
|
643
|
+
return Option4.isSome(Schema2.validateOption(JsonPath)(value));
|
|
324
644
|
};
|
|
325
645
|
var createJsonPath = (path) => {
|
|
326
646
|
const candidatePath = path.map((p, i) => {
|
|
@@ -331,8 +651,8 @@ var createJsonPath = (path) => {
|
|
|
331
651
|
}
|
|
332
652
|
}).join("");
|
|
333
653
|
invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`, {
|
|
334
|
-
F:
|
|
335
|
-
L:
|
|
654
|
+
F: __dxlog_file3,
|
|
655
|
+
L: 69,
|
|
336
656
|
S: void 0,
|
|
337
657
|
A: [
|
|
338
658
|
"isJsonPath(candidatePath)",
|
|
@@ -344,8 +664,8 @@ var createJsonPath = (path) => {
|
|
|
344
664
|
var fromEffectValidationPath = (effectPath) => {
|
|
345
665
|
const jsonPath = effectPath.replace(/\.\[(\d+)\]/g, "[$1]");
|
|
346
666
|
invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`, {
|
|
347
|
-
F:
|
|
348
|
-
L:
|
|
667
|
+
F: __dxlog_file3,
|
|
668
|
+
L: 80,
|
|
349
669
|
S: void 0,
|
|
350
670
|
A: [
|
|
351
671
|
"isJsonPath(jsonPath)",
|
|
@@ -358,7 +678,10 @@ var splitJsonPath = (path) => {
|
|
|
358
678
|
if (!isJsonPath(path)) {
|
|
359
679
|
return [];
|
|
360
680
|
}
|
|
361
|
-
return path.match(/[a-zA-Z_$][\w$]*|\[\d+\]/g)?.map((part) => part.
|
|
681
|
+
return path.match(/[a-zA-Z_$][\w$]*|\[\d+\]/g)?.map((part) => part.replace(/[[\]]/g, "")).map((part) => {
|
|
682
|
+
const parsed = Number.parseInt(part, 10);
|
|
683
|
+
return Number.isNaN(parsed) ? part : parsed;
|
|
684
|
+
}) ?? [];
|
|
362
685
|
};
|
|
363
686
|
var getField = (object, path) => {
|
|
364
687
|
return JSONPath({
|
|
@@ -366,11 +689,33 @@ var getField = (object, path) => {
|
|
|
366
689
|
json: object
|
|
367
690
|
})[0];
|
|
368
691
|
};
|
|
692
|
+
var getValue = (obj, path) => {
|
|
693
|
+
return getDeep(obj, splitJsonPath(path));
|
|
694
|
+
};
|
|
695
|
+
var setValue = (obj, path, value) => {
|
|
696
|
+
return setDeep(obj, splitJsonPath(path), value);
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
// src/resource.ts
|
|
700
|
+
import * as Effect4 from "effect/Effect";
|
|
701
|
+
var acquireReleaseResource = (getResource) => Effect4.acquireRelease(Effect4.gen(function* () {
|
|
702
|
+
const resource = getResource();
|
|
703
|
+
yield* Effect4.promise(async () => {
|
|
704
|
+
await resource.open?.();
|
|
705
|
+
return void 0;
|
|
706
|
+
});
|
|
707
|
+
return resource;
|
|
708
|
+
}), (resource) => Effect4.promise(async () => {
|
|
709
|
+
await resource.close?.();
|
|
710
|
+
return void 0;
|
|
711
|
+
}));
|
|
369
712
|
|
|
370
713
|
// src/url.ts
|
|
371
|
-
import
|
|
714
|
+
import * as Function2 from "effect/Function";
|
|
715
|
+
import * as Option5 from "effect/Option";
|
|
716
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
372
717
|
import { decamelize } from "@dxos/util";
|
|
373
|
-
var ParamKeyAnnotationId = Symbol.for("@dxos/schema/annotation/ParamKey");
|
|
718
|
+
var ParamKeyAnnotationId = /* @__PURE__ */ Symbol.for("@dxos/schema/annotation/ParamKey");
|
|
374
719
|
var getParamKeyAnnotation = SchemaAST2.getAnnotation(ParamKeyAnnotationId);
|
|
375
720
|
var ParamKeyAnnotation = (value) => (self) => self.annotations({
|
|
376
721
|
[ParamKeyAnnotationId]: value
|
|
@@ -411,7 +756,7 @@ var UrlParser = class {
|
|
|
411
756
|
if (value !== void 0) {
|
|
412
757
|
const field = this._schema.fields[key];
|
|
413
758
|
if (field) {
|
|
414
|
-
const { key: serializedKey } =
|
|
759
|
+
const { key: serializedKey } = Function2.pipe(getParamKeyAnnotation(field.ast), Option5.getOrElse(() => ({
|
|
415
760
|
key: decamelize(key)
|
|
416
761
|
})));
|
|
417
762
|
url.searchParams.set(serializedKey, String(value));
|
|
@@ -422,189 +767,121 @@ var UrlParser = class {
|
|
|
422
767
|
}
|
|
423
768
|
};
|
|
424
769
|
|
|
425
|
-
// src/
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
F: __dxlog_file3,
|
|
432
|
-
L: 12
|
|
433
|
-
});
|
|
434
|
-
yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));
|
|
435
|
-
return ctx;
|
|
770
|
+
// src/RuntimeProvider.ts
|
|
771
|
+
var RuntimeProvider_exports = {};
|
|
772
|
+
__export(RuntimeProvider_exports, {
|
|
773
|
+
currentRuntime: () => currentRuntime,
|
|
774
|
+
provide: () => provide2,
|
|
775
|
+
runPromise: () => runPromise2
|
|
436
776
|
});
|
|
777
|
+
import * as Effect5 from "effect/Effect";
|
|
778
|
+
import * as Runtime3 from "effect/Runtime";
|
|
779
|
+
var currentRuntime = () => Effect5.runtime().pipe(Effect5.map(Effect5.succeed));
|
|
780
|
+
var runPromise2 = (provider) => async (effect) => {
|
|
781
|
+
const runtime2 = await runAndForwardErrors(provider);
|
|
782
|
+
return unwrapExit(await effect.pipe(Runtime3.runPromiseExit(runtime2)));
|
|
783
|
+
};
|
|
784
|
+
var provide2 = (runtimeProvider) => (effect) => Effect5.flatMap(runtimeProvider, (runtime2) => Effect5.provide(effect, runtime2));
|
|
437
785
|
|
|
438
|
-
// src/
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
var
|
|
445
|
-
const
|
|
446
|
-
const
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
}
|
|
454
|
-
atStack = true;
|
|
455
|
-
if (lines[i].includes(" at new BaseEffectError") || lines[i].includes(" at new YieldableError")) {
|
|
456
|
-
i++;
|
|
457
|
-
continue;
|
|
458
|
-
}
|
|
459
|
-
if (lines[i].includes("Generator.next")) {
|
|
460
|
-
break;
|
|
461
|
-
}
|
|
462
|
-
if (lines[i].includes("effect_internal_function")) {
|
|
463
|
-
break;
|
|
786
|
+
// src/Performance.ts
|
|
787
|
+
var Performance_exports = {};
|
|
788
|
+
__export(Performance_exports, {
|
|
789
|
+
addTrackEntry: () => addTrackEntry
|
|
790
|
+
});
|
|
791
|
+
import * as Effect6 from "effect/Effect";
|
|
792
|
+
var addTrackEntry = (options) => (effect) => Effect6.gen(function* () {
|
|
793
|
+
const start = performance.now();
|
|
794
|
+
const exit2 = yield* Effect6.exit(effect);
|
|
795
|
+
const resolvedOptions = typeof options === "function" ? options(exit2) : options;
|
|
796
|
+
performance.measure(resolvedOptions.name, {
|
|
797
|
+
start,
|
|
798
|
+
detail: {
|
|
799
|
+
...resolvedOptions.detail,
|
|
800
|
+
devtools: resolvedOptions.devtools
|
|
464
801
|
}
|
|
465
|
-
|
|
802
|
+
});
|
|
803
|
+
return yield* exit2;
|
|
804
|
+
});
|
|
805
|
+
|
|
806
|
+
// src/async-task-tagging.ts
|
|
807
|
+
import * as Context3 from "effect/Context";
|
|
808
|
+
import * as Effect7 from "effect/Effect";
|
|
809
|
+
import { pipe as pipe3 } from "effect/Function";
|
|
810
|
+
import * as Layer from "effect/Layer";
|
|
811
|
+
import * as Predicate from "effect/Predicate";
|
|
812
|
+
import * as Tracer from "effect/Tracer";
|
|
813
|
+
var runInTask = /* @__PURE__ */ Symbol("runInTask");
|
|
814
|
+
var asyncTaskTaggingLayer = () => {
|
|
815
|
+
if (Predicate.hasProperty(console, "createTask") === false) {
|
|
816
|
+
return Layer.empty;
|
|
466
817
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
} else {
|
|
485
|
-
out.push(` at ${current.name}`);
|
|
818
|
+
const makeTracer = Effect7.gen(function* () {
|
|
819
|
+
const oldTracer = yield* Effect7.tracer;
|
|
820
|
+
return Tracer.make({
|
|
821
|
+
span: (name, ...args) => {
|
|
822
|
+
const span = oldTracer.span(name, ...args);
|
|
823
|
+
const trace = console.createTask(name);
|
|
824
|
+
span[runInTask] = (f) => trace.run(f);
|
|
825
|
+
return span;
|
|
826
|
+
},
|
|
827
|
+
context: (f, fiber) => {
|
|
828
|
+
const maybeParentSpan = Context3.getOption(Tracer.ParentSpan)(fiber.currentContext);
|
|
829
|
+
if (maybeParentSpan._tag === "None") return oldTracer.context(f, fiber);
|
|
830
|
+
const parentSpan = maybeParentSpan.value;
|
|
831
|
+
if (parentSpan._tag === "ExternalSpan") return oldTracer.context(f, fiber);
|
|
832
|
+
const span = parentSpan;
|
|
833
|
+
if (runInTask in span && typeof span[runInTask] === "function") {
|
|
834
|
+
return span[runInTask](() => oldTracer.context(f, fiber));
|
|
486
835
|
}
|
|
487
|
-
|
|
488
|
-
out.push(` at ${current.name}`);
|
|
836
|
+
return oldTracer.context(f, fiber);
|
|
489
837
|
}
|
|
490
|
-
|
|
491
|
-
i++;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
out.push(...appendStacks);
|
|
495
|
-
if (error[originalSymbol]) {
|
|
496
|
-
error = error[originalSymbol];
|
|
497
|
-
}
|
|
498
|
-
if (error.cause) {
|
|
499
|
-
error.cause = prettyErrorStack(error.cause);
|
|
500
|
-
}
|
|
501
|
-
Object.defineProperty(error, "stack", {
|
|
502
|
-
value: out.join("\n"),
|
|
503
|
-
writable: true,
|
|
504
|
-
enumerable: false,
|
|
505
|
-
configurable: true
|
|
838
|
+
});
|
|
506
839
|
});
|
|
507
|
-
return
|
|
840
|
+
return pipe3(makeTracer, Effect7.map(Layer.setTracer), Layer.unwrapEffect);
|
|
508
841
|
};
|
|
509
|
-
var runAndForwardErrors = async (effect, options) => {
|
|
510
|
-
const exit = await Effect2.runPromiseExit(effect, options);
|
|
511
|
-
if (Exit.isSuccess(exit)) {
|
|
512
|
-
return exit.value;
|
|
513
|
-
}
|
|
514
|
-
if (Cause.isEmpty(exit.cause)) {
|
|
515
|
-
throw new Error("Fiber failed without a cause");
|
|
516
|
-
} else if (Cause.isInterrupted(exit.cause)) {
|
|
517
|
-
throw new Error("Fiber was interrupted");
|
|
518
|
-
} else {
|
|
519
|
-
const errors = [
|
|
520
|
-
...Chunk.toArray(Cause.failures(exit.cause)),
|
|
521
|
-
...Chunk.toArray(Cause.defects(exit.cause))
|
|
522
|
-
];
|
|
523
|
-
const getStackFrames = () => {
|
|
524
|
-
const o = {};
|
|
525
|
-
Error.captureStackTrace(o, getStackFrames);
|
|
526
|
-
return o.stack.split("\n").slice(1);
|
|
527
|
-
};
|
|
528
|
-
const stackFrames = getStackFrames();
|
|
529
|
-
const newErrors = errors.map((error) => prettyErrorStack(error, stackFrames));
|
|
530
|
-
if (newErrors.length === 1) {
|
|
531
|
-
throw newErrors[0];
|
|
532
|
-
} else {
|
|
533
|
-
throw new AggregateError(newErrors);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
// src/testing.ts
|
|
539
|
-
import { Effect as Effect3 } from "effect";
|
|
540
|
-
(function(TestHelpers2) {
|
|
541
|
-
TestHelpers2.runIf = (condition) => (effect, ctx) => Effect3.gen(function* () {
|
|
542
|
-
if (!condition) {
|
|
543
|
-
ctx.skip();
|
|
544
|
-
} else {
|
|
545
|
-
return yield* effect;
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
TestHelpers2.skipIf = (condition) => (effect, ctx) => Effect3.gen(function* () {
|
|
549
|
-
if (condition) {
|
|
550
|
-
ctx.skip();
|
|
551
|
-
} else {
|
|
552
|
-
return yield* effect;
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
TestHelpers2.taggedTest = (tag) => (effect, ctx) => Effect3.gen(function* () {
|
|
556
|
-
if (!process.env.DX_TEST_TAGS?.includes(tag)) {
|
|
557
|
-
ctx.skip();
|
|
558
|
-
} else {
|
|
559
|
-
return yield* effect;
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
})(TestHelpers || (TestHelpers = {}));
|
|
563
|
-
var TestHelpers;
|
|
564
|
-
|
|
565
|
-
// src/resource.ts
|
|
566
|
-
import { Effect as Effect4 } from "effect";
|
|
567
|
-
var accuireReleaseResource = (getResource) => Effect4.acquireRelease(Effect4.gen(function* () {
|
|
568
|
-
const resource = getResource();
|
|
569
|
-
yield* Effect4.promise(async () => {
|
|
570
|
-
resource.open?.();
|
|
571
|
-
return void 0;
|
|
572
|
-
});
|
|
573
|
-
return resource;
|
|
574
|
-
}), (resource) => Effect4.promise(async () => {
|
|
575
|
-
resource.close?.();
|
|
576
|
-
return void 0;
|
|
577
|
-
}));
|
|
578
842
|
export {
|
|
843
|
+
dynamic_runtime_exports as DynamicRuntime,
|
|
579
844
|
JsonPath,
|
|
580
845
|
JsonProp,
|
|
581
846
|
ParamKeyAnnotation,
|
|
582
|
-
|
|
583
|
-
|
|
847
|
+
Performance_exports as Performance,
|
|
848
|
+
RuntimeProvider_exports as RuntimeProvider,
|
|
584
849
|
UrlParser,
|
|
585
850
|
VisitResult,
|
|
586
|
-
|
|
851
|
+
acquireReleaseResource,
|
|
852
|
+
asyncTaskTaggingLayer,
|
|
853
|
+
causeToError,
|
|
587
854
|
contextFromScope,
|
|
588
855
|
createJsonPath,
|
|
856
|
+
createKvsStore,
|
|
589
857
|
findAnnotation,
|
|
590
858
|
findNode,
|
|
591
859
|
findProperty,
|
|
592
860
|
fromEffectValidationPath,
|
|
593
|
-
getAnnotation,
|
|
861
|
+
getAnnotation2 as getAnnotation,
|
|
862
|
+
getArrayElementType,
|
|
863
|
+
getBaseType,
|
|
594
864
|
getDiscriminatedType,
|
|
595
865
|
getDiscriminatingProps,
|
|
596
866
|
getField,
|
|
597
867
|
getParamKeyAnnotation,
|
|
598
|
-
|
|
868
|
+
getProperties,
|
|
869
|
+
getValue,
|
|
599
870
|
isArrayType,
|
|
600
871
|
isDiscriminatedUnion,
|
|
601
872
|
isJsonPath,
|
|
602
873
|
isLiteralUnion,
|
|
874
|
+
isNestedType,
|
|
603
875
|
isOption,
|
|
604
|
-
|
|
876
|
+
isTupleType2 as isTupleType,
|
|
605
877
|
mapAst,
|
|
878
|
+
promiseWithCauseCapture,
|
|
606
879
|
runAndForwardErrors,
|
|
880
|
+
runInRuntime,
|
|
881
|
+
setValue,
|
|
607
882
|
splitJsonPath,
|
|
883
|
+
throwCause,
|
|
884
|
+
unwrapExit,
|
|
608
885
|
visit
|
|
609
886
|
};
|
|
610
887
|
//# sourceMappingURL=index.mjs.map
|