arktype 2.0.0-dev.12 → 2.0.0-dev.12-cjs

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/out/scope.js CHANGED
@@ -1,35 +1,38 @@
1
- import { RawRootScope, hasArkKind } from "@arktype/schema";
2
- import { domainOf, hasDomain, isThunk, throwParseError } from "@arktype/util";
3
- import { Generic } from "./generic.js";
4
- import { createMatchParser } from "./match.js";
5
- import { parseObject, writeBadDefinitionTypeMessage } from "./parser/definition.js";
6
- import { parseGenericParams } from "./parser/generic.js";
7
- import { DynamicState } from "./parser/string/reduce/dynamic.js";
8
- import { fullStringParse } from "./parser/string/string.js";
9
- import { _TypeParser } from "./type.js";
10
- export const scope = ((def, config = {}) => new RawScope(def, config));
11
- export class RawScope extends RawRootScope {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseScopeKey = exports.writeShallowCycleErrorMessage = exports.RawScope = exports.scope = void 0;
4
+ const schema_1 = require("@arktype/schema");
5
+ const util_1 = require("@arktype/util");
6
+ const generic_js_1 = require("./generic.js");
7
+ const match_js_1 = require("./match.js");
8
+ const definition_js_1 = require("./parser/definition.js");
9
+ const generic_js_2 = require("./parser/generic.js");
10
+ const dynamic_js_1 = require("./parser/string/reduce/dynamic.js");
11
+ const string_js_1 = require("./parser/string/string.js");
12
+ const type_js_1 = require("./type.js");
13
+ exports.scope = ((def, config = {}) => new RawScope(def, config));
14
+ class RawScope extends schema_1.RawRootScope {
12
15
  parseCache = {};
13
16
  constructor(def, config) {
14
17
  const aliases = {};
15
18
  for (const k in def) {
16
- const parsedKey = parseScopeKey(k);
19
+ const parsedKey = (0, exports.parseScopeKey)(k);
17
20
  aliases[parsedKey.name] =
18
21
  parsedKey.params.length ?
19
22
  // TODO: this
20
- new Generic(parsedKey.params, def[k], {})
23
+ new generic_js_1.Generic(parsedKey.params, def[k], {})
21
24
  : def[k];
22
25
  }
23
26
  super(aliases, config);
24
27
  }
25
- type = new _TypeParser(this);
26
- match = createMatchParser(this);
28
+ type = new type_js_1.RawTypeParser(this);
29
+ match = (0, match_js_1.createMatchParser)(this);
27
30
  declare = (() => ({
28
31
  type: this.type
29
32
  })).bind(this);
30
33
  define = ((def) => def).bind(this);
31
34
  preparseRoot(def) {
32
- if (isThunk(def) && !hasArkKind(def, "generic"))
35
+ if ((0, util_1.isThunk)(def) && !(0, schema_1.hasArkKind)(def, "generic"))
33
36
  return def();
34
37
  return def;
35
38
  }
@@ -53,19 +56,21 @@ export class RawScope extends RawRootScope {
53
56
  this.parseCache[def] = this.parseString(def, ctx);
54
57
  return this.parseCache[def];
55
58
  }
56
- return hasDomain(def, "object") ?
57
- parseObject(def, ctx)
58
- : throwParseError(writeBadDefinitionTypeMessage(domainOf(def)));
59
+ return (0, util_1.hasDomain)(def, "object") ?
60
+ (0, definition_js_1.parseObject)(def, ctx)
61
+ : (0, util_1.throwParseError)((0, definition_js_1.writeBadDefinitionTypeMessage)((0, util_1.domainOf)(def)));
59
62
  }
60
63
  parseString(def, ctx) {
61
64
  return (this.maybeResolveRoot(def) ??
62
65
  ((def.endsWith("[]") &&
63
66
  this.maybeResolveRoot(def.slice(0, -2))?.array()) ||
64
- fullStringParse(new DynamicState(def, ctx))));
67
+ (0, string_js_1.fullStringParse)(new dynamic_js_1.DynamicState(def, ctx))));
65
68
  }
66
69
  }
67
- export const writeShallowCycleErrorMessage = (name, seen) => `Alias '${name}' has a shallow resolution cycle: ${[...seen, name].join(":")}`;
68
- export const parseScopeKey = (k) => {
70
+ exports.RawScope = RawScope;
71
+ const writeShallowCycleErrorMessage = (name, seen) => `Alias '${name}' has a shallow resolution cycle: ${[...seen, name].join(":")}`;
72
+ exports.writeShallowCycleErrorMessage = writeShallowCycleErrorMessage;
73
+ const parseScopeKey = (k) => {
69
74
  const firstParamIndex = k.indexOf("<");
70
75
  if (firstParamIndex === -1) {
71
76
  return {
@@ -74,10 +79,11 @@ export const parseScopeKey = (k) => {
74
79
  };
75
80
  }
76
81
  if (k.at(-1) !== ">") {
77
- throwParseError(`'>' must be the last character of a generic declaration in a scope`);
82
+ (0, util_1.throwParseError)(`'>' must be the last character of a generic declaration in a scope`);
78
83
  }
79
84
  return {
80
85
  name: k.slice(0, firstParamIndex),
81
- params: parseGenericParams(k.slice(firstParamIndex + 1, -1))
86
+ params: (0, generic_js_2.parseGenericParams)(k.slice(firstParamIndex + 1, -1))
82
87
  };
83
88
  };
89
+ exports.parseScopeKey = parseScopeKey;
package/out/type.d.ts CHANGED
@@ -15,7 +15,7 @@ export interface TypeParser<$> extends TypeParserAttachments {
15
15
  [param in parseGenericParams<params>[number]]: unknown;
16
16
  }>): Generic<parseGenericParams<params>, def, $>;
17
17
  }
18
- export declare class _TypeParser extends Callable<(...args: unknown[]) => BaseRoot | Generic, TypeParserAttachments> {
18
+ export declare class RawTypeParser extends Callable<(...args: unknown[]) => BaseRoot | Generic, TypeParserAttachments> {
19
19
  constructor($: RawScope);
20
20
  }
21
21
  export type DeclarationParser<$> = <preinferred>() => {
package/out/type.js CHANGED
@@ -1,11 +1,14 @@
1
- import { ArkErrors, BaseRoot } from "@arktype/schema";
2
- import { Callable } from "@arktype/util";
3
- import { Generic } from "./generic.js";
4
- import { parseGenericParams } from "./parser/generic.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Type = exports.RawTypeParser = void 0;
4
+ const schema_1 = require("@arktype/schema");
5
+ const util_1 = require("@arktype/util");
6
+ const generic_js_1 = require("./generic.js");
7
+ const generic_js_2 = require("./parser/generic.js");
5
8
  const typeParserAttachments = Object.freeze({
6
- errors: ArkErrors
9
+ errors: schema_1.ArkErrors
7
10
  });
8
- export class _TypeParser extends Callable {
11
+ class RawTypeParser extends util_1.Callable {
9
12
  constructor($) {
10
13
  super((...args) => {
11
14
  if (args.length === 1) {
@@ -18,10 +21,10 @@ export class _TypeParser extends Callable {
18
21
  args[0].at(-1) === ">") {
19
22
  // if there are exactly two args, the first of which looks like <${string}>,
20
23
  // treat as a generic
21
- const params = parseGenericParams(args[0].slice(1, -1));
24
+ const params = (0, generic_js_2.parseGenericParams)(args[0].slice(1, -1));
22
25
  const def = args[1];
23
26
  // TODO: validateUninstantiatedGeneric, remove this cast
24
- return new Generic(params, def, $);
27
+ return new generic_js_1.Generic(params, def, $);
25
28
  }
26
29
  // otherwise, treat as a tuple expression. technically, this also allows
27
30
  // non-expression tuple definitions to be parsed, but it's not a supported
@@ -30,4 +33,5 @@ export class _TypeParser extends Callable {
30
33
  }, { bind: $, attach: typeParserAttachments });
31
34
  }
32
35
  }
33
- export const Type = BaseRoot;
36
+ exports.RawTypeParser = RawTypeParser;
37
+ exports.Type = schema_1.BaseRoot;
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.0.0-dev.12",
4
+ "version": "2.0.0-dev.12-cjs",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "David Blass",
@@ -16,17 +16,9 @@
16
16
  "main": "./out/api.js",
17
17
  "types": "./out/api.d.ts",
18
18
  "exports": {
19
- ".": {
20
- "types": "./out/api.d.ts",
21
- "default": "./out/api.js"
22
- },
23
- "./config": {
24
- "types": "./out/config.d.ts",
25
- "default": "./out/config.js"
26
- },
27
- "./internal/*": {
28
- "default": "./out/*"
29
- }
19
+ ".": "./out/api.js",
20
+ "./config": "./out/config.js",
21
+ "./internal/*": "./out/*"
30
22
  },
31
23
  "files": [
32
24
  "out"
@@ -36,7 +28,7 @@
36
28
  "test": "tsx ../repo/testPackage.ts"
37
29
  },
38
30
  "dependencies": {
39
- "@arktype/util": "0.0.41",
40
- "@arktype/schema": "0.1.4"
31
+ "@arktype/util": "0.0.41-cjs",
32
+ "@arktype/schema": "0.1.4-cjs"
41
33
  }
42
34
  }