//#region src/core/codegen/issue-decls.d.ts /** * Issue factory function bodies (statement form). * * These functions produce the same `{code, ...}` shapes that lean-mode * generated code would otherwise inline at every check site. * Hosted in "virtual:zod-compiler/runtime" and called as `__zcTS(...)` etc. * * Argument convention (positional, kept short to minimize call-site bytes): * __zcTS(minimum, origin, inclusive, input, path, msg?) — too_small * __zcTSt(minimum, origin, input, path, msg?) — too_small, tuple key order * __zcTBt(maximum, origin, input, path, msg?) — too_big, tuple key order * __zcTB(maximum, origin, inclusive, input, path, msg?) — too_big * __zcIT(expected, input, path, msg?) — invalid_type * __zcITc(expected, input, path, msg?) — invalid_type, `code` first * __zcIF(origin, format, input, path, extra?, msg?) — invalid_format (extra merged into result) * __zcIV(values, input, path, extra?, msg?) — invalid_value (extra merged into result) * __zcUK(keys, input, path, msg?) — unrecognized_keys * * The trailing msg argument carries a static custom error message; when * absent, the __zcFin finalizer applies the configured locale default. * * KEY ORDER IS PART OF THE CONTRACT. `ZodError.message` is * `JSON.stringify(issues, …, 2)`, so the order these factories insert keys in is * printed verbatim in the message every consumer logs, snapshots or serializes. * Each literal below therefore reproduces the order of the corresponding * `payload.issues.push({…})` in zod, which is irregular by type — `too_small` * from a check leads with `origin` while the same code from a tuple's length * branch leads with `code` — and every factory writes `message` LAST, because * zod's `finalizeIssue` assigns it after the fact (`full.message = …`) even for * a custom message baked into the check's error map. */ /** All issue factory declarations indexed by helper name. */ declare const ISSUE_DECLS: Readonly>; /** * Float-safe remainder — byte-for-byte port of zod's util.floatSafeRemainder. * Raw `%` mis-rejects valid multiples of decimal steps (0.3 % 0.1 !== 0). * * zod 4.5 REPLACED the decimal-scaling implementation this once mirrored with a * ratio-and-tolerance one, and the two disagree in both directions: the old form * accepted `1e-7` as a multiple of 3 (its `toFixed` scaling collapsed the value * to 0) and rejected `1e21` (where `toFixed` yields exponential notation and * `parseInt` then reads 1). The tolerance is 4x epsilon because `val` and `step` * each round to a double before the division rounds again, so a true decimal * multiple's quotient can sit up to 1.5 scaled epsilons from the integer. */ declare const ZC_FSR_DECL: string; /** * Hoisted `Object.prototype.hasOwnProperty` reference. Record fast/slow paths * iterate keys with `for(k in o)` (no `Object.keys` array allocation) and guard * each key with `__zcHop.call(o,k)` to skip inherited enumerable properties — * yielding the exact own-enumerable string-key set `Object.keys` would, so * fast/slow stay in agreement and parity with zod's own-key record semantics is * preserved. The hoisted reference inlines in V8; reading the prototype property * per call would not. */ declare const ZC_HOP_DECL = "const __zcHop=Object.prototype.hasOwnProperty;"; /** * Port of zod's `util.isPlainObject` — the guard `$ZodRecord` applies to its * input, and a STRICTLY narrower test than the `util.isObject` (`typeof * "object"`, not null, not an array) that `$ZodObject` uses. * * The distinction is load-bearing and was a validation hole while records shared * the object guard: `z.record(z.string(), z.string())` accepted a `Date`, a * `Map`, a `RegExp`, an `Error`, a `File` and any class instance — every one of * which zod rejects with `invalid_type`/`expected: "record"`, and none of which * has own enumerable string keys for the value schema to catch. Compiled output * therefore said "valid" to inputs zod refuses, which is the one direction a * validator must never diverge in. * * The algorithm is zod's, step for step, because the answer is observable and * the edge cases are deliberate: * - `constructor === undefined` (a null-prototype object) is PLAIN; * - a non-function own `constructor` (`{ constructor: 1 }`) is PLAIN; * - otherwise the constructor's `prototype` must be an object carrying its OWN * `isPrototypeOf` — which `Object.prototype` does and `Date.prototype`, * `Map.prototype` and every user class prototype do not. Testing that rather * than `Object.getPrototypeOf(o) === Object.prototype` is what lets a plain * object from another realm (a vm context, an iframe) still count as plain. * * `c===Object` is a short-cut, not a fourth rule: it is exactly the case where * zod's remaining steps are foregone — `Object.prototype` is an object and has * its own `isPrototypeOf` — so the answer is `true` either way. It is also the * case every ordinary record takes (an object literal, `JSON.parse` output, a * `Map`-free DTO), and taking it saves the `prototype` load and the * `hasOwnProperty` call: measured 9.6 → 5.7 ns on a monomorphic record and * 15.7 → 9.2 ns across 16 shapes, i.e. 22% of a five-key record's whole parse. * A plain object from another realm has a different `Object` and simply takes * the long road to the same verdict, as before. * * Self-contained (`Object.prototype.hasOwnProperty` spelled out rather than * reusing `__zcHop`) so inline mode can emit this decl alone: `emitRuntimeHelper` * pushes only the decl it is asked for, and a helper that closed over another * name would dangle wherever that one was not also emitted. */ declare const ZC_PLAIN_DECL: string; /** * `z.email()`'s default validator, `regexes.email`, as a single linear scan. * * Zod's pattern is * `^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$`, * and even its lookahead-free rewrite (EMAIL_FAST_REGEX_SOURCE) backtracks at * every dot it fails to find: `(?:[X]+\.)*` re-tries the run one character * shorter each time, and the domain's `(?:label\.)+` does the same over the * TLD. Written as a scanner the language is: * * local — `[A-Za-z0-9_'+.-]+`, no leading `.`, no `..`, and the character * before `@` is neither `.` nor `'` (that last is the `[A-Za-z0-9_+-]` * the pattern demands there); * domain — one or more labels `[A-Za-z0-9][A-Za-z0-9-]*` each ending in `.`, * then a TLD of two or more letters running to the end. * * A trailing `\n` is not accepted: the pattern has no `m` flag, so its `$` * matches only at the end of input, and the scan reads to `length`. * * Measured against the fast regex on V8: 32 → 16 ns for `alice@example.com`, * 48 → 40 for `bob_smith-99@mail-server.io`, 39 → 20 for a non-address, and a * tie from ~35 characters up (the regex's per-character work is cheaper than a * `charCodeAt` loop's; its fixed dispatch cost is what the scanner avoids). A * lookbehind rewrite runs about as fast but needs ES2018 regex support, which * the CLI's React Native / Hermes and older-Safari consumers cannot assume. * * Equivalence to zod's regex — every string, both verdicts — is pinned by * tests/core/codegen/email-scanner.test.ts. Reached only behind a `typeof` * string guard, like the `.test()` it replaces; issue sites keep reporting * zod's own pattern string (see `emitRegexSourceString`). */ declare const ZC_EMAIL_DECL: string; /** * Does `s` parse as a URL? The verdict `new URL(s)` gives by not throwing, * without building the URL object: `URL.canParse` runs the same parser at half * the cost (~80 ns against ~160 ns on V8, trim included). Used only where * nothing reads the parsed URL — no hostname or protocol test, no `normalize`. * A host without `canParse` (Node before 18.17, older browsers, React Native's * polyfill) falls back to the constructor, and one without `URL` at all answers * false, as the try/catch zod wraps around that constructor does. */ declare const ZC_URL_DECL: string; /** * Ports of `util.getLengthableOrigin` / `util.getSizableOrigin` — the `origin` a * length/size check puts on its issue, computed from the RUNTIME INPUT rather * than from the schema. * * They only matter because those checks declare a `when` predicate * (`!nullish(value) && value.length/size !== undefined`), which bypasses zod's * abort gate: `z.string().min(2)` handed `[]` reports the `invalid_type` AND a * `too_small` whose origin is `"array"`, because the empty array satisfies the * `when`. Inside the matching type branch the origin is statically known and * these are not used; they exist for the type-MISMATCH branch, where the input * can be anything with a `.length` or a `.size`. * * `File` is probed through `typeof` first: zod tests `input instanceof File` * unguarded, which throws where the global is absent — an environment zod does * not run in, and not one worth reproducing a crash for. */ declare const ZC_LENGTH_ORIGIN_DECL = "function __zcLo(v){return Array.isArray(v)?\"array\":typeof v===\"string\"?\"string\":\"unknown\";}"; /** * Drop an own `__proto__` from a container the parse hands back BY REFERENCE. * * zod never lets the key into an output: `$ZodObject`'s shape loop strips a * declared one, `handleCatchall` skips an undeclared one, and `$ZodRecord` skips * it while copying — all so the assignment into their fresh `{}` cannot replace * the result's prototype. A compiled loose/catchall object or record IS its * input, so the key has to be removed here instead; leaving it made * `Object.assign({}, parsed)` a prototype-pollution sink, since [[Set]] runs the * inherited setter the spread that built the value did not. * * Copies rather than editing in place: the divergence note promises the caller * its own container back, not one with a key silently deleted from it. The * common object has no such key and is returned untouched, so the cost is one * `hasOwnProperty` call. */ declare const ZC_PROTO_SCRUB_DECL: string; /** * Code points in a string — zod's `util.codePointLength`, verbatim. A surrogate * pair counts once and a lone surrogate as itself. The regex probe is the fast * exit for a string with no astral characters, and the hand-rolled loop avoids * the allocating string iterator. Only reached from a length check whose * UTF-16 count leaves the verdict in doubt (see stringLengthTests). */ declare const ZC_CPL_DECL = "function __zcCpl(s){var n=s.length;if(!/[\\uD800-\\uDBFF]/.test(s))return n;var c=n;for(var i=0;i>; //#endregion export { ISSUE_DECLS, RUNTIME_HELPER_DECLS, ZC_AB_DECL, ZC_ASYNC_DECL, ZC_CPL_DECL, ZC_CUSTOM_OK_DECL, ZC_DELEGATE_ISSUES_DECL, ZC_EMAIL_DECL, ZC_FSR_DECL, ZC_FZ_DECL, ZC_HOP_DECL, ZC_LENGTH_ORIGIN_DECL, ZC_PATH_APPEND_DECL, ZC_PFX_DECL, ZC_PLAIN_DECL, ZC_PROTO_SCRUB_DECL, ZC_RUN_DELEGATE_DECL, ZC_SIZE_ORIGIN_DECL, ZC_SR_DECL, ZC_SR_OK_DECL, ZC_SR_RUN_DECL, ZC_URL_DECL, abortingCodeTest, propertyKeyTest }; //# sourceMappingURL=issue-decls.d.ts.map