@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.
- package/README.md +1 -7
- package/dist/esm/Error/index.js +8 -0
- package/dist/esm/Instance/Core.js +8 -17
- package/dist/esm/Instance/Stack/Async.js +10 -0
- package/dist/esm/Instance/Stack/Sync.js +16 -0
- package/dist/esm/Primitive/bigint/Registry.js +12 -12
- package/dist/esm/Primitive/boolean/Registry.js +2 -1
- package/dist/esm/Primitive/date/Registry.js +15 -14
- package/dist/esm/Primitive/null/Registry.js +2 -1
- package/dist/esm/Primitive/number/Registry.js +18 -17
- package/dist/esm/Primitive/symbol/Registry.js +2 -1
- package/dist/esm/Primitive/undefined/Registry.js +2 -1
- package/dist/esm/Random/CallSite.js +27 -13
- package/dist/esm/Utility/Core.js +6 -1
- package/dist/esm/index.js +4 -2
- package/dist/esm/internal.js +2 -1
- package/dist/types/Adapter/Core.d.ts +29 -32
- package/dist/types/Adapter/Types.d.ts +78 -88
- package/dist/types/Bound.d.ts +15 -15
- package/dist/types/Distribution/index.d.ts +54 -61
- package/dist/types/Enumeration/Enumerate.d.ts +21 -23
- package/dist/types/Enumeration/Plan.d.ts +22 -26
- package/dist/types/Enumeration/Types.d.ts +38 -43
- package/dist/types/Error/index.d.ts +94 -76
- package/dist/types/Fabricator/Constructor.d.ts +23 -25
- package/dist/types/Fabricator/Types.d.ts +73 -81
- package/dist/types/Instance/Core.d.ts +54 -73
- package/dist/types/Instance/Stack/Async.d.ts +14 -0
- package/dist/types/Instance/Stack/Sync.d.ts +14 -0
- package/dist/types/Instance/Types.d.ts +91 -89
- package/dist/types/Primitive/always/Schema.d.ts +8 -8
- package/dist/types/Primitive/always/Types.d.ts +7 -7
- package/dist/types/Primitive/array/Registry.d.ts +10 -8
- package/dist/types/Primitive/array/Schema.d.ts +4 -5
- package/dist/types/Primitive/array/Types.d.ts +6 -6
- package/dist/types/Primitive/bigint/Registry.d.ts +6 -6
- package/dist/types/Primitive/bigint/Schema.d.ts +8 -8
- package/dist/types/Primitive/bigint/Types.d.ts +5 -5
- package/dist/types/Primitive/boolean/Outcomes.d.ts +8 -8
- package/dist/types/Primitive/boolean/Registry.d.ts +2 -12
- package/dist/types/Primitive/boolean/Schema.d.ts +8 -8
- package/dist/types/Primitive/boolean/Types.d.ts +3 -3
- package/dist/types/Primitive/choice/Fabricator.d.ts +6 -7
- package/dist/types/Primitive/choice/Registry.d.ts +13 -13
- package/dist/types/Primitive/choice/Schema.d.ts +6 -6
- package/dist/types/Primitive/choice/Types.d.ts +11 -11
- package/dist/types/Primitive/date/Registry.d.ts +25 -48
- package/dist/types/Primitive/date/Schema.d.ts +9 -10
- package/dist/types/Primitive/date/Types.d.ts +4 -4
- package/dist/types/Primitive/enum/Registry.d.ts +13 -13
- package/dist/types/Primitive/enum/Schema.d.ts +5 -5
- package/dist/types/Primitive/enum/Types.d.ts +17 -19
- package/dist/types/Primitive/namespace.d.ts +10 -10
- package/dist/types/Primitive/null/Registry.d.ts +2 -2
- package/dist/types/Primitive/null/Schema.d.ts +2 -2
- package/dist/types/Primitive/null/Types.d.ts +3 -3
- package/dist/types/Primitive/nullable/Fabricator.d.ts +7 -7
- package/dist/types/Primitive/nullable/Schema.d.ts +13 -13
- package/dist/types/Primitive/nullable/Types.d.ts +9 -10
- package/dist/types/Primitive/nullish/Fabricator.d.ts +12 -13
- package/dist/types/Primitive/nullish/Schema.d.ts +8 -8
- package/dist/types/Primitive/nullish/Types.d.ts +12 -13
- package/dist/types/Primitive/number/Registry.d.ts +20 -38
- package/dist/types/Primitive/number/Schema.d.ts +11 -12
- package/dist/types/Primitive/number/Types.d.ts +13 -13
- package/dist/types/Primitive/number/defaults.d.ts +3 -3
- package/dist/types/Primitive/object/Fabricator.d.ts +15 -15
- package/dist/types/Primitive/object/Registry.d.ts +8 -8
- package/dist/types/Primitive/object/Schema.d.ts +10 -10
- package/dist/types/Primitive/object/Types.d.ts +20 -22
- package/dist/types/Primitive/object/compute/Fabricator.d.ts +4 -5
- package/dist/types/Primitive/object/compute/Schema.d.ts +4 -4
- package/dist/types/Primitive/object/compute/Types.d.ts +19 -20
- package/dist/types/Primitive/object/omittable/Fabricator.d.ts +10 -10
- package/dist/types/Primitive/object/omittable/Outcomes.d.ts +2 -2
- package/dist/types/Primitive/object/omittable/Schema.d.ts +11 -11
- package/dist/types/Primitive/object/omittable/Types.d.ts +14 -15
- package/dist/types/Primitive/object/optional/Fabricator.d.ts +16 -18
- package/dist/types/Primitive/object/optional/Outcomes.d.ts +2 -2
- package/dist/types/Primitive/object/optional/Schema.d.ts +4 -4
- package/dist/types/Primitive/object/optional/Types.d.ts +17 -17
- package/dist/types/Primitive/opaque/Registry.d.ts +3 -3
- package/dist/types/Primitive/opaque/Schema.d.ts +8 -9
- package/dist/types/Primitive/record/Registry.d.ts +8 -6
- package/dist/types/Primitive/record/Schema.d.ts +9 -11
- package/dist/types/Primitive/record/Types.d.ts +25 -25
- package/dist/types/Primitive/recursive/Fabricator.d.ts +16 -17
- package/dist/types/Primitive/recursive/Registry.d.ts +6 -7
- package/dist/types/Primitive/recursive/Schema.d.ts +8 -8
- package/dist/types/Primitive/recursive/Terminate.d.ts +13 -14
- package/dist/types/Primitive/recursive/Types.d.ts +31 -31
- package/dist/types/Primitive/recursive/self/Fabricator.d.ts +11 -12
- package/dist/types/Primitive/recursive/self/Schema.d.ts +10 -10
- package/dist/types/Primitive/recursive/self/Types.d.ts +7 -8
- package/dist/types/Primitive/string/Constants.d.ts +12 -13
- package/dist/types/Primitive/string/Fabricator.d.ts +2 -2
- package/dist/types/Primitive/string/Registry.d.ts +10 -16
- package/dist/types/Primitive/string/Schema.d.ts +5 -5
- package/dist/types/Primitive/string/Types.d.ts +17 -17
- package/dist/types/Primitive/symbol/Fabricator.d.ts +2 -2
- package/dist/types/Primitive/symbol/Registry.d.ts +4 -11
- package/dist/types/Primitive/symbol/Schema.d.ts +6 -6
- package/dist/types/Primitive/symbol/Types.d.ts +2 -2
- package/dist/types/Primitive/tuple/Fabricator.d.ts +7 -8
- package/dist/types/Primitive/tuple/Schema.d.ts +5 -5
- package/dist/types/Primitive/tuple/Types.d.ts +24 -25
- package/dist/types/Primitive/undefinable/Fabricator.d.ts +7 -7
- package/dist/types/Primitive/undefinable/Schema.d.ts +13 -13
- package/dist/types/Primitive/undefinable/Types.d.ts +10 -10
- package/dist/types/Primitive/undefined/Registry.d.ts +2 -2
- package/dist/types/Primitive/undefined/Schema.d.ts +4 -4
- package/dist/types/Primitive/undefined/Types.d.ts +3 -3
- package/dist/types/Random/CallSite.d.ts +63 -44
- package/dist/types/Random/Generator/sfc32.d.ts +4 -4
- package/dist/types/Random/Types.d.ts +214 -236
- package/dist/types/Random/index.d.ts +63 -70
- package/dist/types/Schema/Core.d.ts +19 -21
- package/dist/types/Schema/Registry.d.ts +3 -3
- package/dist/types/Schema/Types.d.ts +41 -48
- package/dist/types/Types.d.ts +39 -45
- package/dist/types/Utility/Core.d.ts +18 -9
- package/dist/types/index.d.ts +110 -108
- package/dist/types/internal.d.ts +68 -37
- package/package.json +17 -5
|
@@ -1,59 +1,78 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* One canonical form for a location, whatever produced it: Node ESM
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
|
-
*
|
|
19
|
-
*
|
|
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
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
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
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
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
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
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(
|
|
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
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
*/
|