@langchain/core 0.3.22 → 0.3.23

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 (64) hide show
  1. package/dist/callbacks/base.cjs +9 -1
  2. package/dist/callbacks/base.d.ts +1 -0
  3. package/dist/callbacks/base.js +7 -0
  4. package/dist/callbacks/manager.cjs +18 -0
  5. package/dist/callbacks/manager.js +19 -1
  6. package/dist/context.cjs +13 -123
  7. package/dist/context.d.ts +2 -101
  8. package/dist/context.js +9 -119
  9. package/dist/messages/tool.cjs +14 -1
  10. package/dist/messages/tool.d.ts +13 -1
  11. package/dist/messages/tool.js +12 -0
  12. package/dist/output_parsers/transform.cjs +2 -2
  13. package/dist/output_parsers/transform.js +1 -1
  14. package/dist/singletons/async_local_storage/context.cjs +189 -0
  15. package/dist/singletons/async_local_storage/context.d.ts +155 -0
  16. package/dist/singletons/async_local_storage/context.js +182 -0
  17. package/dist/singletons/async_local_storage/globals.cjs +2 -1
  18. package/dist/singletons/async_local_storage/globals.d.ts +2 -1
  19. package/dist/singletons/async_local_storage/globals.js +1 -0
  20. package/dist/singletons/async_local_storage/index.cjs +4 -5
  21. package/dist/singletons/async_local_storage/index.d.ts +0 -1
  22. package/dist/singletons/async_local_storage/index.js +1 -2
  23. package/dist/singletons/callbacks.cjs +6 -4
  24. package/dist/singletons/callbacks.js +6 -4
  25. package/dist/singletons/index.cjs +3 -3
  26. package/dist/singletons/index.d.ts +4 -2
  27. package/dist/singletons/index.js +4 -3
  28. package/dist/tools/index.cjs +12 -10
  29. package/dist/tools/index.d.ts +11 -8
  30. package/dist/tools/index.js +13 -11
  31. package/dist/utils/json_schema.cjs +3 -3
  32. package/dist/utils/json_schema.d.ts +1 -1
  33. package/dist/utils/json_schema.js +1 -1
  34. package/package.json +2 -1
  35. package/dist/utils/@cfworker/json-schema/index.cjs +0 -17
  36. package/dist/utils/@cfworker/json-schema/index.d.ts +0 -1
  37. package/dist/utils/@cfworker/json-schema/index.js +0 -1
  38. package/dist/utils/@cfworker/json-schema/src/deep-compare-strict.cjs +0 -43
  39. package/dist/utils/@cfworker/json-schema/src/deep-compare-strict.d.ts +0 -1
  40. package/dist/utils/@cfworker/json-schema/src/deep-compare-strict.js +0 -39
  41. package/dist/utils/@cfworker/json-schema/src/dereference.cjs +0 -171
  42. package/dist/utils/@cfworker/json-schema/src/dereference.d.ts +0 -12
  43. package/dist/utils/@cfworker/json-schema/src/dereference.js +0 -167
  44. package/dist/utils/@cfworker/json-schema/src/format.cjs +0 -139
  45. package/dist/utils/@cfworker/json-schema/src/format.d.ts +0 -2
  46. package/dist/utils/@cfworker/json-schema/src/format.js +0 -136
  47. package/dist/utils/@cfworker/json-schema/src/index.cjs +0 -24
  48. package/dist/utils/@cfworker/json-schema/src/index.d.ts +0 -8
  49. package/dist/utils/@cfworker/json-schema/src/index.js +0 -8
  50. package/dist/utils/@cfworker/json-schema/src/pointer.cjs +0 -11
  51. package/dist/utils/@cfworker/json-schema/src/pointer.d.ts +0 -2
  52. package/dist/utils/@cfworker/json-schema/src/pointer.js +0 -6
  53. package/dist/utils/@cfworker/json-schema/src/types.cjs +0 -2
  54. package/dist/utils/@cfworker/json-schema/src/types.d.ts +0 -72
  55. package/dist/utils/@cfworker/json-schema/src/types.js +0 -1
  56. package/dist/utils/@cfworker/json-schema/src/ucs2-length.cjs +0 -28
  57. package/dist/utils/@cfworker/json-schema/src/ucs2-length.d.ts +0 -6
  58. package/dist/utils/@cfworker/json-schema/src/ucs2-length.js +0 -24
  59. package/dist/utils/@cfworker/json-schema/src/validate.cjs +0 -808
  60. package/dist/utils/@cfworker/json-schema/src/validate.d.ts +0 -3
  61. package/dist/utils/@cfworker/json-schema/src/validate.js +0 -804
  62. package/dist/utils/@cfworker/json-schema/src/validator.cjs +0 -44
  63. package/dist/utils/@cfworker/json-schema/src/validator.d.ts +0 -10
  64. package/dist/utils/@cfworker/json-schema/src/validator.js +0 -40
@@ -1,167 +0,0 @@
1
- import { encodePointer } from "./pointer.js";
2
- export const schemaKeyword = {
3
- additionalItems: true,
4
- unevaluatedItems: true,
5
- items: true,
6
- contains: true,
7
- additionalProperties: true,
8
- unevaluatedProperties: true,
9
- propertyNames: true,
10
- not: true,
11
- if: true,
12
- then: true,
13
- else: true,
14
- };
15
- export const schemaArrayKeyword = {
16
- prefixItems: true,
17
- items: true,
18
- allOf: true,
19
- anyOf: true,
20
- oneOf: true,
21
- };
22
- export const schemaMapKeyword = {
23
- $defs: true,
24
- definitions: true,
25
- properties: true,
26
- patternProperties: true,
27
- dependentSchemas: true,
28
- };
29
- export const ignoredKeyword = {
30
- id: true,
31
- $id: true,
32
- $ref: true,
33
- $schema: true,
34
- $anchor: true,
35
- $vocabulary: true,
36
- $comment: true,
37
- default: true,
38
- enum: true,
39
- const: true,
40
- required: true,
41
- type: true,
42
- maximum: true,
43
- minimum: true,
44
- exclusiveMaximum: true,
45
- exclusiveMinimum: true,
46
- multipleOf: true,
47
- maxLength: true,
48
- minLength: true,
49
- pattern: true,
50
- format: true,
51
- maxItems: true,
52
- minItems: true,
53
- uniqueItems: true,
54
- maxProperties: true,
55
- minProperties: true,
56
- };
57
- /**
58
- * Default base URI for schemas without an $id.
59
- * https://json-schema.org/draft/2019-09/json-schema-core.html#initial-base
60
- * https://tools.ietf.org/html/rfc3986#section-5.1
61
- */
62
- export let initialBaseURI =
63
- // @ts-ignore
64
- typeof self !== "undefined" &&
65
- self.location &&
66
- self.location.origin !== "null"
67
- ? //@ts-ignore
68
- /* #__PURE__ */ new URL(self.location.origin + self.location.pathname + location.search)
69
- : /* #__PURE__ */ new URL("https://github.com/cfworker");
70
- export function dereference(schema, lookup = Object.create(null), baseURI = initialBaseURI, basePointer = "") {
71
- if (schema && typeof schema === "object" && !Array.isArray(schema)) {
72
- const id = schema.$id || schema.id;
73
- if (id) {
74
- const url = new URL(id, baseURI.href);
75
- if (url.hash.length > 1) {
76
- lookup[url.href] = schema;
77
- }
78
- else {
79
- url.hash = ""; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
80
- if (basePointer === "") {
81
- baseURI = url;
82
- }
83
- else {
84
- dereference(schema, lookup, baseURI);
85
- }
86
- }
87
- }
88
- }
89
- else if (schema !== true && schema !== false) {
90
- return lookup;
91
- }
92
- // compute the schema's URI and add it to the mapping.
93
- const schemaURI = baseURI.href + (basePointer ? "#" + basePointer : "");
94
- if (lookup[schemaURI] !== undefined) {
95
- throw new Error(`Duplicate schema URI "${schemaURI}".`);
96
- }
97
- lookup[schemaURI] = schema;
98
- // exit early if this is a boolean schema.
99
- if (schema === true || schema === false) {
100
- return lookup;
101
- }
102
- // set the schema's absolute URI.
103
- if (schema.__absolute_uri__ === undefined) {
104
- Object.defineProperty(schema, "__absolute_uri__", {
105
- enumerable: false,
106
- value: schemaURI,
107
- });
108
- }
109
- // if a $ref is found, resolve it's absolute URI.
110
- if (schema.$ref && schema.__absolute_ref__ === undefined) {
111
- const url = new URL(schema.$ref, baseURI.href);
112
- url.hash = url.hash; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
113
- Object.defineProperty(schema, "__absolute_ref__", {
114
- enumerable: false,
115
- value: url.href,
116
- });
117
- }
118
- // if a $recursiveRef is found, resolve it's absolute URI.
119
- if (schema.$recursiveRef && schema.__absolute_recursive_ref__ === undefined) {
120
- const url = new URL(schema.$recursiveRef, baseURI.href);
121
- url.hash = url.hash; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
122
- Object.defineProperty(schema, "__absolute_recursive_ref__", {
123
- enumerable: false,
124
- value: url.href,
125
- });
126
- }
127
- // if an $anchor is found, compute it's URI and add it to the mapping.
128
- if (schema.$anchor) {
129
- const url = new URL("#" + schema.$anchor, baseURI.href);
130
- lookup[url.href] = schema;
131
- }
132
- // process subschemas.
133
- for (let key in schema) {
134
- if (ignoredKeyword[key]) {
135
- continue;
136
- }
137
- const keyBase = `${basePointer}/${encodePointer(key)}`;
138
- const subSchema = schema[key];
139
- if (Array.isArray(subSchema)) {
140
- if (schemaArrayKeyword[key]) {
141
- const length = subSchema.length;
142
- for (let i = 0; i < length; i++) {
143
- dereference(subSchema[i], lookup, baseURI, `${keyBase}/${i}`);
144
- }
145
- }
146
- }
147
- else if (schemaMapKeyword[key]) {
148
- for (let subKey in subSchema) {
149
- dereference(subSchema[subKey], lookup, baseURI, `${keyBase}/${encodePointer(subKey)}`);
150
- }
151
- }
152
- else {
153
- dereference(subSchema, lookup, baseURI, keyBase);
154
- }
155
- }
156
- return lookup;
157
- }
158
- // schema identification examples
159
- // https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.appendix.A
160
- // $ref delegation
161
- // https://github.com/json-schema-org/json-schema-spec/issues/514
162
- // output format
163
- // https://json-schema.org/draft/2019-09/json-schema-core.html#output
164
- // JSON pointer
165
- // https://tools.ietf.org/html/rfc6901
166
- // JSON relative pointer
167
- // https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01
@@ -1,139 +0,0 @@
1
- "use strict";
2
- // based on https://github.com/epoberezkin/ajv/blob/master/lib/compile/formats.js
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.fastFormat = exports.fullFormat = void 0;
5
- const DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
6
- const DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
7
- const TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
8
- const HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
9
- // const URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?: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6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
11
- // uri-template: https://tools.ietf.org/html/rfc6570
12
- const URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
13
- // For the source: https://gist.github.com/dperini/729294
14
- // For test cases: https://mathiasbynens.be/demo/url-regex
15
- const URL_ = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
16
- const UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
17
- const JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
18
- const JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
19
- const RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
20
- // date: http://tools.ietf.org/html/rfc3339#section-5.6
21
- const FASTDATE = /^\d\d\d\d-[0-1]\d-[0-3]\d$/;
22
- // date-time: http://tools.ietf.org/html/rfc3339#section-5.6
23
- const FASTTIME = /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i;
24
- const FASTDATETIME = /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i;
25
- // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
26
- // const FASTURI = /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i;
27
- const FASTURIREFERENCE = /^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i;
28
- // https://github.com/ExodusMovement/schemasafe/blob/master/src/formats.js
29
- const EMAIL = (input) => {
30
- if (input[0] === '"')
31
- return false;
32
- const [name, host, ...rest] = input.split("@");
33
- if (!name ||
34
- !host ||
35
- rest.length !== 0 ||
36
- name.length > 64 ||
37
- host.length > 253)
38
- return false;
39
- if (name[0] === "." || name.endsWith(".") || name.includes(".."))
40
- return false;
41
- if (!/^[a-z0-9.-]+$/i.test(host) ||
42
- !/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(name))
43
- return false;
44
- return host
45
- .split(".")
46
- .every((part) => /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(part));
47
- };
48
- // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
49
- const IPV4 = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/;
50
- // optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
51
- const IPV6 = /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i;
52
- // https://github.com/ExodusMovement/schemasafe/blob/master/src/formats.js
53
- const DURATION = (input) => input.length > 1 &&
54
- input.length < 80 &&
55
- (/^P\d+([.,]\d+)?W$/.test(input) ||
56
- (/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(input) &&
57
- /^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(input)));
58
- function bind(r) {
59
- return r.test.bind(r);
60
- }
61
- exports.fullFormat = {
62
- date,
63
- time: /* #__PURE__ */ time.bind(undefined, false),
64
- "date-time": date_time,
65
- duration: DURATION,
66
- uri,
67
- "uri-reference": /* #__PURE__ */ bind(URIREF),
68
- "uri-template": /* #__PURE__ */ bind(URITEMPLATE),
69
- url: /* #__PURE__ */ bind(URL_),
70
- email: EMAIL,
71
- hostname: /* #__PURE__ */ bind(HOSTNAME),
72
- ipv4: /* #__PURE__ */ bind(IPV4),
73
- ipv6: /* #__PURE__ */ bind(IPV6),
74
- regex: regex,
75
- uuid: /* #__PURE__ */ bind(UUID),
76
- "json-pointer": /* #__PURE__ */ bind(JSON_POINTER),
77
- "json-pointer-uri-fragment": /* #__PURE__ */ bind(JSON_POINTER_URI_FRAGMENT),
78
- "relative-json-pointer": /* #__PURE__ */ bind(RELATIVE_JSON_POINTER),
79
- };
80
- exports.fastFormat = {
81
- ...exports.fullFormat,
82
- date: /* #__PURE__ */ bind(FASTDATE),
83
- time: /* #__PURE__ */ bind(FASTTIME),
84
- "date-time": /* #__PURE__ */ bind(FASTDATETIME),
85
- "uri-reference": /* #__PURE__ */ bind(FASTURIREFERENCE),
86
- };
87
- function isLeapYear(year) {
88
- // https://tools.ietf.org/html/rfc3339#appendix-C
89
- return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
90
- }
91
- function date(str) {
92
- // full-date from http://tools.ietf.org/html/rfc3339#section-5.6
93
- const matches = str.match(DATE);
94
- if (!matches)
95
- return false;
96
- const year = +matches[1];
97
- const month = +matches[2];
98
- const day = +matches[3];
99
- return (month >= 1 &&
100
- month <= 12 &&
101
- day >= 1 &&
102
- day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]));
103
- }
104
- function time(full, str) {
105
- const matches = str.match(TIME);
106
- if (!matches)
107
- return false;
108
- const hour = +matches[1];
109
- const minute = +matches[2];
110
- const second = +matches[3];
111
- const timeZone = !!matches[5];
112
- return (((hour <= 23 && minute <= 59 && second <= 59) ||
113
- (hour == 23 && minute == 59 && second == 60)) &&
114
- (!full || timeZone));
115
- }
116
- const DATE_TIME_SEPARATOR = /t|\s/i;
117
- function date_time(str) {
118
- // http://tools.ietf.org/html/rfc3339#section-5.6
119
- const dateTime = str.split(DATE_TIME_SEPARATOR);
120
- return dateTime.length == 2 && date(dateTime[0]) && time(true, dateTime[1]);
121
- }
122
- const NOT_URI_FRAGMENT = /\/|:/;
123
- const URI_PATTERN = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
124
- function uri(str) {
125
- // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
126
- return NOT_URI_FRAGMENT.test(str) && URI_PATTERN.test(str);
127
- }
128
- const Z_ANCHOR = /[^\\]\\Z/;
129
- function regex(str) {
130
- if (Z_ANCHOR.test(str))
131
- return false;
132
- try {
133
- new RegExp(str);
134
- return true;
135
- }
136
- catch (e) {
137
- return false;
138
- }
139
- }
@@ -1,2 +0,0 @@
1
- export declare const fullFormat: Record<string, (s: string) => boolean>;
2
- export declare const fastFormat: Record<string, (s: string) => boolean>;
@@ -1,136 +0,0 @@
1
- // based on https://github.com/epoberezkin/ajv/blob/master/lib/compile/formats.js
2
- const DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
3
- const DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
4
- const TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
5
- const HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
6
- // const URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a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:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
8
- // uri-template: https://tools.ietf.org/html/rfc6570
9
- const URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
10
- // For the source: https://gist.github.com/dperini/729294
11
- // For test cases: https://mathiasbynens.be/demo/url-regex
12
- const URL_ = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
13
- const UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
14
- const JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
15
- const JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
16
- const RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
17
- // date: http://tools.ietf.org/html/rfc3339#section-5.6
18
- const FASTDATE = /^\d\d\d\d-[0-1]\d-[0-3]\d$/;
19
- // date-time: http://tools.ietf.org/html/rfc3339#section-5.6
20
- const FASTTIME = /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i;
21
- const FASTDATETIME = /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i;
22
- // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
23
- // const FASTURI = /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i;
24
- const FASTURIREFERENCE = /^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i;
25
- // https://github.com/ExodusMovement/schemasafe/blob/master/src/formats.js
26
- const EMAIL = (input) => {
27
- if (input[0] === '"')
28
- return false;
29
- const [name, host, ...rest] = input.split("@");
30
- if (!name ||
31
- !host ||
32
- rest.length !== 0 ||
33
- name.length > 64 ||
34
- host.length > 253)
35
- return false;
36
- if (name[0] === "." || name.endsWith(".") || name.includes(".."))
37
- return false;
38
- if (!/^[a-z0-9.-]+$/i.test(host) ||
39
- !/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(name))
40
- return false;
41
- return host
42
- .split(".")
43
- .every((part) => /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(part));
44
- };
45
- // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
46
- const IPV4 = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/;
47
- // optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
48
- const IPV6 = /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i;
49
- // https://github.com/ExodusMovement/schemasafe/blob/master/src/formats.js
50
- const DURATION = (input) => input.length > 1 &&
51
- input.length < 80 &&
52
- (/^P\d+([.,]\d+)?W$/.test(input) ||
53
- (/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(input) &&
54
- /^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(input)));
55
- function bind(r) {
56
- return r.test.bind(r);
57
- }
58
- export const fullFormat = {
59
- date,
60
- time: /* #__PURE__ */ time.bind(undefined, false),
61
- "date-time": date_time,
62
- duration: DURATION,
63
- uri,
64
- "uri-reference": /* #__PURE__ */ bind(URIREF),
65
- "uri-template": /* #__PURE__ */ bind(URITEMPLATE),
66
- url: /* #__PURE__ */ bind(URL_),
67
- email: EMAIL,
68
- hostname: /* #__PURE__ */ bind(HOSTNAME),
69
- ipv4: /* #__PURE__ */ bind(IPV4),
70
- ipv6: /* #__PURE__ */ bind(IPV6),
71
- regex: regex,
72
- uuid: /* #__PURE__ */ bind(UUID),
73
- "json-pointer": /* #__PURE__ */ bind(JSON_POINTER),
74
- "json-pointer-uri-fragment": /* #__PURE__ */ bind(JSON_POINTER_URI_FRAGMENT),
75
- "relative-json-pointer": /* #__PURE__ */ bind(RELATIVE_JSON_POINTER),
76
- };
77
- export const fastFormat = {
78
- ...fullFormat,
79
- date: /* #__PURE__ */ bind(FASTDATE),
80
- time: /* #__PURE__ */ bind(FASTTIME),
81
- "date-time": /* #__PURE__ */ bind(FASTDATETIME),
82
- "uri-reference": /* #__PURE__ */ bind(FASTURIREFERENCE),
83
- };
84
- function isLeapYear(year) {
85
- // https://tools.ietf.org/html/rfc3339#appendix-C
86
- return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
87
- }
88
- function date(str) {
89
- // full-date from http://tools.ietf.org/html/rfc3339#section-5.6
90
- const matches = str.match(DATE);
91
- if (!matches)
92
- return false;
93
- const year = +matches[1];
94
- const month = +matches[2];
95
- const day = +matches[3];
96
- return (month >= 1 &&
97
- month <= 12 &&
98
- day >= 1 &&
99
- day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]));
100
- }
101
- function time(full, str) {
102
- const matches = str.match(TIME);
103
- if (!matches)
104
- return false;
105
- const hour = +matches[1];
106
- const minute = +matches[2];
107
- const second = +matches[3];
108
- const timeZone = !!matches[5];
109
- return (((hour <= 23 && minute <= 59 && second <= 59) ||
110
- (hour == 23 && minute == 59 && second == 60)) &&
111
- (!full || timeZone));
112
- }
113
- const DATE_TIME_SEPARATOR = /t|\s/i;
114
- function date_time(str) {
115
- // http://tools.ietf.org/html/rfc3339#section-5.6
116
- const dateTime = str.split(DATE_TIME_SEPARATOR);
117
- return dateTime.length == 2 && date(dateTime[0]) && time(true, dateTime[1]);
118
- }
119
- const NOT_URI_FRAGMENT = /\/|:/;
120
- const URI_PATTERN = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
121
- function uri(str) {
122
- // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
123
- return NOT_URI_FRAGMENT.test(str) && URI_PATTERN.test(str);
124
- }
125
- const Z_ANCHOR = /[^\\]\\Z/;
126
- function regex(str) {
127
- if (Z_ANCHOR.test(str))
128
- return false;
129
- try {
130
- new RegExp(str);
131
- return true;
132
- }
133
- catch (e) {
134
- return false;
135
- }
136
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./deep-compare-strict.cjs"), exports);
18
- __exportStar(require("./dereference.cjs"), exports);
19
- __exportStar(require("./format.cjs"), exports);
20
- __exportStar(require("./pointer.cjs"), exports);
21
- __exportStar(require("./types.cjs"), exports);
22
- __exportStar(require("./ucs2-length.cjs"), exports);
23
- __exportStar(require("./validate.cjs"), exports);
24
- __exportStar(require("./validator.cjs"), exports);
@@ -1,8 +0,0 @@
1
- export * from "./deep-compare-strict.js";
2
- export * from "./dereference.js";
3
- export * from "./format.js";
4
- export * from "./pointer.js";
5
- export * from "./types.js";
6
- export * from "./ucs2-length.js";
7
- export * from "./validate.js";
8
- export * from "./validator.js";
@@ -1,8 +0,0 @@
1
- export * from "./deep-compare-strict.js";
2
- export * from "./dereference.js";
3
- export * from "./format.js";
4
- export * from "./pointer.js";
5
- export * from "./types.js";
6
- export * from "./ucs2-length.js";
7
- export * from "./validate.js";
8
- export * from "./validator.js";
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.escapePointer = exports.encodePointer = void 0;
4
- function encodePointer(p) {
5
- return encodeURI(escapePointer(p));
6
- }
7
- exports.encodePointer = encodePointer;
8
- function escapePointer(p) {
9
- return p.replace(/~/g, "~0").replace(/\//g, "~1");
10
- }
11
- exports.escapePointer = escapePointer;
@@ -1,2 +0,0 @@
1
- export declare function encodePointer(p: string): string;
2
- export declare function escapePointer(p: string): string;
@@ -1,6 +0,0 @@
1
- export function encodePointer(p) {
2
- return encodeURI(escapePointer(p));
3
- }
4
- export function escapePointer(p) {
5
- return p.replace(/~/g, "~0").replace(/\//g, "~1");
6
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,72 +0,0 @@
1
- export type SchemaDraft = "4" | "7" | "2019-09" | "2020-12";
2
- export declare const enum OutputFormat {
3
- Flag = 1,
4
- Basic = 2,
5
- Detailed = 4
6
- }
7
- export type InstanceType = "array" | "boolean" | "integer" | "null" | "number" | "object" | "string";
8
- export interface Schema {
9
- $id?: string;
10
- $anchor?: string;
11
- $recursiveAnchor?: boolean;
12
- $ref?: string;
13
- $recursiveRef?: "#";
14
- $schema?: string;
15
- $comment?: string;
16
- $defs?: any;
17
- $vocabulary?: Record<string, boolean>;
18
- type?: InstanceType | InstanceType[];
19
- const?: any;
20
- enum?: any[];
21
- required?: string[];
22
- not?: Schema;
23
- anyOf?: Schema[];
24
- allOf?: Schema[];
25
- oneOf?: Schema[];
26
- if?: Schema;
27
- then?: Schema;
28
- else?: Schema;
29
- format?: string;
30
- properties?: Record<string | number, Schema | boolean>;
31
- patternProperties?: Record<string, Schema | boolean>;
32
- additionalProperties?: Schema | boolean;
33
- unevaluatedProperties?: Schema | boolean;
34
- minProperties?: number;
35
- maxProperties?: number;
36
- propertyNames?: Schema;
37
- dependentRequired?: Record<string, string[]>;
38
- dependentSchemas?: Record<string, Schema>;
39
- dependencies?: Record<string, Schema | string[]>;
40
- prefixItems?: Array<Schema | boolean>[];
41
- items?: Schema | boolean | Array<Schema | boolean>;
42
- additionalItems?: Schema | boolean;
43
- unevaluatedItems?: Schema | boolean;
44
- contains?: Schema | boolean;
45
- minContains?: number;
46
- maxContains?: number;
47
- minItems?: number;
48
- maxItems?: number;
49
- uniqueItems?: boolean;
50
- minimum?: number;
51
- maximum?: number;
52
- exclusiveMinimum?: number | boolean;
53
- exclusiveMaximum?: number | boolean;
54
- multipleOf?: number;
55
- minLength?: number;
56
- maxLength?: number;
57
- pattern?: string;
58
- __absolute_ref__?: string;
59
- __absolute_recursive_ref__?: string;
60
- __absolute_uri__?: string;
61
- [key: string]: any;
62
- }
63
- export interface OutputUnit {
64
- keyword: string;
65
- keywordLocation: string;
66
- instanceLocation: string;
67
- error: string;
68
- }
69
- export interface ValidationResult {
70
- valid: boolean;
71
- errors: OutputUnit[];
72
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ucs2length = void 0;
4
- /**
5
- * Get UCS-2 length of a string
6
- * https://mathiasbynens.be/notes/javascript-encoding
7
- * https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
8
- */
9
- function ucs2length(s) {
10
- let result = 0;
11
- let length = s.length;
12
- let index = 0;
13
- let charCode;
14
- while (index < length) {
15
- result++;
16
- charCode = s.charCodeAt(index++);
17
- if (charCode >= 0xd800 && charCode <= 0xdbff && index < length) {
18
- // high surrogate, and there is a next character
19
- charCode = s.charCodeAt(index);
20
- if ((charCode & 0xfc00) == 0xdc00) {
21
- // low surrogate
22
- index++;
23
- }
24
- }
25
- }
26
- return result;
27
- }
28
- exports.ucs2length = ucs2length;
@@ -1,6 +0,0 @@
1
- /**
2
- * Get UCS-2 length of a string
3
- * https://mathiasbynens.be/notes/javascript-encoding
4
- * https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
5
- */
6
- export declare function ucs2length(s: string): number;