flavor-code 1.2.13 → 1.2.14

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 (131) hide show
  1. package/README.md +3 -0
  2. package/README.zh-CN.md +3 -0
  3. package/dist/{app-Z3YWFIBB.js → app-UJAGMKD5.js} +2 -2
  4. package/dist/astgraph/db.mjs +237 -237
  5. package/dist/astgraph/extract.mjs +239 -239
  6. package/dist/astgraph/flavor-plugin.json +25 -25
  7. package/dist/astgraph/grammars.mjs +68 -68
  8. package/dist/astgraph/index.js +301 -301
  9. package/dist/astgraph/indexer.mjs +175 -175
  10. package/dist/astgraph/query.mjs +165 -165
  11. package/dist/astgraph/resolve.mjs +93 -93
  12. package/dist/astgraph/vendor/tree-sitter.js +3980 -3980
  13. package/dist/astgraph/vendor/zod/LICENSE +21 -21
  14. package/dist/astgraph/vendor/zod/index.js +4 -4
  15. package/dist/astgraph/vendor/zod/locales/index.js +1 -1
  16. package/dist/astgraph/vendor/zod/locales/package.json +7 -7
  17. package/dist/astgraph/vendor/zod/package.json +135 -135
  18. package/dist/astgraph/vendor/zod/v4/classic/checks.js +1 -1
  19. package/dist/astgraph/vendor/zod/v4/classic/coerce.js +17 -17
  20. package/dist/astgraph/vendor/zod/v4/classic/compat.js +31 -31
  21. package/dist/astgraph/vendor/zod/v4/classic/errors.js +48 -48
  22. package/dist/astgraph/vendor/zod/v4/classic/external.js +20 -20
  23. package/dist/astgraph/vendor/zod/v4/classic/from-json-schema.js +599 -599
  24. package/dist/astgraph/vendor/zod/v4/classic/index.js +4 -4
  25. package/dist/astgraph/vendor/zod/v4/classic/iso.js +30 -30
  26. package/dist/astgraph/vendor/zod/v4/classic/package.json +7 -7
  27. package/dist/astgraph/vendor/zod/v4/classic/parse.js +15 -15
  28. package/dist/astgraph/vendor/zod/v4/classic/schemas.js +1395 -1395
  29. package/dist/astgraph/vendor/zod/v4/core/api.js +1087 -1087
  30. package/dist/astgraph/vendor/zod/v4/core/checks.js +575 -575
  31. package/dist/astgraph/vendor/zod/v4/core/core.js +78 -78
  32. package/dist/astgraph/vendor/zod/v4/core/doc.js +35 -35
  33. package/dist/astgraph/vendor/zod/v4/core/errors.js +185 -185
  34. package/dist/astgraph/vendor/zod/v4/core/index.js +16 -16
  35. package/dist/astgraph/vendor/zod/v4/core/json-schema-generator.js +95 -95
  36. package/dist/astgraph/vendor/zod/v4/core/json-schema-processors.js +601 -601
  37. package/dist/astgraph/vendor/zod/v4/core/json-schema.js +1 -1
  38. package/dist/astgraph/vendor/zod/v4/core/package.json +7 -7
  39. package/dist/astgraph/vendor/zod/v4/core/parse.js +93 -93
  40. package/dist/astgraph/vendor/zod/v4/core/regexes.js +139 -139
  41. package/dist/astgraph/vendor/zod/v4/core/registries.js +51 -51
  42. package/dist/astgraph/vendor/zod/v4/core/schemas.js +2239 -2239
  43. package/dist/astgraph/vendor/zod/v4/core/standard-schema.js +1 -1
  44. package/dist/astgraph/vendor/zod/v4/core/to-json-schema.js +448 -448
  45. package/dist/astgraph/vendor/zod/v4/core/util.js +674 -674
  46. package/dist/astgraph/vendor/zod/v4/core/versions.js +5 -5
  47. package/dist/astgraph/vendor/zod/v4/index.js +3 -3
  48. package/dist/astgraph/vendor/zod/v4/locales/ar.js +106 -106
  49. package/dist/astgraph/vendor/zod/v4/locales/az.js +105 -105
  50. package/dist/astgraph/vendor/zod/v4/locales/be.js +156 -156
  51. package/dist/astgraph/vendor/zod/v4/locales/bg.js +120 -120
  52. package/dist/astgraph/vendor/zod/v4/locales/ca.js +107 -107
  53. package/dist/astgraph/vendor/zod/v4/locales/cs.js +111 -111
  54. package/dist/astgraph/vendor/zod/v4/locales/da.js +115 -115
  55. package/dist/astgraph/vendor/zod/v4/locales/de.js +108 -108
  56. package/dist/astgraph/vendor/zod/v4/locales/el.js +109 -109
  57. package/dist/astgraph/vendor/zod/v4/locales/en.js +113 -113
  58. package/dist/astgraph/vendor/zod/v4/locales/eo.js +109 -109
  59. package/dist/astgraph/vendor/zod/v4/locales/es.js +132 -132
  60. package/dist/astgraph/vendor/zod/v4/locales/fa.js +114 -114
  61. package/dist/astgraph/vendor/zod/v4/locales/fi.js +112 -112
  62. package/dist/astgraph/vendor/zod/v4/locales/fr-CA.js +107 -107
  63. package/dist/astgraph/vendor/zod/v4/locales/fr.js +125 -125
  64. package/dist/astgraph/vendor/zod/v4/locales/he.js +214 -214
  65. package/dist/astgraph/vendor/zod/v4/locales/hr.js +122 -122
  66. package/dist/astgraph/vendor/zod/v4/locales/hu.js +108 -108
  67. package/dist/astgraph/vendor/zod/v4/locales/hy.js +147 -147
  68. package/dist/astgraph/vendor/zod/v4/locales/id.js +106 -106
  69. package/dist/astgraph/vendor/zod/v4/locales/index.js +52 -52
  70. package/dist/astgraph/vendor/zod/v4/locales/is.js +109 -109
  71. package/dist/astgraph/vendor/zod/v4/locales/it.js +108 -108
  72. package/dist/astgraph/vendor/zod/v4/locales/ja.js +107 -107
  73. package/dist/astgraph/vendor/zod/v4/locales/ka.js +112 -112
  74. package/dist/astgraph/vendor/zod/v4/locales/kh.js +5 -5
  75. package/dist/astgraph/vendor/zod/v4/locales/km.js +110 -110
  76. package/dist/astgraph/vendor/zod/v4/locales/ko.js +111 -111
  77. package/dist/astgraph/vendor/zod/v4/locales/lt.js +203 -203
  78. package/dist/astgraph/vendor/zod/v4/locales/mk.js +109 -109
  79. package/dist/astgraph/vendor/zod/v4/locales/ms.js +107 -107
  80. package/dist/astgraph/vendor/zod/v4/locales/nl.js +110 -110
  81. package/dist/astgraph/vendor/zod/v4/locales/no.js +108 -108
  82. package/dist/astgraph/vendor/zod/v4/locales/ota.js +109 -109
  83. package/dist/astgraph/vendor/zod/v4/locales/package.json +7 -7
  84. package/dist/astgraph/vendor/zod/v4/locales/pl.js +109 -109
  85. package/dist/astgraph/vendor/zod/v4/locales/ps.js +114 -114
  86. package/dist/astgraph/vendor/zod/v4/locales/pt.js +108 -108
  87. package/dist/astgraph/vendor/zod/v4/locales/ro.js +119 -119
  88. package/dist/astgraph/vendor/zod/v4/locales/ru.js +156 -156
  89. package/dist/astgraph/vendor/zod/v4/locales/sl.js +109 -109
  90. package/dist/astgraph/vendor/zod/v4/locales/sv.js +110 -110
  91. package/dist/astgraph/vendor/zod/v4/locales/ta.js +110 -110
  92. package/dist/astgraph/vendor/zod/v4/locales/th.js +110 -110
  93. package/dist/astgraph/vendor/zod/v4/locales/tr.js +105 -105
  94. package/dist/astgraph/vendor/zod/v4/locales/ua.js +5 -5
  95. package/dist/astgraph/vendor/zod/v4/locales/uk.js +108 -108
  96. package/dist/astgraph/vendor/zod/v4/locales/ur.js +110 -110
  97. package/dist/astgraph/vendor/zod/v4/locales/uz.js +110 -110
  98. package/dist/astgraph/vendor/zod/v4/locales/vi.js +108 -108
  99. package/dist/astgraph/vendor/zod/v4/locales/yo.js +107 -107
  100. package/dist/astgraph/vendor/zod/v4/locales/zh-CN.js +109 -109
  101. package/dist/astgraph/vendor/zod/v4/locales/zh-TW.js +107 -107
  102. package/dist/astgraph/vendor/zod/v4/mini/checks.js +1 -1
  103. package/dist/astgraph/vendor/zod/v4/mini/coerce.js +22 -22
  104. package/dist/astgraph/vendor/zod/v4/mini/external.js +14 -14
  105. package/dist/astgraph/vendor/zod/v4/mini/index.js +3 -3
  106. package/dist/astgraph/vendor/zod/v4/mini/iso.js +34 -34
  107. package/dist/astgraph/vendor/zod/v4/mini/package.json +7 -7
  108. package/dist/astgraph/vendor/zod/v4/mini/parse.js +1 -1
  109. package/dist/astgraph/vendor/zod/v4/mini/schemas.js +961 -961
  110. package/dist/astgraph/vendor/zod/v4/package.json +7 -7
  111. package/dist/{chunk-Y5MZDG7I.js → chunk-4YXDGGIC.js} +4611 -3754
  112. package/dist/{chunk-XFCJXRJ2.js → chunk-IG4Z23CL.js} +6 -0
  113. package/dist/{chunk-G6Q2Y2A7.js → chunk-KL6TR2KG.js} +1 -1
  114. package/dist/cli.js +5 -5
  115. package/dist/config/schema.d.ts +6 -0
  116. package/dist/desktop/main.js +4900 -4038
  117. package/dist/desktop-renderer/assets/{index-CCnSpff0.js → index-CcD0D6x0.js} +1 -1
  118. package/dist/desktop-renderer/index.html +1 -1
  119. package/dist/evolve/loader.d.ts +21 -0
  120. package/dist/evolve/service.d.ts +37 -0
  121. package/dist/evolve/store.d.ts +91 -0
  122. package/dist/hooks/types.d.ts +5 -1
  123. package/dist/{load-6ZMEBHSG.js → load-GKA7P6RJ.js} +1 -1
  124. package/dist/plugins/host.d.ts +9 -0
  125. package/dist/plugins/types.d.ts +1 -0
  126. package/dist/sdk/index.js +3 -3
  127. package/dist/tools/shell.d.ts +13 -0
  128. package/dist/ui/commands.d.ts +5 -2
  129. package/dist/ui/session.d.ts +1 -0
  130. package/package.json +1 -1
  131. package//346/212/200/346/234/257/346/226/271/346/241/210/346/212/245/345/221/212.md +303 -1
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,7 +1,7 @@
1
- {
2
- "type": "module",
3
- "main": "./index.cjs",
4
- "module": "./index.js",
5
- "types": "./index.d.cts",
6
- "sideEffects": false
7
- }
1
+ {
2
+ "type": "module",
3
+ "main": "./index.cjs",
4
+ "module": "./index.js",
5
+ "types": "./index.d.cts",
6
+ "sideEffects": false
7
+ }
@@ -1,93 +1,93 @@
1
- import * as core from "./core.js";
2
- import * as errors from "./errors.js";
3
- import * as util from "./util.js";
4
- export const _parse = (_Err) => (schema, value, _ctx, _params) => {
5
- const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
6
- const result = schema._zod.run({ value, issues: [] }, ctx);
7
- if (result instanceof Promise) {
8
- throw new core.$ZodAsyncError();
9
- }
10
- if (result.issues.length) {
11
- const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
12
- util.captureStackTrace(e, _params?.callee);
13
- throw e;
14
- }
15
- return result.value;
16
- };
17
- export const parse = /* @__PURE__*/ _parse(errors.$ZodRealError);
18
- export const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
19
- const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
20
- let result = schema._zod.run({ value, issues: [] }, ctx);
21
- if (result instanceof Promise)
22
- result = await result;
23
- if (result.issues.length) {
24
- const e = new (params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
25
- util.captureStackTrace(e, params?.callee);
26
- throw e;
27
- }
28
- return result.value;
29
- };
30
- export const parseAsync = /* @__PURE__*/ _parseAsync(errors.$ZodRealError);
31
- export const _safeParse = (_Err) => (schema, value, _ctx) => {
32
- const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
33
- const result = schema._zod.run({ value, issues: [] }, ctx);
34
- if (result instanceof Promise) {
35
- throw new core.$ZodAsyncError();
36
- }
37
- return result.issues.length
38
- ? {
39
- success: false,
40
- error: new (_Err ?? errors.$ZodError)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
41
- }
42
- : { success: true, data: result.value };
43
- };
44
- export const safeParse = /* @__PURE__*/ _safeParse(errors.$ZodRealError);
45
- export const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
46
- const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
47
- let result = schema._zod.run({ value, issues: [] }, ctx);
48
- if (result instanceof Promise)
49
- result = await result;
50
- return result.issues.length
51
- ? {
52
- success: false,
53
- error: new _Err(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
54
- }
55
- : { success: true, data: result.value };
56
- };
57
- export const safeParseAsync = /* @__PURE__*/ _safeParseAsync(errors.$ZodRealError);
58
- export const _encode = (_Err) => (schema, value, _ctx) => {
59
- const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
60
- return _parse(_Err)(schema, value, ctx);
61
- };
62
- export const encode = /* @__PURE__*/ _encode(errors.$ZodRealError);
63
- export const _decode = (_Err) => (schema, value, _ctx) => {
64
- return _parse(_Err)(schema, value, _ctx);
65
- };
66
- export const decode = /* @__PURE__*/ _decode(errors.$ZodRealError);
67
- export const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
68
- const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
69
- return _parseAsync(_Err)(schema, value, ctx);
70
- };
71
- export const encodeAsync = /* @__PURE__*/ _encodeAsync(errors.$ZodRealError);
72
- export const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
73
- return _parseAsync(_Err)(schema, value, _ctx);
74
- };
75
- export const decodeAsync = /* @__PURE__*/ _decodeAsync(errors.$ZodRealError);
76
- export const _safeEncode = (_Err) => (schema, value, _ctx) => {
77
- const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
78
- return _safeParse(_Err)(schema, value, ctx);
79
- };
80
- export const safeEncode = /* @__PURE__*/ _safeEncode(errors.$ZodRealError);
81
- export const _safeDecode = (_Err) => (schema, value, _ctx) => {
82
- return _safeParse(_Err)(schema, value, _ctx);
83
- };
84
- export const safeDecode = /* @__PURE__*/ _safeDecode(errors.$ZodRealError);
85
- export const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
86
- const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
87
- return _safeParseAsync(_Err)(schema, value, ctx);
88
- };
89
- export const safeEncodeAsync = /* @__PURE__*/ _safeEncodeAsync(errors.$ZodRealError);
90
- export const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
91
- return _safeParseAsync(_Err)(schema, value, _ctx);
92
- };
93
- export const safeDecodeAsync = /* @__PURE__*/ _safeDecodeAsync(errors.$ZodRealError);
1
+ import * as core from "./core.js";
2
+ import * as errors from "./errors.js";
3
+ import * as util from "./util.js";
4
+ export const _parse = (_Err) => (schema, value, _ctx, _params) => {
5
+ const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
6
+ const result = schema._zod.run({ value, issues: [] }, ctx);
7
+ if (result instanceof Promise) {
8
+ throw new core.$ZodAsyncError();
9
+ }
10
+ if (result.issues.length) {
11
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
12
+ util.captureStackTrace(e, _params?.callee);
13
+ throw e;
14
+ }
15
+ return result.value;
16
+ };
17
+ export const parse = /* @__PURE__*/ _parse(errors.$ZodRealError);
18
+ export const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
19
+ const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
20
+ let result = schema._zod.run({ value, issues: [] }, ctx);
21
+ if (result instanceof Promise)
22
+ result = await result;
23
+ if (result.issues.length) {
24
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
25
+ util.captureStackTrace(e, params?.callee);
26
+ throw e;
27
+ }
28
+ return result.value;
29
+ };
30
+ export const parseAsync = /* @__PURE__*/ _parseAsync(errors.$ZodRealError);
31
+ export const _safeParse = (_Err) => (schema, value, _ctx) => {
32
+ const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
33
+ const result = schema._zod.run({ value, issues: [] }, ctx);
34
+ if (result instanceof Promise) {
35
+ throw new core.$ZodAsyncError();
36
+ }
37
+ return result.issues.length
38
+ ? {
39
+ success: false,
40
+ error: new (_Err ?? errors.$ZodError)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
41
+ }
42
+ : { success: true, data: result.value };
43
+ };
44
+ export const safeParse = /* @__PURE__*/ _safeParse(errors.$ZodRealError);
45
+ export const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
46
+ const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
47
+ let result = schema._zod.run({ value, issues: [] }, ctx);
48
+ if (result instanceof Promise)
49
+ result = await result;
50
+ return result.issues.length
51
+ ? {
52
+ success: false,
53
+ error: new _Err(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
54
+ }
55
+ : { success: true, data: result.value };
56
+ };
57
+ export const safeParseAsync = /* @__PURE__*/ _safeParseAsync(errors.$ZodRealError);
58
+ export const _encode = (_Err) => (schema, value, _ctx) => {
59
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
60
+ return _parse(_Err)(schema, value, ctx);
61
+ };
62
+ export const encode = /* @__PURE__*/ _encode(errors.$ZodRealError);
63
+ export const _decode = (_Err) => (schema, value, _ctx) => {
64
+ return _parse(_Err)(schema, value, _ctx);
65
+ };
66
+ export const decode = /* @__PURE__*/ _decode(errors.$ZodRealError);
67
+ export const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
68
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
69
+ return _parseAsync(_Err)(schema, value, ctx);
70
+ };
71
+ export const encodeAsync = /* @__PURE__*/ _encodeAsync(errors.$ZodRealError);
72
+ export const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
73
+ return _parseAsync(_Err)(schema, value, _ctx);
74
+ };
75
+ export const decodeAsync = /* @__PURE__*/ _decodeAsync(errors.$ZodRealError);
76
+ export const _safeEncode = (_Err) => (schema, value, _ctx) => {
77
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
78
+ return _safeParse(_Err)(schema, value, ctx);
79
+ };
80
+ export const safeEncode = /* @__PURE__*/ _safeEncode(errors.$ZodRealError);
81
+ export const _safeDecode = (_Err) => (schema, value, _ctx) => {
82
+ return _safeParse(_Err)(schema, value, _ctx);
83
+ };
84
+ export const safeDecode = /* @__PURE__*/ _safeDecode(errors.$ZodRealError);
85
+ export const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
86
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
87
+ return _safeParseAsync(_Err)(schema, value, ctx);
88
+ };
89
+ export const safeEncodeAsync = /* @__PURE__*/ _safeEncodeAsync(errors.$ZodRealError);
90
+ export const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
91
+ return _safeParseAsync(_Err)(schema, value, _ctx);
92
+ };
93
+ export const safeDecodeAsync = /* @__PURE__*/ _safeDecodeAsync(errors.$ZodRealError);
@@ -1,139 +1,139 @@
1
- import * as util from "./util.js";
2
- /**
3
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
4
- * (timestamps embedded in the id). Use {@link cuid2} instead.
5
- * See https://github.com/paralleldrive/cuid.
6
- */
7
- export const cuid = /^[cC][0-9a-z]{6,}$/;
8
- export const cuid2 = /^[0-9a-z]+$/;
9
- export const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
10
- export const xid = /^[0-9a-vA-V]{20}$/;
11
- export const ksuid = /^[A-Za-z0-9]{27}$/;
12
- export const nanoid = /^[a-zA-Z0-9_-]{21}$/;
13
- /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
14
- export const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
15
- /** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
16
- export const extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
17
- /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
18
- export const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
19
- /** Returns a regex for validating an RFC 9562/4122 UUID.
20
- *
21
- * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
22
- export const uuid = (version) => {
23
- if (!version)
24
- return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
25
- return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
26
- };
27
- export const uuid4 = /*@__PURE__*/ uuid(4);
28
- export const uuid6 = /*@__PURE__*/ uuid(6);
29
- export const uuid7 = /*@__PURE__*/ uuid(7);
30
- /** Practical email validation */
31
- export const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
32
- /** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
33
- export const html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
34
- /** The classic emailregex.com regex for RFC 5322-compliant emails */
35
- export const rfc5322Email = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
36
- /** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
37
- export const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
38
- export const idnEmail = unicodeEmail;
39
- export const browserEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
40
- // from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
41
- const _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
42
- export function emoji() {
43
- return new RegExp(_emoji, "u");
44
- }
45
- export const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
46
- export const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
47
- export const mac = (delimiter) => {
48
- const escapedDelim = util.escapeRegex(delimiter ?? ":");
49
- return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
50
- };
51
- export const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
52
- export const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
53
- // https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
54
- export const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
55
- export const base64url = /^[A-Za-z0-9_-]*$/;
56
- // based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
57
- // export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
58
- export const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
59
- export const domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
60
- export const httpProtocol = /^https?$/;
61
- // https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
62
- // E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15
63
- export const e164 = /^\+[1-9]\d{6,14}$/;
64
- // const dateSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
65
- const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
66
- export const date = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
67
- function timeSource(args) {
68
- const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
69
- const regex = typeof args.precision === "number"
70
- ? args.precision === -1
71
- ? `${hhmm}`
72
- : args.precision === 0
73
- ? `${hhmm}:[0-5]\\d`
74
- : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}`
75
- : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
76
- return regex;
77
- }
78
- export function time(args) {
79
- return new RegExp(`^${timeSource(args)}$`);
80
- }
81
- // Adapted from https://stackoverflow.com/a/3143231
82
- export function datetime(args) {
83
- const time = timeSource({ precision: args.precision });
84
- const opts = ["Z"];
85
- if (args.local)
86
- opts.push("");
87
- // if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
88
- if (args.offset)
89
- opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
90
- const timeRegex = `${time}(?:${opts.join("|")})`;
91
- return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
92
- }
93
- export const string = (params) => {
94
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
95
- return new RegExp(`^${regex}$`);
96
- };
97
- export const bigint = /^-?\d+n?$/;
98
- export const integer = /^-?\d+$/;
99
- export const number = /^-?\d+(?:\.\d+)?$/;
100
- export const boolean = /^(?:true|false)$/i;
101
- const _null = /^null$/i;
102
- export { _null as null };
103
- const _undefined = /^undefined$/i;
104
- export { _undefined as undefined };
105
- // regex for string with no uppercase letters
106
- export const lowercase = /^[^A-Z]*$/;
107
- // regex for string with no lowercase letters
108
- export const uppercase = /^[^a-z]*$/;
109
- // regex for hexadecimal strings (any length)
110
- export const hex = /^[0-9a-fA-F]*$/;
111
- // Hash regexes for different algorithms and encodings
112
- // Helper function to create base64 regex with exact length and padding
113
- function fixedBase64(bodyLength, padding) {
114
- return new RegExp(`^[A-Za-z0-9+/]{${bodyLength}}${padding}$`);
115
- }
116
- // Helper function to create base64url regex with exact length (no padding)
117
- function fixedBase64url(length) {
118
- return new RegExp(`^[A-Za-z0-9_-]{${length}}$`);
119
- }
120
- // MD5 (16 bytes): base64 = 24 chars total (22 + "==")
121
- export const md5_hex = /^[0-9a-fA-F]{32}$/;
122
- export const md5_base64 = /*@__PURE__*/ fixedBase64(22, "==");
123
- export const md5_base64url = /*@__PURE__*/ fixedBase64url(22);
124
- // SHA1 (20 bytes): base64 = 28 chars total (27 + "=")
125
- export const sha1_hex = /^[0-9a-fA-F]{40}$/;
126
- export const sha1_base64 = /*@__PURE__*/ fixedBase64(27, "=");
127
- export const sha1_base64url = /*@__PURE__*/ fixedBase64url(27);
128
- // SHA256 (32 bytes): base64 = 44 chars total (43 + "=")
129
- export const sha256_hex = /^[0-9a-fA-F]{64}$/;
130
- export const sha256_base64 = /*@__PURE__*/ fixedBase64(43, "=");
131
- export const sha256_base64url = /*@__PURE__*/ fixedBase64url(43);
132
- // SHA384 (48 bytes): base64 = 64 chars total (no padding)
133
- export const sha384_hex = /^[0-9a-fA-F]{96}$/;
134
- export const sha384_base64 = /*@__PURE__*/ fixedBase64(64, "");
135
- export const sha384_base64url = /*@__PURE__*/ fixedBase64url(64);
136
- // SHA512 (64 bytes): base64 = 88 chars total (86 + "==")
137
- export const sha512_hex = /^[0-9a-fA-F]{128}$/;
138
- export const sha512_base64 = /*@__PURE__*/ fixedBase64(86, "==");
139
- export const sha512_base64url = /*@__PURE__*/ fixedBase64url(86);
1
+ import * as util from "./util.js";
2
+ /**
3
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
4
+ * (timestamps embedded in the id). Use {@link cuid2} instead.
5
+ * See https://github.com/paralleldrive/cuid.
6
+ */
7
+ export const cuid = /^[cC][0-9a-z]{6,}$/;
8
+ export const cuid2 = /^[0-9a-z]+$/;
9
+ export const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
10
+ export const xid = /^[0-9a-vA-V]{20}$/;
11
+ export const ksuid = /^[A-Za-z0-9]{27}$/;
12
+ export const nanoid = /^[a-zA-Z0-9_-]{21}$/;
13
+ /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
14
+ export const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
15
+ /** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
16
+ export const extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
17
+ /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
18
+ export const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
19
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
20
+ *
21
+ * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
22
+ export const uuid = (version) => {
23
+ if (!version)
24
+ return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
25
+ return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
26
+ };
27
+ export const uuid4 = /*@__PURE__*/ uuid(4);
28
+ export const uuid6 = /*@__PURE__*/ uuid(6);
29
+ export const uuid7 = /*@__PURE__*/ uuid(7);
30
+ /** Practical email validation */
31
+ export const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
32
+ /** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
33
+ export const html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
34
+ /** The classic emailregex.com regex for RFC 5322-compliant emails */
35
+ export const rfc5322Email = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
36
+ /** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
37
+ export const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
38
+ export const idnEmail = unicodeEmail;
39
+ export const browserEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
40
+ // from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
41
+ const _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
42
+ export function emoji() {
43
+ return new RegExp(_emoji, "u");
44
+ }
45
+ export const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
46
+ export const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
47
+ export const mac = (delimiter) => {
48
+ const escapedDelim = util.escapeRegex(delimiter ?? ":");
49
+ return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
50
+ };
51
+ export const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
52
+ export const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
53
+ // https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
54
+ export const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
55
+ export const base64url = /^[A-Za-z0-9_-]*$/;
56
+ // based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
57
+ // export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
58
+ export const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
59
+ export const domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
60
+ export const httpProtocol = /^https?$/;
61
+ // https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
62
+ // E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15
63
+ export const e164 = /^\+[1-9]\d{6,14}$/;
64
+ // const dateSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
65
+ const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
66
+ export const date = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
67
+ function timeSource(args) {
68
+ const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
69
+ const regex = typeof args.precision === "number"
70
+ ? args.precision === -1
71
+ ? `${hhmm}`
72
+ : args.precision === 0
73
+ ? `${hhmm}:[0-5]\\d`
74
+ : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}`
75
+ : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
76
+ return regex;
77
+ }
78
+ export function time(args) {
79
+ return new RegExp(`^${timeSource(args)}$`);
80
+ }
81
+ // Adapted from https://stackoverflow.com/a/3143231
82
+ export function datetime(args) {
83
+ const time = timeSource({ precision: args.precision });
84
+ const opts = ["Z"];
85
+ if (args.local)
86
+ opts.push("");
87
+ // if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
88
+ if (args.offset)
89
+ opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
90
+ const timeRegex = `${time}(?:${opts.join("|")})`;
91
+ return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
92
+ }
93
+ export const string = (params) => {
94
+ const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
95
+ return new RegExp(`^${regex}$`);
96
+ };
97
+ export const bigint = /^-?\d+n?$/;
98
+ export const integer = /^-?\d+$/;
99
+ export const number = /^-?\d+(?:\.\d+)?$/;
100
+ export const boolean = /^(?:true|false)$/i;
101
+ const _null = /^null$/i;
102
+ export { _null as null };
103
+ const _undefined = /^undefined$/i;
104
+ export { _undefined as undefined };
105
+ // regex for string with no uppercase letters
106
+ export const lowercase = /^[^A-Z]*$/;
107
+ // regex for string with no lowercase letters
108
+ export const uppercase = /^[^a-z]*$/;
109
+ // regex for hexadecimal strings (any length)
110
+ export const hex = /^[0-9a-fA-F]*$/;
111
+ // Hash regexes for different algorithms and encodings
112
+ // Helper function to create base64 regex with exact length and padding
113
+ function fixedBase64(bodyLength, padding) {
114
+ return new RegExp(`^[A-Za-z0-9+/]{${bodyLength}}${padding}$`);
115
+ }
116
+ // Helper function to create base64url regex with exact length (no padding)
117
+ function fixedBase64url(length) {
118
+ return new RegExp(`^[A-Za-z0-9_-]{${length}}$`);
119
+ }
120
+ // MD5 (16 bytes): base64 = 24 chars total (22 + "==")
121
+ export const md5_hex = /^[0-9a-fA-F]{32}$/;
122
+ export const md5_base64 = /*@__PURE__*/ fixedBase64(22, "==");
123
+ export const md5_base64url = /*@__PURE__*/ fixedBase64url(22);
124
+ // SHA1 (20 bytes): base64 = 28 chars total (27 + "=")
125
+ export const sha1_hex = /^[0-9a-fA-F]{40}$/;
126
+ export const sha1_base64 = /*@__PURE__*/ fixedBase64(27, "=");
127
+ export const sha1_base64url = /*@__PURE__*/ fixedBase64url(27);
128
+ // SHA256 (32 bytes): base64 = 44 chars total (43 + "=")
129
+ export const sha256_hex = /^[0-9a-fA-F]{64}$/;
130
+ export const sha256_base64 = /*@__PURE__*/ fixedBase64(43, "=");
131
+ export const sha256_base64url = /*@__PURE__*/ fixedBase64url(43);
132
+ // SHA384 (48 bytes): base64 = 64 chars total (no padding)
133
+ export const sha384_hex = /^[0-9a-fA-F]{96}$/;
134
+ export const sha384_base64 = /*@__PURE__*/ fixedBase64(64, "");
135
+ export const sha384_base64url = /*@__PURE__*/ fixedBase64url(64);
136
+ // SHA512 (64 bytes): base64 = 88 chars total (86 + "==")
137
+ export const sha512_hex = /^[0-9a-fA-F]{128}$/;
138
+ export const sha512_base64 = /*@__PURE__*/ fixedBase64(86, "==");
139
+ export const sha512_base64url = /*@__PURE__*/ fixedBase64url(86);
@@ -1,51 +1,51 @@
1
- var _a;
2
- export const $output = Symbol("ZodOutput");
3
- export const $input = Symbol("ZodInput");
4
- export class $ZodRegistry {
5
- constructor() {
6
- this._map = new WeakMap();
7
- this._idmap = new Map();
8
- }
9
- add(schema, ..._meta) {
10
- const meta = _meta[0];
11
- this._map.set(schema, meta);
12
- if (meta && typeof meta === "object" && "id" in meta) {
13
- this._idmap.set(meta.id, schema);
14
- }
15
- return this;
16
- }
17
- clear() {
18
- this._map = new WeakMap();
19
- this._idmap = new Map();
20
- return this;
21
- }
22
- remove(schema) {
23
- const meta = this._map.get(schema);
24
- if (meta && typeof meta === "object" && "id" in meta) {
25
- this._idmap.delete(meta.id);
26
- }
27
- this._map.delete(schema);
28
- return this;
29
- }
30
- get(schema) {
31
- // return this._map.get(schema) as any;
32
- // inherit metadata
33
- const p = schema._zod.parent;
34
- if (p) {
35
- const pm = { ...(this.get(p) ?? {}) };
36
- delete pm.id; // do not inherit id
37
- const f = { ...pm, ...this._map.get(schema) };
38
- return Object.keys(f).length ? f : undefined;
39
- }
40
- return this._map.get(schema);
41
- }
42
- has(schema) {
43
- return this._map.has(schema);
44
- }
45
- }
46
- // registries
47
- export function registry() {
48
- return new $ZodRegistry();
49
- }
50
- (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
51
- export const globalRegistry = globalThis.__zod_globalRegistry;
1
+ var _a;
2
+ export const $output = Symbol("ZodOutput");
3
+ export const $input = Symbol("ZodInput");
4
+ export class $ZodRegistry {
5
+ constructor() {
6
+ this._map = new WeakMap();
7
+ this._idmap = new Map();
8
+ }
9
+ add(schema, ..._meta) {
10
+ const meta = _meta[0];
11
+ this._map.set(schema, meta);
12
+ if (meta && typeof meta === "object" && "id" in meta) {
13
+ this._idmap.set(meta.id, schema);
14
+ }
15
+ return this;
16
+ }
17
+ clear() {
18
+ this._map = new WeakMap();
19
+ this._idmap = new Map();
20
+ return this;
21
+ }
22
+ remove(schema) {
23
+ const meta = this._map.get(schema);
24
+ if (meta && typeof meta === "object" && "id" in meta) {
25
+ this._idmap.delete(meta.id);
26
+ }
27
+ this._map.delete(schema);
28
+ return this;
29
+ }
30
+ get(schema) {
31
+ // return this._map.get(schema) as any;
32
+ // inherit metadata
33
+ const p = schema._zod.parent;
34
+ if (p) {
35
+ const pm = { ...(this.get(p) ?? {}) };
36
+ delete pm.id; // do not inherit id
37
+ const f = { ...pm, ...this._map.get(schema) };
38
+ return Object.keys(f).length ? f : undefined;
39
+ }
40
+ return this._map.get(schema);
41
+ }
42
+ has(schema) {
43
+ return this._map.has(schema);
44
+ }
45
+ }
46
+ // registries
47
+ export function registry() {
48
+ return new $ZodRegistry();
49
+ }
50
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
51
+ export const globalRegistry = globalThis.__zod_globalRegistry;