@mionjs/run-types 0.8.6 → 0.8.8
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/.dist/cjs/index.d.ts +1 -0
- package/.dist/cjs/index.d.ts.map +1 -0
- package/.dist/cjs/src/constants.d.ts +1 -0
- package/.dist/cjs/src/constants.d.ts.map +1 -0
- package/.dist/cjs/src/constants.functions.d.ts +1 -0
- package/.dist/cjs/src/constants.functions.d.ts.map +1 -0
- package/.dist/cjs/src/constants.kind.d.ts +1 -0
- package/.dist/cjs/src/constants.kind.d.ts.map +1 -0
- package/.dist/cjs/src/createRunType.d.ts +1 -0
- package/.dist/cjs/src/createRunType.d.ts.map +1 -0
- package/.dist/cjs/src/createRunTypeFunctions.d.ts +1 -0
- package/.dist/cjs/src/createRunTypeFunctions.d.ts.map +1 -0
- package/.dist/cjs/src/formats.runtype.d.ts +1 -0
- package/.dist/cjs/src/formats.runtype.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/binary/fromBinary.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/binary/fromBinary.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/binary/toBinary.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/binary/toBinary.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/equalsHelpers.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/equalsHelpers.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/json/stringifyJson.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/json/stringifyJson.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/json/toJsCode.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/json/toJsCode.d.ts.map +1 -0
- package/.dist/cjs/src/lib/baseRunTypeFormat.d.ts +1 -0
- package/.dist/cjs/src/lib/baseRunTypeFormat.d.ts.map +1 -0
- package/.dist/cjs/src/lib/baseRunTypes.d.ts +1 -0
- package/.dist/cjs/src/lib/baseRunTypes.d.ts.map +1 -0
- package/.dist/cjs/src/lib/createJitFunction.d.ts +1 -0
- package/.dist/cjs/src/lib/createJitFunction.d.ts.map +1 -0
- package/.dist/cjs/src/lib/dkProxy.d.ts +1 -0
- package/.dist/cjs/src/lib/dkProxy.d.ts.map +1 -0
- package/.dist/cjs/src/lib/formats.d.ts +1 -0
- package/.dist/cjs/src/lib/formats.d.ts.map +1 -0
- package/.dist/cjs/src/lib/guards.d.ts +1 -0
- package/.dist/cjs/src/lib/guards.d.ts.map +1 -0
- package/.dist/cjs/src/lib/jitFnCompiler.d.ts +1 -0
- package/.dist/cjs/src/lib/jitFnCompiler.d.ts.map +1 -0
- package/.dist/cjs/src/lib/jitFnsRegistry.d.ts +1 -0
- package/.dist/cjs/src/lib/jitFnsRegistry.d.ts.map +1 -0
- package/.dist/cjs/src/lib/typeId.d.ts +1 -0
- package/.dist/cjs/src/lib/typeId.d.ts.map +1 -0
- package/.dist/cjs/src/lib/utils.d.ts +1 -0
- package/.dist/cjs/src/lib/utils.d.ts.map +1 -0
- package/.dist/cjs/src/mocking/constants.mock.d.ts +1 -0
- package/.dist/cjs/src/mocking/constants.mock.d.ts.map +1 -0
- package/.dist/cjs/src/mocking/mockRegistry.d.ts +1 -0
- package/.dist/cjs/src/mocking/mockRegistry.d.ts.map +1 -0
- package/.dist/cjs/src/mocking/mockType.d.ts +1 -0
- package/.dist/cjs/src/mocking/mockType.d.ts.map +1 -0
- package/.dist/cjs/src/mocking/mockUtils.d.ts +1 -0
- package/.dist/cjs/src/mocking/mockUtils.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/any.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/any.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/bigInt.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/bigInt.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/boolean.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/boolean.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/date.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/date.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/enum.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/enum.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/enumMember.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/enumMember.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/literal.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/literal.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/never.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/never.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/null.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/null.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/number.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/number.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/object.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/object.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/regexp.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/regexp.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/string.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/string.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/symbol.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/symbol.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/undefined.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/undefined.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/unknown.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/unknown.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/void.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/void.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/collection/class.d.ts +1 -0
- package/.dist/cjs/src/nodes/collection/class.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/collection/functionParams.d.ts +1 -0
- package/.dist/cjs/src/nodes/collection/functionParams.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/collection/interface.d.ts +1 -0
- package/.dist/cjs/src/nodes/collection/interface.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/collection/intersection.d.ts +1 -0
- package/.dist/cjs/src/nodes/collection/intersection.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/collection/tuple.d.ts +1 -0
- package/.dist/cjs/src/nodes/collection/tuple.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/collection/union.d.ts +1 -0
- package/.dist/cjs/src/nodes/collection/union.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/collection/unionDiscriminator.d.ts +1 -0
- package/.dist/cjs/src/nodes/collection/unionDiscriminator.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/function/function.d.ts +1 -0
- package/.dist/cjs/src/nodes/function/function.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/array.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/array.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/callSignature.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/callSignature.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/genericMember.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/genericMember.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/indexProperty.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/indexProperty.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/method.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/method.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/methodSignature.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/methodSignature.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/param.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/param.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/property.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/property.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/restParams.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/restParams.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/tupleMember.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/tupleMember.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/native/Iterable.d.ts +1 -0
- package/.dist/cjs/src/nodes/native/Iterable.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/native/map.d.ts +1 -0
- package/.dist/cjs/src/nodes/native/map.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/native/nonSerializable.d.ts +1 -0
- package/.dist/cjs/src/nodes/native/nonSerializable.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/native/promise.d.ts +1 -0
- package/.dist/cjs/src/nodes/native/promise.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/native/set.d.ts +1 -0
- package/.dist/cjs/src/nodes/native/set.d.ts.map +1 -0
- package/.dist/cjs/src/run-types-pure-fns.d.ts +1 -0
- package/.dist/cjs/src/run-types-pure-fns.d.ts.map +1 -0
- package/.dist/cjs/src/types.d.ts +1 -0
- package/.dist/cjs/src/types.d.ts.map +1 -0
- package/.dist/esm/index.d.ts +1 -0
- package/.dist/esm/index.d.ts.map +1 -0
- package/.dist/esm/src/constants.d.ts +1 -0
- package/.dist/esm/src/constants.d.ts.map +1 -0
- package/.dist/esm/src/constants.functions.d.ts +1 -0
- package/.dist/esm/src/constants.functions.d.ts.map +1 -0
- package/.dist/esm/src/constants.kind.d.ts +1 -0
- package/.dist/esm/src/constants.kind.d.ts.map +1 -0
- package/.dist/esm/src/createRunType.d.ts +1 -0
- package/.dist/esm/src/createRunType.d.ts.map +1 -0
- package/.dist/esm/src/createRunTypeFunctions.d.ts +1 -0
- package/.dist/esm/src/createRunTypeFunctions.d.ts.map +1 -0
- package/.dist/esm/src/formats.runtype.d.ts +1 -0
- package/.dist/esm/src/formats.runtype.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/binary/fromBinary.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/binary/fromBinary.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/binary/toBinary.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/binary/toBinary.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/equalsHelpers.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/equalsHelpers.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/json/stringifyJson.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/json/stringifyJson.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/json/toJsCode.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/json/toJsCode.d.ts.map +1 -0
- package/.dist/esm/src/lib/baseRunTypeFormat.d.ts +1 -0
- package/.dist/esm/src/lib/baseRunTypeFormat.d.ts.map +1 -0
- package/.dist/esm/src/lib/baseRunTypes.d.ts +1 -0
- package/.dist/esm/src/lib/baseRunTypes.d.ts.map +1 -0
- package/.dist/esm/src/lib/createJitFunction.d.ts +1 -0
- package/.dist/esm/src/lib/createJitFunction.d.ts.map +1 -0
- package/.dist/esm/src/lib/dkProxy.d.ts +1 -0
- package/.dist/esm/src/lib/dkProxy.d.ts.map +1 -0
- package/.dist/esm/src/lib/formats.d.ts +1 -0
- package/.dist/esm/src/lib/formats.d.ts.map +1 -0
- package/.dist/esm/src/lib/guards.d.ts +1 -0
- package/.dist/esm/src/lib/guards.d.ts.map +1 -0
- package/.dist/esm/src/lib/jitFnCompiler.d.ts +1 -0
- package/.dist/esm/src/lib/jitFnCompiler.d.ts.map +1 -0
- package/.dist/esm/src/lib/jitFnsRegistry.d.ts +1 -0
- package/.dist/esm/src/lib/jitFnsRegistry.d.ts.map +1 -0
- package/.dist/esm/src/lib/typeId.d.ts +1 -0
- package/.dist/esm/src/lib/typeId.d.ts.map +1 -0
- package/.dist/esm/src/lib/utils.d.ts +1 -0
- package/.dist/esm/src/lib/utils.d.ts.map +1 -0
- package/.dist/esm/src/mocking/constants.mock.d.ts +1 -0
- package/.dist/esm/src/mocking/constants.mock.d.ts.map +1 -0
- package/.dist/esm/src/mocking/mockRegistry.d.ts +1 -0
- package/.dist/esm/src/mocking/mockRegistry.d.ts.map +1 -0
- package/.dist/esm/src/mocking/mockType.d.ts +1 -0
- package/.dist/esm/src/mocking/mockType.d.ts.map +1 -0
- package/.dist/esm/src/mocking/mockUtils.d.ts +1 -0
- package/.dist/esm/src/mocking/mockUtils.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/any.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/any.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/bigInt.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/bigInt.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/boolean.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/boolean.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/date.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/date.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/enum.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/enum.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/enumMember.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/enumMember.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/literal.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/literal.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/never.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/never.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/null.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/null.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/number.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/number.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/object.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/object.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/regexp.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/regexp.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/string.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/string.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/symbol.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/symbol.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/undefined.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/undefined.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/unknown.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/unknown.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/void.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/void.d.ts.map +1 -0
- package/.dist/esm/src/nodes/collection/class.d.ts +1 -0
- package/.dist/esm/src/nodes/collection/class.d.ts.map +1 -0
- package/.dist/esm/src/nodes/collection/functionParams.d.ts +1 -0
- package/.dist/esm/src/nodes/collection/functionParams.d.ts.map +1 -0
- package/.dist/esm/src/nodes/collection/interface.d.ts +1 -0
- package/.dist/esm/src/nodes/collection/interface.d.ts.map +1 -0
- package/.dist/esm/src/nodes/collection/intersection.d.ts +1 -0
- package/.dist/esm/src/nodes/collection/intersection.d.ts.map +1 -0
- package/.dist/esm/src/nodes/collection/tuple.d.ts +1 -0
- package/.dist/esm/src/nodes/collection/tuple.d.ts.map +1 -0
- package/.dist/esm/src/nodes/collection/union.d.ts +1 -0
- package/.dist/esm/src/nodes/collection/union.d.ts.map +1 -0
- package/.dist/esm/src/nodes/collection/unionDiscriminator.d.ts +1 -0
- package/.dist/esm/src/nodes/collection/unionDiscriminator.d.ts.map +1 -0
- package/.dist/esm/src/nodes/function/function.d.ts +1 -0
- package/.dist/esm/src/nodes/function/function.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/array.d.ts +1 -0
- package/.dist/esm/src/nodes/member/array.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/callSignature.d.ts +1 -0
- package/.dist/esm/src/nodes/member/callSignature.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/genericMember.d.ts +1 -0
- package/.dist/esm/src/nodes/member/genericMember.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/indexProperty.d.ts +1 -0
- package/.dist/esm/src/nodes/member/indexProperty.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/method.d.ts +1 -0
- package/.dist/esm/src/nodes/member/method.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/methodSignature.d.ts +1 -0
- package/.dist/esm/src/nodes/member/methodSignature.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/param.d.ts +1 -0
- package/.dist/esm/src/nodes/member/param.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/property.d.ts +1 -0
- package/.dist/esm/src/nodes/member/property.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/restParams.d.ts +1 -0
- package/.dist/esm/src/nodes/member/restParams.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/tupleMember.d.ts +1 -0
- package/.dist/esm/src/nodes/member/tupleMember.d.ts.map +1 -0
- package/.dist/esm/src/nodes/native/Iterable.d.ts +1 -0
- package/.dist/esm/src/nodes/native/Iterable.d.ts.map +1 -0
- package/.dist/esm/src/nodes/native/map.d.ts +1 -0
- package/.dist/esm/src/nodes/native/map.d.ts.map +1 -0
- package/.dist/esm/src/nodes/native/nonSerializable.d.ts +1 -0
- package/.dist/esm/src/nodes/native/nonSerializable.d.ts.map +1 -0
- package/.dist/esm/src/nodes/native/promise.d.ts +1 -0
- package/.dist/esm/src/nodes/native/promise.d.ts.map +1 -0
- package/.dist/esm/src/nodes/native/set.d.ts +1 -0
- package/.dist/esm/src/nodes/native/set.d.ts.map +1 -0
- package/.dist/esm/src/run-types-pure-fns.d.ts +1 -0
- package/.dist/esm/src/run-types-pure-fns.d.ts.map +1 -0
- package/.dist/esm/src/types.d.ts +1 -0
- package/.dist/esm/src/types.d.ts.map +1 -0
- package/index.ts +70 -0
- package/package.json +11 -4
- package/src/constants.functions.ts +196 -0
- package/src/constants.kind.ts +76 -0
- package/src/constants.ts +85 -0
- package/src/createRunType.ts +323 -0
- package/src/createRunTypeFunctions.ts +93 -0
- package/src/formats.runtype.ts +35 -0
- package/src/jitCompilers/binary/binarySPEC.md +138 -0
- package/src/jitCompilers/binary/binarySpec/binaryHelpers.ts +118 -0
- package/src/jitCompilers/binary/fromBinary.ts +492 -0
- package/src/jitCompilers/binary/toBinary.ts +435 -0
- package/src/jitCompilers/equalsHelpers.ts +62 -0
- package/src/jitCompilers/json/jsonSpec/jsonHelpers.ts +64 -0
- package/src/jitCompilers/json/stringifyJson.ts +475 -0
- package/src/jitCompilers/json/stringifySpec/stringifyHelpers.ts +59 -0
- package/src/jitCompilers/json/toJsCode.ts +182 -0
- package/src/jitCompilers/serialization-suite.ts +1637 -0
- package/src/jitCompilers/xyz-Template/fromXYZ.ts +211 -0
- package/src/jitCompilers/xyz-Template/toXYZ.ts +216 -0
- package/src/jitCompilers/xyz-Template/xyzReadme.md +6 -0
- package/src/jitCompilers/xyz-Template/xyzSpec/xyzHelpers.ts +66 -0
- package/src/lib/baseRunTypeFormat.ts +320 -0
- package/src/lib/baseRunTypes.ts +367 -0
- package/src/lib/createJitFunction.ts +87 -0
- package/src/lib/dkProxy.ts +47 -0
- package/src/lib/formats.ts +144 -0
- package/src/lib/guards.ts +290 -0
- package/src/lib/jitFnCompiler.ts +783 -0
- package/src/lib/jitFnsRegistry.ts +53 -0
- package/src/lib/typeId.ts +225 -0
- package/src/lib/utils.ts +402 -0
- package/src/mocking/constants.mock.ts +87 -0
- package/src/mocking/mockRegistry.ts +20 -0
- package/src/mocking/mockType.ts +354 -0
- package/src/mocking/mockUtils.ts +82 -0
- package/src/nodes/atomic/any.ts +22 -0
- package/src/nodes/atomic/bigInt.ts +26 -0
- package/src/nodes/atomic/boolean.ts +26 -0
- package/src/nodes/atomic/date.ts +26 -0
- package/src/nodes/atomic/enum.ts +23 -0
- package/src/nodes/atomic/enumMember.ts +29 -0
- package/src/nodes/atomic/literal.ts +125 -0
- package/src/nodes/atomic/never.ts +26 -0
- package/src/nodes/atomic/null.ts +26 -0
- package/src/nodes/atomic/number.ts +26 -0
- package/src/nodes/atomic/object.ts +20 -0
- package/src/nodes/atomic/regexp.ts +29 -0
- package/src/nodes/atomic/string.ts +20 -0
- package/src/nodes/atomic/symbol.ts +31 -0
- package/src/nodes/atomic/undefined.ts +23 -0
- package/src/nodes/atomic/unknown.ts +10 -0
- package/src/nodes/atomic/void.ts +26 -0
- package/src/nodes/collection/class.ts +36 -0
- package/src/nodes/collection/functionParams.ts +42 -0
- package/src/nodes/collection/interface.ts +300 -0
- package/src/nodes/collection/intersection.ts +30 -0
- package/src/nodes/collection/tuple.ts +80 -0
- package/src/nodes/collection/union.ts +205 -0
- package/src/nodes/collection/unionDiscriminator.ts +259 -0
- package/src/nodes/function/function.ts +166 -0
- package/src/nodes/member/array.ts +150 -0
- package/src/nodes/member/callSignature.ts +34 -0
- package/src/nodes/member/genericMember.ts +63 -0
- package/src/nodes/member/indexProperty.ts +125 -0
- package/src/nodes/member/method.ts +30 -0
- package/src/nodes/member/methodSignature.ts +31 -0
- package/src/nodes/member/param.ts +22 -0
- package/src/nodes/member/property.ts +75 -0
- package/src/nodes/member/restParams.ts +22 -0
- package/src/nodes/member/tupleMember.ts +93 -0
- package/src/nodes/native/Iterable.ts +153 -0
- package/src/nodes/native/map.ts +91 -0
- package/src/nodes/native/nonSerializable.ts +42 -0
- package/src/nodes/native/promise.ts +43 -0
- package/src/nodes/native/set.ts +56 -0
- package/src/run-types-pure-fns.ts +116 -0
- package/src/types.ts +206 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {getENV, getJitUtils, type JITUtils} from '@mionjs/core';
|
|
2
|
+
import type {JitFnID, Mutable, RunTypeOptions} from '../types.ts';
|
|
3
|
+
import {BaseFnCompiler, JitCompilerLike, printClosure} from './jitFnCompiler.ts';
|
|
4
|
+
import type {BaseRunType} from './baseRunTypes.ts';
|
|
5
|
+
import {getJITFnName} from './jitFnsRegistry.ts';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates a function name/hash based on the jitHash of the runType and the id of the function.
|
|
9
|
+
* it is a valid js variable name.
|
|
10
|
+
* @param id
|
|
11
|
+
* @param rt
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export function getJITFnHash(id: JitFnID, rt: BaseRunType, opts?: RunTypeOptions): string {
|
|
15
|
+
if (opts) return `${id}_${rt.getJitHash(opts)}`;
|
|
16
|
+
return `${id}_${rt.getJitHash({})}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Creates a jit function from a compiler.
|
|
21
|
+
* This function handles the logic to determine if the function should be created or retrieved from the cache.
|
|
22
|
+
* @param comp
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export function createJitFunction(comp: BaseFnCompiler): (...args: any[]) => any {
|
|
26
|
+
if (comp.fn) return comp.fn;
|
|
27
|
+
if (comp.stack.length !== 0) throw new Error('Can not get compiled function before the compile operation is finished');
|
|
28
|
+
if (getJitUtils().hasJitFn(comp.jitFnHash)) return getJitUtils().getJitFn(comp.jitFnHash);
|
|
29
|
+
const {fnCode, fnName, contextCode} = getJitFnCode(comp);
|
|
30
|
+
const {createJitFn, fn, code} = createJitFnWithContext(comp, fnName, fnCode, contextCode);
|
|
31
|
+
(comp as Mutable<BaseFnCompiler>).code = code;
|
|
32
|
+
(comp as Mutable<BaseFnCompiler>).fn = fn;
|
|
33
|
+
(comp as Mutable<BaseFnCompiler>).createJitFn = createJitFn;
|
|
34
|
+
return fn;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a JIT function that has jitUtils (and possibly other required variables) in the context,
|
|
39
|
+
* This way jitUtils ca be used without passing them as arguments to every atomic jit function (kind of global variables).
|
|
40
|
+
* @param varName
|
|
41
|
+
* @param fnCode
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
function createJitFnWithContext(comp: BaseFnCompiler, fnName: string, fnCode: string, contextCode?: string) {
|
|
45
|
+
// this function will have jitUtils as context as is an argument of the enclosing function
|
|
46
|
+
const context = contextCode ? `${contextCode};` : '';
|
|
47
|
+
let fnWithContext = `'use strict'; ${context} return ${fnCode}`;
|
|
48
|
+
if (getENV('DEBUG_RUN_TIME')) {
|
|
49
|
+
const fnArgs = getJitFnArgs(comp);
|
|
50
|
+
const argsCall = getJitFnArgs(comp, false);
|
|
51
|
+
const debugWrapper = `function debug_${fnName}(${fnArgs}){
|
|
52
|
+
const resp = ${fnName}(${argsCall});
|
|
53
|
+
console.log('${fnName} ${getJITFnName(comp.fnID)} ${comp.rootType.getTypeName()}', 'result:', resp, ' value:', ${argsCall});
|
|
54
|
+
return resp;
|
|
55
|
+
}`;
|
|
56
|
+
fnWithContext = `'use strict'; ${context} ${fnCode} ${debugWrapper} return debug_${fnName};`;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
// wrapper functions that works as a factory and returns the actual jit function, context contains all constants and heavy to create objects
|
|
60
|
+
const wrapperWithContext = new Function('utl', fnWithContext) as (utl: JITUtils) => (...args: any[]) => any;
|
|
61
|
+
if (getENV('DEBUG_JIT')) console.log(printClosure(fnWithContext, fnName));
|
|
62
|
+
return {createJitFn: wrapperWithContext, fn: wrapperWithContext(getJitUtils()), code: fnWithContext}; // returns the jit internal function with the context
|
|
63
|
+
} catch (e: any) {
|
|
64
|
+
if (getENV('DEBUG_JIT')) {
|
|
65
|
+
console.warn('Error creating jit function with context code:\n', printClosure(fnWithContext, fnName));
|
|
66
|
+
}
|
|
67
|
+
throw e;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function getJitFnCode(comp: BaseFnCompiler): {fnName: string; fnCode: string; contextCode: string} {
|
|
72
|
+
const fnName = comp.jitFnHash;
|
|
73
|
+
const fnArgs = getJitFnArgs(comp); // function arguments with default values ie: 'vλl, pλth=[], εrr=[]'
|
|
74
|
+
const fnCode = `function ${fnName}(${fnArgs}){${comp.code}}`;
|
|
75
|
+
return {fnName, fnCode, contextCode: comp.getContextItemValues().join(';\n')};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Returns the arguments of the function with default values */
|
|
79
|
+
function getJitFnArgs(comp: JitCompilerLike, defaultValues = true): string {
|
|
80
|
+
return Object.entries(comp.args)
|
|
81
|
+
.map(([key, name]) => {
|
|
82
|
+
if (!comp.defaultParamValues[key] || !defaultValues) return name;
|
|
83
|
+
const value = comp.defaultParamValues[key];
|
|
84
|
+
return `${name}=${value}`;
|
|
85
|
+
})
|
|
86
|
+
.join(',');
|
|
87
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2025 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
|
|
8
|
+
import {typeAnnotation, typeToObject} from '@deepkit/type';
|
|
9
|
+
import {RunType, RunTypeAnnotation, SrcType} from '../types.ts';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns RunType annotations, ie:
|
|
13
|
+
*
|
|
14
|
+
* type WithSuffix<Suffix extends string> = string & TypeAnnotation<'suffix', Suffix>;
|
|
15
|
+
* const rt = runType<WithSuffix<'hello'>>();
|
|
16
|
+
* const annotations = rt.getRunTypeAnnotations();
|
|
17
|
+
* annotations = [{name: 'suffix', options: LiteralRunType<'hello'>}];
|
|
18
|
+
*/
|
|
19
|
+
export function getRunTypeAnnotations(rt: RunType): RunTypeAnnotation[] {
|
|
20
|
+
const annotations = typeAnnotation.getAnnotations(rt.src);
|
|
21
|
+
return annotations.map((a) => {
|
|
22
|
+
const annotation: RunTypeAnnotation = {
|
|
23
|
+
name: a.name,
|
|
24
|
+
options: (a.options as SrcType)._rt as RunType,
|
|
25
|
+
};
|
|
26
|
+
return annotation;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Returns the options of the annotations parsed js data, ie:
|
|
32
|
+
*
|
|
33
|
+
* type WithSuffix<Suffix extends string> = string & TypeAnnotation<'suffix', Suffix>;
|
|
34
|
+
* const rt = runType<WithSuffix<'hello'>>();
|
|
35
|
+
* const parsedOptions = rt.getParsedAnnotationOptions();
|
|
36
|
+
* parsedOptions = 'hello';
|
|
37
|
+
*/
|
|
38
|
+
export function getParsedAnnotationOptions(rt: RunType): any[] {
|
|
39
|
+
return getRunTypeAnnotations(rt).map((a) => typeAnnotation.getOption(rt.src, a.name));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Returns the deepkit type as a js object, this is useful to extract metadata from the type.
|
|
44
|
+
*/
|
|
45
|
+
export function getTypeToObject(rt: RunType): any {
|
|
46
|
+
return typeToObject(rt.src);
|
|
47
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2025 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
|
|
8
|
+
import {CompiledPureFunction, TypeFormatParams, TypeFormatValue} from '@mionjs/core';
|
|
9
|
+
import {ReflectionKindName} from '../constants.kind.ts';
|
|
10
|
+
import type {FormatAnnotation} from '../types.ts';
|
|
11
|
+
import {typeAnnotation, ReflectionKind} from '@deepkit/type';
|
|
12
|
+
import type {BaseRunType} from './baseRunTypes.ts';
|
|
13
|
+
import type {JitErrorsFnCompiler, JitFnCompiler} from './jitFnCompiler.ts';
|
|
14
|
+
import type {BaseRunTypeFormat} from './baseRunTypeFormat.ts';
|
|
15
|
+
import {toLiteralInContext} from './utils.ts';
|
|
16
|
+
|
|
17
|
+
// ################# REGISTER FORMATTERS & PURE FUNCTIONS #################
|
|
18
|
+
|
|
19
|
+
const typeAnnotationsCache = new Map<string, BaseRunTypeFormat>();
|
|
20
|
+
const formatterPrefix = 'f';
|
|
21
|
+
|
|
22
|
+
/** Adds a TypeFormatter or TypeValidator to the formatters cache */
|
|
23
|
+
export function registerFormatter<T extends BaseRunTypeFormat>(operation: T, shouldThrow = false): T {
|
|
24
|
+
const id = getFormatterKey(formatterPrefix, operation.kind, operation.name);
|
|
25
|
+
const exiting = typeAnnotationsCache.get(id);
|
|
26
|
+
if (exiting && exiting !== operation) {
|
|
27
|
+
if (shouldThrow)
|
|
28
|
+
throw new Error(`Annotation type ${operation.name} already registered for ${ReflectionKindName[operation.kind]}`);
|
|
29
|
+
return operation;
|
|
30
|
+
}
|
|
31
|
+
typeAnnotationsCache.set(id, operation);
|
|
32
|
+
return operation;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Gets a TypeFormatter or TypeValidator to the formatters cache */
|
|
36
|
+
export function getFormatterFromCache(
|
|
37
|
+
typeKind: ReflectionKind,
|
|
38
|
+
name: string,
|
|
39
|
+
shouldThrow = false
|
|
40
|
+
): BaseRunTypeFormat | undefined {
|
|
41
|
+
const formatter = typeAnnotationsCache.get(getFormatterKey(formatterPrefix, typeKind, name));
|
|
42
|
+
if (!formatter) {
|
|
43
|
+
if (shouldThrow) throw new Error(`Annotation type ${name} not found for ${ReflectionKindName[typeKind]}`);
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return formatter;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function getFormatterKey(prefix: string, kind: string | number, name: string | number): string {
|
|
50
|
+
return `${prefix}:${kind}:${name}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Returns the validator for a given type. ATM only one validator is allowed for each type */
|
|
54
|
+
export function getRunTypeFormat(rt: BaseRunType): BaseRunTypeFormat | undefined {
|
|
55
|
+
return getFormatAnnotation(rt)?.formatter;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getRunTypeTransformer(rt: BaseRunType): BaseRunTypeFormat | undefined {
|
|
59
|
+
const rtFormat = getRunTypeFormat(rt);
|
|
60
|
+
if (rtFormat?.emitFormat) return rtFormat;
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// ################# ANNOTATIONS #################
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Reads deepkit annotations and augment them with the associated formatters.
|
|
68
|
+
* @param rt
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
export function initFormatAnnotations(rt: BaseRunType): FormatAnnotation | undefined {
|
|
72
|
+
const annotations = typeAnnotation.getAnnotations(rt.src);
|
|
73
|
+
if (annotations.length === 0) return;
|
|
74
|
+
if (annotations.length > 1)
|
|
75
|
+
throw new Error(`Only one type annotation is allowed for runTypes and ${rt.getTypeName()} has ${annotations.length}`);
|
|
76
|
+
const annotation = annotations[0] as FormatAnnotation;
|
|
77
|
+
if (!annotation.name) throw new Error(`Type annotation must have a name for ${rt.getTypeName()}`);
|
|
78
|
+
const params = annotation.options;
|
|
79
|
+
const formatter = getFormatterFromCache(rt.src.kind, annotation.name);
|
|
80
|
+
// formatter property is only added to registered formatters, this allows using other type annotations that are not formatters
|
|
81
|
+
if (formatter && params.kind === ReflectionKind.objectLiteral) {
|
|
82
|
+
annotation.formatter = formatter;
|
|
83
|
+
return annotation;
|
|
84
|
+
}
|
|
85
|
+
return annotation as FormatAnnotation;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Returns the params for a given type formatter */
|
|
89
|
+
export function getFormatterParams<P extends TypeFormatParams>(rt: BaseRunType, fmtName: string): P {
|
|
90
|
+
const annotation = getFormatAnnotation(rt);
|
|
91
|
+
if (annotation?.name === fmtName) {
|
|
92
|
+
if (annotation.params) return annotation.params as P;
|
|
93
|
+
annotation.params = typeAnnotation.getOption(rt.src, annotation.name) as P;
|
|
94
|
+
return annotation.params as P;
|
|
95
|
+
}
|
|
96
|
+
throw new Error(`Type Formatter ${fmtName} not found for ${rt.getTypeName()}`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function getFormatAnnotation(rt: BaseRunType): FormatAnnotation | undefined {
|
|
100
|
+
const parsedAnnotations = typeAnnotation.getAnnotations(rt.src);
|
|
101
|
+
const formatAnnotations = parsedAnnotations.filter((a) => (a as FormatAnnotation).formatter);
|
|
102
|
+
return formatAnnotations[0] as FormatAnnotation | undefined;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ################# COMPILING #################
|
|
106
|
+
|
|
107
|
+
// TODO, read ignoreProps from multiple formatters, rather than a constant here
|
|
108
|
+
export const defaultIgnoreFormatProps = ['mockSamples'];
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Transforms a params object into a literal string to be used in JIT code.
|
|
112
|
+
* ie: {total: 5, name: 'hello'} gets transformed into teh string '{total: 5, name: "hello"}' that can be used as JIT code.
|
|
113
|
+
* Some literals are automatically added to the context to reduce code size. in this case the reference to the context variable is returned.
|
|
114
|
+
*
|
|
115
|
+
* @param comp
|
|
116
|
+
* @param params
|
|
117
|
+
* @param ignoreProps
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
120
|
+
export function paramsToLiteral(comp: JitFnCompiler | JitErrorsFnCompiler, params: TypeFormatValue, ignoreProps?: string[]) {
|
|
121
|
+
return toLiteralInContext(comp, params, ignoreProps, false);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function getToLiteralFn(comp: JitFnCompiler | JitErrorsFnCompiler, ignoreProps?: string[]) {
|
|
125
|
+
return (params: TypeFormatValue) => paramsToLiteral(comp, params, ignoreProps);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Transforms a dependencies object into a string literal that can be used as JIT code.
|
|
130
|
+
* Dependencies object can contain pure functions or code.
|
|
131
|
+
* Pure functions will be load as dependency using jitUtils.getPureFn, and code will be left as is.
|
|
132
|
+
* ie: {helloFn: function hello(){}, code: 'v + 2'} gets transformed into the string '{helloFn: utl.getPureFn("hello"), code: v + 2}'
|
|
133
|
+
* @param comp
|
|
134
|
+
* @param params
|
|
135
|
+
* @param ignoreProps
|
|
136
|
+
* @returns
|
|
137
|
+
*/
|
|
138
|
+
export function dependenciesToLiteral(
|
|
139
|
+
comp: JitFnCompiler | JitErrorsFnCompiler,
|
|
140
|
+
params: Record<string, string | CompiledPureFunction>,
|
|
141
|
+
ignoreProps: string[] = []
|
|
142
|
+
) {
|
|
143
|
+
return toLiteralInContext(comp, params, ignoreProps, true);
|
|
144
|
+
}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/* eslint-disable no-case-declarations */
|
|
2
|
+
/* ########
|
|
3
|
+
* 2024 mion
|
|
4
|
+
* Author: Ma-jerez
|
|
5
|
+
* License: MIT
|
|
6
|
+
* The software is provided "as is", without warranty of any kind.
|
|
7
|
+
* ######## */
|
|
8
|
+
|
|
9
|
+
import type {Type, TypeClass, TypeMethod, TypeObjectLiteral, TypeParameter} from '@deepkit/type';
|
|
10
|
+
import type {AnyClass, FormatParamMeta, TypeFormatValue} from '@mionjs/core';
|
|
11
|
+
import {isType, ReflectionKind} from '@deepkit/type';
|
|
12
|
+
import {ReflectionSubKind} from '../constants.kind.ts';
|
|
13
|
+
import {nativeUtilityStringTypes, nonSerializableClasses, nonSerializableGlobals} from '../constants.ts';
|
|
14
|
+
import {JitFunctions} from '../constants.functions.ts';
|
|
15
|
+
/* IMPORTANT: import classes as type only to prevent js circular imports */
|
|
16
|
+
import type {RunType, RunTypeChildAccessor} from '../types.ts';
|
|
17
|
+
import type {StringRunType} from '../nodes/atomic/string.ts';
|
|
18
|
+
import type {DateRunType} from '../nodes/atomic/date.ts';
|
|
19
|
+
import type {NumberRunType} from '../nodes/atomic/number.ts';
|
|
20
|
+
import type {BooleanRunType} from '../nodes/atomic/boolean.ts';
|
|
21
|
+
import type {NullRunType} from '../nodes/atomic/null.ts';
|
|
22
|
+
import type {BigIntRunType} from '../nodes/atomic/bigInt.ts';
|
|
23
|
+
import type {AnyRunType} from '../nodes/atomic/any.ts';
|
|
24
|
+
import type {UndefinedRunType} from '../nodes/atomic/undefined.ts';
|
|
25
|
+
import type {UnknownRunType} from '../nodes/atomic/unknown.ts';
|
|
26
|
+
import type {VoidRunType} from '../nodes/atomic/void.ts';
|
|
27
|
+
import type {ArrayRunType} from '../nodes/member/array.ts';
|
|
28
|
+
import type {LiteralRunType} from '../nodes/atomic/literal.ts';
|
|
29
|
+
import type {RegexpRunType} from '../nodes/atomic/regexp.ts';
|
|
30
|
+
import type {NeverRunType} from '../nodes/atomic/never.ts';
|
|
31
|
+
import type {EnumRunType} from '../nodes/atomic/enum.ts';
|
|
32
|
+
import type {EnumMemberRunType} from '../nodes/atomic/enumMember.ts';
|
|
33
|
+
import type {UnionRunType} from '../nodes/collection/union.ts';
|
|
34
|
+
import type {TupleRunType} from '../nodes/collection/tuple.ts';
|
|
35
|
+
import type {TupleMemberRunType} from '../nodes/member/tupleMember.ts';
|
|
36
|
+
import type {InterfaceRunType, InterfaceMember} from '../nodes/collection/interface.ts';
|
|
37
|
+
import type {PropertyRunType} from '../nodes/member/property.ts';
|
|
38
|
+
import type {IndexSignatureRunType} from '../nodes/member/indexProperty.ts';
|
|
39
|
+
import type {MethodSignatureRunType} from '../nodes/member/methodSignature.ts';
|
|
40
|
+
import type {CallSignatureRunType} from '../nodes/member/callSignature.ts';
|
|
41
|
+
import type {FunctionRunType} from '../nodes/function/function.ts';
|
|
42
|
+
import type {FunctionParamsRunType} from '../nodes/collection/functionParams.ts';
|
|
43
|
+
import type {ParameterRunType} from '../nodes/member/param.ts';
|
|
44
|
+
import type {PromiseRunType} from '../nodes/native/promise.ts';
|
|
45
|
+
import type {ObjectRunType} from '../nodes/atomic/object.ts';
|
|
46
|
+
import type {MethodRunType} from '../nodes/member/method.ts';
|
|
47
|
+
import type {AtomicRunType, CollectionRunType, MemberRunType} from './baseRunTypes.ts';
|
|
48
|
+
import type {BaseFnCompiler, JitErrorsFnCompiler} from './jitFnCompiler.ts';
|
|
49
|
+
import type {ClassRunType} from '../nodes/collection/class.ts';
|
|
50
|
+
import type {IntersectionRunType} from '../nodes/collection/intersection.ts';
|
|
51
|
+
import type {SymbolRunType} from '../nodes/atomic/symbol.ts';
|
|
52
|
+
|
|
53
|
+
export function isAnyRunType(rt: RunType): rt is AnyRunType {
|
|
54
|
+
return rt.src.kind === ReflectionKind.any;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function isArrayRunType(rt: RunType): rt is ArrayRunType {
|
|
58
|
+
return rt.src.kind === ReflectionKind.array;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function isBigIntRunType(rt: RunType): rt is BigIntRunType {
|
|
62
|
+
return rt.src.kind === ReflectionKind.bigint;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function isBooleanRunType(rt: RunType): rt is BooleanRunType {
|
|
66
|
+
return rt.src.kind === ReflectionKind.boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function isCallSignatureRunType(rt: RunType): rt is CallSignatureRunType {
|
|
70
|
+
return rt.src.kind === ReflectionKind.callSignature;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function isDateRunType(rt: RunType): rt is DateRunType {
|
|
74
|
+
return rt.getTypeID() === ReflectionSubKind.date;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function isEnumRunType(rt: RunType): rt is EnumRunType {
|
|
78
|
+
return rt.src.kind === ReflectionKind.enum;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function isEnumMemberRunType(rt: RunType): rt is EnumMemberRunType {
|
|
82
|
+
return rt.src.kind === ReflectionKind.enumMember;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function isFunctionRunType(rt: RunType): rt is FunctionRunType<any> {
|
|
86
|
+
return rt.src.kind === ReflectionKind.function;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function isFunctionParamsRunType(rt: RunType): rt is FunctionParamsRunType {
|
|
90
|
+
return rt.src.subKind === ReflectionSubKind.params;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function isAnyFunctionRunType(rt: RunType): rt is FunctionRunType<any> {
|
|
94
|
+
return (rt.src as any).return?.kind !== undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function isIndexSignatureRunType(rt: RunType): rt is IndexSignatureRunType {
|
|
98
|
+
return rt.src.kind === ReflectionKind.indexSignature;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function isLiteralRunType(rt: RunType): rt is LiteralRunType {
|
|
102
|
+
return rt.src.kind === ReflectionKind.literal;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function isMethodSignatureRunType(rt: RunType): rt is MethodSignatureRunType {
|
|
106
|
+
return rt.src.kind === ReflectionKind.methodSignature;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function isNullRunType(rt: RunType): rt is NullRunType {
|
|
110
|
+
return rt.src.kind === ReflectionKind.null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function isNumberRunType(rt: RunType): rt is NumberRunType {
|
|
114
|
+
return rt.src.kind === ReflectionKind.number;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function isInterfaceRunType(rt: RunType): rt is InterfaceRunType {
|
|
118
|
+
return rt.src.kind === ReflectionKind.objectLiteral;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function isObjectLiteralRunType(rt: RunType): rt is InterfaceRunType {
|
|
122
|
+
return rt.src.kind === ReflectionKind.objectLiteral;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function isClassRunType(rt: RunType, cls?: string | AnyClass): rt is ClassRunType {
|
|
126
|
+
const isClassRt = rt.src.kind === ReflectionKind.class && rt.src.subKind !== ReflectionSubKind.date;
|
|
127
|
+
if (!cls) return isClassRt;
|
|
128
|
+
return isClassRt && (rt.src.classType === cls || rt.src.classType.name === cls);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function isIntersectionRunType(rt: RunType): rt is IntersectionRunType {
|
|
132
|
+
return rt.src.kind === ReflectionKind.intersection;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function isPropertyRunType(rt: RunType): rt is PropertyRunType {
|
|
136
|
+
return rt.src.kind === ReflectionKind.property;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function isPropertySignatureRunType(rt: RunType): rt is PropertyRunType {
|
|
140
|
+
return rt.src.kind === ReflectionKind.propertySignature;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function isRegexpRunType(rt: RunType): rt is RegexpRunType {
|
|
144
|
+
return rt.src.kind === ReflectionKind.regexp;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function isStringRunType(rt: RunType): rt is StringRunType {
|
|
148
|
+
return rt.src.kind === ReflectionKind.string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function isSymbolRunType(rt: RunType): rt is SymbolRunType {
|
|
152
|
+
return rt.src.kind === ReflectionKind.symbol;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function isTupleRunType(rt: RunType): rt is TupleRunType {
|
|
156
|
+
return rt.src.kind === ReflectionKind.tuple;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function isTupleMemberRunType(rt: RunType): rt is TupleMemberRunType {
|
|
160
|
+
return rt.src.kind === ReflectionKind.tupleMember;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function isUndefinedRunType(rt: RunType): rt is UndefinedRunType {
|
|
164
|
+
return rt.src.kind === ReflectionKind.undefined;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function isUnionRunType(rt: RunType): rt is UnionRunType {
|
|
168
|
+
return rt.src.kind === ReflectionKind.union;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function isUnknownRunType(rt: RunType): rt is UnknownRunType {
|
|
172
|
+
return rt.src.kind === ReflectionKind.unknown;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function isVoidRunType(rt: RunType): rt is VoidRunType {
|
|
176
|
+
return rt.src.kind === ReflectionKind.void;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function isNeverRunType(rt: RunType): rt is NeverRunType {
|
|
180
|
+
return rt.src.kind === ReflectionKind.never;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function isObjectRunType(rt: RunType): rt is ObjectRunType {
|
|
184
|
+
return rt.src.kind === ReflectionKind.object;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function isParameterRunType(rt: RunType): rt is ParameterRunType {
|
|
188
|
+
return rt.src.kind === ReflectionKind.parameter;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function isPromiseRunType(rt: RunType): rt is PromiseRunType {
|
|
192
|
+
return rt.src.kind === ReflectionKind.promise;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function isConstructor(rt: InterfaceMember): rt is MethodSignatureRunType | MethodRunType {
|
|
196
|
+
return (
|
|
197
|
+
(rt.src.kind === ReflectionKind.method || rt.src.kind === ReflectionKind.methodSignature) &&
|
|
198
|
+
(rt.src as TypeMethod).name === 'constructor'
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function isChildAccessorType(rt: RunType): rt is RunTypeChildAccessor {
|
|
203
|
+
return !!(rt as any as RunTypeChildAccessor).getChildVarName && !!(rt as any as RunTypeChildAccessor).getChildLiteral;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function isAtomicRunType(rt: RunType): rt is AtomicRunType<any> {
|
|
207
|
+
return rt.getFamily() === 'A';
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function isCollectionRunType(rt: RunType): rt is CollectionRunType<any> {
|
|
211
|
+
return rt.getFamily() === 'C';
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function isMemberRunType(rt: RunType): rt is MemberRunType<any> {
|
|
215
|
+
return rt.getFamily() === 'M';
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function isRunType(value: any): value is RunType {
|
|
219
|
+
return typeof value?.src?.kind === 'number' && typeof value?.getTypeID === 'function';
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function isJitErrorsCompiler(value: BaseFnCompiler): value is JitErrorsFnCompiler {
|
|
223
|
+
return value.fnID === JitFunctions.typeErrors.id || value.fnID === JitFunctions.unknownKeyErrors.id;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export function isNonSerializableClass(src: TypeClass): boolean {
|
|
227
|
+
return nonSerializableClasses.includes(src.classType);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export function isNonSerializableObject(src: TypeObjectLiteral): boolean {
|
|
231
|
+
if (!src.typeName) return false;
|
|
232
|
+
return nonSerializableGlobals.includes(src.typeName);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function isNativeUtilityStringTypes(src: Type): boolean {
|
|
236
|
+
if (!src.typeName) return false;
|
|
237
|
+
return nativeUtilityStringTypes.includes(src.typeName);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function hasType(src: any): src is {type: Type} {
|
|
241
|
+
return isType(src?.type);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function hasTypes(src: any): src is {types: Type[]} {
|
|
245
|
+
return Array.isArray(src?.types) && isType(src);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export function hasReturn(src: any): src is {return: Type} {
|
|
249
|
+
return isType(src?.return);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function hasParameters(src: any): src is {parameters: Type[]} {
|
|
253
|
+
return Array.isArray(src?.parameters) && isType(src);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function hasIndexType(src: any): src is {indexType: Type} {
|
|
257
|
+
return isType(src?.indexType);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export function hasArguments(src: any): src is {arguments: Type[]} {
|
|
261
|
+
return Array.isArray(src?.arguments) && isType(src);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export function hasExtends(src: any): src is {extends: Type[]} {
|
|
265
|
+
return Array.isArray(src?.extends) && isType(src);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export function hasExtendsArguments(src: any): src is {extendsArguments: Type[]} {
|
|
269
|
+
return Array.isArray(src?.extendsArguments) && isType(src);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export function hasTypeArguments(src: any): src is {typeArguments: Type[]} {
|
|
273
|
+
return Array.isArray(src?.typeArguments) && isType(src);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export function hasTypeParameters(src: any): src is {typeParameters: TypeParameter[]} {
|
|
277
|
+
return Array.isArray(src?.typeParameters) && isType(src);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export function hasMembers(src: any): src is {members: InterfaceMember[]} {
|
|
281
|
+
return Array.isArray(src?.members) && isType(src);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export function hasImplements(src: any): src is {implements: Type[]} {
|
|
285
|
+
return Array.isArray(src?.implements) && isType(src);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function isFormatParamMeta(src: TypeFormatValue): src is FormatParamMeta {
|
|
289
|
+
return (src as FormatParamMeta)?.val !== undefined;
|
|
290
|
+
}
|