@es-joy/jsoe 0.27.0 → 0.28.1
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/CHANGES.md +37 -0
- package/README.md +3 -1
- package/badges/coverage-badge.svg +1 -1
- package/badges/tests-badge.svg +1 -0
- package/dist/formats/schema.d.ts +11 -0
- package/dist/formats/schema.d.ts.map +1 -1
- package/dist/formats/structuredCloning.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
- package/dist/fundamentalTypes/stringType.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/typeChoices.d.ts +32 -2
- package/dist/typeChoices.d.ts.map +1 -1
- package/dist/types.d.ts +8 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/rawTypesonEditor.d.ts +110 -0
- package/dist/utils/rawTypesonEditor.d.ts.map +1 -0
- package/dist/vendor-imports.d.ts +4 -0
- package/docs/proposals/raw-typeson-edit-view.md +575 -0
- package/mmr.json +6 -0
- package/package.json +34 -12
- package/pnpm-workspace.yaml +32 -30
- package/src/formats/schema.js +10 -15
- package/src/formats/structuredCloning.js +24 -17
- package/src/fundamentalTypes/arrayType.js +119 -23
- package/src/fundamentalTypes/blobType.js +16 -16
- package/src/fundamentalTypes/fileType.js +13 -13
- package/src/fundamentalTypes/regexpType.js +1 -1
- package/src/fundamentalTypes/stringType.js +5 -0
- package/src/jsoe.css +12 -0
- package/src/subTypes/blobHTMLType.js +1 -1
- package/src/superTypes/dommatrixType.js +1 -1
- package/src/superTypes/errorsSpecialType.js +1 -1
- package/src/typeChoices.js +37 -10
- package/src/types.js +13 -8
- package/src/utils/media.js +3 -3
- package/src/utils/rawTypesonEditor.js +669 -0
- package/src/vendor-imports.js +12 -0
- package/tsconfig.json +1 -1
- package/typings/json-6.d.ts +12 -0
- package/vendor/@codemirror/autocomplete/dist/index.js +2125 -0
- package/vendor/@codemirror/commands/dist/index.js +1826 -0
- package/vendor/@codemirror/lang-javascript/dist/index.js +513 -0
- package/vendor/@codemirror/language/dist/index.js +2693 -0
- package/vendor/@codemirror/lint/dist/index.js +956 -0
- package/vendor/@codemirror/search/dist/index.js +1238 -0
- package/vendor/@codemirror/state/dist/index.js +3947 -0
- package/vendor/@codemirror/view/dist/index.js +11867 -0
- package/vendor/@lezer/common/dist/index.js +2202 -0
- package/vendor/@lezer/highlight/dist/index.js +927 -0
- package/vendor/@lezer/javascript/dist/index.js +192 -0
- package/vendor/@lezer/lr/dist/index.js +1889 -0
- package/vendor/@marijn/find-cluster-break/src/index.js +87 -0
- package/vendor/codemirror/dist/index.js +96 -0
- package/vendor/crelt/index.js +28 -0
- package/vendor/jamilih/dist/jml.mjs +898 -25
- package/vendor/json-6/dist/index.mjs +1783 -0
- package/vendor/style-mod/src/style-mod.js +172 -0
- package/vendor/w3c-keyname/index.js +119 -0
- package/vendor/zod/classic/checks.d.ts +1 -1
- package/vendor/zod/classic/checks.js +1 -1
- package/vendor/zod/classic/schemas.d.ts +2 -6
- package/vendor/zod/classic/schemas.js +9 -13
- package/vendor/zod/core/api.d.ts +8 -4
- package/vendor/zod/core/api.js +11 -23
- package/vendor/zod/core/checks.d.ts +16 -0
- package/vendor/zod/core/checks.js +31 -0
- package/vendor/zod/core/compile.js +20 -24
- package/vendor/zod/core/core.js +1 -1
- package/vendor/zod/core/json-schema-processors.d.ts +0 -1
- package/vendor/zod/core/json-schema-processors.js +8 -43
- package/vendor/zod/core/memoizer.js +2 -5
- package/vendor/zod/core/regexes.d.ts +1 -0
- package/vendor/zod/core/regexes.js +2 -0
- package/vendor/zod/core/schemas.d.ts +8 -23
- package/vendor/zod/core/schemas.js +39 -80
- package/vendor/zod/core/to-json-schema.d.ts +0 -3
- package/vendor/zod/core/to-json-schema.js +1 -1
- package/vendor/zod/core/util.js +0 -4
- package/vendor/zod/core/versions.js +1 -1
- package/vendor/zod/core/visit.js +0 -12
- package/vendor/zod/locales/ar.js +1 -0
- package/vendor/zod/locales/az.js +1 -0
- package/vendor/zod/locales/be.js +1 -0
- package/vendor/zod/locales/bg.js +1 -0
- package/vendor/zod/locales/bn.js +1 -0
- package/vendor/zod/locales/ca.js +1 -0
- package/vendor/zod/locales/ckb.js +1 -0
- package/vendor/zod/locales/cs.js +1 -0
- package/vendor/zod/locales/da.js +1 -0
- package/vendor/zod/locales/de.js +1 -0
- package/vendor/zod/locales/el.js +1 -0
- package/vendor/zod/locales/en.js +1 -0
- package/vendor/zod/locales/eo.js +1 -0
- package/vendor/zod/locales/es.js +1 -0
- package/vendor/zod/locales/fa.js +1 -0
- package/vendor/zod/locales/fi.js +1 -0
- package/vendor/zod/locales/fr-CA.js +1 -0
- package/vendor/zod/locales/fr.js +1 -0
- package/vendor/zod/locales/gu.js +1 -0
- package/vendor/zod/locales/he.js +1 -0
- package/vendor/zod/locales/hi.js +1 -0
- package/vendor/zod/locales/hr.js +1 -0
- package/vendor/zod/locales/hu.js +1 -0
- package/vendor/zod/locales/hy.js +1 -0
- package/vendor/zod/locales/id.js +1 -0
- package/vendor/zod/locales/is.js +1 -0
- package/vendor/zod/locales/it.js +1 -0
- package/vendor/zod/locales/ja.js +1 -0
- package/vendor/zod/locales/ka.js +1 -0
- package/vendor/zod/locales/km.js +1 -0
- package/vendor/zod/locales/kn.js +1 -0
- package/vendor/zod/locales/ko.js +1 -0
- package/vendor/zod/locales/lt.js +1 -0
- package/vendor/zod/locales/mk.js +1 -0
- package/vendor/zod/locales/ms.js +1 -0
- package/vendor/zod/locales/ne.js +1 -0
- package/vendor/zod/locales/nl.js +1 -0
- package/vendor/zod/locales/nn.js +1 -0
- package/vendor/zod/locales/no.js +1 -0
- package/vendor/zod/locales/ota.js +1 -0
- package/vendor/zod/locales/pl.js +1 -0
- package/vendor/zod/locales/ps.js +1 -0
- package/vendor/zod/locales/pt-BR.js +1 -0
- package/vendor/zod/locales/pt.js +1 -0
- package/vendor/zod/locales/ro.js +1 -0
- package/vendor/zod/locales/ru.js +1 -0
- package/vendor/zod/locales/sk.js +1 -0
- package/vendor/zod/locales/sl.js +1 -0
- package/vendor/zod/locales/sv.js +1 -0
- package/vendor/zod/locales/ta.js +1 -0
- package/vendor/zod/locales/tg.js +1 -0
- package/vendor/zod/locales/th.js +1 -0
- package/vendor/zod/locales/tk.js +1 -0
- package/vendor/zod/locales/tr.js +1 -0
- package/vendor/zod/locales/uk.js +1 -0
- package/vendor/zod/locales/ur.js +1 -0
- package/vendor/zod/locales/uz.js +1 -0
- package/vendor/zod/locales/vi.js +1 -0
- package/vendor/zod/locales/yo.js +1 -0
- package/vendor/zod/locales/zh-CN.js +1 -0
- package/vendor/zod/locales/zh-TW.js +1 -0
- package/vendor/zod/mini/checks.d.ts +1 -1
- package/vendor/zod/mini/checks.js +1 -1
- package/vendor/zod/mini/schemas.d.ts +2 -5
- package/vendor/zod/mini/schemas.js +9 -11
- package/vendor/zodexy/dist/esm/index.js +4 -33
- package/vendor/zodexy/dist/schema.zodexy.json +1 -17
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
const C = "\u037c"
|
|
2
|
+
const COUNT = typeof Symbol == "undefined" ? "__" + C : Symbol.for(C)
|
|
3
|
+
const SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet")
|
|
4
|
+
const top = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : {}
|
|
5
|
+
|
|
6
|
+
// :: - Style modules encapsulate a set of CSS rules defined from
|
|
7
|
+
// JavaScript. Their definitions are only available in a given DOM
|
|
8
|
+
// root after it has been _mounted_ there with `StyleModule.mount`.
|
|
9
|
+
//
|
|
10
|
+
// Style modules should be created once and stored somewhere, as
|
|
11
|
+
// opposed to re-creating them every time you need them. The amount of
|
|
12
|
+
// CSS rules generated for a given DOM root is bounded by the amount
|
|
13
|
+
// of style modules that were used. So to avoid leaking rules, don't
|
|
14
|
+
// create these dynamically, but treat them as one-time allocations.
|
|
15
|
+
export class StyleModule {
|
|
16
|
+
// :: (Object<Style>, ?{finish: ?(string) → string})
|
|
17
|
+
// Create a style module from the given spec.
|
|
18
|
+
//
|
|
19
|
+
// When `finish` is given, it is called on regular (non-`@`)
|
|
20
|
+
// selectors (after `&` expansion) to compute the final selector.
|
|
21
|
+
constructor(spec, options) {
|
|
22
|
+
this.rules = []
|
|
23
|
+
let {finish} = options || {}
|
|
24
|
+
|
|
25
|
+
function splitSelector(selector) {
|
|
26
|
+
return /^@/.test(selector) ? [selector] : selector.split(/,\s*/)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function render(selectors, spec, target, isKeyframes) {
|
|
30
|
+
let local = [], isAt = /^@(\w+)\b/.exec(selectors[0]), keyframes = isAt && isAt[1] == "keyframes"
|
|
31
|
+
if (isAt && spec == null) return target.push(selectors[0] + ";")
|
|
32
|
+
for (let prop in spec) {
|
|
33
|
+
let value = spec[prop]
|
|
34
|
+
if (/&/.test(prop)) {
|
|
35
|
+
render(prop.split(/,\s*/).map(part => selectors.map(sel => part.replace(/&/, sel))).reduce((a, b) => a.concat(b)),
|
|
36
|
+
value, target)
|
|
37
|
+
} else if (value && typeof value == "object") {
|
|
38
|
+
if (!isAt) throw new RangeError("The value of a property (" + prop + ") should be a primitive value.")
|
|
39
|
+
render(splitSelector(prop), value, local, keyframes)
|
|
40
|
+
} else if (value != null) {
|
|
41
|
+
local.push(prop.replace(/_.*/, "").replace(/[A-Z]/g, l => "-" + l.toLowerCase()) + ": " + value + ";")
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (local.length || keyframes) {
|
|
45
|
+
target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(", ") +
|
|
46
|
+
" {" + local.join(" ") + "}")
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
for (let prop in spec) render(splitSelector(prop), spec[prop], this.rules)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// :: () → string
|
|
54
|
+
// Returns a string containing the module's CSS rules.
|
|
55
|
+
getRules() { return this.rules.join("\n") }
|
|
56
|
+
|
|
57
|
+
// :: () → string
|
|
58
|
+
// Generate a new unique CSS class name.
|
|
59
|
+
static newName() {
|
|
60
|
+
let id = top[COUNT] || 1
|
|
61
|
+
top[COUNT] = id + 1
|
|
62
|
+
return C + id.toString(36)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>, ?{nonce: ?string})
|
|
66
|
+
//
|
|
67
|
+
// Mount the given set of modules in the given DOM root, which ensures
|
|
68
|
+
// that the CSS rules defined by the module are available in that
|
|
69
|
+
// context.
|
|
70
|
+
//
|
|
71
|
+
// Rules are only added to the document once per root.
|
|
72
|
+
//
|
|
73
|
+
// Rule order will follow the order of the modules, so that rules from
|
|
74
|
+
// modules later in the array take precedence of those from earlier
|
|
75
|
+
// modules. If you call this function multiple times for the same root
|
|
76
|
+
// in a way that changes the order of already mounted modules, the old
|
|
77
|
+
// order will be changed.
|
|
78
|
+
//
|
|
79
|
+
// If a Content Security Policy nonce is provided, it is added to
|
|
80
|
+
// the `<style>` tag generated by the library.
|
|
81
|
+
static mount(root, modules, options) {
|
|
82
|
+
let set = root[SET], nonce = options && options.nonce
|
|
83
|
+
if (!set) set = new StyleSet(root, nonce)
|
|
84
|
+
else if (nonce) set.setNonce(nonce)
|
|
85
|
+
set.mount(Array.isArray(modules) ? modules : [modules], root)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let adoptedSet = new Map //<Document, StyleSet>
|
|
90
|
+
|
|
91
|
+
class StyleSet {
|
|
92
|
+
constructor(root, nonce) {
|
|
93
|
+
let doc = root.ownerDocument || root, win = doc.defaultView
|
|
94
|
+
if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {
|
|
95
|
+
let adopted = adoptedSet.get(doc)
|
|
96
|
+
if (adopted) return root[SET] = adopted
|
|
97
|
+
this.sheet = new win.CSSStyleSheet
|
|
98
|
+
adoptedSet.set(doc, this)
|
|
99
|
+
} else {
|
|
100
|
+
this.styleTag = doc.createElement("style")
|
|
101
|
+
if (nonce) this.styleTag.setAttribute("nonce", nonce)
|
|
102
|
+
}
|
|
103
|
+
this.modules = []
|
|
104
|
+
root[SET] = this
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
mount(modules, root) {
|
|
108
|
+
let sheet = this.sheet
|
|
109
|
+
let pos = 0 /* Current rule offset */, j = 0 /* Index into this.modules */
|
|
110
|
+
for (let i = 0; i < modules.length; i++) {
|
|
111
|
+
let mod = modules[i], index = this.modules.indexOf(mod)
|
|
112
|
+
if (index < j && index > -1) { // Ordering conflict
|
|
113
|
+
this.modules.splice(index, 1)
|
|
114
|
+
j--
|
|
115
|
+
index = -1
|
|
116
|
+
}
|
|
117
|
+
if (index == -1) {
|
|
118
|
+
this.modules.splice(j++, 0, mod)
|
|
119
|
+
if (sheet) for (let k = 0; k < mod.rules.length; k++)
|
|
120
|
+
sheet.insertRule(mod.rules[k], pos++)
|
|
121
|
+
} else {
|
|
122
|
+
while (j < index) pos += this.modules[j++].rules.length
|
|
123
|
+
pos += mod.rules.length
|
|
124
|
+
j++
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (sheet) {
|
|
129
|
+
if (root.adoptedStyleSheets.indexOf(this.sheet) < 0)
|
|
130
|
+
root.adoptedStyleSheets = [this.sheet, ...root.adoptedStyleSheets]
|
|
131
|
+
} else {
|
|
132
|
+
let text = ""
|
|
133
|
+
for (let i = 0; i < this.modules.length; i++)
|
|
134
|
+
text += this.modules[i].getRules() + "\n"
|
|
135
|
+
this.styleTag.textContent = text
|
|
136
|
+
let target = root.head || root
|
|
137
|
+
if (this.styleTag.parentNode != target)
|
|
138
|
+
target.insertBefore(this.styleTag, target.firstChild)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
setNonce(nonce) {
|
|
143
|
+
if (this.styleTag && this.styleTag.getAttribute("nonce") != nonce)
|
|
144
|
+
this.styleTag.setAttribute("nonce", nonce)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Style::Object<union<Style,string>>
|
|
149
|
+
//
|
|
150
|
+
// A style is an object that, in the simple case, maps CSS property
|
|
151
|
+
// names to strings holding their values, as in `{color: "red",
|
|
152
|
+
// fontWeight: "bold"}`. The property names can be given in
|
|
153
|
+
// camel-case—the library will insert a dash before capital letters
|
|
154
|
+
// when converting them to CSS.
|
|
155
|
+
//
|
|
156
|
+
// If you include an underscore in a property name, it and everything
|
|
157
|
+
// after it will be removed from the output, which can be useful when
|
|
158
|
+
// providing a property multiple times, for browser compatibility
|
|
159
|
+
// reasons.
|
|
160
|
+
//
|
|
161
|
+
// A property in a style object can also be a sub-selector, which
|
|
162
|
+
// extends the current context to add a pseudo-selector or a child
|
|
163
|
+
// selector. Such a property should contain a `&` character, which
|
|
164
|
+
// will be replaced by the current selector. For example `{"&:before":
|
|
165
|
+
// {content: '"hi"'}}`. Sub-selectors and regular properties can
|
|
166
|
+
// freely be mixed in a given object. Any property containing a `&` is
|
|
167
|
+
// assumed to be a sub-selector.
|
|
168
|
+
//
|
|
169
|
+
// Finally, a property can specify an @-block to be wrapped around the
|
|
170
|
+
// styles defined inside the object that's the property's value. For
|
|
171
|
+
// example to create a media query you can do `{"@media screen and
|
|
172
|
+
// (min-width: 400px)": {...}}`.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export var base = {
|
|
2
|
+
8: "Backspace",
|
|
3
|
+
9: "Tab",
|
|
4
|
+
10: "Enter",
|
|
5
|
+
12: "NumLock",
|
|
6
|
+
13: "Enter",
|
|
7
|
+
16: "Shift",
|
|
8
|
+
17: "Control",
|
|
9
|
+
18: "Alt",
|
|
10
|
+
20: "CapsLock",
|
|
11
|
+
27: "Escape",
|
|
12
|
+
32: " ",
|
|
13
|
+
33: "PageUp",
|
|
14
|
+
34: "PageDown",
|
|
15
|
+
35: "End",
|
|
16
|
+
36: "Home",
|
|
17
|
+
37: "ArrowLeft",
|
|
18
|
+
38: "ArrowUp",
|
|
19
|
+
39: "ArrowRight",
|
|
20
|
+
40: "ArrowDown",
|
|
21
|
+
44: "PrintScreen",
|
|
22
|
+
45: "Insert",
|
|
23
|
+
46: "Delete",
|
|
24
|
+
59: ";",
|
|
25
|
+
61: "=",
|
|
26
|
+
91: "Meta",
|
|
27
|
+
92: "Meta",
|
|
28
|
+
106: "*",
|
|
29
|
+
107: "+",
|
|
30
|
+
108: ",",
|
|
31
|
+
109: "-",
|
|
32
|
+
110: ".",
|
|
33
|
+
111: "/",
|
|
34
|
+
144: "NumLock",
|
|
35
|
+
145: "ScrollLock",
|
|
36
|
+
160: "Shift",
|
|
37
|
+
161: "Shift",
|
|
38
|
+
162: "Control",
|
|
39
|
+
163: "Control",
|
|
40
|
+
164: "Alt",
|
|
41
|
+
165: "Alt",
|
|
42
|
+
173: "-",
|
|
43
|
+
186: ";",
|
|
44
|
+
187: "=",
|
|
45
|
+
188: ",",
|
|
46
|
+
189: "-",
|
|
47
|
+
190: ".",
|
|
48
|
+
191: "/",
|
|
49
|
+
192: "`",
|
|
50
|
+
219: "[",
|
|
51
|
+
220: "\\",
|
|
52
|
+
221: "]",
|
|
53
|
+
222: "'"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export var shift = {
|
|
57
|
+
48: ")",
|
|
58
|
+
49: "!",
|
|
59
|
+
50: "@",
|
|
60
|
+
51: "#",
|
|
61
|
+
52: "$",
|
|
62
|
+
53: "%",
|
|
63
|
+
54: "^",
|
|
64
|
+
55: "&",
|
|
65
|
+
56: "*",
|
|
66
|
+
57: "(",
|
|
67
|
+
59: ":",
|
|
68
|
+
61: "+",
|
|
69
|
+
173: "_",
|
|
70
|
+
186: ":",
|
|
71
|
+
187: "+",
|
|
72
|
+
188: "<",
|
|
73
|
+
189: "_",
|
|
74
|
+
190: ">",
|
|
75
|
+
191: "?",
|
|
76
|
+
192: "~",
|
|
77
|
+
219: "{",
|
|
78
|
+
220: "|",
|
|
79
|
+
221: "}",
|
|
80
|
+
222: "\""
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
var mac = typeof navigator != "undefined" && /Mac/.test(navigator.platform)
|
|
84
|
+
var ie = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent)
|
|
85
|
+
|
|
86
|
+
// Fill in the digit keys
|
|
87
|
+
for (var i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i)
|
|
88
|
+
|
|
89
|
+
// The function keys
|
|
90
|
+
for (var i = 1; i <= 24; i++) base[i + 111] = "F" + i
|
|
91
|
+
|
|
92
|
+
// And the alphabetic keys
|
|
93
|
+
for (var i = 65; i <= 90; i++) {
|
|
94
|
+
base[i] = String.fromCharCode(i + 32)
|
|
95
|
+
shift[i] = String.fromCharCode(i)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// For each code that doesn't have a shift-equivalent, copy the base name
|
|
99
|
+
for (var code in base) if (!shift.hasOwnProperty(code)) shift[code] = base[code]
|
|
100
|
+
|
|
101
|
+
export function keyName(event) {
|
|
102
|
+
// On macOS, keys held with Shift and Cmd don't reflect the effect of Shift in `.key`.
|
|
103
|
+
// On IE, shift effect is never included in `.key`.
|
|
104
|
+
var ignoreKey = mac && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey ||
|
|
105
|
+
ie && event.shiftKey && event.key && event.key.length == 1 ||
|
|
106
|
+
event.key == "Unidentified"
|
|
107
|
+
var name = (!ignoreKey && event.key) ||
|
|
108
|
+
(event.shiftKey ? shift : base)[event.keyCode] ||
|
|
109
|
+
event.key || "Unidentified"
|
|
110
|
+
// Edge sometimes produces wrong names (Issue #3)
|
|
111
|
+
if (name == "Esc") name = "Escape"
|
|
112
|
+
if (name == "Del") name = "Delete"
|
|
113
|
+
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/
|
|
114
|
+
if (name == "Left") name = "ArrowLeft"
|
|
115
|
+
if (name == "Up") name = "ArrowUp"
|
|
116
|
+
if (name == "Right") name = "ArrowRight"
|
|
117
|
+
if (name == "Down") name = "ArrowDown"
|
|
118
|
+
return name
|
|
119
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { _lt as lt, _lte as lte, _gt as gt, _gte as gte, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, _slugify as slugify, type $RefinementCtx as RefinementCtx, } from "../core/index.js";
|
|
1
|
+
export { _lt as lt, _lte as lte, _gt as gt, _gte as gte, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _properties as properties, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, _slugify as slugify, type $RefinementCtx as RefinementCtx, } from "../core/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { _lt as lt, _lte as lte, _gt as gt, _gte as gte, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, _slugify as slugify, } from "../core/index.js";
|
|
1
|
+
export { _lt as lt, _lte as lte, _gt as gt, _gte as gte, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _properties as properties, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, _slugify as slugify, } from "../core/index.js";
|
|
@@ -330,6 +330,7 @@ export declare const ZodCustomStringFormat: core.$constructor<ZodCustomStringFor
|
|
|
330
330
|
export declare function stringFormat<Format extends string>(format: Format, fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp, _params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<Format>;
|
|
331
331
|
export declare function hostname(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hostname">;
|
|
332
332
|
export declare function hex(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hex">;
|
|
333
|
+
export declare function currencyCode(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"currency_code">;
|
|
333
334
|
export declare function hash<Alg extends util.HashAlgorithm, Enc extends util.HashEncoding = "hex">(alg: Alg, params?: {
|
|
334
335
|
enc?: Enc;
|
|
335
336
|
} & core.$ZodStringFormatParams): ZodCustomStringFormat<`${Alg}_${Enc}`>;
|
|
@@ -779,11 +780,6 @@ export interface ZodCustom<O = unknown, I = unknown> extends _ZodType<core.$ZodC
|
|
|
779
780
|
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
780
781
|
}
|
|
781
782
|
export declare const ZodCustom: core.$constructor<ZodCustom>;
|
|
782
|
-
export interface ZodProperties<Shape extends core.$ZodShape = core.$ZodShape> extends _ZodType<core.$ZodPropertiesInternals<Shape>>, core.$ZodProperties<Shape> {
|
|
783
|
-
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
784
|
-
}
|
|
785
|
-
export declare const ZodProperties: core.$constructor<ZodProperties>;
|
|
786
|
-
export declare function properties<Shape extends core.$ZodShape>(shape: Shape, params?: string | core.$ZodPropertiesParams): ZodProperties<Shape>;
|
|
787
783
|
export declare function check<O = unknown>(fn: core.CheckFn<O>): core.$ZodCheck<O>;
|
|
788
784
|
export declare function custom<O>(fn?: (data: unknown) => unknown, _params?: string | core.$ZodCustomParams | undefined): ZodCustom<O, O>;
|
|
789
785
|
export declare function refine<T>(fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>, _params?: string | core.$ZodCustomParams): core.$ZodCheck<T>;
|
|
@@ -792,7 +788,7 @@ export declare const describe: typeof core.describe;
|
|
|
792
788
|
export declare const meta: typeof core.meta;
|
|
793
789
|
type ZodInstanceOfParams = core.Params<ZodCustom, core.$ZodIssueCustom, "type" | "check" | "checks" | "fn" | "abort" | "error" | "params" | "path">;
|
|
794
790
|
export interface ZodInstanceOf<T = unknown> extends ZodCustom<T, T> {
|
|
795
|
-
properties<Shape extends core.$ZodShape>(shape: Shape, params?: string | core.$
|
|
791
|
+
properties<Shape extends core.$ZodShape>(shape: Shape, params?: string | core.$ZodCheckPropertiesParams): ZodInstanceOf<T & core.$InferObjectInput<Shape, {}>>;
|
|
796
792
|
}
|
|
797
793
|
export declare const ZodInstanceOf: core.$constructor<ZodInstanceOf>;
|
|
798
794
|
declare function _instanceof<T extends typeof util.Class>(cls: T, params?: ZodInstanceOfParams): ZodInstanceOf<InstanceType<T>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as core from "../core/index.js";
|
|
2
2
|
import { util } from "../core/index.js";
|
|
3
3
|
import * as processors from "../core/json-schema-processors.js";
|
|
4
|
+
import * as regexes from "../core/regexes.js";
|
|
4
5
|
import { createStandardJSONSchemaMethod, createToJSONSchemaMethod } from "../core/to-json-schema.js";
|
|
5
6
|
import en from "../locales/en.js";
|
|
6
7
|
import * as checks from "./checks.js";
|
|
@@ -399,8 +400,8 @@ export function url(params) {
|
|
|
399
400
|
}
|
|
400
401
|
export function httpUrl(params) {
|
|
401
402
|
return core._url(ZodURL, {
|
|
402
|
-
protocol:
|
|
403
|
-
hostname:
|
|
403
|
+
protocol: regexes.httpProtocol,
|
|
404
|
+
hostname: regexes.domain,
|
|
404
405
|
...util.normalizeParams(params),
|
|
405
406
|
});
|
|
406
407
|
}
|
|
@@ -565,10 +566,13 @@ export function stringFormat(format, fnOrRegex, _params = {}) {
|
|
|
565
566
|
return core._stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
|
|
566
567
|
}
|
|
567
568
|
export function hostname(_params) {
|
|
568
|
-
return core._stringFormat(ZodCustomStringFormat, "hostname",
|
|
569
|
+
return core._stringFormat(ZodCustomStringFormat, "hostname", regexes.hostname, _params);
|
|
569
570
|
}
|
|
570
571
|
export function hex(_params) {
|
|
571
|
-
return core._stringFormat(ZodCustomStringFormat, "hex",
|
|
572
|
+
return core._stringFormat(ZodCustomStringFormat, "hex", regexes.hex, _params);
|
|
573
|
+
}
|
|
574
|
+
export function currencyCode(_params) {
|
|
575
|
+
return core._stringFormat(ZodCustomStringFormat, "currency_code", regexes.currencyCode, _params);
|
|
572
576
|
}
|
|
573
577
|
export function hash(alg, params) {
|
|
574
578
|
const enc = params?.enc ?? "hex";
|
|
@@ -1455,14 +1459,6 @@ export const ZodCustom = /*@__PURE__*/ core.$constructor("ZodCustom", (inst, def
|
|
|
1455
1459
|
ZodType.init(inst, def);
|
|
1456
1460
|
inst._zod.processJSONSchema = (ctx, json, params) => processors.customProcessor(inst, ctx, json, params);
|
|
1457
1461
|
});
|
|
1458
|
-
export const ZodProperties = /*@__PURE__*/ core.$constructor("ZodProperties", (inst, def) => {
|
|
1459
|
-
_ensureDefaultMemoizer();
|
|
1460
|
-
core.$ZodProperties.init(inst, def);
|
|
1461
|
-
ZodType.init(inst, def);
|
|
1462
|
-
});
|
|
1463
|
-
export function properties(shape, params) {
|
|
1464
|
-
return core._properties(ZodProperties, shape, params);
|
|
1465
|
-
}
|
|
1466
1462
|
// custom checks
|
|
1467
1463
|
export function check(fn) {
|
|
1468
1464
|
const ch = new core.$ZodCheck({
|
|
@@ -1490,7 +1486,7 @@ export const ZodInstanceOf = /*@__PURE__*/ core.$constructor("ZodInstanceOf", (i
|
|
|
1490
1486
|
}, {
|
|
1491
1487
|
properties(shape, params) {
|
|
1492
1488
|
// asserts in place, so the narrowed output type is truthful without a wrapper
|
|
1493
|
-
return this.check(
|
|
1489
|
+
return this.check(core._properties(shape, params));
|
|
1494
1490
|
},
|
|
1495
1491
|
});
|
|
1496
1492
|
function _instanceof(cls, params = {}) {
|
package/vendor/zod/core/api.d.ts
CHANGED
|
@@ -17,7 +17,9 @@ AlsoOmit extends Exclude<keyof T["_zod"]["def"], "check" | "error"> = never> = P
|
|
|
17
17
|
export type StringFormatParams<T extends schemas.$ZodStringFormat = schemas.$ZodStringFormat, AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "coerce" | "checks" | "error" | "check" | "format"> = never> = Params<T, NonNullable<T["_zod"]["isst"] | T["_zod"]["issc"]>, "type" | "coerce" | "checks" | "error" | "check" | "format" | AlsoOmit>;
|
|
18
18
|
export type CheckStringFormatParams<T extends schemas.$ZodStringFormat = schemas.$ZodStringFormat, AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "coerce" | "checks" | "error" | "check" | "format"> = never> = Params<T, NonNullable<T["_zod"]["issc"]>, "type" | "coerce" | "checks" | "error" | "check" | "format" | AlsoOmit>;
|
|
19
19
|
export type CheckTypeParams<T extends schemas.$ZodType & checks.$ZodCheck = schemas.$ZodType & checks.$ZodCheck, AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "checks" | "error" | "check"> = never> = Params<T, NonNullable<T["_zod"]["isst"] | T["_zod"]["issc"]>, "type" | "checks" | "error" | "check" | AlsoOmit>;
|
|
20
|
-
export type $ZodStringParams = TypeParams<schemas.$ZodString<string>, "coerce"
|
|
20
|
+
export type $ZodStringParams = TypeParams<schemas.$ZodString<string>, "coerce"> & {
|
|
21
|
+
checks?: readonly checks.$ZodCheck<string>[];
|
|
22
|
+
};
|
|
21
23
|
export declare function _string<T extends schemas.$ZodString>(Class: util.SchemaClass<T>, params?: string | $ZodStringParams): T;
|
|
22
24
|
export declare function _coercedString<T extends schemas.$ZodString>(Class: util.SchemaClass<T>, params?: string | $ZodStringParams): T;
|
|
23
25
|
export type $ZodStringFormatParams = CheckTypeParams<schemas.$ZodStringFormat, "format" | "coerce" | "when" | "pattern">;
|
|
@@ -131,7 +133,9 @@ export declare function _isoTime<T extends schemas.$ZodISOTime>(Class: util.Sche
|
|
|
131
133
|
export type $ZodISODurationParams = StringFormatParams<schemas.$ZodISODuration, "when">;
|
|
132
134
|
export type $ZodCheckISODurationParams = CheckStringFormatParams<schemas.$ZodISODuration, "when">;
|
|
133
135
|
export declare function _isoDuration<T extends schemas.$ZodISODuration>(Class: util.SchemaClass<T>, params?: string | $ZodISODurationParams | $ZodCheckISODurationParams): T;
|
|
134
|
-
export type $ZodNumberParams = TypeParams<schemas.$ZodNumber<number>, "coerce"
|
|
136
|
+
export type $ZodNumberParams = TypeParams<schemas.$ZodNumber<number>, "coerce"> & {
|
|
137
|
+
checks?: readonly checks.$ZodCheck<number>[];
|
|
138
|
+
};
|
|
135
139
|
export type $ZodNumberFormatParams = CheckTypeParams<schemas.$ZodNumberFormat, "format" | "coerce">;
|
|
136
140
|
export type $ZodCheckNumberFormatParams = CheckParams<checks.$ZodCheckNumberFormat, "format" | "when">;
|
|
137
141
|
export declare function _number<T extends schemas.$ZodNumber>(Class: util.SchemaClass<T>, params?: string | $ZodNumberParams): T;
|
|
@@ -216,8 +220,8 @@ export type $ZodCheckPropertyParams = CheckParams<checks.$ZodCheckProperty, "pro
|
|
|
216
220
|
export declare function _property<K extends string, T extends schemas.$ZodType>(property: K, schema: T, params?: string | $ZodCheckPropertyParams): checks.$ZodCheckProperty<{
|
|
217
221
|
[k in K]: util.Widen<core.input<T>>;
|
|
218
222
|
}>;
|
|
219
|
-
export type $
|
|
220
|
-
export declare function _properties<Shape extends schemas.$ZodShape>(
|
|
223
|
+
export type $ZodCheckPropertiesParams = CheckParams<checks.$ZodCheckProperties, "shape" | "when">;
|
|
224
|
+
export declare function _properties<Shape extends schemas.$ZodShape>(shape: Shape, params?: string | $ZodCheckPropertiesParams): checks.$ZodCheckProperties<Shape>;
|
|
221
225
|
export type $ZodCheckMimeTypeParams = CheckParams<checks.$ZodCheckMimeType, "mime" | "when">;
|
|
222
226
|
export declare function _mime(types: util.MimeTypes[], params?: string | $ZodCheckMimeTypeParams): checks.$ZodCheckMimeType;
|
|
223
227
|
export declare function _overwrite<T>(tx: (input: T) => T): checks.$ZodCheckOverwrite<T>;
|
package/vendor/zod/core/api.js
CHANGED
|
@@ -2,20 +2,18 @@ import * as checks from "./checks.js";
|
|
|
2
2
|
import * as registries from "./registries.js";
|
|
3
3
|
import * as schemas from "./schemas.js";
|
|
4
4
|
import * as util from "./util.js";
|
|
5
|
+
function snapshotChecks(def) {
|
|
6
|
+
if (def.checks)
|
|
7
|
+
def.checks = [...def.checks];
|
|
8
|
+
return def;
|
|
9
|
+
}
|
|
5
10
|
// @__NO_SIDE_EFFECTS__
|
|
6
11
|
export function _string(Class, params) {
|
|
7
|
-
return new Class({
|
|
8
|
-
type: "string",
|
|
9
|
-
...util.normalizeParams(params),
|
|
10
|
-
});
|
|
12
|
+
return new Class(snapshotChecks({ type: "string", ...util.normalizeParams(params) }));
|
|
11
13
|
}
|
|
12
14
|
// @__NO_SIDE_EFFECTS__
|
|
13
15
|
export function _coercedString(Class, params) {
|
|
14
|
-
return new Class({
|
|
15
|
-
type: "string",
|
|
16
|
-
coerce: true,
|
|
17
|
-
...util.normalizeParams(params),
|
|
18
|
-
});
|
|
16
|
+
return new Class(snapshotChecks({ type: "string", coerce: true, ...util.normalizeParams(params) }));
|
|
19
17
|
}
|
|
20
18
|
// @__NO_SIDE_EFFECTS__
|
|
21
19
|
export function _email(Class, params) {
|
|
@@ -324,20 +322,11 @@ export function _isoDuration(Class, params) {
|
|
|
324
322
|
}
|
|
325
323
|
// @__NO_SIDE_EFFECTS__
|
|
326
324
|
export function _number(Class, params) {
|
|
327
|
-
return new Class({
|
|
328
|
-
type: "number",
|
|
329
|
-
checks: [],
|
|
330
|
-
...util.normalizeParams(params),
|
|
331
|
-
});
|
|
325
|
+
return new Class(snapshotChecks({ type: "number", checks: [], ...util.normalizeParams(params) }));
|
|
332
326
|
}
|
|
333
327
|
// @__NO_SIDE_EFFECTS__
|
|
334
328
|
export function _coercedNumber(Class, params) {
|
|
335
|
-
return new Class({
|
|
336
|
-
type: "number",
|
|
337
|
-
coerce: true,
|
|
338
|
-
checks: [],
|
|
339
|
-
...util.normalizeParams(params),
|
|
340
|
-
});
|
|
329
|
+
return new Class(snapshotChecks({ type: "number", coerce: true, checks: [], ...util.normalizeParams(params) }));
|
|
341
330
|
}
|
|
342
331
|
// @__NO_SIDE_EFFECTS__
|
|
343
332
|
export function _int(Class, params) {
|
|
@@ -688,9 +677,8 @@ export function _property(property, schema, params) {
|
|
|
688
677
|
});
|
|
689
678
|
}
|
|
690
679
|
// @__NO_SIDE_EFFECTS__
|
|
691
|
-
export function _properties(
|
|
692
|
-
return new
|
|
693
|
-
type: "properties",
|
|
680
|
+
export function _properties(shape, params) {
|
|
681
|
+
return new checks.$ZodCheckProperties({
|
|
694
682
|
check: "properties",
|
|
695
683
|
shape,
|
|
696
684
|
...util.normalizeParams(params),
|
|
@@ -250,6 +250,22 @@ export interface $ZodCheckProperty<T extends object = object> extends $ZodCheck<
|
|
|
250
250
|
_zod: $ZodCheckPropertyInternals<T>;
|
|
251
251
|
}
|
|
252
252
|
export declare const $ZodCheckProperty: core.$constructor<$ZodCheckProperty>;
|
|
253
|
+
export interface $ZodCheckPropertiesDef<Shape extends schemas.$ZodShape = schemas.$ZodShape> extends $ZodCheckDef {
|
|
254
|
+
check: "properties";
|
|
255
|
+
shape: Shape;
|
|
256
|
+
}
|
|
257
|
+
export type $ZodCheckPropertiesInput<Shape extends schemas.$ZodShape = schemas.$ZodShape> = {
|
|
258
|
+
-readonly [k in keyof Shape]: util.Widen<core.input<Shape[k]>>;
|
|
259
|
+
};
|
|
260
|
+
export interface $ZodCheckPropertiesInternals<Shape extends schemas.$ZodShape = schemas.$ZodShape> extends $ZodCheckInternals<$ZodCheckPropertiesInput<Shape>> {
|
|
261
|
+
def: $ZodCheckPropertiesDef<Shape>;
|
|
262
|
+
issc: errors.$ZodIssue;
|
|
263
|
+
}
|
|
264
|
+
export interface $ZodCheckProperties<Shape extends schemas.$ZodShape = schemas.$ZodShape> extends $ZodCheck<$ZodCheckPropertiesInput<Shape>> {
|
|
265
|
+
_zod: $ZodCheckPropertiesInternals<Shape>;
|
|
266
|
+
[Symbol.iterator](): Iterator<this>;
|
|
267
|
+
}
|
|
268
|
+
export declare const $ZodCheckProperties: core.$constructor<$ZodCheckProperties>;
|
|
253
269
|
export interface $ZodCheckMimeTypeDef extends $ZodCheckDef {
|
|
254
270
|
check: "mime_type";
|
|
255
271
|
mime: util.MimeTypes[];
|
|
@@ -462,6 +462,37 @@ export const $ZodCheckProperty = /*@__PURE__*/ core.$constructor("$ZodCheckPrope
|
|
|
462
462
|
return;
|
|
463
463
|
};
|
|
464
464
|
});
|
|
465
|
+
export const $ZodCheckProperties = /*@__PURE__*/ core.$constructor("$ZodCheckProperties", (inst, def) => {
|
|
466
|
+
$ZodCheck.init(inst, def);
|
|
467
|
+
util.hide(inst, Symbol.iterator, function* () {
|
|
468
|
+
yield inst;
|
|
469
|
+
});
|
|
470
|
+
// key and schema snapshotted together: reading one live and the other cached lets a later mutation of the caller's shape object pair a stale key with a missing schema
|
|
471
|
+
let entries;
|
|
472
|
+
inst._zod.check = (payload) => {
|
|
473
|
+
// the base schema already typed the value, so only a nullish one is rejected here: the properties read on a primitive too, matching z.property() on a string's length
|
|
474
|
+
if (payload.value == null) {
|
|
475
|
+
payload.issues.push({ expected: "object", code: "invalid_type", input: payload.value, inst });
|
|
476
|
+
return undefined;
|
|
477
|
+
}
|
|
478
|
+
entries ?? (entries = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));
|
|
479
|
+
const input = payload.value;
|
|
480
|
+
let proms;
|
|
481
|
+
for (const [key, schema] of entries) {
|
|
482
|
+
const result = schema._zod.run({ value: input[key], issues: [] }, {});
|
|
483
|
+
if (result instanceof Promise) {
|
|
484
|
+
proms ?? (proms = []);
|
|
485
|
+
proms.push(result.then((result) => handleCheckPropertyResult(result, payload, key)));
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
handleCheckPropertyResult(result, payload, key);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (proms)
|
|
492
|
+
return Promise.all(proms).then(() => undefined);
|
|
493
|
+
return undefined;
|
|
494
|
+
};
|
|
495
|
+
});
|
|
465
496
|
export const $ZodCheckMimeType = /*@__PURE__*/ core.$constructor("$ZodCheckMimeType", (inst, def) => {
|
|
466
497
|
$ZodCheck.init(inst, def);
|
|
467
498
|
const mimeSet = new Set(def.mime);
|