@dxos/effect 0.8.4-main.406dc2a → 0.8.4-main.422d1c7879
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 +464 -241
- 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 +464 -241
- 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 +34 -21
- 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/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 +12 -0
- 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/{jsonPath.d.ts → json-path.d.ts} +11 -3
- 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/resource.d.ts +5 -1
- package/dist/types/src/resource.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +4 -3
- package/dist/types/src/testing.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -13
- package/src/Performance.ts +45 -0
- package/src/RuntimeProvider.ts +35 -0
- package/src/ast.test.ts +35 -8
- package/src/ast.ts +115 -89
- package/src/async-task-tagging.ts +47 -0
- package/src/atom-kvs.ts +35 -0
- package/src/dynamic-runtime.test.ts +465 -0
- package/src/dynamic-runtime.ts +195 -0
- package/src/errors.ts +69 -8
- package/src/index.ts +7 -3
- package/src/interrupt.test.ts +3 -1
- package/src/{jsonPath.test.ts → json-path.test.ts} +47 -8
- package/src/{jsonPath.ts → json-path.ts} +27 -3
- package/src/layers.test.ts +4 -2
- package/src/otel.test.ts +1 -0
- package/src/resource.ts +9 -4
- package/src/sanity.test.ts +24 -10
- package/src/testing.ts +6 -4
- 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,4 +1,7 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
|
+
import {
|
|
3
|
+
__export
|
|
4
|
+
} from "./chunk-CGS2ULMK.mjs";
|
|
2
5
|
|
|
3
6
|
// src/ast.ts
|
|
4
7
|
import * as Function from "effect/Function";
|
|
@@ -8,65 +11,59 @@ import * as SchemaAST from "effect/SchemaAST";
|
|
|
8
11
|
import { invariant } from "@dxos/invariant";
|
|
9
12
|
import { isNonNullable } from "@dxos/util";
|
|
10
13
|
var __dxlog_file = "/__w/dxos/dxos/packages/common/effect/src/ast.ts";
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (SchemaAST.isBooleanKeyword(node)) {
|
|
26
|
-
return "boolean";
|
|
27
|
-
}
|
|
28
|
-
if (SchemaAST.isEnums(node)) {
|
|
29
|
-
return "enum";
|
|
30
|
-
}
|
|
31
|
-
if (SchemaAST.isLiteral(node)) {
|
|
32
|
-
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
|
+
]);
|
|
33
28
|
}
|
|
29
|
+
return {
|
|
30
|
+
type,
|
|
31
|
+
refinements
|
|
32
|
+
};
|
|
34
33
|
};
|
|
35
|
-
var
|
|
36
|
-
(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return {};
|
|
50
|
-
}
|
|
51
|
-
default: {
|
|
52
|
-
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
|
|
53
48
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
} : type;
|
|
50
|
+
return {
|
|
51
|
+
type: mergedType,
|
|
52
|
+
refinements,
|
|
53
|
+
name: prop.name,
|
|
54
|
+
isOptional: prop.isOptional,
|
|
55
|
+
isReadonly: prop.isReadonly
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
};
|
|
57
59
|
var VisitResult = /* @__PURE__ */ (function(VisitResult2) {
|
|
58
60
|
VisitResult2[VisitResult2["CONTINUE"] = 0] = "CONTINUE";
|
|
59
61
|
VisitResult2[VisitResult2["SKIP"] = 1] = "SKIP";
|
|
60
62
|
VisitResult2[VisitResult2["EXIT"] = 2] = "EXIT";
|
|
61
63
|
return VisitResult2;
|
|
62
64
|
})({});
|
|
63
|
-
var defaultTest = isSimpleType;
|
|
64
65
|
var visit = (node, testOrVisitor, visitor) => {
|
|
65
|
-
|
|
66
|
-
visitNode(node, defaultTest, testOrVisitor);
|
|
67
|
-
} else {
|
|
68
|
-
visitNode(node, testOrVisitor, visitor);
|
|
69
|
-
}
|
|
66
|
+
visitNode(node, testOrVisitor, visitor);
|
|
70
67
|
};
|
|
71
68
|
var visitNode = (node, test, visitor, path = [], depth = 0) => {
|
|
72
69
|
const $result = test?.(node, path, depth);
|
|
@@ -123,6 +120,12 @@ var findNode = (node, test) => {
|
|
|
123
120
|
return child;
|
|
124
121
|
}
|
|
125
122
|
}
|
|
123
|
+
for (const prop of getIndexSignatures(node)) {
|
|
124
|
+
const child = findNode(prop.type, test);
|
|
125
|
+
if (child) {
|
|
126
|
+
return child;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
126
129
|
} else if (SchemaAST.isTupleType(node)) {
|
|
127
130
|
for (const [_, element] of node.elements.entries()) {
|
|
128
131
|
const child = findNode(element.type, test);
|
|
@@ -150,7 +153,7 @@ var findProperty = (schema, path) => {
|
|
|
150
153
|
const typeNode = findNode(node, SchemaAST.isTypeLiteral);
|
|
151
154
|
invariant(typeNode, void 0, {
|
|
152
155
|
F: __dxlog_file,
|
|
153
|
-
L:
|
|
156
|
+
L: 247,
|
|
154
157
|
S: void 0,
|
|
155
158
|
A: [
|
|
156
159
|
"typeNode",
|
|
@@ -170,10 +173,10 @@ var findProperty = (schema, path) => {
|
|
|
170
173
|
return getProp(schema.ast, path.split("."));
|
|
171
174
|
};
|
|
172
175
|
var defaultAnnotations = {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
176
|
+
ObjectKeyword: SchemaAST.objectKeyword,
|
|
177
|
+
StringKeyword: SchemaAST.stringKeyword,
|
|
178
|
+
NumberKeyword: SchemaAST.numberKeyword,
|
|
179
|
+
BooleanKeyword: SchemaAST.booleanKeyword
|
|
177
180
|
};
|
|
178
181
|
var getAnnotation2 = (annotationId, noDefault = true) => (node) => {
|
|
179
182
|
const id = Function.pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);
|
|
@@ -204,13 +207,22 @@ var isOption = (node) => {
|
|
|
204
207
|
var isLiteralUnion = (node) => {
|
|
205
208
|
return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);
|
|
206
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
|
+
};
|
|
207
219
|
var isDiscriminatedUnion = (node) => {
|
|
208
220
|
return SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;
|
|
209
221
|
};
|
|
210
222
|
var getDiscriminatingProps = (node) => {
|
|
211
223
|
invariant(SchemaAST.isUnion(node), void 0, {
|
|
212
224
|
F: __dxlog_file,
|
|
213
|
-
L:
|
|
225
|
+
L: 365,
|
|
214
226
|
S: void 0,
|
|
215
227
|
A: [
|
|
216
228
|
"SchemaAST.isUnion(node)",
|
|
@@ -228,7 +240,7 @@ var getDiscriminatingProps = (node) => {
|
|
|
228
240
|
var getDiscriminatedType = (node, value = {}) => {
|
|
229
241
|
invariant(SchemaAST.isUnion(node), void 0, {
|
|
230
242
|
F: __dxlog_file,
|
|
231
|
-
L:
|
|
243
|
+
L: 389,
|
|
232
244
|
S: void 0,
|
|
233
245
|
A: [
|
|
234
246
|
"SchemaAST.isUnion(node)",
|
|
@@ -237,7 +249,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
237
249
|
});
|
|
238
250
|
invariant(value, void 0, {
|
|
239
251
|
F: __dxlog_file,
|
|
240
|
-
L:
|
|
252
|
+
L: 390,
|
|
241
253
|
S: void 0,
|
|
242
254
|
A: [
|
|
243
255
|
"value",
|
|
@@ -252,7 +264,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
252
264
|
const match = SchemaAST.getPropertySignatures(type).filter((prop) => props?.includes(prop.name.toString())).every((prop) => {
|
|
253
265
|
invariant(SchemaAST.isLiteral(prop.type), void 0, {
|
|
254
266
|
F: __dxlog_file,
|
|
255
|
-
L:
|
|
267
|
+
L: 401,
|
|
256
268
|
S: void 0,
|
|
257
269
|
A: [
|
|
258
270
|
"SchemaAST.isLiteral(prop.type)",
|
|
@@ -270,7 +282,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
270
282
|
const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop);
|
|
271
283
|
invariant(SchemaAST.isLiteral(literal.type), void 0, {
|
|
272
284
|
F: __dxlog_file,
|
|
273
|
-
L:
|
|
285
|
+
L: 419,
|
|
274
286
|
S: void 0,
|
|
275
287
|
A: [
|
|
276
288
|
"SchemaAST.isLiteral(literal.type)",
|
|
@@ -287,6 +299,10 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
287
299
|
const schema = Schema.Struct(fields);
|
|
288
300
|
return schema.ast;
|
|
289
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
|
+
};
|
|
290
306
|
var mapAst = (ast, f) => {
|
|
291
307
|
switch (ast._tag) {
|
|
292
308
|
case "TypeLiteral": {
|
|
@@ -307,173 +323,79 @@ var mapAst = (ast, f) => {
|
|
|
307
323
|
}
|
|
308
324
|
}
|
|
309
325
|
};
|
|
310
|
-
var
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
// src/jsonPath.ts
|
|
316
|
-
import * as Option2 from "effect/Option";
|
|
317
|
-
import * as Schema2 from "effect/Schema";
|
|
318
|
-
import { JSONPath } from "jsonpath-plus";
|
|
319
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
320
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/effect/src/jsonPath.ts";
|
|
321
|
-
var PATH_REGEX = /^($|[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*|\[\d+\](?:\.)?)*$)/;
|
|
322
|
-
var PROP_REGEX = /^\w+$/;
|
|
323
|
-
var JsonPath = Schema2.String.pipe(Schema2.pattern(PATH_REGEX)).annotations({
|
|
324
|
-
title: "JSON path",
|
|
325
|
-
description: "JSON path to a property"
|
|
326
|
-
});
|
|
327
|
-
var JsonProp = Schema2.NonEmptyString.pipe(Schema2.pattern(PROP_REGEX, {
|
|
328
|
-
message: () => "Property name must contain only letters, numbers, and underscores"
|
|
329
|
-
}));
|
|
330
|
-
var isJsonPath = (value) => {
|
|
331
|
-
return Option2.isSome(Schema2.validateOption(JsonPath)(value));
|
|
332
|
-
};
|
|
333
|
-
var createJsonPath = (path) => {
|
|
334
|
-
const candidatePath = path.map((p, i) => {
|
|
335
|
-
if (typeof p === "number") {
|
|
336
|
-
return `[${p}]`;
|
|
337
|
-
} else {
|
|
338
|
-
return i === 0 ? p : `.${p}`;
|
|
339
|
-
}
|
|
340
|
-
}).join("");
|
|
341
|
-
invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`, {
|
|
342
|
-
F: __dxlog_file2,
|
|
343
|
-
L: 64,
|
|
344
|
-
S: void 0,
|
|
345
|
-
A: [
|
|
346
|
-
"isJsonPath(candidatePath)",
|
|
347
|
-
"`Invalid JsonPath: ${candidatePath}`"
|
|
348
|
-
]
|
|
349
|
-
});
|
|
350
|
-
return candidatePath;
|
|
351
|
-
};
|
|
352
|
-
var fromEffectValidationPath = (effectPath) => {
|
|
353
|
-
const jsonPath = effectPath.replace(/\.\[(\d+)\]/g, "[$1]");
|
|
354
|
-
invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`, {
|
|
355
|
-
F: __dxlog_file2,
|
|
356
|
-
L: 75,
|
|
357
|
-
S: void 0,
|
|
358
|
-
A: [
|
|
359
|
-
"isJsonPath(jsonPath)",
|
|
360
|
-
"`Invalid JsonPath: ${jsonPath}`"
|
|
361
|
-
]
|
|
362
|
-
});
|
|
363
|
-
return jsonPath;
|
|
364
|
-
};
|
|
365
|
-
var splitJsonPath = (path) => {
|
|
366
|
-
if (!isJsonPath(path)) {
|
|
367
|
-
return [];
|
|
326
|
+
var getIndexSignatures = (ast) => {
|
|
327
|
+
const annotation = SchemaAST.getSurrogateAnnotation(ast);
|
|
328
|
+
if (Option.isSome(annotation)) {
|
|
329
|
+
return getIndexSignatures(annotation.value);
|
|
368
330
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
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 [];
|
|
376
340
|
};
|
|
377
341
|
|
|
378
|
-
// src/
|
|
379
|
-
import
|
|
380
|
-
import * as
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
});
|
|
391
|
-
} else {
|
|
392
|
-
obj[key] = value;
|
|
393
|
-
}
|
|
394
|
-
return obj;
|
|
395
|
-
}
|
|
396
|
-
var ParamKeyAnnotationId = Symbol.for("@dxos/schema/annotation/ParamKey");
|
|
397
|
-
var getParamKeyAnnotation = SchemaAST2.getAnnotation(ParamKeyAnnotationId);
|
|
398
|
-
var ParamKeyAnnotation = (value) => (self) => self.annotations({
|
|
399
|
-
[ParamKeyAnnotationId]: value
|
|
400
|
-
});
|
|
401
|
-
var UrlParser = class {
|
|
402
|
-
/**
|
|
403
|
-
* Parse URL params.
|
|
404
|
-
*/
|
|
405
|
-
parse(_url) {
|
|
406
|
-
const url = new URL(_url);
|
|
407
|
-
return Object.entries(this._schema.fields).reduce((params, [key, type]) => {
|
|
408
|
-
let value = url.searchParams.get(decamelize(key));
|
|
409
|
-
if (value == null) {
|
|
410
|
-
value = url.searchParams.get(key);
|
|
411
|
-
}
|
|
412
|
-
if (value != null) {
|
|
413
|
-
if (SchemaAST2.isNumberKeyword(type.ast)) {
|
|
414
|
-
params[key] = parseInt(value);
|
|
415
|
-
} else if (SchemaAST2.isBooleanKeyword(type.ast)) {
|
|
416
|
-
params[key] = value === "true" || value === "1";
|
|
417
|
-
} else {
|
|
418
|
-
params[key] = value;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
return params;
|
|
422
|
-
}, {});
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* Return URL with encoded params.
|
|
426
|
-
*/
|
|
427
|
-
create(_url, params) {
|
|
428
|
-
const url = new URL(_url);
|
|
429
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
430
|
-
if (value !== void 0) {
|
|
431
|
-
const field = this._schema.fields[key];
|
|
432
|
-
if (field) {
|
|
433
|
-
const { key: serializedKey } = Function2.pipe(getParamKeyAnnotation(field.ast), Option3.getOrElse(() => ({
|
|
434
|
-
key: decamelize(key)
|
|
435
|
-
})));
|
|
436
|
-
url.searchParams.set(serializedKey, String(value));
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
return url;
|
|
441
|
-
}
|
|
442
|
-
constructor(_schema) {
|
|
443
|
-
_define_property(this, "_schema", void 0);
|
|
444
|
-
this._schema = _schema;
|
|
445
|
-
}
|
|
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);
|
|
446
354
|
};
|
|
447
355
|
|
|
448
356
|
// src/context.ts
|
|
449
357
|
import * as Effect from "effect/Effect";
|
|
450
358
|
import { Context } from "@dxos/context";
|
|
451
|
-
var
|
|
359
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/effect/src/context.ts";
|
|
452
360
|
var contextFromScope = () => Effect.gen(function* () {
|
|
453
361
|
const ctx = new Context(void 0, {
|
|
454
|
-
F:
|
|
362
|
+
F: __dxlog_file2,
|
|
455
363
|
L: 13
|
|
456
364
|
});
|
|
457
365
|
yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));
|
|
458
366
|
return ctx;
|
|
459
367
|
});
|
|
460
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
|
+
|
|
461
380
|
// src/errors.ts
|
|
462
381
|
import * as Cause from "effect/Cause";
|
|
463
382
|
import * as Chunk from "effect/Chunk";
|
|
464
383
|
import * as Effect2 from "effect/Effect";
|
|
465
384
|
import * as Exit from "effect/Exit";
|
|
466
385
|
import * as GlobalValue from "effect/GlobalValue";
|
|
467
|
-
import * as
|
|
468
|
-
|
|
469
|
-
var
|
|
386
|
+
import * as Option2 from "effect/Option";
|
|
387
|
+
import * as Runtime from "effect/Runtime";
|
|
388
|
+
var spanSymbol = /* @__PURE__ */ Symbol.for("effect/SpanAnnotation");
|
|
470
389
|
var spanToTrace = GlobalValue.globalValue("effect/Tracer/spanToTrace", () => /* @__PURE__ */ new WeakMap());
|
|
471
390
|
var locationRegex = /\((.*)\)/g;
|
|
472
391
|
var prettyErrorStack = (error, appendStacks = []) => {
|
|
392
|
+
if (typeof error !== "object" || error === null) {
|
|
393
|
+
return error;
|
|
394
|
+
}
|
|
473
395
|
const span = error[spanSymbol];
|
|
474
396
|
const lines = typeof error.stack === "string" ? error.stack.split("\n") : [];
|
|
475
397
|
const out = [];
|
|
476
|
-
let atStack = false;
|
|
398
|
+
let atStack = false, inCore = false, passedScheduler = false;
|
|
477
399
|
for (let i = 0; i < lines.length; i++) {
|
|
478
400
|
if (!atStack && !lines[i].startsWith(" at ")) {
|
|
479
401
|
out.push(lines[i]);
|
|
@@ -490,6 +412,26 @@ var prettyErrorStack = (error, appendStacks = []) => {
|
|
|
490
412
|
if (lines[i].includes("effect_internal_function")) {
|
|
491
413
|
break;
|
|
492
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
|
+
}
|
|
493
435
|
out.push(lines[i].replace(/at .*effect_instruction_i.*\((.*)\)/, "at $1").replace(/EffectPrimitive\.\w+/, "<anonymous>").replace(/at Arguments\./, "at "));
|
|
494
436
|
}
|
|
495
437
|
if (span) {
|
|
@@ -515,14 +457,12 @@ var prettyErrorStack = (error, appendStacks = []) => {
|
|
|
515
457
|
} else {
|
|
516
458
|
out.push(` at ${current.name}`);
|
|
517
459
|
}
|
|
518
|
-
current =
|
|
460
|
+
current = Option2.getOrUndefined(current.parent);
|
|
519
461
|
i++;
|
|
520
462
|
}
|
|
521
463
|
}
|
|
522
464
|
out.push(...appendStacks);
|
|
523
|
-
|
|
524
|
-
error = error[originalSymbol];
|
|
525
|
-
}
|
|
465
|
+
error = Cause.originalError(error);
|
|
526
466
|
if (error.cause) {
|
|
527
467
|
error.cause = prettyErrorStack(error.cause);
|
|
528
468
|
}
|
|
@@ -545,8 +485,8 @@ var causeToError = (cause) => {
|
|
|
545
485
|
...Chunk.toArray(Cause.defects(cause))
|
|
546
486
|
];
|
|
547
487
|
const getStackFrames = () => {
|
|
548
|
-
const o =
|
|
549
|
-
Error.captureStackTrace(o,
|
|
488
|
+
const o = new Error();
|
|
489
|
+
Error.captureStackTrace(o, causeToError);
|
|
550
490
|
return o.stack.split("\n").slice(1);
|
|
551
491
|
};
|
|
552
492
|
const stackFrames = getStackFrames();
|
|
@@ -561,15 +501,30 @@ var causeToError = (cause) => {
|
|
|
561
501
|
var throwCause = (cause) => {
|
|
562
502
|
throw causeToError(cause);
|
|
563
503
|
};
|
|
564
|
-
var unwrapExit = (
|
|
565
|
-
if (Exit.isSuccess(
|
|
566
|
-
return
|
|
504
|
+
var unwrapExit = (exit2) => {
|
|
505
|
+
if (Exit.isSuccess(exit2)) {
|
|
506
|
+
return exit2.value;
|
|
567
507
|
}
|
|
568
|
-
return throwCause(
|
|
508
|
+
return throwCause(exit2.cause);
|
|
569
509
|
};
|
|
570
510
|
var runAndForwardErrors = async (effect, options) => {
|
|
571
|
-
const
|
|
572
|
-
return unwrapExit(
|
|
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
|
+
}
|
|
573
528
|
};
|
|
574
529
|
var promiseWithCauseCapture = (evaluate) => Effect2.promise(async (signal) => {
|
|
575
530
|
try {
|
|
@@ -580,82 +535,350 @@ var promiseWithCauseCapture = (evaluate) => Effect2.promise(async (signal) => {
|
|
|
580
535
|
}
|
|
581
536
|
}).pipe(Effect2.flatten);
|
|
582
537
|
|
|
583
|
-
// src/
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
(
|
|
587
|
-
|
|
588
|
-
if (
|
|
589
|
-
|
|
590
|
-
} else {
|
|
591
|
-
return yield* effect;
|
|
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);
|
|
592
545
|
}
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
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
|
+
}));
|
|
599
562
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
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
|
+
}
|
|
625
|
+
|
|
626
|
+
// src/json-path.ts
|
|
627
|
+
import * as Option4 from "effect/Option";
|
|
628
|
+
import * as Schema2 from "effect/Schema";
|
|
629
|
+
import { JSONPath } from "jsonpath-plus";
|
|
630
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
631
|
+
import { getDeep, setDeep } from "@dxos/util";
|
|
632
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/effect/src/json-path.ts";
|
|
633
|
+
var PATH_REGEX = /^($|[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*|\[\d+\](?:\.)?)*$)/;
|
|
634
|
+
var PROP_REGEX = /^\w+$/;
|
|
635
|
+
var JsonPath = Schema2.String.pipe(Schema2.pattern(PATH_REGEX)).annotations({
|
|
636
|
+
title: "JSON path",
|
|
637
|
+
description: "JSON path to a property"
|
|
638
|
+
});
|
|
639
|
+
var JsonProp = Schema2.NonEmptyString.pipe(Schema2.pattern(PROP_REGEX, {
|
|
640
|
+
message: () => "Property name must contain only letters, numbers, and underscores"
|
|
641
|
+
}));
|
|
642
|
+
var isJsonPath = (value) => {
|
|
643
|
+
return Option4.isSome(Schema2.validateOption(JsonPath)(value));
|
|
644
|
+
};
|
|
645
|
+
var createJsonPath = (path) => {
|
|
646
|
+
const candidatePath = path.map((p, i) => {
|
|
647
|
+
if (typeof p === "number") {
|
|
648
|
+
return `[${p}]`;
|
|
604
649
|
} else {
|
|
605
|
-
return
|
|
650
|
+
return i === 0 ? p : `.${p}`;
|
|
606
651
|
}
|
|
652
|
+
}).join("");
|
|
653
|
+
invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`, {
|
|
654
|
+
F: __dxlog_file3,
|
|
655
|
+
L: 69,
|
|
656
|
+
S: void 0,
|
|
657
|
+
A: [
|
|
658
|
+
"isJsonPath(candidatePath)",
|
|
659
|
+
"`Invalid JsonPath: ${candidatePath}`"
|
|
660
|
+
]
|
|
607
661
|
});
|
|
608
|
-
|
|
609
|
-
}
|
|
610
|
-
var
|
|
662
|
+
return candidatePath;
|
|
663
|
+
};
|
|
664
|
+
var fromEffectValidationPath = (effectPath) => {
|
|
665
|
+
const jsonPath = effectPath.replace(/\.\[(\d+)\]/g, "[$1]");
|
|
666
|
+
invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`, {
|
|
667
|
+
F: __dxlog_file3,
|
|
668
|
+
L: 80,
|
|
669
|
+
S: void 0,
|
|
670
|
+
A: [
|
|
671
|
+
"isJsonPath(jsonPath)",
|
|
672
|
+
"`Invalid JsonPath: ${jsonPath}`"
|
|
673
|
+
]
|
|
674
|
+
});
|
|
675
|
+
return jsonPath;
|
|
676
|
+
};
|
|
677
|
+
var splitJsonPath = (path) => {
|
|
678
|
+
if (!isJsonPath(path)) {
|
|
679
|
+
return [];
|
|
680
|
+
}
|
|
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
|
+
}) ?? [];
|
|
685
|
+
};
|
|
686
|
+
var getField = (object, path) => {
|
|
687
|
+
return JSONPath({
|
|
688
|
+
path,
|
|
689
|
+
json: object
|
|
690
|
+
})[0];
|
|
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);
|
|
611
697
|
};
|
|
612
|
-
var TestHelpers;
|
|
613
698
|
|
|
614
699
|
// src/resource.ts
|
|
615
700
|
import * as Effect4 from "effect/Effect";
|
|
616
701
|
var acquireReleaseResource = (getResource) => Effect4.acquireRelease(Effect4.gen(function* () {
|
|
617
702
|
const resource = getResource();
|
|
618
703
|
yield* Effect4.promise(async () => {
|
|
619
|
-
resource.open?.();
|
|
704
|
+
await resource.open?.();
|
|
620
705
|
return void 0;
|
|
621
706
|
});
|
|
622
707
|
return resource;
|
|
623
708
|
}), (resource) => Effect4.promise(async () => {
|
|
624
|
-
resource.close?.();
|
|
709
|
+
await resource.close?.();
|
|
625
710
|
return void 0;
|
|
626
711
|
}));
|
|
712
|
+
|
|
713
|
+
// src/url.ts
|
|
714
|
+
import * as Function2 from "effect/Function";
|
|
715
|
+
import * as Option5 from "effect/Option";
|
|
716
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
717
|
+
import { decamelize } from "@dxos/util";
|
|
718
|
+
var ParamKeyAnnotationId = /* @__PURE__ */ Symbol.for("@dxos/schema/annotation/ParamKey");
|
|
719
|
+
var getParamKeyAnnotation = SchemaAST2.getAnnotation(ParamKeyAnnotationId);
|
|
720
|
+
var ParamKeyAnnotation = (value) => (self) => self.annotations({
|
|
721
|
+
[ParamKeyAnnotationId]: value
|
|
722
|
+
});
|
|
723
|
+
var UrlParser = class {
|
|
724
|
+
_schema;
|
|
725
|
+
constructor(_schema) {
|
|
726
|
+
this._schema = _schema;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Parse URL params.
|
|
730
|
+
*/
|
|
731
|
+
parse(_url) {
|
|
732
|
+
const url = new URL(_url);
|
|
733
|
+
return Object.entries(this._schema.fields).reduce((params, [key, type]) => {
|
|
734
|
+
let value = url.searchParams.get(decamelize(key));
|
|
735
|
+
if (value == null) {
|
|
736
|
+
value = url.searchParams.get(key);
|
|
737
|
+
}
|
|
738
|
+
if (value != null) {
|
|
739
|
+
if (SchemaAST2.isNumberKeyword(type.ast)) {
|
|
740
|
+
params[key] = parseInt(value);
|
|
741
|
+
} else if (SchemaAST2.isBooleanKeyword(type.ast)) {
|
|
742
|
+
params[key] = value === "true" || value === "1";
|
|
743
|
+
} else {
|
|
744
|
+
params[key] = value;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
return params;
|
|
748
|
+
}, {});
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Return URL with encoded params.
|
|
752
|
+
*/
|
|
753
|
+
create(_url, params) {
|
|
754
|
+
const url = new URL(_url);
|
|
755
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
756
|
+
if (value !== void 0) {
|
|
757
|
+
const field = this._schema.fields[key];
|
|
758
|
+
if (field) {
|
|
759
|
+
const { key: serializedKey } = Function2.pipe(getParamKeyAnnotation(field.ast), Option5.getOrElse(() => ({
|
|
760
|
+
key: decamelize(key)
|
|
761
|
+
})));
|
|
762
|
+
url.searchParams.set(serializedKey, String(value));
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
return url;
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
// src/RuntimeProvider.ts
|
|
771
|
+
var RuntimeProvider_exports = {};
|
|
772
|
+
__export(RuntimeProvider_exports, {
|
|
773
|
+
currentRuntime: () => currentRuntime,
|
|
774
|
+
provide: () => provide2,
|
|
775
|
+
runPromise: () => runPromise2
|
|
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));
|
|
785
|
+
|
|
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
|
|
801
|
+
}
|
|
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;
|
|
817
|
+
}
|
|
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));
|
|
835
|
+
}
|
|
836
|
+
return oldTracer.context(f, fiber);
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
});
|
|
840
|
+
return pipe3(makeTracer, Effect7.map(Layer.setTracer), Layer.unwrapEffect);
|
|
841
|
+
};
|
|
627
842
|
export {
|
|
843
|
+
dynamic_runtime_exports as DynamicRuntime,
|
|
628
844
|
JsonPath,
|
|
629
845
|
JsonProp,
|
|
630
846
|
ParamKeyAnnotation,
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
TestHelpers,
|
|
847
|
+
Performance_exports as Performance,
|
|
848
|
+
RuntimeProvider_exports as RuntimeProvider,
|
|
634
849
|
UrlParser,
|
|
635
850
|
VisitResult,
|
|
636
851
|
acquireReleaseResource,
|
|
852
|
+
asyncTaskTaggingLayer,
|
|
637
853
|
causeToError,
|
|
638
854
|
contextFromScope,
|
|
639
855
|
createJsonPath,
|
|
856
|
+
createKvsStore,
|
|
640
857
|
findAnnotation,
|
|
641
858
|
findNode,
|
|
642
859
|
findProperty,
|
|
643
860
|
fromEffectValidationPath,
|
|
644
861
|
getAnnotation2 as getAnnotation,
|
|
862
|
+
getArrayElementType,
|
|
863
|
+
getBaseType,
|
|
645
864
|
getDiscriminatedType,
|
|
646
865
|
getDiscriminatingProps,
|
|
647
866
|
getField,
|
|
648
867
|
getParamKeyAnnotation,
|
|
649
|
-
|
|
868
|
+
getProperties,
|
|
869
|
+
getValue,
|
|
650
870
|
isArrayType,
|
|
651
871
|
isDiscriminatedUnion,
|
|
652
872
|
isJsonPath,
|
|
653
873
|
isLiteralUnion,
|
|
874
|
+
isNestedType,
|
|
654
875
|
isOption,
|
|
655
|
-
|
|
876
|
+
isTupleType2 as isTupleType,
|
|
656
877
|
mapAst,
|
|
657
878
|
promiseWithCauseCapture,
|
|
658
879
|
runAndForwardErrors,
|
|
880
|
+
runInRuntime,
|
|
881
|
+
setValue,
|
|
659
882
|
splitJsonPath,
|
|
660
883
|
throwCause,
|
|
661
884
|
unwrapExit,
|