@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
@@ -1,59 +1,78 @@
1
1
  /**
2
- * One canonical form for a location, whatever produced it: Node ESM
3
- * emits `file:///…` URLs, Bun emits bare absolute paths, and this
4
- * module's own `import.meta.url` is percent-encoded — three spellings
5
- * of one file that must compare equal, or `isOwnFrame`/`relativize`
6
- * silently stop matching. A bare path is trusted as-is and never
7
- * decoded, since it may contain a literal `%20`; only the `file://`
8
- * form's escaping is guaranteed well-formed. Forward slashes and an
9
- * uppercased leading `/X:/` drive fold Windows' `C:\a\b` and
10
- * `file:///c:/a/b` together the drive is the one component two
11
- * sources disagree on, so it's the only thing case-folded: doing more
12
- * would break case-sensitive filesystems and change what ends up
13
- * hashed.
2
+ * One canonical form for a location, whatever produced it: Node ESM emits
3
+ * `file:///…` URLs, Bun emits bare absolute paths, and this module's own
4
+ * `import.meta.url` is percent-encoded — three spellings of one file that must
5
+ * compare equal, or `isInternalFrame`/`relativize` silently stop matching. A
6
+ * bare path is trusted as-is and never decoded, since it may contain a literal
7
+ * `%20`; only the `file://` form's escaping is guaranteed well-formed. Forward
8
+ * slashes and an uppercased leading `/X:/` drive fold Windows' `C:\a\b` and
9
+ * `file:///c:/a/b` together the drive is the one component two sources
10
+ * disagree on, so it's the only thing case-folded: doing more would break
11
+ * case-sensitive filesystems and change what ends up hashed.
14
12
  */
15
13
  export declare function normalizeLocation(location: string): string;
16
14
  /**
17
- * The directory a location sits in, trailing separator included —
18
- * without it, a root of `/a/b/` would match the unrelated sibling
19
- * `/a/bcd/x.ts`, since `startsWith`/prefix-stripping only sees
20
- * character runs, not path segments.
15
+ * The directory a location sits in, trailing separator included — without it, a
16
+ * root of `/a/b/` would match the unrelated sibling `/a/bcd/x.ts`, since
17
+ * `startsWith`/prefix-stripping only sees character runs, not path segments.
21
18
  */
22
19
  export declare function directoryOf(location: string): string;
23
20
  /**
24
- * `file` expressed relative to `root`, ascending with `..` where `file`
25
- * sits outside `root` rather than falling back to `file` unchanged. An
26
- * ascending path stays identical across machines whose checkouts hold
27
- * both locations at the same relative position, the common case for
28
- * anything under the same repository — passing an escaping file through
29
- * as absolute would defeat the default `"call site"` policy for every
30
- * schema helper that isn't a sibling of wherever `initialize()` was
31
- * called. A location that isn't an absolute path (`native`,
32
- * `<anonymous>`, or a value that has already been relativized) doesn't
33
- * start with `/` and is returned unchanged applying this twice is a
34
- * no-op, which lets `T.recursive` thread an already-relativized file
35
- * back through here uniformly.
21
+ * `file` expressed relative to `root`, ascending with `..` where `file` sits
22
+ * outside `root` rather than falling back to `file` unchanged. An ascending
23
+ * path stays identical across machines whose checkouts hold both locations at
24
+ * the same relative position, the common case for anything under the same
25
+ * repository — passing an escaping file through as absolute would defeat the
26
+ * default `"call site"` policy for every schema helper that isn't a sibling of
27
+ * wherever `initialize()` was called. A location that isn't an absolute path
28
+ * (`native`, `<anonymous>`, or a value that has already been relativized)
29
+ * doesn't start with `/` and is returned unchanged applying this twice is a
30
+ * no-op, which lets `T.recursive` thread an already-relativized file back
31
+ * through here uniformly.
36
32
  */
37
33
  export declare function relativize(root: string, file: string): string;
38
34
  /**
39
35
  * Resolve the file that (transitively) triggered the current call, so
40
- * construction can be attributed to the source file the user wrote it
41
- * in.
36
+ * construction can be attributed to the source file the user wrote it in.
42
37
  *
43
- * Primary path: `Error.captureStackTrace` (V8, and Bun for Node
44
- * compatibility) captures the full stack, then `firstExternalFrame`
45
- * skips this library's own frames by path — no need to hardcode how
46
- * many frames to exclude, so it stays correct as internal call depth
47
- * changes.
38
+ * Primary path: `Error.captureStackTrace` (V8, and Bun for Node compatibility)
39
+ * captures the full stack, then `firstExternalFrame` skips this library's own
40
+ * frames by path — no need to hardcode how many frames to exclude, so it stays
41
+ * correct as internal call depth changes.
48
42
  *
49
- * Fallback: engines without `captureStackTrace` get the whole raw
50
- * stack, position-stripped, hashed as-is rather than guessing which
51
- * frame to isolate. Lower fidelity (sensitive to edits anywhere in the
52
- * visible call chain, not just the immediate caller), but rarely
53
- * exercised Bun, Node, and Chrome all support the primary path. Left
54
- * unnormalized: a whole multi-line stack has no single location for
55
- * `normalizeLocation`'s separator/drive rewriting to apply to, so this
56
- * path never relativizes — it always falls through `relativize`'s
43
+ * Fallback: engines without `captureStackTrace` get the whole raw stack,
44
+ * position-stripped, hashed as-is rather than guessing which frame to isolate.
45
+ * Lower fidelity (sensitive to edits anywhere in the visible call chain, not
46
+ * just the immediate caller), but rarely exercised — Bun, Node, and Chrome all
47
+ * support the primary path. Left unnormalized: a whole multi-line stack has no
48
+ * single location for `normalizeLocation`'s separator/drive rewriting to apply
49
+ * to, so this path never relativizes it always falls through `relativize`'s
57
50
  * non-absolute passthrough instead.
51
+ *
52
+ * Both options exist for a library that wraps fabricator and wants to attribute
53
+ * a construction to _its own_ caller rather than to itself —
54
+ * `@ghostry/extern`'s testing scope is the motivating case: it opens a `wrap`
55
+ * per test and wants the resolved site to be the test file, not `extern`'s own
56
+ * module. This module's own callers (`resolveAttribution`'s `"call site"`
57
+ * branch, `resolveRootFile`) pass neither.
58
+ *
59
+ * `skip`, when given, is a list of _additional_ roots to exclude — layered onto
60
+ * `OWN_ROOT`, never replacing it. With a wrapper between fabricator and the
61
+ * real caller, the stack reads fabricator → wrapper → caller: omitting
62
+ * `OWN_ROOT` from the skip set would make this resolve to fabricator's own file
63
+ * instead of stopping at the wrapper.
64
+ *
65
+ * Always a list, never a bare root: a _chain_ of wrappers needs every link
66
+ * named, and any link left out is where resolution stops. An integration
67
+ * layered on another integration reads fabricator → inner → outer → caller —
68
+ * `@ghostry/extern`'s fabricator extension sits between fabricator and extern
69
+ * exactly this way.
70
+ *
71
+ * `root`, when given, relativizes the result exactly as a `{ kind: "rooted" }`
72
+ * attribution policy does ({@link relativize}) — so a caller needs no separate
73
+ * import to get a checkout-relative path.
58
74
  */
59
- export declare function resolveCallerFile(): string;
75
+ export declare function resolveCallerFile(options?: {
76
+ readonly skip?: readonly string[];
77
+ readonly root?: string;
78
+ }): string;
@@ -1,9 +1,9 @@
1
1
  import type { NumberGenerator } from "../Types";
2
2
  /**
3
- * sfc32 ("Small Fast Counter"): a 128-bit-state PRNG that is fast, compact,
4
- * and statistically strong (passes both PractRand and TestU01 BigCrush).
5
- * Each call advances the state and returns the top 32 bits scaled into
6
- * `[0, 1)`. Non-cryptographic: never use this for secrets or tokens.
3
+ * sfc32 ("Small Fast Counter"): a 128-bit-state PRNG that is fast, compact, and
4
+ * statistically strong (passes both PractRand and TestU01 BigCrush). Each call
5
+ * advances the state and returns the top 32 bits scaled into `[0, 1)`.
6
+ * Non-cryptographic: never use this for secrets or tokens.
7
7
  *
8
8
  * @see https://stackoverflow.com/a/47593316
9
9
  */