@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,125 @@
|
|
|
1
|
+
import {ReflectionKind, TypeIndexSignature} from '@deepkit/type';
|
|
2
|
+
import {MemberRunType} from '../../lib/baseRunTypes.ts';
|
|
3
|
+
import {type JitCode} from '../../types.ts';
|
|
4
|
+
import {JitFunctions} from '../../constants.functions.ts';
|
|
5
|
+
import type {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';
|
|
6
|
+
import {InterfaceRunType} from '../collection/interface.ts';
|
|
7
|
+
import {childIsExpression} from '../../lib/utils.ts';
|
|
8
|
+
|
|
9
|
+
/* ########
|
|
10
|
+
* 2024 mion
|
|
11
|
+
* Author: Ma-jerez
|
|
12
|
+
* License: MIT
|
|
13
|
+
* The software is provided "as is", without warranty of any kind.
|
|
14
|
+
* ######## */
|
|
15
|
+
|
|
16
|
+
export class IndexSignatureRunType extends MemberRunType<TypeIndexSignature> {
|
|
17
|
+
isOptional(): boolean {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
getChildVarName(comp: JitFnCompiler): string {
|
|
21
|
+
return comp.getLocalVarName('p', this);
|
|
22
|
+
}
|
|
23
|
+
getChildLiteral(comp: JitFnCompiler): string {
|
|
24
|
+
return this.getChildVarName(comp);
|
|
25
|
+
}
|
|
26
|
+
useArrayAccessor(): true {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
skipJit(comp: JitFnCompiler): boolean {
|
|
30
|
+
const index = (this.src as TypeIndexSignature).index?.kind;
|
|
31
|
+
if (index === ReflectionKind.symbol) {
|
|
32
|
+
return comp?.fnID !== JitFunctions.toJSCode.id;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// #### jit code ####
|
|
38
|
+
emitIsType(comp: JitFnCompiler): JitCode {
|
|
39
|
+
const child = this.getJitChild(comp);
|
|
40
|
+
const childJit = comp.compileIsType(child, 'E');
|
|
41
|
+
if (!childJit?.code) return {code: undefined, type: 'E'};
|
|
42
|
+
return {
|
|
43
|
+
code: `for (const ${this.getChildVarName(comp)} in ${comp.vλl}){if (!(${childJit.code})) return false;} return true;`,
|
|
44
|
+
type: 'RB',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {
|
|
48
|
+
const child = this.getJitChild(comp);
|
|
49
|
+
const childJit = comp.compileTypeErrors(child, 'S');
|
|
50
|
+
if (!childJit?.code) return {code: undefined, type: 'S'};
|
|
51
|
+
return {code: `for (const ${this.getChildVarName(comp)} in ${comp.vλl}) {${childJit.code}}`, type: 'S'};
|
|
52
|
+
}
|
|
53
|
+
emitPrepareForJson(comp: JitFnCompiler): JitCode {
|
|
54
|
+
const child = this.getJitChild(comp);
|
|
55
|
+
const childJit = comp.compilePrepareForJson(child, 'S');
|
|
56
|
+
if (!child || !childJit?.code) return {code: undefined, type: 'S'};
|
|
57
|
+
const varName = comp.vλl;
|
|
58
|
+
const prop = this.getChildVarName(comp);
|
|
59
|
+
const skipCode = this.getSkipCode(comp, prop);
|
|
60
|
+
const isExpression = childIsExpression(childJit, child);
|
|
61
|
+
const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';
|
|
62
|
+
return {code: `for (const ${prop} in ${varName}){${skipCode} ${code}}`, type: 'S'};
|
|
63
|
+
}
|
|
64
|
+
emitRestoreFromJson(comp: JitFnCompiler): JitCode {
|
|
65
|
+
const child = this.getJitChild(comp);
|
|
66
|
+
const childJit = comp.compileRestoreFromJson(child, 'S');
|
|
67
|
+
if (!child || !childJit?.code) return {code: undefined, type: 'S'};
|
|
68
|
+
const varName = comp.vλl;
|
|
69
|
+
const prop = this.getChildVarName(comp);
|
|
70
|
+
const skipCode = this.getSkipCode(comp, prop);
|
|
71
|
+
const isExpression = childIsExpression(childJit, child);
|
|
72
|
+
const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';
|
|
73
|
+
return {code: `for (const ${prop} in ${varName}){${skipCode} ${code}}`, type: 'S'};
|
|
74
|
+
}
|
|
75
|
+
emitHasUnknownKeys(comp: JitFnCompiler): JitCode {
|
|
76
|
+
if (this.getMemberType().getFamily() === 'A') return {code: undefined, type: 'E'};
|
|
77
|
+
const child = this.getJitChild(comp);
|
|
78
|
+
const childJit = comp.compileHasUnknownKeys(child, 'E');
|
|
79
|
+
if (!childJit?.code) return {code: '', type: 'E'};
|
|
80
|
+
const varName = comp.vλl;
|
|
81
|
+
const prop = this.getChildVarName(comp);
|
|
82
|
+
const resultVal = comp.getLocalVarName('res', this);
|
|
83
|
+
return {
|
|
84
|
+
code: `for (const ${prop} in ${varName}) {const ${resultVal} = ${childJit.code};if (${resultVal}) return true;}return false;`,
|
|
85
|
+
type: 'RB',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
emitUnknownKeyErrors(comp: JitErrorsFnCompiler): JitCode {
|
|
89
|
+
if (this.getMemberType().getFamily() === 'A') return {code: undefined, type: 'S'};
|
|
90
|
+
const child = this.getJitChild(comp);
|
|
91
|
+
const childJit = comp.compileUnknownKeyErrors(child, 'S');
|
|
92
|
+
return this.traverseCode(comp, childJit);
|
|
93
|
+
}
|
|
94
|
+
emitStripUnknownKeys(comp: JitFnCompiler): JitCode {
|
|
95
|
+
if (this.getMemberType().getFamily() === 'A') return {code: undefined, type: 'S'};
|
|
96
|
+
const child = this.getJitChild(comp);
|
|
97
|
+
const childJit = comp.compileStripUnknownKeys(child, 'S');
|
|
98
|
+
return this.traverseCode(comp, childJit);
|
|
99
|
+
}
|
|
100
|
+
emitUnknownKeysToUndefined(comp: JitFnCompiler): JitCode {
|
|
101
|
+
if (this.getMemberType().getFamily() === 'A') return {code: undefined, type: 'S'};
|
|
102
|
+
const child = this.getJitChild(comp);
|
|
103
|
+
const childJit = comp.compileUnknownKeysToUndefined(child, 'S');
|
|
104
|
+
return this.traverseCode(comp, childJit);
|
|
105
|
+
}
|
|
106
|
+
traverseCode(comp: JitFnCompiler, childJit: JitCode | undefined): JitCode {
|
|
107
|
+
if (!childJit?.code) return {code: undefined, type: 'S'};
|
|
108
|
+
const prop = this.getChildVarName(comp);
|
|
109
|
+
return {code: `for (const ${prop} in ${comp.vλl}) {${childJit.code}}`, type: 'S'};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* if index property should be skipped then it output some code to skip it,
|
|
113
|
+
* this happen when an object/interface has an index property but also has named properties
|
|
114
|
+
* that might collide with the index property. ie {[key: string]: string, a: string}
|
|
115
|
+
* when executing the logic for the index property we need to skip the named properties.
|
|
116
|
+
*/
|
|
117
|
+
getSkipCode(comp: JitFnCompiler, prop: string): string {
|
|
118
|
+
const parent = this.getParent() as InterfaceRunType;
|
|
119
|
+
const namedChildren = parent.getNamedChildren(comp);
|
|
120
|
+
const skipNames = namedChildren.length
|
|
121
|
+
? namedChildren.map((child) => `${child.getChildLiteral(comp)} === ${prop}`).join(' || ')
|
|
122
|
+
: '';
|
|
123
|
+
return namedChildren.length ? `if (${skipNames}) continue;` : '';
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2024 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
import {TypeMethod} from '@deepkit/type';
|
|
8
|
+
import {FunctionRunType} from '../function/function.ts';
|
|
9
|
+
import {RunTypeChildAccessor} from '../../types.ts';
|
|
10
|
+
import {getPropIndex, getPropLiteral, getPropVarName, useArrayAccessorForProp} from '../../lib/utils.ts';
|
|
11
|
+
import type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';
|
|
12
|
+
|
|
13
|
+
export class MethodRunType extends FunctionRunType<TypeMethod> implements RunTypeChildAccessor {
|
|
14
|
+
getChildIndex = (comp: JitFnCompiler) => {
|
|
15
|
+
const start = comp?.opts?.paramsSlice?.start;
|
|
16
|
+
if (start) return getPropIndex(this.src) - start;
|
|
17
|
+
return getPropIndex(this.src);
|
|
18
|
+
};
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
+
getChildVarName(comp: JitFnCompiler) {
|
|
21
|
+
return getPropVarName(this.src.name);
|
|
22
|
+
}
|
|
23
|
+
getChildLiteral(comp: JitFnCompiler) {
|
|
24
|
+
return getPropLiteral(this.getChildVarName(comp));
|
|
25
|
+
}
|
|
26
|
+
useArrayAccessor() {
|
|
27
|
+
return useArrayAccessorForProp(this.src.name);
|
|
28
|
+
}
|
|
29
|
+
isOptional = () => !!this.src.optional;
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2024 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
import {TypeMethodSignature} from '@deepkit/type';
|
|
8
|
+
import {RunTypeChildAccessor} from '../../types.ts';
|
|
9
|
+
import {FunctionRunType} from '../function/function.ts';
|
|
10
|
+
import {getPropIndex, getPropLiteral, getPropVarName, useArrayAccessorForProp} from '../../lib/utils.ts';
|
|
11
|
+
import type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';
|
|
12
|
+
|
|
13
|
+
export class MethodSignatureRunType extends FunctionRunType<TypeMethodSignature> implements RunTypeChildAccessor {
|
|
14
|
+
getChildIndex = (comp: JitFnCompiler) => {
|
|
15
|
+
const start = comp?.opts?.paramsSlice?.start;
|
|
16
|
+
if (start) return getPropIndex(this.src) - start;
|
|
17
|
+
return getPropIndex(this.src);
|
|
18
|
+
};
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
+
getChildVarName(comp: JitFnCompiler) {
|
|
21
|
+
return getPropVarName(this.src.name);
|
|
22
|
+
}
|
|
23
|
+
getChildLiteral(comp: JitFnCompiler) {
|
|
24
|
+
return getPropLiteral(this.getChildVarName(comp));
|
|
25
|
+
}
|
|
26
|
+
useArrayAccessor() {
|
|
27
|
+
return useArrayAccessorForProp(this.src.name);
|
|
28
|
+
}
|
|
29
|
+
isOptional = () => !!this.src.optional;
|
|
30
|
+
skipCommas = false;
|
|
31
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2024 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
|
|
8
|
+
import type {TypeParameter} from '@deepkit/type';
|
|
9
|
+
import type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';
|
|
10
|
+
import {TupleMemberRunType} from './tupleMember.ts';
|
|
11
|
+
|
|
12
|
+
export class ParameterRunType<T extends TypeParameter = TypeParameter> extends TupleMemberRunType<T> {
|
|
13
|
+
getParamName() {
|
|
14
|
+
return this.src.name;
|
|
15
|
+
}
|
|
16
|
+
getChildVarName(comp: JitFnCompiler): number {
|
|
17
|
+
return this.getChildIndex(comp);
|
|
18
|
+
}
|
|
19
|
+
getChildLiteral(comp: JitFnCompiler): number {
|
|
20
|
+
return this.getChildIndex(comp);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2024 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
|
|
8
|
+
import type {TypeProperty, TypePropertySignature} from '@deepkit/type';
|
|
9
|
+
import type {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';
|
|
10
|
+
import type {JitCode} from '../../types.ts';
|
|
11
|
+
import {childIsExpression, getPropLiteral, getPropVarName, useArrayAccessorForProp} from '../../lib/utils.ts';
|
|
12
|
+
import {MemberRunType} from '../../lib/baseRunTypes.ts';
|
|
13
|
+
import {InterfaceRunType} from '../collection/interface.ts';
|
|
14
|
+
import {JitFunctions} from '../../constants.functions.ts';
|
|
15
|
+
|
|
16
|
+
export class PropertyRunType extends MemberRunType<TypePropertySignature | TypeProperty> {
|
|
17
|
+
isUnionDiscriminator = false;
|
|
18
|
+
/** this is set by the parent interface if prop is optional, when optional properties are sorted */
|
|
19
|
+
optionalIndex = -1;
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
|
+
getPropertyName() {
|
|
22
|
+
return getPropVarName(this.src.name);
|
|
23
|
+
}
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
|
+
getChildVarName(comp: JitFnCompiler) {
|
|
26
|
+
return getPropVarName(this.src.name);
|
|
27
|
+
}
|
|
28
|
+
getChildLiteral(comp: JitFnCompiler) {
|
|
29
|
+
return getPropLiteral(this.getChildVarName(comp));
|
|
30
|
+
}
|
|
31
|
+
useArrayAccessor() {
|
|
32
|
+
return useArrayAccessorForProp(this.src.name);
|
|
33
|
+
}
|
|
34
|
+
getJitChildIndex = (comp: JitFnCompiler) => (this.getParent() as InterfaceRunType).getJitChildren(comp).indexOf(this);
|
|
35
|
+
isOptional = () => !!this.src.optional;
|
|
36
|
+
skipJit(comp: JitFnCompiler): boolean {
|
|
37
|
+
const name = (this.src as TypeProperty).name;
|
|
38
|
+
if (typeof name === 'symbol') {
|
|
39
|
+
return comp?.fnID !== JitFunctions.toJSCode.id;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
// #### jit code ####
|
|
44
|
+
|
|
45
|
+
emitIsType(comp: JitFnCompiler): JitCode {
|
|
46
|
+
const child = this.getJitChild(comp);
|
|
47
|
+
const childJit = comp.compileIsType(child, 'E');
|
|
48
|
+
if (!childJit?.code) return {code: undefined, type: 'E'};
|
|
49
|
+
return this.src.optional ? {code: `(${comp.getChildVλl()} === undefined || ${childJit.code})`, type: 'E'} : childJit;
|
|
50
|
+
}
|
|
51
|
+
emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {
|
|
52
|
+
const child = this.getJitChild(comp);
|
|
53
|
+
const childJit = comp.compileTypeErrors(child, 'S');
|
|
54
|
+
if (!childJit?.code) return {code: undefined, type: 'S'};
|
|
55
|
+
return this.src.optional ? {code: `if (${comp.getChildVλl()} !== undefined) {${childJit.code}}`, type: 'S'} : childJit;
|
|
56
|
+
}
|
|
57
|
+
emitPrepareForJson(comp: JitFnCompiler): JitCode {
|
|
58
|
+
const child = this.getJitChild(comp);
|
|
59
|
+
const childJit = comp.compilePrepareForJson(child, 'S');
|
|
60
|
+
if (!child || !childJit?.code) return {code: undefined, type: 'S'};
|
|
61
|
+
const isExpression = childIsExpression(childJit, child);
|
|
62
|
+
const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';
|
|
63
|
+
if (this.src.optional) return {code: `if (${comp.getChildVλl()} !== undefined) {${code}}`, type: 'S'};
|
|
64
|
+
return {code, type: 'S'};
|
|
65
|
+
}
|
|
66
|
+
emitRestoreFromJson(comp: JitFnCompiler): JitCode {
|
|
67
|
+
const child = this.getJitChild(comp);
|
|
68
|
+
const childJit = comp.compileRestoreFromJson(child, 'S');
|
|
69
|
+
if (!child || !childJit?.code) return {code: undefined, type: 'S'};
|
|
70
|
+
const isExpression = childIsExpression(childJit, child);
|
|
71
|
+
const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';
|
|
72
|
+
if (this.src.optional) return {code: `if (${comp.getChildVλl()} !== undefined) {${code}}`, type: 'S'};
|
|
73
|
+
return {code, type: 'S'};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2024 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
|
|
8
|
+
import type {TypeRest} from '@deepkit/type';
|
|
9
|
+
import type {ParameterRunType} from './param.ts';
|
|
10
|
+
import type {TupleMemberRunType} from './tupleMember.ts';
|
|
11
|
+
import {ArrayRunType} from './array.ts';
|
|
12
|
+
import type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';
|
|
13
|
+
|
|
14
|
+
export class RestParamsRunType extends ArrayRunType<TypeRest> {
|
|
15
|
+
getChildIndex(comp: JitFnCompiler): number {
|
|
16
|
+
const parent = this.getParent() as ParameterRunType | TupleMemberRunType;
|
|
17
|
+
return parent.getChildIndex(comp);
|
|
18
|
+
}
|
|
19
|
+
startIndex(comp: JitFnCompiler): number {
|
|
20
|
+
return this.getChildIndex(comp);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2024 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
|
|
8
|
+
import {ReflectionKind, TypeTupleMember, type TypeParameter} from '@deepkit/type';
|
|
9
|
+
import type {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';
|
|
10
|
+
import {MemberRunType} from '../../lib/baseRunTypes.ts';
|
|
11
|
+
import {JitCode} from '../../types.ts';
|
|
12
|
+
import {childIsExpression, getParamIndex} from '../../lib/utils.ts';
|
|
13
|
+
|
|
14
|
+
type TupleMemberT = TypeParameter | TypeTupleMember;
|
|
15
|
+
export class TupleMemberRunType<T extends TupleMemberT = TypeTupleMember> extends MemberRunType<T> {
|
|
16
|
+
isOptional(): boolean {
|
|
17
|
+
return !!this.src.optional || this.isRest() || this.hasDefaultValue();
|
|
18
|
+
}
|
|
19
|
+
getChildIndex(comp: JitFnCompiler): number {
|
|
20
|
+
const start = comp?.opts?.paramsSlice?.start;
|
|
21
|
+
if (start) return getParamIndex(this.src as TypeParameter) - start;
|
|
22
|
+
return getParamIndex(this.src as TypeParameter);
|
|
23
|
+
}
|
|
24
|
+
getChildVarName(comp: JitFnCompiler): number {
|
|
25
|
+
// For tuple members, use the index in the parent tuple
|
|
26
|
+
const src = this.src as any;
|
|
27
|
+
if (src.parent?.types) {
|
|
28
|
+
return src.parent.types.indexOf(this.src);
|
|
29
|
+
}
|
|
30
|
+
// Fallback to parameter index for non-tuple members
|
|
31
|
+
return this.getChildIndex(comp);
|
|
32
|
+
}
|
|
33
|
+
getChildLiteral(comp: JitFnCompiler): number {
|
|
34
|
+
return this.getChildVarName(comp);
|
|
35
|
+
}
|
|
36
|
+
useArrayAccessor(): true {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
isRest(): boolean {
|
|
40
|
+
return this.getMemberType().src.kind === ReflectionKind.rest;
|
|
41
|
+
}
|
|
42
|
+
skipSettingAccessor() {
|
|
43
|
+
return this.isRest();
|
|
44
|
+
}
|
|
45
|
+
hasDefaultValue(): boolean {
|
|
46
|
+
return !!(this.src as TypeParameter).default;
|
|
47
|
+
}
|
|
48
|
+
emitIsType(comp: JitFnCompiler): JitCode {
|
|
49
|
+
const child = this.getJitChild(comp);
|
|
50
|
+
const skipChild = child?.skipJit(comp);
|
|
51
|
+
const childJit = comp.compileIsType(child, 'E');
|
|
52
|
+
const isNonSerializable = skipChild || (!childJit?.code && !child);
|
|
53
|
+
if (isNonSerializable) return {code: `${comp.getChildVλl()} === undefined`, type: 'E'}; // non serializable types must be undefined
|
|
54
|
+
if (!childJit?.code) return {code: undefined, type: 'E'};
|
|
55
|
+
if (this.isRest()) return childJit;
|
|
56
|
+
return this.isOptional() ? {code: `(${comp.getChildVλl()} === undefined || (${childJit.code}))`, type: 'E'} : childJit;
|
|
57
|
+
}
|
|
58
|
+
emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {
|
|
59
|
+
const child = this.getJitChild(comp);
|
|
60
|
+
const skipChild = child?.skipJit(comp);
|
|
61
|
+
const childJit = comp.compileTypeErrors(child, 'S');
|
|
62
|
+
const isNonSerializable = skipChild || (!childJit?.code && !child);
|
|
63
|
+
if (isNonSerializable)
|
|
64
|
+
return {
|
|
65
|
+
code: `if (${comp.getChildVλl()} !== undefined) ${comp.callJitErrWithPath('undefined', this.getChildIndex(comp))}`,
|
|
66
|
+
type: 'S',
|
|
67
|
+
}; // non serializable types must be undefined
|
|
68
|
+
if (!childJit?.code) return {code: undefined, type: 'S'};
|
|
69
|
+
if (this.isRest()) return childJit;
|
|
70
|
+
return this.isOptional() ? {code: `if (${comp.getChildVλl()} !== undefined) {${childJit.code}}`, type: 'S'} : childJit;
|
|
71
|
+
}
|
|
72
|
+
emitPrepareForJson(comp: JitFnCompiler): JitCode {
|
|
73
|
+
const child = this.getJitChild(comp);
|
|
74
|
+
const childJit = comp.compilePrepareForJson(child, 'S');
|
|
75
|
+
const optionalCode = `if (${comp.getChildVλl()} === undefined ) {if (${comp.vλl}.length > ${this.getChildIndex(comp)}) ${comp.getChildVλl()} = null}`;
|
|
76
|
+
if (!child || !childJit?.code) return this.isOptional() ? {code: optionalCode, type: 'S'} : {code: undefined, type: 'S'};
|
|
77
|
+
const isExpression = childIsExpression(childJit, child);
|
|
78
|
+
const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';
|
|
79
|
+
return this.isOptional() ? {code: `${optionalCode} else {${code}}`, type: 'S'} : {code, type: 'S'};
|
|
80
|
+
}
|
|
81
|
+
emitRestoreFromJson(comp: JitFnCompiler): JitCode {
|
|
82
|
+
if (!this.getJitChild(comp)) return {code: `${comp.getChildVλl()} = undefined;`, type: 'S'}; // non serializable are restored to undefined
|
|
83
|
+
const child = this.getJitChild(comp);
|
|
84
|
+
const childJit = comp.compileRestoreFromJson(child, 'S');
|
|
85
|
+
const optionalCOde = `if (${comp.getChildVλl()} === null ) {${comp.getChildVλl()} = undefined}`;
|
|
86
|
+
if (!child || !childJit?.code) return this.isOptional() ? {code: optionalCOde, type: 'S'} : {code: undefined, type: 'S'};
|
|
87
|
+
const isExpression = childIsExpression(childJit, child);
|
|
88
|
+
const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';
|
|
89
|
+
return this.isOptional()
|
|
90
|
+
? {code: `${optionalCOde} else if (${comp.getChildVλl()} !== undefined) {${code}}`, type: 'S'}
|
|
91
|
+
: {code, type: 'S'};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2024 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
import type {JitCode} from '../../types.ts';
|
|
8
|
+
import {ClassRunType} from '../collection/class.ts';
|
|
9
|
+
import {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';
|
|
10
|
+
import {BaseRunType} from '../../lib/baseRunTypes.ts';
|
|
11
|
+
|
|
12
|
+
// This is the base class for all iterable run types, like SetRunType and MapRunType
|
|
13
|
+
export abstract class IterableRunType extends ClassRunType {
|
|
14
|
+
abstract children: BaseRunType[];
|
|
15
|
+
abstract constructorName: string;
|
|
16
|
+
getIndexVarName(comp: JitFnCompiler): string {
|
|
17
|
+
return comp.getLocalVarName('e', this);
|
|
18
|
+
}
|
|
19
|
+
getChildRunTypes = (): BaseRunType[] => {
|
|
20
|
+
return this.children;
|
|
21
|
+
};
|
|
22
|
+
emitIsType(comp: JitFnCompiler): JitCode {
|
|
23
|
+
const entry = this.getCustomVλl(comp)?.vλl || comp.vλl;
|
|
24
|
+
const childrenCode = this.getJitChildren(comp)
|
|
25
|
+
.map((c) => `if (!(${comp.compileIsType(c, 'E').code})) return false`)
|
|
26
|
+
.join(';');
|
|
27
|
+
return {
|
|
28
|
+
code: `
|
|
29
|
+
if (!(${comp.vλl} instanceof ${this.constructorName})) return false;
|
|
30
|
+
for (const ${entry} of ${comp.vλl}) {${childrenCode}} return true;
|
|
31
|
+
`,
|
|
32
|
+
type: 'RB',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {
|
|
36
|
+
const entry = this.getCustomVλl(comp)?.vλl || comp.vλl;
|
|
37
|
+
const childrenCode = this.getJitChildren(comp)
|
|
38
|
+
.map((c) => comp.compileTypeErrors(c, 'S').code)
|
|
39
|
+
.join(';');
|
|
40
|
+
const index = this.getIndexVarName(comp);
|
|
41
|
+
return {
|
|
42
|
+
code: `
|
|
43
|
+
if (!(${comp.vλl} instanceof ${this.constructorName})){${comp.callJitErr(this)}}
|
|
44
|
+
else {let ${index} = 0;for (const ${entry} of ${comp.vλl}) {${childrenCode}; ${index}++}}
|
|
45
|
+
`,
|
|
46
|
+
type: 'S',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
emitPrepareForJson(comp: JitFnCompiler): JitCode {
|
|
50
|
+
const entry = this.getCustomVλl(comp)?.vλl || comp.vλl;
|
|
51
|
+
const resName = comp.getLocalVarName('ml', this);
|
|
52
|
+
const childrenCode = this.getJitChildren(comp)
|
|
53
|
+
.map((c) => comp.compilePrepareForJson(c, 'S').code)
|
|
54
|
+
.filter(Boolean)
|
|
55
|
+
.join(';');
|
|
56
|
+
if (!childrenCode) return {code: `${comp.vλl} = Array.from(${comp.vλl})`, type: 'S'};
|
|
57
|
+
return {
|
|
58
|
+
code: `
|
|
59
|
+
const ${resName} = [];
|
|
60
|
+
for (let ${entry} of ${comp.vλl}) {${childrenCode} ${resName}.push(${entry})}
|
|
61
|
+
${comp.vλl} = ${resName};
|
|
62
|
+
`,
|
|
63
|
+
type: 'S',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
emitRestoreFromJson(comp: JitFnCompiler): JitCode {
|
|
67
|
+
const children = this.getJitChildren(comp);
|
|
68
|
+
if (!children.length) return {code: `${comp.vλl} = new Map(${comp.vλl})`, type: 'S'};
|
|
69
|
+
const index = this.getCustomVλl(comp)?.vλl || comp.vλl;
|
|
70
|
+
const childrenCode = children
|
|
71
|
+
.map((c) => comp.compileRestoreFromJson(c, 'S').code)
|
|
72
|
+
.filter(Boolean)
|
|
73
|
+
.join(';');
|
|
74
|
+
if (!childrenCode) return {code: `${comp.vλl} = new ${this.constructorName}(${comp.vλl})`, type: 'S'};
|
|
75
|
+
return {
|
|
76
|
+
code: `
|
|
77
|
+
for (let ${index} = 0; ${index} < ${comp.vλl}.length; ${index}++) {${childrenCode}}
|
|
78
|
+
${comp.vλl} = new ${this.constructorName}(${comp.vλl})
|
|
79
|
+
`,
|
|
80
|
+
type: 'S',
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// TODO: Implement the following methods, should just call same compile method for children, look into to array run type
|
|
85
|
+
|
|
86
|
+
emitHasUnknownKeys(comp: JitFnCompiler): JitCode {
|
|
87
|
+
const childrenCode = this.getJitChildren(comp)
|
|
88
|
+
.map((child) => {
|
|
89
|
+
const itemJit = comp.compileHasUnknownKeys(child, 'E');
|
|
90
|
+
return itemJit?.code ? `if (${itemJit.code}) return true;` : '';
|
|
91
|
+
})
|
|
92
|
+
.filter(Boolean)
|
|
93
|
+
.join('');
|
|
94
|
+
if (!childrenCode) return {code: 'return false', type: 'RB'};
|
|
95
|
+
const entry = this.getCustomVλl(comp)?.vλl || comp.vλl;
|
|
96
|
+
return {
|
|
97
|
+
code: `
|
|
98
|
+
if (!(${comp.vλl} instanceof ${this.constructorName})) return false;
|
|
99
|
+
for (const ${entry} of ${comp.vλl}) {${childrenCode}} return false;
|
|
100
|
+
`,
|
|
101
|
+
type: 'RB',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
emitUnknownKeyErrors(comp: JitErrorsFnCompiler): JitCode {
|
|
106
|
+
const childrenCode = this.getJitChildren(comp)
|
|
107
|
+
.map((child) => comp.compileUnknownKeyErrors(child, 'S').code)
|
|
108
|
+
.filter(Boolean)
|
|
109
|
+
.join(';');
|
|
110
|
+
if (!childrenCode) return {code: undefined, type: 'S'};
|
|
111
|
+
const entry = this.getCustomVλl(comp)?.vλl || comp.vλl;
|
|
112
|
+
const index = this.getIndexVarName(comp);
|
|
113
|
+
return {
|
|
114
|
+
code: `
|
|
115
|
+
if (!(${comp.vλl} instanceof ${this.constructorName})) return;
|
|
116
|
+
let ${index} = 0; for (const ${entry} of ${comp.vλl}) {${childrenCode}; ${index}++}
|
|
117
|
+
`,
|
|
118
|
+
type: 'S',
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
emitStripUnknownKeys(comp: JitFnCompiler): JitCode {
|
|
123
|
+
const childrenCode = this.getJitChildren(comp)
|
|
124
|
+
.map((child) => comp.compileStripUnknownKeys(child, 'S').code)
|
|
125
|
+
.filter(Boolean)
|
|
126
|
+
.join(';');
|
|
127
|
+
if (!childrenCode) return {code: undefined, type: 'S'};
|
|
128
|
+
const entry = this.getCustomVλl(comp)?.vλl || comp.vλl;
|
|
129
|
+
return {
|
|
130
|
+
code: `
|
|
131
|
+
if (!(${comp.vλl} instanceof ${this.constructorName})) return;
|
|
132
|
+
for (const ${entry} of ${comp.vλl}) {${childrenCode}}
|
|
133
|
+
`,
|
|
134
|
+
type: 'S',
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
emitUnknownKeysToUndefined(comp: JitFnCompiler): JitCode {
|
|
139
|
+
const childrenCode = this.getJitChildren(comp)
|
|
140
|
+
.map((child) => comp.compileUnknownKeysToUndefined(child, 'S').code)
|
|
141
|
+
.filter(Boolean)
|
|
142
|
+
.join(';');
|
|
143
|
+
if (!childrenCode) return {code: undefined, type: 'S'};
|
|
144
|
+
const entry = this.getCustomVλl(comp)?.vλl || comp.vλl;
|
|
145
|
+
return {
|
|
146
|
+
code: `
|
|
147
|
+
if (!(${comp.vλl} instanceof ${this.constructorName})) return;
|
|
148
|
+
for (const ${entry} of ${comp.vλl}) {${childrenCode}}
|
|
149
|
+
`,
|
|
150
|
+
type: 'S',
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2024 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
import type {SrcType} from '../../types.ts';
|
|
8
|
+
import {GenericMemberRunType} from '../member/genericMember.ts';
|
|
9
|
+
import {ReflectionSubKind} from '../../constants.kind.ts';
|
|
10
|
+
import {ReflectionKind, TypeClass} from '@deepkit/type';
|
|
11
|
+
import {IterableRunType} from './Iterable.ts';
|
|
12
|
+
import {JitFunctions} from '../../constants.functions.ts';
|
|
13
|
+
import type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';
|
|
14
|
+
import {cpf_safeIterableKey} from '../../run-types-pure-fns.ts';
|
|
15
|
+
|
|
16
|
+
export class MapRunType extends IterableRunType {
|
|
17
|
+
keyRT = new MapKeyRunType();
|
|
18
|
+
valueRT = new MapValueRunType();
|
|
19
|
+
children = [this.keyRT, this.valueRT];
|
|
20
|
+
constructorName = 'Map';
|
|
21
|
+
onCreated(src: SrcType<TypeClass>): void {
|
|
22
|
+
const types = src.arguments;
|
|
23
|
+
if (!types || types.length !== 2) throw new Error(`Map expects 2 type arguments: ie: Map<string, number>`);
|
|
24
|
+
super.onCreated(src);
|
|
25
|
+
this.keyRT.onCreated({
|
|
26
|
+
kind: ReflectionKind.parameter,
|
|
27
|
+
parent: src,
|
|
28
|
+
type: types[0],
|
|
29
|
+
subKind: ReflectionSubKind.mapKey,
|
|
30
|
+
});
|
|
31
|
+
this.valueRT.onCreated({
|
|
32
|
+
kind: ReflectionKind.parameter,
|
|
33
|
+
parent: src,
|
|
34
|
+
type: types[1],
|
|
35
|
+
subKind: ReflectionSubKind.mapValue,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
getCustomVλl(comp: JitFnCompiler) {
|
|
39
|
+
// restoreFromJson is decoding a regular array so no need to use an special case for vλl as other operations
|
|
40
|
+
if (comp.fnID === JitFunctions.restoreFromJson.id)
|
|
41
|
+
return {vλl: comp.getLocalVarName('it', this), isStandalone: false, useArrayAccessor: true};
|
|
42
|
+
// other operations use an special case for vλl where all parents are skipped
|
|
43
|
+
return {vλl: comp.getLocalVarName('it', this), isStandalone: true};
|
|
44
|
+
}
|
|
45
|
+
getMapKeyVλl(comp: JitFnCompiler) {
|
|
46
|
+
return comp.getLocalVarName('mpk', this);
|
|
47
|
+
}
|
|
48
|
+
getMapValueVλl(comp: JitFnCompiler) {
|
|
49
|
+
return comp.getLocalVarName('mpV', this);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
class MapKeyRunType extends GenericMemberRunType<any> {
|
|
54
|
+
index = 0;
|
|
55
|
+
getStaticPathLiteral(comp: JitFnCompiler): string | number {
|
|
56
|
+
const parent = this.getParent()! as MapRunType;
|
|
57
|
+
const custom = parent.getCustomVλl(comp)!;
|
|
58
|
+
const safeKeyFn = comp.addPureFunction(cpf_safeIterableKey);
|
|
59
|
+
return `{key:${safeKeyFn}(${custom.vλl}[0]),index:${parent.getIndexVarName(comp)},failed:'mapKey'}`;
|
|
60
|
+
}
|
|
61
|
+
getCustomVλl(comp: JitFnCompiler) {
|
|
62
|
+
// temp variable to assign mapKey
|
|
63
|
+
if (comp.fnID === JitFunctions.fromBinary.id)
|
|
64
|
+
return {
|
|
65
|
+
vλl: (this.getParent()! as MapRunType).getMapKeyVλl(comp),
|
|
66
|
+
isStandalone: true,
|
|
67
|
+
useArrayAccessor: false,
|
|
68
|
+
};
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
class MapValueRunType extends GenericMemberRunType<any> {
|
|
74
|
+
index = 1;
|
|
75
|
+
getStaticPathLiteral(comp: JitFnCompiler): string | number {
|
|
76
|
+
const parent = this.getParent()! as MapRunType;
|
|
77
|
+
const custom = parent.getCustomVλl(comp)!;
|
|
78
|
+
const safeKeyFn = comp.addPureFunction(cpf_safeIterableKey);
|
|
79
|
+
return `{key:${safeKeyFn}(${custom.vλl}[0]),index:${parent.getIndexVarName(comp)},failed:'mapVal'}`;
|
|
80
|
+
}
|
|
81
|
+
getCustomVλl(comp: JitFnCompiler) {
|
|
82
|
+
// temp variable to assign mapKey
|
|
83
|
+
if (comp.fnID === JitFunctions.fromBinary.id)
|
|
84
|
+
return {
|
|
85
|
+
vλl: (this.getParent()! as MapRunType).getMapValueVλl(comp),
|
|
86
|
+
isStandalone: true,
|
|
87
|
+
useArrayAccessor: false,
|
|
88
|
+
};
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
}
|