@ghostry/fabricator 0.0.1 → 0.0.2

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 (124) hide show
  1. package/README.md +1 -7
  2. package/dist/esm/Error/index.js +8 -0
  3. package/dist/esm/Instance/Core.js +8 -17
  4. package/dist/esm/Instance/Stack/Async.js +10 -0
  5. package/dist/esm/Instance/Stack/Sync.js +16 -0
  6. package/dist/esm/Primitive/bigint/Registry.js +12 -12
  7. package/dist/esm/Primitive/boolean/Registry.js +2 -1
  8. package/dist/esm/Primitive/date/Registry.js +15 -14
  9. package/dist/esm/Primitive/null/Registry.js +2 -1
  10. package/dist/esm/Primitive/number/Registry.js +18 -17
  11. package/dist/esm/Primitive/symbol/Registry.js +2 -1
  12. package/dist/esm/Primitive/undefined/Registry.js +2 -1
  13. package/dist/esm/Random/CallSite.js +27 -13
  14. package/dist/esm/Utility/Core.js +6 -1
  15. package/dist/esm/index.js +4 -2
  16. package/dist/esm/internal.js +2 -1
  17. package/dist/types/Adapter/Core.d.ts +29 -32
  18. package/dist/types/Adapter/Types.d.ts +78 -88
  19. package/dist/types/Bound.d.ts +15 -15
  20. package/dist/types/Distribution/index.d.ts +54 -61
  21. package/dist/types/Enumeration/Enumerate.d.ts +21 -23
  22. package/dist/types/Enumeration/Plan.d.ts +22 -26
  23. package/dist/types/Enumeration/Types.d.ts +38 -43
  24. package/dist/types/Error/index.d.ts +94 -76
  25. package/dist/types/Fabricator/Constructor.d.ts +23 -25
  26. package/dist/types/Fabricator/Types.d.ts +73 -81
  27. package/dist/types/Instance/Core.d.ts +54 -73
  28. package/dist/types/Instance/Stack/Async.d.ts +14 -0
  29. package/dist/types/Instance/Stack/Sync.d.ts +14 -0
  30. package/dist/types/Instance/Types.d.ts +91 -89
  31. package/dist/types/Primitive/always/Schema.d.ts +8 -8
  32. package/dist/types/Primitive/always/Types.d.ts +7 -7
  33. package/dist/types/Primitive/array/Registry.d.ts +10 -8
  34. package/dist/types/Primitive/array/Schema.d.ts +4 -5
  35. package/dist/types/Primitive/array/Types.d.ts +6 -6
  36. package/dist/types/Primitive/bigint/Registry.d.ts +6 -6
  37. package/dist/types/Primitive/bigint/Schema.d.ts +8 -8
  38. package/dist/types/Primitive/bigint/Types.d.ts +5 -5
  39. package/dist/types/Primitive/boolean/Outcomes.d.ts +8 -8
  40. package/dist/types/Primitive/boolean/Registry.d.ts +2 -12
  41. package/dist/types/Primitive/boolean/Schema.d.ts +8 -8
  42. package/dist/types/Primitive/boolean/Types.d.ts +3 -3
  43. package/dist/types/Primitive/choice/Fabricator.d.ts +6 -7
  44. package/dist/types/Primitive/choice/Registry.d.ts +13 -13
  45. package/dist/types/Primitive/choice/Schema.d.ts +6 -6
  46. package/dist/types/Primitive/choice/Types.d.ts +11 -11
  47. package/dist/types/Primitive/date/Registry.d.ts +25 -48
  48. package/dist/types/Primitive/date/Schema.d.ts +9 -10
  49. package/dist/types/Primitive/date/Types.d.ts +4 -4
  50. package/dist/types/Primitive/enum/Registry.d.ts +13 -13
  51. package/dist/types/Primitive/enum/Schema.d.ts +5 -5
  52. package/dist/types/Primitive/enum/Types.d.ts +17 -19
  53. package/dist/types/Primitive/namespace.d.ts +10 -10
  54. package/dist/types/Primitive/null/Registry.d.ts +2 -2
  55. package/dist/types/Primitive/null/Schema.d.ts +2 -2
  56. package/dist/types/Primitive/null/Types.d.ts +3 -3
  57. package/dist/types/Primitive/nullable/Fabricator.d.ts +7 -7
  58. package/dist/types/Primitive/nullable/Schema.d.ts +13 -13
  59. package/dist/types/Primitive/nullable/Types.d.ts +9 -10
  60. package/dist/types/Primitive/nullish/Fabricator.d.ts +12 -13
  61. package/dist/types/Primitive/nullish/Schema.d.ts +8 -8
  62. package/dist/types/Primitive/nullish/Types.d.ts +12 -13
  63. package/dist/types/Primitive/number/Registry.d.ts +20 -38
  64. package/dist/types/Primitive/number/Schema.d.ts +11 -12
  65. package/dist/types/Primitive/number/Types.d.ts +13 -13
  66. package/dist/types/Primitive/number/defaults.d.ts +3 -3
  67. package/dist/types/Primitive/object/Fabricator.d.ts +15 -15
  68. package/dist/types/Primitive/object/Registry.d.ts +8 -8
  69. package/dist/types/Primitive/object/Schema.d.ts +10 -10
  70. package/dist/types/Primitive/object/Types.d.ts +20 -22
  71. package/dist/types/Primitive/object/compute/Fabricator.d.ts +4 -5
  72. package/dist/types/Primitive/object/compute/Schema.d.ts +4 -4
  73. package/dist/types/Primitive/object/compute/Types.d.ts +19 -20
  74. package/dist/types/Primitive/object/omittable/Fabricator.d.ts +10 -10
  75. package/dist/types/Primitive/object/omittable/Outcomes.d.ts +2 -2
  76. package/dist/types/Primitive/object/omittable/Schema.d.ts +11 -11
  77. package/dist/types/Primitive/object/omittable/Types.d.ts +14 -15
  78. package/dist/types/Primitive/object/optional/Fabricator.d.ts +16 -18
  79. package/dist/types/Primitive/object/optional/Outcomes.d.ts +2 -2
  80. package/dist/types/Primitive/object/optional/Schema.d.ts +4 -4
  81. package/dist/types/Primitive/object/optional/Types.d.ts +17 -17
  82. package/dist/types/Primitive/opaque/Registry.d.ts +3 -3
  83. package/dist/types/Primitive/opaque/Schema.d.ts +8 -9
  84. package/dist/types/Primitive/record/Registry.d.ts +8 -6
  85. package/dist/types/Primitive/record/Schema.d.ts +9 -11
  86. package/dist/types/Primitive/record/Types.d.ts +25 -25
  87. package/dist/types/Primitive/recursive/Fabricator.d.ts +16 -17
  88. package/dist/types/Primitive/recursive/Registry.d.ts +6 -7
  89. package/dist/types/Primitive/recursive/Schema.d.ts +8 -8
  90. package/dist/types/Primitive/recursive/Terminate.d.ts +13 -14
  91. package/dist/types/Primitive/recursive/Types.d.ts +31 -31
  92. package/dist/types/Primitive/recursive/self/Fabricator.d.ts +11 -12
  93. package/dist/types/Primitive/recursive/self/Schema.d.ts +10 -10
  94. package/dist/types/Primitive/recursive/self/Types.d.ts +7 -8
  95. package/dist/types/Primitive/string/Constants.d.ts +12 -13
  96. package/dist/types/Primitive/string/Fabricator.d.ts +2 -2
  97. package/dist/types/Primitive/string/Registry.d.ts +10 -16
  98. package/dist/types/Primitive/string/Schema.d.ts +5 -5
  99. package/dist/types/Primitive/string/Types.d.ts +17 -17
  100. package/dist/types/Primitive/symbol/Fabricator.d.ts +2 -2
  101. package/dist/types/Primitive/symbol/Registry.d.ts +4 -11
  102. package/dist/types/Primitive/symbol/Schema.d.ts +6 -6
  103. package/dist/types/Primitive/symbol/Types.d.ts +2 -2
  104. package/dist/types/Primitive/tuple/Fabricator.d.ts +7 -8
  105. package/dist/types/Primitive/tuple/Schema.d.ts +5 -5
  106. package/dist/types/Primitive/tuple/Types.d.ts +24 -25
  107. package/dist/types/Primitive/undefinable/Fabricator.d.ts +7 -7
  108. package/dist/types/Primitive/undefinable/Schema.d.ts +13 -13
  109. package/dist/types/Primitive/undefinable/Types.d.ts +10 -10
  110. package/dist/types/Primitive/undefined/Registry.d.ts +2 -2
  111. package/dist/types/Primitive/undefined/Schema.d.ts +4 -4
  112. package/dist/types/Primitive/undefined/Types.d.ts +3 -3
  113. package/dist/types/Random/CallSite.d.ts +63 -44
  114. package/dist/types/Random/Generator/sfc32.d.ts +4 -4
  115. package/dist/types/Random/Types.d.ts +214 -236
  116. package/dist/types/Random/index.d.ts +63 -70
  117. package/dist/types/Schema/Core.d.ts +19 -21
  118. package/dist/types/Schema/Registry.d.ts +3 -3
  119. package/dist/types/Schema/Types.d.ts +41 -48
  120. package/dist/types/Types.d.ts +39 -45
  121. package/dist/types/Utility/Core.d.ts +18 -9
  122. package/dist/types/index.d.ts +110 -108
  123. package/dist/types/internal.d.ts +68 -37
  124. package/package.json +17 -5
package/README.md CHANGED
@@ -38,10 +38,4 @@ const item = Product.fabricate();
38
38
  const widget = Product.fabricate({ name: "Widget", inStock: true });
39
39
  ```
40
40
 
41
- `seed: "1234"` is an optional mixer; `clock` (the wall-clock instant of this call, by default) is the run's entropy. Pass the same seed and clock to replay. See the [docs site](https://ghostry-dev.github.io/fabricator/) for the full guide: the mental model behind Schemas and Fabricators, composing and overriding schemas, custom types, distributions, and the [TypeBox adapter](https://www.npmjs.com/package/@ghostry/fabricator-adapter-typebox-v0).
42
-
43
- ## Similar
44
-
45
- https://www.npmjs.com/package/@anatine/zod-mock
46
-
47
- https://www.npmjs.com/package/@travelperksl/fabricator
41
+ `seed: "1234"` is an optional mixer; `clock` (the wall-clock instant of this call, by default) is the run's entropy. Pass the same seed and clock to replay. See the [docs site](https://docs.ghostry.dev/fabricator/) for the full guide: the mental model behind Schemas and Fabricators, composing and overriding schemas, custom types, distributions, and the [TypeBox adapter](https://www.npmjs.com/package/@ghostry/fabricator-adapter-typebox-v0).
@@ -197,5 +197,13 @@ class Error_FabricatorError extends Error {
197
197
  }
198
198
  }
199
199
  FabricatorError.TraceKindMismatchError = TraceKindMismatchError;
200
+ class SynchronousStackError extends FabricatorError {
201
+ constructor(){
202
+ super();
203
+ this.name = "SynchronousStackError";
204
+ this.message = "`wrap` received an async block, but this instance's ambient stack cannot carry a frame across `await` — a build after the first `await` would silently resolve against the base instance. This runtime has no `node:async_hooks`, so `#stack` resolved to the synchronous carrier; either keep the block synchronous, or pass an async-capable carrier as `initialize({ stack })`.";
205
+ }
206
+ }
207
+ FabricatorError.SynchronousStackError = SynchronousStackError;
200
208
  })(Error_FabricatorError || (Error_FabricatorError = {}));
201
209
  export { Error_FabricatorError as FabricatorError };
@@ -4,7 +4,7 @@ import { Constructor } from "../Fabricator/Constructor.js";
4
4
  import { defaultAlgorithm, deriveClock, isLayered, normalizeSeed, resolveAttribution, toRandomSource } from "../Random/index.js";
5
5
  import { registry } from "../Schema/Registry.js";
6
6
  import { Layer } from "../Types.js";
7
- import { inline } from "../Utility/Core.js";
7
+ import { inline, isThenable, noop } from "../Utility/Core.js";
8
8
  const DEFAULT_COMBINATORIAL_LIMIT = 1024;
9
9
  function resolveCombinatorialLimit(limit) {
10
10
  if (void 0 === limit) return DEFAULT_COMBINATORIAL_LIMIT;
@@ -42,20 +42,6 @@ function overlay(base, over) {
42
42
  }
43
43
  };
44
44
  }
45
- function toStack() {
46
- const frames = [];
47
- return {
48
- current: ()=>frames[frames.length - 1],
49
- enter: (frame, block)=>{
50
- frames.push(frame);
51
- try {
52
- return block();
53
- } finally{
54
- frames.pop();
55
- }
56
- }
57
- };
58
- }
59
45
  function instantiate(config, stack) {
60
46
  const source = toRandomSource({
61
47
  seed: config.seed,
@@ -74,10 +60,15 @@ function instantiate(config, stack) {
74
60
  const base = null != (_ref = null == (_stack_current = stack.current()) ? void 0 : _stack_current.config) ? _ref : config;
75
61
  const scopedConfig = overlay(base, wrapOverlay);
76
62
  const scoped = instantiate(scopedConfig, stack);
77
- return stack.enter({
63
+ const result = stack.enter({
78
64
  config: scopedConfig,
79
65
  source: scoped.source
80
66
  }, ()=>block(scoped.instance));
67
+ if (!stack.asynchronous && isThenable(result)) {
68
+ result.then(noop, noop);
69
+ throw new FabricatorError.SynchronousStackError();
70
+ }
71
+ return result;
81
72
  }
82
73
  const context = {
83
74
  get seed () {
@@ -116,4 +107,4 @@ function instantiate(config, stack) {
116
107
  source
117
108
  };
118
109
  }
119
- export { DEFAULT_COMBINATORIAL_LIMIT, instantiate, overlay, toStack };
110
+ export { DEFAULT_COMBINATORIAL_LIMIT, instantiate, overlay };
@@ -0,0 +1,10 @@
1
+ import { AsyncLocalStorage } from "async_hooks";
2
+ function toStack() {
3
+ const store = new AsyncLocalStorage();
4
+ return {
5
+ asynchronous: true,
6
+ current: ()=>store.getStore(),
7
+ enter: (frame, block)=>store.run(frame, block)
8
+ };
9
+ }
10
+ export { toStack };
@@ -0,0 +1,16 @@
1
+ function toStack() {
2
+ const frames = [];
3
+ return {
4
+ asynchronous: false,
5
+ current: ()=>frames[frames.length - 1],
6
+ enter: (frame, block)=>{
7
+ frames.push(frame);
8
+ try {
9
+ return block();
10
+ } finally{
11
+ frames.pop();
12
+ }
13
+ }
14
+ };
15
+ }
16
+ export { toStack };
@@ -1,18 +1,6 @@
1
1
  import { assertNonemptyDiscreteBigint, toBound } from "../../Bound.js";
2
2
  import { Kind, Meta } from "../../Types.js";
3
3
  import { Schema } from "./Schema.js";
4
- function toWhereby(input) {
5
- const max = toBound(input.max);
6
- const min = void 0 === input.min ? {
7
- value: -max.value,
8
- exclusive: false
9
- } : toBound(input.min);
10
- assertNonemptyDiscreteBigint("T.bigint.whereby", min, max);
11
- return {
12
- min,
13
- max
14
- };
15
- }
16
4
  const Registry = {
17
5
  [Kind]: "bigint",
18
6
  whereby: (whereby)=>Schema({
@@ -28,4 +16,16 @@ const Registry = {
28
16
  }
29
17
  })
30
18
  };
19
+ function toWhereby(input) {
20
+ const max = toBound(input.max);
21
+ const min = void 0 === input.min ? {
22
+ value: -max.value,
23
+ exclusive: false
24
+ } : toBound(input.min);
25
+ assertNonemptyDiscreteBigint("T.bigint.whereby", min, max);
26
+ return {
27
+ min,
28
+ max
29
+ };
30
+ }
31
31
  export default Registry;
@@ -1,6 +1,6 @@
1
1
  import { Adaptation, Kind, Meta, Produces } from "../../Types.js";
2
2
  import { Schema } from "./Schema.js";
3
- const Registry = {
3
+ const registry = {
4
4
  ...Schema({
5
5
  [Kind]: "boolean",
6
6
  [Meta]: {},
@@ -8,4 +8,5 @@ const Registry = {
8
8
  [Adaptation]: void 0
9
9
  })
10
10
  };
11
+ const Registry = registry;
11
12
  export default Registry;
@@ -1,20 +1,7 @@
1
1
  import { assertNonemptyDiscrete, epochBound, toBound } from "../../Bound.js";
2
2
  import { Adaptation, Kind, Meta, Produces } from "../../Types.js";
3
3
  import { Schema } from "./Schema.js";
4
- function toWhereby(input) {
5
- const min = void 0 === input.min ? void 0 : toBound(input.min);
6
- const max = void 0 === input.max ? void 0 : toBound(input.max);
7
- if (void 0 !== min && void 0 !== max) assertNonemptyDiscrete("T.date.whereby", epochBound(min), epochBound(max));
8
- return void 0 === input.distribution ? {
9
- min,
10
- max
11
- } : {
12
- min,
13
- max,
14
- distribution: input.distribution
15
- };
16
- }
17
- const Registry = {
4
+ const registry = {
18
5
  ...Schema({
19
6
  [Kind]: "date",
20
7
  [Meta]: {},
@@ -58,4 +45,18 @@ const Registry = {
58
45
  })
59
46
  }
60
47
  };
48
+ const Registry = registry;
49
+ function toWhereby(input) {
50
+ const min = void 0 === input.min ? void 0 : toBound(input.min);
51
+ const max = void 0 === input.max ? void 0 : toBound(input.max);
52
+ if (void 0 !== min && void 0 !== max) assertNonemptyDiscrete("T.date.whereby", epochBound(min), epochBound(max));
53
+ return void 0 === input.distribution ? {
54
+ min,
55
+ max
56
+ } : {
57
+ min,
58
+ max,
59
+ distribution: input.distribution
60
+ };
61
+ }
61
62
  export default Registry;
@@ -1,8 +1,9 @@
1
1
  import { Kind, Meta, Produces } from "../../Types.js";
2
2
  import { Schema } from "./Schema.js";
3
- const Registry = Schema({
3
+ const registry = Schema({
4
4
  [Kind]: "null",
5
5
  [Meta]: {},
6
6
  [Produces]: null
7
7
  });
8
+ const Registry = registry;
8
9
  export default Registry;
@@ -3,23 +3,7 @@ import { Adaptation, Kind, Meta, Produces } from "../../Types.js";
3
3
  import bigint from "../bigint/index.js";
4
4
  import { unboundedContinuous, unboundedDiscrete } from "./defaults.js";
5
5
  import { Schema } from "./Schema.js";
6
- function toWhereby(input, integer) {
7
- const min = void 0 === input.min ? void 0 : toBound(input.min);
8
- const max = void 0 === input.max ? void 0 : toBound(input.max);
9
- const defaults = integer ? unboundedDiscrete : unboundedContinuous;
10
- const label = integer ? "T.number.integer.whereby" : "T.number.whereby";
11
- if (integer) assertNonemptyDiscrete(label, null != min ? min : defaults.min, null != max ? max : defaults.max);
12
- else assertNonemptyContinuous(label, null != min ? min : defaults.min, null != max ? max : defaults.max);
13
- return void 0 === input.distribution ? {
14
- min,
15
- max
16
- } : {
17
- min,
18
- max,
19
- distribution: input.distribution
20
- };
21
- }
22
- const Registry = {
6
+ const registry = {
23
7
  ...Schema({
24
8
  [Kind]: "number",
25
9
  [Meta]: {},
@@ -56,4 +40,21 @@ const Registry = {
56
40
  big: bigint
57
41
  }
58
42
  };
43
+ const Registry = registry;
44
+ function toWhereby(input, integer) {
45
+ const min = void 0 === input.min ? void 0 : toBound(input.min);
46
+ const max = void 0 === input.max ? void 0 : toBound(input.max);
47
+ const defaults = integer ? unboundedDiscrete : unboundedContinuous;
48
+ const label = integer ? "T.number.integer.whereby" : "T.number.whereby";
49
+ if (integer) assertNonemptyDiscrete(label, null != min ? min : defaults.min, null != max ? max : defaults.max);
50
+ else assertNonemptyContinuous(label, null != min ? min : defaults.min, null != max ? max : defaults.max);
51
+ return void 0 === input.distribution ? {
52
+ min,
53
+ max
54
+ } : {
55
+ min,
56
+ max,
57
+ distribution: input.distribution
58
+ };
59
+ }
59
60
  export default Registry;
@@ -1,6 +1,6 @@
1
1
  import { Adaptation, Kind, Meta, Produces } from "../../Types.js";
2
2
  import { Schema } from "./Schema.js";
3
- const Registry = {
3
+ const registry = {
4
4
  ...Schema({
5
5
  [Kind]: "symbol",
6
6
  [Meta]: {},
@@ -14,4 +14,5 @@ const Registry = {
14
14
  }
15
15
  })
16
16
  };
17
+ const Registry = registry;
17
18
  export default Registry;
@@ -1,8 +1,9 @@
1
1
  import { Kind, Meta, Produces } from "../../Types.js";
2
2
  import { Schema } from "./Schema.js";
3
- const Registry = Schema({
3
+ const registry = Schema({
4
4
  [Kind]: "undefined",
5
5
  [Meta]: {},
6
6
  [Produces]: void 0
7
7
  });
8
+ const Registry = registry;
8
9
  export default Registry;
@@ -35,22 +35,36 @@ function relativize(root, file) {
35
35
  ...to.slice(shared)
36
36
  ].join("/");
37
37
  }
38
- function isOwnFrame(location) {
39
- return location.startsWith(OWN_ROOT);
38
+ function isInternalFrame(location, otherInternals = []) {
39
+ if (location.startsWith(OWN_ROOT)) return true;
40
+ return otherInternals.some((skip)=>location.startsWith(skip));
40
41
  }
41
- function firstExternalFrame(stack) {
42
+ function firstExternalFrame(stack, otherInternals = []) {
42
43
  var _ref, _locations_find;
43
44
  const locations = stack.split("\n").filter((line)=>line.trim().startsWith("at ")).map(extractLocation).map(normalizeLocation);
44
- return null != (_ref = null != (_locations_find = locations.find((location)=>!isOwnFrame(location))) ? _locations_find : locations[locations.length - 1]) ? _ref : stack;
45
- }
46
- function resolveCallerFile() {
47
- var _stack;
48
- if ("function" == typeof Error.captureStackTrace) {
49
- var _captured_stack;
50
- const captured = {};
51
- Error.captureStackTrace(captured);
52
- return stripPosition(firstExternalFrame(null != (_captured_stack = captured.stack) ? _captured_stack : ""));
45
+ return null != (_ref = null != (_locations_find = locations.find((location)=>!isInternalFrame(location, otherInternals))) ? _locations_find : locations[locations.length - 1]) ? _ref : stack;
46
+ }
47
+ function resolveCallerFile(options) {
48
+ var _options_skip;
49
+ const skip = null == options ? void 0 : null == (_options_skip = options.skip) ? void 0 : _options_skip.map(normalizeLocation);
50
+ const stack = captureRawStack();
51
+ const location = stripPosition(stack.walkable ? firstExternalFrame(stack.text, skip) : stack.text);
52
+ return (null == options ? void 0 : options.root) === void 0 ? location : relativize(normalizeLocation(options.root), location);
53
+ }
54
+ function captureRawStack() {
55
+ var _captured_stack;
56
+ if ("function" != typeof Error.captureStackTrace) {
57
+ var _stack;
58
+ return {
59
+ text: null != (_stack = new Error().stack) ? _stack : "",
60
+ walkable: false
61
+ };
53
62
  }
54
- return stripPosition(null != (_stack = new Error().stack) ? _stack : "");
63
+ const captured = {};
64
+ Error.captureStackTrace(captured);
65
+ return {
66
+ text: null != (_captured_stack = captured.stack) ? _captured_stack : "",
67
+ walkable: true
68
+ };
55
69
  }
56
70
  export { directoryOf, normalizeLocation, relativize, resolveCallerFile };
@@ -3,6 +3,11 @@ function inline(fn) {
3
3
  return fn();
4
4
  }
5
5
  function never(_) {}
6
+ function noop() {}
7
+ function isThenable(value) {
8
+ if ("object" != typeof value || null === value) return false;
9
+ return "function" == typeof value.then;
10
+ }
6
11
  function isArray(candidate) {
7
12
  return Array.isArray(candidate);
8
13
  }
@@ -33,4 +38,4 @@ function replace(value) {
33
38
  [Replace]: true
34
39
  };
35
40
  }
36
- export { inline, isArray, isPlainObject, isPollutionKey, mergeableKeys, never, replace };
41
+ export { inline, isArray, isPlainObject, isPollutionKey, isThenable, mergeableKeys, never, noop, replace };
package/dist/esm/index.js CHANGED
@@ -1,6 +1,8 @@
1
- import { instantiate, overlay, toStack } from "./Instance/Core.js";
1
+ import { toStack } from "#stack";
2
+ import { instantiate, overlay } from "./Instance/Core.js";
2
3
  function initialize(config) {
3
- return instantiate(overlay({}, null != config ? config : {}), toStack()).instance;
4
+ var _ref;
5
+ return instantiate(overlay({}, null != config ? config : {}), null != (_ref = null == config ? void 0 : config.stack) ? _ref : toStack()).instance;
4
6
  }
5
7
  export { Adaptation, Omitted } from "./Types.js";
6
8
  export { layer } from "./Random/index.js";
@@ -2,4 +2,5 @@ export { Children, Kind, Meta, Produces } from "./Types.js";
2
2
  export { isPlainObject } from "./Utility/Core.js";
3
3
  export { plan, resolve } from "./Enumeration/Plan.js";
4
4
  export { defaultAlgorithm, encode, randomSeed, toRandomSource, toStream, toStreamFromTrace } from "./Random/index.js";
5
- export { directoryOf, normalizeLocation, relativize } from "./Random/CallSite.js";
5
+ export { directoryOf, normalizeLocation, relativize, resolveCallerFile } from "./Random/CallSite.js";
6
+ export { toStack as toSynchronousStack } from "./Instance/Stack/Sync.js";
@@ -4,59 +4,56 @@ type OverrideSchemaAdaptation<$Schema extends object, $Map extends Adaptations>
4
4
  readonly [Adaptation]?: WithAdaptations<AdaptationsOf<$Schema>, $Map>;
5
5
  };
6
6
  /**
7
- * One adapter's entry, keyed by `$Adapter["key"]`. Written as a mapped
8
- * type rather than built inline: a computed key in an object literal
9
- * (`{ [adapter.key]: produce }`) widens to a `string` index signature,
10
- * which no adapter's literal-keyed dispatch matches.
7
+ * One adapter's entry, keyed by `$Adapter["key"]`. Written as a mapped type
8
+ * rather than built inline: a computed key in an object literal (`{
9
+ * [adapter.key]: produce }`) widens to a `string` index signature, which no
10
+ * adapter's literal-keyed dispatch matches.
11
11
  */
12
12
  export type AdaptationEntry<$Adapter extends Adapter, $Returnable> = {
13
13
  readonly [$K in $Adapter["key"]]: (schema: any) => $Returnable;
14
14
  };
15
15
  /**
16
- * A copy of `schema` carrying `produce` as `adapter`'s adaptation:
17
- * that adapter's prior entry is replaced (via {@link layer}), every
18
- * other adapter's is carried forward. Every kind's `.adapt(...)` is a
19
- * call to this, re-typed to that kind's own
20
- * `Schema<..., WithAdaptations<...>>`.
16
+ * A copy of `schema` carrying `produce` as `adapter`'s adaptation: that
17
+ * adapter's prior entry is replaced (via {@link layer}), every other adapter's
18
+ * is carried forward. Every kind's `.adapt(...)` is a call to this, re-typed to
19
+ * that kind's own `Schema<..., WithAdaptations<...>>`.
21
20
  *
22
- * Takes the adapter and producer separately rather than a prebuilt map
23
- * so the key stays a literal, per {@link AdaptationEntry}. The return
24
- * type mirrors the merge (rather than handing back `$Schema`) so call
25
- * sites need no cast: `AdaptationsOf<$Schema>` recovers the prior map
26
- * from whichever kind's `Core` was passed in.
21
+ * Takes the adapter and producer separately rather than a prebuilt map so the
22
+ * key stays a literal, per {@link AdaptationEntry}. The return type mirrors the
23
+ * merge (rather than handing back `$Schema`) so call sites need no cast:
24
+ * `AdaptationsOf<$Schema>` recovers the prior map from whichever kind's `Core`
25
+ * was passed in.
27
26
  */
28
27
  export declare function withAdaptations<const $Schema extends object, const $Adapter extends Adapter, $Returnable>(schema: $Schema, adapter: $Adapter, produce: (adapting: Adapting<any>) => $Returnable): OverrideSchemaAdaptation<$Schema, AdaptationEntry<$Adapter, $Returnable>>;
29
28
  /**
30
29
  * {@link withAdaptations} at the map level, for a kind that keeps its
31
30
  * adaptations beside its schema rather than on it — `object`, whose
32
31
  * `extend`/`refine`/`override` each rebuild the schema from scratch, so
33
- * `Registry.ts`'s `make` has to thread the map through explicitly (see
34
- * its `adapt`).
32
+ * `Registry.ts`'s `make` has to thread the map through explicitly (see its
33
+ * `adapt`).
35
34
  *
36
- * `undefined` rather than an empty map when there is nothing to carry,
37
- * for the same reason `patched` drops the symbol: an absent map and an
38
- * empty one mean the same thing, and only one of them should exist at
39
- * runtime.
35
+ * `undefined` rather than an empty map when there is nothing to carry, for the
36
+ * same reason `patched` drops the symbol: an absent map and an empty one mean
37
+ * the same thing, and only one of them should exist at runtime.
40
38
  */
41
39
  export declare function mergeAdaptations<$Prior extends Adaptations, const $Adapter extends Adapter, $Returnable>(prior: $Prior | undefined, adapter: $Adapter, produce: (adapting: Adapting<any>) => $Returnable): WithAdaptations<$Prior, AdaptationEntry<$Adapter, $Returnable>> | undefined;
42
40
  /**
43
41
  * Walk `schema` with `adapter`, resolving each node to its external
44
42
  * counterpart. Every adapter's entry point is a call to this.
45
43
  *
46
- * The adaptation lookup lives here, ahead of the adapter's own
47
- * per-kind dispatch, so an explicit adaptation wins over the kind's
48
- * mapping — and here rather than in each adapter so it applies at
49
- * *every* node the walk reaches, not just the one it started from.
50
- * That is why an adapter recurses through the {@link Recurse} it is
51
- * handed rather than calling its own `convert` again: a nested
52
- * `object` field, `array` element, or `choice` option gets the same
44
+ * The adaptation lookup lives here, ahead of the adapter's own per-kind
45
+ * dispatch, so an explicit adaptation wins over the kind's mapping — and here
46
+ * rather than in each adapter so it applies at _every_ node the walk reaches,
47
+ * not just the one it started from. That is why an adapter recurses through the
48
+ * {@link Recurse} it is handed rather than calling its own `convert` again: a
49
+ * nested `object` field, `array` element, or `choice` option gets the same
53
50
  * treatment as the root.
54
51
  *
55
- * Paired with {@link layer}: together they make `toTypeBox(schema)`
56
- * *inside* an adaptation resolve to the layer that adaptation replaced
57
- * instead of re-entering itself. This reads the entry; `layer` already
58
- * substituted the previous one into the argument. Splitting the two
59
- * across packages is how they drift.
52
+ * Paired with {@link layer}: together they make `toTypeBox(schema)` _inside_ an
53
+ * adaptation resolve to the layer that adaptation replaced instead of
54
+ * re-entering itself. This reads the entry; `layer` already substituted the
55
+ * previous one into the argument. Splitting the two across packages is how they
56
+ * drift.
60
57
  */
61
58
  export declare function drive<$Context, $Returnable>(adapter: Adapter<string, $Context, $Returnable>, schema: {
62
59
  [Adaptation]?: Adaptations;