trilean 1.7.11 → 1.8.0

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.
Files changed (56) hide show
  1. package/README.md +33 -13
  2. package/dist/builtin-functions.cjs +129 -0
  3. package/dist/builtin-functions.d.cts +13 -0
  4. package/dist/builtin-functions.d.ts +13 -0
  5. package/dist/builtin-functions.js +128 -0
  6. package/dist/complex-division.cjs +48 -0
  7. package/dist/complex-division.d.cts +25 -0
  8. package/dist/complex-division.d.ts +25 -0
  9. package/dist/complex-division.js +47 -0
  10. package/dist/duration-order.cjs +84 -0
  11. package/dist/duration-order.d.cts +22 -0
  12. package/dist/duration-order.d.ts +22 -0
  13. package/dist/duration-order.js +82 -0
  14. package/dist/evaluate-document.cjs +87 -0
  15. package/dist/evaluate-document.d.cts +40 -0
  16. package/dist/evaluate-document.d.ts +40 -0
  17. package/dist/evaluate-document.js +86 -0
  18. package/dist/evaluator-collection.d.cts +1 -1
  19. package/dist/evaluator-collection.d.ts +1 -1
  20. package/dist/evaluator-factory.d.cts +1 -1
  21. package/dist/evaluator-factory.d.ts +1 -1
  22. package/dist/evaluator-indeterminacy-helpers.cjs +1 -1
  23. package/dist/evaluator-indeterminacy-helpers.d.cts +1 -1
  24. package/dist/evaluator-indeterminacy-helpers.d.ts +1 -1
  25. package/dist/evaluator-indeterminacy-helpers.js +1 -1
  26. package/dist/evaluator-operations.cjs +75 -24
  27. package/dist/evaluator-operations.d.cts +3 -3
  28. package/dist/evaluator-operations.d.ts +3 -3
  29. package/dist/evaluator-operations.js +74 -23
  30. package/dist/evaluator-test-helpers.cjs +1 -1
  31. package/dist/evaluator-test-helpers.js +1 -1
  32. package/dist/evaluator.d.cts +1 -1
  33. package/dist/evaluator.d.ts +1 -1
  34. package/dist/functions.d.cts +8 -4
  35. package/dist/functions.d.ts +8 -4
  36. package/dist/{index.C4tKZ0yW-CfMRGP9u.js → index.C4tKZ0yW-ICJbIYnA.js} +11 -11
  37. package/dist/{index.C4tKZ0yW-CZW6CdWn.cjs → index.C4tKZ0yW-q5POG9-K.cjs} +10 -10
  38. package/dist/index.cjs +8 -1
  39. package/dist/index.d.cts +5 -2
  40. package/dist/index.d.ts +5 -2
  41. package/dist/index.js +5 -2
  42. package/dist/input-resolvers.cjs +63 -0
  43. package/dist/input-resolvers.d.cts +19 -0
  44. package/dist/input-resolvers.d.ts +19 -0
  45. package/dist/input-resolvers.js +61 -0
  46. package/dist/integer-power.cjs +20 -0
  47. package/dist/integer-power.d.cts +13 -0
  48. package/dist/integer-power.d.ts +13 -0
  49. package/dist/integer-power.js +19 -0
  50. package/dist/plain-record.cjs +8 -0
  51. package/dist/plain-record.d.cts +4 -0
  52. package/dist/plain-record.d.ts +4 -0
  53. package/dist/plain-record.js +7 -0
  54. package/dist-cli/trilean.mjs +1745 -0
  55. package/package.json +7 -3
  56. package/schemas/trilean.schema.json +1 -1
@@ -1,7 +1,7 @@
1
1
  //#region \0rolldown/runtime.js
2
2
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
3
3
  //#endregion
4
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.4_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.4_4ca565f8243d3bb5b39217c73caab404/node_modules/vitest/dist/chunks/tinyrainbow.Ht9iggcq.js
4
+ //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.5_5333ae081f4122dbae688304e924e108/node_modules/vitest/dist/chunks/tinyrainbow.Ht9iggcq.js
5
5
  var b$1 = {
6
6
  reset: [0, 0],
7
7
  bold: [
@@ -84,7 +84,7 @@ function C({ force: e } = {}) {
84
84
  }
85
85
  var y$1 = C();
86
86
  //#endregion
87
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.4_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.4_4ca565f8243d3bb5b39217c73caab404/node_modules/vitest/dist/chunks/index.cx-_w29y.js
87
+ //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.5_5333ae081f4122dbae688304e924e108/node_modules/vitest/dist/chunks/index.cx-_w29y.js
88
88
  function _mergeNamespaces(n, m) {
89
89
  m.forEach(function(e) {
90
90
  e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
@@ -1247,7 +1247,7 @@ const plugins = {
1247
1247
  Error: ErrorPlugin
1248
1248
  };
1249
1249
  //#endregion
1250
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.4_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.4_4ca565f8243d3bb5b39217c73caab404/node_modules/vitest/dist/chunks/display.CXBnkt9a.js
1250
+ //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.5_5333ae081f4122dbae688304e924e108/node_modules/vitest/dist/chunks/display.CXBnkt9a.js
1251
1251
  const { AsymmetricMatcher: AsymmetricMatcher$3, DOMCollection: DOMCollection$2, DOMElement: DOMElement$2, Immutable: Immutable$2, ReactElement: ReactElement$2, ReactTestComponent: ReactTestComponent$2 } = plugins;
1252
1252
  const PLUGINS$2 = [
1253
1253
  ReactTestComponent$2,
@@ -1708,7 +1708,7 @@ const isAbsolute = function(p) {
1708
1708
  return _IS_ABSOLUTE_RE.test(p);
1709
1709
  };
1710
1710
  //#endregion
1711
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.4_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.4_4ca565f8243d3bb5b39217c73caab404/node_modules/vitest/dist/chunks/source-map.DUxvo12T.js
1711
+ //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.5_5333ae081f4122dbae688304e924e108/node_modules/vitest/dist/chunks/source-map.DUxvo12T.js
1712
1712
  var build = {};
1713
1713
  var hasRequiredBuild;
1714
1714
  function requireBuild() {
@@ -2487,7 +2487,7 @@ function getOriginalPosition(map, needle) {
2487
2487
  return result;
2488
2488
  }
2489
2489
  //#endregion
2490
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.4_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.4_4ca565f8243d3bb5b39217c73caab404/node_modules/vitest/dist/task-utils.js
2490
+ //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.5_5333ae081f4122dbae688304e924e108/node_modules/vitest/dist/task-utils.js
2491
2491
  /* @__NO_SIDE_EFFECTS__ */
2492
2492
  function getNames(task) {
2493
2493
  const names = [task.name];
@@ -2504,7 +2504,7 @@ function createTaskName(names, separator = " > ") {
2504
2504
  return names.filter((name) => name !== void 0).join(separator);
2505
2505
  }
2506
2506
  //#endregion
2507
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.4_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.4_4ca565f8243d3bb5b39217c73caab404/node_modules/vitest/dist/chunks/run.BTlFXlnv.js
2507
+ //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.5_5333ae081f4122dbae688304e924e108/node_modules/vitest/dist/chunks/run.BTlFXlnv.js
2508
2508
  /**
2509
2509
  * Diff Match and Patch
2510
2510
  * Copyright 2018 The diff-match-patch Authors.
@@ -5072,7 +5072,7 @@ async function finishSendTasksUpdate(runner) {
5072
5072
  await Promise.all(pendingTasksUpdates);
5073
5073
  }
5074
5074
  //#endregion
5075
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.4_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.4_4ca565f8243d3bb5b39217c73caab404/node_modules/vitest/dist/chunks/utils.DYj33du9.js
5075
+ //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.5_5333ae081f4122dbae688304e924e108/node_modules/vitest/dist/chunks/utils.DYj33du9.js
5076
5076
  const NAME_WORKER_STATE = "__vitest_worker__";
5077
5077
  function getWorkerState() {
5078
5078
  const workerState = globalThis[NAME_WORKER_STATE];
@@ -5098,7 +5098,7 @@ function resetModules(modules, resetMocks = false) {
5098
5098
  });
5099
5099
  }
5100
5100
  //#endregion
5101
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.4_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.4_4ca565f8243d3bb5b39217c73caab404/node_modules/vitest/dist/chunks/spy.DgMTfhrK.js
5101
+ //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.5_5333ae081f4122dbae688304e924e108/node_modules/vitest/dist/chunks/spy.DgMTfhrK.js
5102
5102
  function isMockFunction(fn) {
5103
5103
  return typeof fn === "function" && "_isMockFunction" in fn && fn._isMockFunction === true;
5104
5104
  }
@@ -8495,7 +8495,7 @@ function use(fn) {
8495
8495
  }
8496
8496
  __name(use, "use");
8497
8497
  //#endregion
8498
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.4_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.4_4ca565f8243d3bb5b39217c73caab404/node_modules/vitest/dist/chunks/plugins.D2ut1V9b.js
8498
+ //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.5_5333ae081f4122dbae688304e924e108/node_modules/vitest/dist/chunks/plugins.D2ut1V9b.js
8499
8499
  const serialize$1 = (val, config, indentation, depth, refs, printer) => {
8500
8500
  const name = val.getMockName();
8501
8501
  const nameString = name === "vi.fn()" ? "" : ` ${name}`;
@@ -8528,7 +8528,7 @@ function getSerializers() {
8528
8528
  return PLUGINS;
8529
8529
  }
8530
8530
  //#endregion
8531
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.4_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.4_4ca565f8243d3bb5b39217c73caab404/node_modules/vitest/dist/chunks/offset.Dy-5Fdfn.js
8531
+ //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.3_vite@8.2.2_@types+node@26.6.5_5333ae081f4122dbae688304e924e108/node_modules/vitest/dist/chunks/offset.Dy-5Fdfn.js
8532
8532
  const lineSplitRE = /\r?\n/;
8533
8533
  function positionToOffset(source, lineNumber, columnNumber) {
8534
8534
  const lines = source.split(lineSplitRE);
package/dist/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_complex = require("./complex.cjs");
3
2
  const require_computed_value = require("./computed-value.cjs");
3
+ const require_builtin_functions = require("./builtin-functions.cjs");
4
+ const require_complex = require("./complex.cjs");
4
5
  const require_derived_aggregates = require("./derived-aggregates.cjs");
5
6
  const require_derived_connectives = require("./derived-connectives.cjs");
6
7
  const require_derived_patterns = require("./derived-patterns.cjs");
@@ -10,6 +11,8 @@ const require_json_value = require("./json-value.cjs");
10
11
  const require_tree = require("./tree.cjs");
11
12
  const require_functions = require("./functions.cjs");
12
13
  const require_evaluator_factory = require("./evaluator-factory.cjs");
14
+ const require_input_resolvers = require("./input-resolvers.cjs");
15
+ const require_evaluate_document = require("./evaluate-document.cjs");
13
16
  exports.AccumulatorNodeSchema = require_tree.AccumulatorNodeSchema;
14
17
  exports.AllOfNodeSchema = require_tree.AllOfNodeSchema;
15
18
  exports.AndNodeSchema = require_tree.AndNodeSchema;
@@ -55,6 +58,7 @@ exports.TreeReferenceNodeSchema = require_tree.TreeReferenceNodeSchema;
55
58
  exports.UnitSchema = require_computed_value.UnitSchema;
56
59
  exports.and = require_derived_connectives.and;
57
60
  exports.average = require_derived_aggregates.average;
61
+ exports.builtinFunctions = require_builtin_functions.builtinFunctions;
58
62
  exports.coalesce = require_derived_values.coalesce;
59
63
  exports.combineUnitsForDivide = require_computed_value.combineUnitsForDivide;
60
64
  exports.combineUnitsForMultiply = require_computed_value.combineUnitsForMultiply;
@@ -64,9 +68,11 @@ exports.complexMagnitude = require_complex.complexMagnitude;
64
68
  exports.complexPhase = require_complex.complexPhase;
65
69
  exports.count = require_derived_aggregates.count;
66
70
  exports.createEvaluator = require_evaluator_factory.createEvaluator;
71
+ exports.createInputResolvers = require_input_resolvers.createInputResolvers;
67
72
  exports.createSyncEvaluator = require_evaluator_factory.createSyncEvaluator;
68
73
  exports.definite = require_evaluation.definite;
69
74
  exports.emptyFunctionRegistry = require_functions.emptyFunctionRegistry;
75
+ exports.evaluateDocument = require_evaluate_document.evaluateDocument;
70
76
  exports.evaluatePredicate = require_evaluator_factory.evaluatePredicate;
71
77
  exports.evaluateValue = require_evaluator_factory.evaluateValue;
72
78
  exports.firstIndeterminate = require_evaluation.firstIndeterminate;
@@ -79,6 +85,7 @@ exports.none = require_derived_connectives.none;
79
85
  exports.nor = require_derived_connectives.nor;
80
86
  exports.not = require_derived_connectives.not;
81
87
  exports.or = require_derived_connectives.or;
88
+ exports.parseInputs = require_input_resolvers.parseInputs;
82
89
  exports.prefixPattern = require_derived_patterns.prefixPattern;
83
90
  exports.presenceOf = require_derived_aggregates.presenceOf;
84
91
  exports.sum = require_derived_aggregates.sum;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { a as Unit, c as combineUnitsForMultiply, i as DurationUnitSchema, l as unitsEqual, n as ComputedValueSchema, o as UnitSchema, r as DurationUnit, s as combineUnitsForDivide, t as ComputedValue } from "./computed-value-CbRF0Izc.cjs";
2
+ import { FunctionFailure, FunctionRegistry, emptyFunctionRegistry } from "./functions.cjs";
3
+ import { builtinFunctions } from "./builtin-functions.cjs";
2
4
  import { n as JsonValueSchema, t as JsonValue } from "./json-value-B1Hjjjri.cjs";
3
5
  import { AccumulatorNode, AccumulatorNodeSchema, AllOfNode, AllOfNodeSchema, AndNode, AndNodeSchema, AnyOfNode, AnyOfNodeSchema, ArithmeticNode, ArithmeticNodeSchema, ArithmeticOperator, ArithmeticOperatorSchema, BooleanLiteralNode, BooleanLiteralNodeSchema, CallNode, CallNodeSchema, CompareNode, CompareNodeSchema, ComparisonOperator, ComparisonOperatorSchema, ComplexLiteralNode, ComplexLiteralNodeSchema, ComplexPolarLiteralNode, ComplexPolarLiteralNodeSchema, ComplexRectangularLiteralNode, ComplexRectangularLiteralNodeSchema, ConditionalCase, ConditionalCaseSchema, ConditionalNode, ConditionalNodeSchema, DelegateNode, DelegateNodeSchema, DurationLiteralNode, DurationLiteralNodeSchema, EveryNode, EveryNodeSchema, ExistsNode, ExistsNodeSchema, ExpressionNode, ExpressionNodeSchema, FoldCombiner, FoldCombinerSchema, FoldNode, FoldNodeSchema, HitPolicy, HitPolicySchema, InstantLiteralNode, InstantLiteralNodeSchema, LookupNode, LookupNodeSchema, MemberOfNode, MemberOfNodeSchema, MembershipOperator, MembershipOperatorSchema, NegateNode, NegateNodeSchema, NotNode, NotNodeSchema, NumberLiteralNode, NumberLiteralNodeSchema, OrNode, OrNodeSchema, PredicateNode, PredicateNodeSchema, ReferenceNode, ReferenceNodeSchema, SomeNode, SomeNodeSchema, TextCompareNode, TextCompareNodeSchema, TextComparisonOperator, TextComparisonOperatorSchema, TextLiteralNode, TextLiteralNodeSchema, TreeReferenceNode, TreeReferenceNodeSchema } from "./tree.cjs";
4
6
  import { complexFromPolar, complexLiteralFromPolar, complexMagnitude, complexPhase } from "./complex.cjs";
@@ -7,7 +9,8 @@ import { and, iff, implies, nand, none, nor, not, or, xor } from "./derived-conn
7
9
  import { hierarchicalGlobPattern, prefixPattern, wildcardPattern } from "./derived-patterns.cjs";
8
10
  import { coalesce } from "./derived-values.cjs";
9
11
  import { Evaluation, IndeterminateReason, IndeterminateReasonSchema, definite, firstIndeterminate, indeterminate } from "./evaluation.cjs";
10
- import { FunctionRegistry, emptyFunctionRegistry } from "./functions.cjs";
12
+ import { DocumentEvaluation, EvaluateDocumentOptions, TreeKind, evaluateDocument } from "./evaluate-document.cjs";
11
13
  import { EvaluationContext, Resolution, Resolvers, SyncResolvers, TreeResolution } from "./resolvers.cjs";
12
14
  import { EvaluatorOptions, createEvaluator, createSyncEvaluator, evaluatePredicate, evaluateValue } from "./evaluator-factory.cjs";
13
- export { type AccumulatorNode, AccumulatorNodeSchema, type AllOfNode, AllOfNodeSchema, type AndNode, AndNodeSchema, type AnyOfNode, AnyOfNodeSchema, type ArithmeticNode, ArithmeticNodeSchema, type ArithmeticOperator, ArithmeticOperatorSchema, type BooleanLiteralNode, BooleanLiteralNodeSchema, type CallNode, CallNodeSchema, type CompareNode, CompareNodeSchema, type ComparisonOperator, ComparisonOperatorSchema, type ComplexLiteralNode, ComplexLiteralNodeSchema, type ComplexPolarLiteralNode, ComplexPolarLiteralNodeSchema, type ComplexRectangularLiteralNode, ComplexRectangularLiteralNodeSchema, type ComputedValue, ComputedValueSchema, type ConditionalCase, ConditionalCaseSchema, type ConditionalNode, ConditionalNodeSchema, type DelegateNode, DelegateNodeSchema, type DurationLiteralNode, DurationLiteralNodeSchema, type DurationUnit, DurationUnitSchema, type Evaluation, type EvaluationContext, type EvaluatorOptions, type EveryNode, EveryNodeSchema, type ExistsNode, ExistsNodeSchema, type ExpressionNode, ExpressionNodeSchema, type FoldCombiner, FoldCombinerSchema, type FoldNode, FoldNodeSchema, type FunctionRegistry, type HitPolicy, HitPolicySchema, type IndeterminateReason, IndeterminateReasonSchema, type InstantLiteralNode, InstantLiteralNodeSchema, type JsonValue, JsonValueSchema, type LookupNode, LookupNodeSchema, type MemberOfNode, MemberOfNodeSchema, type MembershipOperator, MembershipOperatorSchema, type NegateNode, NegateNodeSchema, type NotNode, NotNodeSchema, type NumberLiteralNode, NumberLiteralNodeSchema, type OrNode, OrNodeSchema, type PredicateNode, PredicateNodeSchema, type ReferenceNode, ReferenceNodeSchema, type Resolution, type Resolvers, type SomeNode, SomeNodeSchema, type SyncResolvers, type TextCompareNode, TextCompareNodeSchema, type TextComparisonOperator, TextComparisonOperatorSchema, type TextLiteralNode, TextLiteralNodeSchema, type TreeReferenceNode, TreeReferenceNodeSchema, type TreeResolution, type Unit, UnitSchema, and, average, coalesce, combineUnitsForDivide, combineUnitsForMultiply, complexFromPolar, complexLiteralFromPolar, complexMagnitude, complexPhase, count, createEvaluator, createSyncEvaluator, definite, emptyFunctionRegistry, evaluatePredicate, evaluateValue, firstIndeterminate, hierarchicalGlobPattern, iff, implies, indeterminate, nand, none, nor, not, or, prefixPattern, presenceOf, sum, unitsEqual, wildcardPattern, xor };
15
+ import { InputsParseResult, createInputResolvers, parseInputs } from "./input-resolvers.cjs";
16
+ export { type AccumulatorNode, AccumulatorNodeSchema, type AllOfNode, AllOfNodeSchema, type AndNode, AndNodeSchema, type AnyOfNode, AnyOfNodeSchema, type ArithmeticNode, ArithmeticNodeSchema, type ArithmeticOperator, ArithmeticOperatorSchema, type BooleanLiteralNode, BooleanLiteralNodeSchema, type CallNode, CallNodeSchema, type CompareNode, CompareNodeSchema, type ComparisonOperator, ComparisonOperatorSchema, type ComplexLiteralNode, ComplexLiteralNodeSchema, type ComplexPolarLiteralNode, ComplexPolarLiteralNodeSchema, type ComplexRectangularLiteralNode, ComplexRectangularLiteralNodeSchema, type ComputedValue, ComputedValueSchema, type ConditionalCase, ConditionalCaseSchema, type ConditionalNode, ConditionalNodeSchema, type DelegateNode, DelegateNodeSchema, type DocumentEvaluation, type DurationLiteralNode, DurationLiteralNodeSchema, type DurationUnit, DurationUnitSchema, type EvaluateDocumentOptions, type Evaluation, type EvaluationContext, type EvaluatorOptions, type EveryNode, EveryNodeSchema, type ExistsNode, ExistsNodeSchema, type ExpressionNode, ExpressionNodeSchema, type FoldCombiner, FoldCombinerSchema, type FoldNode, FoldNodeSchema, type FunctionFailure, type FunctionRegistry, type HitPolicy, HitPolicySchema, type IndeterminateReason, IndeterminateReasonSchema, type InputsParseResult, type InstantLiteralNode, InstantLiteralNodeSchema, type JsonValue, JsonValueSchema, type LookupNode, LookupNodeSchema, type MemberOfNode, MemberOfNodeSchema, type MembershipOperator, MembershipOperatorSchema, type NegateNode, NegateNodeSchema, type NotNode, NotNodeSchema, type NumberLiteralNode, NumberLiteralNodeSchema, type OrNode, OrNodeSchema, type PredicateNode, PredicateNodeSchema, type ReferenceNode, ReferenceNodeSchema, type Resolution, type Resolvers, type SomeNode, SomeNodeSchema, type SyncResolvers, type TextCompareNode, TextCompareNodeSchema, type TextComparisonOperator, TextComparisonOperatorSchema, type TextLiteralNode, TextLiteralNodeSchema, type TreeKind, type TreeReferenceNode, TreeReferenceNodeSchema, type TreeResolution, type Unit, UnitSchema, and, average, builtinFunctions, coalesce, combineUnitsForDivide, combineUnitsForMultiply, complexFromPolar, complexLiteralFromPolar, complexMagnitude, complexPhase, count, createEvaluator, createInputResolvers, createSyncEvaluator, definite, emptyFunctionRegistry, evaluateDocument, evaluatePredicate, evaluateValue, firstIndeterminate, hierarchicalGlobPattern, iff, implies, indeterminate, nand, none, nor, not, or, parseInputs, prefixPattern, presenceOf, sum, unitsEqual, wildcardPattern, xor };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { a as Unit, c as combineUnitsForMultiply, i as DurationUnitSchema, l as unitsEqual, n as ComputedValueSchema, o as UnitSchema, r as DurationUnit, s as combineUnitsForDivide, t as ComputedValue } from "./computed-value-CbRF0Izc.js";
2
+ import { FunctionFailure, FunctionRegistry, emptyFunctionRegistry } from "./functions.js";
3
+ import { builtinFunctions } from "./builtin-functions.js";
2
4
  import { n as JsonValueSchema, t as JsonValue } from "./json-value-B1Hjjjri.js";
3
5
  import { AccumulatorNode, AccumulatorNodeSchema, AllOfNode, AllOfNodeSchema, AndNode, AndNodeSchema, AnyOfNode, AnyOfNodeSchema, ArithmeticNode, ArithmeticNodeSchema, ArithmeticOperator, ArithmeticOperatorSchema, BooleanLiteralNode, BooleanLiteralNodeSchema, CallNode, CallNodeSchema, CompareNode, CompareNodeSchema, ComparisonOperator, ComparisonOperatorSchema, ComplexLiteralNode, ComplexLiteralNodeSchema, ComplexPolarLiteralNode, ComplexPolarLiteralNodeSchema, ComplexRectangularLiteralNode, ComplexRectangularLiteralNodeSchema, ConditionalCase, ConditionalCaseSchema, ConditionalNode, ConditionalNodeSchema, DelegateNode, DelegateNodeSchema, DurationLiteralNode, DurationLiteralNodeSchema, EveryNode, EveryNodeSchema, ExistsNode, ExistsNodeSchema, ExpressionNode, ExpressionNodeSchema, FoldCombiner, FoldCombinerSchema, FoldNode, FoldNodeSchema, HitPolicy, HitPolicySchema, InstantLiteralNode, InstantLiteralNodeSchema, LookupNode, LookupNodeSchema, MemberOfNode, MemberOfNodeSchema, MembershipOperator, MembershipOperatorSchema, NegateNode, NegateNodeSchema, NotNode, NotNodeSchema, NumberLiteralNode, NumberLiteralNodeSchema, OrNode, OrNodeSchema, PredicateNode, PredicateNodeSchema, ReferenceNode, ReferenceNodeSchema, SomeNode, SomeNodeSchema, TextCompareNode, TextCompareNodeSchema, TextComparisonOperator, TextComparisonOperatorSchema, TextLiteralNode, TextLiteralNodeSchema, TreeReferenceNode, TreeReferenceNodeSchema } from "./tree.js";
4
6
  import { complexFromPolar, complexLiteralFromPolar, complexMagnitude, complexPhase } from "./complex.js";
@@ -7,7 +9,8 @@ import { and, iff, implies, nand, none, nor, not, or, xor } from "./derived-conn
7
9
  import { hierarchicalGlobPattern, prefixPattern, wildcardPattern } from "./derived-patterns.js";
8
10
  import { coalesce } from "./derived-values.js";
9
11
  import { Evaluation, IndeterminateReason, IndeterminateReasonSchema, definite, firstIndeterminate, indeterminate } from "./evaluation.js";
10
- import { FunctionRegistry, emptyFunctionRegistry } from "./functions.js";
12
+ import { DocumentEvaluation, EvaluateDocumentOptions, TreeKind, evaluateDocument } from "./evaluate-document.js";
11
13
  import { EvaluationContext, Resolution, Resolvers, SyncResolvers, TreeResolution } from "./resolvers.js";
12
14
  import { EvaluatorOptions, createEvaluator, createSyncEvaluator, evaluatePredicate, evaluateValue } from "./evaluator-factory.js";
13
- export { type AccumulatorNode, AccumulatorNodeSchema, type AllOfNode, AllOfNodeSchema, type AndNode, AndNodeSchema, type AnyOfNode, AnyOfNodeSchema, type ArithmeticNode, ArithmeticNodeSchema, type ArithmeticOperator, ArithmeticOperatorSchema, type BooleanLiteralNode, BooleanLiteralNodeSchema, type CallNode, CallNodeSchema, type CompareNode, CompareNodeSchema, type ComparisonOperator, ComparisonOperatorSchema, type ComplexLiteralNode, ComplexLiteralNodeSchema, type ComplexPolarLiteralNode, ComplexPolarLiteralNodeSchema, type ComplexRectangularLiteralNode, ComplexRectangularLiteralNodeSchema, type ComputedValue, ComputedValueSchema, type ConditionalCase, ConditionalCaseSchema, type ConditionalNode, ConditionalNodeSchema, type DelegateNode, DelegateNodeSchema, type DurationLiteralNode, DurationLiteralNodeSchema, type DurationUnit, DurationUnitSchema, type Evaluation, type EvaluationContext, type EvaluatorOptions, type EveryNode, EveryNodeSchema, type ExistsNode, ExistsNodeSchema, type ExpressionNode, ExpressionNodeSchema, type FoldCombiner, FoldCombinerSchema, type FoldNode, FoldNodeSchema, type FunctionRegistry, type HitPolicy, HitPolicySchema, type IndeterminateReason, IndeterminateReasonSchema, type InstantLiteralNode, InstantLiteralNodeSchema, type JsonValue, JsonValueSchema, type LookupNode, LookupNodeSchema, type MemberOfNode, MemberOfNodeSchema, type MembershipOperator, MembershipOperatorSchema, type NegateNode, NegateNodeSchema, type NotNode, NotNodeSchema, type NumberLiteralNode, NumberLiteralNodeSchema, type OrNode, OrNodeSchema, type PredicateNode, PredicateNodeSchema, type ReferenceNode, ReferenceNodeSchema, type Resolution, type Resolvers, type SomeNode, SomeNodeSchema, type SyncResolvers, type TextCompareNode, TextCompareNodeSchema, type TextComparisonOperator, TextComparisonOperatorSchema, type TextLiteralNode, TextLiteralNodeSchema, type TreeReferenceNode, TreeReferenceNodeSchema, type TreeResolution, type Unit, UnitSchema, and, average, coalesce, combineUnitsForDivide, combineUnitsForMultiply, complexFromPolar, complexLiteralFromPolar, complexMagnitude, complexPhase, count, createEvaluator, createSyncEvaluator, definite, emptyFunctionRegistry, evaluatePredicate, evaluateValue, firstIndeterminate, hierarchicalGlobPattern, iff, implies, indeterminate, nand, none, nor, not, or, prefixPattern, presenceOf, sum, unitsEqual, wildcardPattern, xor };
15
+ import { InputsParseResult, createInputResolvers, parseInputs } from "./input-resolvers.js";
16
+ export { type AccumulatorNode, AccumulatorNodeSchema, type AllOfNode, AllOfNodeSchema, type AndNode, AndNodeSchema, type AnyOfNode, AnyOfNodeSchema, type ArithmeticNode, ArithmeticNodeSchema, type ArithmeticOperator, ArithmeticOperatorSchema, type BooleanLiteralNode, BooleanLiteralNodeSchema, type CallNode, CallNodeSchema, type CompareNode, CompareNodeSchema, type ComparisonOperator, ComparisonOperatorSchema, type ComplexLiteralNode, ComplexLiteralNodeSchema, type ComplexPolarLiteralNode, ComplexPolarLiteralNodeSchema, type ComplexRectangularLiteralNode, ComplexRectangularLiteralNodeSchema, type ComputedValue, ComputedValueSchema, type ConditionalCase, ConditionalCaseSchema, type ConditionalNode, ConditionalNodeSchema, type DelegateNode, DelegateNodeSchema, type DocumentEvaluation, type DurationLiteralNode, DurationLiteralNodeSchema, type DurationUnit, DurationUnitSchema, type EvaluateDocumentOptions, type Evaluation, type EvaluationContext, type EvaluatorOptions, type EveryNode, EveryNodeSchema, type ExistsNode, ExistsNodeSchema, type ExpressionNode, ExpressionNodeSchema, type FoldCombiner, FoldCombinerSchema, type FoldNode, FoldNodeSchema, type FunctionFailure, type FunctionRegistry, type HitPolicy, HitPolicySchema, type IndeterminateReason, IndeterminateReasonSchema, type InputsParseResult, type InstantLiteralNode, InstantLiteralNodeSchema, type JsonValue, JsonValueSchema, type LookupNode, LookupNodeSchema, type MemberOfNode, MemberOfNodeSchema, type MembershipOperator, MembershipOperatorSchema, type NegateNode, NegateNodeSchema, type NotNode, NotNodeSchema, type NumberLiteralNode, NumberLiteralNodeSchema, type OrNode, OrNodeSchema, type PredicateNode, PredicateNodeSchema, type ReferenceNode, ReferenceNodeSchema, type Resolution, type Resolvers, type SomeNode, SomeNodeSchema, type SyncResolvers, type TextCompareNode, TextCompareNodeSchema, type TextComparisonOperator, TextComparisonOperatorSchema, type TextLiteralNode, TextLiteralNodeSchema, type TreeKind, type TreeReferenceNode, TreeReferenceNodeSchema, type TreeResolution, type Unit, UnitSchema, and, average, builtinFunctions, coalesce, combineUnitsForDivide, combineUnitsForMultiply, complexFromPolar, complexLiteralFromPolar, complexMagnitude, complexPhase, count, createEvaluator, createInputResolvers, createSyncEvaluator, definite, emptyFunctionRegistry, evaluateDocument, evaluatePredicate, evaluateValue, firstIndeterminate, hierarchicalGlobPattern, iff, implies, indeterminate, nand, none, nor, not, or, parseInputs, prefixPattern, presenceOf, sum, unitsEqual, wildcardPattern, xor };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
- import { complexFromPolar, complexLiteralFromPolar, complexMagnitude, complexPhase } from "./complex.js";
2
1
  import { ComputedValueSchema, DurationUnitSchema, UnitSchema, combineUnitsForDivide, combineUnitsForMultiply, unitsEqual } from "./computed-value.js";
2
+ import { builtinFunctions } from "./builtin-functions.js";
3
+ import { complexFromPolar, complexLiteralFromPolar, complexMagnitude, complexPhase } from "./complex.js";
3
4
  import { average, count, presenceOf, sum } from "./derived-aggregates.js";
4
5
  import { and, iff, implies, nand, none, nor, not, or, xor } from "./derived-connectives.js";
5
6
  import { hierarchicalGlobPattern, prefixPattern, wildcardPattern } from "./derived-patterns.js";
@@ -9,4 +10,6 @@ import { JsonValueSchema } from "./json-value.js";
9
10
  import { AccumulatorNodeSchema, AllOfNodeSchema, AndNodeSchema, AnyOfNodeSchema, ArithmeticNodeSchema, ArithmeticOperatorSchema, BooleanLiteralNodeSchema, CallNodeSchema, CompareNodeSchema, ComparisonOperatorSchema, ComplexLiteralNodeSchema, ComplexPolarLiteralNodeSchema, ComplexRectangularLiteralNodeSchema, ConditionalCaseSchema, ConditionalNodeSchema, DelegateNodeSchema, DurationLiteralNodeSchema, EveryNodeSchema, ExistsNodeSchema, ExpressionNodeSchema, FoldCombinerSchema, FoldNodeSchema, HitPolicySchema, InstantLiteralNodeSchema, LookupNodeSchema, MemberOfNodeSchema, MembershipOperatorSchema, NegateNodeSchema, NotNodeSchema, NumberLiteralNodeSchema, OrNodeSchema, PredicateNodeSchema, ReferenceNodeSchema, SomeNodeSchema, TextCompareNodeSchema, TextComparisonOperatorSchema, TextLiteralNodeSchema, TreeReferenceNodeSchema } from "./tree.js";
10
11
  import { emptyFunctionRegistry } from "./functions.js";
11
12
  import { createEvaluator, createSyncEvaluator, evaluatePredicate, evaluateValue } from "./evaluator-factory.js";
12
- export { AccumulatorNodeSchema, AllOfNodeSchema, AndNodeSchema, AnyOfNodeSchema, ArithmeticNodeSchema, ArithmeticOperatorSchema, BooleanLiteralNodeSchema, CallNodeSchema, CompareNodeSchema, ComparisonOperatorSchema, ComplexLiteralNodeSchema, ComplexPolarLiteralNodeSchema, ComplexRectangularLiteralNodeSchema, ComputedValueSchema, ConditionalCaseSchema, ConditionalNodeSchema, DelegateNodeSchema, DurationLiteralNodeSchema, DurationUnitSchema, EveryNodeSchema, ExistsNodeSchema, ExpressionNodeSchema, FoldCombinerSchema, FoldNodeSchema, HitPolicySchema, IndeterminateReasonSchema, InstantLiteralNodeSchema, JsonValueSchema, LookupNodeSchema, MemberOfNodeSchema, MembershipOperatorSchema, NegateNodeSchema, NotNodeSchema, NumberLiteralNodeSchema, OrNodeSchema, PredicateNodeSchema, ReferenceNodeSchema, SomeNodeSchema, TextCompareNodeSchema, TextComparisonOperatorSchema, TextLiteralNodeSchema, TreeReferenceNodeSchema, UnitSchema, and, average, coalesce, combineUnitsForDivide, combineUnitsForMultiply, complexFromPolar, complexLiteralFromPolar, complexMagnitude, complexPhase, count, createEvaluator, createSyncEvaluator, definite, emptyFunctionRegistry, evaluatePredicate, evaluateValue, firstIndeterminate, hierarchicalGlobPattern, iff, implies, indeterminate, nand, none, nor, not, or, prefixPattern, presenceOf, sum, unitsEqual, wildcardPattern, xor };
13
+ import { createInputResolvers, parseInputs } from "./input-resolvers.js";
14
+ import { evaluateDocument } from "./evaluate-document.js";
15
+ export { AccumulatorNodeSchema, AllOfNodeSchema, AndNodeSchema, AnyOfNodeSchema, ArithmeticNodeSchema, ArithmeticOperatorSchema, BooleanLiteralNodeSchema, CallNodeSchema, CompareNodeSchema, ComparisonOperatorSchema, ComplexLiteralNodeSchema, ComplexPolarLiteralNodeSchema, ComplexRectangularLiteralNodeSchema, ComputedValueSchema, ConditionalCaseSchema, ConditionalNodeSchema, DelegateNodeSchema, DurationLiteralNodeSchema, DurationUnitSchema, EveryNodeSchema, ExistsNodeSchema, ExpressionNodeSchema, FoldCombinerSchema, FoldNodeSchema, HitPolicySchema, IndeterminateReasonSchema, InstantLiteralNodeSchema, JsonValueSchema, LookupNodeSchema, MemberOfNodeSchema, MembershipOperatorSchema, NegateNodeSchema, NotNodeSchema, NumberLiteralNodeSchema, OrNodeSchema, PredicateNodeSchema, ReferenceNodeSchema, SomeNodeSchema, TextCompareNodeSchema, TextComparisonOperatorSchema, TextLiteralNodeSchema, TreeReferenceNodeSchema, UnitSchema, and, average, builtinFunctions, coalesce, combineUnitsForDivide, combineUnitsForMultiply, complexFromPolar, complexLiteralFromPolar, complexMagnitude, complexPhase, count, createEvaluator, createInputResolvers, createSyncEvaluator, definite, emptyFunctionRegistry, evaluateDocument, evaluatePredicate, evaluateValue, firstIndeterminate, hierarchicalGlobPattern, iff, implies, indeterminate, nand, none, nor, not, or, parseInputs, prefixPattern, presenceOf, sum, unitsEqual, wildcardPattern, xor };
@@ -0,0 +1,63 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_computed_value = require("./computed-value.cjs");
3
+ const require_plain_record = require("./plain-record.cjs");
4
+ //#region src/input-resolvers.ts
5
+ /** A plain JSON number, string or boolean is the unit-less value of that kind; anything else must already be a complete `ComputedValue` (the only way to supply units, durations, instants or complex values). Both routes end in `ComputedValueSchema`, so a number that is not finite (`1e999` parses to `Infinity`) is refused whichever way it was written, and a field the schema does not define is dropped rather than carried along. */
6
+ function toComputedValue(raw) {
7
+ const candidate = typeof raw === "number" ? {
8
+ kind: "number",
9
+ value: raw
10
+ } : typeof raw === "string" ? {
11
+ kind: "text",
12
+ value: raw
13
+ } : typeof raw === "boolean" ? {
14
+ kind: "boolean",
15
+ value: raw
16
+ } : raw;
17
+ const parsed = require_computed_value.ComputedValueSchema.safeParse(candidate);
18
+ return parsed.success ? parsed.data : void 0;
19
+ }
20
+ /**
21
+ * Validates a plain object of named inputs, one `ComputedValue` per name (see `toComputedValue` for the accepted shapes). Every entry is checked up front, so a malformed input is reported as one by name rather than surfacing later as a `not-found` reference.
22
+ */
23
+ function parseInputs(raw) {
24
+ if (!require_plain_record.isPlainRecord(raw)) return {
25
+ ok: false,
26
+ issues: ["inputs must be a JSON object of named values"]
27
+ };
28
+ const inputs = /* @__PURE__ */ new Map();
29
+ const issues = [];
30
+ for (const [name, value] of Object.entries(raw)) {
31
+ const computed = toComputedValue(value);
32
+ if (computed === void 0) issues.push(`inputs.${name}: expected a finite number, text, boolean or a complete computed value`);
33
+ else inputs.set(name, computed);
34
+ }
35
+ return issues.length === 0 ? {
36
+ ok: true,
37
+ inputs
38
+ } : {
39
+ ok: false,
40
+ issues
41
+ };
42
+ }
43
+ /**
44
+ * Synchronous resolvers over a fixed set of named inputs: a `reference` whose key is a string naming an input resolves to it, and every other key, and every `lookup`, is `not-found`. `resolveCollection` throws, because a fixed map of scalars has no collection to hand back and an empty list would silently change what a `fold`, `some` or `every` means; `delegate` and `treeReference` nodes are left unresolved, so they are `wrong-type` like any node whose optional resolver is absent.
45
+ */
46
+ function createInputResolvers(inputs) {
47
+ return {
48
+ resolveValue: (key) => {
49
+ const value = typeof key === "string" ? inputs.get(key) : void 0;
50
+ return value === void 0 ? { found: false } : {
51
+ found: true,
52
+ value
53
+ };
54
+ },
55
+ resolveLookup: () => ({ found: false }),
56
+ resolveCollection: (collection) => {
57
+ throw new Error(`collection ${JSON.stringify(collection)} cannot be resolved: named inputs hold scalar values only`);
58
+ }
59
+ };
60
+ }
61
+ //#endregion
62
+ exports.createInputResolvers = createInputResolvers;
63
+ exports.parseInputs = parseInputs;
@@ -0,0 +1,19 @@
1
+ import { t as ComputedValue } from "./computed-value-CbRF0Izc.cjs";
2
+ import { SyncResolvers } from "./resolvers.cjs";
3
+ //#region src/input-resolvers.d.ts
4
+ export type InputsParseResult = {
5
+ ok: true;
6
+ inputs: ReadonlyMap<string, ComputedValue>;
7
+ } | {
8
+ ok: false;
9
+ issues: readonly string[];
10
+ };
11
+ /**
12
+ * Validates a plain object of named inputs, one `ComputedValue` per name (see `toComputedValue` for the accepted shapes). Every entry is checked up front, so a malformed input is reported as one by name rather than surfacing later as a `not-found` reference.
13
+ */
14
+ export declare function parseInputs(raw: unknown): InputsParseResult;
15
+ /**
16
+ * Synchronous resolvers over a fixed set of named inputs: a `reference` whose key is a string naming an input resolves to it, and every other key, and every `lookup`, is `not-found`. `resolveCollection` throws, because a fixed map of scalars has no collection to hand back and an empty list would silently change what a `fold`, `some` or `every` means; `delegate` and `treeReference` nodes are left unresolved, so they are `wrong-type` like any node whose optional resolver is absent.
17
+ */
18
+ export declare function createInputResolvers(inputs: ReadonlyMap<string, ComputedValue>): SyncResolvers;
19
+ //#endregion
@@ -0,0 +1,19 @@
1
+ import { t as ComputedValue } from "./computed-value-CbRF0Izc.js";
2
+ import { SyncResolvers } from "./resolvers.js";
3
+ //#region src/input-resolvers.d.ts
4
+ export type InputsParseResult = {
5
+ ok: true;
6
+ inputs: ReadonlyMap<string, ComputedValue>;
7
+ } | {
8
+ ok: false;
9
+ issues: readonly string[];
10
+ };
11
+ /**
12
+ * Validates a plain object of named inputs, one `ComputedValue` per name (see `toComputedValue` for the accepted shapes). Every entry is checked up front, so a malformed input is reported as one by name rather than surfacing later as a `not-found` reference.
13
+ */
14
+ export declare function parseInputs(raw: unknown): InputsParseResult;
15
+ /**
16
+ * Synchronous resolvers over a fixed set of named inputs: a `reference` whose key is a string naming an input resolves to it, and every other key, and every `lookup`, is `not-found`. `resolveCollection` throws, because a fixed map of scalars has no collection to hand back and an empty list would silently change what a `fold`, `some` or `every` means; `delegate` and `treeReference` nodes are left unresolved, so they are `wrong-type` like any node whose optional resolver is absent.
17
+ */
18
+ export declare function createInputResolvers(inputs: ReadonlyMap<string, ComputedValue>): SyncResolvers;
19
+ //#endregion
@@ -0,0 +1,61 @@
1
+ import { ComputedValueSchema } from "./computed-value.js";
2
+ import { isPlainRecord } from "./plain-record.js";
3
+ //#region src/input-resolvers.ts
4
+ /** A plain JSON number, string or boolean is the unit-less value of that kind; anything else must already be a complete `ComputedValue` (the only way to supply units, durations, instants or complex values). Both routes end in `ComputedValueSchema`, so a number that is not finite (`1e999` parses to `Infinity`) is refused whichever way it was written, and a field the schema does not define is dropped rather than carried along. */
5
+ function toComputedValue(raw) {
6
+ const candidate = typeof raw === "number" ? {
7
+ kind: "number",
8
+ value: raw
9
+ } : typeof raw === "string" ? {
10
+ kind: "text",
11
+ value: raw
12
+ } : typeof raw === "boolean" ? {
13
+ kind: "boolean",
14
+ value: raw
15
+ } : raw;
16
+ const parsed = ComputedValueSchema.safeParse(candidate);
17
+ return parsed.success ? parsed.data : void 0;
18
+ }
19
+ /**
20
+ * Validates a plain object of named inputs, one `ComputedValue` per name (see `toComputedValue` for the accepted shapes). Every entry is checked up front, so a malformed input is reported as one by name rather than surfacing later as a `not-found` reference.
21
+ */
22
+ function parseInputs(raw) {
23
+ if (!isPlainRecord(raw)) return {
24
+ ok: false,
25
+ issues: ["inputs must be a JSON object of named values"]
26
+ };
27
+ const inputs = /* @__PURE__ */ new Map();
28
+ const issues = [];
29
+ for (const [name, value] of Object.entries(raw)) {
30
+ const computed = toComputedValue(value);
31
+ if (computed === void 0) issues.push(`inputs.${name}: expected a finite number, text, boolean or a complete computed value`);
32
+ else inputs.set(name, computed);
33
+ }
34
+ return issues.length === 0 ? {
35
+ ok: true,
36
+ inputs
37
+ } : {
38
+ ok: false,
39
+ issues
40
+ };
41
+ }
42
+ /**
43
+ * Synchronous resolvers over a fixed set of named inputs: a `reference` whose key is a string naming an input resolves to it, and every other key, and every `lookup`, is `not-found`. `resolveCollection` throws, because a fixed map of scalars has no collection to hand back and an empty list would silently change what a `fold`, `some` or `every` means; `delegate` and `treeReference` nodes are left unresolved, so they are `wrong-type` like any node whose optional resolver is absent.
44
+ */
45
+ function createInputResolvers(inputs) {
46
+ return {
47
+ resolveValue: (key) => {
48
+ const value = typeof key === "string" ? inputs.get(key) : void 0;
49
+ return value === void 0 ? { found: false } : {
50
+ found: true,
51
+ value
52
+ };
53
+ },
54
+ resolveLookup: () => ({ found: false }),
55
+ resolveCollection: (collection) => {
56
+ throw new Error(`collection ${JSON.stringify(collection)} cannot be resolved: named inputs hold scalar values only`);
57
+ }
58
+ };
59
+ }
60
+ //#endregion
61
+ export { createInputResolvers, parseInputs };
@@ -0,0 +1,20 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/integer-power.ts
3
+ /**
4
+ * `base` raised to a non-negative integer `exponent` by exponentiation by squaring: one squaring and at most one product per bit of the exponent, so the number of `multiply` calls grows with the logarithm of the exponent where repeated multiplication grows with the exponent itself (an exponent of 1e9 is a few dozen products rather than a billion). `identity` is the value of exponent zero and the start of the product; `multiply` must be associative, which squaring relies on. With a rounding `multiply` the grouping matters: squaring compounds a rounding error through each successive square, so its error grows in proportion to the exponent, and for large exponents the result is many times less accurate than a plain loop's, in exchange for work that does not grow with the exponent.
5
+ *
6
+ * The exponent is halved with `Math.floor(remaining / 2)` and tested for oddness with `% 2`, both exact for any finite double, including those past the largest safe integer, whose low bits are all zero. The last squaring is skipped, so no unused product is formed and a base too large to square is not squared once more than the result needs.
7
+ */
8
+ function powerByRepeatedSquaring({ base, exponent, identity, multiply }) {
9
+ let result = identity;
10
+ let factor = base;
11
+ let remaining = exponent;
12
+ while (remaining > 0) {
13
+ if (remaining % 2 === 1) result = multiply(result, factor);
14
+ remaining = Math.floor(remaining / 2);
15
+ if (remaining > 0) factor = multiply(factor, factor);
16
+ }
17
+ return result;
18
+ }
19
+ //#endregion
20
+ exports.powerByRepeatedSquaring = powerByRepeatedSquaring;
@@ -0,0 +1,13 @@
1
+ //#region src/integer-power.d.ts
2
+ /**
3
+ * `base` raised to a non-negative integer `exponent` by exponentiation by squaring: one squaring and at most one product per bit of the exponent, so the number of `multiply` calls grows with the logarithm of the exponent where repeated multiplication grows with the exponent itself (an exponent of 1e9 is a few dozen products rather than a billion). `identity` is the value of exponent zero and the start of the product; `multiply` must be associative, which squaring relies on. With a rounding `multiply` the grouping matters: squaring compounds a rounding error through each successive square, so its error grows in proportion to the exponent, and for large exponents the result is many times less accurate than a plain loop's, in exchange for work that does not grow with the exponent.
4
+ *
5
+ * The exponent is halved with `Math.floor(remaining / 2)` and tested for oddness with `% 2`, both exact for any finite double, including those past the largest safe integer, whose low bits are all zero. The last squaring is skipped, so no unused product is formed and a base too large to square is not squared once more than the result needs.
6
+ */
7
+ export declare function powerByRepeatedSquaring<T>({ base, exponent, identity, multiply }: {
8
+ base: T;
9
+ exponent: number;
10
+ identity: T;
11
+ multiply: (left: T, right: T) => T;
12
+ }): T;
13
+ //#endregion
@@ -0,0 +1,13 @@
1
+ //#region src/integer-power.d.ts
2
+ /**
3
+ * `base` raised to a non-negative integer `exponent` by exponentiation by squaring: one squaring and at most one product per bit of the exponent, so the number of `multiply` calls grows with the logarithm of the exponent where repeated multiplication grows with the exponent itself (an exponent of 1e9 is a few dozen products rather than a billion). `identity` is the value of exponent zero and the start of the product; `multiply` must be associative, which squaring relies on. With a rounding `multiply` the grouping matters: squaring compounds a rounding error through each successive square, so its error grows in proportion to the exponent, and for large exponents the result is many times less accurate than a plain loop's, in exchange for work that does not grow with the exponent.
4
+ *
5
+ * The exponent is halved with `Math.floor(remaining / 2)` and tested for oddness with `% 2`, both exact for any finite double, including those past the largest safe integer, whose low bits are all zero. The last squaring is skipped, so no unused product is formed and a base too large to square is not squared once more than the result needs.
6
+ */
7
+ export declare function powerByRepeatedSquaring<T>({ base, exponent, identity, multiply }: {
8
+ base: T;
9
+ exponent: number;
10
+ identity: T;
11
+ multiply: (left: T, right: T) => T;
12
+ }): T;
13
+ //#endregion
@@ -0,0 +1,19 @@
1
+ //#region src/integer-power.ts
2
+ /**
3
+ * `base` raised to a non-negative integer `exponent` by exponentiation by squaring: one squaring and at most one product per bit of the exponent, so the number of `multiply` calls grows with the logarithm of the exponent where repeated multiplication grows with the exponent itself (an exponent of 1e9 is a few dozen products rather than a billion). `identity` is the value of exponent zero and the start of the product; `multiply` must be associative, which squaring relies on. With a rounding `multiply` the grouping matters: squaring compounds a rounding error through each successive square, so its error grows in proportion to the exponent, and for large exponents the result is many times less accurate than a plain loop's, in exchange for work that does not grow with the exponent.
4
+ *
5
+ * The exponent is halved with `Math.floor(remaining / 2)` and tested for oddness with `% 2`, both exact for any finite double, including those past the largest safe integer, whose low bits are all zero. The last squaring is skipped, so no unused product is formed and a base too large to square is not squared once more than the result needs.
6
+ */
7
+ function powerByRepeatedSquaring({ base, exponent, identity, multiply }) {
8
+ let result = identity;
9
+ let factor = base;
10
+ let remaining = exponent;
11
+ while (remaining > 0) {
12
+ if (remaining % 2 === 1) result = multiply(result, factor);
13
+ remaining = Math.floor(remaining / 2);
14
+ if (remaining > 0) factor = multiply(factor, factor);
15
+ }
16
+ return result;
17
+ }
18
+ //#endregion
19
+ export { powerByRepeatedSquaring };
@@ -0,0 +1,8 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/plain-record.ts
3
+ /** Narrows `unknown` to a plain JSON-style object: not `null`, not an array. The guard parsed JSON is checked with before its fields are read, in place of an `as Record<string, unknown>` assertion. */
4
+ function isPlainRecord(value) {
5
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6
+ }
7
+ //#endregion
8
+ exports.isPlainRecord = isPlainRecord;
@@ -0,0 +1,4 @@
1
+ //#region src/plain-record.d.ts
2
+ /** Narrows `unknown` to a plain JSON-style object: not `null`, not an array. The guard parsed JSON is checked with before its fields are read, in place of an `as Record<string, unknown>` assertion. */
3
+ export declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
4
+ //#endregion
@@ -0,0 +1,4 @@
1
+ //#region src/plain-record.d.ts
2
+ /** Narrows `unknown` to a plain JSON-style object: not `null`, not an array. The guard parsed JSON is checked with before its fields are read, in place of an `as Record<string, unknown>` assertion. */
3
+ export declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
4
+ //#endregion
@@ -0,0 +1,7 @@
1
+ //#region src/plain-record.ts
2
+ /** Narrows `unknown` to a plain JSON-style object: not `null`, not an array. The guard parsed JSON is checked with before its fields are read, in place of an `as Record<string, unknown>` assertion. */
3
+ function isPlainRecord(value) {
4
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5
+ }
6
+ //#endregion
7
+ export { isPlainRecord };