MCPcopy Create free account
hub / github.com/arktypeio/arktype / constructor

Method constructor

ark/aot/precompile.ts:860–921  ·  view source on GitHub ↗
(host: PrecompileHost, opts: PrecompileOptions = {})

Source from the content-addressed store, hash-verified

858 private usagesByProgram = new Map<string, ProgramUsage>()
859
860 constructor(host: PrecompileHost, opts: PrecompileOptions = {}) {
861 opts = resolvePrecompileOptions(opts)
862 this.graph = new ModuleGraph(host, opts.cwd, opts.dependencies)
863 this.interpreter = new Interpreter(
864 this.graph,
865 opts,
866 module => this.readsOf(module),
867 // arktype throws reading .encode in a program built on it
868 module => this.mode !== "standalone" || this.importsCodecs(module)
869 )
870 this.mode = opts.runtime === "arktype" ? "cache" : "standalone"
871 this.config = opts.config || undefined
872 this.configures = opts.config !== false
873 this.inline = !!opts.inline
874 this.defers = opts.defers
875 const checks = opts.creationChecks ?? "types"
876 this.checkHelpers = this.mode === "standalone" && checks === "helpers"
877 this.shadow = this.mode === "standalone" && !!opts.shadow
878 this.allowUnsafe = !!opts.allowUnsafe
879 this.droppedNarrow = opts.droppedNarrow !== false
880 this.members = opts.members ?? {}
881 this.errors = opts.errors
882 this.variant = runtimeVariantOf(opts)
883 this.mutatesInput = opts.mutatesInput
884 this.standalone = {
885 members: this.members,
886 errors: this.errors,
887 freeze: opts.freeze !== false,
888 lazy: opts.lazy !== false,
889 checks,
890 mutatesInput: this.mutatesInput,
891 optimize: opts.optimize ?? "speed",
892 // errors written for size find their issues as a call returns: the
893 // classes that wait to are the ones written for speed
894 defersIssues: (opts.optimizeErrors ?? opts.optimize) !== "size",
895 jsonInput: opts.jsonInput,
896 bakedLimit: opts.bakedLimit
897 }
898 this.optimizeUnset = opts.optimize === undefined
899 this.strategies = new SchemaStrategies(
900 opts,
901 this.standalone.optimize!,
902 opts.cwd
903 )
904 this.lackedMembers = new Set(
905 defaultMembers.flatMap(member =>
906 this.members[member] !== false ? []
907 : member === "methods" ? methodMembers
908 : [member]
909 )
910 )
911 this.unsureLackedMembers = new Set([
912 ...this.lackedMembers,
913 ...introspectionMembers.filter(member => this.members[member] === false)
914 ])
915 const contract: ShadowContract = {}
916 if (this.members.meta === false) contract.members = { meta: false }
917 if (this.mutatesInput) contract.mutatesInput = this.mutatesInput

Callers

nothing calls this directly

Calls 5

readsOfMethod · 0.95
importsCodecsMethod · 0.95
resolvePrecompileOptionsFunction · 0.90
runtimeVariantOfFunction · 0.90
filterMethod · 0.80

Tested by

no test coverage detected