@openclaw/firecrawl-plugin 2026.8.1-beta.3 → 2026.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/api.js +12 -11
  2. package/dist/{firecrawl-client-mz7GIgb4.js → firecrawl-client-BPFpIblh.js} +15 -22
  3. package/dist/{firecrawl-fetch-provider-shared-DlD5WG_i.js → firecrawl-fetch-provider-CIpxLKLq.js} +36 -1
  4. package/dist/{firecrawl-free-search-provider-BnGTMs5x.js → firecrawl-free-search-provider-BEyEhOfR.js} +3 -7
  5. package/dist/index.js +3 -3
  6. package/dist/web-fetch-contract-api.js +2 -11
  7. package/dist/web-fetch-provider.js +1 -1
  8. package/dist/web-search-contract-api.js +2 -15
  9. package/dist/web-search-provider.js +1 -1
  10. package/node_modules/typebox/build/format/date.d.mts +1 -1
  11. package/node_modules/typebox/build/format/date.mjs +1 -1
  12. package/node_modules/typebox/build/format/date_time.d.mts +2 -2
  13. package/node_modules/typebox/build/format/date_time.mjs +3 -3
  14. package/node_modules/typebox/build/format/email.d.mts +1 -1
  15. package/node_modules/typebox/build/format/email.mjs +2 -2
  16. package/node_modules/typebox/build/format/hostname.mjs +2 -10
  17. package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
  18. package/node_modules/typebox/build/format/idn_email.mjs +3 -3
  19. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
  20. package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
  21. package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
  22. package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
  23. package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
  24. package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
  25. package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
  26. package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
  27. package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
  28. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +41 -0
  29. package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
  30. package/node_modules/typebox/build/format/idna/index.mjs +2 -0
  31. package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
  32. package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
  33. package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
  34. package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
  35. package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
  36. package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
  37. package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
  38. package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
  39. package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
  40. package/node_modules/typebox/build/format/ipv4.mjs +2 -32
  41. package/node_modules/typebox/build/format/ipv6.mjs +2 -61
  42. package/node_modules/typebox/build/format/iri.d.mts +2 -2
  43. package/node_modules/typebox/build/format/iri.mjs +26 -8
  44. package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
  45. package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
  46. package/node_modules/typebox/build/format/regex.d.mts +1 -2
  47. package/node_modules/typebox/build/format/regex.mjs +2 -6
  48. package/node_modules/typebox/build/format/time.d.mts +2 -2
  49. package/node_modules/typebox/build/format/time.mjs +19 -14
  50. package/node_modules/typebox/build/format/uri.d.mts +1 -1
  51. package/node_modules/typebox/build/format/uri.mjs +3 -130
  52. package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
  53. package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
  54. package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
  55. package/node_modules/typebox/build/format/uri_template.mjs +4 -5
  56. package/node_modules/typebox/build/format/url.d.mts +3 -3
  57. package/node_modules/typebox/build/format/url.mjs +4 -5
  58. package/node_modules/typebox/build/guard/emit.d.mts +3 -1
  59. package/node_modules/typebox/build/guard/emit.mjs +12 -5
  60. package/node_modules/typebox/build/guard/guard.d.mts +8 -2
  61. package/node_modules/typebox/build/guard/guard.mjs +25 -4
  62. package/node_modules/typebox/build/guard/string.d.mts +2 -2
  63. package/node_modules/typebox/build/guard/string.mjs +7 -7
  64. package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
  65. package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
  66. package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
  67. package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
  68. package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
  69. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
  70. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
  71. package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
  72. package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
  73. package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
  74. package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
  75. package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
  76. package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
  77. package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
  78. package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
  79. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
  80. package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
  81. package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
  82. package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
  83. package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
  84. package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
  85. package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
  86. package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
  87. package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
  88. package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
  89. package/node_modules/typebox/build/schema/types/index.mjs +0 -2
  90. package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
  91. package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
  92. package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
  93. package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
  94. package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
  95. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
  96. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
  97. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
  98. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
  99. package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
  100. package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
  101. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
  102. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
  103. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
  104. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
  105. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
  106. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
  107. package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
  108. package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
  109. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
  110. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
  111. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
  112. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
  113. package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
  114. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
  115. package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
  116. package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
  117. package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
  118. package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
  119. package/node_modules/typebox/build/type/script/parser.mjs +27 -23
  120. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  121. package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  122. package/node_modules/typebox/package.json +27 -27
  123. package/node_modules/typebox/readme.md +79 -82
  124. package/package.json +5 -5
  125. package/dist/firecrawl-fetch-provider-kMXMNJJw.js +0 -38
  126. package/node_modules/typebox/build/format/_idna.d.mts +0 -2
  127. package/node_modules/typebox/build/format/_idna.mjs +0 -246
  128. package/node_modules/typebox/build/format/_puny.d.mts +0 -1
  129. package/node_modules/typebox/build/format/_puny.mjs +0 -77
  130. package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
  131. package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
  132. package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
  133. package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
  134. package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
  135. package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
5
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
6
  };
7
- var _Stack_instances, _Stack_PushResourceAnchors, _Stack_PopResourceAnchors, _Stack_FromContext, _Stack_FromRef;
7
+ var _Stack_instances, _Stack_PushResourceAnchors, _Stack_PopResourceAnchors;
8
8
  import * as Schema from '../types/index.mjs';
9
9
  import { Guard as G } from '../../guard/index.mjs';
10
10
  import { Resolve } from '../resolve/index.mjs';
@@ -22,7 +22,7 @@ export class Stack {
22
22
  // Base
23
23
  // ----------------------------------------------------------------
24
24
  BaseURL() {
25
- return this.ids.reduce((result, schema) => new URL(schema.$id, result), new URL('http://unknown'));
25
+ return this.ids.reduce((result, schema) => new URL(schema.$id, result), Resolve.DefaultBase);
26
26
  }
27
27
  Base() {
28
28
  return this.ids[this.ids.length - 1] ?? this.schema;
@@ -58,23 +58,29 @@ export class Stack {
58
58
  if (Schema.IsDynamicAnchor(schema))
59
59
  this.dynamicAnchors.pop();
60
60
  }
61
+ // ----------------------------------------------------------------
62
+ // Ref
63
+ // ----------------------------------------------------------------
61
64
  Ref(ref) {
62
- return __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_FromContext).call(this, ref) ?? __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_FromRef).call(this, ref);
65
+ const root = this.schema;
66
+ return !ref.$ref.startsWith('#')
67
+ ? Resolve.Ref(this.context, root, ref.$ref)
68
+ : Resolve.Ref(this.context, this.Base(), ref.$ref);
63
69
  }
64
70
  // ----------------------------------------------------------------
65
71
  // RecursiveRef
66
72
  // ----------------------------------------------------------------
67
73
  RecursiveRef(recursiveRef) {
68
74
  return Schema.IsRecursiveAnchorTrue(this.Base())
69
- ? Resolve.Ref(this.recursiveAnchors[0], recursiveRef.$recursiveRef)
70
- : Resolve.Ref(this.Base(), recursiveRef.$recursiveRef);
75
+ ? Resolve.Ref(this.context, this.recursiveAnchors[0], recursiveRef.$recursiveRef)
76
+ : Resolve.Ref(this.context, this.Base(), recursiveRef.$recursiveRef);
71
77
  }
72
78
  // ----------------------------------------------------------------
73
79
  // DynamicRef
74
80
  // ----------------------------------------------------------------
75
81
  DynamicRef(dynamicRef) {
76
82
  const root = this.schema;
77
- return Resolve.DynamicRef(root, this.Base(), dynamicRef, this.dynamicAnchors);
83
+ return Resolve.DynamicRef(this.context, root, this.Base(), dynamicRef, this.dynamicAnchors);
78
84
  }
79
85
  }
80
86
  _Stack_instances = new WeakSet(), _Stack_PushResourceAnchors = function _Stack_PushResourceAnchors(schema, isRoot = true) {
@@ -97,11 +103,4 @@ _Stack_instances = new WeakSet(), _Stack_PushResourceAnchors = function _Stack_P
97
103
  this.dynamicAnchors.pop();
98
104
  for (const key of G.Keys(current))
99
105
  __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_PopResourceAnchors).call(this, current[key], false);
100
- }, _Stack_FromContext = function _Stack_FromContext(ref) {
101
- return G.HasPropertyKey(this.context, ref.$ref) ? this.context[ref.$ref] : undefined;
102
- }, _Stack_FromRef = function _Stack_FromRef(ref) {
103
- const root = this.schema;
104
- return !ref.$ref.startsWith('#')
105
- ? Resolve.Ref(root, ref.$ref)
106
- : Resolve.Ref(this.Base(), ref.$ref);
107
106
  };
@@ -12,15 +12,25 @@ function IsValid(schema) {
12
12
  // ------------------------------------------------------------------
13
13
  // Build
14
14
  // ------------------------------------------------------------------
15
- export function BuildAdditionalItems(stack, context, schema, value) {
16
- if (!IsValid(schema))
17
- return E.Constant(true);
15
+ function BuildAdditionalItemsStandard(stack, context, schema, value) {
18
16
  const [item, index] = [Unique(), Unique()];
19
17
  const isSchema = BuildSchemaPushStack(stack, context, schema.additionalItems, item);
20
18
  const isLength = E.IsLessThan(index, E.Constant(schema.items.length));
21
19
  const addIndex = context.AddIndex(index);
22
- const guarded = context.UseUnevaluated() ? E.Or(isLength, E.And(isSchema, addIndex)) : E.Or(isLength, isSchema);
23
- return E.Call(E.Member(value, 'every'), [E.ArrowFunction([item, index], guarded)]);
20
+ return E.Every(value, E.Constant(0), [item, index], E.Or(isLength, E.And(isSchema, addIndex)));
21
+ }
22
+ function BuildAdditionalItemsFast(stack, context, schema, value) {
23
+ const [item, index] = [Unique(), Unique()];
24
+ const isSchema = BuildSchemaPushStack(stack, context, schema.additionalItems, item);
25
+ const isLength = E.IsLessThan(index, E.Constant(schema.items.length));
26
+ return E.Every(value, E.Constant(0), [item, index], E.Or(isLength, isSchema));
27
+ }
28
+ export function BuildAdditionalItems(stack, context, schema, value) {
29
+ if (!IsValid(schema))
30
+ return E.Constant(true);
31
+ return context.UseUnevaluated()
32
+ ? BuildAdditionalItemsStandard(stack, context, schema, value)
33
+ : BuildAdditionalItemsFast(stack, context, schema, value);
24
34
  }
25
35
  // ------------------------------------------------------------------
26
36
  // Check
@@ -28,7 +38,7 @@ export function BuildAdditionalItems(stack, context, schema, value) {
28
38
  export function CheckAdditionalItems(stack, context, schema, value) {
29
39
  if (!IsValid(schema))
30
40
  return true;
31
- const isAdditionalItems = value.every((item, index) => {
41
+ const isAdditionalItems = G.Every(value, 0, (item, index) => {
32
42
  return G.IsLessThan(index, schema.items.length)
33
43
  || (CheckSchemaPushStack(stack, context, schema.additionalItems, item) && context.AddIndex(index));
34
44
  });
@@ -40,7 +50,7 @@ export function CheckAdditionalItems(stack, context, schema, value) {
40
50
  export function ErrorAdditionalItems(stack, context, schemaPath, instancePath, schema, value) {
41
51
  if (!IsValid(schema))
42
52
  return true;
43
- const isAdditionalItems = value.every((item, index) => {
53
+ const isAdditionalItems = G.Every(value, 0, (item, index) => {
44
54
  const nextSchemaPath = `${schemaPath}/additionalItems`;
45
55
  const nextInstancePath = `${instancePath}/${index}`;
46
56
  return G.IsLessThan(index, schema.items.length) ||
@@ -3,6 +3,7 @@ import * as S from '../types/index.mjs';
3
3
  import * as V from './_externals.mjs';
4
4
  import { Unique } from './_unique.mjs';
5
5
  import { AccumulatedErrorContext } from './_context.mjs';
6
+ import { UnicodeRegExp } from './_regexp.mjs';
6
7
  import { EmitGuard as E, Guard as G } from '../../guard/index.mjs';
7
8
  import { BuildSchemaPushStack, CheckSchemaPushStack, ErrorSchemaPushStack } from './schema.mjs';
8
9
  // ------------------------------------------------------------------
@@ -58,7 +59,7 @@ export function BuildAdditionalPropertiesFast(_context, schema, value) {
58
59
  // ------------------------------------------------------------------
59
60
  export function BuildAdditionalPropertiesStandard(stack, context, schema, value) {
60
61
  const [key, _index] = [Unique(), Unique()];
61
- const regexp = V.CreateVariable(new RegExp(GetPropertiesPattern(schema)));
62
+ const regexp = V.CreateVariable(UnicodeRegExp(GetPropertiesPattern(schema)));
62
63
  const isSchema = BuildSchemaPushStack(stack, context, schema.additionalProperties, `${value}[${key}]`);
63
64
  const isKey = E.Call(E.Member(regexp, 'test'), [key]);
64
65
  const addKey = context.AddKey(key);
@@ -78,7 +79,7 @@ export function BuildAdditionalProperties(stack, context, schema, value) {
78
79
  // Check
79
80
  // ------------------------------------------------------------------
80
81
  export function CheckAdditionalProperties(stack, context, schema, value) {
81
- const regexp = new RegExp(GetPropertiesPattern(schema));
82
+ const regexp = UnicodeRegExp(GetPropertiesPattern(schema));
82
83
  const isAdditionalProperties = G.Every(G.Keys(value), 0, (key, _index) => {
83
84
  return regexp.test(key) ||
84
85
  (CheckSchemaPushStack(stack, context, schema.additionalProperties, value[key]) && context.AddKey(key));
@@ -89,7 +90,7 @@ export function CheckAdditionalProperties(stack, context, schema, value) {
89
90
  // Error
90
91
  // ------------------------------------------------------------------
91
92
  export function ErrorAdditionalProperties(stack, context, schemaPath, instancePath, schema, value) {
92
- const regexp = new RegExp(GetPropertiesPattern(schema));
93
+ const regexp = UnicodeRegExp(GetPropertiesPattern(schema));
93
94
  const additionalProperties = [];
94
95
  const isAdditionalProperties = G.EveryAll(G.Keys(value), 0, (key, _index) => {
95
96
  const nextSchemaPath = `${schemaPath}/additionalProperties`;
@@ -12,13 +12,24 @@ function IsValid(schema) {
12
12
  // ------------------------------------------------------------------
13
13
  // Build
14
14
  // ------------------------------------------------------------------
15
+ function BuildContainsStandard(stack, context, schema, value) {
16
+ const [item, index] = [Unique(), Unique()];
17
+ const isLength = E.Not(E.IsEqual(E.Member(value, 'length'), E.Constant(0)));
18
+ const isSome = E.SomeAll(value, [item, index], E.And(BuildSchema(stack, context, schema.contains, item), context.AddIndex(index)));
19
+ return E.And(isLength, isSome);
20
+ }
21
+ function BuildContainsFast(stack, context, schema, value) {
22
+ const [item] = [Unique()];
23
+ const isLength = E.Not(E.IsEqual(E.Member(value, 'length'), E.Constant(0)));
24
+ const isSome = E.Some(value, [item, '_'], BuildSchema(stack, context, schema.contains, item));
25
+ return E.And(isLength, isSome);
26
+ }
15
27
  export function BuildContains(stack, context, schema, value) {
16
28
  if (!IsValid(schema))
17
29
  return E.Constant(true);
18
- const item = Unique();
19
- const isLength = E.Not(E.IsEqual(E.Member(value, 'length'), E.Constant(0)));
20
- const isSome = E.Call(E.Member(value, 'some'), [E.ArrowFunction([item], BuildSchema(stack, context, schema.contains, item))]);
21
- return E.And(isLength, isSome);
30
+ return context.UseUnevaluated()
31
+ ? BuildContainsStandard(stack, context, schema, value)
32
+ : BuildContainsFast(stack, context, schema, value);
22
33
  }
23
34
  // ------------------------------------------------------------------
24
35
  // Check
@@ -26,8 +37,9 @@ export function BuildContains(stack, context, schema, value) {
26
37
  export function CheckContains(stack, context, schema, value) {
27
38
  if (!IsValid(schema))
28
39
  return true;
29
- return !G.IsEqual(value.length, 0) &&
30
- value.some((item) => CheckSchema(stack, context, schema.contains, item));
40
+ return !G.IsEqual(value.length, 0) && G.SomeAll(value, (item, index) => {
41
+ return CheckSchema(stack, context, schema.contains, item) && context.AddIndex(index);
42
+ });
31
43
  }
32
44
  // ------------------------------------------------------------------
33
45
  // Error
@@ -16,7 +16,7 @@ export function BuildEnum(_stack, _context, schema, value) {
16
16
  // Check
17
17
  // ------------------------------------------------------------------
18
18
  export function CheckEnum(_stack, _context, schema, value) {
19
- return schema.enum.some(option => G.IsValueLike(option)
19
+ return G.Some(schema.enum, option => G.IsValueLike(option)
20
20
  ? G.IsEqual(value, option)
21
21
  : G.IsDeepEqual(value, option));
22
22
  }
@@ -5,15 +5,26 @@ import { BuildSchemaPushStack, CheckSchemaPushStack, ErrorSchemaPushStack } from
5
5
  // ------------------------------------------------------------------
6
6
  // ItemsSized
7
7
  // ------------------------------------------------------------------
8
- function BuildItemsSized(stack, context, schema, value) {
8
+ function BuildItemsSizedStandard(stack, context, schema, value) {
9
9
  return E.ReduceAnd(schema.items.map((schema, index) => {
10
10
  const isLength = E.IsLessEqualThan(E.Member(value, 'length'), E.Constant(index));
11
11
  const isSchema = BuildSchemaPushStack(stack, context, schema, `${value}[${index}]`);
12
12
  const addIndex = context.AddIndex(E.Constant(index));
13
- const guarded = context.UseUnevaluated() ? E.And(isSchema, addIndex) : isSchema;
14
- return E.Or(isLength, guarded);
13
+ return E.Or(isLength, E.And(isSchema, addIndex));
15
14
  }));
16
15
  }
16
+ function BuildItemsSizedFast(stack, context, schema, value) {
17
+ return E.ReduceAnd(schema.items.map((schema, index) => {
18
+ const isLength = E.IsLessEqualThan(E.Member(value, 'length'), E.Constant(index));
19
+ const isSchema = BuildSchemaPushStack(stack, context, schema, `${value}[${index}]`);
20
+ return E.Or(isLength, isSchema);
21
+ }));
22
+ }
23
+ function BuildItemsSized(stack, context, schema, value) {
24
+ return context.UseUnevaluated()
25
+ ? BuildItemsSizedStandard(stack, context, schema, value)
26
+ : BuildItemsSizedFast(stack, context, schema, value);
27
+ }
17
28
  function CheckItemsSized(stack, context, schema, value) {
18
29
  return G.Every(schema.items, 0, (schema, index) => {
19
30
  return G.IsLessEqualThan(value.length, index)
@@ -31,12 +42,21 @@ function ErrorItemsSized(stack, context, schemaPath, instancePath, schema, value
31
42
  // ------------------------------------------------------------------
32
43
  // ItemsUnsized
33
44
  // ------------------------------------------------------------------
34
- function BuildItemsUnsized(stack, context, schema, value) {
45
+ function BuildItemsUnsizedStandard(stack, context, schema, value) {
35
46
  const offset = Schema.IsPrefixItems(schema) ? schema.prefixItems.length : 0;
36
47
  const isSchema = BuildSchemaPushStack(stack, context, schema.items, 'element');
37
48
  const addIndex = context.AddIndex('index');
38
- const guarded = context.UseUnevaluated() ? E.And(isSchema, addIndex) : isSchema;
39
- return E.Every(value, E.Constant(offset), ['element', 'index'], guarded);
49
+ return E.Every(value, E.Constant(offset), ['element', 'index'], E.And(isSchema, addIndex));
50
+ }
51
+ function BuildItemsUnsizedFast(stack, context, schema, value) {
52
+ const offset = Schema.IsPrefixItems(schema) ? schema.prefixItems.length : 0;
53
+ const isSchema = BuildSchemaPushStack(stack, context, schema.items, 'element');
54
+ return E.Every(value, E.Constant(offset), ['element', 'index'], isSchema);
55
+ }
56
+ function BuildItemsUnsized(stack, context, schema, value) {
57
+ return context.UseUnevaluated()
58
+ ? BuildItemsUnsizedStandard(stack, context, schema, value)
59
+ : BuildItemsUnsizedFast(stack, context, schema, value);
40
60
  }
41
61
  function CheckItemsUnsized(stack, context, schema, value) {
42
62
  const offset = Schema.IsPrefixItems(schema) ? schema.prefixItems.length : 0;
@@ -15,8 +15,8 @@ function IsValid(schema) {
15
15
  export function BuildMaxContains(stack, context, schema, value) {
16
16
  if (!IsValid(schema))
17
17
  return E.Constant(true);
18
- const [result, item] = [Unique(), Unique()];
19
- const count = E.Call(E.Member(value, 'reduce'), [E.ArrowFunction([result, item], E.Ternary(BuildSchema(stack, context, schema.contains, item), E.PrefixIncrement(result), result)), E.Constant(0)]);
18
+ const [item] = [Unique()];
19
+ const count = E.Counted(value, [item, '_'], BuildSchema(stack, context, schema.contains, item));
20
20
  return E.IsLessEqualThan(count, E.Constant(schema.maxContains));
21
21
  }
22
22
  // ------------------------------------------------------------------
@@ -25,7 +25,7 @@ export function BuildMaxContains(stack, context, schema, value) {
25
25
  export function CheckMaxContains(stack, context, schema, value) {
26
26
  if (!IsValid(schema))
27
27
  return true;
28
- const count = value.reduce((result, item) => CheckSchema(stack, context, schema.contains, item) ? ++result : result, 0);
28
+ const count = G.Counted(value, (item) => CheckSchema(stack, context, schema.contains, item));
29
29
  return G.IsLessEqualThan(count, schema.maxContains);
30
30
  }
31
31
  // ------------------------------------------------------------------
@@ -12,12 +12,22 @@ function IsValid(schema) {
12
12
  // ------------------------------------------------------------------
13
13
  // Build
14
14
  // ------------------------------------------------------------------
15
+ function BuildMinContainsStandard(stack, context, schema, value) {
16
+ const [item, index] = [Unique(), Unique()];
17
+ const count = E.Counted(value, [item, index], E.And(BuildSchema(stack, context, schema.contains, item), context.AddIndex(index)));
18
+ return E.IsGreaterEqualThan(count, E.Constant(schema.minContains));
19
+ }
20
+ function BuildMinContainsFast(stack, context, schema, value) {
21
+ const [item] = [Unique()];
22
+ const count = E.Counted(value, [item, '_'], BuildSchema(stack, context, schema.contains, item));
23
+ return E.IsGreaterEqualThan(count, E.Constant(schema.minContains));
24
+ }
15
25
  export function BuildMinContains(stack, context, schema, value) {
16
26
  if (!IsValid(schema))
17
27
  return E.Constant(true);
18
- const [result, item] = [Unique(), Unique()];
19
- const count = E.Call(E.Member(value, 'reduce'), [E.ArrowFunction([result, item], E.Ternary(BuildSchema(stack, context, schema.contains, item), E.PrefixIncrement(result), result)), E.Constant(0)]);
20
- return E.IsGreaterEqualThan(count, E.Constant(schema.minContains));
28
+ return context.UseUnevaluated()
29
+ ? BuildMinContainsStandard(stack, context, schema, value)
30
+ : BuildMinContainsFast(stack, context, schema, value);
21
31
  }
22
32
  // ------------------------------------------------------------------
23
33
  // Check
@@ -25,7 +35,7 @@ export function BuildMinContains(stack, context, schema, value) {
25
35
  export function CheckMinContains(stack, context, schema, value) {
26
36
  if (!IsValid(schema))
27
37
  return true;
28
- const count = value.reduce((result, item) => CheckSchema(stack, context, schema.contains, item) ? ++result : result, 0);
38
+ const count = G.Counted(value, (item, index) => CheckSchema(stack, context, schema.contains, item) && context.AddIndex(index));
29
39
  return G.IsGreaterEqualThan(count, schema.minContains);
30
40
  }
31
41
  // ------------------------------------------------------------------
@@ -6,14 +6,16 @@ import { BuildSchema, CheckSchema } from './schema.mjs';
6
6
  // ------------------------------------------------------------------
7
7
  // Build
8
8
  // ------------------------------------------------------------------
9
- function BuildNotUnevaluated(stack, context, schema, value) {
9
+ function BuildNotStandard(stack, context, schema, value) {
10
10
  return Reducer(stack, context, [schema.not], value, E.Not(E.IsEqual(E.Member('results', 'length'), E.Constant(1))));
11
11
  }
12
12
  function BuildNotFast(stack, context, schema, value) {
13
13
  return E.Not(BuildSchema(stack, context, schema.not, value));
14
14
  }
15
15
  export function BuildNot(stack, context, schema, value) {
16
- return context.UseUnevaluated() ? BuildNotUnevaluated(stack, context, schema, value) : BuildNotFast(stack, context, schema, value);
16
+ return context.UseUnevaluated()
17
+ ? BuildNotStandard(stack, context, schema, value)
18
+ : BuildNotFast(stack, context, schema, value);
17
19
  }
18
20
  // ------------------------------------------------------------------
19
21
  // Check
@@ -3,22 +3,23 @@ import { CheckContext, AccumulatedErrorContext } from './_context.mjs';
3
3
  import { Reducer } from './_reducer.mjs';
4
4
  import { EmitGuard as E, Guard as G } from '../../guard/index.mjs';
5
5
  import { BuildSchema, CheckSchema, ErrorSchema } from './schema.mjs';
6
+ import { Unique } from './_unique.mjs';
6
7
  // ------------------------------------------------------------------
7
8
  // Build
8
9
  // ------------------------------------------------------------------
9
- function BuildOneOfUnevaluated(stack, context, schema, value) {
10
+ function BuildOneOfStandard(stack, context, schema, value) {
10
11
  return Reducer(stack, context, schema.oneOf, value, E.IsEqual(E.Member('results', 'length'), E.Constant(1)));
11
12
  }
12
13
  function BuildOneOfFast(stack, context, schema, value) {
14
+ const [result] = [Unique()];
13
15
  const results = E.ArrayLiteral(schema.oneOf.map((schema) => BuildSchema(stack, context, schema, value)));
14
- const count = E.Call(E.Member(results, 'reduce'), [
15
- E.ArrowFunction(['count', 'result'], E.Ternary(E.IsEqual('result', E.Constant(true)), E.PrefixIncrement('count'), 'count')),
16
- E.Constant(0),
17
- ]);
16
+ const count = E.Counted(results, [result, '_'], E.IsEqual(result, E.Constant(true)));
18
17
  return E.IsEqual(count, E.Constant(1));
19
18
  }
20
19
  export function BuildOneOf(stack, context, schema, value) {
21
- return context.UseUnevaluated() ? BuildOneOfUnevaluated(stack, context, schema, value) : BuildOneOfFast(stack, context, schema, value);
20
+ return context.UseUnevaluated()
21
+ ? BuildOneOfStandard(stack, context, schema, value)
22
+ : BuildOneOfFast(stack, context, schema, value);
22
23
  }
23
24
  // ------------------------------------------------------------------
24
25
  // Check
@@ -1,18 +1,19 @@
1
1
  // deno-fmt-ignore-file
2
2
  import * as Externals from './_externals.mjs';
3
3
  import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
4
+ import { UnicodeRegExp } from './_regexp.mjs';
4
5
  // ------------------------------------------------------------------
5
6
  // Build
6
7
  // ------------------------------------------------------------------
7
8
  export function BuildPattern(_stack, _context, schema, value) {
8
- const regexp = Externals.CreateVariable(G.IsString(schema.pattern) ? new RegExp(schema.pattern, 'u') : schema.pattern);
9
+ const regexp = Externals.CreateVariable(G.IsString(schema.pattern) ? UnicodeRegExp(schema.pattern) : schema.pattern);
9
10
  return E.Call(E.Member(regexp, 'test'), [value]);
10
11
  }
11
12
  // ------------------------------------------------------------------
12
13
  // Check
13
14
  // ------------------------------------------------------------------
14
15
  export function CheckPattern(_stack, _context, schema, value) {
15
- const regexp = G.IsString(schema.pattern) ? new RegExp(schema.pattern, 'u') : schema.pattern;
16
+ const regexp = G.IsString(schema.pattern) ? UnicodeRegExp(schema.pattern) : schema.pattern;
16
17
  return regexp.test(value);
17
18
  }
18
19
  // ------------------------------------------------------------------
@@ -1,6 +1,7 @@
1
1
  // deno-fmt-ignore-file
2
2
  import * as Externals from './_externals.mjs';
3
3
  import { Unique } from './_unique.mjs';
4
+ import { UnicodeRegExp } from './_regexp.mjs';
4
5
  import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
5
6
  import { BuildSchemaPushStack, CheckSchemaPushStack, ErrorSchemaPushStack } from './schema.mjs';
6
7
  // ------------------------------------------------------------------
@@ -9,7 +10,7 @@ import { BuildSchemaPushStack, CheckSchemaPushStack, ErrorSchemaPushStack } from
9
10
  export function BuildPatternProperties(stack, context, schema, value) {
10
11
  return E.ReduceAnd(G.Entries(schema.patternProperties).map(([pattern, schema]) => {
11
12
  const [key, prop] = [Unique(), Unique()];
12
- const regexp = Externals.CreateVariable(new RegExp(pattern, 'u'));
13
+ const regexp = Externals.CreateVariable(UnicodeRegExp(pattern));
13
14
  const notKey = E.Not(E.Call(E.Member(regexp, 'test'), [key]));
14
15
  const isSchema = BuildSchemaPushStack(stack, context, schema, prop);
15
16
  const addKey = context.AddKey(key);
@@ -22,7 +23,7 @@ export function BuildPatternProperties(stack, context, schema, value) {
22
23
  // ------------------------------------------------------------------
23
24
  export function CheckPatternProperties(stack, context, schema, value) {
24
25
  return G.Every(G.Entries(schema.patternProperties), 0, ([pattern, schema]) => {
25
- const regexp = new RegExp(pattern, 'u');
26
+ const regexp = UnicodeRegExp(pattern);
26
27
  return G.Every(G.Entries(value), 0, ([key, prop]) => {
27
28
  return !regexp.test(key) || CheckSchemaPushStack(stack, context, schema, prop) && context.AddKey(key);
28
29
  });
@@ -34,7 +35,7 @@ export function CheckPatternProperties(stack, context, schema, value) {
34
35
  export function ErrorPatternProperties(stack, context, schemaPath, instancePath, schema, value) {
35
36
  return G.EveryAll(G.Entries(schema.patternProperties), 0, ([pattern, schema]) => {
36
37
  const nextSchemaPath = `${schemaPath}/patternProperties/${pattern}`;
37
- const regexp = new RegExp(pattern, 'u');
38
+ const regexp = UnicodeRegExp(pattern);
38
39
  return G.EveryAll(G.Entries(value), 0, ([key, value]) => {
39
40
  const nextInstancePath = `${instancePath}/${key}`;
40
41
  const notKey = !regexp.test(key);
@@ -5,7 +5,7 @@ import { CheckContext, AccumulatedErrorContext } from './_context.mjs';
5
5
  import { EmitGuard as E } from '../../guard/index.mjs';
6
6
  import { CheckSchema, ErrorSchema } from './schema.mjs';
7
7
  // ------------------------------------------------------------------
8
- // BuildRefStandard
8
+ // BuildRef
9
9
  // ------------------------------------------------------------------
10
10
  function BuildRefStandard(stack, context, target, value) {
11
11
  const interior = E.ArrowFunction(['context', 'value'], Functions.CreateFunction(stack, context, target, 'value'));
@@ -17,15 +17,9 @@ function BuildRefStandard(stack, context, target, value) {
17
17
  ]));
18
18
  return E.Call(exterior, ['context', value]);
19
19
  }
20
- // ------------------------------------------------------------------
21
- // BuildRefStandard
22
- // ------------------------------------------------------------------
23
20
  function BuildRefFast(stack, context, target, value) {
24
21
  return Functions.CreateFunction(stack, context, target, value);
25
22
  }
26
- // ------------------------------------------------------------------
27
- // BuildRef
28
- // ------------------------------------------------------------------
29
23
  export function BuildRef(stack, context, schema, value) {
30
24
  const target = stack.Ref(schema) ?? false;
31
25
  return context.UseUnevaluated()
@@ -45,12 +45,21 @@ import { BuildUnevaluatedItems, CheckUnevaluatedItems, ErrorUnevaluatedItems } f
45
45
  import { BuildUnevaluatedProperties, CheckUnevaluatedProperties, ErrorUnevaluatedProperties } from './unevaluatedProperties.mjs';
46
46
  import { BuildUniqueItems, CheckUniqueItems, ErrorUniqueItems } from './uniqueItems.mjs';
47
47
  // ----------------------------------------------------------------
48
- // HasTypeName
48
+ // HasTypeName (Optimization)
49
+ //
50
+ // We only consider a schema as having a type name when the schema
51
+ // has a single type string, or when every element in the type
52
+ // array is the same. For a type array, we must treat multi-variant
53
+ // types as unions and therefore can NOT use an optimized forward
54
+ // type check.
55
+ //
49
56
  // ----------------------------------------------------------------
50
57
  function HasTypeName(schema, typename) {
51
- return Schema.IsType(schema) &&
52
- (G.IsArray(schema.type) && schema.type.includes(typename) ||
53
- G.IsEqual(schema.type, typename));
58
+ return (Schema.IsType(schema) &&
59
+ ((G.IsArray(schema.type) &&
60
+ G.IsGreaterThan(schema.type.length, 0) &&
61
+ G.Every(schema.type, 0, type => G.IsEqual(type, typename))) ||
62
+ G.IsEqual(schema.type, typename)));
54
63
  }
55
64
  // ----------------------------------------------------------------
56
65
  // HasObject
@@ -48,7 +48,7 @@ function BuildTypeNames(stack, context, typenames, value) {
48
48
  return E.ReduceOr(typenames.map(type => BuildTypeName(stack, context, type, value)));
49
49
  }
50
50
  function CheckTypeNames(stack, context, types, schema, value) {
51
- return types.some(type => CheckTypeName(stack, context, type, schema, value));
51
+ return G.Some(types, type => CheckTypeName(stack, context, type, schema, value));
52
52
  }
53
53
  // ------------------------------------------------------------------
54
54
  // Type
@@ -1 +1,4 @@
1
- export * from './ref.mjs';
1
+ import * as Schema from '../types/index.mjs';
2
+ export declare const DefaultBase: URL;
3
+ export declare function Ref(context: Record<string, Schema.XSchema>, schema: Schema.XSchemaObject, ref: string): Schema.XSchema | undefined;
4
+ export declare function DynamicRef(context: Record<string, Schema.XSchema>, root: Schema.XSchemaObject, base: Schema.XSchemaObject, dynamicRef: Schema.XDynamicRef, dynamicAnchors: Schema.XDynamicAnchor[]): Schema.XSchema | undefined;