typebox 1.3.0 → 1.3.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/build/format/_idna.mjs +11 -3
- package/build/system/memory/clone.mjs +6 -5
- package/package.json +1 -1
- package/readme.md +7 -4
package/build/format/_idna.mjs
CHANGED
|
@@ -34,7 +34,8 @@ const RFC5892_DISALLOWED = new Set([
|
|
|
34
34
|
// ------------------------------------------------------------------
|
|
35
35
|
// A set of Virama (halant) code points used to validate CONTEXTJ
|
|
36
36
|
// rules (RFC 5892 Appendix A.1). These characters allow a subsequent
|
|
37
|
-
// Zero Width Joiner (U+
|
|
37
|
+
// Zero Width Non-Joiner (U+200C) or Zero Width Joiner (U+200D) to
|
|
38
|
+
// be valid in a label.
|
|
38
39
|
// ------------------------------------------------------------------
|
|
39
40
|
const VIRAMA_CPS = new Set([
|
|
40
41
|
0x094d,
|
|
@@ -145,10 +146,17 @@ function IsUnicodeLabel(value) {
|
|
|
145
146
|
if (prev === undefined || !IsHebrew(prev))
|
|
146
147
|
return false;
|
|
147
148
|
break; // Hebrew GERESH
|
|
148
|
-
case
|
|
149
|
+
case 0x200c: // ZWNJ - RFC 5892 Appendix A.1
|
|
150
|
+
// Note: Full validation requires a Unicode joining type table. We reject
|
|
151
|
+
// only when preceded by ASCII (U+0000-U+007F), which can never satisfy
|
|
152
|
+
// the Virama or cursive-joining rules.
|
|
153
|
+
if (prev === undefined || (prev < 0x0080 && !IsVirama(prev)))
|
|
154
|
+
return false;
|
|
155
|
+
break;
|
|
156
|
+
case 0x200d: // ZWJ - RFC 5892 Appendix A.2
|
|
149
157
|
if (prev === undefined || !IsVirama(prev))
|
|
150
158
|
return false;
|
|
151
|
-
break;
|
|
159
|
+
break;
|
|
152
160
|
case 0x30fb: /* Checked at end via hasJapanese */
|
|
153
161
|
break; // KATAKANA MIDDLE DOT
|
|
154
162
|
}
|
|
@@ -13,15 +13,16 @@ function FromClassInstance(value) {
|
|
|
13
13
|
return value; // atomic
|
|
14
14
|
}
|
|
15
15
|
// ------------------------------------------------------------------
|
|
16
|
-
//
|
|
16
|
+
// TypeObject
|
|
17
17
|
//
|
|
18
18
|
// Types have non-enumerable properties that MUST be preserved on Clone.
|
|
19
19
|
// The following is the optimal path for TypeBox types.
|
|
20
20
|
// ------------------------------------------------------------------
|
|
21
|
-
function
|
|
22
|
-
return Guard.HasPropertyKey(value, '~kind')
|
|
21
|
+
function IsTypeObject(value) {
|
|
22
|
+
return (Guard.HasPropertyKey(value, '~kind') ||
|
|
23
|
+
Guard.HasPropertyKey(value, '~unsafe'));
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
+
function FromTypeObject(value) {
|
|
25
26
|
const result = {};
|
|
26
27
|
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
27
28
|
for (const key of Object.keys(descriptors)) {
|
|
@@ -54,7 +55,7 @@ function FromPlainObject(value) {
|
|
|
54
55
|
// ------------------------------------------------------------------
|
|
55
56
|
function FromObject(value) {
|
|
56
57
|
return (Guard.IsClassInstance(value) ? FromClassInstance(value) :
|
|
57
|
-
|
|
58
|
+
IsTypeObject(value) ? FromTypeObject(value) :
|
|
58
59
|
FromPlainObject(value));
|
|
59
60
|
}
|
|
60
61
|
// ------------------------------------------------------------------
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -113,21 +113,24 @@ type User = Type.Static<typeof User> // type User = {
|
|
|
113
113
|
|
|
114
114
|
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/script/overview) | [Example 1](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgehrgFonmXW32POv3b7k0AdAGUAxlGBgYACjwC5eAJS9G3VWvXdqdOADkAhiFQBnMHpGpKIiADsj8ALJ6YACzgBeREWFiJ0gAaUcHCEaHAAaqgiMNAATO5wAN5wZABccNYAriDEqFAANHBIaZnZuXAAvoHBROGR0VAAzPEAogBuegA2GU6oADwRUbFwAGSJcABexVk5UBUAfFUh6AP1ACwt7V09-XXQTaNJAO5TpbPlC35KygAiqGjWACao1vD6hiZmFla28En2xq5yvF+KhvOJJFIknIBI4XBUCn4gosahFYKgyPEElUgpAjMAYMAbGkVtBVnlseloCBOsTdo1yUEghlWrTBlAYlVKkElnAAOKoHCoGBQJCYimtXIE8xGWlosgAbQAugzGcBHsBpScZkrOcjQrDcsBOmLGXADMRgM8YKy1iqgg9gBgMBkjKgbaS7XATJEMh09FB3VBVrruTV-kZXB4saaAOYCwzCop8+NCkWe6kwQ00uAG8SdXWXLT0ABKGReoHQxdQGA6dUJ1ko4ecAjA2DQsEtRgEccFiZbbclnYEEo70oE+NQIC7rYg7YJxhbEDxBJs-dng4XZEbALXc6HPYTIt3G67I6lC4nU+PHYX1ipnWv867W6bj-3Kb7M73C7PGovmavL8TwEZk303bcIzArsMyzDooIEB0nRdUEgJvZ8IObVCnwEGC8zgrCh3NS0Xngl8dwIhdcKNfCBzQgRvREX1-VIos4CEGAnA1OAAElrAwXJnnMShnWsKJ6zgKBnieKApHeZw0hBYQOKlXolggDAcwBOYFESKo5O7D8j1-aV5QABkVRdl3rAQtyCfSD1TJBh0HEzzIEO8oGpODbLgezDKc4zjDMizQJ8-SqIfRDnVdGy9J3CK4KIq1Yrs+Kejw+i0EYv0oFi8ogA) | [Example 2](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgehrgFonmXW32POv3b7k0AdACpejbuImTu1OnAByAQxCoAzmAUBjVJQB2S1eq1wAsgpgALOAG9KcOKjKRYcDRB0r4ANVQaY0AExwALyIRAIA8sQAVj4wABRWcGQAXKGCcgCuIMSoUHEAlAA0cEip-KgCmdm5BXAAvvm29o7Q8K7uXrHQAMzBaRUAogBuCgA2GWaoceUCAJI6MLkqsXEA2t6+AcUzkTG+CXAAXmVhVTl5+fX5ALr5jXYOTm1uHnAbflAALH0zw2MTi2mYXmiygy326y6UG62zCuxWiQA7id0llzrUGrdGnUZPQACKoNA6AAmqAW8n0ak02nar28sAcPzh0QRTUgKmAMGAblSpgsAne0E+hSaOmgIDGvLM5gFUJhTQyQyl-MFUH8lAalFp8AA4qgcKgYFAkEzBPD9jY7ENclytCoURUAIJQKAKJBxemLMhFJrAEnAO0OgTO13umZnGp3DWNbUmSZQYBjU0Vc3xS1wJTEYBkmDKmWq4VNYnADAYDLLPOyzZfEV2NQ+DKjBRQSsF6Nal7wYyqSwhHYsi1NADm+uURtKcD1BvHtbgEtBidGytyi-bogAShkFqB0OvUBhRrFuTpKN2VDKwNg0LBsyoBCPp8aBJeINeuaoBNab3aBJzUCA7xfN9b2fCAOS5NxnyvG0QLIU8eyg18YI-B8xyfIDkLvL9bQ-P8AMQ4CPzFKAJVGAjMIEOCzwvaCbxQ0dDXQ2j3ywmCfzwwDmJAxVyLou8qIQjC+IEecVzGXiWIEYtS3LCohMkgTzwkkDRITcT5JAzNswWZSP0UmikOE1TF10u96w0Rtm1MyjcTgABlGAzADOB5gwXIyS0Sgyx0XxjzgKAyVJPJlHPIMHKcjQAB5CDQCAMBMHsAD5LnTEKZVQxikE-NjVFWAAGa5QPA48bLsNL7wY8dsu-XKCoEYjSNKucEIyqrsIDWrCp4uCyoQ4zxOkstlia8r+rIrScxGvr4xM8zLKgGy6iAA) | [Challenge](test/typescript/readme.md)
|
|
115
115
|
|
|
116
|
-
TypeBox includes a syntax engine that can transform TypeScript declarations into JSON Schema. The engine is a full syntactic frontend to Type.* and supports many advanced type-level constructs such as Conditional, Mapped, Indexed, Infer, Generics, Distributed types and more. This feature is implemented symmetrically at runtime and statically via TypeScript Template Literal types.
|
|
116
|
+
TypeBox includes a syntax engine that can transform TypeScript declarations into JSON Schema. The engine is a full syntactic frontend to Type.* and supports many advanced type-level constructs such as Conditional, Mapped, Indexed, Infer, Generics, Distributed types and more. This feature is implemented symmetrically at runtime and statically via TypeScript Template Literal types.
|
|
117
|
+
|
|
118
|
+
Syntax highlighting is available via the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=sinclairzx81.typebox-script)
|
|
119
|
+
|
|
117
120
|
|
|
118
121
|
### Example
|
|
119
122
|
|
|
120
|
-
The following uses Script to parse TypeScript declarations into JSON Schema.
|
|
123
|
+
The following uses Script to parse TypeScript declarations into JSON Schema.
|
|
121
124
|
|
|
122
125
|
```typescript
|
|
123
|
-
//
|
|
126
|
+
// Module
|
|
124
127
|
const Math = Type.Script(`
|
|
125
128
|
type Vector2 = { x: number, y: number }
|
|
126
129
|
type Vector3 = Evaluate<Vector2 & { z: number }>
|
|
127
130
|
type Vector4 = Evaluate<Vector3 & { w: number }>
|
|
128
131
|
`)
|
|
129
132
|
|
|
130
|
-
// Dependent
|
|
133
|
+
// Dependent Module
|
|
131
134
|
const { Mesh } = Type.Script({ ...Math }, `
|
|
132
135
|
type Vertex = {
|
|
133
136
|
position: Vector4,
|