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