@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,211 @@
|
|
|
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 {ReflectionKind} from '@deepkit/type';
|
|
9
|
+
import {ReflectionSubKind} from '../../constants.kind';
|
|
10
|
+
import type {JitCode} from '../../types';
|
|
11
|
+
import type {BaseRunType} from '../../lib/baseRunTypes';
|
|
12
|
+
import type {LiteralRunType} from '../../nodes/atomic/literal';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Main XYZ deserialization compiler function
|
|
16
|
+
* Generates JIT code to deserialize XYZ data to JavaScript values
|
|
17
|
+
*/
|
|
18
|
+
function _compileFromXYZ(runType: BaseRunType, comp: JitXYZCompiler): JitCode {
|
|
19
|
+
const src = runType.src;
|
|
20
|
+
const kind = src.kind;
|
|
21
|
+
|
|
22
|
+
switch (kind) {
|
|
23
|
+
// ###################### ATOMIC TYPES ######################
|
|
24
|
+
case ReflectionKind.unknown:
|
|
25
|
+
case ReflectionKind.any:
|
|
26
|
+
// TODO
|
|
27
|
+
break;
|
|
28
|
+
case ReflectionKind.null:
|
|
29
|
+
// TODO
|
|
30
|
+
break;
|
|
31
|
+
case ReflectionKind.boolean:
|
|
32
|
+
// TODO
|
|
33
|
+
break;
|
|
34
|
+
case ReflectionKind.number:
|
|
35
|
+
// TODO
|
|
36
|
+
break;
|
|
37
|
+
case ReflectionKind.string:
|
|
38
|
+
// TODO
|
|
39
|
+
break;
|
|
40
|
+
case ReflectionKind.bigint:
|
|
41
|
+
// TODO
|
|
42
|
+
break;
|
|
43
|
+
case ReflectionKind.undefined:
|
|
44
|
+
// TODO
|
|
45
|
+
break;
|
|
46
|
+
case ReflectionKind.void:
|
|
47
|
+
// TODO
|
|
48
|
+
break;
|
|
49
|
+
|
|
50
|
+
case ReflectionKind.symbol:
|
|
51
|
+
// TODO
|
|
52
|
+
break;
|
|
53
|
+
|
|
54
|
+
case ReflectionKind.regexp:
|
|
55
|
+
// TODO
|
|
56
|
+
break;
|
|
57
|
+
|
|
58
|
+
case ReflectionKind.object:
|
|
59
|
+
throw new Error('XYZ deserialization not supported for generic object types');
|
|
60
|
+
|
|
61
|
+
case ReflectionKind.enum:
|
|
62
|
+
// TODO
|
|
63
|
+
break;
|
|
64
|
+
|
|
65
|
+
case ReflectionKind.enumMember:
|
|
66
|
+
throw new Error('XYZ deserialization not supported for enum member types');
|
|
67
|
+
|
|
68
|
+
case ReflectionKind.never:
|
|
69
|
+
throw new Error('Never type cannot be deserialized from XYZ');
|
|
70
|
+
|
|
71
|
+
case ReflectionKind.templateLiteral:
|
|
72
|
+
throw new Error('Template literals are not supported in XYZ deserialization');
|
|
73
|
+
|
|
74
|
+
case ReflectionKind.literal:
|
|
75
|
+
return compileLiteral(runType as LiteralRunType, comp);
|
|
76
|
+
|
|
77
|
+
// ###################### MEMBER RUNTYPES ######################
|
|
78
|
+
// Types that represent members of collections or other structures
|
|
79
|
+
case ReflectionKind.array:
|
|
80
|
+
// TODO
|
|
81
|
+
break;
|
|
82
|
+
|
|
83
|
+
case ReflectionKind.indexSignature:
|
|
84
|
+
// TODO
|
|
85
|
+
break;
|
|
86
|
+
|
|
87
|
+
case ReflectionKind.function:
|
|
88
|
+
case ReflectionKind.method:
|
|
89
|
+
case ReflectionKind.methodSignature:
|
|
90
|
+
case ReflectionKind.callSignature:
|
|
91
|
+
if (runType.src.subKind === ReflectionSubKind.params) {
|
|
92
|
+
// TODO: Handle function parameters
|
|
93
|
+
break;
|
|
94
|
+
} else {
|
|
95
|
+
throw new Error(
|
|
96
|
+
'XYZ deserialization not supported for function types, call compileParams or compileReturn instead'
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
case ReflectionKind.parameter:
|
|
101
|
+
switch (src.subKind) {
|
|
102
|
+
case ReflectionSubKind.mapKey:
|
|
103
|
+
// TODO: Handle map key parameter
|
|
104
|
+
break;
|
|
105
|
+
case ReflectionSubKind.mapValue:
|
|
106
|
+
// TODO: Handle map value parameter
|
|
107
|
+
break;
|
|
108
|
+
case ReflectionSubKind.setItem:
|
|
109
|
+
// TODO: Handle set item parameter
|
|
110
|
+
break;
|
|
111
|
+
default:
|
|
112
|
+
// TODO: Handle regular parameter
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
|
|
117
|
+
case ReflectionKind.property:
|
|
118
|
+
case ReflectionKind.propertySignature:
|
|
119
|
+
// TODO
|
|
120
|
+
break;
|
|
121
|
+
|
|
122
|
+
case ReflectionKind.rest:
|
|
123
|
+
// TODO
|
|
124
|
+
break;
|
|
125
|
+
|
|
126
|
+
case ReflectionKind.tupleMember:
|
|
127
|
+
// TODO
|
|
128
|
+
break;
|
|
129
|
+
|
|
130
|
+
case ReflectionKind.promise:
|
|
131
|
+
throw new Error('XYZ deserialization not supported for Promise types');
|
|
132
|
+
|
|
133
|
+
// ###################### COLLECTION RUNTYPES ######################
|
|
134
|
+
// Types that contain other types as members
|
|
135
|
+
case ReflectionKind.objectLiteral:
|
|
136
|
+
case ReflectionKind.intersection:
|
|
137
|
+
if (runType.src.subKind === ReflectionSubKind.nonSerializable) {
|
|
138
|
+
throw new Error('XYZ deserialization is disabled for Non Serializable types');
|
|
139
|
+
} else {
|
|
140
|
+
// TODO: Handle object literal/intersection
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
case ReflectionKind.class:
|
|
145
|
+
switch (runType.src.subKind) {
|
|
146
|
+
case ReflectionSubKind.date:
|
|
147
|
+
// TODO: Handle Date class
|
|
148
|
+
break;
|
|
149
|
+
case ReflectionSubKind.map:
|
|
150
|
+
// TODO: Handle Map class
|
|
151
|
+
break;
|
|
152
|
+
case ReflectionSubKind.set:
|
|
153
|
+
// TODO: Handle Set class
|
|
154
|
+
break;
|
|
155
|
+
case ReflectionSubKind.nonSerializable:
|
|
156
|
+
throw new Error('XYZ deserialization disabled for Non Serializable types');
|
|
157
|
+
default:
|
|
158
|
+
// TODO: Handle regular class
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
break;
|
|
162
|
+
|
|
163
|
+
case ReflectionKind.infer:
|
|
164
|
+
throw new Error('Infer is not supported in XYZ deserialization');
|
|
165
|
+
|
|
166
|
+
case ReflectionKind.tuple:
|
|
167
|
+
// TODO
|
|
168
|
+
break;
|
|
169
|
+
|
|
170
|
+
case ReflectionKind.typeParameter:
|
|
171
|
+
throw new Error('Type parameter not implemented in XYZ deserialization');
|
|
172
|
+
|
|
173
|
+
case ReflectionKind.union:
|
|
174
|
+
// TODO
|
|
175
|
+
break;
|
|
176
|
+
|
|
177
|
+
default:
|
|
178
|
+
throw new Error(`XYZ deserialization not supported for ${ReflectionKind[kind]} types`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function compileLiteral(runType: LiteralRunType, comp: JitXYZCompiler): JitCode {
|
|
183
|
+
const src = runType.src;
|
|
184
|
+
// Literal types are serialized as their underlying value
|
|
185
|
+
const literalValue = src.literal;
|
|
186
|
+
const originalKind = src.kind;
|
|
187
|
+
// Handle RegExp literals specially
|
|
188
|
+
if (literalValue instanceof RegExp) {
|
|
189
|
+
(src as any).kind = ReflectionKind.regexp;
|
|
190
|
+
} else if (typeof literalValue === 'string') {
|
|
191
|
+
(src as any).kind = ReflectionKind.string;
|
|
192
|
+
} else if (typeof literalValue === 'number') {
|
|
193
|
+
(src as any).kind = ReflectionKind.number;
|
|
194
|
+
} else if (typeof literalValue === 'boolean') {
|
|
195
|
+
(src as any).kind = ReflectionKind.boolean;
|
|
196
|
+
} else if (typeof literalValue === 'bigint') {
|
|
197
|
+
(src as any).kind = ReflectionKind.bigint;
|
|
198
|
+
} else if (typeof literalValue === 'symbol') {
|
|
199
|
+
(src as any).kind = ReflectionKind.symbol;
|
|
200
|
+
} else if (literalValue === null) {
|
|
201
|
+
(src as any).kind = ReflectionKind.null;
|
|
202
|
+
} else {
|
|
203
|
+
// Fallback to string for unknown types
|
|
204
|
+
(src as any).kind = ReflectionKind.string;
|
|
205
|
+
}
|
|
206
|
+
// Recursively call the main function with the changed kind
|
|
207
|
+
const result = _compileFromXYZ(runType, comp);
|
|
208
|
+
// Restore the original kind
|
|
209
|
+
(src as any).kind = originalKind;
|
|
210
|
+
return result;
|
|
211
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
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 {ReflectionKind} from '@deepkit/type';
|
|
9
|
+
import {ReflectionSubKind} from '../../constants.kind';
|
|
10
|
+
import type {JitCode} from '../../types';
|
|
11
|
+
import type {BaseRunType} from '../../lib/baseRunTypes';
|
|
12
|
+
import type {LiteralRunType} from '../../nodes/atomic/literal';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Main XYZ serialization compiler function
|
|
16
|
+
* Generates JIT code to serialize values to XYZ format following XYZ 1.1 specification
|
|
17
|
+
*
|
|
18
|
+
* This function generates JavaScript expressions that return Uint8Array containing XYZ bytes.
|
|
19
|
+
*/
|
|
20
|
+
export function _compileToXYZ(runType: BaseRunType, comp: JitXYZCompiler): JitCode {
|
|
21
|
+
const src = runType.src;
|
|
22
|
+
const kind = src.kind;
|
|
23
|
+
|
|
24
|
+
switch (kind) {
|
|
25
|
+
// ###################### ATOMIC TYPES ######################
|
|
26
|
+
case ReflectionKind.unknown:
|
|
27
|
+
case ReflectionKind.any:
|
|
28
|
+
// TODO
|
|
29
|
+
break;
|
|
30
|
+
case ReflectionKind.null:
|
|
31
|
+
// TODO
|
|
32
|
+
break;
|
|
33
|
+
|
|
34
|
+
case ReflectionKind.boolean:
|
|
35
|
+
// TODO
|
|
36
|
+
break;
|
|
37
|
+
|
|
38
|
+
case ReflectionKind.number:
|
|
39
|
+
// TODO
|
|
40
|
+
break;
|
|
41
|
+
|
|
42
|
+
case ReflectionKind.string:
|
|
43
|
+
// TODO
|
|
44
|
+
break;
|
|
45
|
+
|
|
46
|
+
case ReflectionKind.bigint:
|
|
47
|
+
// TODO
|
|
48
|
+
break;
|
|
49
|
+
case ReflectionKind.undefined:
|
|
50
|
+
// TODO
|
|
51
|
+
break;
|
|
52
|
+
case ReflectionKind.void:
|
|
53
|
+
// TODO
|
|
54
|
+
break;
|
|
55
|
+
case ReflectionKind.symbol:
|
|
56
|
+
// TODO
|
|
57
|
+
break;
|
|
58
|
+
|
|
59
|
+
case ReflectionKind.regexp:
|
|
60
|
+
// TODO
|
|
61
|
+
break;
|
|
62
|
+
|
|
63
|
+
case ReflectionKind.object:
|
|
64
|
+
throw new Error('XYZ serialization not supported for generic object types');
|
|
65
|
+
|
|
66
|
+
case ReflectionKind.enum:
|
|
67
|
+
// TODO
|
|
68
|
+
break;
|
|
69
|
+
|
|
70
|
+
case ReflectionKind.enumMember:
|
|
71
|
+
throw new Error('XYZ serialization not supported for enum member types');
|
|
72
|
+
|
|
73
|
+
case ReflectionKind.never:
|
|
74
|
+
throw new Error('Never type cannot be serialized to XYZ');
|
|
75
|
+
|
|
76
|
+
case ReflectionKind.templateLiteral:
|
|
77
|
+
throw new Error('Template literals are not supported in XYZ serialization');
|
|
78
|
+
|
|
79
|
+
case ReflectionKind.literal:
|
|
80
|
+
return compileLiteral(runType as LiteralRunType, comp);
|
|
81
|
+
|
|
82
|
+
// ###################### MEMBER RUNTYPES ######################
|
|
83
|
+
// Types that represent members of collections or other structures
|
|
84
|
+
case ReflectionKind.array:
|
|
85
|
+
// TODO
|
|
86
|
+
break;
|
|
87
|
+
|
|
88
|
+
case ReflectionKind.indexSignature:
|
|
89
|
+
// TODO
|
|
90
|
+
break;
|
|
91
|
+
|
|
92
|
+
case ReflectionKind.function:
|
|
93
|
+
case ReflectionKind.method:
|
|
94
|
+
case ReflectionKind.methodSignature:
|
|
95
|
+
case ReflectionKind.callSignature:
|
|
96
|
+
if (runType.src.subKind === ReflectionSubKind.params) {
|
|
97
|
+
// TODO: Handle function parameters
|
|
98
|
+
break;
|
|
99
|
+
} else {
|
|
100
|
+
throw new Error(
|
|
101
|
+
'XYZ serialization not supported for function types, call compileParams or compileReturn instead'
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
case ReflectionKind.parameter:
|
|
106
|
+
switch (src.subKind) {
|
|
107
|
+
case ReflectionSubKind.mapKey:
|
|
108
|
+
// TODO: Handle map key parameter
|
|
109
|
+
break;
|
|
110
|
+
case ReflectionSubKind.mapValue:
|
|
111
|
+
// TODO: Handle map value parameter
|
|
112
|
+
break;
|
|
113
|
+
case ReflectionSubKind.setItem:
|
|
114
|
+
// TODO: Handle set item parameter
|
|
115
|
+
break;
|
|
116
|
+
default:
|
|
117
|
+
// TODO: Handle regular parameter
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
|
|
122
|
+
case ReflectionKind.property:
|
|
123
|
+
case ReflectionKind.propertySignature:
|
|
124
|
+
// TODO
|
|
125
|
+
break;
|
|
126
|
+
|
|
127
|
+
case ReflectionKind.rest:
|
|
128
|
+
// TODO
|
|
129
|
+
break;
|
|
130
|
+
|
|
131
|
+
case ReflectionKind.tupleMember:
|
|
132
|
+
// TODO
|
|
133
|
+
break;
|
|
134
|
+
|
|
135
|
+
case ReflectionKind.promise:
|
|
136
|
+
throw new Error('XYZ serialization not supported for Promise types');
|
|
137
|
+
|
|
138
|
+
// ###################### COLLECTION RUNTYPES ######################
|
|
139
|
+
// Types that contain other types as members
|
|
140
|
+
case ReflectionKind.objectLiteral:
|
|
141
|
+
case ReflectionKind.intersection:
|
|
142
|
+
if (runType.src.subKind === ReflectionSubKind.nonSerializable) {
|
|
143
|
+
throw new Error('XYZ serialization is disabled for Non Serializable types');
|
|
144
|
+
} else {
|
|
145
|
+
// TODO: Handle object literal/intersection
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
case ReflectionKind.class:
|
|
150
|
+
switch (runType.src.subKind) {
|
|
151
|
+
case ReflectionSubKind.date:
|
|
152
|
+
// TODO: Handle Date class
|
|
153
|
+
break;
|
|
154
|
+
case ReflectionSubKind.map:
|
|
155
|
+
// TODO: Handle Map class
|
|
156
|
+
break;
|
|
157
|
+
case ReflectionSubKind.set:
|
|
158
|
+
// TODO: Handle Set class
|
|
159
|
+
break;
|
|
160
|
+
case ReflectionSubKind.nonSerializable:
|
|
161
|
+
throw new Error('XYZ serialization disabled for Non Serializable types');
|
|
162
|
+
default:
|
|
163
|
+
// TODO: Handle regular class
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
break;
|
|
167
|
+
|
|
168
|
+
case ReflectionKind.infer:
|
|
169
|
+
throw new Error('Infer is not supported in XYZ serialization');
|
|
170
|
+
|
|
171
|
+
case ReflectionKind.tuple:
|
|
172
|
+
// TODO
|
|
173
|
+
break;
|
|
174
|
+
|
|
175
|
+
case ReflectionKind.typeParameter:
|
|
176
|
+
throw new Error('Type parameter not implemented in XYZ serialization');
|
|
177
|
+
|
|
178
|
+
case ReflectionKind.union:
|
|
179
|
+
// TODO
|
|
180
|
+
break;
|
|
181
|
+
|
|
182
|
+
default:
|
|
183
|
+
throw new Error(`XYZ serialization not supported for ${ReflectionKind[kind]} types`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function compileLiteral(runType: LiteralRunType, comp: JitXYZCompiler): JitCode {
|
|
188
|
+
const src = runType.src;
|
|
189
|
+
// Literal types are serialized as their underlying value
|
|
190
|
+
const literalValue = src.literal;
|
|
191
|
+
const originalKind = src.kind;
|
|
192
|
+
// Handle RegExp literals specially
|
|
193
|
+
if (literalValue instanceof RegExp) {
|
|
194
|
+
(src as any).kind = ReflectionKind.regexp;
|
|
195
|
+
} else if (typeof literalValue === 'string') {
|
|
196
|
+
(src as any).kind = ReflectionKind.string;
|
|
197
|
+
} else if (typeof literalValue === 'number') {
|
|
198
|
+
(src as any).kind = ReflectionKind.number;
|
|
199
|
+
} else if (typeof literalValue === 'boolean') {
|
|
200
|
+
(src as any).kind = ReflectionKind.boolean;
|
|
201
|
+
} else if (typeof literalValue === 'bigint') {
|
|
202
|
+
(src as any).kind = ReflectionKind.bigint;
|
|
203
|
+
} else if (typeof literalValue === 'symbol') {
|
|
204
|
+
(src as any).kind = ReflectionKind.symbol;
|
|
205
|
+
} else if (literalValue === null) {
|
|
206
|
+
(src as any).kind = ReflectionKind.null;
|
|
207
|
+
} else {
|
|
208
|
+
// Fallback to string for unknown types
|
|
209
|
+
(src as any).kind = ReflectionKind.string;
|
|
210
|
+
}
|
|
211
|
+
// Recursively call the main function with the changed kind
|
|
212
|
+
const result = _compileToXYZ(runType, comp);
|
|
213
|
+
// Restore the original kind
|
|
214
|
+
(src as any).kind = originalKind;
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Scaffolding
|
|
2
|
+
|
|
3
|
+
This directory contain the files to scaffold a new JIT compiler for a new format XYZ.
|
|
4
|
+
It is intended for serialization formats as contains from/to XYZ functions. but could be used for any other jit compiled functions.
|
|
5
|
+
|
|
6
|
+
Each JIT compiler is basically a giant switch statement that handles all node types. and return the src code for the operation on that node type.
|
|
@@ -0,0 +1,66 @@
|
|
|
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 {JitFunctions} from '../../../constants.functions';
|
|
9
|
+
import type {InterfaceRunType} from '../../../nodes/collection/interface';
|
|
10
|
+
import type {FunctionRunType} from '../../../nodes/function/function';
|
|
11
|
+
import type {RunType} from '../../../types';
|
|
12
|
+
|
|
13
|
+
// ################# UPDATE FOLLOWING FUNCTIONS TO YOUR OWN SERIALIZER #################
|
|
14
|
+
|
|
15
|
+
const SERIALIZE_FN = JitFunctions.prepareForJson;
|
|
16
|
+
const DESERIALIZE_FN = JitFunctions.restoreFromJson;
|
|
17
|
+
|
|
18
|
+
export function createSerializationFns(rt: RunType) {
|
|
19
|
+
const prepareForJson = rt.createJitFunction(SERIALIZE_FN);
|
|
20
|
+
const restoreFromJson = rt.createJitFunction(DESERIALIZE_FN);
|
|
21
|
+
const serialize = (v: any) => JSON.stringify(prepareForJson(v));
|
|
22
|
+
const deserialize = (data: any) => restoreFromJson(JSON.parse(data));
|
|
23
|
+
return {serialize, deserialize};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function createSerializationParamsFn(rt: FunctionRunType, sliceStart?: number) {
|
|
27
|
+
const params = typeof sliceStart === 'number' ? {paramsSlice: {start: sliceStart}} : undefined;
|
|
28
|
+
const prepareForJson = rt.createJitParamsFunction(SERIALIZE_FN, params);
|
|
29
|
+
const restoreFromJson = rt.createJitParamsFunction(DESERIALIZE_FN, params);
|
|
30
|
+
const serialize = (v: any) => JSON.stringify(prepareForJson(v));
|
|
31
|
+
const deserialize = (data: any) => restoreFromJson(JSON.parse(data));
|
|
32
|
+
return {serialize, deserialize};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function createSerializationReturnFn(rt: FunctionRunType) {
|
|
36
|
+
const prepareForJson = rt.createJitReturnFunction(SERIALIZE_FN);
|
|
37
|
+
const restoreFromJson = rt.createJitReturnFunction(DESERIALIZE_FN);
|
|
38
|
+
const serialize = (v: any) => JSON.stringify(prepareForJson(v));
|
|
39
|
+
const deserialize = (data: any) => restoreFromJson(JSON.parse(data));
|
|
40
|
+
return {serialize, deserialize};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function createSerializationCallSignatureParamsFn(rt: InterfaceRunType) {
|
|
44
|
+
const callSignature = rt.getCallSignature()!;
|
|
45
|
+
const prepareForJson = callSignature.createJitParamsFunction(SERIALIZE_FN);
|
|
46
|
+
const restoreFromJson = callSignature.createJitParamsFunction(DESERIALIZE_FN);
|
|
47
|
+
const serialize = (v: any) => JSON.stringify(prepareForJson(v));
|
|
48
|
+
const deserialize = (data: any) => restoreFromJson(JSON.parse(data));
|
|
49
|
+
return {serialize, deserialize};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function createSerializationCallSignatureReturnFn(rt: InterfaceRunType) {
|
|
53
|
+
const callSignature = rt.getCallSignature()!;
|
|
54
|
+
const prepareForJson = callSignature.createJitReturnFunction(SERIALIZE_FN);
|
|
55
|
+
const restoreFromJson = callSignature.createJitReturnFunction(DESERIALIZE_FN);
|
|
56
|
+
const serialize = (v: any) => JSON.stringify(prepareForJson(v));
|
|
57
|
+
const deserialize = (data: any) => restoreFromJson(JSON.parse(data));
|
|
58
|
+
return {serialize, deserialize};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function roundTrip(serialize: (v: any) => string, deserialize: (v: string) => any, value: any) {
|
|
62
|
+
const serialized = serialize(value);
|
|
63
|
+
const deserialized = deserialize(serialized);
|
|
64
|
+
const result = {serialized, deserialized};
|
|
65
|
+
return result;
|
|
66
|
+
}
|