@dxos/effect 0.8.4-main.fbb7a13 → 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/index.mjs +149 -111
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing.mjs +0 -7
- package/dist/lib/browser/testing.mjs.map +3 -3
- package/dist/lib/node-esm/index.mjs +149 -111
- 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 +0 -7
- package/dist/lib/node-esm/testing.mjs.map +3 -3
- 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.map +1 -1
- package/dist/types/src/ast.d.ts +7 -1
- 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.map +1 -1
- package/dist/types/src/errors.d.ts +11 -3
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/json-path.d.ts.map +1 -1
- package/dist/types/src/resource.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +3 -12
- package/dist/types/src/testing.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -19
- package/src/Performance.ts +45 -0
- package/src/ast.test.ts +25 -0
- package/src/ast.ts +38 -12
- package/src/async-task-tagging.ts +51 -0
- package/src/atom-kvs.ts +1 -1
- package/src/errors.ts +59 -13
- package/src/index.ts +3 -0
- package/src/testing.ts +3 -27
- package/src/types.ts +11 -0
|
@@ -10,16 +10,14 @@ import * as Schema from "effect/Schema";
|
|
|
10
10
|
import * as SchemaAST from "effect/SchemaAST";
|
|
11
11
|
import { invariant } from "@dxos/invariant";
|
|
12
12
|
import { isNonNullable } from "@dxos/util";
|
|
13
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/common/effect/src/ast.ts";
|
|
14
13
|
var reduceRefinements = (type, refinements = []) => {
|
|
15
14
|
if (SchemaAST.isRefinement(type)) {
|
|
16
|
-
const annotations = type.annotations;
|
|
17
15
|
const filter = type.filter;
|
|
18
16
|
const nextType = {
|
|
19
17
|
...type.from,
|
|
20
18
|
annotations: {
|
|
21
|
-
...type.annotations,
|
|
22
|
-
...annotations
|
|
19
|
+
...type.from.annotations,
|
|
20
|
+
...type.annotations
|
|
23
21
|
}
|
|
24
22
|
};
|
|
25
23
|
return reduceRefinements(nextType, [
|
|
@@ -39,12 +37,23 @@ var getBaseType = (prop) => {
|
|
|
39
37
|
};
|
|
40
38
|
var getProperties = (ast) => {
|
|
41
39
|
const properties = SchemaAST.getPropertySignatures(ast);
|
|
42
|
-
return properties.map((prop) =>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
+
}
|
|
48
|
+
} : type;
|
|
49
|
+
return {
|
|
50
|
+
type: mergedType,
|
|
51
|
+
refinements,
|
|
52
|
+
name: prop.name,
|
|
53
|
+
isOptional: prop.isOptional,
|
|
54
|
+
isReadonly: prop.isReadonly
|
|
55
|
+
};
|
|
56
|
+
});
|
|
48
57
|
};
|
|
49
58
|
var VisitResult = /* @__PURE__ */ (function(VisitResult2) {
|
|
50
59
|
VisitResult2[VisitResult2["CONTINUE"] = 0] = "CONTINUE";
|
|
@@ -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: 235,
|
|
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,10 +164,10 @@ var findProperty = (schema, path) => {
|
|
|
163
164
|
return getProp(schema.ast, path.split("."));
|
|
164
165
|
};
|
|
165
166
|
var defaultAnnotations = {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
ObjectKeyword: SchemaAST.objectKeyword,
|
|
168
|
+
StringKeyword: SchemaAST.stringKeyword,
|
|
169
|
+
NumberKeyword: SchemaAST.numberKeyword,
|
|
170
|
+
BooleanKeyword: SchemaAST.booleanKeyword
|
|
170
171
|
};
|
|
171
172
|
var getAnnotation2 = (annotationId, noDefault = true) => (node) => {
|
|
172
173
|
const id = Function.pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);
|
|
@@ -197,6 +198,12 @@ 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
|
+
};
|
|
200
207
|
var isArrayType = (node) => {
|
|
201
208
|
return SchemaAST.isTupleType(node) && node.elements.length === 0 && node.rest.length === 1;
|
|
202
209
|
};
|
|
@@ -210,15 +217,7 @@ var isDiscriminatedUnion = (node) => {
|
|
|
210
217
|
return SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;
|
|
211
218
|
};
|
|
212
219
|
var getDiscriminatingProps = (node) => {
|
|
213
|
-
invariant(SchemaAST.isUnion(node)
|
|
214
|
-
F: __dxlog_file,
|
|
215
|
-
L: 353,
|
|
216
|
-
S: void 0,
|
|
217
|
-
A: [
|
|
218
|
-
"SchemaAST.isUnion(node)",
|
|
219
|
-
""
|
|
220
|
-
]
|
|
221
|
-
});
|
|
220
|
+
invariant(SchemaAST.isUnion(node));
|
|
222
221
|
if (isOption(node)) {
|
|
223
222
|
return;
|
|
224
223
|
}
|
|
@@ -228,39 +227,15 @@ var getDiscriminatingProps = (node) => {
|
|
|
228
227
|
}, []);
|
|
229
228
|
};
|
|
230
229
|
var getDiscriminatedType = (node, value = {}) => {
|
|
231
|
-
invariant(SchemaAST.isUnion(node)
|
|
232
|
-
|
|
233
|
-
L: 377,
|
|
234
|
-
S: void 0,
|
|
235
|
-
A: [
|
|
236
|
-
"SchemaAST.isUnion(node)",
|
|
237
|
-
""
|
|
238
|
-
]
|
|
239
|
-
});
|
|
240
|
-
invariant(value, void 0, {
|
|
241
|
-
F: __dxlog_file,
|
|
242
|
-
L: 378,
|
|
243
|
-
S: void 0,
|
|
244
|
-
A: [
|
|
245
|
-
"value",
|
|
246
|
-
""
|
|
247
|
-
]
|
|
248
|
-
});
|
|
230
|
+
invariant(SchemaAST.isUnion(node));
|
|
231
|
+
invariant(value);
|
|
249
232
|
const props = getDiscriminatingProps(node);
|
|
250
233
|
if (!props?.length) {
|
|
251
234
|
return;
|
|
252
235
|
}
|
|
253
236
|
for (const type of node.types) {
|
|
254
237
|
const match = SchemaAST.getPropertySignatures(type).filter((prop) => props?.includes(prop.name.toString())).every((prop) => {
|
|
255
|
-
invariant(SchemaAST.isLiteral(prop.type)
|
|
256
|
-
F: __dxlog_file,
|
|
257
|
-
L: 389,
|
|
258
|
-
S: void 0,
|
|
259
|
-
A: [
|
|
260
|
-
"SchemaAST.isLiteral(prop.type)",
|
|
261
|
-
""
|
|
262
|
-
]
|
|
263
|
-
});
|
|
238
|
+
invariant(SchemaAST.isLiteral(prop.type));
|
|
264
239
|
return prop.type.literal === value[prop.name.toString()];
|
|
265
240
|
});
|
|
266
241
|
if (match) {
|
|
@@ -270,15 +245,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
270
245
|
const fields = Object.fromEntries(props.map((prop) => {
|
|
271
246
|
const literals = node.types.map((type) => {
|
|
272
247
|
const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop);
|
|
273
|
-
invariant(SchemaAST.isLiteral(literal.type)
|
|
274
|
-
F: __dxlog_file,
|
|
275
|
-
L: 407,
|
|
276
|
-
S: void 0,
|
|
277
|
-
A: [
|
|
278
|
-
"SchemaAST.isLiteral(literal.type)",
|
|
279
|
-
""
|
|
280
|
-
]
|
|
281
|
-
});
|
|
248
|
+
invariant(SchemaAST.isLiteral(literal.type));
|
|
282
249
|
return literal.type.literal;
|
|
283
250
|
}).filter(isNonNullable);
|
|
284
251
|
return literals.length ? [
|
|
@@ -330,8 +297,8 @@ var getIndexSignatures = (ast) => {
|
|
|
330
297
|
};
|
|
331
298
|
|
|
332
299
|
// src/atom-kvs.ts
|
|
333
|
-
import * as BrowserKeyValueStore from "@effect/platform-browser/BrowserKeyValueStore";
|
|
334
300
|
import { Atom } from "@effect-atom/atom-react";
|
|
301
|
+
import * as BrowserKeyValueStore from "@effect/platform-browser/BrowserKeyValueStore";
|
|
335
302
|
var defaultRuntime = Atom.runtime(BrowserKeyValueStore.layerLocalStorage);
|
|
336
303
|
var createKvsStore = (options) => {
|
|
337
304
|
const runtime2 = options.runtime ?? defaultRuntime;
|
|
@@ -346,12 +313,8 @@ var createKvsStore = (options) => {
|
|
|
346
313
|
// src/context.ts
|
|
347
314
|
import * as Effect from "effect/Effect";
|
|
348
315
|
import { Context } from "@dxos/context";
|
|
349
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/effect/src/context.ts";
|
|
350
316
|
var contextFromScope = () => Effect.gen(function* () {
|
|
351
|
-
const ctx = new Context(
|
|
352
|
-
F: __dxlog_file2,
|
|
353
|
-
L: 13
|
|
354
|
-
});
|
|
317
|
+
const ctx = new Context();
|
|
355
318
|
yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));
|
|
356
319
|
return ctx;
|
|
357
320
|
});
|
|
@@ -375,8 +338,7 @@ import * as Exit from "effect/Exit";
|
|
|
375
338
|
import * as GlobalValue from "effect/GlobalValue";
|
|
376
339
|
import * as Option2 from "effect/Option";
|
|
377
340
|
import * as Runtime from "effect/Runtime";
|
|
378
|
-
var spanSymbol = Symbol.for("effect/SpanAnnotation");
|
|
379
|
-
var originalSymbol = Symbol.for("effect/OriginalAnnotation");
|
|
341
|
+
var spanSymbol = /* @__PURE__ */ Symbol.for("effect/SpanAnnotation");
|
|
380
342
|
var spanToTrace = GlobalValue.globalValue("effect/Tracer/spanToTrace", () => /* @__PURE__ */ new WeakMap());
|
|
381
343
|
var locationRegex = /\((.*)\)/g;
|
|
382
344
|
var prettyErrorStack = (error, appendStacks = []) => {
|
|
@@ -386,7 +348,7 @@ var prettyErrorStack = (error, appendStacks = []) => {
|
|
|
386
348
|
const span = error[spanSymbol];
|
|
387
349
|
const lines = typeof error.stack === "string" ? error.stack.split("\n") : [];
|
|
388
350
|
const out = [];
|
|
389
|
-
let atStack = false;
|
|
351
|
+
let atStack = false, inCore = false, passedScheduler = false;
|
|
390
352
|
for (let i = 0; i < lines.length; i++) {
|
|
391
353
|
if (!atStack && !lines[i].startsWith(" at ")) {
|
|
392
354
|
out.push(lines[i]);
|
|
@@ -403,6 +365,26 @@ var prettyErrorStack = (error, appendStacks = []) => {
|
|
|
403
365
|
if (lines[i].includes("effect_internal_function")) {
|
|
404
366
|
break;
|
|
405
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
|
+
}
|
|
406
388
|
out.push(lines[i].replace(/at .*effect_instruction_i.*\((.*)\)/, "at $1").replace(/EffectPrimitive\.\w+/, "<anonymous>").replace(/at Arguments\./, "at "));
|
|
407
389
|
}
|
|
408
390
|
if (span) {
|
|
@@ -433,9 +415,7 @@ var prettyErrorStack = (error, appendStacks = []) => {
|
|
|
433
415
|
}
|
|
434
416
|
}
|
|
435
417
|
out.push(...appendStacks);
|
|
436
|
-
|
|
437
|
-
error = error[originalSymbol];
|
|
438
|
-
}
|
|
418
|
+
error = Cause.originalError(error);
|
|
439
419
|
if (error.cause) {
|
|
440
420
|
error.cause = prettyErrorStack(error.cause);
|
|
441
421
|
}
|
|
@@ -459,7 +439,7 @@ var causeToError = (cause) => {
|
|
|
459
439
|
];
|
|
460
440
|
const getStackFrames = () => {
|
|
461
441
|
const o = new Error();
|
|
462
|
-
Error.captureStackTrace(o,
|
|
442
|
+
Error.captureStackTrace(o, causeToError);
|
|
463
443
|
return o.stack.split("\n").slice(1);
|
|
464
444
|
};
|
|
465
445
|
const stackFrames = getStackFrames();
|
|
@@ -474,19 +454,30 @@ var causeToError = (cause) => {
|
|
|
474
454
|
var throwCause = (cause) => {
|
|
475
455
|
throw causeToError(cause);
|
|
476
456
|
};
|
|
477
|
-
var unwrapExit = (
|
|
478
|
-
if (Exit.isSuccess(
|
|
479
|
-
return
|
|
457
|
+
var unwrapExit = (exit2) => {
|
|
458
|
+
if (Exit.isSuccess(exit2)) {
|
|
459
|
+
return exit2.value;
|
|
480
460
|
}
|
|
481
|
-
return throwCause(
|
|
461
|
+
return throwCause(exit2.cause);
|
|
482
462
|
};
|
|
483
463
|
var runAndForwardErrors = async (effect, options) => {
|
|
484
|
-
const
|
|
485
|
-
return unwrapExit(
|
|
486
|
-
};
|
|
487
|
-
var runInRuntime =
|
|
488
|
-
|
|
489
|
-
|
|
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
|
+
}
|
|
490
481
|
};
|
|
491
482
|
var promiseWithCauseCapture = (evaluate) => Effect2.promise(async (signal) => {
|
|
492
483
|
try {
|
|
@@ -591,7 +582,6 @@ import * as Schema2 from "effect/Schema";
|
|
|
591
582
|
import { JSONPath } from "jsonpath-plus";
|
|
592
583
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
593
584
|
import { getDeep, setDeep } from "@dxos/util";
|
|
594
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/effect/src/json-path.ts";
|
|
595
585
|
var PATH_REGEX = /^($|[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*|\[\d+\](?:\.)?)*$)/;
|
|
596
586
|
var PROP_REGEX = /^\w+$/;
|
|
597
587
|
var JsonPath = Schema2.String.pipe(Schema2.pattern(PATH_REGEX)).annotations({
|
|
@@ -612,28 +602,12 @@ var createJsonPath = (path) => {
|
|
|
612
602
|
return i === 0 ? p : `.${p}`;
|
|
613
603
|
}
|
|
614
604
|
}).join("");
|
|
615
|
-
invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}
|
|
616
|
-
F: __dxlog_file3,
|
|
617
|
-
L: 69,
|
|
618
|
-
S: void 0,
|
|
619
|
-
A: [
|
|
620
|
-
"isJsonPath(candidatePath)",
|
|
621
|
-
"`Invalid JsonPath: ${candidatePath}`"
|
|
622
|
-
]
|
|
623
|
-
});
|
|
605
|
+
invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`);
|
|
624
606
|
return candidatePath;
|
|
625
607
|
};
|
|
626
608
|
var fromEffectValidationPath = (effectPath) => {
|
|
627
609
|
const jsonPath = effectPath.replace(/\.\[(\d+)\]/g, "[$1]");
|
|
628
|
-
invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}
|
|
629
|
-
F: __dxlog_file3,
|
|
630
|
-
L: 80,
|
|
631
|
-
S: void 0,
|
|
632
|
-
A: [
|
|
633
|
-
"isJsonPath(jsonPath)",
|
|
634
|
-
"`Invalid JsonPath: ${jsonPath}`"
|
|
635
|
-
]
|
|
636
|
-
});
|
|
610
|
+
invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`);
|
|
637
611
|
return jsonPath;
|
|
638
612
|
};
|
|
639
613
|
var splitJsonPath = (path) => {
|
|
@@ -677,7 +651,7 @@ import * as Function2 from "effect/Function";
|
|
|
677
651
|
import * as Option5 from "effect/Option";
|
|
678
652
|
import * as SchemaAST2 from "effect/SchemaAST";
|
|
679
653
|
import { decamelize } from "@dxos/util";
|
|
680
|
-
var ParamKeyAnnotationId = Symbol.for("@dxos/schema/annotation/ParamKey");
|
|
654
|
+
var ParamKeyAnnotationId = /* @__PURE__ */ Symbol.for("@dxos/schema/annotation/ParamKey");
|
|
681
655
|
var getParamKeyAnnotation = SchemaAST2.getAnnotation(ParamKeyAnnotationId);
|
|
682
656
|
var ParamKeyAnnotation = (value) => (self) => self.annotations({
|
|
683
657
|
[ParamKeyAnnotationId]: value
|
|
@@ -744,15 +718,78 @@ var runPromise2 = (provider) => async (effect) => {
|
|
|
744
718
|
return unwrapExit(await effect.pipe(Runtime3.runPromiseExit(runtime2)));
|
|
745
719
|
};
|
|
746
720
|
var provide2 = (runtimeProvider) => (effect) => Effect5.flatMap(runtimeProvider, (runtime2) => Effect5.provide(effect, runtime2));
|
|
721
|
+
|
|
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
|
|
737
|
+
}
|
|
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;
|
|
753
|
+
}
|
|
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);
|
|
767
|
+
}
|
|
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);
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
});
|
|
780
|
+
return pipe3(makeTracer, Effect7.map(Layer.setTracer), Layer.unwrapEffect);
|
|
781
|
+
};
|
|
747
782
|
export {
|
|
748
783
|
dynamic_runtime_exports as DynamicRuntime,
|
|
749
784
|
JsonPath,
|
|
750
785
|
JsonProp,
|
|
751
786
|
ParamKeyAnnotation,
|
|
787
|
+
Performance_exports as Performance,
|
|
752
788
|
RuntimeProvider_exports as RuntimeProvider,
|
|
753
789
|
UrlParser,
|
|
754
790
|
VisitResult,
|
|
755
791
|
acquireReleaseResource,
|
|
792
|
+
asyncTaskTaggingLayer,
|
|
756
793
|
causeToError,
|
|
757
794
|
contextFromScope,
|
|
758
795
|
createJsonPath,
|
|
@@ -767,6 +804,7 @@ export {
|
|
|
767
804
|
getDiscriminatedType,
|
|
768
805
|
getDiscriminatingProps,
|
|
769
806
|
getField,
|
|
807
|
+
getLiteralValues,
|
|
770
808
|
getParamKeyAnnotation,
|
|
771
809
|
getProperties,
|
|
772
810
|
getValue,
|