@dxos/effect 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6

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.
@@ -13,13 +13,12 @@ import { isNonNullable } from "@dxos/util";
13
13
  var __dxlog_file = "/__w/dxos/dxos/packages/common/effect/src/ast.ts";
14
14
  var reduceRefinements = (type, refinements = []) => {
15
15
  if (SchemaAST.isRefinement(type)) {
16
- const annotations = type.annotations;
17
16
  const filter = type.filter;
18
17
  const nextType = {
19
18
  ...type.from,
20
19
  annotations: {
21
- ...type.annotations,
22
- ...annotations
20
+ ...type.from.annotations,
21
+ ...type.annotations
23
22
  }
24
23
  };
25
24
  return reduceRefinements(nextType, [
@@ -143,7 +142,7 @@ var findProperty = (schema, path) => {
143
142
  const typeNode = findNode(node, SchemaAST.isTypeLiteral);
144
143
  invariant(typeNode, void 0, {
145
144
  F: __dxlog_file,
146
- L: 235,
145
+ L: 237,
147
146
  S: void 0,
148
147
  A: [
149
148
  "typeNode",
@@ -163,10 +162,10 @@ var findProperty = (schema, path) => {
163
162
  return getProp(schema.ast, path.split("."));
164
163
  };
165
164
  var defaultAnnotations = {
166
- ["ObjectKeyword"]: SchemaAST.objectKeyword,
167
- ["StringKeyword"]: SchemaAST.stringKeyword,
168
- ["NumberKeyword"]: SchemaAST.numberKeyword,
169
- ["BooleanKeyword"]: SchemaAST.booleanKeyword
165
+ ObjectKeyword: SchemaAST.objectKeyword,
166
+ StringKeyword: SchemaAST.stringKeyword,
167
+ NumberKeyword: SchemaAST.numberKeyword,
168
+ BooleanKeyword: SchemaAST.booleanKeyword
170
169
  };
171
170
  var getAnnotation2 = (annotationId, noDefault = true) => (node) => {
172
171
  const id = Function.pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);
@@ -212,7 +211,7 @@ var isDiscriminatedUnion = (node) => {
212
211
  var getDiscriminatingProps = (node) => {
213
212
  invariant(SchemaAST.isUnion(node), void 0, {
214
213
  F: __dxlog_file,
215
- L: 353,
214
+ L: 355,
216
215
  S: void 0,
217
216
  A: [
218
217
  "SchemaAST.isUnion(node)",
@@ -230,7 +229,7 @@ var getDiscriminatingProps = (node) => {
230
229
  var getDiscriminatedType = (node, value = {}) => {
231
230
  invariant(SchemaAST.isUnion(node), void 0, {
232
231
  F: __dxlog_file,
233
- L: 377,
232
+ L: 379,
234
233
  S: void 0,
235
234
  A: [
236
235
  "SchemaAST.isUnion(node)",
@@ -239,7 +238,7 @@ var getDiscriminatedType = (node, value = {}) => {
239
238
  });
240
239
  invariant(value, void 0, {
241
240
  F: __dxlog_file,
242
- L: 378,
241
+ L: 380,
243
242
  S: void 0,
244
243
  A: [
245
244
  "value",
@@ -254,7 +253,7 @@ var getDiscriminatedType = (node, value = {}) => {
254
253
  const match = SchemaAST.getPropertySignatures(type).filter((prop) => props?.includes(prop.name.toString())).every((prop) => {
255
254
  invariant(SchemaAST.isLiteral(prop.type), void 0, {
256
255
  F: __dxlog_file,
257
- L: 389,
256
+ L: 391,
258
257
  S: void 0,
259
258
  A: [
260
259
  "SchemaAST.isLiteral(prop.type)",
@@ -272,7 +271,7 @@ var getDiscriminatedType = (node, value = {}) => {
272
271
  const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop);
273
272
  invariant(SchemaAST.isLiteral(literal.type), void 0, {
274
273
  F: __dxlog_file,
275
- L: 407,
274
+ L: 409,
276
275
  S: void 0,
277
276
  A: [
278
277
  "SchemaAST.isLiteral(literal.type)",
@@ -375,8 +374,7 @@ import * as Exit from "effect/Exit";
375
374
  import * as GlobalValue from "effect/GlobalValue";
376
375
  import * as Option2 from "effect/Option";
377
376
  import * as Runtime from "effect/Runtime";
378
- var spanSymbol = Symbol.for("effect/SpanAnnotation");
379
- var originalSymbol = Symbol.for("effect/OriginalAnnotation");
377
+ var spanSymbol = /* @__PURE__ */ Symbol.for("effect/SpanAnnotation");
380
378
  var spanToTrace = GlobalValue.globalValue("effect/Tracer/spanToTrace", () => /* @__PURE__ */ new WeakMap());
381
379
  var locationRegex = /\((.*)\)/g;
382
380
  var prettyErrorStack = (error, appendStacks = []) => {
@@ -386,7 +384,7 @@ var prettyErrorStack = (error, appendStacks = []) => {
386
384
  const span = error[spanSymbol];
387
385
  const lines = typeof error.stack === "string" ? error.stack.split("\n") : [];
388
386
  const out = [];
389
- let atStack = false;
387
+ let atStack = false, inCore = false, passedScheduler = false;
390
388
  for (let i = 0; i < lines.length; i++) {
391
389
  if (!atStack && !lines[i].startsWith(" at ")) {
392
390
  out.push(lines[i]);
@@ -403,6 +401,26 @@ var prettyErrorStack = (error, appendStacks = []) => {
403
401
  if (lines[i].includes("effect_internal_function")) {
404
402
  break;
405
403
  }
404
+ const filename = lines[i].match(/\/([a-zA-Z0-9_\-.]+):\d+:\d+\)$/)?.[1];
405
+ if (!inCore && [
406
+ "core-effect.ts"
407
+ ].includes(filename)) {
408
+ inCore = true;
409
+ }
410
+ if (inCore && !passedScheduler && [
411
+ "Scheduler.ts"
412
+ ].includes(filename)) {
413
+ passedScheduler = true;
414
+ continue;
415
+ }
416
+ if (passedScheduler && ![
417
+ "Scheduler.ts"
418
+ ].includes(filename)) {
419
+ inCore = false;
420
+ }
421
+ if (inCore) {
422
+ continue;
423
+ }
406
424
  out.push(lines[i].replace(/at .*effect_instruction_i.*\((.*)\)/, "at $1").replace(/EffectPrimitive\.\w+/, "<anonymous>").replace(/at Arguments\./, "at "));
407
425
  }
408
426
  if (span) {
@@ -433,9 +451,7 @@ var prettyErrorStack = (error, appendStacks = []) => {
433
451
  }
434
452
  }
435
453
  out.push(...appendStacks);
436
- if (error[originalSymbol]) {
437
- error = error[originalSymbol];
438
- }
454
+ error = Cause.originalError(error);
439
455
  if (error.cause) {
440
456
  error.cause = prettyErrorStack(error.cause);
441
457
  }
@@ -459,7 +475,7 @@ var causeToError = (cause) => {
459
475
  ];
460
476
  const getStackFrames = () => {
461
477
  const o = new Error();
462
- Error.captureStackTrace(o, getStackFrames);
478
+ Error.captureStackTrace(o, causeToError);
463
479
  return o.stack.split("\n").slice(1);
464
480
  };
465
481
  const stackFrames = getStackFrames();
@@ -474,19 +490,30 @@ var causeToError = (cause) => {
474
490
  var throwCause = (cause) => {
475
491
  throw causeToError(cause);
476
492
  };
477
- var unwrapExit = (exit) => {
478
- if (Exit.isSuccess(exit)) {
479
- return exit.value;
493
+ var unwrapExit = (exit2) => {
494
+ if (Exit.isSuccess(exit2)) {
495
+ return exit2.value;
480
496
  }
481
- return throwCause(exit.cause);
497
+ return throwCause(exit2.cause);
482
498
  };
483
499
  var runAndForwardErrors = async (effect, options) => {
484
- const exit = await Effect2.runPromiseExit(effect, options);
485
- return unwrapExit(exit);
486
- };
487
- var runInRuntime = async (runtime2, effect, options) => {
488
- const exit = await Runtime.runPromiseExit(runtime2, effect, options);
489
- return unwrapExit(exit);
500
+ const exit2 = await Effect2.runPromiseExit(effect, options);
501
+ return unwrapExit(exit2);
502
+ };
503
+ var runInRuntime = (...args) => {
504
+ if (args.length === 1) {
505
+ const [runtime2] = args;
506
+ return async (effect, options) => {
507
+ const exit2 = await Runtime.runPromiseExit(runtime2, effect, options);
508
+ return unwrapExit(exit2);
509
+ };
510
+ } else {
511
+ const [runtime2, effect, options] = args;
512
+ return (async () => {
513
+ const exit2 = await Runtime.runPromiseExit(runtime2, effect, options);
514
+ return unwrapExit(exit2);
515
+ })();
516
+ }
490
517
  };
491
518
  var promiseWithCauseCapture = (evaluate) => Effect2.promise(async (signal) => {
492
519
  try {
@@ -677,7 +704,7 @@ import * as Function2 from "effect/Function";
677
704
  import * as Option5 from "effect/Option";
678
705
  import * as SchemaAST2 from "effect/SchemaAST";
679
706
  import { decamelize } from "@dxos/util";
680
- var ParamKeyAnnotationId = Symbol.for("@dxos/schema/annotation/ParamKey");
707
+ var ParamKeyAnnotationId = /* @__PURE__ */ Symbol.for("@dxos/schema/annotation/ParamKey");
681
708
  var getParamKeyAnnotation = SchemaAST2.getAnnotation(ParamKeyAnnotationId);
682
709
  var ParamKeyAnnotation = (value) => (self) => self.annotations({
683
710
  [ParamKeyAnnotationId]: value
@@ -744,11 +771,32 @@ var runPromise2 = (provider) => async (effect) => {
744
771
  return unwrapExit(await effect.pipe(Runtime3.runPromiseExit(runtime2)));
745
772
  };
746
773
  var provide2 = (runtimeProvider) => (effect) => Effect5.flatMap(runtimeProvider, (runtime2) => Effect5.provide(effect, runtime2));
774
+
775
+ // src/Performance.ts
776
+ var Performance_exports = {};
777
+ __export(Performance_exports, {
778
+ addTrackEntry: () => addTrackEntry
779
+ });
780
+ import * as Effect6 from "effect/Effect";
781
+ var addTrackEntry = (options) => (effect) => Effect6.gen(function* () {
782
+ const start = performance.now();
783
+ const exit2 = yield* Effect6.exit(effect);
784
+ const resolvedOptions = typeof options === "function" ? options(exit2) : options;
785
+ performance.measure(resolvedOptions.name, {
786
+ start,
787
+ detail: {
788
+ ...resolvedOptions.detail,
789
+ devtools: resolvedOptions.devtools
790
+ }
791
+ });
792
+ return yield* exit2;
793
+ });
747
794
  export {
748
795
  dynamic_runtime_exports as DynamicRuntime,
749
796
  JsonPath,
750
797
  JsonProp,
751
798
  ParamKeyAnnotation,
799
+ Performance_exports as Performance,
752
800
  RuntimeProvider_exports as RuntimeProvider,
753
801
  UrlParser,
754
802
  VisitResult,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/ast.ts", "../../../src/atom-kvs.ts", "../../../src/context.ts", "../../../src/dynamic-runtime.ts", "../../../src/errors.ts", "../../../src/json-path.ts", "../../../src/resource.ts", "../../../src/url.ts", "../../../src/RuntimeProvider.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { invariant } from '@dxos/invariant';\nimport { isNonNullable } from '@dxos/util';\n\nimport { type JsonPath, type JsonProp } from './json-path';\n\n//\n// Refs\n// https://effect.website/docs/schema/introduction\n// https://www.npmjs.com/package/@effect/schema\n// https://effect-ts.github.io/effect/schema/SchemaAST.ts.html\n//\n\n/**\n * Unwraps and collects refinement filters.\n */\nconst reduceRefinements = (\n type: SchemaAST.AST,\n refinements: SchemaAST.Refinement['filter'][] = [],\n): { type: SchemaAST.AST; refinements: SchemaAST.Refinement['filter'][] } => {\n if (SchemaAST.isRefinement(type)) {\n const annotations = type.annotations;\n const filter = type.filter;\n const nextType = { ...type.from, annotations: { ...type.annotations, ...annotations } } as SchemaAST.AST;\n return reduceRefinements(nextType, [...refinements, filter]);\n }\n\n return { type, refinements };\n};\n\n/**\n * Get the base type of a property.\n *\n * Unwraps refinements and optional unions.\n */\nexport const getBaseType = (\n prop: SchemaAST.PropertySignature | SchemaProperty,\n): { type: SchemaAST.AST; refinements: SchemaAST.Refinement['filter'][] } => {\n const encoded = SchemaAST.encodedBoundAST(prop.type);\n // Extract property ast from optional union.\n const unwrapped = prop.isOptional && encoded._tag === 'Union' ? encoded.types[0] : encoded;\n return reduceRefinements(unwrapped);\n};\n\nexport type SchemaProperty = Pick<SchemaAST.PropertySignature, 'name' | 'type' | 'isOptional' | 'isReadonly'> & {\n /** Can be used to validate the property to the spec of the initial AST. */\n refinements: SchemaAST.Refinement['filter'][];\n};\n\n/**\n * Get the property types of an AST.\n */\nexport const getProperties = (ast: SchemaAST.AST): SchemaProperty[] => {\n const properties = SchemaAST.getPropertySignatures(ast);\n return properties.map((prop) => ({\n ...getBaseType(prop),\n name: prop.name,\n isOptional: prop.isOptional,\n isReadonly: prop.isReadonly,\n }));\n};\n\n//\n// Branded types\n//\n\nexport enum VisitResult {\n CONTINUE = 0,\n /**\n * Skip visiting children.\n */\n SKIP = 1,\n /**\n * Stop traversing immediately.\n */\n EXIT = 2,\n}\n\nexport type Path = (string | number)[];\n\nexport type TestFn = (node: SchemaAST.AST, path: Path, depth: number) => VisitResult | boolean | undefined;\n\nexport type VisitorFn = (node: SchemaAST.AST, path: Path, depth: number) => void;\n\n/**\n * Visit leaf nodes.\n * Refs:\n * - https://github.com/syntax-tree/unist-util-visit?tab=readme-ov-file#visitor\n * - https://github.com/syntax-tree/unist-util-is?tab=readme-ov-file#test\n */\nexport const visit = (node: SchemaAST.AST, testOrVisitor: TestFn | VisitorFn, visitor: VisitorFn): void => {\n visitNode(node, testOrVisitor as TestFn, visitor);\n};\n\nconst visitNode = (\n node: SchemaAST.AST,\n test: TestFn | undefined,\n visitor: VisitorFn,\n path: Path = [],\n depth = 0,\n): VisitResult | undefined => {\n const $result = test?.(node, path, depth);\n const result: VisitResult =\n $result === undefined\n ? VisitResult.CONTINUE\n : typeof $result === 'boolean'\n ? $result\n ? VisitResult.CONTINUE\n : VisitResult.SKIP\n : $result;\n\n if (result === VisitResult.EXIT) {\n return result;\n }\n if (result !== VisitResult.SKIP) {\n visitor(node, path, depth);\n }\n\n // Object.\n if (SchemaAST.isTypeLiteral(node)) {\n for (const prop of SchemaAST.getPropertySignatures(node)) {\n const currentPath = [...path, prop.name.toString()];\n const result = visitNode(prop.type, test, visitor, currentPath, depth + 1);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Array.\n else if (SchemaAST.isTupleType(node)) {\n for (const [i, element] of node.elements.entries()) {\n const currentPath = [...path, i];\n const result = visitNode(element.type, test, visitor, currentPath, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Branching union (e.g., optional, discriminated unions).\n else if (SchemaAST.isUnion(node)) {\n for (const type of node.types) {\n const result = visitNode(type, test, visitor, path, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Refinement.\n else if (SchemaAST.isRefinement(node)) {\n const result = visitNode(node.from, test, visitor, path, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n\n // TODO(burdon): Transforms?\n};\n\n/**\n * Recursively descend into AST to find first node that passes the test.\n */\n// TODO(burdon): Rewrite using visitNode?\nexport const findNode = (node: SchemaAST.AST, test: (node: SchemaAST.AST) => boolean): SchemaAST.AST | undefined => {\n if (test(node)) {\n return node;\n }\n\n // Object.\n else if (SchemaAST.isTypeLiteral(node)) {\n for (const prop of SchemaAST.getPropertySignatures(node)) {\n const child = findNode(prop.type, test);\n if (child) {\n return child;\n }\n }\n for (const prop of getIndexSignatures(node)) {\n const child = findNode(prop.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Tuple.\n else if (SchemaAST.isTupleType(node)) {\n for (const [_, element] of node.elements.entries()) {\n const child = findNode(element.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Branching union (e.g., optional, discriminated unions).\n else if (SchemaAST.isUnion(node)) {\n if (isLiteralUnion(node)) {\n return undefined;\n }\n\n for (const type of node.types) {\n const child = findNode(type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Refinement.\n else if (SchemaAST.isRefinement(node)) {\n return findNode(node.from, test);\n }\n};\n\n/**\n * Get the AST node for the given property (dot-path).\n */\nexport const findProperty = (\n schema: Schema.Schema.AnyNoContext,\n path: JsonPath | JsonProp,\n): SchemaAST.AST | undefined => {\n const getProp = (node: SchemaAST.AST, path: JsonProp[]): SchemaAST.AST | undefined => {\n const [name, ...rest] = path;\n const typeNode = findNode(node, SchemaAST.isTypeLiteral);\n invariant(typeNode);\n for (const prop of SchemaAST.getPropertySignatures(typeNode)) {\n if (prop.name === name) {\n if (rest.length) {\n return getProp(prop.type, rest);\n } else {\n return prop.type;\n }\n }\n }\n };\n\n return getProp(schema.ast, path.split('.') as JsonProp[]);\n};\n\n//\n// Annotations\n//\n\nconst defaultAnnotations: Record<string, SchemaAST.Annotated> = {\n ['ObjectKeyword' as const]: SchemaAST.objectKeyword,\n ['StringKeyword' as const]: SchemaAST.stringKeyword,\n ['NumberKeyword' as const]: SchemaAST.numberKeyword,\n ['BooleanKeyword' as const]: SchemaAST.booleanKeyword,\n};\n\n/**\n * Get annotation or return undefined.\n * @param annotationId\n * @param noDefault If true, then return undefined for effect library defined values.\n */\nexport const getAnnotation =\n <T>(annotationId: symbol, noDefault = true) =>\n (node: SchemaAST.AST): T | undefined => {\n // Title fallback seems to be the identifier.\n const id = Function.pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);\n const value = Function.pipe(SchemaAST.getAnnotation<T>(annotationId)(node), Option.getOrUndefined);\n if (noDefault && (value === defaultAnnotations[node._tag]?.annotations[annotationId] || value === id)) {\n return undefined;\n }\n\n return value;\n };\n\n/**\n * Recursively descend into AST to find first matching annotations.\n * Optionally skips default annotations for basic types (e.g., 'a string').\n */\n// TODO(burdon): Convert to effect pattern (i.e., return operator like getAnnotation).\nexport const findAnnotation = <T>(node: SchemaAST.AST, annotationId: symbol, noDefault = true): T | undefined => {\n const getAnnotationById = getAnnotation(annotationId, noDefault);\n\n const getBaseAnnotation = (node: SchemaAST.AST): T | undefined => {\n const value = getAnnotationById(node);\n if (value !== undefined) {\n return value as T;\n }\n\n if (SchemaAST.isUnion(node)) {\n if (isOption(node)) {\n return getAnnotationById(node.types[0]) as T;\n }\n }\n };\n\n return getBaseAnnotation(node);\n};\n\n//\n// Unions\n//\n\n/**\n * Effect Schema.optional creates a union type with undefined as the second type.\n */\nexport const isOption = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && node.types.length === 2 && SchemaAST.isUndefinedKeyword(node.types[1]);\n};\n\n/**\n * Determines if the node is a union of literal types.\n */\nexport const isLiteralUnion = (node: SchemaAST.AST): node is SchemaAST.Union<SchemaAST.Literal> => {\n return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);\n};\n\n/**\n * Determines if the node is an array type.\n */\nexport const isArrayType = (node: SchemaAST.AST): node is SchemaAST.TupleType => {\n return SchemaAST.isTupleType(node) && node.elements.length === 0 && node.rest.length === 1;\n};\n\n/**\n * Get the type of the array elements.\n */\nexport const getArrayElementType = (node: SchemaAST.AST): SchemaAST.AST | undefined => {\n return isArrayType(node) ? node.rest.at(0)?.type : undefined;\n};\n\n/**\n * Determines if the node is a tuple type.\n */\nexport const isTupleType = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isTupleType(node) && node.elements.length > 0;\n};\n\n/**\n * Determines if the node is a discriminated union.\n */\nexport const isDiscriminatedUnion = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;\n};\n\n/**\n * Get the discriminating properties for the given union type.\n */\nexport const getDiscriminatingProps = (node: SchemaAST.AST): string[] | undefined => {\n invariant(SchemaAST.isUnion(node));\n if (isOption(node)) {\n return;\n }\n\n // Get common literals across all types.\n return node.types.reduce<string[]>((shared, type) => {\n const props = SchemaAST.getPropertySignatures(type)\n // TODO(burdon): Should check each literal is unique.\n .filter((p) => SchemaAST.isLiteral(p.type))\n .map((p) => p.name.toString());\n\n // Return common literals.\n return shared.length === 0 ? props : shared.filter((prop) => props.includes(prop));\n }, []);\n};\n\n/**\n * Get the discriminated type for the given value.\n */\nexport const getDiscriminatedType = (\n node: SchemaAST.AST,\n value: Record<string, any> = {},\n): SchemaAST.AST | undefined => {\n invariant(SchemaAST.isUnion(node));\n invariant(value);\n const props = getDiscriminatingProps(node);\n if (!props?.length) {\n return;\n }\n\n // Match provided values.\n for (const type of node.types) {\n const match = SchemaAST.getPropertySignatures(type)\n .filter((prop) => props?.includes(prop.name.toString()))\n .every((prop) => {\n invariant(SchemaAST.isLiteral(prop.type));\n return prop.type.literal === value[prop.name.toString()];\n });\n\n if (match) {\n return type;\n }\n }\n\n // Create union of discriminating properties.\n // NOTE: This may not work with non-overlapping variants.\n // TODO(burdon): Iterate through props and knock-out variants that don't match.\n const fields = Object.fromEntries(\n props\n .map((prop) => {\n const literals = node.types\n .map((type) => {\n const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop)!;\n invariant(SchemaAST.isLiteral(literal.type));\n return literal.type.literal;\n })\n .filter(isNonNullable);\n\n return literals.length ? [prop, Schema.Literal(...literals)] : undefined;\n })\n .filter(isNonNullable),\n );\n\n const schema = Schema.Struct(fields);\n return schema.ast;\n};\n\n/**\n * Determines if the node is a nested object type.\n */\nexport const isNestedType = (node: SchemaAST.AST): boolean => {\n return (\n SchemaAST.isDeclaration(node) ||\n SchemaAST.isObjectKeyword(node) ||\n SchemaAST.isTypeLiteral(node) ||\n // TODO(wittjosiah): Tuples are actually arrays.\n isTupleType(node) ||\n isDiscriminatedUnion(node)\n );\n};\n\n/**\n * Maps AST nodes.\n * The user is responsible for recursively calling {@link mapAst} on the SchemaAST.\n * NOTE: Will evaluate suspended ASTs.\n */\nexport const mapAst = (\n ast: SchemaAST.AST,\n f: (ast: SchemaAST.AST, key: keyof any | undefined) => SchemaAST.AST,\n): SchemaAST.AST => {\n switch (ast._tag) {\n case 'TypeLiteral': {\n return new SchemaAST.TypeLiteral(\n ast.propertySignatures.map(\n (prop) =>\n new SchemaAST.PropertySignature(\n prop.name,\n f(prop.type, prop.name),\n prop.isOptional,\n prop.isReadonly,\n prop.annotations,\n ),\n ),\n ast.indexSignatures,\n ast.annotations,\n );\n }\n case 'Union': {\n return SchemaAST.Union.make(ast.types.map(f), ast.annotations);\n }\n case 'TupleType': {\n return new SchemaAST.TupleType(\n ast.elements.map((t, index) => new SchemaAST.OptionalType(f(t.type, index), t.isOptional, t.annotations)),\n ast.rest.map((t) => new SchemaAST.Type(f(t.type, undefined), t.annotations)),\n ast.isReadonly,\n ast.annotations,\n );\n }\n case 'Suspend': {\n const newAst = f(ast.f(), undefined);\n return new SchemaAST.Suspend(() => newAst, ast.annotations);\n }\n default: {\n // TODO(dmaretskyi): Support more nodes.\n return ast;\n }\n }\n};\n\nconst getIndexSignatures = (ast: SchemaAST.AST): Array<SchemaAST.IndexSignature> => {\n const annotation = SchemaAST.getSurrogateAnnotation(ast);\n if (Option.isSome(annotation)) {\n return getIndexSignatures(annotation.value);\n }\n switch (ast._tag) {\n case 'TypeLiteral':\n return ast.indexSignatures.slice();\n case 'Suspend':\n return getIndexSignatures(ast.f());\n case 'Refinement':\n return getIndexSignatures(ast.from);\n }\n return [];\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as BrowserKeyValueStore from '@effect/platform-browser/BrowserKeyValueStore';\nimport { Atom } from '@effect-atom/atom-react';\nimport type * as Schema from 'effect/Schema';\n\n// TODO(wittjosiah): This is currently provided for convenience but maybe should be removed.\nconst defaultRuntime = Atom.runtime(BrowserKeyValueStore.layerLocalStorage);\n\n/**\n * Creates a KVS-backed atom for structured settings using Atom.kvs.\n * The entire object is stored as a single localStorage key with JSON serialization.\n *\n * @param options.key - The localStorage key to store the value under.\n * @param options.schema - Effect Schema for the value type.\n * @param options.defaultValue - Function returning the default value.\n * @param options.runtime - Optional custom Atom runtime (defaults to localStorage).\n * @returns A writable atom that persists to localStorage.\n */\nexport const createKvsStore = <T extends Record<string, any>>(options: {\n key: string;\n schema: Schema.Schema<T>;\n defaultValue: () => T;\n runtime?: ReturnType<typeof Atom.runtime>;\n}): Atom.Writable<T> => {\n const runtime = options.runtime ?? defaultRuntime;\n return Atom.kvs({\n runtime,\n key: options.key,\n schema: options.schema,\n defaultValue: options.defaultValue,\n }).pipe(Atom.keepAlive);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport type * as Scope from 'effect/Scope';\n\nimport { Context } from '@dxos/context';\n\n// TODO(dmaretskyi): Error handling.\nexport const contextFromScope = (): Effect.Effect<Context, never, Scope.Scope> =>\n Effect.gen(function* () {\n const ctx = new Context();\n yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));\n return ctx;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport type * as Fiber from 'effect/Fiber';\nimport type * as ManagedRuntime from 'effect/ManagedRuntime';\nimport * as Option from 'effect/Option';\nimport * as Runtime from 'effect/Runtime';\n\nimport { unwrapExit } from './errors';\n\n/**\n * Helper type to construct a union of tag identifiers from an array of tags.\n */\nexport type TagsToContext<Tags extends ReadonlyArray<Context.Tag<any, any>>> = Tags extends readonly [\n infer Head,\n ...infer Tail,\n]\n ? Head extends Context.Tag<infer Id, any>\n ? Tail extends ReadonlyArray<Context.Tag<any, any>>\n ? Id | TagsToContext<Tail>\n : Id\n : never\n : never;\n\n/**\n * A runtime wrapper that validates required tags are available at runtime\n * while providing type-level guarantees that effects require those tags.\n */\nexport interface DynamicRuntime<Tags extends ReadonlyArray<Context.Tag<any, any>>> {\n /**\n * Run an effect as a promise that requires the specified tags.\n */\n readonly runPromise: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => Promise<A>;\n\n /**\n * Run an effect synchronously that requires the specified tags.\n */\n readonly runSync: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => A;\n\n /**\n * Run an effect synchronously returning exit that requires the specified tags.\n */\n readonly runSyncExit: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => Exit.Exit<A, E>;\n\n /**\n * Run an effect as a promise returning exit that requires the specified tags.\n */\n readonly runPromiseExit: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => Promise<Exit.Exit<A, E>>;\n\n /**\n * Fork an effect that requires the specified tags.\n */\n readonly runFork: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => Fiber.RuntimeFiber<A, E>;\n\n /**\n * Get the runtime as an effect that requires the specified tags.\n */\n readonly runtimeEffect: Effect.Effect<Runtime.Runtime<TagsToContext<Tags>>, never, never>;\n\n /**\n * Dispose the underlying managed runtime.\n */\n readonly dispose: () => Promise<void>;\n\n /**\n * Get the underlying managed runtime.\n */\n readonly managedRuntime: ManagedRuntime.ManagedRuntime<any, any>;\n}\n\n/**\n * Validate that all required tags are present in the runtime context.\n */\nconst validateTags = <Tags extends ReadonlyArray<Context.Tag<any, any>>>(\n context: Context.Context<any>,\n tags: Tags,\n): Effect.Effect<void> =>\n Effect.gen(function* () {\n const missingTags: string[] = [];\n for (const tag of tags) {\n const option = Context.getOption(context, tag);\n if (Option.isNone(option)) {\n missingTags.push(tag.key);\n }\n }\n\n if (missingTags.length > 0) {\n return yield* Effect.die(new Error(`Missing required tags in runtime: ${missingTags.join(', ')}`));\n }\n });\n\n/**\n * Create a dynamic runtime from a managed runtime and validate required tags.\n */\nexport function make<const Tags extends ReadonlyArray<Context.Tag<any, any>>>(\n managedRuntime: ManagedRuntime.ManagedRuntime<any, any> | ManagedRuntime.ManagedRuntime<never, never>,\n tags: Tags,\n): DynamicRuntime<Tags> {\n type RequiredContext = TagsToContext<Tags>;\n const managedRuntimeAny = managedRuntime as ManagedRuntime.ManagedRuntime<any, any>;\n\n // Cache for the validated runtime - once resolved, can be used synchronously.\n let cachedRuntime: Runtime.Runtime<RequiredContext> | undefined;\n\n // Cache validated runtime for async operations.\n let validatedRuntimePromise: Promise<Runtime.Runtime<RequiredContext>> | undefined;\n\n const getValidatedRuntimeAsync = async (): Promise<Runtime.Runtime<RequiredContext>> => {\n if (!validatedRuntimePromise) {\n validatedRuntimePromise = managedRuntimeAny.runPromise(\n Effect.gen(function* () {\n const rt = yield* managedRuntimeAny.runtimeEffect;\n yield* validateTags(rt.context, tags);\n return rt as Runtime.Runtime<RequiredContext>;\n }),\n );\n }\n return validatedRuntimePromise;\n };\n\n // Get validated runtime for sync operations.\n const getValidatedRuntime = (): Runtime.Runtime<RequiredContext> => {\n const validationExit = managedRuntimeAny.runSyncExit(\n Effect.gen(function* () {\n const rt = yield* managedRuntimeAny.runtimeEffect;\n yield* validateTags(rt.context, tags);\n return rt as Runtime.Runtime<RequiredContext>;\n }),\n );\n return unwrapExit(validationExit);\n };\n\n return {\n managedRuntime: managedRuntimeAny,\n runPromise: async <A, E>(effect: Effect.Effect<A, E, RequiredContext>): Promise<A> => {\n const runtime = await getValidatedRuntimeAsync();\n return Runtime.runPromise(runtime)(effect);\n },\n runSync: <A, E>(effect: Effect.Effect<A, E, RequiredContext>): A => {\n const runtime = getValidatedRuntime();\n return Runtime.runSync(runtime)(effect);\n },\n runSyncExit: <A, E>(effect: Effect.Effect<A, E, RequiredContext>): Exit.Exit<A, E> => {\n const validationExit = managedRuntimeAny.runSyncExit(\n Effect.gen(function* () {\n const rt = yield* managedRuntimeAny.runtimeEffect;\n yield* validateTags(rt.context, tags);\n return rt as Runtime.Runtime<RequiredContext>;\n }),\n );\n if (Exit.isSuccess(validationExit)) {\n const runtime = validationExit.value;\n return Runtime.runSyncExit(runtime)(effect);\n }\n return validationExit as Exit.Exit<A, E>;\n },\n runPromiseExit: async <A, E>(effect: Effect.Effect<A, E, RequiredContext>): Promise<Exit.Exit<A, E>> => {\n try {\n const runtime = await getValidatedRuntimeAsync();\n return Runtime.runPromiseExit(runtime)(effect);\n } catch (error) {\n // If validation failed, return a failure exit\n return Exit.die(error);\n }\n },\n runFork: <A, E>(effect: Effect.Effect<A, E, RequiredContext>): Fiber.RuntimeFiber<A, E> => {\n const runtime = getValidatedRuntime();\n return Runtime.runFork(runtime)(effect);\n },\n runtimeEffect: Effect.gen(function* () {\n // Return cached runtime if available.\n if (cachedRuntime) {\n return cachedRuntime;\n }\n const rt = yield* managedRuntimeAny.runtimeEffect;\n yield* validateTags(rt.context, tags);\n const runtime = rt as Runtime.Runtime<RequiredContext>;\n // Cache for future sync calls.\n cachedRuntime = runtime;\n return runtime;\n }).pipe(\n Effect.catchAll(() =>\n // This should never happen since validateTags uses Effect.die\n Effect.die(new Error('Unexpected error in runtimeEffect validation')),\n ),\n ),\n dispose: async (): Promise<void> => {\n await managedRuntimeAny.dispose();\n },\n };\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Cause from 'effect/Cause';\nimport * as Chunk from 'effect/Chunk';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport * as GlobalValue from 'effect/GlobalValue';\nimport * as Option from 'effect/Option';\nimport * as Runtime from 'effect/Runtime';\nimport type * as Tracer from 'effect/Tracer';\n\nconst spanSymbol = Symbol.for('effect/SpanAnnotation');\nconst originalSymbol = Symbol.for('effect/OriginalAnnotation');\nconst spanToTrace = GlobalValue.globalValue('effect/Tracer/spanToTrace', () => new WeakMap());\nconst locationRegex = /\\((.*)\\)/g;\n\n/**\n * Adds effect spans.\n * Removes effect internal functions.\n * Unwraps error proxy.\n */\nconst prettyErrorStack = (error: any, appendStacks: string[] = []): any => {\n if (typeof error !== 'object' || error === null) {\n return error;\n }\n\n const span = error[spanSymbol];\n\n const lines = typeof error.stack === 'string' ? error.stack.split('\\n') : [];\n const out = [];\n\n let atStack = false;\n for (let i = 0; i < lines.length; i++) {\n if (!atStack && !lines[i].startsWith(' at ')) {\n out.push(lines[i]);\n continue;\n }\n atStack = true;\n\n if (lines[i].includes(' at new BaseEffectError') || lines[i].includes(' at new YieldableError')) {\n i++;\n continue;\n }\n if (lines[i].includes('Generator.next')) {\n break;\n }\n if (lines[i].includes('effect_internal_function')) {\n break;\n }\n out.push(\n lines[i]\n .replace(/at .*effect_instruction_i.*\\((.*)\\)/, 'at $1')\n .replace(/EffectPrimitive\\.\\w+/, '<anonymous>')\n .replace(/at Arguments\\./, 'at '),\n );\n }\n\n if (span) {\n let current: Tracer.Span | Tracer.AnySpan | undefined = span;\n let i = 0;\n while (current && current._tag === 'Span' && i < 10) {\n const stackFn = spanToTrace.get(current);\n if (typeof stackFn === 'function') {\n const stack = stackFn();\n if (typeof stack === 'string') {\n const locationMatchAll = stack.matchAll(locationRegex);\n let match = false;\n for (const [, location] of locationMatchAll) {\n match = true;\n out.push(` at ${current.name} (${location})`);\n }\n if (!match) {\n out.push(` at ${current.name} (${stack.replace(/^at /, '')})`);\n }\n } else {\n out.push(` at ${current.name}`);\n }\n } else {\n out.push(` at ${current.name}`);\n }\n current = Option.getOrUndefined(current.parent);\n i++;\n }\n }\n\n out.push(...appendStacks);\n\n if (error[originalSymbol]) {\n error = error[originalSymbol];\n }\n if (error.cause) {\n error.cause = prettyErrorStack(error.cause);\n }\n\n Object.defineProperty(error, 'stack', {\n value: out.join('\\n'),\n writable: true,\n enumerable: false,\n configurable: true,\n });\n\n return error;\n};\n\n/**\n * Converts a cause to an error.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const causeToError = (cause: Cause.Cause<any>): Error => {\n if (Cause.isEmpty(cause)) {\n return new Error('Fiber failed without a cause');\n } else if (Cause.isInterruptedOnly(cause)) {\n return new Error('Fiber was interrupted');\n } else {\n const errors = [...Chunk.toArray(Cause.failures(cause)), ...Chunk.toArray(Cause.defects(cause))];\n\n const getStackFrames = (): string[] => {\n // Bun requies the target object for `captureStackTrace` to be an Error.\n const o = new Error();\n Error.captureStackTrace(o, getStackFrames);\n return o.stack!.split('\\n').slice(1);\n };\n\n const stackFrames = getStackFrames();\n const newErrors = errors.map((error) => prettyErrorStack(error, stackFrames));\n\n if (newErrors.length === 1) {\n return newErrors[0];\n } else {\n return new AggregateError(newErrors);\n }\n }\n};\n\n/**\n * Throws an error based on the cause.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const throwCause = (cause: Cause.Cause<any>): never => {\n throw causeToError(cause);\n};\n\nexport const unwrapExit = <A>(exit: Exit.Exit<A, any>): A => {\n if (Exit.isSuccess(exit)) {\n return exit.value;\n }\n\n return throwCause(exit.cause);\n};\n\n/**\n * Runs the embedded effect asynchronously and throws any failures and defects as errors.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const runAndForwardErrors = async <A, E>(\n effect: Effect.Effect<A, E, never>,\n options?: { signal?: AbortSignal },\n): Promise<A> => {\n const exit = await Effect.runPromiseExit(effect, options);\n return unwrapExit(exit);\n};\n\nexport const runInRuntime = async <A, E, R>(\n runtime: Runtime.Runtime<R>,\n effect: Effect.Effect<A, E, R>,\n options?: { signal?: AbortSignal },\n): Promise<A> => {\n const exit = await Runtime.runPromiseExit(runtime, effect, options);\n return unwrapExit(exit);\n};\n\n/**\n * Like `Effect.promise` but also caputes spans for defects.\n * Workaround for: https://github.com/Effect-TS/effect/issues/5436\n */\nexport const promiseWithCauseCapture: <A>(evaluate: (signal: AbortSignal) => PromiseLike<A>) => Effect.Effect<A> = (\n evaluate,\n) =>\n Effect.promise(async (signal) => {\n try {\n const result = await evaluate(signal);\n return Effect.succeed(result);\n } catch (err) {\n return Effect.die(err);\n }\n }).pipe(Effect.flatten);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport { JSONPath } from 'jsonpath-plus';\n\nimport { invariant } from '@dxos/invariant';\nimport { getDeep, setDeep } from '@dxos/util';\n\nexport type JsonProp = string & { __JsonPath: true; __JsonProp: true };\nexport type JsonPath = string & { __JsonPath: true };\n\n// TODO(burdon): Start with \"$.\"?\n\nconst PATH_REGEX = /^($|[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*|\\[\\d+\\](?:\\.)?)*$)/;\n\nconst PROP_REGEX = /^\\w+$/;\n\n/**\n * https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html\n */\n// TODO(burdon): Keys could be arbitrary strings.\nexport const JsonPath = Schema.String.pipe(Schema.pattern(PATH_REGEX)).annotations({\n title: 'JSON path',\n description: 'JSON path to a property',\n}) as any as Schema.Schema<JsonPath>;\nexport const JsonProp = Schema.NonEmptyString.pipe(\n Schema.pattern(PROP_REGEX, {\n message: () => 'Property name must contain only letters, numbers, and underscores',\n }),\n) as any as Schema.Schema<JsonProp>;\n\nexport const isJsonPath = (value: unknown): value is JsonPath => {\n return Option.isSome(Schema.validateOption(JsonPath)(value));\n};\n\n/**\n * Creates a JsonPath from an array of path segments.\n *\n * Currently supports:\n * - Simple property access (e.g., 'foo.bar')\n * - Array indexing with non-negative integers (e.g., 'foo[0]')\n * - Identifiers starting with letters, underscore, or $ (e.g., '$foo', '_bar')\n * - Dot notation for nested properties (e.g., 'foo.bar.baz')\n *\n * Does not support (yet?).\n * - Recursive descent (..)\n * - Wildcards (*)\n * - Array slicing\n * - Filters\n * - Negative indices\n *\n * @param path Array of string or number segments\n * @returns Valid JsonPath or undefined if invalid\n */\nexport const createJsonPath = (path: readonly (string | number)[]): JsonPath => {\n const candidatePath = path\n .map((p, i) => {\n if (typeof p === 'number') {\n return `[${p}]`;\n } else {\n return i === 0 ? p : `.${p}`;\n }\n })\n .join('');\n\n invariant(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`);\n return candidatePath;\n};\n\n/**\n * Converts Effect validation path format (e.g. \"addresses.[0].zip\")\n * to JsonPath format (e.g., \"addresses[0].zip\")\n */\nexport const fromEffectValidationPath = (effectPath: string): JsonPath => {\n // Handle array notation: convert \"prop.[0]\" to \"prop[0]\"\n const jsonPath = effectPath.replace(/\\.\\[(\\d+)\\]/g, '[$1]');\n invariant(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`);\n return jsonPath;\n};\n\n/**\n * Splits a JsonPath into its constituent parts.\n * Handles property access and array indexing.\n */\nexport const splitJsonPath = (path: JsonPath): (string | number)[] => {\n if (!isJsonPath(path)) {\n return [];\n }\n\n return (\n path\n .match(/[a-zA-Z_$][\\w$]*|\\[\\d+\\]/g)\n ?.map((part) => part.replace(/[[\\]]/g, ''))\n .map((part) => {\n const parsed = Number.parseInt(part, 10);\n return Number.isNaN(parsed) ? part : parsed;\n }) ?? []\n );\n};\n\n/**\n * Applies a JsonPath to an object.\n */\n// TODO(burdon): Reconcile with getValue.\nexport const getField = (object: any, path: JsonPath): any => {\n // By default, JSONPath returns an array of results.\n return JSONPath({ path, json: object })[0];\n};\n\n/**\n * Get value from object using JsonPath.\n */\nexport const getValue = <T extends object>(obj: T, path: JsonPath): any => {\n return getDeep(obj, splitJsonPath(path));\n};\n\n/**\n * Set value on object using JsonPath.\n */\nexport const setValue = <T extends object>(obj: T, path: JsonPath, value: any): T => {\n return setDeep(obj, splitJsonPath(path), value);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport type * as Scope from 'effect/Scope';\n\nimport type { Lifecycle } from '@dxos/context';\n\n/**\n * Acquires a resource and releases it when the scope is closed.\n */\nexport const acquireReleaseResource = <T extends Lifecycle>(\n getResource: () => T,\n): Effect.Effect<T, never, Scope.Scope> =>\n Effect.acquireRelease(\n Effect.gen(function* () {\n const resource = getResource();\n yield* Effect.promise(async () => {\n await resource.open?.();\n return undefined;\n });\n return resource;\n }),\n (resource) =>\n Effect.promise(async () => {\n await resource.close?.();\n return undefined;\n }),\n );\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport type * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { decamelize } from '@dxos/util';\n\nconst ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKey');\n\ntype ParamKeyAnnotationValue = { key: string };\n\nexport const getParamKeyAnnotation: (annotated: SchemaAST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n SchemaAST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends Schema.Annotable.All>(self: S): Schema.Annotable.Self<S> =>\n self.annotations({ [ParamKeyAnnotationId]: value });\n\n/**\n * HTTP params parser.\n * Supports custom key serialization.\n */\nexport class UrlParser<T extends Record<string, any>> {\n constructor(private readonly _schema: Schema.Struct<T>) {}\n\n /**\n * Parse URL params.\n */\n parse(_url: string): T {\n const url = new URL(_url);\n return Object.entries(this._schema.fields).reduce<Record<string, any>>((params, [key, type]) => {\n let value = url.searchParams.get(decamelize(key));\n if (value == null) {\n value = url.searchParams.get(key);\n }\n\n if (value != null) {\n if (SchemaAST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (SchemaAST.isBooleanKeyword(type.ast)) {\n params[key] = value === 'true' || value === '1';\n } else {\n params[key] = value;\n }\n }\n\n return params;\n }, {}) as T;\n }\n\n /**\n * Return URL with encoded params.\n */\n create(_url: string, params: T): URL {\n const url = new URL(_url);\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n const field = this._schema.fields[key];\n if (field) {\n const { key: serializedKey } = Function.pipe(\n getParamKeyAnnotation(field.ast),\n Option.getOrElse(() => ({\n key: decamelize(key),\n })),\n );\n\n url.searchParams.set(serializedKey, String(value));\n }\n }\n });\n\n return url;\n }\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Runtime from 'effect/Runtime';\n\nimport { runAndForwardErrors, unwrapExit } from './errors';\n\n/**\n * Provides effect runtime with services to run effects.\n */\nexport type RuntimeProvider<R> = Effect.Effect<Runtime.Runtime<R>>;\n\n/**\n * @returns Runtime provider from the current context.\n */\nexport const currentRuntime = <R = never>() => Effect.runtime<R>().pipe(Effect.map(Effect.succeed));\n\n/**\n * Run effect, within runitme, clean errors and fix stack-traces.\n */\nexport const runPromise =\n <R>(provider: RuntimeProvider<R>) =>\n async <A>(effect: Effect.Effect<A, any, R>): Promise<A> => {\n const runtime = await runAndForwardErrors(provider);\n return unwrapExit(await effect.pipe(Runtime.runPromiseExit(runtime)));\n };\n\n/**\n * Provide services from runtime provider to effect.\n */\nexport const provide: {\n <R2>(runtime: RuntimeProvider<R2>): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, R2>>;\n} = (runtimeProvider) => (effect) => Effect.flatMap(runtimeProvider, (runtime) => Effect.provide(effect, runtime));\n"],
5
- "mappings": ";;;;;;AAIA,YAAYA,cAAc;AAC1B,YAAYC,YAAY;AACxB,YAAYC,Y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AAoBF,QAAAA;AAC1C,SAAOG,WAAW,MAAMF,OAAOL,KAAaQ,wBAAeT,QAAAA,CAAAA,CAAAA;AAC7D;AAKK,IAAMU,WAET,CAACC,oBAAoB,CAACL,WAAkBM,gBAAQD,iBAAiB,CAACX,aAAmBU,gBAAQJ,QAAQN,QAAAA,CAAAA;",
6
- "names": ["Function", "Option", "Schema", "SchemaAST", "invariant", "isNonNullable", "reduceRefinements", "type", "refinements", "isRefinement", "annotations", "filter", "nextType", "from", "getBaseType", "prop", "encoded", "encodedBoundAST", "unwrapped", "isOptional", "_tag", "types", "getProperties", "ast", "properties", "getPropertySignatures", "map", "name", "isReadonly", "VisitResult", "visit", "node", "testOrVisitor", "visitor", "visitNode", "test", "path", "depth", "$result", "result", "undefined", "isTypeLiteral", "currentPath", "toString", "isTupleType", "i", "element", "elements", "entries", "isUnion", "findNode", "child", "getIndexSignatures", "_", "isLiteralUnion", "findProperty", "schema", "getProp", "rest", "typeNode", "length", "split", "defaultAnnotations", "objectKeyword", "stringKeyword", "numberKeyword", "booleanKeyword", "getAnnotation", "annotationId", "noDefault", "id", "pipe", "getIdentifierAnnotation", "getOrUndefined", "value", "findAnnotation", "getAnnotationById", "getBaseAnnotation", "isOption", "isUndefinedKeyword", "every", "isLiteral", "isArrayType", "getArrayElementType", "at", "isDiscriminatedUnion", "getDiscriminatingProps", "reduce", "shared", "props", "p", "includes", "getDiscriminatedType", "match", "literal", "fields", "Object", "fromEntries", "literals", "find", "Literal", "Struct", "isNestedType", "isDeclaration", "isObjectKeyword", "mapAst", "f", "TypeLiteral", "propertySignatures", "PropertySignature", "indexSignatures", "Union", "make", "TupleType", "t", "index", "OptionalType", "Type", "newAst", "Suspend", "annotation", "getSurrogateAnnotation", "isSome", "slice", "BrowserKeyValueStore", "Atom", "defaultRuntime", "Atom", "runtime", "layerLocalStorage", "createKvsStore", "options", "kvs", "key", "schema", "defaultValue", "pipe", "keepAlive", "Effect", "Context", "contextFromScope", "gen", "ctx", "addFinalizer", "promise", "dispose", "Context", "Effect", "Exit", "Option", "Runtime", "Cause", "Chunk", "Effect", "Exit", "GlobalValue", "Option", "Runtime", "spanSymbol", "Symbol", "for", "originalSymbol", "spanToTrace", "globalValue", "WeakMap", "locationRegex", "prettyErrorStack", "error", "appendStacks", "span", "lines", "stack", "split", "out", "atStack", "i", "length", "startsWith", "push", "includes", "replace", "current", "_tag", "stackFn", "get", "locationMatchAll", "matchAll", "match", "location", "name", "getOrUndefined", "parent", "cause", "Object", "defineProperty", "value", "join", "writable", "enumerable", "configurable", "causeToError", "isEmpty", "Error", "isInterruptedOnly", "errors", "toArray", "failures", "defects", "getStackFrames", "o", "captureStackTrace", "slice", "stackFrames", "newErrors", "map", "AggregateError", "throwCause", "unwrapExit", "exit", "isSuccess", "runAndForwardErrors", "effect", "options", "runPromiseExit", "runInRuntime", "runtime", "promiseWithCauseCapture", "evaluate", "promise", "signal", "result", "succeed", "err", "die", "pipe", "flatten", "validateTags", "context", "tags", "gen", "missingTags", "tag", "option", "getOption", "isNone", "push", "key", "length", "die", "Error", "join", "make", "managedRuntime", "managedRuntimeAny", "cachedRuntime", "validatedRuntimePromise", "getValidatedRuntimeAsync", "runPromise", "rt", "runtimeEffect", "getValidatedRuntime", "validationExit", "runSyncExit", "unwrapExit", "effect", "runtime", "runSync", "isSuccess", "value", "runPromiseExit", "error", "runFork", "pipe", "catchAll", "dispose", "Option", "Schema", "JSONPath", "invariant", "getDeep", "setDeep", "PATH_REGEX", "PROP_REGEX", "JsonPath", "String", "pipe", "pattern", "annotations", "title", "description", "JsonProp", "NonEmptyString", "message", "isJsonPath", "value", "isSome", "validateOption", "createJsonPath", "path", "candidatePath", "map", "p", "i", "join", "fromEffectValidationPath", "effectPath", "jsonPath", "replace", "splitJsonPath", "match", "part", "parsed", "Number", "parseInt", "isNaN", "getField", "object", "json", "getValue", "obj", "setValue", "Effect", "acquireReleaseResource", "getResource", "acquireRelease", "gen", "resource", "promise", "open", "undefined", "close", "Function", "Option", "SchemaAST", "decamelize", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "getAnnotation", "ParamKeyAnnotation", "value", "self", "annotations", "UrlParser", "_schema", "parse", "_url", "url", "URL", "Object", "entries", "fields", "reduce", "params", "key", "type", "searchParams", "get", "decamelize", "isNumberKeyword", "ast", "parseInt", "isBooleanKeyword", "create", "forEach", "undefined", "field", "serializedKey", "pipe", "getOrElse", "set", "String", "provide", "runPromise", "Effect", "Runtime", "currentRuntime", "runtime", "pipe", "map", "succeed", "runPromise", "provider", "effect", "runAndForwardErrors", "unwrapExit", "runPromiseExit", "provide", "runtimeProvider", "flatMap"]
3
+ "sources": ["../../../src/ast.ts", "../../../src/atom-kvs.ts", "../../../src/context.ts", "../../../src/dynamic-runtime.ts", "../../../src/errors.ts", "../../../src/json-path.ts", "../../../src/resource.ts", "../../../src/url.ts", "../../../src/RuntimeProvider.ts", "../../../src/Performance.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { invariant } from '@dxos/invariant';\nimport { isNonNullable } from '@dxos/util';\n\nimport { type JsonPath, type JsonProp } from './json-path';\n\n//\n// Refs\n// https://effect.website/docs/schema/introduction\n// https://www.npmjs.com/package/@effect/schema\n// https://effect-ts.github.io/effect/schema/SchemaAST.ts.html\n//\n\n/**\n * Unwraps and collects refinement filters.\n */\nconst reduceRefinements = (\n type: SchemaAST.AST,\n refinements: SchemaAST.Refinement['filter'][] = [],\n): { type: SchemaAST.AST; refinements: SchemaAST.Refinement['filter'][] } => {\n if (SchemaAST.isRefinement(type)) {\n const filter = type.filter;\n const nextType = {\n ...type.from,\n annotations: { ...type.from.annotations, ...type.annotations },\n } as SchemaAST.AST;\n return reduceRefinements(nextType, [...refinements, filter]);\n }\n\n return { type, refinements };\n};\n\n/**\n * Get the base type of a property.\n *\n * Unwraps refinements and optional unions.\n */\nexport const getBaseType = (\n prop: SchemaAST.PropertySignature | SchemaProperty,\n): { type: SchemaAST.AST; refinements: SchemaAST.Refinement['filter'][] } => {\n const encoded = SchemaAST.encodedBoundAST(prop.type);\n // Extract property ast from optional union.\n const unwrapped = prop.isOptional && encoded._tag === 'Union' ? encoded.types[0] : encoded;\n return reduceRefinements(unwrapped);\n};\n\nexport type SchemaProperty = Pick<SchemaAST.PropertySignature, 'name' | 'type' | 'isOptional' | 'isReadonly'> & {\n /** Can be used to validate the property to the spec of the initial AST. */\n refinements: SchemaAST.Refinement['filter'][];\n};\n\n/**\n * Get the property types of an AST.\n */\nexport const getProperties = (ast: SchemaAST.AST): SchemaProperty[] => {\n const properties = SchemaAST.getPropertySignatures(ast);\n return properties.map((prop) => ({\n ...getBaseType(prop),\n name: prop.name,\n isOptional: prop.isOptional,\n isReadonly: prop.isReadonly,\n }));\n};\n\n//\n// Branded types\n//\n\nexport enum VisitResult {\n CONTINUE = 0,\n /**\n * Skip visiting children.\n */\n SKIP = 1,\n /**\n * Stop traversing immediately.\n */\n EXIT = 2,\n}\n\nexport type Path = (string | number)[];\n\nexport type TestFn = (node: SchemaAST.AST, path: Path, depth: number) => VisitResult | boolean | undefined;\n\nexport type VisitorFn = (node: SchemaAST.AST, path: Path, depth: number) => void;\n\n/**\n * Visit leaf nodes.\n * Refs:\n * - https://github.com/syntax-tree/unist-util-visit?tab=readme-ov-file#visitor\n * - https://github.com/syntax-tree/unist-util-is?tab=readme-ov-file#test\n */\nexport const visit = (node: SchemaAST.AST, testOrVisitor: TestFn | VisitorFn, visitor: VisitorFn): void => {\n visitNode(node, testOrVisitor as TestFn, visitor);\n};\n\nconst visitNode = (\n node: SchemaAST.AST,\n test: TestFn | undefined,\n visitor: VisitorFn,\n path: Path = [],\n depth = 0,\n): VisitResult | undefined => {\n const $result = test?.(node, path, depth);\n const result: VisitResult =\n $result === undefined\n ? VisitResult.CONTINUE\n : typeof $result === 'boolean'\n ? $result\n ? VisitResult.CONTINUE\n : VisitResult.SKIP\n : $result;\n\n if (result === VisitResult.EXIT) {\n return result;\n }\n if (result !== VisitResult.SKIP) {\n visitor(node, path, depth);\n }\n\n // Object.\n if (SchemaAST.isTypeLiteral(node)) {\n for (const prop of SchemaAST.getPropertySignatures(node)) {\n const currentPath = [...path, prop.name.toString()];\n const result = visitNode(prop.type, test, visitor, currentPath, depth + 1);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Array.\n else if (SchemaAST.isTupleType(node)) {\n for (const [i, element] of node.elements.entries()) {\n const currentPath = [...path, i];\n const result = visitNode(element.type, test, visitor, currentPath, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Branching union (e.g., optional, discriminated unions).\n else if (SchemaAST.isUnion(node)) {\n for (const type of node.types) {\n const result = visitNode(type, test, visitor, path, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Refinement.\n else if (SchemaAST.isRefinement(node)) {\n const result = visitNode(node.from, test, visitor, path, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n\n // TODO(burdon): Transforms?\n};\n\n/**\n * Recursively descend into AST to find first node that passes the test.\n */\n// TODO(burdon): Rewrite using visitNode?\nexport const findNode = (node: SchemaAST.AST, test: (node: SchemaAST.AST) => boolean): SchemaAST.AST | undefined => {\n if (test(node)) {\n return node;\n }\n\n // Object.\n else if (SchemaAST.isTypeLiteral(node)) {\n for (const prop of SchemaAST.getPropertySignatures(node)) {\n const child = findNode(prop.type, test);\n if (child) {\n return child;\n }\n }\n for (const prop of getIndexSignatures(node)) {\n const child = findNode(prop.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Tuple.\n else if (SchemaAST.isTupleType(node)) {\n for (const [_, element] of node.elements.entries()) {\n const child = findNode(element.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Branching union (e.g., optional, discriminated unions).\n else if (SchemaAST.isUnion(node)) {\n if (isLiteralUnion(node)) {\n return undefined;\n }\n\n for (const type of node.types) {\n const child = findNode(type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Refinement.\n else if (SchemaAST.isRefinement(node)) {\n return findNode(node.from, test);\n }\n};\n\n/**\n * Get the AST node for the given property (dot-path).\n */\nexport const findProperty = (\n schema: Schema.Schema.AnyNoContext,\n path: JsonPath | JsonProp,\n): SchemaAST.AST | undefined => {\n const getProp = (node: SchemaAST.AST, path: JsonProp[]): SchemaAST.AST | undefined => {\n const [name, ...rest] = path;\n const typeNode = findNode(node, SchemaAST.isTypeLiteral);\n invariant(typeNode);\n for (const prop of SchemaAST.getPropertySignatures(typeNode)) {\n if (prop.name === name) {\n if (rest.length) {\n return getProp(prop.type, rest);\n } else {\n return prop.type;\n }\n }\n }\n };\n\n return getProp(schema.ast, path.split('.') as JsonProp[]);\n};\n\n//\n// Annotations\n//\n\nconst defaultAnnotations: Record<string, SchemaAST.Annotated> = {\n ObjectKeyword: SchemaAST.objectKeyword,\n StringKeyword: SchemaAST.stringKeyword,\n NumberKeyword: SchemaAST.numberKeyword,\n BooleanKeyword: SchemaAST.booleanKeyword,\n};\n\n/**\n * Get annotation or return undefined.\n * @param annotationId\n * @param noDefault If true, then return undefined for effect library defined values.\n */\nexport const getAnnotation =\n <T>(annotationId: symbol, noDefault = true) =>\n (node: SchemaAST.AST): T | undefined => {\n // Title fallback seems to be the identifier.\n const id = Function.pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);\n const value = Function.pipe(SchemaAST.getAnnotation<T>(annotationId)(node), Option.getOrUndefined);\n if (noDefault && (value === defaultAnnotations[node._tag]?.annotations[annotationId] || value === id)) {\n return undefined;\n }\n\n return value;\n };\n\n/**\n * Recursively descend into AST to find first matching annotations.\n * Optionally skips default annotations for basic types (e.g., 'a string').\n */\n// TODO(burdon): Convert to effect pattern (i.e., return operator like getAnnotation).\nexport const findAnnotation = <T>(node: SchemaAST.AST, annotationId: symbol, noDefault = true): T | undefined => {\n const getAnnotationById = getAnnotation(annotationId, noDefault);\n\n const getBaseAnnotation = (node: SchemaAST.AST): T | undefined => {\n const value = getAnnotationById(node);\n if (value !== undefined) {\n return value as T;\n }\n\n if (SchemaAST.isUnion(node)) {\n if (isOption(node)) {\n return getAnnotationById(node.types[0]) as T;\n }\n }\n };\n\n return getBaseAnnotation(node);\n};\n\n//\n// Unions\n//\n\n/**\n * Effect Schema.optional creates a union type with undefined as the second type.\n */\nexport const isOption = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && node.types.length === 2 && SchemaAST.isUndefinedKeyword(node.types[1]);\n};\n\n/**\n * Determines if the node is a union of literal types.\n */\nexport const isLiteralUnion = (node: SchemaAST.AST): node is SchemaAST.Union<SchemaAST.Literal> => {\n return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);\n};\n\n/**\n * Determines if the node is an array type.\n */\nexport const isArrayType = (node: SchemaAST.AST): node is SchemaAST.TupleType => {\n return SchemaAST.isTupleType(node) && node.elements.length === 0 && node.rest.length === 1;\n};\n\n/**\n * Get the type of the array elements.\n */\nexport const getArrayElementType = (node: SchemaAST.AST): SchemaAST.AST | undefined => {\n return isArrayType(node) ? node.rest.at(0)?.type : undefined;\n};\n\n/**\n * Determines if the node is a tuple type.\n */\nexport const isTupleType = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isTupleType(node) && node.elements.length > 0;\n};\n\n/**\n * Determines if the node is a discriminated union.\n */\nexport const isDiscriminatedUnion = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;\n};\n\n/**\n * Get the discriminating properties for the given union type.\n */\nexport const getDiscriminatingProps = (node: SchemaAST.AST): string[] | undefined => {\n invariant(SchemaAST.isUnion(node));\n if (isOption(node)) {\n return;\n }\n\n // Get common literals across all types.\n return node.types.reduce<string[]>((shared, type) => {\n const props = SchemaAST.getPropertySignatures(type)\n // TODO(burdon): Should check each literal is unique.\n .filter((p) => SchemaAST.isLiteral(p.type))\n .map((p) => p.name.toString());\n\n // Return common literals.\n return shared.length === 0 ? props : shared.filter((prop) => props.includes(prop));\n }, []);\n};\n\n/**\n * Get the discriminated type for the given value.\n */\nexport const getDiscriminatedType = (\n node: SchemaAST.AST,\n value: Record<string, any> = {},\n): SchemaAST.AST | undefined => {\n invariant(SchemaAST.isUnion(node));\n invariant(value);\n const props = getDiscriminatingProps(node);\n if (!props?.length) {\n return;\n }\n\n // Match provided values.\n for (const type of node.types) {\n const match = SchemaAST.getPropertySignatures(type)\n .filter((prop) => props?.includes(prop.name.toString()))\n .every((prop) => {\n invariant(SchemaAST.isLiteral(prop.type));\n return prop.type.literal === value[prop.name.toString()];\n });\n\n if (match) {\n return type;\n }\n }\n\n // Create union of discriminating properties.\n // NOTE: This may not work with non-overlapping variants.\n // TODO(burdon): Iterate through props and knock-out variants that don't match.\n const fields = Object.fromEntries(\n props\n .map((prop) => {\n const literals = node.types\n .map((type) => {\n const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop)!;\n invariant(SchemaAST.isLiteral(literal.type));\n return literal.type.literal;\n })\n .filter(isNonNullable);\n\n return literals.length ? [prop, Schema.Literal(...literals)] : undefined;\n })\n .filter(isNonNullable),\n );\n\n const schema = Schema.Struct(fields);\n return schema.ast;\n};\n\n/**\n * Determines if the node is a nested object type.\n */\nexport const isNestedType = (node: SchemaAST.AST): boolean => {\n return (\n SchemaAST.isDeclaration(node) ||\n SchemaAST.isObjectKeyword(node) ||\n SchemaAST.isTypeLiteral(node) ||\n // TODO(wittjosiah): Tuples are actually arrays.\n isTupleType(node) ||\n isDiscriminatedUnion(node)\n );\n};\n\n/**\n * Maps AST nodes.\n * The user is responsible for recursively calling {@link mapAst} on the SchemaAST.\n * NOTE: Will evaluate suspended ASTs.\n */\nexport const mapAst = (\n ast: SchemaAST.AST,\n f: (ast: SchemaAST.AST, key: keyof any | undefined) => SchemaAST.AST,\n): SchemaAST.AST => {\n switch (ast._tag) {\n case 'TypeLiteral': {\n return new SchemaAST.TypeLiteral(\n ast.propertySignatures.map(\n (prop) =>\n new SchemaAST.PropertySignature(\n prop.name,\n f(prop.type, prop.name),\n prop.isOptional,\n prop.isReadonly,\n prop.annotations,\n ),\n ),\n ast.indexSignatures,\n ast.annotations,\n );\n }\n case 'Union': {\n return SchemaAST.Union.make(ast.types.map(f), ast.annotations);\n }\n case 'TupleType': {\n return new SchemaAST.TupleType(\n ast.elements.map((t, index) => new SchemaAST.OptionalType(f(t.type, index), t.isOptional, t.annotations)),\n ast.rest.map((t) => new SchemaAST.Type(f(t.type, undefined), t.annotations)),\n ast.isReadonly,\n ast.annotations,\n );\n }\n case 'Suspend': {\n const newAst = f(ast.f(), undefined);\n return new SchemaAST.Suspend(() => newAst, ast.annotations);\n }\n default: {\n // TODO(dmaretskyi): Support more nodes.\n return ast;\n }\n }\n};\n\nconst getIndexSignatures = (ast: SchemaAST.AST): Array<SchemaAST.IndexSignature> => {\n const annotation = SchemaAST.getSurrogateAnnotation(ast);\n if (Option.isSome(annotation)) {\n return getIndexSignatures(annotation.value);\n }\n switch (ast._tag) {\n case 'TypeLiteral':\n return ast.indexSignatures.slice();\n case 'Suspend':\n return getIndexSignatures(ast.f());\n case 'Refinement':\n return getIndexSignatures(ast.from);\n }\n return [];\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as BrowserKeyValueStore from '@effect/platform-browser/BrowserKeyValueStore';\nimport { Atom } from '@effect-atom/atom-react';\nimport type * as Schema from 'effect/Schema';\n\n// TODO(wittjosiah): This is currently provided for convenience but maybe should be removed.\nconst defaultRuntime = Atom.runtime(BrowserKeyValueStore.layerLocalStorage);\n\n/**\n * Creates a KVS-backed atom for structured settings using Atom.kvs.\n * The entire object is stored as a single localStorage key with JSON serialization.\n *\n * @param options.key - The localStorage key to store the value under.\n * @param options.schema - Effect Schema for the value type.\n * @param options.defaultValue - Function returning the default value.\n * @param options.runtime - Optional custom Atom runtime (defaults to localStorage).\n * @returns A writable atom that persists to localStorage.\n */\nexport const createKvsStore = <T extends Record<string, any>>(options: {\n key: string;\n schema: Schema.Schema<T>;\n defaultValue: () => T;\n runtime?: ReturnType<typeof Atom.runtime>;\n}): Atom.Writable<T> => {\n const runtime = options.runtime ?? defaultRuntime;\n return Atom.kvs({\n runtime,\n key: options.key,\n schema: options.schema,\n defaultValue: options.defaultValue,\n }).pipe(Atom.keepAlive);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport type * as Scope from 'effect/Scope';\n\nimport { Context } from '@dxos/context';\n\n// TODO(dmaretskyi): Error handling.\nexport const contextFromScope = (): Effect.Effect<Context, never, Scope.Scope> =>\n Effect.gen(function* () {\n const ctx = new Context();\n yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));\n return ctx;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport type * as Fiber from 'effect/Fiber';\nimport type * as ManagedRuntime from 'effect/ManagedRuntime';\nimport * as Option from 'effect/Option';\nimport * as Runtime from 'effect/Runtime';\n\nimport { unwrapExit } from './errors';\n\n/**\n * Helper type to construct a union of tag identifiers from an array of tags.\n */\nexport type TagsToContext<Tags extends ReadonlyArray<Context.Tag<any, any>>> = Tags extends readonly [\n infer Head,\n ...infer Tail,\n]\n ? Head extends Context.Tag<infer Id, any>\n ? Tail extends ReadonlyArray<Context.Tag<any, any>>\n ? Id | TagsToContext<Tail>\n : Id\n : never\n : never;\n\n/**\n * A runtime wrapper that validates required tags are available at runtime\n * while providing type-level guarantees that effects require those tags.\n */\nexport interface DynamicRuntime<Tags extends ReadonlyArray<Context.Tag<any, any>>> {\n /**\n * Run an effect as a promise that requires the specified tags.\n */\n readonly runPromise: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => Promise<A>;\n\n /**\n * Run an effect synchronously that requires the specified tags.\n */\n readonly runSync: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => A;\n\n /**\n * Run an effect synchronously returning exit that requires the specified tags.\n */\n readonly runSyncExit: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => Exit.Exit<A, E>;\n\n /**\n * Run an effect as a promise returning exit that requires the specified tags.\n */\n readonly runPromiseExit: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => Promise<Exit.Exit<A, E>>;\n\n /**\n * Fork an effect that requires the specified tags.\n */\n readonly runFork: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => Fiber.RuntimeFiber<A, E>;\n\n /**\n * Get the runtime as an effect that requires the specified tags.\n */\n readonly runtimeEffect: Effect.Effect<Runtime.Runtime<TagsToContext<Tags>>, never, never>;\n\n /**\n * Dispose the underlying managed runtime.\n */\n readonly dispose: () => Promise<void>;\n\n /**\n * Get the underlying managed runtime.\n */\n readonly managedRuntime: ManagedRuntime.ManagedRuntime<any, any>;\n}\n\n/**\n * Validate that all required tags are present in the runtime context.\n */\nconst validateTags = <Tags extends ReadonlyArray<Context.Tag<any, any>>>(\n context: Context.Context<any>,\n tags: Tags,\n): Effect.Effect<void> =>\n Effect.gen(function* () {\n const missingTags: string[] = [];\n for (const tag of tags) {\n const option = Context.getOption(context, tag);\n if (Option.isNone(option)) {\n missingTags.push(tag.key);\n }\n }\n\n if (missingTags.length > 0) {\n return yield* Effect.die(new Error(`Missing required tags in runtime: ${missingTags.join(', ')}`));\n }\n });\n\n/**\n * Create a dynamic runtime from a managed runtime and validate required tags.\n */\nexport function make<const Tags extends ReadonlyArray<Context.Tag<any, any>>>(\n managedRuntime: ManagedRuntime.ManagedRuntime<any, any> | ManagedRuntime.ManagedRuntime<never, never>,\n tags: Tags,\n): DynamicRuntime<Tags> {\n type RequiredContext = TagsToContext<Tags>;\n const managedRuntimeAny = managedRuntime as ManagedRuntime.ManagedRuntime<any, any>;\n\n // Cache for the validated runtime - once resolved, can be used synchronously.\n let cachedRuntime: Runtime.Runtime<RequiredContext> | undefined;\n\n // Cache validated runtime for async operations.\n let validatedRuntimePromise: Promise<Runtime.Runtime<RequiredContext>> | undefined;\n\n const getValidatedRuntimeAsync = async (): Promise<Runtime.Runtime<RequiredContext>> => {\n if (!validatedRuntimePromise) {\n validatedRuntimePromise = managedRuntimeAny.runPromise(\n Effect.gen(function* () {\n const rt = yield* managedRuntimeAny.runtimeEffect;\n yield* validateTags(rt.context, tags);\n return rt as Runtime.Runtime<RequiredContext>;\n }),\n );\n }\n return validatedRuntimePromise;\n };\n\n // Get validated runtime for sync operations.\n const getValidatedRuntime = (): Runtime.Runtime<RequiredContext> => {\n const validationExit = managedRuntimeAny.runSyncExit(\n Effect.gen(function* () {\n const rt = yield* managedRuntimeAny.runtimeEffect;\n yield* validateTags(rt.context, tags);\n return rt as Runtime.Runtime<RequiredContext>;\n }),\n );\n return unwrapExit(validationExit);\n };\n\n return {\n managedRuntime: managedRuntimeAny,\n runPromise: async <A, E>(effect: Effect.Effect<A, E, RequiredContext>): Promise<A> => {\n const runtime = await getValidatedRuntimeAsync();\n return Runtime.runPromise(runtime)(effect);\n },\n runSync: <A, E>(effect: Effect.Effect<A, E, RequiredContext>): A => {\n const runtime = getValidatedRuntime();\n return Runtime.runSync(runtime)(effect);\n },\n runSyncExit: <A, E>(effect: Effect.Effect<A, E, RequiredContext>): Exit.Exit<A, E> => {\n const validationExit = managedRuntimeAny.runSyncExit(\n Effect.gen(function* () {\n const rt = yield* managedRuntimeAny.runtimeEffect;\n yield* validateTags(rt.context, tags);\n return rt as Runtime.Runtime<RequiredContext>;\n }),\n );\n if (Exit.isSuccess(validationExit)) {\n const runtime = validationExit.value;\n return Runtime.runSyncExit(runtime)(effect);\n }\n return validationExit as Exit.Exit<A, E>;\n },\n runPromiseExit: async <A, E>(effect: Effect.Effect<A, E, RequiredContext>): Promise<Exit.Exit<A, E>> => {\n try {\n const runtime = await getValidatedRuntimeAsync();\n return Runtime.runPromiseExit(runtime)(effect);\n } catch (error) {\n // If validation failed, return a failure exit\n return Exit.die(error);\n }\n },\n runFork: <A, E>(effect: Effect.Effect<A, E, RequiredContext>): Fiber.RuntimeFiber<A, E> => {\n const runtime = getValidatedRuntime();\n return Runtime.runFork(runtime)(effect);\n },\n runtimeEffect: Effect.gen(function* () {\n // Return cached runtime if available.\n if (cachedRuntime) {\n return cachedRuntime;\n }\n const rt = yield* managedRuntimeAny.runtimeEffect;\n yield* validateTags(rt.context, tags);\n const runtime = rt as Runtime.Runtime<RequiredContext>;\n // Cache for future sync calls.\n cachedRuntime = runtime;\n return runtime;\n }).pipe(\n Effect.catchAll(() =>\n // This should never happen since validateTags uses Effect.die\n Effect.die(new Error('Unexpected error in runtimeEffect validation')),\n ),\n ),\n dispose: async (): Promise<void> => {\n await managedRuntimeAny.dispose();\n },\n };\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Cause from 'effect/Cause';\nimport * as Chunk from 'effect/Chunk';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport * as GlobalValue from 'effect/GlobalValue';\nimport * as Option from 'effect/Option';\nimport * as Runtime from 'effect/Runtime';\nimport type * as Tracer from 'effect/Tracer';\n\nconst spanSymbol = Symbol.for('effect/SpanAnnotation');\nconst spanToTrace = GlobalValue.globalValue('effect/Tracer/spanToTrace', () => new WeakMap());\nconst locationRegex = /\\((.*)\\)/g;\n\n/**\n * Adds effect spans.\n * Removes effect internal functions.\n * Unwraps error proxy.\n */\nconst prettyErrorStack = (error: any, appendStacks: string[] = []): any => {\n if (typeof error !== 'object' || error === null) {\n return error;\n }\n\n const span = error[spanSymbol];\n\n const lines = typeof error.stack === 'string' ? error.stack.split('\\n') : [];\n const out = [];\n\n // Very hacky way to remove effect runtime internal stack frames.\n let atStack = false,\n inCore = false,\n passedScheduler = false;\n for (let i = 0; i < lines.length; i++) {\n if (!atStack && !lines[i].startsWith(' at ')) {\n out.push(lines[i]);\n continue;\n }\n atStack = true;\n\n if (lines[i].includes(' at new BaseEffectError') || lines[i].includes(' at new YieldableError')) {\n i++;\n continue;\n }\n if (lines[i].includes('Generator.next')) {\n break;\n }\n if (lines[i].includes('effect_internal_function')) {\n break;\n }\n\n const filename = lines[i].match(/\\/([a-zA-Z0-9_\\-.]+):\\d+:\\d+\\)$/)?.[1];\n\n if (!inCore && ['core-effect.ts'].includes(filename)) {\n inCore = true;\n }\n\n if (inCore && !passedScheduler && ['Scheduler.ts'].includes(filename)) {\n passedScheduler = true;\n continue;\n }\n\n if (passedScheduler && !['Scheduler.ts'].includes(filename)) {\n inCore = false;\n }\n\n if (inCore) {\n continue;\n }\n\n out.push(\n lines[i]\n .replace(/at .*effect_instruction_i.*\\((.*)\\)/, 'at $1')\n .replace(/EffectPrimitive\\.\\w+/, '<anonymous>')\n .replace(/at Arguments\\./, 'at '),\n );\n }\n\n if (span) {\n let current: Tracer.Span | Tracer.AnySpan | undefined = span;\n let i = 0;\n while (current && current._tag === 'Span' && i < 10) {\n const stackFn = spanToTrace.get(current);\n if (typeof stackFn === 'function') {\n const stack = stackFn();\n if (typeof stack === 'string') {\n const locationMatchAll = stack.matchAll(locationRegex);\n let match = false;\n for (const [, location] of locationMatchAll) {\n match = true;\n out.push(` at ${current.name} (${location})`);\n }\n if (!match) {\n out.push(` at ${current.name} (${stack.replace(/^at /, '')})`);\n }\n } else {\n out.push(` at ${current.name}`);\n }\n } else {\n out.push(` at ${current.name}`);\n }\n current = Option.getOrUndefined(current.parent);\n i++;\n }\n }\n\n out.push(...appendStacks);\n\n error = Cause.originalError(error);\n if (error.cause) {\n error.cause = prettyErrorStack(error.cause);\n }\n\n Object.defineProperty(error, 'stack', {\n value: out.join('\\n'),\n writable: true,\n enumerable: false,\n configurable: true,\n });\n\n return error;\n};\n\n/**\n * Converts a cause to an error.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const causeToError = (cause: Cause.Cause<any>): Error => {\n if (Cause.isEmpty(cause)) {\n return new Error('Fiber failed without a cause');\n } else if (Cause.isInterruptedOnly(cause)) {\n return new Error('Fiber was interrupted');\n } else {\n const errors = [...Chunk.toArray(Cause.failures(cause)), ...Chunk.toArray(Cause.defects(cause))];\n\n const getStackFrames = (): string[] => {\n // Bun requies the target object for `captureStackTrace` to be an Error.\n const o = new Error();\n Error.captureStackTrace(o, causeToError);\n return o.stack!.split('\\n').slice(1);\n };\n\n const stackFrames = getStackFrames();\n const newErrors = errors.map((error) => prettyErrorStack(error, stackFrames));\n\n if (newErrors.length === 1) {\n return newErrors[0];\n } else {\n return new AggregateError(newErrors);\n }\n }\n};\n\n/**\n * Throws an error based on the cause.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const throwCause = (cause: Cause.Cause<any>): never => {\n throw causeToError(cause);\n};\n\nexport const unwrapExit = <A>(exit: Exit.Exit<A, any>): A => {\n if (Exit.isSuccess(exit)) {\n return exit.value;\n }\n\n return throwCause(exit.cause);\n};\n\n/**\n * Runs the embedded effect asynchronously and throws any failures and defects as errors.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const runAndForwardErrors = async <A, E>(\n effect: Effect.Effect<A, E, never>,\n options?: { signal?: AbortSignal },\n): Promise<A> => {\n const exit = await Effect.runPromiseExit(effect, options);\n return unwrapExit(exit);\n};\n\n/**\n * Runs the embedded effect asynchronously and throws any failures and defects as errors.\n */\nexport const runInRuntime: {\n <R>(\n runtime: Runtime.Runtime<R>,\n ): <A, E>(effect: Effect.Effect<A, E, R>, options?: { signal?: AbortSignal } | undefined) => Promise<A>;\n <R, A, E>(\n runtime: Runtime.Runtime<R>,\n effect: Effect.Effect<A, E, R>,\n options?: { signal?: AbortSignal } | undefined,\n ): Promise<A>;\n} = (...args: any[]): any => {\n if (args.length === 1) {\n const [runtime] = args as [Runtime.Runtime<any>];\n return async (\n effect: Effect.Effect<any, any, any>,\n options?: { signal?: AbortSignal } | undefined,\n ): Promise<any> => {\n const exit = await Runtime.runPromiseExit(runtime, effect, options);\n return unwrapExit(exit);\n };\n } else {\n const [runtime, effect, options] = args as [\n Runtime.Runtime<any>,\n Effect.Effect<any, any, any>,\n { signal?: AbortSignal } | undefined,\n ];\n return (async () => {\n const exit = await Runtime.runPromiseExit(runtime, effect, options);\n return unwrapExit(exit);\n })();\n }\n};\n\n/**\n * Like `Effect.promise` but also caputes spans for defects.\n * Workaround for: https://github.com/Effect-TS/effect/issues/5436\n */\nexport const promiseWithCauseCapture: <A>(evaluate: (signal: AbortSignal) => PromiseLike<A>) => Effect.Effect<A> = (\n evaluate,\n) =>\n Effect.promise(async (signal) => {\n try {\n const result = await evaluate(signal);\n return Effect.succeed(result);\n } catch (err) {\n return Effect.die(err);\n }\n }).pipe(Effect.flatten);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport { JSONPath } from 'jsonpath-plus';\n\nimport { invariant } from '@dxos/invariant';\nimport { getDeep, setDeep } from '@dxos/util';\n\nexport type JsonProp = string & { __JsonPath: true; __JsonProp: true };\nexport type JsonPath = string & { __JsonPath: true };\n\n// TODO(burdon): Start with \"$.\"?\n\nconst PATH_REGEX = /^($|[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*|\\[\\d+\\](?:\\.)?)*$)/;\n\nconst PROP_REGEX = /^\\w+$/;\n\n/**\n * https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html\n */\n// TODO(burdon): Keys could be arbitrary strings.\nexport const JsonPath = Schema.String.pipe(Schema.pattern(PATH_REGEX)).annotations({\n title: 'JSON path',\n description: 'JSON path to a property',\n}) as any as Schema.Schema<JsonPath>;\nexport const JsonProp = Schema.NonEmptyString.pipe(\n Schema.pattern(PROP_REGEX, {\n message: () => 'Property name must contain only letters, numbers, and underscores',\n }),\n) as any as Schema.Schema<JsonProp>;\n\nexport const isJsonPath = (value: unknown): value is JsonPath => {\n return Option.isSome(Schema.validateOption(JsonPath)(value));\n};\n\n/**\n * Creates a JsonPath from an array of path segments.\n *\n * Currently supports:\n * - Simple property access (e.g., 'foo.bar')\n * - Array indexing with non-negative integers (e.g., 'foo[0]')\n * - Identifiers starting with letters, underscore, or $ (e.g., '$foo', '_bar')\n * - Dot notation for nested properties (e.g., 'foo.bar.baz')\n *\n * Does not support (yet?).\n * - Recursive descent (..)\n * - Wildcards (*)\n * - Array slicing\n * - Filters\n * - Negative indices\n *\n * @param path Array of string or number segments\n * @returns Valid JsonPath or undefined if invalid\n */\nexport const createJsonPath = (path: readonly (string | number)[]): JsonPath => {\n const candidatePath = path\n .map((p, i) => {\n if (typeof p === 'number') {\n return `[${p}]`;\n } else {\n return i === 0 ? p : `.${p}`;\n }\n })\n .join('');\n\n invariant(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`);\n return candidatePath;\n};\n\n/**\n * Converts Effect validation path format (e.g. \"addresses.[0].zip\")\n * to JsonPath format (e.g., \"addresses[0].zip\")\n */\nexport const fromEffectValidationPath = (effectPath: string): JsonPath => {\n // Handle array notation: convert \"prop.[0]\" to \"prop[0]\"\n const jsonPath = effectPath.replace(/\\.\\[(\\d+)\\]/g, '[$1]');\n invariant(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`);\n return jsonPath;\n};\n\n/**\n * Splits a JsonPath into its constituent parts.\n * Handles property access and array indexing.\n */\nexport const splitJsonPath = (path: JsonPath): (string | number)[] => {\n if (!isJsonPath(path)) {\n return [];\n }\n\n return (\n path\n .match(/[a-zA-Z_$][\\w$]*|\\[\\d+\\]/g)\n ?.map((part) => part.replace(/[[\\]]/g, ''))\n .map((part) => {\n const parsed = Number.parseInt(part, 10);\n return Number.isNaN(parsed) ? part : parsed;\n }) ?? []\n );\n};\n\n/**\n * Applies a JsonPath to an object.\n */\n// TODO(burdon): Reconcile with getValue.\nexport const getField = (object: any, path: JsonPath): any => {\n // By default, JSONPath returns an array of results.\n return JSONPath({ path, json: object })[0];\n};\n\n/**\n * Get value from object using JsonPath.\n */\nexport const getValue = <T extends object>(obj: T, path: JsonPath): any => {\n return getDeep(obj, splitJsonPath(path));\n};\n\n/**\n * Set value on object using JsonPath.\n */\nexport const setValue = <T extends object>(obj: T, path: JsonPath, value: any): T => {\n return setDeep(obj, splitJsonPath(path), value);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport type * as Scope from 'effect/Scope';\n\nimport type { Lifecycle } from '@dxos/context';\n\n/**\n * Acquires a resource and releases it when the scope is closed.\n */\nexport const acquireReleaseResource = <T extends Lifecycle>(\n getResource: () => T,\n): Effect.Effect<T, never, Scope.Scope> =>\n Effect.acquireRelease(\n Effect.gen(function* () {\n const resource = getResource();\n yield* Effect.promise(async () => {\n await resource.open?.();\n return undefined;\n });\n return resource;\n }),\n (resource) =>\n Effect.promise(async () => {\n await resource.close?.();\n return undefined;\n }),\n );\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport type * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { decamelize } from '@dxos/util';\n\nconst ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKey');\n\ntype ParamKeyAnnotationValue = { key: string };\n\nexport const getParamKeyAnnotation: (annotated: SchemaAST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n SchemaAST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends Schema.Annotable.All>(self: S): Schema.Annotable.Self<S> =>\n self.annotations({ [ParamKeyAnnotationId]: value });\n\n/**\n * HTTP params parser.\n * Supports custom key serialization.\n */\nexport class UrlParser<T extends Record<string, any>> {\n constructor(private readonly _schema: Schema.Struct<T>) {}\n\n /**\n * Parse URL params.\n */\n parse(_url: string): T {\n const url = new URL(_url);\n return Object.entries(this._schema.fields).reduce<Record<string, any>>((params, [key, type]) => {\n let value = url.searchParams.get(decamelize(key));\n if (value == null) {\n value = url.searchParams.get(key);\n }\n\n if (value != null) {\n if (SchemaAST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (SchemaAST.isBooleanKeyword(type.ast)) {\n params[key] = value === 'true' || value === '1';\n } else {\n params[key] = value;\n }\n }\n\n return params;\n }, {}) as T;\n }\n\n /**\n * Return URL with encoded params.\n */\n create(_url: string, params: T): URL {\n const url = new URL(_url);\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n const field = this._schema.fields[key];\n if (field) {\n const { key: serializedKey } = Function.pipe(\n getParamKeyAnnotation(field.ast),\n Option.getOrElse(() => ({\n key: decamelize(key),\n })),\n );\n\n url.searchParams.set(serializedKey, String(value));\n }\n }\n });\n\n return url;\n }\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Runtime from 'effect/Runtime';\n\nimport { runAndForwardErrors, unwrapExit } from './errors';\n\n/**\n * Provides effect runtime with services to run effects.\n */\nexport type RuntimeProvider<R> = Effect.Effect<Runtime.Runtime<R>>;\n\n/**\n * @returns Runtime provider from the current context.\n */\nexport const currentRuntime = <R = never>() => Effect.runtime<R>().pipe(Effect.map(Effect.succeed));\n\n/**\n * Run effect, within runitme, clean errors and fix stack-traces.\n */\nexport const runPromise =\n <R>(provider: RuntimeProvider<R>) =>\n async <A>(effect: Effect.Effect<A, any, R>): Promise<A> => {\n const runtime = await runAndForwardErrors(provider);\n return unwrapExit(await effect.pipe(Runtime.runPromiseExit(runtime)));\n };\n\n/**\n * Provide services from runtime provider to effect.\n */\nexport const provide: {\n <R2>(runtime: RuntimeProvider<R2>): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, R2>>;\n} = (runtimeProvider) => (effect) => Effect.flatMap(runtimeProvider, (runtime) => Effect.provide(effect, runtime));\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport type * as Exit from 'effect/Exit';\n\nexport interface AddTrackEntryOptions {\n name: string;\n devtools?: {\n /**\n * @example 'track-entry'\n */\n dataType: string;\n track: string;\n trackGroup: string;\n /**\n * @example 'tertiary-dark'\n */\n color: string;\n properties?: [string, any][];\n tooltipText?: string;\n };\n detail?: Record<string, unknown>;\n}\n\n/**\n * Puts the effect span on the performance timeline in DevTools.\n */\nexport const addTrackEntry =\n <A, E>(options: AddTrackEntryOptions | ((exit: Exit.Exit<A, E>) => AddTrackEntryOptions)) =>\n <R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>\n Effect.gen(function* () {\n const start = performance.now();\n const exit = yield* Effect.exit(effect);\n const resolvedOptions = typeof options === 'function' ? options(exit) : options;\n performance.measure(resolvedOptions.name, {\n start: start,\n detail: {\n ...resolvedOptions.detail,\n devtools: resolvedOptions.devtools,\n },\n });\n return yield* exit;\n });\n"],
5
+ "mappings": ";;;;;;AAIA,YAAYA,cAAc;AAC1B,YAAYC,YAAY;AACxB,YAAYC,YAAY;AACxB,YAAYC,eAAe;AAE3B,SAASC,iBAAiB;AAC1B,SAASC,qBAAqB;;AAc9B,IAAMC,oBAAoB,CACxBC,MACAC,cAAgD,CAAA,MAAE;AAElD,MAAcC,uBAAaF,IAAAA,GAAO;AAChC,UAAMG,SAASH,KAAKG;AACpB,UAAMC,WAAW;MACf,GAAGJ,KAAKK;MACRC,aAAa;QAAE,GAAGN,KAAKK,KAAKC;QAAa,GAAGN,KAAKM;MAAY;IAC/D;AACA,WAAOP,kBAAkBK,UAAU;SAAIH;MAAaE;KAAO;EAC7D;AAEA,SAAO;IAAEH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YlB,IAAMC,iBAAiB,MAAwBC,gBAAO,EAAMC,KAAYC,YAAWC,eAAO,CAAA;AAK1F,IAAMC,cACX,CAAIC,aACJ,OAAUC,WAAAA;AACR,QAAMN,WAAU,MAAMO,oBAAoBF,QAAAA;AAC1C,SAAOG,WAAW,MAAMF,OAAOL,KAAaQ,wBAAeT,QAAAA,CAAAA,CAAAA;AAC7D;AAKK,IAAMU,WAET,CAACC,oBAAoB,CAACL,WAAkBM,gBAAQD,iBAAiB,CAACX,aAAmBU,gBAAQJ,QAAQN,QAAAA,CAAAA;;;AClCzG;;;;AAIA,YAAYa,aAAY;AAyBjB,IAAMC,gBACX,CAAOC,YACP,CAAIC,WACKC,YAAI,aAAA;AACT,QAAMC,QAAQC,YAAYC,IAAG;AAC7B,QAAMC,QAAO,OAAcA,aAAKL,MAAAA;AAChC,QAAMM,kBAAkB,OAAOP,YAAY,aAAaA,QAAQM,KAAAA,IAAQN;AACxEI,cAAYI,QAAQD,gBAAgBE,MAAM;IACxCN;IACAO,QAAQ;MACN,GAAGH,gBAAgBG;MACnBC,UAAUJ,gBAAgBI;IAC5B;EACF,CAAA;AACA,SAAO,OAAOL;AAChB,CAAA;",
6
+ "names": ["Function", "Option", "Schema", "SchemaAST", "invariant", "isNonNullable", "reduceRefinements", "type", "refinements", "isRefinement", "filter", "nextType", "from", "annotations", "getBaseType", "prop", "encoded", "encodedBoundAST", "unwrapped", "isOptional", "_tag", "types", "getProperties", "ast", "properties", "getPropertySignatures", "map", "name", "isReadonly", "VisitResult", "visit", "node", "testOrVisitor", "visitor", "visitNode", "test", "path", "depth", "$result", "result", "undefined", "isTypeLiteral", "currentPath", "toString", "isTupleType", "i", "element", "elements", "entries", "isUnion", "findNode", "child", "getIndexSignatures", "_", "isLiteralUnion", "findProperty", "schema", "getProp", "rest", "typeNode", "length", "split", "defaultAnnotations", "ObjectKeyword", "objectKeyword", "StringKeyword", "stringKeyword", "NumberKeyword", "numberKeyword", "BooleanKeyword", "booleanKeyword", "getAnnotation", "annotationId", "noDefault", "id", "pipe", "getIdentifierAnnotation", "getOrUndefined", "value", "findAnnotation", "getAnnotationById", "getBaseAnnotation", "isOption", "isUndefinedKeyword", "every", "isLiteral", "isArrayType", "getArrayElementType", "at", "isDiscriminatedUnion", "getDiscriminatingProps", "reduce", "shared", "props", "p", "includes", "getDiscriminatedType", "match", "literal", "fields", "Object", "fromEntries", "literals", "find", "Literal", "Struct", "isNestedType", "isDeclaration", "isObjectKeyword", "mapAst", "f", "TypeLiteral", "propertySignatures", "PropertySignature", "indexSignatures", "Union", "make", "TupleType", "t", "index", "OptionalType", "Type", "newAst", "Suspend", "annotation", "getSurrogateAnnotation", "isSome", "slice", "BrowserKeyValueStore", "Atom", "defaultRuntime", "Atom", "runtime", "layerLocalStorage", "createKvsStore", "options", "kvs", "key", "schema", "defaultValue", "pipe", "keepAlive", "Effect", "Context", "contextFromScope", "gen", "ctx", "addFinalizer", "promise", "dispose", "Context", "Effect", "Exit", "Option", "Runtime", "Cause", "Chunk", "Effect", "Exit", "GlobalValue", "Option", "Runtime", "spanSymbol", "Symbol", "for", "spanToTrace", "globalValue", "WeakMap", "locationRegex", "prettyErrorStack", "error", "appendStacks", "span", "lines", "stack", "split", "out", "atStack", "inCore", "passedScheduler", "i", "length", "startsWith", "push", "includes", "filename", "match", "replace", "current", "_tag", "stackFn", "get", "locationMatchAll", "matchAll", "location", "name", "getOrUndefined", "parent", "originalError", "cause", "Object", "defineProperty", "value", "join", "writable", "enumerable", "configurable", "causeToError", "isEmpty", "Error", "isInterruptedOnly", "errors", "toArray", "failures", "defects", "getStackFrames", "o", "captureStackTrace", "slice", "stackFrames", "newErrors", "map", "AggregateError", "throwCause", "unwrapExit", "exit", "isSuccess", "runAndForwardErrors", "effect", "options", "runPromiseExit", "runInRuntime", "args", "runtime", "promiseWithCauseCapture", "evaluate", "promise", "signal", "result", "succeed", "err", "die", "pipe", "flatten", "validateTags", "context", "tags", "gen", "missingTags", "tag", "option", "getOption", "isNone", "push", "key", "length", "die", "Error", "join", "make", "managedRuntime", "managedRuntimeAny", "cachedRuntime", "validatedRuntimePromise", "getValidatedRuntimeAsync", "runPromise", "rt", "runtimeEffect", "getValidatedRuntime", "validationExit", "runSyncExit", "unwrapExit", "effect", "runtime", "runSync", "isSuccess", "value", "runPromiseExit", "error", "runFork", "pipe", "catchAll", "dispose", "Option", "Schema", "JSONPath", "invariant", "getDeep", "setDeep", "PATH_REGEX", "PROP_REGEX", "JsonPath", "String", "pipe", "pattern", "annotations", "title", "description", "JsonProp", "NonEmptyString", "message", "isJsonPath", "value", "isSome", "validateOption", "createJsonPath", "path", "candidatePath", "map", "p", "i", "join", "fromEffectValidationPath", "effectPath", "jsonPath", "replace", "splitJsonPath", "match", "part", "parsed", "Number", "parseInt", "isNaN", "getField", "object", "json", "getValue", "obj", "setValue", "Effect", "acquireReleaseResource", "getResource", "acquireRelease", "gen", "resource", "promise", "open", "undefined", "close", "Function", "Option", "SchemaAST", "decamelize", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "getAnnotation", "ParamKeyAnnotation", "value", "self", "annotations", "UrlParser", "_schema", "parse", "_url", "url", "URL", "Object", "entries", "fields", "reduce", "params", "key", "type", "searchParams", "get", "decamelize", "isNumberKeyword", "ast", "parseInt", "isBooleanKeyword", "create", "forEach", "undefined", "field", "serializedKey", "pipe", "getOrElse", "set", "String", "provide", "runPromise", "Effect", "Runtime", "currentRuntime", "runtime", "pipe", "map", "succeed", "runPromise", "provider", "effect", "runAndForwardErrors", "unwrapExit", "runPromiseExit", "provide", "runtimeProvider", "flatMap", "Effect", "addTrackEntry", "options", "effect", "gen", "start", "performance", "now", "exit", "resolvedOptions", "measure", "name", "detail", "devtools"]
7
7
  }