arktype 2.1.27 → 2.1.28

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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  ArkType is a runtime validation library that parses optimized validators from familiar, type-safe syntax.
5
5
 
6
- It can be used to check external data like JSON payloads or forms at the boundaries of your code (similar to Zod or Yup).
6
+ It can be used to check external data like JSON payloads or forms at the boundaries of your code (similar to Zod).
7
7
 
8
8
  <video
9
9
  autoPlay
package/out/declare.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import type { anyOrNever, array, defined, equals, ErrorMessage, ErrorType, optionalKeyOf, requiredKeyOf, show, unset } from "@ark/util";
1
+ import type { anyOrNever, array, equals, ErrorMessage, ErrorType, optionalKeyOf, requiredKeyOf, show, unset } from "@ark/util";
2
2
  import type { distill } from "./attributes.ts";
3
3
  import type { type } from "./keywords/keywords.ts";
4
- import type { inferDefinition, ThunkCast } from "./parser/definition.ts";
4
+ import type { inferDefinition, TerminalObjectDefinition, ThunkCast } from "./parser/definition.ts";
5
+ import type { OptionalPropertyDefinition } from "./parser/property.ts";
5
6
  import type { TupleExpression } from "./parser/tupleExpressions.ts";
6
7
  import type { bindThis } from "./scope.ts";
7
8
  import type { Type } from "./type.ts";
@@ -15,13 +16,17 @@ export type DeclareContext = {
15
16
  side?: "in" | "out";
16
17
  };
17
18
  export type validateDeclared<declared, def, $, ctx extends DeclareContext> = def extends type.validate<def, $> ? validateInference<def, declared, $, bindThis<def>, ctx> : type.validate<def, $>;
18
- type validateInference<def, declared, $, args, ctx extends DeclareContext> = def extends RegExp | type.cast<unknown> | ThunkCast | TupleExpression ? validateShallowInference<inferDefinition<def, $, args>, declared, ctx> : def extends array ? declared extends array ? {
19
+ type validateInference<def, declared, $, args, ctx extends DeclareContext> = def extends TerminalObjectDefinition | ThunkCast | TupleExpression ? keyof def extends never ? validateObjectInference<def, declared, $, args, ctx> : validateShallowInference<inferDefinition<def, $, args>, declared, ctx> : def extends array ? validateArrayInference<def, declared, $, args, ctx> : def extends object ? validateObjectInference<def, declared, $, args, ctx> : validateShallowInference<inferDefinition<def, $, args>, declared, ctx>;
20
+ type validateArrayInference<def extends array, declared, $, args, ctx extends DeclareContext> = declared extends array ? {
19
21
  [i in keyof declared]: i extends keyof def ? validateInference<def[i], declared[i], $, args, ctx> : declared[i];
20
- } : show<declarationMismatch<inferDefinition<def, $, args>, declared>> : def extends object ? show<{
22
+ } : show<declarationMismatch<inferDefinition<def, $, args>, declared>>;
23
+ type validateObjectInference<def extends object, declared, $, args, ctx extends DeclareContext> = show<{
21
24
  [k in requiredKeyOf<declared>]: k extends keyof def ? validateInference<def[k], declared[k], $, args, ctx> : declared[k];
22
25
  } & {
23
- [k in optionalKeyOf<declared> & string as `${k}?`]: `${k}?` extends (keyof def) ? validateInference<def[`${k}?`], defined<declared[k]>, $, args, ctx> : declared[k];
24
- }> : validateShallowInference<inferDefinition<def, $, args>, declared, ctx>;
26
+ [k in optionalKeyOf<declared> & string as declaredOptionalKeySuggestion<k, def>]: declaredOptionalValueSuggestion<def, k, declared, $, args, ctx>;
27
+ }>;
28
+ type declaredOptionalKeySuggestion<k extends string, def> = k extends keyof def ? def[k] extends OptionalPropertyDefinition ? k : `${k}?` : `${k}?`;
29
+ type declaredOptionalValueSuggestion<def, k extends keyof declared & string, declared, $, args, ctx extends DeclareContext> = k extends keyof def ? def[k] extends OptionalPropertyDefinition ? validateInference<def[k], Required<declared>[k], $, args, ctx> : declared[k] : `${k}?` extends keyof def ? validateInference<def[`${k}?`], Required<declared>[k], $, args, ctx> : declared[k];
25
30
  type validateShallowInference<t, declared, ctx extends DeclareContext, inferred = ctx["side"] extends distill.Side ? distill<t, ctx["side"]> : t> = equals<inferred, declared> extends true ? unknown : show<declarationMismatch<inferred, declared>>;
26
31
  type declarationMismatch<inferred, declared> = ErrorType<{
27
32
  declared: declared;
package/out/fn.d.ts CHANGED
@@ -6,10 +6,10 @@ import type { validateInnerDefinition } from "./parser/definition.ts";
6
6
  import type { inferTupleLiteral, validateTupleLiteral } from "./parser/tupleLiteral.ts";
7
7
  import type { InternalScope, Scope } from "./scope.ts";
8
8
  import type { Type } from "./type.ts";
9
- export interface FnParser<$ = {}> {
10
- <const args extends readonly unknown[], paramsT extends readonly unknown[] = inferTupleLiteral<args extends readonly [...infer params, ":", unknown] ? params : args, $, {}>, returnT = args extends readonly [...unknown[], ":", infer returnDef] ? type.infer<returnDef, $> : unknown>(...args: {
11
- [i in keyof args]: conform<args[i], get<validateFnArgs<args, $>, i>>;
12
- }): <internalSignature extends (...args: distill.Out<paramsT>) => distill.In<returnT>, externalSignature extends Fn = (...args: applyElementLabels<distill.In<paramsT>, Parameters<internalSignature>>) => args extends readonly [...unknown[], ":", unknown] ? distill.Out<returnT> : ReturnType<internalSignature>>(implementation: internalSignature) => TypedFn<externalSignature, $, args extends readonly [...unknown[], ":", unknown] ? Return.introspectable : {}>;
9
+ export type BaseFnParser<$ = {}> = <const args extends readonly unknown[], paramsT extends readonly unknown[] = inferTupleLiteral<args extends readonly [...infer params, ":", unknown] ? params : args, $, {}>, returnT = args extends readonly [...unknown[], ":", infer returnDef] ? type.infer<returnDef, $> : unknown>(...args: {
10
+ [i in keyof args]: conform<args[i], get<validateFnArgs<args, $>, i>>;
11
+ }) => <internalSignature extends (...args: distill.Out<paramsT>) => distill.In<returnT>, externalSignature extends Fn = (...args: applyElementLabels<distill.In<paramsT>, Parameters<internalSignature>>) => args extends readonly [...unknown[], ":", unknown] ? distill.Out<returnT> : ReturnType<internalSignature>>(implementation: internalSignature) => TypedFn<externalSignature, $, args extends readonly [...unknown[], ":", unknown] ? Return.introspectable : {}>;
12
+ export interface FnParser<$ = {}> extends BaseFnParser<$> {
13
13
  /**
14
14
  * The {@link Scope} in which definitions passed to this function will be parsed.
15
15
  */
package/out/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export { ArkError, ArkErrors, Traversal, TraversalError, type ArkSchemaConfig, type ArkSchemaScopeConfig, type JsonSchema } from "@ark/schema";
2
- export { Hkt, ParseError, inferred } from "@ark/util";
2
+ export { Hkt, inferred, ParseError } from "@ark/util";
3
3
  export { regex } from "arkregex";
4
- export type { Out, distill } from "./attributes.ts";
4
+ export type { distill, Out } from "./attributes.ts";
5
5
  export * from "./config.ts";
6
6
  export { Generic } from "./generic.ts";
7
- export { ark, declare, define, generic, keywords, match, type, type Ark } from "./keywords/keywords.ts";
7
+ export { ark, declare, define, fn, generic, keywords, match, type, type Ark } from "./keywords/keywords.ts";
8
8
  export { Module, type BoundModule, type Submodule } from "./module.ts";
9
9
  export type { inferDefinition, validateDefinition } from "./parser/definition.ts";
10
- export { scope, type Scope, type bindThis } from "./scope.ts";
10
+ export { scope, type bindThis, type Scope } from "./scope.ts";
11
11
  export { Type } from "./type.ts";
12
12
  export type { BaseType } from "./variants/base.ts";
package/out/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export { ArkError, ArkErrors, Traversal, TraversalError } from "@ark/schema";
2
- export { Hkt, ParseError, inferred } from "@ark/util";
2
+ export { Hkt, inferred, ParseError } from "@ark/util";
3
3
  export { regex } from "arkregex";
4
4
  export * from "./config.js";
5
5
  export { Generic } from "./generic.js";
6
- export { ark, declare, define, generic, keywords, match, type } from "./keywords/keywords.js";
6
+ export { ark, declare, define, fn, generic, keywords, match, type } from "./keywords/keywords.js";
7
7
  export { Module } from "./module.js";
8
8
  export { scope } from "./scope.js";
9
9
  export { Type } from "./type.js";
@@ -1,5 +1,6 @@
1
- import { type BaseParseContext, type BaseRoot } from "@ark/schema";
1
+ import { type BaseParseContext, type BaseRoot, type StandardSchemaV1 } from "@ark/schema";
2
2
  import { type anyOrNever, type array, type ErrorMessage, type Fn, type ifEmptyObjectLiteral, type objectKindOrDomainOf, type Primitive } from "@ark/util";
3
+ import type { Out } from "../attributes.ts";
3
4
  import type { type } from "../keywords/keywords.ts";
4
5
  import type { InnerParseResult } from "../scope.ts";
5
6
  import type { shallowDefaultableMessage, shallowOptionalMessage, validateString } from "./ast/validate.ts";
@@ -12,15 +13,16 @@ export declare const parseInnerDefinition: (def: unknown, ctx: BaseParseContext)
12
13
  export declare const parseObject: (def: object, ctx: BaseParseContext) => BaseRoot;
13
14
  export type inferDefinition<def, $, args> = [
14
15
  def
15
- ] extends [anyOrNever] ? def : def extends type.cast<infer t> ? ifEmptyObjectLiteral<def, object, t> : def extends ThunkCast<infer t> ? t : def extends string ? inferString<def, $, args> : def extends array ? inferTuple<def, $, args> : def extends RegExp ? string : def extends object ? inferObjectLiteral<def, $, args> : never;
16
+ ] extends [anyOrNever] ? def : def extends type.cast<infer t> ? ifEmptyObjectLiteral<def, object, t> : def extends ThunkCast<infer t> ? t : def extends string ? inferString<def, $, args> : def extends array ? inferTuple<def, $, args> : def extends RegExp ? string : def extends StandardSchemaV1 ? inferStandardSchema<def> : def extends object ? inferObjectLiteral<def, $, args> : never;
17
+ type inferStandardSchema<schema extends StandardSchemaV1, i = StandardSchemaV1.InferInput<schema>, o = StandardSchemaV1.InferOutput<schema>> = [i, o] extends [o, i] ? i : (In: i) => Out<o>;
16
18
  export type validateDefinition<def, $, args> = null extends undefined ? ErrorMessage<`'strict' or 'strictNullChecks' must be set to true in your tsconfig's 'compilerOptions'`> : [def] extends [anyOrNever] ? def : def extends OptionalPropertyDefinition ? ErrorMessage<shallowOptionalMessage> : isDefaultable<def, $, args> extends true ? ErrorMessage<shallowDefaultableMessage> : validateInnerDefinition<def, $, args>;
17
19
  export type validateInnerDefinition<def, $, args> = [
18
20
  def
19
- ] extends [Terminal] ? def : def extends string ? validateString<def, $, args> : unknown extends def ? BaseCompletions<$, args> | {} : def extends readonly unknown[] ? validateTuple<def, $, args> : def extends BadDefinitionType ? ErrorMessage<writeBadDefinitionTypeMessage<objectKindOrDomainOf<def>>> : validateObjectLiteral<def, $, args>;
21
+ ] extends [TerminalObjectDefinition] ? def : def extends string ? validateString<def, $, args> : unknown extends def ? BaseCompletions<$, args> | {} : def extends readonly unknown[] ? validateTuple<def, $, args> : def extends BadDefinitionType ? ErrorMessage<writeBadDefinitionTypeMessage<objectKindOrDomainOf<def>>> : validateObjectLiteral<def, $, args>;
20
22
  export declare const parseTuple: (def: array, ctx: BaseParseContext) => BaseRoot;
21
23
  export type validateTuple<def extends array, $, args> = maybeValidateTupleExpression<def, $, args> extends infer result ? result extends null ? validateTupleLiteral<def, $, args> : result : never;
22
24
  export type inferTuple<def extends array, $, args> = def extends TupleExpression ? inferTupleExpression<def, $, args> : inferTupleLiteral<def, $, args>;
23
- type Terminal = type.cast<unknown> | Fn | RegExp;
25
+ export type TerminalObjectDefinition = type.cast<unknown> | Fn | RegExp | StandardSchemaV1;
24
26
  export type ThunkCast<t = unknown> = () => type.cast<t>;
25
27
  type BadDefinitionType = Exclude<Primitive, string>;
26
28
  export declare const writeBadDefinitionTypeMessage: <actual extends string>(actual: actual) => writeBadDefinitionTypeMessage<actual>;
@@ -1,5 +1,5 @@
1
1
  import { hasArkKind } from "@ark/schema";
2
- import { domainOf, hasDomain, isThunk, objectKindOf, printable, throwParseError } from "@ark/util";
2
+ import { domainOf, hasDomain, isThunk, objectKindOf, printable, throwParseError, uncapitalize } from "@ark/util";
3
3
  import { parseObjectLiteral } from "./objectLiteral.js";
4
4
  import { parseString } from "./string.js";
5
5
  import { maybeParseTupleExpression } from "./tupleExpressions.js";
@@ -25,6 +25,8 @@ export const parseObject = (def, ctx) => {
25
25
  case undefined:
26
26
  if (hasArkKind(def, "root"))
27
27
  return def;
28
+ if ("~standard" in def)
29
+ return parseStandardSchema(def, ctx);
28
30
  return parseObjectLiteral(def, ctx);
29
31
  case "Array":
30
32
  return parseTuple(def, ctx);
@@ -43,5 +45,30 @@ export const parseObject = (def, ctx) => {
43
45
  return throwParseError(writeBadDefinitionTypeMessage(objectKind ?? printable(def)));
44
46
  }
45
47
  };
48
+ const parseStandardSchema = (def, ctx) => ctx.$.intrinsic.unknown.pipe((v, ctx) => {
49
+ const result = def["~standard"].validate(v);
50
+ if (!result.issues)
51
+ return result.value;
52
+ for (const { message, path } of result.issues) {
53
+ if (path) {
54
+ if (path.length) {
55
+ ctx.error({
56
+ problem: uncapitalize(message),
57
+ relativePath: path.map(k => (typeof k === "object" ? k.key : k))
58
+ });
59
+ }
60
+ else {
61
+ ctx.error({
62
+ message
63
+ });
64
+ }
65
+ }
66
+ else {
67
+ ctx.error({
68
+ message
69
+ });
70
+ }
71
+ }
72
+ });
46
73
  export const parseTuple = (def, ctx) => maybeParseTupleExpression(def, ctx) ?? parseTupleLiteral(def, ctx);
47
74
  export const writeBadDefinitionTypeMessage = (actual) => `Type definitions must be strings or objects (was ${actual})`;
@@ -37,6 +37,6 @@ export declare class RuntimeState {
37
37
  private assertRangeUnset;
38
38
  reduceGroupOpen(): void;
39
39
  previousOperator(): MinComparator | StringifiablePrefixOperator | InfixToken | undefined;
40
- shiftedByOne(): this;
40
+ shiftedBy(count: number): this;
41
41
  }
42
42
  export {};
@@ -146,8 +146,8 @@ export class RuntimeState {
146
146
  : this.branches.pipe ? "|>"
147
147
  : undefined));
148
148
  }
149
- shiftedByOne() {
150
- this.scanner.shift();
149
+ shiftedBy(count) {
150
+ this.scanner.jumpForward(count);
151
151
  return this;
152
152
  }
153
153
  }
@@ -1,5 +1,6 @@
1
- import { type Scanner } from "@ark/util";
2
- import type { regex } from "arkregex";
1
+ import { type ErrorMessage, type Scanner } from "@ark/util";
2
+ import type { Regex, regex } from "arkregex";
3
+ import type { Out } from "../../../attributes.ts";
3
4
  import type { InferredAst } from "../../ast/infer.ts";
4
5
  import type { RuntimeState } from "../../reduce/dynamic.ts";
5
6
  import type { StaticState, s } from "../../reduce/static.ts";
@@ -7,7 +8,8 @@ export type StringLiteral<contents extends string = string> = DoubleQuotedString
7
8
  export type DoubleQuotedStringLiteral<contents extends string = string> = `"${contents}"`;
8
9
  export type SingleQuotedStringLiteral<contents extends string = string> = `'${contents}'`;
9
10
  export declare const parseEnclosed: (s: RuntimeState, enclosing: EnclosingStartToken) => void;
10
- export type parseEnclosed<s extends StaticState, enclosingStart extends EnclosingStartToken, unscanned extends string> = Scanner.shiftUntilEscapable<unscanned, EnclosingTokens[enclosingStart], ""> extends Scanner.shiftResult<infer scanned, infer nextUnscanned> ? nextUnscanned extends "" ? s.error<writeUnterminatedEnclosedMessage<scanned, enclosingStart>> : s.setRoot<s, InferredAst<enclosingStart extends EnclosingQuote ? scanned : enclosingStart extends "/" ? regex.infer<scanned> : Date, `${enclosingStart}${scanned}${EnclosingTokens[enclosingStart]}`>, nextUnscanned extends Scanner.shift<string, infer unscanned> ? unscanned : ""> : never;
11
+ export type parseEnclosed<s extends StaticState, enclosingStart extends EnclosingStartToken, unscanned extends string> = Scanner.shiftUntilEscapable<unscanned, EnclosingTokens[enclosingStart], ""> extends Scanner.shiftResult<infer scanned, infer nextUnscanned> ? _parseEnclosed<s, enclosingStart, scanned, nextUnscanned> : never;
12
+ type _parseEnclosed<s extends StaticState, enclosingStart extends EnclosingStartToken, scanned extends string, nextUnscanned extends string, def extends string = `${enclosingStart}${scanned}${EnclosingTokens[enclosingStart]}`> = nextUnscanned extends "" ? s.error<writeUnterminatedEnclosedMessage<scanned, enclosingStart>> : enclosingStart extends EnclosingQuote ? s.setRoot<s, InferredAst<scanned, def>, nextUnscanned extends Scanner.shift<string, infer unscanned> ? unscanned : ""> : enclosingStart extends EnclosingRegexToken ? regex.parse<scanned> extends infer r ? r extends Regex ? s.setRoot<s, InferredAst<enclosingStart extends "/" ? r["infer"] : (In: r["infer"]) => Out<r["inferExecArray"]>, def>, nextUnscanned extends Scanner.shift<string, infer unscanned> ? unscanned : ""> : r extends ErrorMessage<infer e> ? s.error<e> : never : never : s.setRoot<s, InferredAst<Date, def>, nextUnscanned extends Scanner.shift<string, infer unscanned> ? unscanned : "">;
11
13
  export declare const enclosingQuote: {
12
14
  readonly "'": 1;
13
15
  readonly '"': 1;
@@ -26,8 +28,15 @@ export declare const enclosingLiteralTokens: {
26
28
  };
27
29
  export type EnclosingLiteralTokens = typeof enclosingLiteralTokens;
28
30
  export type EnclosingLiteralStartToken = keyof EnclosingLiteralTokens;
31
+ export declare const enclosingRegexTokens: {
32
+ readonly "/": "/";
33
+ readonly "x/": "/";
34
+ };
35
+ export type EnclosingRegexTokens = typeof enclosingRegexTokens;
36
+ export type EnclosingRegexToken = keyof EnclosingRegexTokens;
29
37
  export declare const enclosingTokens: {
30
38
  readonly "/": "/";
39
+ readonly "x/": "/";
31
40
  readonly "d'": "'";
32
41
  readonly 'd"': "\"";
33
42
  readonly "'": "'";
@@ -1,14 +1,24 @@
1
+ import { rootSchema } from "@ark/schema";
1
2
  import { isKeyOf, throwParseError } from "@ark/util";
2
3
  import { tryParseDate, writeInvalidDateMessage } from "./date.js";
4
+ const regexExecArray = rootSchema({
5
+ proto: "Array",
6
+ sequence: "string",
7
+ required: {
8
+ key: "groups",
9
+ value: ["object", { unit: undefined }]
10
+ }
11
+ });
3
12
  export const parseEnclosed = (s, enclosing) => {
4
13
  const enclosed = s.scanner.shiftUntilEscapable(untilLookaheadIsClosing[enclosingTokens[enclosing]]);
5
14
  if (s.scanner.lookahead === "")
6
15
  return s.error(writeUnterminatedEnclosedMessage(enclosed, enclosing));
7
16
  // Shift the scanner one additional time for the second enclosing token
8
17
  s.scanner.shift();
9
- if (enclosing === "/") {
18
+ if (enclosing in enclosingRegexTokens) {
19
+ let regex;
10
20
  try {
11
- new RegExp(enclosed);
21
+ regex = new RegExp(enclosed);
12
22
  }
13
23
  catch (e) {
14
24
  throwParseError(String(e));
@@ -17,6 +27,13 @@ export const parseEnclosed = (s, enclosing) => {
17
27
  domain: "string",
18
28
  pattern: enclosed
19
29
  }, { prereduced: true });
30
+ if (enclosing === "x/") {
31
+ s.root = s.ctx.$.node("morph", {
32
+ in: s.root,
33
+ morphs: (s) => regex.exec(s),
34
+ declaredOut: regexExecArray
35
+ });
36
+ }
20
37
  }
21
38
  else if (isKeyOf(enclosing, enclosingQuote))
22
39
  s.root = s.ctx.$.node("unit", { unit: enclosed });
@@ -40,9 +57,13 @@ export const enclosingLiteralTokens = {
40
57
  "'": "'",
41
58
  '"': '"'
42
59
  };
60
+ export const enclosingRegexTokens = {
61
+ "/": "/",
62
+ "x/": "/"
63
+ };
43
64
  export const enclosingTokens = {
44
65
  ...enclosingLiteralTokens,
45
- "/": "/"
66
+ ...enclosingRegexTokens
46
67
  };
47
68
  export const untilLookaheadIsClosing = {
48
69
  "'": scanner => scanner.lookahead === `'`,
@@ -5,4 +5,4 @@ import type { BaseCompletions } from "../../string.ts";
5
5
  import { parseEnclosed, type EnclosingQuote, type EnclosingStartToken } from "./enclosed.ts";
6
6
  import { parseUnenclosed } from "./unenclosed.ts";
7
7
  export declare const parseOperand: (s: RuntimeState) => void;
8
- export type parseOperand<s extends StaticState, $, args> = s["unscanned"] extends Scanner.shift<infer lookahead, infer unscanned> ? lookahead extends "(" ? s.reduceGroupOpen<s, unscanned> : lookahead extends EnclosingStartToken ? parseEnclosed<s, lookahead, unscanned> : lookahead extends WhitespaceChar ? parseOperand<s.scanTo<s, unscanned>, $, args> : lookahead extends "d" ? unscanned extends (Scanner.shift<infer enclosing extends EnclosingQuote, infer nextUnscanned>) ? parseEnclosed<s, `d${enclosing}`, nextUnscanned> : parseUnenclosed<s, $, args> : parseUnenclosed<s, $, args> : s.completion<`${s["scanned"]}${BaseCompletions<$, args>}`>;
8
+ export type parseOperand<s extends StaticState, $, args> = s["unscanned"] extends Scanner.shift<infer lookahead, infer unscanned> ? lookahead extends "(" ? s.reduceGroupOpen<s, unscanned> : lookahead extends EnclosingStartToken ? parseEnclosed<s, lookahead, unscanned> : lookahead extends WhitespaceChar ? parseOperand<s.scanTo<s, unscanned>, $, args> : lookahead extends "d" ? unscanned extends (Scanner.shift<infer enclosing extends EnclosingQuote, infer nextUnscanned>) ? parseEnclosed<s, `d${enclosing}`, nextUnscanned> : parseUnenclosed<s, $, args> : lookahead extends "x" ? unscanned extends Scanner.shift<"/", infer nextUnscanned> ? parseEnclosed<s, "x/", nextUnscanned> : parseUnenclosed<s, $, args> : parseUnenclosed<s, $, args> : s.completion<`${s["scanned"]}${BaseCompletions<$, args>}`>;
@@ -2,11 +2,15 @@ import { whitespaceChars } from "@ark/util";
2
2
  import { enclosingChar, enclosingQuote, parseEnclosed } from "./enclosed.js";
3
3
  import { parseUnenclosed, writeMissingOperandMessage } from "./unenclosed.js";
4
4
  export const parseOperand = (s) => s.scanner.lookahead === "" ? s.error(writeMissingOperandMessage(s))
5
- : s.scanner.lookahead === "(" ? s.shiftedByOne().reduceGroupOpen()
5
+ : s.scanner.lookahead === "(" ? s.shiftedBy(1).reduceGroupOpen()
6
6
  : s.scanner.lookaheadIsIn(enclosingChar) ? parseEnclosed(s, s.scanner.shift())
7
- : s.scanner.lookaheadIsIn(whitespaceChars) ? parseOperand(s.shiftedByOne())
7
+ : s.scanner.lookaheadIsIn(whitespaceChars) ? parseOperand(s.shiftedBy(1))
8
8
  : s.scanner.lookahead === "d" ?
9
9
  s.scanner.nextLookahead in enclosingQuote ?
10
10
  parseEnclosed(s, `${s.scanner.shift()}${s.scanner.shift()}`)
11
11
  : parseUnenclosed(s)
12
- : parseUnenclosed(s);
12
+ : s.scanner.lookahead === "x" ?
13
+ s.scanner.nextLookahead === "/" ?
14
+ s.shiftedBy(2) && parseEnclosed(s, "x/")
15
+ : parseUnenclosed(s)
16
+ : parseUnenclosed(s);
@@ -22,7 +22,7 @@ const unenclosedToNode = (s, token) => maybeParseReference(s, token) ??
22
22
  maybeParseUnenclosedLiteral(s, token) ??
23
23
  s.error(token === "" ?
24
24
  s.scanner.lookahead === "#" ?
25
- writePrefixedPrivateReferenceMessage(s.shiftedByOne().scanner.shiftUntilLookahead(terminatingChars))
25
+ writePrefixedPrivateReferenceMessage(s.shiftedBy(1).scanner.shiftUntilLookahead(terminatingChars))
26
26
  : writeMissingOperandMessage(s)
27
27
  : writeUnresolvableMessage(token));
28
28
  const maybeParseReference = (s, token) => {
@@ -12,7 +12,7 @@ export const parseOperator = (s) => {
12
12
  : s.error(incompleteArrayTokenMessage)
13
13
  : lookahead === "|" ?
14
14
  s.scanner.lookahead === ">" ?
15
- s.shiftedByOne().pushRootToBranch("|>")
15
+ s.shiftedBy(1).pushRootToBranch("|>")
16
16
  : s.pushRootToBranch(lookahead)
17
17
  : lookahead === "&" ? s.pushRootToBranch(lookahead)
18
18
  : lookahead === ")" ? s.finalizeGroup()
package/out/scope.js CHANGED
@@ -101,6 +101,6 @@ export class InternalScope extends BaseScope {
101
101
  static module = ((def, config = {}) => this.scope(def, config).export());
102
102
  }
103
103
  export const scope = Object.assign(InternalScope.scope, {
104
- define: def => def
104
+ define: (def) => def
105
105
  });
106
106
  export const Scope = InternalScope;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arktype",
3
3
  "description": "TypeScript's 1:1 validator, optimized from editor to runtime",
4
- "version": "2.1.27",
4
+ "version": "2.1.28",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -38,9 +38,9 @@
38
38
  "out"
39
39
  ],
40
40
  "dependencies": {
41
- "@ark/util": "0.55.0",
42
- "arkregex": "0.0.3",
43
- "@ark/schema": "0.55.0"
41
+ "@ark/util": "0.56.0",
42
+ "arkregex": "0.0.4",
43
+ "@ark/schema": "0.56.0"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public"