@mionjs/run-types 0.8.3-alpha.0 → 0.8.4

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.
Files changed (119) hide show
  1. package/.dist/cjs/src/constants.cjs.map +1 -1
  2. package/.dist/cjs/src/constants.functions.cjs.map +1 -1
  3. package/.dist/cjs/src/constants.kind.cjs.map +1 -1
  4. package/.dist/cjs/src/createRunType.cjs.map +1 -1
  5. package/.dist/cjs/src/createRunTypeFunctions.cjs.map +1 -1
  6. package/.dist/cjs/src/jitCompilers/json/toJsCode.cjs +34 -26
  7. package/.dist/cjs/src/jitCompilers/json/toJsCode.cjs.map +1 -1
  8. package/.dist/cjs/src/lib/baseRunTypes.cjs +0 -31
  9. package/.dist/cjs/src/lib/baseRunTypes.cjs.map +1 -1
  10. package/.dist/cjs/src/lib/baseRunTypes.d.ts +0 -2
  11. package/.dist/cjs/src/lib/jitFnCompiler.cjs +6 -4
  12. package/.dist/cjs/src/lib/jitFnCompiler.cjs.map +1 -1
  13. package/.dist/cjs/src/lib/jitFnCompiler.d.ts +2 -2
  14. package/.dist/cjs/src/nodes/atomic/any.cjs.map +1 -1
  15. package/.dist/cjs/src/nodes/atomic/bigInt.cjs.map +1 -1
  16. package/.dist/cjs/src/nodes/atomic/boolean.cjs.map +1 -1
  17. package/.dist/cjs/src/nodes/atomic/date.cjs.map +1 -1
  18. package/.dist/cjs/src/nodes/atomic/enum.cjs.map +1 -1
  19. package/.dist/cjs/src/nodes/atomic/enumMember.cjs.map +1 -1
  20. package/.dist/cjs/src/nodes/atomic/literal.cjs.map +1 -1
  21. package/.dist/cjs/src/nodes/atomic/never.cjs.map +1 -1
  22. package/.dist/cjs/src/nodes/atomic/null.cjs.map +1 -1
  23. package/.dist/cjs/src/nodes/atomic/number.cjs.map +1 -1
  24. package/.dist/cjs/src/nodes/atomic/object.cjs.map +1 -1
  25. package/.dist/cjs/src/nodes/atomic/regexp.cjs.map +1 -1
  26. package/.dist/cjs/src/nodes/atomic/string.cjs.map +1 -1
  27. package/.dist/cjs/src/nodes/atomic/symbol.cjs.map +1 -1
  28. package/.dist/cjs/src/nodes/atomic/undefined.cjs.map +1 -1
  29. package/.dist/cjs/src/nodes/atomic/unknown.cjs.map +1 -1
  30. package/.dist/cjs/src/nodes/atomic/void.cjs.map +1 -1
  31. package/.dist/cjs/src/nodes/collection/class.cjs.map +1 -1
  32. package/.dist/cjs/src/nodes/collection/functionParams.cjs.map +1 -1
  33. package/.dist/cjs/src/nodes/collection/interface.cjs +24 -4
  34. package/.dist/cjs/src/nodes/collection/interface.cjs.map +1 -1
  35. package/.dist/cjs/src/nodes/collection/intersection.cjs.map +1 -1
  36. package/.dist/cjs/src/nodes/collection/tuple.cjs.map +1 -1
  37. package/.dist/cjs/src/nodes/collection/union.cjs.map +1 -1
  38. package/.dist/cjs/src/nodes/collection/unionDiscriminator.cjs.map +1 -1
  39. package/.dist/cjs/src/nodes/function/function.cjs +22 -18
  40. package/.dist/cjs/src/nodes/function/function.cjs.map +1 -1
  41. package/.dist/cjs/src/nodes/function/function.d.ts +1 -0
  42. package/.dist/cjs/src/nodes/member/array.cjs.map +1 -1
  43. package/.dist/cjs/src/nodes/member/callSignature.cjs.map +1 -1
  44. package/.dist/cjs/src/nodes/member/genericMember.cjs.map +1 -1
  45. package/.dist/cjs/src/nodes/member/indexProperty.cjs.map +1 -1
  46. package/.dist/cjs/src/nodes/member/method.cjs.map +1 -1
  47. package/.dist/cjs/src/nodes/member/methodSignature.cjs.map +1 -1
  48. package/.dist/cjs/src/nodes/member/param.cjs.map +1 -1
  49. package/.dist/cjs/src/nodes/member/property.cjs.map +1 -1
  50. package/.dist/cjs/src/nodes/member/restParams.cjs.map +1 -1
  51. package/.dist/cjs/src/nodes/member/tupleMember.cjs.map +1 -1
  52. package/.dist/cjs/src/nodes/native/Iterable.cjs.map +1 -1
  53. package/.dist/cjs/src/nodes/native/map.cjs.map +1 -1
  54. package/.dist/cjs/src/nodes/native/nonSerializable.cjs.map +1 -1
  55. package/.dist/cjs/src/nodes/native/promise.cjs.map +1 -1
  56. package/.dist/cjs/src/nodes/native/set.cjs.map +1 -1
  57. package/.dist/cjs/src/run-types-pure-fns.cjs.map +1 -1
  58. package/.dist/cjs/src/types.cjs +1 -1
  59. package/.dist/cjs/src/types.d.ts +1 -0
  60. package/.dist/esm/src/constants.functions.js.map +1 -1
  61. package/.dist/esm/src/constants.js.map +1 -1
  62. package/.dist/esm/src/constants.kind.js.map +1 -1
  63. package/.dist/esm/src/createRunType.js.map +1 -1
  64. package/.dist/esm/src/createRunTypeFunctions.js.map +1 -1
  65. package/.dist/esm/src/jitCompilers/json/toJsCode.js +34 -26
  66. package/.dist/esm/src/jitCompilers/json/toJsCode.js.map +1 -1
  67. package/.dist/esm/src/lib/baseRunTypes.d.ts +0 -2
  68. package/.dist/esm/src/lib/baseRunTypes.js +1 -32
  69. package/.dist/esm/src/lib/baseRunTypes.js.map +1 -1
  70. package/.dist/esm/src/lib/jitFnCompiler.d.ts +2 -2
  71. package/.dist/esm/src/lib/jitFnCompiler.js +6 -4
  72. package/.dist/esm/src/lib/jitFnCompiler.js.map +1 -1
  73. package/.dist/esm/src/nodes/atomic/any.js.map +1 -1
  74. package/.dist/esm/src/nodes/atomic/bigInt.js.map +1 -1
  75. package/.dist/esm/src/nodes/atomic/boolean.js.map +1 -1
  76. package/.dist/esm/src/nodes/atomic/date.js.map +1 -1
  77. package/.dist/esm/src/nodes/atomic/enum.js.map +1 -1
  78. package/.dist/esm/src/nodes/atomic/enumMember.js.map +1 -1
  79. package/.dist/esm/src/nodes/atomic/literal.js.map +1 -1
  80. package/.dist/esm/src/nodes/atomic/never.js.map +1 -1
  81. package/.dist/esm/src/nodes/atomic/null.js.map +1 -1
  82. package/.dist/esm/src/nodes/atomic/number.js.map +1 -1
  83. package/.dist/esm/src/nodes/atomic/object.js.map +1 -1
  84. package/.dist/esm/src/nodes/atomic/regexp.js.map +1 -1
  85. package/.dist/esm/src/nodes/atomic/string.js.map +1 -1
  86. package/.dist/esm/src/nodes/atomic/symbol.js.map +1 -1
  87. package/.dist/esm/src/nodes/atomic/undefined.js.map +1 -1
  88. package/.dist/esm/src/nodes/atomic/unknown.js.map +1 -1
  89. package/.dist/esm/src/nodes/atomic/void.js.map +1 -1
  90. package/.dist/esm/src/nodes/collection/class.js.map +1 -1
  91. package/.dist/esm/src/nodes/collection/functionParams.js.map +1 -1
  92. package/.dist/esm/src/nodes/collection/interface.js +24 -4
  93. package/.dist/esm/src/nodes/collection/interface.js.map +1 -1
  94. package/.dist/esm/src/nodes/collection/intersection.js.map +1 -1
  95. package/.dist/esm/src/nodes/collection/tuple.js.map +1 -1
  96. package/.dist/esm/src/nodes/collection/union.js.map +1 -1
  97. package/.dist/esm/src/nodes/collection/unionDiscriminator.js.map +1 -1
  98. package/.dist/esm/src/nodes/function/function.d.ts +1 -0
  99. package/.dist/esm/src/nodes/function/function.js +22 -18
  100. package/.dist/esm/src/nodes/function/function.js.map +1 -1
  101. package/.dist/esm/src/nodes/member/array.js.map +1 -1
  102. package/.dist/esm/src/nodes/member/callSignature.js.map +1 -1
  103. package/.dist/esm/src/nodes/member/genericMember.js.map +1 -1
  104. package/.dist/esm/src/nodes/member/indexProperty.js.map +1 -1
  105. package/.dist/esm/src/nodes/member/method.js.map +1 -1
  106. package/.dist/esm/src/nodes/member/methodSignature.js.map +1 -1
  107. package/.dist/esm/src/nodes/member/param.js.map +1 -1
  108. package/.dist/esm/src/nodes/member/property.js.map +1 -1
  109. package/.dist/esm/src/nodes/member/restParams.js.map +1 -1
  110. package/.dist/esm/src/nodes/member/tupleMember.js.map +1 -1
  111. package/.dist/esm/src/nodes/native/Iterable.js.map +1 -1
  112. package/.dist/esm/src/nodes/native/map.js.map +1 -1
  113. package/.dist/esm/src/nodes/native/nonSerializable.js.map +1 -1
  114. package/.dist/esm/src/nodes/native/promise.js.map +1 -1
  115. package/.dist/esm/src/nodes/native/set.js.map +1 -1
  116. package/.dist/esm/src/run-types-pure-fns.js.map +1 -1
  117. package/.dist/esm/src/types.d.ts +1 -0
  118. package/.dist/esm/src/types.js +1 -1
  119. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"intersection.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"intersection.cjs","sources":["../../../../../src/nodes/collection/intersection.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport {TypeIntersection} from '@deepkit/type';\nimport {InterfaceRunType} from './interface.ts';\nimport {type JitCode} from '../../types.ts';\n\n/** IMPORTANT:\n * Intersection are already resolved by deepkit so seems like this runType wont ever be called\n * ie: type A = {a: string} & {b: number} will be resolved to ObjectLiteral {a: string, b: number}\n * ie: type NeVer = string & number will be resolved to never\n * */\nexport class IntersectionRunType extends InterfaceRunType<TypeIntersection> {\n compileIsType(): JitCode {\n throw new Error('Intersection validation not supported, should be resolve to other RunTypes');\n }\n compileTypeErrors(): JitCode {\n throw new Error('Intersection validation not supported, should be resolve to other RunTypes');\n }\n compilePrepareForJson(): JitCode {\n throw new Error('Intersection serialization not supported, should be resolve to other RunTypes');\n }\n compileRestoreFromJson(): JitCode {\n throw new Error('Intersection serialization not supported, should be resolve to other RunTypes');\n }\n}\n"],"names":["InterfaceRunType"],"mappings":";;;;AAgBM,MAAO,4BAA4BA,+BAAAA,iBAAkC;AAAA,EACvE,gBAAa;AACT,UAAM,IAAI,MAAM,4EAA4E;AAAA,EAChG;AAAA,EACA,oBAAiB;AACb,UAAM,IAAI,MAAM,4EAA4E;AAAA,EAChG;AAAA,EACA,wBAAqB;AACjB,UAAM,IAAI,MAAM,+EAA+E;AAAA,EACnG;AAAA,EACA,yBAAsB;AAClB,UAAM,IAAI,MAAM,+EAA+E;AAAA,EACnG;AAAA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"tuple.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"tuple.cjs","sources":["../../../../../src/nodes/collection/tuple.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport type {TypeFunction, TypeTuple} from '@deepkit/type';\nimport type {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';\nimport type {AnyParameterListRunType, SrcType, JitCode} from '../../types.ts';\nimport {ParameterRunType} from '../member/param.ts';\nimport {CollectionRunType} from '../../lib/baseRunTypes.ts';\nimport {TupleMemberRunType} from '../member/tupleMember.ts';\n\ntype AnyParamRunType = ParameterRunType | TupleMemberRunType;\n\nexport class TupleRunType<\n ParamList extends AnyParameterListRunType = TypeTuple,\n ParamType extends AnyParamRunType = TupleMemberRunType,\n> extends CollectionRunType<ParamList> {\n getChildRunTypes = (): ParamType[] => {\n const childTypes = ((this.src as TypeFunction).parameters || (this.src as TypeTuple).types || []) as SrcType[];\n return childTypes.map((t) => t._rt as ParamType);\n };\n getParamRunTypes(comp: JitFnCompiler): ParamType[] {\n const start = comp.opts?.paramsSlice?.start;\n const end = comp.opts?.paramsSlice?.end;\n const children = this.getChildRunTypes();\n if (!start && !end) return children;\n // Get all child run types first without using comp to avoid recursion\n return children.slice(start, end);\n }\n hasRestParameter(comp: JitFnCompiler): boolean {\n return (\n !!this.getParamRunTypes(comp).length && this.getParamRunTypes(comp)[this.getParamRunTypes(comp).length - 1].isRest()\n );\n }\n totalRequiredParams(comp: JitFnCompiler): number {\n return this.getParamRunTypes(comp).filter((p) => !p.isOptional() && !p.isRest()).length;\n }\n // ####### params #######\n\n emitIsType(comp: JitFnCompiler): JitCode {\n const children = this.getParamRunTypes(comp);\n if (children.length === 0 && comp.opts.noIsArrayCheck) return {code: undefined, type: 'E'};\n if (children.length === 0) return {code: `Array.isArray(${comp.vλl}) && ${comp.vλl}.length === 0`, type: 'E'};\n const lengthCode = this.hasRestParameter(comp) ? '' : `&& ${comp.vλl}.length <= ${this.getParamRunTypes(comp).length}`;\n const paramsCode = children.map((p) => `(${comp.compileIsType(p, 'E').code})`).join(' && ');\n const checkIsArrayCode = comp.opts.noIsArrayCheck ? '' : `Array.isArray(${comp.vλl})${lengthCode} && `;\n return {code: `(${checkIsArrayCode} ${paramsCode})`, type: 'E'};\n }\n emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {\n const children = this.getParamRunTypes(comp);\n if (children.length === 0 && comp.opts.noIsArrayCheck) return {code: undefined, type: 'S'};\n if (children.length === 0)\n return {code: `if (!Array.isArray(${comp.vλl}) || && ${comp.vλl}.length === 0) ${comp.callJitErr(this)}`, type: 'S'};\n const lengthCode = this.hasRestParameter(comp) ? '' : `|| ${comp.vλl}.length > ${this.getParamRunTypes(comp).length}`;\n const paramsCode = children.map((p) => comp.compileTypeErrors(p, 'S').code).join(';');\n if (comp.opts.noIsArrayCheck) return {code: paramsCode, type: 'S'};\n return {code: `if (!Array.isArray(${comp.vλl})${lengthCode}) ${comp.callJitErr(this)}; else {${paramsCode}}`, type: 'S'};\n }\n emitPrepareForJson(comp: JitFnCompiler): JitCode {\n const children = this.getParamRunTypes(comp);\n if (!children.length) return {code: undefined, type: 'S'};\n const code = children\n .map((p) => comp.compilePrepareForJson(p, 'S').code)\n .filter(Boolean)\n .join(';');\n return {code: code, type: 'S'};\n }\n emitRestoreFromJson(comp: JitFnCompiler): JitCode {\n const children = this.getParamRunTypes(comp);\n if (!children.length) return {code: undefined, type: 'S'};\n const code = children\n .map((p) => comp.compileRestoreFromJson(p, 'S').code)\n .filter(Boolean)\n .join(';');\n return {code: code, type: 'S'};\n }\n}\n"],"names":["CollectionRunType","TupleMemberRunType"],"mappings":";;;;;;;;AAgBM,MAAO,qBAGHA,qBAAAA,kBAA4B;AAAA,EAClC,mBAAg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,MAAY,MAAM,IAAA;AAAA,EAC9B;AAAA,EACA,oBAAoB,MAAmB;AACnC,UAAM,WAAW,KAAK,iBAAiB,IAAI;AAC3C,QAAI,CAAC,SAAS;AAAQ,aAAO,EAAC,MAAM,QAAW,MAAM,IAAA;AACrD,UAAM,OAAO,SACR,iBAAI,CAAC,MAAM,KAAK,uBAAuB,GAAG,GAAG,EAAE,MAAI,CAAA,KAAA,IAAA,SAAA,CAAA,CAAA,EACnD,OAAO,OAAO,EACd,KAAK,GAAG;AACb,WAAO,EAAC,MAAY,MAAM,IAAA;AAAA,EAC9B;AAAA,EA1DmB,OAAA,SAAA,CAAA,aAAA,aAAA,MAAAC,6BAAAA,oBAAA,aAAA,MAAAD,wCAAA,oBAAA,WAAA;AAAA,WAAA,aAAA,MAAkB;AACjC,YAAM,aAAe,KAAK,IAAqB,cAAe,KAAK,IAAkB,SAAS,CAAA;AAC9F,aAAO,WAAW,IAAG,aAAC,CAAC,MAAM,EAAE;IACnC,GAAC,CAAA,IAAA,OAAA,CAAA;AAAA,EAAA,GAAA,iBAAA,QAAA,oBAAA,oBAAA,uBAAA,WAAA,cAAA,uBAAA,kBAAA,sBAAA,uBAAA,gBAAA,yGAAA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"union.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"union.cjs","sources":["../../../../../src/nodes/collection/union.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport {ReflectionKind, type TypeUnion} from '@deepkit/type';\nimport type {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';\nimport type {JitCode} from '../../types.ts';\nimport {BaseRunType, CollectionRunType} from '../../lib/baseRunTypes.ts';\nimport {childIsExpression, createIfElseFn, toLiteral} from '../../lib/utils.ts';\nimport {isClassRunType, isInterfaceRunType, isIntersectionRunType, isObjectLiteralRunType} from '../../lib/guards.ts';\nimport {markDiscriminators, splitUnionItems, SplitUnionResult} from './unionDiscriminator.ts';\nimport type {PropertyRunType} from '../member/property.ts';\n\n/**\n * Unions get encoded into an array where arr[0] is the discriminator and arr[1] is the value.\n * this is because some times we can't distinguish the type of an union.\n * ie: bigint gets encoded into an string, so if we have an union 'type U = string | bigint' we can't distinguish between the when encoding/decoding the json.\n * to solve this issue the index of the type is used as a discriminator.\n * So [0, \"123n\"] is interpreted as a string and [1, \"123n\"] is interpreted as a bigint.\n * */\nexport class UnionRunType extends CollectionRunType<TypeUnion> {\n hasDiscriminators: boolean | undefined = undefined;\n hasObjectTypes: boolean | undefined = undefined;\n\n isTypeWithProperties(rt: BaseRunType) {\n return (\n rt.getFamily() === 'C' &&\n (isInterfaceRunType(rt) || isClassRunType(rt) || isObjectLiteralRunType(rt) || isIntersectionRunType(rt))\n );\n }\n\n getUnionChildren(comp: JitFnCompiler): SplitUnionResult {\n const children = this.getJitChildren(comp);\n markDiscriminators(comp, this, children);\n return splitUnionItems(comp, this, children);\n }\n\n getUnionItemIndex(comp: JitFnCompiler, unionItem: BaseRunType): number {\n const children = this.getJitChildren(comp);\n const index = children.findIndex((child) => child === unionItem);\n if (index === -1) throw new Error(`Item ${unionItem.getTypeName()} not found in union ${this.getTypeName()}`);\n return index;\n }\n\n /**\n * Returns isType check for a union child with loose matching.\n * Uses first-match strategy: returns first matching type in declaration order.\n * For all-optional types (weak types), ensures at least one property matches or is empty object.\n * Note: Use ESLint rules @mionjs/no-unreachable-union-types and @mionjs/no-mixed-union-properties\n * to detect overlapping union types at compile time.\n * @see union.spec.ts 'Union Obj' and 'Union Mixed' test suites for examples.\n */\n getChildIsTypeWithLooseCheck(rt: BaseRunType, comp: JitFnCompiler): string {\n const isTypeCode = comp.compileIsType(rt, 'E').code || '';\n const isTypeWithProperties =\n isInterfaceRunType(rt) || isClassRunType(rt) || isObjectLiteralRunType(rt) || isIntersectionRunType(rt);\n if (!isTypeWithProperties || rt.getFamily() !== 'C') return isTypeCode;\n const props = rt.getJitChildren(comp);\n const hasIndexProperty = props.some((prop) => prop.src.kind === ReflectionKind.indexSignature);\n if (hasIndexProperty) return isTypeCode;\n const isAllOptional = rt.areAllChildrenOptional(props);\n // For all-optional types (weak types), TypeScript requires at least one matching property\n // or an empty object. This prevents {c: 'hello'} from matching {a?: string; b?: string}\n if (isAllOptional && props.length > 0) {\n // Must have at least one of this type's own props OR be empty\n const hasOwnPropCheck = props.map((p) => {\n const name = (p as PropertyRunType).getPropertyName();\n return `(${toLiteral(name)} in ${comp.vλl})`;\n });\n hasOwnPropCheck.push(`Object.keys(${comp.vλl}).length === 0`);\n const weakTypeCheck = `(${hasOwnPropCheck.join(' || ')})`;\n return `(${isTypeCode} && ${weakTypeCheck})`;\n }\n return isTypeCode;\n }\n\n /**\n * Loose union matching: returns first matching type in declaration order.\n * Objects with properties from multiple union types will match the first compatible type.\n * Use ESLint rules to detect overlapping types at compile time.\n */\n emitIsType(comp: JitFnCompiler): JitCode {\n this.checkAllowedChildren(comp);\n const {simpleItems, objectTypes, anyItem} = this.getUnionChildren(comp);\n // Simple items (atomic types) don't need null guard\n const simpleChecks = simpleItems.map((rt) => this.getChildIsTypeWithLooseCheck(rt, comp)).filter(Boolean);\n // Object types need null guard to prevent accessing properties on null\n const objChecks = objectTypes.map((rt) => this.getChildIsTypeWithLooseCheck(rt, comp)).filter(Boolean);\n const objCode = objChecks.length\n ? `(typeof ${comp.vλl} === 'object' && ${comp.vλl} !== null && (${objChecks.join(' || ')}))`\n : '';\n // any/unknown checked last as fallback\n const anyCheck = anyItem ? this.getChildIsTypeWithLooseCheck(anyItem, comp) : '';\n const allChecks = [...simpleChecks, objCode, anyCheck].filter(Boolean);\n return {code: `(${allChecks.join(' || ')})`, type: 'E'};\n }\n\n emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {\n this.checkAllowedChildren(comp);\n const isType = comp.compileIsType(this, 'E').code;\n const code = `if (!${isType}) ${comp.callJitErr(this)};`;\n return {code, type: 'S'};\n }\n\n /**\n * When a union is encodes to json is encode into and array with two elements: [unionDiscriminator, encoded Value]\n * the first element is the index of the type in the union.\n * the second element is the encoded value of the type.\n * ie: type union = string | number | bigint; var v1: union = 123n; v1 is encoded as [2, \"123n\"]\n */\n emitPrepareForJson(comp: JitFnCompiler): JitCode {\n this.checkAllowedChildren(comp);\n const {simpleItems, objectTypes, anyItem} = this.getUnionChildren(comp);\n const errName = comp.getLocalVarName('uErr', this);\n const fail = `throw new Error(${errName});`;\n comp.setContextItem(errName, `const ${errName} = \"Can not json encode union: item does not belong to the union\"`);\n\n const ifElse = createIfElseFn();\n\n // Helper to generate encode code for a union item\n const getEncodeCode = (childRt: BaseRunType) => {\n const toJit = comp.compilePrepareForJson(childRt, 'S');\n const fromJit = comp.compileRestoreFromJson(childRt, 'S');\n const needsTupleEncoding = !!toJit.code || !!fromJit.code;\n const isExpression = childIsExpression(toJit, childRt);\n const encodeCode = isExpression && toJit.code ? `${comp.vλl} = ${toJit.code};` : toJit.code || '';\n const index = this.getUnionItemIndex(comp, childRt);\n const tupleEncode = needsTupleEncoding ? `${comp.vλl} = [${index}, ${comp.vλl}]` : '/*noop*/';\n return `${encodeCode} ${tupleEncode}`;\n };\n\n // Generate code for simple items (atomic types)\n const simpleCode = simpleItems.map((rt) => {\n const isTypeCode = this.getChildIsTypeWithLooseCheck(rt, comp);\n return `${ifElse()} (${isTypeCode}) {${getEncodeCode(rt)}}`;\n });\n\n // Generate code for object types (need null guard)\n const objCode = objectTypes.length\n ? objectTypes.map((rt) => {\n const isTypeCode = this.getChildIsTypeWithLooseCheck(rt, comp);\n return `${ifElse()} (typeof ${comp.vλl} === 'object' && ${comp.vλl} !== null && ${isTypeCode}) {${getEncodeCode(rt)}}`;\n })\n : [];\n\n // Generate code for anyItem (always matches, checked last as fallback)\n const anyCode = anyItem ? `${ifElse(true)} {${getEncodeCode(anyItem)}}` : `${ifElse(true)} {${fail}}`;\n\n return {code: [...simpleCode, ...objCode, anyCode].join(''), type: 'S'};\n }\n\n /**\n * When a union is decoded from json it expects de two elements array format: [unionDiscriminator, Value to decode]\n * the first element is the index of the type in the union.\n * the second element is the encoded value of the type.\n * ie: type union = string | number | bigint; var v1: union = 123n; v1 is encoded as [2, \"123n\"]\n */\n emitRestoreFromJson(comp: JitFnCompiler): JitCode {\n this.checkAllowedChildren(comp);\n const decVar = comp.getLocalVarName('dec', this);\n const errVarName = comp.getLocalVarName('uErr', this);\n comp.setContextItem(errVarName, `const ${errVarName} = \"Can not json decode union: invalid union index\"`);\n const children = this.getJitChildren(comp);\n const ifElse = createIfElseFn();\n const itemsCode = children\n .map((unionItem) => {\n const childJit = comp.compileRestoreFromJson(unionItem, 'S');\n const isExpression = childIsExpression(childJit, unionItem);\n const code =\n isExpression && childJit.code && childJit.code !== comp.vλl\n ? `${comp.vλl} = ${childJit.code}`\n : childJit.code || '';\n // item is decoded before being extracted from the array\n const index = this.getUnionItemIndex(comp, unionItem);\n return `${ifElse()} (${decVar} === ${index}) {${code || '/*noop*/'}}`;\n })\n .filter(Boolean);\n const childrenCode = itemsCode.join('');\n const failCode = childrenCode ? `else {throw new Error(${errVarName})}` : '';\n const code = `\n if (${comp.vλl}?.length === 2 && Array.isArray(${comp.vλl}) && typeof ${comp.vλl}[0] === 'number') {\n const ${decVar} = ${comp.vλl}[0]; ${comp.vλl} = ${comp.vλl}[1];\n ${childrenCode}\n ${failCode}\n }\n `;\n return {code, type: 'S'};\n }\n\n getUnionTypeNames(): string {\n return this.getChildRunTypes()\n .map((rt) => rt.getTypeName())\n .join(' | ');\n }\n\n checkAllowedChildren(comp: JitFnCompiler) {\n const allChildren = this.getChildRunTypes();\n const toSkip = allChildren.filter((rt) => rt.skipJit(comp));\n if (toSkip.length)\n throw new Error(`Union can not have non serializable types, ie: Symbol, Function, etc. \\nType: ${this.stringify()}`);\n }\n}\n"],"names":["CollectionRunType","isInterfaceRunType","isClassRunType","isObjectLiteralRunType","isIntersectionRunType","markDiscriminators","splitUnionItems","ReflectionKind","toLiteral","createIfElseFn","childIsExpression","code","BaseRunType","__ΩSplitUnionResult"],"mappings":";;;;;;;;;;;AAuBM,MAAO,qBAAqBA,qBAAAA,kBAA4B;AAAA,EAC1D,oBAAyC;AAAA,EACzC,iBAAsC;AAAA,EAEtC,qBAAqB,IAAe;AAChC,WACI,GAAG,UAAA,MAAgB,QAClBC,eAAAA,mBAAmB,EAAE,KAAKC,eAAAA,eAAe,EAAE,KAAKC,eAAAA,uBAAuB,EAAE,KAAKC,eAAAA,sBAAsB,EAAE;AAAA,EAE/G;AAAA,EAEA,iBAAiB,MAAmB;AAChC,UAAM,WAAW,KAAK,eAAe,IAAI;AACzCC,+DAAmB,MAAM,MAAM,QAAQ;AACvC,WAAOC,wDAAgB,MAAM,MAAM,QAAQ;AAAA,EAC/C;AAAA,EAEA,kBAAkB,MAAqB,WAAsB;AACzD,UAAM,WAAW,KAAK,eAAe,IAAI;AACzC,UAAM,QAAQ,SAAS,UAAS,aAAC,CAAC,UAAU,UAAU;AACtD,QAAI,UAAU;AAAI,YAAM,IAAI,MAAM,QAAQ,UAAU,aAAa,uBAAuB,KAAK,YAAA,CAAa,EAAE;AAC5G,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,6BAA6B,IAAiB,MAAmB;AAC7D,UAAM,aAAa,KAAK,cAAc,IAAI,GAAG,EAAE,QAAQ;AACvD,UAAM,uBACFL,eAAAA,mBAAmB,EAAE,KAAKC,eAAAA,eAAe,EAAE,KAAKC,sCAAuB,EAAE,KAAKC,eAAAA,sBAAsB,EAAE;AAC1G,QAAI,CAAC,wBAAwB,GAAG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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"unionDiscriminator.cjs","sources":["../../../../../src/nodes/collection/unionDiscriminator.ts"],"sourcesContent":["import type {BaseRunType, CollectionRunType, MemberRunType} from '../../lib/baseRunTypes.ts';\nimport type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';\nimport type {UnionRunType} from './union.ts';\nimport type {PropertyRunType} from '../member/property.ts';\nimport {getTotalComplexity, sortRunTypeByComplexity} from '../../lib/utils.ts';\nimport {isAnyRunType, isUnknownRunType} from '../../lib/guards.ts';\n\nexport type FlattenedProp = {\n /** union item, parent of the property */\n unionItem: CollectionRunType<any>;\n /** index of the union item in the union */\n unionIndex: string | number;\n /** one property of the union item */\n prop: PropertyRunType;\n /** typeID of the property */\n typeID: string | number;\n /** name of the property as it should be used in the code */\n compiledName: string;\n};\n\nexport type SplitUnionResult = {\n simpleItems: BaseRunType[];\n objectTypes: CollectionRunType<any>[];\n /** any or unknown type if present in the union, should be checked last */\n anyItem?: BaseRunType;\n};\n\n/**\n * Split the union types in two groups: interface types and simple types\n * interface types are types that have properties, simple types are the rest (atomic types, tuples, etc)\n * If any or unknown types are present, they are extracted and returned separately as anyItem\n * so they can be checked last (any/unknown would match anything, so must be last resort)\n */\nexport function splitUnionItems(comp: JitFnCompiler, urt: UnionRunType, unionChildren?: BaseRunType[]): SplitUnionResult {\n const unionItems = unionChildren || urt.getJitChildren(comp);\n const objectTypes: CollectionRunType<any>[] = [];\n const simpleItems: BaseRunType[] = [];\n let anyItem: BaseRunType | undefined;\n\n unionItems.forEach((unionItem) => {\n // Extract any/unknown types to be checked last\n if (isAnyRunType(unionItem) || isUnknownRunType(unionItem)) {\n // Only keep the first any/unknown type (having multiple is redundant)\n if (!anyItem) anyItem = unionItem;\n return;\n }\n const isObj = urt.isTypeWithProperties(unionItem);\n if (!isObj) return simpleItems.push(unionItem);\n return objectTypes.push(unionItem as CollectionRunType<any>);\n });\n\n // Sort object types to prevent unreachable types (objects with more props should come first when they share same prop types)\n const sortedObjectTypes = sortUnreachableTypes(comp, objectTypes);\n\n return {simpleItems, objectTypes: sortedObjectTypes, anyItem};\n}\n\n/**\n * Sorts object types to prevent unreachable union types.\n * When two objects share the same properties (by typeID), the one with more properties must come first.\n * This ensures that at runtime, the more specific type is checked before the less specific one.\n * Objects that don't share properties with others maintain their relative order.\n */\nexport function sortUnreachableTypes(comp: JitFnCompiler, objectTypes: CollectionRunType<any>[]): CollectionRunType<any>[] {\n if (objectTypes.length <= 1) return objectTypes;\n\n // Get property typeIDs for each object type\n const typePropsMap = new Map<CollectionRunType<any>, Set<string | number>>();\n objectTypes.forEach((objType) => {\n const props = objType.getJitChildren(comp) as PropertyRunType[];\n const propTypeIDs = new Set<string | number>();\n props.forEach((prop) => propTypeIDs.add(prop.getTypeID()));\n typePropsMap.set(objType, propTypeIDs);\n });\n\n // Check if one object's props are a subset of another's (all props have same typeIDs)\n const isSubsetOf = (smaller: CollectionRunType<any>, larger: CollectionRunType<any>): boolean => {\n const smallerProps = typePropsMap.get(smaller)!;\n const largerProps = typePropsMap.get(larger)!;\n if (smallerProps.size >= largerProps.size) return false;\n for (const typeID of smallerProps) {\n if (!largerProps.has(typeID)) return false;\n }\n return true;\n };\n\n // Find groups of objects that share properties (one is subset of another)\n const processed = new Set<CollectionRunType<any>>();\n const result: CollectionRunType<any>[] = [];\n\n for (let i = 0; i < objectTypes.length; i++) {\n const current = objectTypes[i];\n if (processed.has(current)) continue;\n\n // Find all objects that are related (subset/superset) to current\n const relatedGroup: CollectionRunType<any>[] = [current];\n processed.add(current);\n\n for (let j = 0; j < objectTypes.length; j++) {\n if (i === j) continue;\n const other = objectTypes[j];\n if (processed.has(other)) continue;\n\n // Check if current and other are related (one is subset of the other)\n if (isSubsetOf(current, other) || isSubsetOf(other, current)) {\n relatedGroup.push(other);\n processed.add(other);\n }\n }\n\n // Sort related group by number of properties (more props first)\n if (relatedGroup.length > 1) {\n relatedGroup.sort((a, b) => {\n const aSize = typePropsMap.get(a)!.size;\n const bSize = typePropsMap.get(b)!.size;\n return bSize - aSize; // descending order (more props first)\n });\n }\n\n result.push(...relatedGroup);\n }\n\n return result;\n}\n\n/**\n * Mark discriminator properties so they can be sorted and validate union more efficiently.\n * @param comp\n * @param urt\n */\nexport function markDiscriminators(comp: JitFnCompiler, urt: UnionRunType, unionItems: BaseRunType[]) {\n if (urt.hasDiscriminators !== undefined && urt.hasObjectTypes !== undefined) return;\n const objectTypes = unionItems.filter((item) => urt.isTypeWithProperties(item)) as CollectionRunType<any>[];\n const namedDiscriminators = getDiscriminatorProperties(comp, urt, objectTypes, initGetCompiledName());\n const uniqueDiscriminators = getUniqueDiscriminatorProperties(comp, urt, objectTypes, initGetCompiledName());\n urt.hasObjectTypes = !!objectTypes.length;\n urt.hasDiscriminators = !!namedDiscriminators.length || !!uniqueDiscriminators.length;\n}\n\ntype PropUnionItemPair = {prop: PropertyRunType; unionItem: CollectionRunType<any>};\n\n/**\n * Find a property with the same name in all the types of the union and that has different types.\n * It also marks those properties as discriminator properties so can be sorted later\n */\nfunction getDiscriminatorProperties(\n comp: JitFnCompiler,\n urt: UnionRunType,\n unionTypes: CollectionRunType<any>[],\n getCompiledName: (comp: JitFnCompiler, urt: UnionRunType, propTypeID: string | number) => string\n): FlattenedProp[] {\n if (!unionTypes.length) return [];\n const propByName = new Map<string | number, PropUnionItemPair[]>();\n unionTypes.forEach((unionItem) => {\n const props = unionItem.getJitChildren(comp) as PropertyRunType[];\n props.forEach((prop) => {\n const name = prop.getChildVarName(comp);\n const existing = propByName.get(name) || [];\n // index no needed now\n propByName.set(name, [...existing, {prop, unionItem}]);\n });\n });\n const propsOnAllTypes = Array.from(propByName.entries())\n // filter all properties that are in all types\n .filter(([, props]) => props.length === unionTypes.length)\n // calculate complexity and check if all types are different in all props\n .map(([key, props]) => ({\n name: key,\n props,\n complexity: props.reduce((acc, item) => acc + getTotalComplexity(comp, item.prop), 0),\n isUniqueType: props.every((item) => {\n const child = item;\n const typeID = child.prop.getTypeID();\n const isDiff = props.every((otherItem) => child.prop === otherItem.prop || otherItem.prop.getTypeID() !== typeID);\n return isDiff;\n }),\n }))\n .filter((item) => item.isUniqueType);\n const lessComplexProps = propsOnAllTypes.toSorted((a, b) => a.complexity - b.complexity);\n const lessComplex = lessComplexProps[0];\n if (!lessComplex) return [];\n // we need to marks the property as discriminator so they can be sorted and checked first later\n return lessComplex.props.map((item) => {\n item.prop.isUnionDiscriminator = true;\n const unionIndex = urt.getUnionItemIndex(comp, item.unionItem);\n const typeID = item.prop.getTypeID();\n return {\n unionItem: item.unionItem,\n unionIndex,\n prop: item.prop,\n typeID,\n compiledName: getCompiledName(comp, urt, typeID),\n };\n });\n}\n\n/**\n * Get unique properties in the union as discriminators.\n * These properties can be of different name but are unique in the union so can act as discriminators.\n * It also marks those properties as discriminator properties so can be sorted later.\n * */\nfunction getUniqueDiscriminatorProperties(\n comp: JitFnCompiler,\n urt: UnionRunType,\n unionTypes: CollectionRunType<any>[],\n getCompiledName: (comp: JitFnCompiler, urt: UnionRunType, propTypeID: string | number) => string\n): FlattenedProp[] {\n if (!unionTypes.length) return [];\n const uniquePropByUnionItem = new Map<CollectionRunType<any>, PropUnionItemPair>();\n unionTypes.forEach((unionItem) => {\n const props = unionItem.getJitChildren(comp) as PropertyRunType[];\n props.forEach((prop) => {\n const typeID = prop.getTypeID();\n const isUnique = unionTypes.every((otherUnionItem) => {\n if (otherUnionItem === unionItem) return true;\n const otherProps = otherUnionItem.getJitChildren(comp) as MemberRunType<any>[];\n return otherProps.every((otherProp) => otherProp.getTypeID() !== typeID);\n });\n if (isUnique) {\n const existing = uniquePropByUnionItem.get(unionItem);\n if (!existing) {\n uniquePropByUnionItem.set(unionItem, {\n prop,\n unionItem,\n });\n return;\n }\n const newItem = {prop, unionItem};\n const lessComplex = [newItem, existing].toSorted((a, b) => sortRunTypeByComplexity(comp, a.prop, b.prop))[0];\n uniquePropByUnionItem.set(unionItem, lessComplex);\n }\n });\n });\n if (!uniquePropByUnionItem.size) return [];\n const uniqueProps = Array.from(uniquePropByUnionItem.values());\n return uniqueProps.map((item) => {\n item.prop.isUnionDiscriminator = true;\n const unionIndex = urt.getUnionItemIndex(comp, item.unionItem);\n const typeID = item.prop.getTypeID();\n return {\n unionItem: item.unionItem,\n unionIndex,\n prop: item.prop,\n typeID,\n compiledName: getCompiledName(comp, urt, typeID),\n };\n });\n}\n\nfunction initGetCompiledName() {\n const typeIDs = new Map<string | number, number>();\n return function getCompiledName(comp: JitFnCompiler, urt: UnionRunType, typeID: string | number): string {\n const existingIndex = typeIDs.get(typeID);\n if (existingIndex) return comp.getLocalVarName('prop', urt) + `_${existingIndex}`;\n const newIndex = typeIDs.size;\n typeIDs.set(typeID, newIndex);\n return comp.getLocalVarName('prop', urt) + `_${newIndex}`;\n };\n}\n"],"names":["isAnyRunType","isUnknownRunType","getTotalComplexity","sortRunTypeByComplexity"],"mappings":";;;;;;;;;;SAiCgB,gBAAgB,MAAqB,KAAmB,eAA6B;AACjG,QAAM,aAAa,iBAAiB,IAAI,eAAe,IAAI;AAC3D,QAAM,cAAwC,CAAA;AAC9C,QAAM,cAA6B,CAAA;AACnC,MAAI;AAEJ,aAAW,QAAO,aAAC,CAAC,cAAa;AAE7B,QAAIA,eAAAA,aAAa,SAAS,KAAKC,eAAAA,iBAAiB,SAAS,GAAG;AAExD,UAAI,CAAC;AAAS,kBAAU;AACxB;AAAA,IACJ;AACA,UAAM,QAAQ,IAAI,qBAAqB,SAAS;AAChD,QAAI,CAAC;AAAO,aAAO,YAAY,KAAK,SAAS;AAC7C,WAAO,YAAY,KAAK,SAAmC;AAAA,EAC/D;AAGA,QAAM,oBAAoB,qBAAqB,MAAM,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,SAAS,KAAK,KAAK,UAAA;AACzB,WAAO;AAAA,MACH,WAAW,KAAK;AAAA,MAChB;AAAA,MACA,MAAM,KAAK;AAAA,MACX;AAAA,MACA,cAAc,gBAAgB,MAAM,KAAK,MAAM;AAAA,IAAA;AAAA,EAEvD;AACJ;;AAEA,SAAS,sBAAmB;AACxB,QAAM,WAAc,IAAG,IAAA,CAAA,CAAA,MAAA,GAAA,CAAA,GAAA,CAAA,GAAP,oBAAI;AACpB,SAAA,aAAO,SAAS,gBAAgB,MAAqB,KAAmB,QAAuB;AAC3F,UAAM,gBAAgB,QAAQ,IAAI,MAAM;AACxC,QAAI;AAAe,aAAO,KAAK,gBAAgB,QAAQ,GAAG,IAAI,IAAI,aAAa;AAC/E,UAAM,WAAW,QAAQ;AACzB,YAAQ,IAAI,QAAQ,QAAQ;AAC5B,WAAO,KAAK,gBAAgB,QAAQ,GAAG,IAAI,IAAI,QAAQ;AAAA,EAC3D,GAAC,CAAA,iBAAA,QAAA,gBAAA,OAAA,UAAA,mBAAA,sBAAA,CAAA;AACL;;;;;;;"}
@@ -57,23 +57,7 @@ class FunctionRunType extends src_lib_baseRunTypes.BaseRunType {
57
57
  return this.createJitCompiledReturnFunction(jitFn).fn;
58
58
  }
59
59
  createJitCompiledReturnFunction(jitFn, opts) {
60
- let currentType = this;
61
- while (true) {
62
- if (src_lib_guards.isAnyFunctionRunType(currentType)) {
63
- const returnType = currentType.getReturnType();
64
- if (src_lib_guards.isPromiseRunType(returnType) || src_lib_guards.isFunctionRunType(returnType)) {
65
- currentType = returnType;
66
- continue;
67
- }
68
- return returnType.createJitCompiledFunction(jitFn.id, void 0, opts);
69
- }
70
- const memberType = currentType.getMemberType();
71
- if (src_lib_guards.isPromiseRunType(memberType) || src_lib_guards.isFunctionRunType(memberType)) {
72
- currentType = memberType;
73
- continue;
74
- }
75
- return memberType.createJitCompiledFunction(jitFn.id, void 0, opts);
76
- }
60
+ return this.getResolvedReturnType().createJitCompiledFunction(jitFn.id, void 0, opts);
77
61
  }
78
62
  // ######## JIT functions (all throw error) ########
79
63
  // can't know the types of the run type function parameters, neither the return type, so only compare function name and length
@@ -117,6 +101,26 @@ class FunctionRunType extends src_lib_baseRunTypes.BaseRunType {
117
101
  getReturnType() {
118
102
  return this.src.return._rt;
119
103
  }
104
+ /** returns the inner run-type when the handler returns Promise<T> (or nested Promise/function-return chains), or the plain return type otherwise */
105
+ getResolvedReturnType() {
106
+ let currentType = this;
107
+ while (true) {
108
+ if (src_lib_guards.isAnyFunctionRunType(currentType)) {
109
+ const returnType = currentType.getReturnType();
110
+ if (src_lib_guards.isPromiseRunType(returnType) || src_lib_guards.isFunctionRunType(returnType)) {
111
+ currentType = returnType;
112
+ continue;
113
+ }
114
+ return returnType;
115
+ }
116
+ const memberType = currentType.getMemberType();
117
+ if (src_lib_guards.isPromiseRunType(memberType) || src_lib_guards.isFunctionRunType(memberType)) {
118
+ currentType = memberType;
119
+ continue;
120
+ }
121
+ return memberType;
122
+ }
123
+ }
120
124
  getParameters() {
121
125
  return this.parameterRunTypes;
122
126
  }
@@ -149,7 +153,7 @@ class FunctionRunType extends src_lib_baseRunTypes.BaseRunType {
149
153
  }
150
154
  static __type = [() => type.__ΩTypeFunction, "CallType", () => src_lib_baseRunTypes.BaseRunType, () => src_nodes_collection_functionParams.FunctionParamsRunType, "parameterRunTypes", function() {
151
155
  return new src_nodes_collection_functionParams.FunctionParamsRunType();
152
- }, () => src_lib_jitFnCompiler.JitFnCompiler, "comp", "skipJit", "SrcType", "deepkitType", "onCreated", "F", "getFamily", "getFnName", "JitFn", "jitFn", "RunTypeOptions", "opts", "args", "", "createJitParamsFunction", () => core.__ΩJitCompiledFn, "createJitCompiledParamsFunction", "createJitReturnFunction", () => core.__ΩJitCompiledFn, "createJitCompiledReturnFunction", () => src_lib_jitFnCompiler.JitFnCompiler, "JitCode", "emitIsType", () => src_lib_jitFnCompiler.JitErrorsFnCompiler, "emitTypeErrors", "emitPrepareForJson", "emitRestoreFromJson", "emitHasUnknownKeys", "emitUnknownKeyErrors", "emitStripUnknownKeys", "emitUnknownKeysToUndefined", () => src_lib_baseRunTypes.BaseRunType, "getReturnType", () => src_nodes_collection_functionParams.FunctionParamsRunType, "getParameters", "getParameterNames", "hasReturnData", "isAsync", "returnIsPromise", "ctx", "mockReturn", "mockParams", "FunctionRunType", 'n!c"Pe"!7#P7$3%>&PP7\'2()0)P"w*2+$0,P.-0.PP&\'J0/P"w021"w2238P"@24"/506P"w021"w2238n708P"w021P"@24"/509P"w021"w2238n:0;PP7<2("w=0>PP7?2("w=0@P"w=0AP"w=0BP"w=0CP"w=0DP"w=0EP"w=0FPP7G0HPP7I0JP"w2238&F0KP)0LP)0MP)0NP"w22O8"`0PP"w22O8"F`0Q5e!!6"wR'];
156
+ }, () => src_lib_jitFnCompiler.JitFnCompiler, "comp", "skipJit", "SrcType", "deepkitType", "onCreated", "F", "getFamily", "getFnName", "JitFn", "jitFn", "RunTypeOptions", "opts", "args", "", "createJitParamsFunction", () => core.__ΩJitCompiledFn, "createJitCompiledParamsFunction", "createJitReturnFunction", () => core.__ΩJitCompiledFn, "createJitCompiledReturnFunction", () => src_lib_jitFnCompiler.JitFnCompiler, "JitCode", "emitIsType", () => src_lib_jitFnCompiler.JitErrorsFnCompiler, "emitTypeErrors", "emitPrepareForJson", "emitRestoreFromJson", "emitHasUnknownKeys", "emitUnknownKeyErrors", "emitStripUnknownKeys", "emitUnknownKeysToUndefined", () => src_lib_baseRunTypes.BaseRunType, "getReturnType", () => src_lib_baseRunTypes.BaseRunType, "getResolvedReturnType", () => src_nodes_collection_functionParams.FunctionParamsRunType, "getParameters", "getParameterNames", "hasReturnData", "isAsync", "returnIsPromise", "ctx", "mockReturn", "mockParams", "FunctionRunType", 'n!c"Pe"!7#P7$3%>&PP7\'2()0)P"w*2+$0,P.-0.PP&\'J0/P"w021"w2238P"@24"/506P"w021"w2238n708P"w021P"@24"/509P"w021"w2238n:0;PP7<2("w=0>PP7?2("w=0@P"w=0AP"w=0BP"w=0CP"w=0DP"w=0EP"w=0FPP7G0HPP7I0JPP7K0LP"w2238&F0MP)0NP)0OP)0PP"w22Q8"`0RP"w22Q8"F`0S5e!!6"wT'];
153
157
  }
154
158
  exports.FunctionRunType = FunctionRunType;
155
159
  //# sourceMappingURL=function.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"function.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"function.cjs","sources":["../../../../../src/nodes/function/function.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport type {AnyFunction, SrcType, JitFn, JitCode, RunTypeOptions} from '../../types.ts';\nimport {ReflectionKind, TypeFunction} from '@deepkit/type';\nimport {BaseRunType} from '../../lib/baseRunTypes.ts';\nimport {isAnyFunctionRunType, isFunctionRunType, isPromiseRunType} from '../../lib/guards.ts';\nimport {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';\nimport {PromiseRunType} from '../native/promise.ts';\nimport {ReflectionSubKind} from '../../constants.kind.ts';\nimport {FunctionParamsRunType} from '../collection/functionParams.ts';\nimport {JitCompiledFn} from '@mionjs/core';\nimport {registerJitFunctionCompiler} from '../../lib/jitFnsRegistry.ts';\nimport {JitFunctions} from '../../constants.functions.ts';\n\nexport class FunctionRunType<CallType extends AnyFunction = TypeFunction> extends BaseRunType<CallType> {\n // parameterRunTypes.src must be set after FunctionRunType creation\n parameterRunTypes: FunctionParamsRunType = new FunctionParamsRunType();\n skipJit(comp: JitFnCompiler): boolean {\n if (!comp) return true;\n return comp.fnID !== JitFunctions.toJSCode.id;\n }\n onCreated(deepkitType: SrcType): void {\n // here we are mapping parameters from TypeParameter[] to TypeTuple as TupleRunType() is the same functionality as ParameterRunType[]\n super.onCreated(deepkitType);\n // Create a synthetic type for parameters with its own subKind\n // Explicitly exclude _typeId and _formatId so the params type gets its own cached IDs\n const paramsType = {...deepkitType, subKind: ReflectionSubKind.params} as any;\n delete paramsType._typeId;\n delete paramsType._formatId;\n this.parameterRunTypes.onCreated(paramsType);\n }\n getFamily(): 'F' {\n return 'F';\n }\n getFnName(): string | number {\n const name = (this.src as TypeFunction).name;\n if (!name) return '';\n if (typeof name === 'symbol') return name.toString();\n return name;\n }\n createJitParamsFunction(jitFn: JitFn, opts?: RunTypeOptions): (...args: any[]) => any {\n return this.createJitCompiledParamsFunction(jitFn, opts).fn;\n }\n createJitCompiledParamsFunction(jitFn: JitFn, opts?: RunTypeOptions): JitCompiledFn {\n const start = opts?.paramsSlice?.start;\n const end = opts?.paramsSlice?.end;\n if (start && end) {\n if (start < 0 || end > this.parameterRunTypes.getChildRunTypes().length)\n throw new Error(`Invalid paramsSlice, start: ${start}, end: ${end}.`);\n if (end <= start) throw new Error(`Invalid paramsSlice, start: ${start}, end: ${end}`);\n }\n return this.parameterRunTypes.createJitCompiledFunction(jitFn.id, undefined, opts);\n }\n createJitReturnFunction(jitFn: JitFn): (...args: any[]) => any {\n return this.createJitCompiledReturnFunction(jitFn).fn;\n }\n\n createJitCompiledReturnFunction(jitFn: JitFn, opts?: RunTypeOptions): JitCompiledFn {\n return this.getResolvedReturnType().createJitCompiledFunction(jitFn.id, undefined, opts);\n }\n\n // ######## JIT functions (all throw error) ########\n\n // can't know the types of the run type function parameters, neither the return type, so only compare function name and length\n emitIsType(comp: JitFnCompiler): JitCode {\n const minLength = this.parameterRunTypes.totalRequiredParams(comp);\n const totalParams = this.parameterRunTypes.getParamRunTypes(comp).length;\n const hasOptional = totalParams > minLength;\n const maxLength =\n this.parameterRunTypes.hasRestParameter(comp) || !hasOptional ? '' : ` && ${comp.vλl}.length <= ${totalParams}`;\n return {code: `(typeof ${comp.vλl} === 'function' && ${comp.vλl}.length >= ${minLength} ${maxLength})`, type: 'E'};\n }\n emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {\n return {code: `if (!(${this.emitIsType(comp).code})) ${comp.callJitErr(this)};`, type: 'S'};\n }\n /**\n * json encode a function\n */\n emitPrepareForJson(): JitCode {\n throw new Error(`Compile function PrepareForJson not supported, call compileParams or compileReturn instead.`);\n }\n emitRestoreFromJson(): JitCode {\n throw new Error(`Compile function RestoreFromJson not supported, call compileParams or compileReturn instead.`);\n }\n emitHasUnknownKeys(): JitCode {\n return {code: '', type: 'E'};\n }\n emitUnknownKeyErrors(): JitCode {\n return {code: '', type: 'S'};\n }\n emitStripUnknownKeys(): JitCode {\n return {code: '', type: 'S'};\n }\n emitUnknownKeysToUndefined(): JitCode {\n return {code: '', type: 'S'};\n }\n\n // TODO: paramsSlice has been removed as options are not jet passed when building the run type. maybe we can pass it to the JitCompileOperation instead\n // constructor() {\n // const start = opts?.paramsSlice?.start;\n // const end = opts?.paramsSlice?.end;\n // parameterRunTypes = src.parameters.slice(start, end).map((p) => visitor(p, parents, opts)) as ParameterRunType[];\n // }\n getReturnType(): BaseRunType {\n return (this.src.return as SrcType)._rt as BaseRunType;\n }\n /** returns the inner run-type when the handler returns Promise<T> (or nested Promise/function-return chains), or the plain return type otherwise */\n getResolvedReturnType(): BaseRunType {\n let currentType: PromiseRunType | FunctionRunType<any> = this; // eslint-disable-line @typescript-eslint/no-this-alias\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (isAnyFunctionRunType(currentType)) {\n const returnType = currentType.getReturnType();\n if (isPromiseRunType(returnType) || isFunctionRunType(returnType)) {\n currentType = returnType;\n continue;\n }\n return returnType;\n }\n const memberType = currentType.getMemberType();\n if (isPromiseRunType(memberType) || isFunctionRunType(memberType)) {\n currentType = memberType;\n continue;\n }\n return memberType;\n }\n }\n getParameters(): FunctionParamsRunType {\n return this.parameterRunTypes;\n }\n getParameterNames(opts?: RunTypeOptions): string[] {\n const start = opts?.paramsSlice?.start;\n const end = opts?.paramsSlice?.end;\n if (start || end) {\n return this.src.parameters.slice(start, end).map((p) => p.name);\n }\n return this.src.parameters.map((p) => p.name);\n }\n hasReturnData(): boolean {\n const returnKind = this.getReturnType().src.kind;\n return (\n returnKind !== ReflectionKind.void && returnKind !== ReflectionKind.never && returnKind !== ReflectionKind.undefined\n );\n }\n isAsync(): boolean {\n const returnKind = this.getReturnType().src.kind;\n return (\n returnKind === ReflectionKind.promise || returnKind === ReflectionKind.any || returnKind === ReflectionKind.unknown\n );\n }\n returnIsPromise(): boolean {\n return isPromiseRunType(this.getReturnType());\n }\n async mockReturn(ctx?: RunTypeOptions): Promise<any> {\n await registerJitFunctionCompiler(JitFunctions.mock);\n return this.getReturnType().mockType(ctx);\n }\n async mockParams(ctx?: RunTypeOptions): Promise<any[]> {\n await registerJitFunctionCompiler(JitFunctions.mock);\n return this.parameterRunTypes.mockType(ctx);\n }\n}\n"],"names":["BaseRunType","FunctionParamsRunType","JitFunctions","ReflectionSubKind","isAnyFunctionRunType","isPromiseRunType","isFunctionRunType","ReflectionKind","registerJitFunctionCompiler","__ΩTypeFunction","JitFnCompiler","__ΩJitCompiledFn","JitErrorsFnCompiler"],"mappings":";;;;;;;;;;;;;;;AAkBM,MAAO,wBAAqEA,qBAAAA,YAAqB;AAAA;AAAA,EAEnG,oBAA2C,IAAIC,oCAAAA,sBAAA;AAAA,EAC/C,QAAQ,MAAmB;AACvB,QAAI,CAAC;AAAM,aAAO;AAClB,WAAO,KAAK,SAASC,wBAAAA,aAAa,SAAS;AAAA,EAC/C;AAAA,EACA,UAAU,aAAoB;AAE1B,UAAM,UAAU,WAAW;AAG3B,UAAM,aAAa,EAAC,GAAG,aAAa,SAASC,mBAAAA,kBAAkB,OAAA;AAC/D,WAAO,WAAW;AAClB,WAAO,WAAW;AAClB,SAAK,kBAAkB,UAAU,UAAU;AAAA,EAC/C;AAAA,EACA,YAAS;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AAA,MAAAE,sBAAAA,qBAAA,kBAAA,sBAAA,uBAAA,sBAAA,wBAAA,wBAAA,8BAAA,MAAAZ,qBAAAA,aAAA,iBAAA,MAAAA,qBAAAA,aAAA,yBAAA,MAAAC,oCAAAA,uBAAA,iBAAA,qBAAA,iBAAA,WAAA,mBAAA,OAAA,cAAA,cAAA,mBAAA,2PAAA;;;"}
@@ -23,6 +23,7 @@ export declare class FunctionRunType<CallType extends AnyFunction = TypeFunction
23
23
  emitStripUnknownKeys(): JitCode;
24
24
  emitUnknownKeysToUndefined(): JitCode;
25
25
  getReturnType(): BaseRunType;
26
+ getResolvedReturnType(): BaseRunType;
26
27
  getParameters(): FunctionParamsRunType;
27
28
  getParameterNames(opts?: RunTypeOptions): string[];
28
29
  hasReturnData(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"array.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"array.cjs","sources":["../../../../../src/nodes/member/array.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport type {Type, TypeArray} from '@deepkit/type';\nimport type {JitCode} from '../../types.ts';\nimport type {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';\nimport {MemberRunType} from '../../lib/baseRunTypes.ts';\nimport {childIsExpression} from '../../lib/utils.ts';\n\nexport class ArrayRunType<T extends Type = TypeArray> extends MemberRunType<T> {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n startIndex(comp: JitFnCompiler): number {\n return 0;\n }\n getChildVarName(comp: JitFnCompiler): string {\n return comp.getLocalVarName('i', this);\n }\n getChildLiteral(comp: JitFnCompiler): string {\n return this.getChildVarName(comp);\n }\n useArrayAccessor(): true {\n return true;\n }\n isOptional(): boolean {\n return false;\n }\n\n // #### jit code ####\n emitIsType(comp: JitFnCompiler): JitCode {\n this.checkNonSkipTypes(comp);\n const resultVal = comp.getLocalVarName('res', this);\n const index = this.getChildVarName(comp);\n const child = this.getJitChild(comp);\n const childJit = comp.compileIsType(child, 'E');\n if (!childJit?.code && comp.opts.noIsArrayCheck) return {code: undefined, type: 'E'};\n if (!childJit?.code) return {code: `Array.isArray(${comp.vλl})`, type: 'E'};\n const isArrayCheckCode = comp.opts.noIsArrayCheck ? '' : `if (!Array.isArray(${comp.vλl})) return false;`;\n return {\n code: `\n ${isArrayCheckCode}\n for (let ${index} = ${this.startIndex(comp)}; ${index} < ${comp.vλl}.length; ${index}++) {\n const ${resultVal} = ${childJit.code};\n if (!(${resultVal})) return false;\n }\n return true;\n `,\n type: 'RB',\n };\n }\n emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {\n this.checkNonSkipTypes(comp);\n const index = this.getChildVarName(comp);\n const child = this.getJitChild(comp);\n const childJit = comp.compileTypeErrors(child, 'S');\n if (!childJit?.code && comp.opts.noIsArrayCheck) return {code: undefined, type: 'E'};\n if (!childJit?.code) return {code: `if (!Array.isArray(${comp.vλl})) ${comp.callJitErr(this)};`, type: 'S'};\n const itemsCode = `for (let ${index} = ${this.startIndex(comp)}; ${index} < ${comp.vλl}.length; ${index}++) {${childJit.code}}`;\n if (comp.opts.noIsArrayCheck) return {code: itemsCode, type: 'S'};\n return {\n code: `if (!Array.isArray(${comp.vλl})) {${comp.callJitErr(this)}} else {${itemsCode}}`,\n type: 'S',\n };\n }\n emitPrepareForJson(comp: JitFnCompiler): JitCode {\n this.checkNonSkipTypes(comp);\n const index = this.getChildVarName(comp);\n const child = this.getJitChild(comp);\n const childJit = comp.compilePrepareForJson(child, 'S');\n if (!childJit?.code || !child) return {code: undefined, type: 'S'};\n const isExpression = childIsExpression(childJit, child);\n const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';\n return {\n code: `for (let ${index} = ${this.startIndex(comp)}; ${index} < ${comp.vλl}.length; ${index}++) {${code}}`,\n type: 'S',\n };\n }\n emitRestoreFromJson(comp: JitFnCompiler): JitCode {\n this.checkNonSkipTypes(comp);\n const index = this.getChildVarName(comp);\n const child = this.getJitChild(comp);\n const childJit = comp.compileRestoreFromJson(child, 'S');\n if (!childJit?.code || !child) return {code: undefined, type: 'S'};\n const isExpression = childIsExpression(childJit, child);\n const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';\n return {\n code: `for (let ${index} = ${this.startIndex(comp)}; ${index} < ${comp.vλl}.length; ${index}++) {${code}}`,\n type: 'S',\n };\n }\n emitHasUnknownKeys(comp: JitFnCompiler): JitCode {\n this.checkNonSkipTypes(comp);\n if (this.getMemberType().getFamily() === 'A') return {code: undefined, type: 'E'};\n const child = this.getJitChild(comp);\n const childJit = comp.compileHasUnknownKeys(child, 'E');\n if (!childJit?.code) return {code: undefined, type: 'E'};\n const resultVal = comp.getLocalVarName('res', this);\n const index = this.getChildVarName(comp);\n\n return {\n code: `\n if (!Array.isArray(${comp.vλl})) return false;\n for (let ${index} = ${this.startIndex(comp)}; ${index} < ${comp.vλl}.length; ${index}++) {\n const ${resultVal} = ${childJit.code};\n if (${resultVal}) return true;\n }\n return false;\n `,\n type: 'RB',\n };\n }\n emitUnknownKeyErrors(comp: JitErrorsFnCompiler): JitCode {\n this.checkNonSkipTypes(comp);\n if (this.getMemberType().getFamily() === 'A') return {code: '', type: 'E'};\n const child = this.getJitChild(comp);\n const childJit = comp.compileUnknownKeyErrors(child, 'S');\n return this.traverseCode(comp, childJit);\n }\n emitStripUnknownKeys(comp: JitFnCompiler): JitCode {\n this.checkNonSkipTypes(comp);\n if (this.getMemberType().getFamily() === 'A') return {code: '', type: 'E'};\n const child = this.getJitChild(comp);\n const childJit = comp.compileStripUnknownKeys(child, 'S');\n return this.traverseCode(comp, childJit);\n }\n emitUnknownKeysToUndefined(comp: JitFnCompiler): JitCode {\n this.checkNonSkipTypes(comp);\n if (this.getMemberType().getFamily() === 'A') return {code: '', type: 'E'};\n const child = this.getJitChild(comp);\n const childJit = comp.compileUnknownKeysToUndefined(child, 'S');\n return this.traverseCode(comp, childJit);\n }\n\n traverseCode(comp: JitFnCompiler, childJit: JitCode | undefined): {code: string | undefined; type: 'S'} {\n if (!childJit?.code) return {code: undefined, type: 'S'};\n const index = this.getChildVarName(comp);\n return {\n code: `for (let ${index} = ${this.startIndex(comp)}; ${index} < ${comp.vλl}.length; ${index}++) {${childJit.code}}`,\n type: 'S',\n };\n }\n\n checkNonSkipTypes(comp: JitFnCompiler) {\n const child = this.getMemberType();\n if (child.skipJit(comp)) throw new Error(`Arrays can not have non serializable types, ie: Symbol[], Function[], etc.`);\n }\n}\n"],"names":["MemberRunType","childIsExpression"],"mappings":";;;;AAaM,MAAO,qBAAiDA,qBAAAA,cAAgB;AAAA;AAAA,EAE1E,WAAW,MAAmB;AAC1B,WAAO;AAAA,EACX;AAAA,EACA,gBAAgB,MAAmB;AAC/B,WAAO,KAAK,gBAAgB,KAAK,IAAI;AAAA,EACzC;AAAA,EACA,gBAAgB,MAAmB;AAC/B,WAAO,KAAK,gBAAgB,IAAI;AAAA,EACpC;AAAA,EACA,mBAAgB;AACZ,WAAO;AAAA,EACX;AAAA,EACA,aAAU;AACN,WAAO;AAAA,EACX;AAAA;AAAA,EAGA,WAAW,MAAmB;AAC1B,SAAK,kBAAkB,IAAI;AAC3B,UAAM,YAAY,KAAK,gBAAgB,OAAO,IAAI;AAClD,UAAM,QAAQ,KAAK,gBAAgB,IAAI;AACvC,UAAM,QAAQ,KAAK,YAAY,IAAI;AACnC,UAAM,WAAW,KAAK,cAAc,OAAO,GAAG;AAC9C,QAAI,CAAC,UAAU,QAAQ,KAAK,KAAK;AAAgB,aAAO,EAAC,MAAM,QAAW,MAAM,IAAA;AAChF,QAAI,C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D,QAAI,CAAC,UAAU;AAAM,aAAO,EAAC,MAAM,QAAW,MAAM,IAAA;AACpD,UAAM,QAAQ,KAAK,gBAAgB,IAAI;AACvC,WAAO;AAAA,MACH,MAAM,YAAY,KAAK,MAAM,KAAK,WAAW,IAAI,CAAC,KAAK,KAAK,MAAM,KAAK,GAAG,YAAY,KAAK,QAAQ,SAAS,IAAI;AAAA,MAChH,MAAM;AAAA,IAAA;AAAA,EAEd;AAAA,EAEA,kBAAkB,MAAmB;AACjC,UAAM,QAAQ,KAAK,cAAA;AACnB,QAAI,MAAM,QAAQ,IAAI;AAAG,YAAM,IAAI,MAAM,4EAA4E;AAAA,EACzH;AAAA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"callSignature.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"callSignature.cjs","sources":["../../../../../src/nodes/member/callSignature.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport {TypeCallSignature} from '@deepkit/type';\nimport {RunTypeChildAccessor} from '../../types.ts';\nimport {getPropIndex} from '../../lib/utils.ts';\nimport {FunctionRunType} from '../function/function.ts';\nimport type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';\n\n/**\n * Represents a call signature.\n * Call signature is an special node within in interface or object literal that represents a function signature but can have extra properties.\n * ie:\n * type = {\n * (a: number, b: boolean): string; // call signature node\n * popA: number;\n * }\n *\n * So when a call signature is present the parent object literal or interface is considered a function.\n */\nexport class CallSignatureRunType extends FunctionRunType<TypeCallSignature> implements RunTypeChildAccessor {\n getChildIndex = (comp: JitFnCompiler) => {\n const start = comp?.opts?.paramsSlice?.start;\n if (start) return getPropIndex(this.src) - start;\n return getPropIndex(this.src);\n };\n getChildVarName = () => '';\n getChildLiteral = () => '\"\"';\n useArrayAccessor = () => false;\n isOptional = () => false;\n}\n"],"names":["FunctionRunType","getPropIndex","__ΩTypeCallSignature","__ΩRunTypeChildAccessor"],"mappings":";;;;;;;;;;AAuBM,MAAO,6BAA6BA,4BAAAA,gBAAkC;AAAA,EACxE,gBAAa,aAAG,CAAC,SAAuB;AACpC,UAAM,QAAQ,MAAM,MAAM,aAAa;AACvC,QAAI;AAAO,aAAOC,2BAAa,KAAK,GAAG,IAAI;AAC3C,WAAOA,cAAAA,aAAa,KAAK,GAAG;AAAA,EAChC,GAAC,CAAA,iBAAA,QAAA,IAAA,WAAA,CAAA;AAAA,EACD,kBAAkB,MAAM;AAAA,EACxB,kBAAkB,MAAM;AAAA,EACxB,mBAAmB,MAAM;AAAA,EACzB,aAAa,MAAM;AAAA;wBARH,CAAC,SAAuB;AACpC,YAAM,QAAQ,MAAM,MAAM,aAAa;AACvC,UAAI;AAAO,eAAOA,2BAAa,KAAK,GAAG,IAAI;AAC3C,aAAOA,cAAAA,aAAa,KAAK,GAAG;AAAA,IAChC;;WACkB,MAAM;AAAA,EAAE,GAAA,mBAAA,WAAA;AAAA,WACR,MAAM;AAAA,EAAI,GAAA,oBAAA,WAAA;AAAA,WACT,MAAM;AAAA;WACZ,MAAM;AAAA,EAAK,GAAA,MAAAC,KAAAA,sBAAA,MAAAC,UAAAA,yBAAA,wBAAA,2CAAA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"genericMember.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"genericMember.cjs","sources":["../../../../../src/nodes/member/genericMember.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport type {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';\nimport {MemberRunType} from '../../lib/baseRunTypes.ts';\nimport type {JitCode, SrcMember} from '../../types.ts';\nimport {childIsExpression} from '../../lib/utils.ts';\n\n// TODO: investigate is other member types cloud extend this class instead of MemberRunType\nexport class GenericMemberRunType<T extends SrcMember> extends MemberRunType<T> {\n index = 0;\n getChildIndex() {\n return this.index;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getChildVarName(comp: JitFnCompiler): string | number {\n return this.index;\n }\n getChildLiteral(comp: JitFnCompiler) {\n return this.getChildVarName(comp);\n }\n useArrayAccessor() {\n return true;\n }\n isOptional() {\n return false;\n }\n emitIsType(comp: JitFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const childJit = comp.compileIsType(child, 'E');\n if (!childJit?.code) return {code: undefined, type: 'E'};\n if (this.isOptional()) return {code: `${comp.getChildVλl()} === undefined || (${childJit.code})`, type: 'E'};\n return childJit;\n }\n emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const childJit = comp.compileTypeErrors(child, 'S');\n if (!childJit?.code) return {code: undefined, type: 'S'};\n if (this.isOptional()) return {code: `if (${comp.getChildVλl()} !== undefined) {${childJit.code}}`, type: 'S'};\n return childJit;\n }\n emitPrepareForJson(comp: JitFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const childJit = comp.compilePrepareForJson(child, 'S');\n if (!childJit?.code || !child) return {code: undefined, type: 'S'};\n const isExpression = childIsExpression(childJit, child); // expressions must be assigned to a variable\n const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code}` : childJit.code || '';\n if (this.isOptional()) return {code: `if (${comp.getChildVλl()} !== undefined) {${code}}`, type: 'S'};\n return {code, type: 'S'};\n }\n emitRestoreFromJson(comp: JitFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const childJit = comp.compileRestoreFromJson(child, 'S');\n if (!childJit?.code || !child) return {code: undefined, type: 'S'};\n const isExpression = childIsExpression(childJit, child);\n const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';\n if (this.isOptional()) return {code: `if (${com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,eAAeC,cAAAA,kBAAkB,UAAU,KAAK;AACtD,UAAM,OAAO,eAAe,GAAG,KAAK,YAAA,CAAa,MAAM,SAAS,IAAI,KAAK,SAAS,QAAQ;AAC1F,QAAI,KAAK,WAAA;AAAc,aAAO,EAAC,MAAM,OAAO,KAAK,YAAA,CAAa,oBAAoB,IAAI,KAAK,MAAM,IAAA;AACjG,WAAO,EAAC,MAAM,MAAM,IAAA;AAAA,EACxB;AAAA,EACA,oBAAoB,MAAmB;AACnC,UAAM,QAAQ,KAAK,YAAY,IAAI;AACnC,UAAM,WAAW,KAAK,uBAAuB,OAAO,GAAG;AACvD,QAAI,CAAC,UAAU,QAAQ,CAAC;AAAO,aAAO,EAAC,MAAM,QAAW,MAAM,IAAA;AAC9D,UAAM,eAAeA,cAAAA,kBAAkB,UAAU,KAAK;AACtD,UAAM,OAAO,eAAe,GAAG,KAAK,YAAA,CAAa,MAAM,SAAS,IAAI,MAAM,SAAS,QAAQ;AAC3F,QAAI,KAAK,WAAA;AAAc,aAAO,EAAC,MAAM,OAAO,KAAK,YAAA,CAAa,oBAAoB,IAAI,KAAK,MAAM,IAAA;AACjG,WAAO,EAAC,MAAM,MAAM,IAAA;AAAA,EACxB;AAAA;WAhDQ;AAAA,EAAC,GAAA,iBAAA,iBAAA,QAAA,mBAAA,mBAAA,oBAAA,cAAA,WAAA,cAAA,uBAAA,kBAAA,sBAAA,uBAAA,wBAAA,oGAAA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"indexProperty.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"indexProperty.cjs","sources":["../../../../../src/nodes/member/indexProperty.ts"],"sourcesContent":["import {ReflectionKind, TypeIndexSignature} from '@deepkit/type';\nimport {MemberRunType} from '../../lib/baseRunTypes.ts';\nimport {type JitCode} from '../../types.ts';\nimport {JitFunctions} from '../../constants.functions.ts';\nimport type {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';\nimport {InterfaceRunType} from '../collection/interface.ts';\nimport {childIsExpression} from '../../lib/utils.ts';\n\n/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nexport class IndexSignatureRunType extends MemberRunType<TypeIndexSignature> {\n isOptional(): boolean {\n return true;\n }\n getChildVarName(comp: JitFnCompiler): string {\n return comp.getLocalVarName('p', this);\n }\n getChildLiteral(comp: JitFnCompiler): string {\n return this.getChildVarName(comp);\n }\n useArrayAccessor(): true {\n return true;\n }\n skipJit(comp: JitFnCompiler): boolean {\n const index = (this.src as TypeIndexSignature).index?.kind;\n if (index === ReflectionKind.symbol) {\n return comp?.fnID !== JitFunctions.toJSCode.id;\n }\n return false;\n }\n\n // #### jit code ####\n emitIsType(comp: JitFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const childJit = comp.compileIsType(child, 'E');\n if (!childJit?.code) return {code: undefined, type: 'E'};\n return {\n code: `for (const ${this.getChildVarName(comp)} in ${comp.vλl}){if (!(${childJit.code})) return false;} return true;`,\n type: 'RB',\n };\n }\n emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const childJit = comp.compileTypeErrors(child, 'S');\n if (!childJit?.code) return {code: undefined, type: 'S'};\n return {code: `for (const ${this.getChildVarName(comp)} in ${comp.vλl}) {${childJit.code}}`, type: 'S'};\n }\n emitPrepareForJson(comp: JitFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const childJit = comp.compilePrepareForJson(child, 'S');\n if (!child || !childJit?.code) return {code: undefined, type: 'S'};\n const varName = comp.vλl;\n const prop = this.getChildVarName(comp);\n const skipCode = this.getSkipCode(comp, prop);\n const isExpression = childIsExpression(childJit, child);\n const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';\n return {code: `for (const ${prop} in ${varName}){${skipCode} ${code}}`, type: 'S'};\n }\n emitRestoreFromJson(comp: JitFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const childJit = comp.compileRestoreFromJson(child, 'S');\n if (!child || !childJit?.code) return {code: undefined, type: 'S'};\n const varName = comp.vλl;\n const prop = this.getChildVarName(comp);\n const skipCode = this.getSkipCode(comp, prop);\n const isExpression = childIsExpression(childJit, child);\n const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';\n return {code: `for (const ${prop} in ${varName}){${skipCode} ${code}}`, type: 'S'};\n }\n emitHasUnknownKeys(comp: JitFnCompiler): JitCode {\n if (this.getMemberType().getFamily() === 'A') return {code: undefined, type: 'E'};\n const child = this.getJitChild(comp);\n const childJit = comp.compileHasUnknownKeys(child, 'E');\n if (!childJit?.code) return {code: '', type: 'E'};\n const varName = comp.vλl;\n const prop = this.getChildVarName(comp);\n const resultVal = comp.getLocalVarName('res', this);\n return {\n code: `for (const ${prop} in ${varName}) {const ${resultVal} = ${childJit.code};if (${resultVal}) return true;}return false;`,\n type: 'RB',\n };\n }\n emitUnknownKeyErrors(comp: JitErrorsFnCompiler): JitCode {\n if (this.getMemberType().getFamily() === 'A') return {code: undefined, type: 'S'};\n const child = this.getJitChild(comp);\n const childJit = comp.compileUnknownKeyErrors(child, 'S');\n return this.traverseCode(comp, childJit);\n }\n emitStripUnknownKeys(comp: JitFnCompiler): JitCode {\n if (this.getMemberType().getFamily() === 'A') return {code: undefined, type: 'S'};\n const child = this.getJitChild(comp);\n const childJit = comp.compileStripUnknownKeys(child, 'S');\n return this.traverseCode(comp, childJit);\n }\n emitUnknownKeysToUndefined(comp: JitFnCompiler): JitCode {\n if (this.getMemberType().getFamily() === 'A') return {code: undefined, type: 'S'};\n const child = this.getJitChild(comp);\n const childJit = comp.compileUnknownKeysToUndefined(child, 'S');\n return this.traverseCode(comp, childJit);\n }\n traverseCode(comp: JitFnCompiler, childJit: JitCode | undefined): JitCode {\n if (!childJit?.code) return {code: undefined, type: 'S'};\n const prop = this.getChildVarName(comp);\n return {code: `for (const ${prop} in ${comp.vλl}) {${childJit.code}}`, type: 'S'};\n }\n /**\n * if index property should be skipped then it output some code to skip it,\n * this happen when an object/interface has an index property but also has named properties\n * that might collide with the index property. ie {[key: string]: string, a: string}\n * when executing the logic for the index property we need to skip the named properties.\n */\n getSkipCode(comp: JitFnCompiler, prop: string): string {\n const parent = this.getParent() as InterfaceRunType;\n const namedChildren = parent.getNamedChildren(comp);\n const skipNames = namedChildren.length\n ? namedChildren.map((child) => `${child.getChildLiteral(comp)} === ${prop}`).join(' || ')\n : '';\n return namedChildren.length ? `if (${skipNames}) continue;` : '';\n }\n}\n"],"names":["MemberRunType","ReflectionKind","JitFunctions","childIsExpression"],"mappings":";;;;;;;;;;AAeM,MAAO,8BAA8BA,qBAAAA,cAAiC;AAAA,EACxE,aAAU;AACN,WAAO;AAAA,EACX;AAAA,EACA,gBAAgB,MAAmB;AAC/B,WAAO,KAAK,gBAAgB,KAAK,IAAI;AAAA,EACzC;AAAA,EACA,gBAAgB,MAAmB;AAC/B,WAAO,KAAK,gBAAgB,IAAI;AAAA,EACpC;AAAA,EACA,mBAAgB;AACZ,WAAO;AAAA,EACX;AAAA,EACA,QAAQ,MAAmB;AACvB,UAAM,QAAS,KAAK,IAA2B,OAAO;AACtD,QAAI,UAAUC,KAAAA,eAAe,QAAQ;AACjC,aAAO,MAAM,SAASC,wBAAAA,aAAa,SAAS;AAAA,IAChD;AACA,WAAO;AAAA,EACX;AAAA;AAAA,EAGA,WAAW,MAAmB;AAC1B,UAAM,QAAQ,KAAK,YAAY,IAAI;AACnC,UAAM,WAAW,KAAK,cAAc,OAAO,GAAG;AAC9C,QAAI,CAAC,UAAU;AAAM,aAAO,EAAC,MAAM,QAAW,MAAM,IAAA;AACpD,WAAO;AAAA,MACH,MAAM,cAAc,KAAK,gBAAgB,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AC1C,QAAI,KAAK,gBAAgB,UAAA,MAAgB;AAAK,aAAO,EAAC,MAAM,QAAW,MAAM,IAAA;AAC7E,UAAM,QAAQ,KAAK,YAAY,IAAI;AACnC,UAAM,WAAW,KAAK,8BAA8B,OAAO,GAAG;AAC9D,WAAO,KAAK,aAAa,MAAM,QAAQ;AAAA,EAC3C;AAAA,EACA,aAAa,MAAqB,UAA6B;AAC3D,QAAI,CAAC,UAAU;AAAM,aAAO,EAAC,MAAM,QAAW,MAAM,IAAA;AACpD,UAAM,OAAO,KAAK,gBAAgB,IAAI;AACtC,WAAO,EAAC,MAAM,cAAc,IAAI,OAAO,KAAK,GAAG,MAAM,SAAS,IAAI,KAAK,MAAM,IAAA;AAAA,EACjF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY,MAAqB,MAAY;AACzC,UAAM,SAAS,KAAK,UAAA;AACpB,UAAM,gBAAgB,OAAO,iBAAiB,IAAI;AAClD,UAAM,YAAY,cAAc,SAC1B,cAAc,IAAG,aAAC,CAAC,UAAU,GAAG,MAAM,gBAAgB,IAAI,CAAC,QAAQ,IAAI,IAAE,CAAA,SAAA,IAAA,SAAA,CAAA,CAAA,EAAE,KAAK,MAAM,IACtF;AACN,WAAO,cAAc,SAAS,OAAO,SAAS,gBAAgB;AAAA,EAClE;AAAA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"method.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"method.cjs","sources":["../../../../../src/nodes/member/method.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport {TypeMethod} from '@deepkit/type';\nimport {FunctionRunType} from '../function/function.ts';\nimport {RunTypeChildAccessor} from '../../types.ts';\nimport {getPropIndex, getPropLiteral, getPropVarName, useArrayAccessorForProp} from '../../lib/utils.ts';\nimport type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';\n\nexport class MethodRunType extends FunctionRunType<TypeMethod> implements RunTypeChildAccessor {\n getChildIndex = (comp: JitFnCompiler) => {\n const start = comp?.opts?.paramsSlice?.start;\n if (start) return getPropIndex(this.src) - start;\n return getPropIndex(this.src);\n };\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getChildVarName(comp: JitFnCompiler) {\n return getPropVarName(this.src.name);\n }\n getChildLiteral(comp: JitFnCompiler) {\n return getPropLiteral(this.getChildVarName(comp));\n }\n useArrayAccessor() {\n return useArrayAccessorForProp(this.src.name);\n }\n isOptional = () => !!this.src.optional;\n}\n"],"names":["FunctionRunType","getPropIndex","getPropVarName","getPropLiteral","useArrayAccessorForProp","__ΩTypeMethod","__ΩRunTypeChildAccessor"],"mappings":";;;;;;;;;;AAYM,MAAO,sBAAsBA,4BAAAA,gBAA2B;AAAA,EAC1D,gBAAa,aAAG,CAAC,SAAuB;AACpC,UAAM,QAAQ,MAAM,MAAM,aAAa;AACvC,QAAI;AAAO,aAAOC,2BAAa,KAAK,GAAG,IAAI;AAC3C,WAAOA,cAAAA,aAAa,KAAK,GAAG;AAAA,EAChC,GAAC,CAAA,iBAAA,QAAA,IAAA,WAAA,CAAA;AAAA;AAAA,EAED,gBAAgB,MAAmB;AAC/B,WAAOC,6BAAe,KAAK,IAAI,IAAI;AAAA,EACvC;AAAA,EACA,gBAAgB,MAAmB;AAC/B,WAAOC,6BAAe,KAAK,gBAAgB,IAAI,CAAC;AAAA,EACpD;AAAA,EACA,mBAAgB;AACZ,WAAOC,sCAAwB,KAAK,IAAI,IAAI;AAAA,EAChD;AAAA,EACA,aAAa,MAAM,CAAC,CAAC,KAAK,IAAI;AAAA;wBAfd,CAAC,SAAuB;AACpC,YAAM,QAAQ,MAAM,MAAM,aAAa;AACvC,UAAI;AAAO,eAAOH,2BAAa,KAAK,GAAG,IAAI;AAC3C,aAAOA,cAAAA,aAAa,KAAK,GAAG;AAAA,IAChC,GAAC,CAAA,iBAAA,QAAA,IAAA,WAAA,CAAA;AAAA,EAAA,GAAA,iBAAA,QAAA,mBAAA,mBAAA,oBAAA,cAAA,WAAA;AAAA,WAWY,MAAM,CAAC,CAAC,KAAK,IAAI;AAAA,EAAQ,GAAA,MAAAI,KAAAA,eAAA,MAAAC,UAAAA,yBAAA,iBAAA,kDAAA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"methodSignature.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"methodSignature.cjs","sources":["../../../../../src/nodes/member/methodSignature.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport {TypeMethodSignature} from '@deepkit/type';\nimport {RunTypeChildAccessor} from '../../types.ts';\nimport {FunctionRunType} from '../function/function.ts';\nimport {getPropIndex, getPropLiteral, getPropVarName, useArrayAccessorForProp} from '../../lib/utils.ts';\nimport type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';\n\nexport class MethodSignatureRunType extends FunctionRunType<TypeMethodSignature> implements RunTypeChildAccessor {\n getChildIndex = (comp: JitFnCompiler) => {\n const start = comp?.opts?.paramsSlice?.start;\n if (start) return getPropIndex(this.src) - start;\n return getPropIndex(this.src);\n };\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getChildVarName(comp: JitFnCompiler) {\n return getPropVarName(this.src.name);\n }\n getChildLiteral(comp: JitFnCompiler) {\n return getPropLiteral(this.getChildVarName(comp));\n }\n useArrayAccessor() {\n return useArrayAccessorForProp(this.src.name);\n }\n isOptional = () => !!this.src.optional;\n skipCommas = false;\n}\n"],"names":["FunctionRunType","getPropIndex","getPropVarName","getPropLiteral","useArrayAccessorForProp","__ΩTypeMethodSignature","__ΩRunTypeChildAccessor"],"mappings":";;;;;;;;;;AAYM,MAAO,+BAA+BA,4BAAAA,gBAAoC;AAAA,EAC5E,gBAAa,aAAG,CAAC,SAAuB;AACpC,UAAM,QAAQ,MAAM,MAAM,aAAa;AACvC,QAAI;AAAO,aAAOC,2BAAa,KAAK,GAAG,IAAI;AAC3C,WAAOA,cAAAA,aAAa,KAAK,GAAG;AAAA,EAChC,GAAC,CAAA,iBAAA,QAAA,IAAA,WAAA,CAAA;AAAA;AAAA,EAED,gBAAgB,MAAmB;AAC/B,WAAOC,6BAAe,KAAK,IAAI,IAAI;AAAA,EACvC;AAAA,EACA,gBAAgB,MAAmB;AAC/B,WAAOC,6BAAe,KAAK,gBAAgB,IAAI,CAAC;AAAA,EACpD;AAAA,EACA,mBAAgB;AACZ,WAAOC,sCAAwB,KAAK,IAAI,IAAI;AAAA,EAChD;AAAA,EACA,aAAa,MAAM,CAAC,CAAC,KAAK,IAAI;AAAA,EAC9B,aAAa;AAAA;wBAhBG,CAAC,SAAuB;AACpC,YAAM,QAAQ,MAAM,MAAM,aAAa;AACvC,UAAI;AAAO,eAAOH,2BAAa,KAAK,GAAG,IAAI;AAC3C,aAAOA,cAAAA,aAAa,KAAK,GAAG;AAAA,IAChC,GAAC,CAAA,iBAAA,QAAA,IAAA,WAAA,CAAA;AAAA,EAAA,GAAA,iBAAA,QAAA,mBAAA,mBAAA,oBAAA,cAAA,WAAA;AAAA,WAWY,MAAM,CAAC,CAAC,KAAK,IAAI;AAAA,EAAQ,GAAA,cAAA,WAAA;AAAA,WACzB;AAAA,EAAK,GAAA,MAAAI,KAAAA,wBAAA,MAAAC,UAAAA,yBAAA,0BAAA,uDAAA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"param.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"param.cjs","sources":["../../../../../src/nodes/member/param.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport type {TypeParameter} from '@deepkit/type';\nimport type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';\nimport {TupleMemberRunType} from './tupleMember.ts';\n\nexport class ParameterRunType<T extends TypeParameter = TypeParameter> extends TupleMemberRunType<T> {\n getParamName() {\n return this.src.name;\n }\n getChildVarName(comp: JitFnCompiler): number {\n return this.getChildIndex(comp);\n }\n getChildLiteral(comp: JitFnCompiler): number {\n return this.getChildIndex(comp);\n }\n}\n"],"names":["TupleMemberRunType"],"mappings":";;;AAWM,MAAO,yBAAkEA,6BAAAA,mBAAqB;AAAA,EAChG,eAAY;AACR,WAAO,KAAK,IAAI;AAAA,EACpB;AAAA,EACA,gBAAgB,MAAmB;AAC/B,WAAO,KAAK,cAAc,IAAI;AAAA,EAClC;AAAA,EACA,gBAAgB,MAAmB;AAC/B,WAAO,KAAK,cAAc,IAAI;AAAA,EAClC;AAAA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"property.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"property.cjs","sources":["../../../../../src/nodes/member/property.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport type {TypeProperty, TypePropertySignature} from '@deepkit/type';\nimport type {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';\nimport type {JitCode} from '../../types.ts';\nimport {childIsExpression, getPropLiteral, getPropVarName, useArrayAccessorForProp} from '../../lib/utils.ts';\nimport {MemberRunType} from '../../lib/baseRunTypes.ts';\nimport {InterfaceRunType} from '../collection/interface.ts';\nimport {JitFunctions} from '../../constants.functions.ts';\n\nexport class PropertyRunType extends MemberRunType<TypePropertySignature | TypeProperty> {\n isUnionDiscriminator = false;\n /** this is set by the parent interface if prop is optional, when optional properties are sorted */\n optionalIndex = -1;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getPropertyName() {\n return getPropVarName(this.src.name);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getChildVarName(comp: JitFnCompiler) {\n return getPropVarName(this.src.name);\n }\n getChildLiteral(comp: JitFnCompiler) {\n return getPropLiteral(this.getChildVarName(comp));\n }\n useArrayAccessor() {\n return useArrayAccessorForProp(this.src.name);\n }\n getJitChildIndex = (comp: JitFnCompiler) => (this.getParent() as InterfaceRunType).getJitChildren(comp).indexOf(this);\n isOptional = () => !!this.src.optional;\n skipJit(comp: JitFnCompiler): boolean {\n const name = (this.src as TypeProperty).name;\n if (typeof name === 'symbol') {\n return comp?.fnID !== JitFunctions.toJSCode.id;\n }\n return false;\n }\n // #### jit code ####\n\n emitIsType(comp: JitFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const childJit = comp.compileIsType(child, 'E');\n if (!childJit?.code) return {code: undefined, type: 'E'};\n return this.src.optional ? {code: `(${comp.getChildVλl()} === undefined || ${childJit.code})`, type: 'E'} : childJit;\n }\n emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const childJit = comp.compileTypeErrors(child, 'S');\n if (!childJit?.code) return {code: undefined, type: 'S'};\n return this.src.optional ? {code: `if (${comp.getChildVλl()} !== undefined) {${childJit.code}}`, type: 'S'} : childJit;\n }\n emitPrepareForJson(comp: JitFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const childJit = comp.compilePrepareForJson(child, 'S');\n if (!child || !childJit?.code) return {code: undefined, type: 'S'};\n const isExpression = childIsExpression(childJit, child);\n const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';\n if (this.src.optional) return {code: `if (${comp.getChildVλl()} !== undefined) {${code}}`, type: 'S'};\n return {code, type: 'S'};\n }\n emitRestoreFromJson(comp: JitFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const childJit = comp.compileRestoreFromJson(child, 'S');\n if (!child || !childJit?.code) return {code: undefined, type: 'S'};\n const isExpression = childIsExpression(childJit, child);\n const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';\n if (this.src.optional) return {code: `if (${comp.getChildVλl()} !== undefined) {${code}}`, type: 'S'};\n return {code, type: 'S'};\n }\n}\n"],"names":["MemberRunType","getPropVarName","getPropLiteral","useArrayAccessorForProp","JitFunctions","childIsExpression"],"mappings":";;;;;;;;;AAeM,MAAO,wBAAwBA,qBAAAA,cAAmD;AAAA,EACpF,uBAAuB;AAAA;AAAA,EAEvB,gBAAgB;AAAA;AAAA,EAEhB,kBAAe;AACX,WAAOC,6BAAe,KAAK,IAAI,IAAI;AAAA,EACvC;AAAA;AAAA,EAEA,gBAAgB,MAAmB;AAC/B,WAAOA,6BAAe,KAAK,IAAI,IAAI;AAAA,EACvC;AAAA,EACA,gBAAgB,MAAmB;AAC/B,WAAOC,6BAAe,KAAK,gBAAgB,IAAI,CAAC;AAAA,EACpD;AAAA,EACA,mBAAgB;AACZ,WAAOC,sCAAwB,KAAK,IAAI,IAAI;AAAA,EAChD;AAAA,EACA,mBAAgB,aAAG,CAAC,SAAyB,KAAK,UAAA,EAAiC,eAAe,IAAI,EAAE,QAAQ,IAAI,GAAC,CAAA,iBAAA,QAAA,IAAA,WAAA,CAAA;AAAA,EACrH,aAAa,MAAM,CAAC,CAAC,KAAK,IAAI;AAAA,EAC9B,QAAQ,MAAmB;AACvB,UAAM,OAAQ,KAAK,IAAqB;AACxC,QAAI,OAAO,SAAS,UAAU;AAC1B,aAAO,MAAM,SAASC,wBAAAA,aAAa,SAAS;AAAA,IAChD;AACA,WAAO;AAAA,EACX;AAAA;AAAA,EAGA,WAAW,MAAmB;AAC1B,UAAM,QAAQ,KAAK,YAAY,IAAI;AACnC,UAAM,WAAW,KAAK,cAAc,OAAO,GAAG;AAC9C,QAAI,CAAC,UAAU;AAAM,aAAO,EAAC,MAAM,QAAW,MAAM,IAA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,aAAO,EAAC,MAAM,OAAO,KAAK,YAAA,CAAa,oBAAoB,IAAI,KAAK,MAAM,IAAA;AACjG,WAAO,EAAC,MAAM,MAAM,IAAA;AAAA,EACxB;AAAA,EAzDuB,OAAA,SAAA,CAAA,yBAAA,gBAAA,MAAAL,qBAAAA,eAAA,wBAAA,WAAA;AAAA,WAAA;AAAA,EAAK,GAAA,iBAAA,WAAA;AAAA,WAEZ;AAAA,EAAE,GAAA,mBAAA,iBAAA,QAAA,mBAAA,mBAAA,oBAAA,oBAAA,WAAA;AAAA,WAAA,aAeC,CAAC,SAAyB,KAAK,UAAA,EAAiC,eAAe,IAAI,EAAE,QAAQ,IAAI,GAAC,CAAA,iBAAA,QAAA,IAAA,WAAA,CAAA;AAAA,EAAA,GAAA,cAAA,WAAA;AAAA,WACxG,MAAM,CAAC,CAAC,KAAK,IAAI;AAAA,EAAQ,GAAA,WAAA,WAAA,cAAA,uBAAA,kBAAA,sBAAA,uBAAA,mBAAA,6HAAA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"restParams.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"restParams.cjs","sources":["../../../../../src/nodes/member/restParams.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport type {TypeRest} from '@deepkit/type';\nimport type {ParameterRunType} from './param.ts';\nimport type {TupleMemberRunType} from './tupleMember.ts';\nimport {ArrayRunType} from './array.ts';\nimport type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';\n\nexport class RestParamsRunType extends ArrayRunType<TypeRest> {\n getChildIndex(comp: JitFnCompiler): number {\n const parent = this.getParent() as ParameterRunType | TupleMemberRunType;\n return parent.getChildIndex(comp);\n }\n startIndex(comp: JitFnCompiler): number {\n return this.getChildIndex(comp);\n }\n}\n"],"names":["ArrayRunType"],"mappings":";;;AAaM,MAAO,0BAA0BA,uBAAAA,aAAsB;AAAA,EACzD,cAAc,MAAmB;AAC7B,UAAM,SAAS,KAAK,UAAA;AACpB,WAAO,OAAO,cAAc,IAAI;AAAA,EACpC;AAAA,EACA,WAAW,MAAmB;AAC1B,WAAO,KAAK,cAAc,IAAI;AAAA,EAClC;AAAA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"tupleMember.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"tupleMember.cjs","sources":["../../../../../src/nodes/member/tupleMember.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport {ReflectionKind, TypeTupleMember, type TypeParameter} from '@deepkit/type';\nimport type {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';\nimport {MemberRunType} from '../../lib/baseRunTypes.ts';\nimport {JitCode} from '../../types.ts';\nimport {childIsExpression, getParamIndex} from '../../lib/utils.ts';\n\ntype TupleMemberT = TypeParameter | TypeTupleMember;\nexport class TupleMemberRunType<T extends TupleMemberT = TypeTupleMember> extends MemberRunType<T> {\n isOptional(): boolean {\n return !!this.src.optional || this.isRest() || this.hasDefaultValue();\n }\n getChildIndex(comp: JitFnCompiler): number {\n const start = comp?.opts?.paramsSlice?.start;\n if (start) return getParamIndex(this.src as TypeParameter) - start;\n return getParamIndex(this.src as TypeParameter);\n }\n getChildVarName(comp: JitFnCompiler): number {\n // For tuple members, use the index in the parent tuple\n const src = this.src as any;\n if (src.parent?.types) {\n return src.parent.types.indexOf(this.src);\n }\n // Fallback to parameter index for non-tuple members\n return this.getChildIndex(comp);\n }\n getChildLiteral(comp: JitFnCompiler): number {\n return this.getChildVarName(comp);\n }\n useArrayAccessor(): true {\n return true;\n }\n isRest(): boolean {\n return this.getMemberType().src.kind === ReflectionKind.rest;\n }\n skipSettingAccessor() {\n return this.isRest();\n }\n hasDefaultValue(): boolean {\n return !!(this.src as TypeParameter).default;\n }\n emitIsType(comp: JitFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const skipChild = child?.skipJit(comp);\n const childJit = comp.compileIsType(child, 'E');\n const isNonSerializable = skipChild || (!childJit?.code && !child);\n if (isNonSerializable) return {code: `${comp.getChildVλl()} === undefined`, type: 'E'}; // non serializable types must be undefined\n if (!childJit?.code) return {code: undefined, type: 'E'};\n if (this.isRest()) return childJit;\n return this.isOptional() ? {code: `(${comp.getChildVλl()} === undefined || (${childJit.code}))`, type: 'E'} : childJit;\n }\n emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const skipChild = child?.skipJit(comp);\n const childJit = comp.compileTypeErrors(child, 'S');\n const isNonSerializable = skipChild || (!childJit?.code && !child);\n if (isNonSerializable)\n return {\n code: `if (${comp.getChildVλl()} !== undefined) ${comp.callJitErrWithPath('undefined', this.getChildIndex(comp))}`,\n type: 'S',\n }; // non serializable types must be undefined\n if (!childJit?.code) return {code: undefined, type: 'S'};\n if (this.isRest()) return childJit;\n return this.isOptional() ? {code: `if (${comp.getChildVλl()} !== undefined) {${childJit.code}}`, type: 'S'} : childJit;\n }\n emitPrepareForJson(comp: JitFnCompiler): JitCode {\n const child = this.getJitChild(comp);\n const childJit = comp.compilePrepareForJson(child, 'S');\n const optionalCode = `if (${comp.getChildVλl()} === undefined ) {if (${comp.vλl}.length > ${this.getChildIndex(comp)}) ${comp.getChildVλl()} = null}`;\n if (!child || !childJit?.code) return this.isOptional() ? {code: optionalCode, type: 'S'} : {code: undefined, type: 'S'};\n const isExpression = childIsExpression(childJit, child);\n const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';\n return this.isOptional() ? {code: `${optionalCode} else {${code}}`, type: 'S'} : {code, type: 'S'};\n }\n emitRestoreFromJson(comp: JitFnCompiler): JitCode {\n if (!this.getJitChild(comp)) return {code: `${comp.getChildVλl()} = undefined;`, type: 'S'}; // non serializable are restored to undefined\n const child = this.getJitChild(comp);\n const childJit = comp.compileRestoreFromJson(child, 'S');\n const optionalCOde = `if (${comp.getChildVλl()} === null ) {${comp.getChildVλl()} = undefined}`;\n if (!child || !childJit?.code) return this.isOptional() ? {code: optionalCOde, type: 'S'} : {code: undefined, type: 'S'};\n const isExpression = childIsExpression(childJit, child);\n const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';\n return this.isOptional()\n ? {code: `${optionalCOde} else if (${comp.getChildVλl()} !== undefined) {${code}}`, type: 'S'}\n : {code, type: 'S'};\n }\n}\n"],"names":["MemberRunType","getParamIndex","ReflectionKind","childIsExpression"],"mappings":";;;;;;AAcM,MAAO,2BAAqEA,qBAAAA,cAAgB;AAAA,EAC9F,aAAU;AACN,WAAO,CAAC,CAAC,KAAK,IAAI,YAAY,KAAK,OAAA,KAAY,KAAK,gBAAA;AAAA,EACxD;AAAA,EACA,cAAc,MAAmB;AAC7B,UAAM,QAAQ,MAAM,MAAM,aAAa;AACvC,QAAI;AAAO,aAAOC,4BAAc,KAAK,GAAoB,IAAI;AAC7D,WAAOA,cAAAA,cAAc,KAAK,GAAoB;AAAA,EAClD;AAAA,EACA,gBAAgB,MAAmB;AAE/B,UAAM,MAAM,KAAK;AACjB,QAAI,IAAI,QAAQ,OAAO;AACnB,aAAO,IAAI,OAAO,MAAM,QAAQ,KAAK,GAAG;AAAA,IAC5C;AAEA,WAAO,KAAK,cAAc,IAAI;AAAA,EAClC;AAAA,EACA,gBAAgB,MAAmB;AAC/B,WAAO,KAAK,gBAAgB,IAAI;AAAA,EACpC;AAAA,EACA,mBAAgB;AACZ,WAAO;AAAA,EACX;AAAA,EACA,SAAM;AACF,WAAO,KAAK,cAAA,EAAgB,IAAI,SAASC,KAAAA,eAAe;AAAA,EAC5D;AAAA,EACA,sBAAmB;AACf,WAAO,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"version":3,"file":"Iterable.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Iterable.cjs","sources":["../../../../../src/nodes/native/Iterable.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport type {JitCode} from '../../types.ts';\nimport {ClassRunType} from '../collection/class.ts';\nimport {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';\nimport {BaseRunType} from '../../lib/baseRunTypes.ts';\n\n// This is the base class for all iterable run types, like SetRunType and MapRunType\nexport abstract class IterableRunType extends ClassRunType {\n abstract children: BaseRunType[];\n abstract constructorName: string;\n getIndexVarName(comp: JitFnCompiler): string {\n return comp.getLocalVarName('e', this);\n }\n getChildRunTypes = (): BaseRunType[] => {\n return this.children;\n };\n emitIsType(comp: JitFnCompiler): JitCode {\n const entry = this.getCustomVλl(comp)?.vλl || comp.vλl;\n const childrenCode = this.getJitChildren(comp)\n .map((c) => `if (!(${comp.compileIsType(c, 'E').code})) return false`)\n .join(';');\n return {\n code: `\n if (!(${comp.vλl} instanceof ${this.constructorName})) return false;\n for (const ${entry} of ${comp.vλl}) {${childrenCode}} return true;\n `,\n type: 'RB',\n };\n }\n emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {\n const entry = this.getCustomVλl(comp)?.vλl || comp.vλl;\n const childrenCode = this.getJitChildren(comp)\n .map((c) => comp.compileTypeErrors(c, 'S').code)\n .join(';');\n const index = this.getIndexVarName(comp);\n return {\n code: `\n if (!(${comp.vλl} instanceof ${this.constructorName})){${comp.callJitErr(this)}}\n else {let ${index} = 0;for (const ${entry} of ${comp.vλl}) {${childrenCode}; ${index}++}}\n `,\n type: 'S',\n };\n }\n emitPrepareForJson(comp: JitFnCompiler): JitCode {\n const entry = this.getCustomVλl(comp)?.vλl || comp.vλl;\n const resName = comp.getLocalVarName('ml', this);\n const childrenCode = this.getJitChildren(comp)\n .map((c) => comp.compilePrepareForJson(c, 'S').code)\n .filter(Boolean)\n .join(';');\n if (!childrenCode) return {code: `${comp.vλl} = Array.from(${comp.vλl})`, type: 'S'};\n return {\n code: `\n const ${resName} = [];\n for (let ${entry} of ${comp.vλl}) {${childrenCode} ${resName}.push(${entry})}\n ${comp.vλl} = ${resName};\n `,\n type: 'S',\n };\n }\n emitRestoreFromJson(comp: JitFnCompiler): JitCode {\n const children = this.getJitChildren(comp);\n if (!children.length) return {code: `${comp.vλl} = new Map(${comp.vλl})`, type: 'S'};\n const index = this.getCustomVλl(comp)?.vλl || comp.vλl;\n const childrenCode = children\n .map((c) => comp.compileRestoreFromJson(c, 'S').code)\n .filter(Boolean)\n .join(';');\n if (!childrenCode) return {code: `${comp.vλl} = new ${this.constructorName}(${comp.vλl})`, type: 'S'};\n return {\n code: `\n for (let ${index} = 0; ${index} < ${comp.vλl}.length; ${index}++) {${childrenCode}}\n ${comp.vλl} = new ${this.constructorName}(${comp.vλl})\n `,\n type: 'S',\n };\n }\n\n // TODO: Implement the following methods, should just call same compile method for children, look into to array run type\n\n emitHasUnknownKeys(comp: JitFnCompiler): JitCode {\n const childrenCode = this.getJitChildren(comp)\n .map((child) => {\n const itemJit = comp.compileHasUnknownKeys(child, 'E');\n return itemJit?.code ? `if (${itemJit.code}) return true;` : '';\n })\n .filter(Boolean)\n .join('');\n if (!childrenCode) return {code: 'return false', type: 'RB'};\n const entry = this.getCustomVλl(comp)?.vλl || comp.vλl;\n return {\n code: `\n if (!(${comp.vλl} instanceof ${this.constructorName})) return false;\n for (const ${entry} of ${comp.vλl}) {${childrenCode}} return false;\n `,\n type: 'RB',\n };\n }\n\n emitUnknownKeyErrors(comp: JitErrorsFnCompiler): JitCode {\n const childrenCode = this.getJitChildren(comp)\n .map((child) => comp.compileUnknownKeyErrors(child, 'S').code)\n .filter(Boolean)\n .join(';');\n if (!childrenCode) return {code: undefined, type: 'S'};\n const entry = this.getCustomVλl(comp)?.vλl || comp.vλl;\n const index = this.getIndexVarName(comp);\n return {\n code: `\n if (!(${comp.vλl} instanceof ${this.constructorName})) return;\n let ${index} = 0; for (const ${entry} of ${comp.vλl}) {${childrenCode}; ${index}++}\n `,\n type: 'S',\n };\n }\n\n emitStripUnknownKeys(comp: JitFnCompiler): JitCode {\n const childrenCode = this.getJitChildren(comp)\n .map((child) => comp.compileStripUnknownKeys(child, 'S').code)\n .filter(Boolean)\n .join(';');\n if (!childrenCode) return {code: undefined, type: 'S'};\n const entry = this.getCustomVλl(comp)?.vλl || comp.vλl;\n return {\n code: `\n if (!(${comp.vλl} instanceof ${this.constructorName})) return;\n for (const ${entry} of ${comp.vλl}) {${childrenCode}}\n `,\n type: 'S',\n };\n }\n\n emitUnknownKeysToUndefined(comp: JitFnCompiler): JitCode {\n const childrenCode = this.getJitChildren(comp)\n .map((child) => comp.compileUnknownKeysToUndefined(child, 'S').code)\n .filter(Boolean)\n .join(';');\n if (!childrenCode) return {code: undefined, type: 'S'};\n const entry = this.getCustomVλl(comp)?.vλl || comp.vλl;\n return {\n code: `\n if (!(${comp.vλl} instanceof ${this.constructorName})) return;\n for (const ${entry} of ${comp.vλl}) {${childrenCode}}\n `,\n type: 'S',\n };\n }\n}\n"],"names":["ClassRunType","BaseRunType","JitFnCompiler","JitErrorsFnCompiler"],"mappings":";;;;;;;;;AAYM,MAAgB,wBAAwBA,2BAAAA,aAAY;AAAA,EAGtD,gBAAgB,MAAmB;AAC/B,WAAO,KAAK,gBAAgB,KAAK,IAAI;AAAA,EACzC;AAAA,EACA,mBAAgB,aAAG,MAAoB;AACnC,WAAO,KAAK;AAAA,EAChB,GAAC,CAAA,MAAAC,qBAAAA,aAAA,IAAA,SAAA,CAAA;AAAA,EACD,WAAW,MAAmB;AA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"map.cjs","sources":["../../../../../src/nodes/native/map.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport type {SrcType} from '../../types.ts';\nimport {GenericMemberRunType} from '../member/genericMember.ts';\nimport {ReflectionSubKind} from '../../constants.kind.ts';\nimport {ReflectionKind, TypeClass} from '@deepkit/type';\nimport {IterableRunType} from './Iterable.ts';\nimport {JitFunctions} from '../../constants.functions.ts';\nimport type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';\nimport {cpf_safeIterableKey} from '../../run-types-pure-fns.ts';\n\nexport class MapRunType extends IterableRunType {\n keyRT = new MapKeyRunType();\n valueRT = new MapValueRunType();\n children = [this.keyRT, this.valueRT];\n constructorName = 'Map';\n onCreated(src: SrcType<TypeClass>): void {\n const types = src.arguments;\n if (!types || types.length !== 2) throw new Error(`Map expects 2 type arguments: ie: Map<string, number>`);\n super.onCreated(src);\n this.keyRT.onCreated({\n kind: ReflectionKind.parameter,\n parent: src,\n type: types[0],\n subKind: ReflectionSubKind.mapKey,\n });\n this.valueRT.onCreated({\n kind: ReflectionKind.parameter,\n parent: src,\n type: types[1],\n subKind: ReflectionSubKind.mapValue,\n });\n }\n getCustomVλl(comp: JitFnCompiler) {\n // restoreFromJson is decoding a regular array so no need to use an special case for vλl as other operations\n if (comp.fnID === JitFunctions.restoreFromJson.id)\n return {vλl: comp.getLocalVarName('it', this), isStandalone: false, useArrayAccessor: true};\n // other operations use an special case for vλl where all parents are skipped\n return {vλl: comp.getLocalVarName('it', this), isStandalone: true};\n }\n getMapKeyVλl(comp: JitFnCompiler) {\n return comp.getLocalVarName('mpk', this);\n }\n getMapValueVλl(comp: JitFnCompiler) {\n return comp.getLocalVarName('mpV', this);\n }\n}\n\nclass MapKeyRunType extends GenericMemberRunType<any> {\n index = 0;\n getStaticPathLiteral(comp: JitFnCompiler): string | number {\n const parent = this.getParent()! as MapRunType;\n const custom = parent.getCustomVλl(comp)!;\n const safeKeyFn = comp.addPureFunction(cpf_safeIterableKey);\n return `{key:${safeKeyFn}(${custom.vλl}[0]),index:${parent.getIndexVarName(comp)},failed:'mapKey'}`;\n }\n getCustomVλl(comp: JitFnCompiler) {\n // temp variable to assign mapKey\n if (comp.fnID === JitFunctions.fromBinary.id)\n return {\n vλl: (this.getParent()! as MapRunType).getMapKeyVλl(comp),\n isStandalone: true,\n useArrayAccessor: false,\n };\n return undefined;\n }\n}\n\nclass MapValueRunType extends GenericMemberRunType<any> {\n index = 1;\n getStaticPathLiteral(comp: JitFnCompiler): string | number {\n const parent = this.getParent()! as MapRunType;\n const custom = parent.getCustomVλl(comp)!;\n const safeKeyFn = comp.addPureFunction(cpf_safeIterableKey);\n return `{key:${safeKeyFn}(${custom.vλl}[0]),index:${parent.getIndexVarName(comp)},failed:'mapVal'}`;\n }\n getCustomVλl(comp: JitFnCompiler) {\n // temp variable to assign mapKey\n if (comp.fnID === JitFunctions.fromBinary.id)\n return {\n vλl: (this.getParent()! as MapRunType).getMapValueVλl(comp),\n isStandalone: true,\n useArrayAccessor: false,\n };\n return undefined;\n }\n}\n"],"names":["IterableRunType","ReflectionKind","ReflectionSubKind","JitFunctions","GenericMemberRunType","cpf_safeIterableKey"],"mappings":";;;;;;;;AAeM,MAAO,mBAAmBA,0BAAAA,gBAAe;AAAA,EAC3C,QAAQ,IAAI,cAAA;AAAA,EACZ,UAAU,IAAI,gBAAA;AAAA,EACd,WAAW,CAAC,KAAK,OAAO,KAAK,OAAO;AAAA,EACpC,kBAAkB;AAAA,EAClB,UAAU,KAAuB;AAC7B,UAAM,QAAQ,IAAI;AAClB,QAAI,CAAC,SAAS,MAAM,WAAW;AAAG,YAAM,IAAI,MAAM,uDAAuD;AACzG,UAAM,UAAU,GAAG;AACnB,SAAK,MAAM,UAAU;AAAA,MACjB,MAAMC,KAAAA,eAAe;AAAA,MACr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AI,CAAC;AAAA,EACpF;AAAA,EACA,aAAa,MAAmB;AAE5B,QAAI,KAAK,SAASF,wBAAAA,aAAa,WAAW;AACtC,aAAO;AAAA,QACH,KAAM,KAAK,YAA4B,aAAa,IAAI;AAAA,QACxD,cAAc;AAAA,QACd,kBAAkB;AAAA,MAAA;AAE1B,WAAO;AAAA,EACX;AAAA;WAhBQ;AAAA,EAAC,GAAA,iBAAA,QAAA,wBAAA,gBAAA,iBAAA,sCAAA;;AAmBb,MAAM,wBAAwBC,+BAAAA,qBAAyB;AAAA,EACnD,QAAQ;AAAA,EACR,qBAAqB,MAAmB;AACpC,UAAM,SAAS,KAAK,UAAA;AACpB,UAAM,SAAS,OAAO,aAAa,IAAI;AACvC,UAAM,YAAY,KAAK,gBAAgBC,uCAAmB;AAC1D,WAAO,QAAQ,SAAS,IAAI,OAAO,GAAG,cAAc,OAAO,gBAAgB,IAAI,CAAC;AAAA,EACpF;AAAA,EACA,aAAa,MAAmB;AAE5B,QAAI,KAAK,SAASF,wBAAAA,aAAa,WAAW;AACtC,aAAO;AAAA,QACH,KAAM,KAAK,YAA4B,eAAe,IAAI;AAAA,QAC1D,cAAc;AAAA,QACd,kBAAkB;AAAA,MAAA;AAE1B,WAAO;AAAA,EACX;AAAA;WAhBQ;AAAA,EAAC,GAAA,iBAAA,QAAA,wBAAA,gBAAA,mBAAA,sCAAA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"nonSerializable.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"nonSerializable.cjs","sources":["../../../../../src/nodes/native/nonSerializable.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport type {TypeClass, TypeObjectLiteral} from '@deepkit/type';\nimport {JitCode} from '../../types.ts';\nimport {InterfaceRunType} from '../collection/interface.ts';\n\n// Non serializable types might not be Atomic but will be skipped so it doesn't matter\nexport class NonSerializableRunType extends InterfaceRunType<TypeObjectLiteral | TypeClass> {\n skipJit() {\n // skip return false so we ensure the compile functions will throw when a NonSerializable type is used\n return false;\n }\n emitIsType(): JitCode {\n throw new Error(`Jit compilation disabled for Non Serializable types.`);\n }\n emitTypeErrors(): JitCode {\n throw new Error(`Jit compilation disabled for Non Serializable types.`);\n }\n emitPrepareForJson(): JitCode {\n throw new Error(`Jit compilation disabled for Non Serializable types.`);\n }\n emitRestoreFromJson(): JitCode {\n throw new Error(`Jit compilation disabled for Non Serializable types.`);\n }\n emitHasUnknownKeys(): JitCode {\n throw new Error(`Jit compilation disabled for Non Serializable types.`);\n }\n emitUnknownKeyErrors(): JitCode {\n throw new Error(`Jit compilation disabled for Non Serializable types.`);\n }\n emitStripUnknownKeys(): JitCode {\n throw new Error(`Jit compilation disabled for Non Serializable types.`);\n }\n emitUnknownKeysToUndefined(): JitCode {\n throw new Error(`Jit compilation disabled for Non Serializable types.`);\n }\n}\n"],"names":["InterfaceRunType"],"mappings":";;;;AAYM,MAAO,+BAA+BA,+BAAAA,iBAA+C;AAAA,EACvF,UAAO;AAEH,WAAO;AAAA,EACX;AAAA,EACA,aAAU;AACN,UAAM,IAAI,MAAM,sDAAsD;AAAA,EAC1E;AAAA,EACA,iBAAc;AACV,UAAM,IAAI,MAAM,sDAAsD;AAAA,EAC1E;AAAA,EACA,qBAAkB;AACd,UAAM,IAAI,MAAM,sDAAsD;AAAA,EAC1E;AAAA,EACA,sBAAmB;AACf,UAAM,IAAI,MAAM,sDAAsD;AAAA,EAC1E;AAAA,EACA,qBAAkB;AACd,UAAM,IAAI,MAAM,sDAAsD;AAAA,EAC1E;AAAA,EACA,uBAAoB;AAChB,UAAM,IAAI,MAAM,sDAAsD;AAAA,EAC1E;AAAA,EACA,uBAAoB;AAChB,UAAM,IAAI,MAAM,sDAAsD;AAAA,EAC1E;AAAA,EACA,6BAA0B;AACtB,UAAM,IAAI,MAAM,sDAAsD;AAAA,EAC1E;AAAA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"promise.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"promise.cjs","sources":["../../../../../src/nodes/native/promise.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport {type TypePromise} from '@deepkit/type';\nimport type {JitCode} from '../../types.ts';\nimport {MemberRunType} from '../../lib/baseRunTypes.ts';\nimport {JitFunctions} from '../../constants.functions.ts';\nimport type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';\n\nexport class PromiseRunType extends MemberRunType<TypePromise> {\n skipJit(comp: JitFnCompiler): boolean {\n return comp?.fnID !== JitFunctions.toJSCode.id;\n }\n emitIsType(): JitCode {\n throw new Error(`Jit compilation disabled for Non Serializable types.`);\n }\n emitTypeErrors(): JitCode {\n throw new Error(`Jit compilation disabled for Non Serializable types.`);\n }\n emitPrepareForJson(): JitCode {\n throw new Error(`Jit compilation disabled for Non Serializable types.`);\n }\n emitRestoreFromJson(): JitCode {\n throw new Error(`Jit compilation disabled for Non Serializable types.`);\n }\n isOptional(): boolean {\n return false;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getChildVarName(comp: JitFnCompiler): string | number {\n return comp.getLocalVarName('p', this);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getChildLiteral(comp: JitFnCompiler): string | number {\n return this.getChildVarName(comp);\n }\n useArrayAccessor(): boolean {\n return false;\n }\n}\n"],"names":["MemberRunType","JitFunctions"],"mappings":";;;;AAYM,MAAO,uBAAuBA,qBAAAA,cAA0B;AAAA,EAC1D,QAAQ,MAAmB;AACvB,WAAO,MAAM,SAASC,wBAAAA,aAAa,SAAS;AAAA,EAChD;AAAA,EACA,aAAU;AACN,UAAM,IAAI,MAAM,sDAAsD;AAAA,EAC1E;AAAA,EACA,iBAAc;AACV,UAAM,IAAI,MAAM,sDAAsD;AAAA,EAC1E;AAAA,EACA,qBAAkB;AACd,UAAM,IAAI,MAAM,sDAAsD;AAAA,EAC1E;AAAA,EACA,sBAAmB;AACf,UAAM,IAAI,MAAM,sDAAsD;AAAA,EAC1E;AAAA,EACA,aAAU;AACN,WAAO;AAAA,EACX;AAAA;AAAA,EAEA,gBAAgB,MAAmB;AAC/B,WAAO,KAAK,gBAAgB,KAAK,IAAI;AAAA,EACzC;AAAA;AAAA,EAEA,gBAAgB,MAAmB;AAC/B,WAAO,KAAK,gBAAgB,IAAI;AAAA,EACpC;AAAA,EACA,mBAAgB;AACZ,WAAO;AAAA,EACX;AAAA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"set.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"set.cjs","sources":["../../../../../src/nodes/native/set.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport type {SrcType} from '../../types.ts';\nimport {ReflectionSubKind} from '../../constants.kind.ts';\nimport {ReflectionKind, type TypeClass} from '@deepkit/type';\nimport {GenericMemberRunType} from '../member/genericMember.ts';\nimport {IterableRunType} from './Iterable.ts';\nimport {JitFunctions} from '../../constants.functions.ts';\nimport type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';\nimport {cpf_safeIterableKey} from '../../run-types-pure-fns.ts';\nexport class SetRunType extends IterableRunType {\n keyRT = new SetKeyRunType();\n children = [this.keyRT];\n constructorName = 'Set';\n onCreated(src: SrcType<TypeClass>): void {\n const types = src.arguments;\n if (!types || types.length !== 1) throw new Error(`Set expects 1 type argument: ie: Set<number>`);\n super.onCreated(src);\n this.keyRT.onCreated({\n kind: ReflectionKind.parameter,\n parent: src,\n type: types[0],\n subKind: ReflectionSubKind.setItem,\n });\n }\n getCustomVλl(comp: JitFnCompiler) {\n // restoreFromJson is decoding a regular array so no need to use an special case for vλl as other operations\n if (comp.fnID === JitFunctions.restoreFromJson.id)\n return {vλl: comp.getLocalVarName('it', this), isStandalone: false, useArrayAccessor: true};\n // other operations use an special case for vλl where all parents are skipped\n return {vλl: comp.getLocalVarName('it', this), isStandalone: true};\n }\n}\n\nexport class SetKeyRunType extends GenericMemberRunType<any> {\n index = 0;\n skipSettingAccessor() {\n return true;\n }\n getStaticPathLiteral(comp: JitFnCompiler): string {\n const parent = this.getParent()! as SetRunType;\n const custom = parent.getCustomVλl(comp)!;\n const safeKeyFn = comp.addPureFunction(cpf_safeIterableKey);\n return `{key:${safeKeyFn}(${custom.vλl}),index:${parent.getIndexVarName(comp)}}`;\n }\n getCustomVλl(comp: JitFnCompiler) {\n if (comp.fnID === JitFunctions.fromBinary.id)\n return {vλl: comp.getLocalVarName('sK', this), isStandalone: true, useArrayAccessor: false};\n // other operations use an special case for vλl where all parents are skipped\n return undefined;\n }\n}\n"],"names":["IterableRunType","ReflectionKind","ReflectionSubKind","JitFunctions","GenericMemberRunType","cpf_safeIterableKey"],"mappings":";;;;;;;;AAcM,MAAO,mBAAmBA,0BAAAA,gBAAe;AAAA,EAC3C,QAAQ,IAAI,cAAA;AAAA,EACZ,WAAW,CAAC,KAAK,KAAK;AAAA,EACtB,kBAAkB;AAAA,EAClB,UAAU,KAAuB;AAC7B,UAAM,QAAQ,IAAI;AAClB,QAAI,CAAC,SAAS,MAAM,WAAW;AAAG,YAAM,IAAI,MAAM,8CAA8C;AAChG,UAAM,UAAU,GAAG;AACnB,SAAK,MAAM,UAAU;AAAA,MACjB,MAAMC,KAAAA,eAAe;AAAA,MACrB,QAAQ;AAAA,MACR,MAAM,MAAM,CAAC;AAAA,MACb,SAASC,mBAAAA,kBAAkB;AAAA,IAAA,CAC9B;AAAA,EACL;AAAA,EACA,aAAa,MAAmB;AAE5B,QA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fns.cjs","sources":["../../../src/run-types-pure-fns.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport type {TypeFormatError, StrNumber, RunTypeError} from '@mionjs/core';\nimport {registerPureFnFactory} from '@mionjs/core';\n\nexport const cpf_asJSONString = registerPureFnFactory('mion', 'asJSONString', function () {\n // @ts-expect-error 2867\n if (typeof Bun !== 'undefined') return JSON.stringify; // bun has a faster JSON.stringify\n // eslint-disable-next-line no-control-regex\n const STR_ESCAPE = /[\\u0000-\\u001f\\u0022\\u005c\\ud800-\\udfff]/;\n const MAX_SCAPE_TEST_LENGTH = 1000;\n return function _asJSONStringRegexOnly(str) {\n // Always use regex test for strings >= 42 chars (n o for loop)\n if (str.length < MAX_SCAPE_TEST_LENGTH && STR_ESCAPE.test(str) === false) {\n return '\"' + str + '\"';\n } else {\n return JSON.stringify(str);\n }\n };\n});\n\nexport const cpf_getUnknownKeysFromArray = registerPureFnFactory('mion', 'getUnknownKeysFromArray', function () {\n const MAX_UNKNOWN_KEYS = 10;\n return function _getUnknownKeysFromArray(obj: Record<StrNumber, any>, keys: StrNumber[]): StrNumber[] {\n const unknownKeys: StrNumber[] = [];\n for (const prop in obj) {\n let found = false;\n for (let j = 0; j < keys.length; j++) {\n if (keys[j] === prop) {\n found = true;\n break;\n }\n }\n if (!found) {\n unknownKeys.push(prop as string);\n if (unknownKeys.length >= MAX_UNKNOWN_KEYS) throw new Error('Too many unknown keys');\n }\n }\n return unknownKeys;\n };\n});\n\nexport const cpf_hasUnknownKeysFromArray = registerPureFnFactory('mion', 'hasUnknownKeysFromArray', function () {\n return function _hasUnknownKeysFromArray(obj: Record<StrNumber, any>, keys: StrNumber[]): boolean {\n for (const prop in obj) {\n // iterates over the object keys and if not found prop adds to unknownKeys\n let found = false;\n for (let j = 0; j < keys.length; j++) {\n if (keys[j] === prop) {\n found = true;\n break;\n }\n }\n if (!found) return true;\n }\n return false;\n };\n});\n\nexport const cpf_newRunTypeErr = registerPureFnFactory('mion', 'newRunTypeErr', function () {\n return function _err(\n pλth: readonly StrNumber[],\n εrr: RunTypeError[],\n expected: string,\n accessPath?: readonly StrNumber[]\n ): void {\n const path = accessPath?.length ? [...pλth, ...accessPath] : [...pλth];\n const runTypeErr: RunTypeError = {expected, path};\n εrr.push(runTypeErr);\n };\n});\n\nexport const cpf_formatErr = registerPureFnFactory('mion', 'formatErr', function () {\n return function _formatErr(\n pλth: StrNumber[],\n εrr: RunTypeError[],\n expected: string,\n fmtName: string,\n paramName: string,\n paramVal: string | number | boolean | bigint,\n fmtPath: StrNumber[],\n accessPath?: StrNumber[],\n fmtAccessPath?: StrNumber[]\n ): void {\n const path = accessPath?.length ? [...pλth, ...accessPath] : [...pλth];\n const formatPath = fmtAccessPath?.length ? [...fmtPath, ...fmtAccessPath, paramName] : [...fmtPath, paramName];\n const format: TypeFormatError = {name: fmtName, formatPath: formatPath, val: paramVal};\n const runTypeErr: Required<RunTypeError> = {expected, path, format};\n εrr.push(runTypeErr);\n };\n});\n\nexport const cpf_safeIterableKey = registerPureFnFactory('mion', 'safeIterableKey', function () {\n return function _safeKey(value: any): any {\n if (value === undefined) return null;\n if (value === null) return null;\n const type = typeof value;\n if (type === 'number' || type === 'string' || type === 'boolean') return value;\n return null;\n };\n});\n\n/** @reflection never */\nexport const cpf_sanitizeCompiledFn = registerPureFnFactory('mion', 'sanitizeCompiledFn', function () {\n const anonymousRegex = /^\\s*function\\s+anonymous\\s*\\(/;\n return function sanitizeCompiled(fnCode: string): string {\n if (anonymousRegex.test(fnCode)) {\n return fnCode.replace(anonymousRegex, 'function (');\n }\n return fnCode;\n };\n});\n"],"names":["registerPureFnFactory"],"mappings":";;;;;;;;AASO,MAAM,mBAAmBA,KAAAA,sBAAsB,QAAQ,gBAAgB,WAAA;AAE1E,MAAI,OAAO,QAAQ;AAAa,WAAO,KAAK;AAE5C,QAAM,aAAa;AACnB,QAAM,wBAAwB;AAC9B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AACtF,QAAM,iBAAiB;AACvB,SAAO,SAAS,iBAAiB,QAAc;AAC3C,QAAI,eAAe,KAAK,MAAM,GAAG;AAC7B,aAAO,OAAO,QAAQ,gBAAgB,YAAY;AAAA,IACtD;AACA,WAAO;AAAA,EACX;AACJ;;;;;;;;"}
@@ -14,7 +14,7 @@ const __ΩSrcMember = ["Type", "type", "SrcMember", 'P"w!P"w!4"MKw#y'];
14
14
  const __ΩJitCompilerOpts = ["fnID", () => __ΩStrNumber, "typeID", "jitFnHash", () => __ΩRunTypeOptions, "opts", "JitCompilerOpts", `P&4!9n"4#9&4$9n%4&9Mw'y`];
15
15
  const __ΩRunTypeChildAccessor = [() => __ΩRunType, "JitFnCompiler", "comp", "getChildIndex", () => __ΩStrNumber, "getChildVarName", () => __ΩStrNumber, "getChildLiteral", "useArrayAccessor", "isOptional", "skipSettingAccessor", "skipCommas", "RunTypeChildAccessor", `Pn!P"w"2#'1$P"w"2#n%1&P"w"2#n'1(P)1)P)1*P)1+8)4,8Mw-y`];
16
16
  const __ΩCustomVλl = ["vλl", "isStandalone", "useArrayAccessor", "CustomVλl", 'P&4!)4"8)4#8Mw$y'];
17
- const __ΩRunTypeOptions = ["start", "end", "paramsSlice", () => __ΩMockOptions, "mock", "noLiterals", "noIsArrayCheck", "RunTypeOptions", `PP'4!8'4"8M4#8n$4%8)4&8)4'8Mw(y`];
17
+ const __ΩRunTypeOptions = ["start", "end", "paramsSlice", () => __ΩMockOptions, "mock", "noLiterals", "noIsArrayCheck", "strictTypes", "RunTypeOptions", `PP'4!8'4"8M4#8n$4%8)4&8)4'8)4(8Mw)y`];
18
18
  const __ΩPartialRunTypeOptions = [() => __ΩDeepPartial, () => __ΩRunTypeOptions, "PartialRunTypeOptions", 'n"o!"w#y'];
19
19
  const __ΩJitFn = [() => JitFunctions, () => JitFunctions, "JitFn", 'i!i"gfw#y'];
20
20
  const __ΩJitFnID = [() => __ΩJitFn, "id", "JitFnID", 'n!."fw#y'];
@@ -61,6 +61,7 @@ export interface RunTypeOptions {
61
61
  mock?: MockOptions;
62
62
  noLiterals?: boolean;
63
63
  noIsArrayCheck?: boolean;
64
+ strictTypes?: boolean;
64
65
  }
65
66
  export type PartialRunTypeOptions = DeepPartial<RunTypeOptions>;
66
67
  export type JitFn = (typeof JitFunctions)[keyof typeof JitFunctions];
@@ -1 +1 @@
1
- {"version":3,"file":"constants.functions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"constants.functions.js","sources":["../../../src/constants.functions.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport {type JitFnArgs, JIT_FUNCTION_IDS} from '@mionjs/core';\n\n/** Javascript code types */\nexport const CodeTypes = {\n expression: 'E', // single expression, that could be concatenated using js operators like + - * && || etc...\n statement: 'S', // one or multiple statements, that could be concatenated using ; to ensure correct syntax\n returnBlock: 'RB', // code block, it can not be concatenated with other code, it has an explicit return statement and needs to be wrapped in a function\n} as const;\nexport type CodeType = (typeof CodeTypes)[keyof typeof CodeTypes];\n\nexport interface JitFnSettings {\n id: string;\n name: string;\n /** dynamically imports a single compiler function that is capable of compiling any node\n * @see {@link ./jitCompilers/stringifyJson.ts#visitJsonStringify} as example of compiler function\n */\n import?: () => Promise<(...args: any[]) => any>;\n jitArgs: JitFnArgs;\n jitDefaultArgs: JitFnArgs;\n returnName: string;\n /**\n * When no initial vλl is required by the function.\n * This is typically used by deserializers, that do not transform the input value but create a new one from other params.\n * an the initial vλl is used as a variable initialization for the returned values.\n * ie binary deserialization\n */\n noInitialVλl?: true;\n runTimeOptions?: Record<string, {keyName: string; type: 'boolean' | 'number' | 'string'; defaultValue: any}>;\n /**\n * When set to true, the format code should replace the jit code for the function.\n * This is used when the format code is more efficient than the default code.\n */\n formatShouldReplaceJitCode?: true;\n} // list of available jit functions\n\n// variable names used in jit functions\n// JitUtils is passed with the name 'utl'. it is hardcoded in all jit code to avoid string interpolation\nexport const jitArgs = {vλl: 'v'} as const;\nexport const jitDefaultArgs = {vλl: ''} as const;\nexport const jitErrorArgs = {vλl: 'v', pλth: 'pth', εrr: 'er'} as const;\nexport const jitDefaultErrorArgs = {vλl: '', pλth: '[]', εrr: '[]'} as const;\nexport const jitArgsWithOptions = {vλl: 'v', θpts: 'opts'} as const;\nexport const jitDefaultArgsWithOptions = {vλl: '', θpts: '{}'} as const;\nexport const jitBinarySerializerArgs = {vλl: 'v', sεr: 'Ser'} as const; // vλl = js value to serialize ser = serializer,\nexport const jitBinaryDeserializerArgs = {vλl: 'ret', dεs: 'Des'} as const; // vλl is used as return variable ans is assigned the deserialized value, des = deserializer\nexport const jitDefaultBinarySerializerArgs = {vλl: '', sεr: ''} as const;\nexport const jitDefaultBinaryDeserializerArgs = {vλl: '', dεs: ''} as const;\n\n// ######## !IMPORTANT: ALL JIT FUNCTIONS IDs MUST BE UNIQUE and short ########\n\ntype JitFunctionsGroup = {[key: string]: JitFnSettings};\n\nexport const jitValidationFunctions = {\n isType: {\n id: JIT_FUNCTION_IDS.isType,\n name: 'isType',\n jitArgs,\n jitDefaultArgs,\n returnName: jitArgs.vλl,\n },\n typeErrors: {\n id: JIT_FUNCTION_IDS.typeErrors,\n name: 'typeErrors',\n jitArgs: jitErrorArgs,\n jitDefaultArgs: jitDefaultErrorArgs,\n returnName: jitErrorArgs.εrr,\n },\n} as const satisfies JitFunctionsGroup;\n\nexport const jitSerializationFunctions = {\n prepareForJson: {\n id: JIT_FUNCTION_IDS.prepareForJson,\n name: 'prepareForJson',\n jitArgs,\n jitDefaultArgs,\n returnName: jitArgs.vλl,\n },\n restoreFromJson: {\n id: JIT_FUNCTION_IDS.restoreFromJson,\n name: 'restoreFromJson',\n jitArgs,\n jitDefaultArgs,\n returnName: jitArgs.vλl,\n },\n stringifyJson: {\n id: JIT_FUNCTION_IDS.stringifyJson,\n name: 'stringifyJson',\n jitArgs,\n jitDefaultArgs,\n returnName: jitArgs.vλl,\n },\n // similar to json stringify but outputs js code, including pure functions, already imported as size is quite small\n toJSCode: {\n id: JIT_FUNCTION_IDS.toJSCode,\n name: 'toJSCode',\n jitArgs,\n jitDefaultArgs,\n returnName: jitArgs.vλl,\n },\n // Binary serialization functions\n toBinary: {\n id: JIT_FUNCTION_IDS.toBinary,\n name: 'toBinary',\n jitArgs: jitBinarySerializerArgs,\n jitDefaultArgs: jitDefaultBinarySerializerArgs,\n // returns the serializer buffer\n returnName: jitBinarySerializerArgs.sεr,\n formatShouldReplaceJitCode: true,\n },\n fromBinary: {\n id: JIT_FUNCTION_IDS.fromBinary,\n name: 'fromBinary',\n jitArgs: jitBinaryDeserializerArgs,\n jitDefaultArgs: jitDefaultBinaryDeserializerArgs,\n // deserialized value is stored in vλl that is initially undefined\n returnName: jitBinaryDeserializerArgs.vλl,\n noInitialVλl: true,\n formatShouldReplaceJitCode: true,\n },\n // apply type formatters, ie: lowercase, uppercase, trim, etc\n format: {\n id: JIT_FUNCTION_IDS.format,\n name: 'format',\n jitArgs,\n jitDefaultArgs,\n returnName: jitArgs.vλl,\n },\n} as const satisfies JitFunctionsGroup;\n\nexport const JitFunctions = {\n ...jitValidationFunctions,\n ...jitSerializationFunctions,\n unknownKeyErrors: {\n id: JIT_FUNCTION_IDS.unknownKeyErrors,\n name: 'unknownKeyErrors',\n jitArgs: jitErrorArgs,\n jitDefaultArgs: jitDefaultErrorArgs,\n returnName: jitErrorArgs.εrr,\n },\n hasUnknownKeys: {\n id: JIT_FUNCTION_IDS.hasUnknownKeys,\n name: 'hasUnknownKeys',\n jitArgs: jitArgsWithOptions,\n jitDefaultArgs: jitDefaultArgsWithOptions,\n runTimeOptions: {checkNonJitProps: {keyName: 'checkNonJitProps', type: 'boolean', defaultValue: false}},\n returnName: jitArgsWithOptions.vλl,\n },\n stripUnknownKeys: {\n id: JIT_FUNCTION_IDS.stripUnknownKeys,\n name: 'stripUnknownKeys',\n jitArgs,\n jitDefaultArgs,\n returnName: jitArgs.vλl,\n },\n unknownKeysToUndefined: {\n id: JIT_FUNCTION_IDS.unknownKeysToUndefined,\n name: 'unknownKeysToUndefined',\n jitArgs,\n jitDefaultArgs,\n returnName: jitArgs.vλl,\n },\n aux: {\n id: JIT_FUNCTION_IDS.aux,\n name: 'aux',\n jitArgs,\n jitDefaultArgs,\n returnName: jitArgs.vλl,\n },\n // mock is not really a jit function but is used in a similar way, main difference is that it is not compiled\n mock: {\n id: JIT_FUNCTION_IDS.mock,\n name: 'mockType',\n import: () => import('./mocking/mockType.ts').then((m) => m.mockType),\n jitArgs,\n jitDefaultArgs,\n returnName: jitArgs.vλl,\n },\n // pure function are not jit compiled but we ensure we reserve a prefix to avoid collisions\n pureFunction: {\n id: JIT_FUNCTION_IDS.pureFunction,\n name: 'pureFunction',\n jitArgs,\n jitDefaultArgs,\n returnName: jitArgs.vλl,\n },\n} as const satisfies JitFunctionsGroup;\n\nexport const jitFunctionList: JitFnSettings[] = Object.values(JitFunctions);\nexport const jitFunctionsById = Object.fromEntries(jitFunctionList.map((f) => [f.id, f]));\n"],"names":[],"mappings":";;;;;;AAUO,MAAM,YAAY;AAAA,EACrB,YAAY;AAAA;AAAA,EACZ,WAAW;AAAA;AAAA,EACX,aAAa;AAAA;;;;AA+BV,MAAM,UAAU,EAAC,KAAK,IAAA;AACtB,MAAM,iBAAiB,EAAC,KAAK,GAAA;AAC7B,MAAM,eAAe,EAAC,KAAK,KAAK,MAAM,OAAO,KAAK,KAAA;AAClD,MAAM,sBAAsB,EAAC,KAAK,IAAI,MAAM,MAAM,KAAK,KAAA;AACvD,MAAM,qBAAqB,EAAC,KAAK,KAAK,MAAM,OAAA;AAC5C,MAAM,4BAA4B,EAAC,K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ACA;AAAA,IACA,YAAY,QAAQ;AAAA,EAAA;AAAA;AAAA,EAGxB,cAAc;AAAA,IACV,IAAI,iBAAiB;AAAA,IACrB,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,YAAY,QAAQ;AAAA,EAAA;;AAIrB,MAAM,kBAAmC,OAAO,OAAO,YAAY;AACnE,MAAM,mBAAmB,OAAO,YAAY,gBAAgB,IAAG,aAAC,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,GAAC,CAAA,KAAA,IAAA,SAAA,CAAA,CAAA,CAAC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../src/constants.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\n// native javascript objects that are not serializable\nexport const nonSerializableClasses = [\n // TODO: decide what to do with native errors, they should be easily serializable\n Error,\n EvalError,\n RangeError,\n ReferenceError,\n SyntaxError,\n TypeError,\n URIError,\n AggregateError,\n // Promise, // Promise has it's own RunType\n // data types\n WeakMap,\n WeakSet,\n DataView,\n ArrayBuffer,\n SharedArrayBuffer,\n Float32Array,\n Float64Array,\n Int8Array,\n Int16Array,\n Int32Array,\n Uint8Array,\n Uint8ClampedArray,\n Uint16Array,\n Uint32Array,\n BigInt64Array,\n BigUint64Array,\n];\n\n// these are global objects that are not serializable.\n// values are repeated from nonSerializableClasses, as if they are classes or global object depends in typescript stn lib types and these can change\nexport const nonSerializableGlobals = [\n // TODO: decide what to do with native errors, they should be easily serializable\n 'Error',\n 'EvalError',\n 'RangeError',\n 'ReferenceError',\n 'SyntaxError',\n 'TypeError',\n 'URIError',\n 'AggregateError',\n // data types\n 'WeakMap',\n 'WeakSet',\n 'DataView',\n 'ArrayBuffer',\n 'SharedArrayBuffer',\n 'Float32Array',\n 'Float64Array',\n 'Int8Array',\n 'Int16Array',\n 'Int32Array',\n 'Uint8Array',\n 'Uint8ClampedArray',\n 'Uint16Array',\n 'Uint32Array',\n 'BigInt64Array',\n 'BigUint64Array',\n // bellow are common interface names from standard libraries, they added here but not tested\n 'Generator',\n 'GeneratorFunction',\n 'AsyncGenerator',\n 'Iterator',\n 'AsyncGeneratorFunction',\n 'AsyncIterator',\n];\n\n// typescript utility types\nexport const nativeUtilityStringTypes = ['Uppercase', 'Lowercase', 'Capitalize', 'Uncapitalize'];\n\n// other constants\nexport const validPropertyNameRegExp = /^[a-zA-Z_][a-zA-Z0-9_]*$/;\nexport const maxStackErrorMessage =\n 'Max compilation nested level reached, either you have a very deeply nested type or there is an error related to circular references un the types.';\nexport const JIT_STACK_TRACE_MESSAGE = '\\nJIT runType trace => ';\nexport const MAX_UNION_ITEMS = 2 ** 16 - 1;\n"],"names":[],"mappings":"AAQO,MAAM,yBAAyB;AAAA;AAAA,EAElC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;AAKG,MAAM,yBAAyB;AAAA;AAAA,EAElC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;AAIG,MAAM,2BAA2B,CAAC,aAAa,aAAa,cAAc,cAAc;AAGxF,MAAM,0BAA0B;AAChC,MAAM,uBACT;AACG,MAAM,0BAA0B;AAChC,MAAM,kBAAkB,KAAK,KAAK;"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.kind.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"constants.kind.js","sources":["../../../src/constants.kind.ts"],"sourcesContent":["/* ########\n * 2024 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport {ReflectionKind} from '@deepkit/type';\nimport {RunType} from './types.ts';\n\nexport const ReflectionKindName: {[key: number]: keyof typeof ReflectionKind} = {\n 0: 'never',\n 1: 'any',\n 2: 'unknown',\n 3: 'void',\n 4: 'objectLiteral', // name was changed from deepkit's 'object' to 'objectLiteral'\n 5: 'string',\n 6: 'number',\n 7: 'boolean',\n 8: 'symbol',\n 9: 'bigint',\n 10: 'null',\n 11: 'undefined',\n 12: 'regexp',\n 13: 'literal',\n 14: 'templateLiteral',\n 15: 'property',\n 16: 'method',\n 17: 'function',\n 18: 'parameter',\n 19: 'promise',\n 20: 'class',\n 21: 'typeParameter',\n 22: 'enum',\n 23: 'union',\n 24: 'intersection',\n 25: 'array',\n 26: 'tuple',\n 27: 'tupleMember',\n 28: 'enumMember',\n 29: 'rest',\n 30: 'object', // name was changed from deepkit's 'objectLiteral' to 'object' for better error messages\n 31: 'indexSignature',\n 32: 'propertySignature',\n 33: 'methodSignature',\n 34: 'infer',\n 35: 'callSignature',\n};\n\n// ReflectionKind from deepkit is extended with the following sub kinds\nexport const ReflectionSubKind = {\n // group of sub-kinds that extends ReflectionKind.class\n date: 20_01,\n map: 20_02,\n set: 20_03,\n nonSerializable: 20_04,\n\n params: 17_01,\n mapKey: 18_01,\n mapValue: 18_02,\n setItem: 18_03,\n} as const;\n\nexport const ReflectionSubNames: {[key: number]: keyof typeof ReflectionSubKind} = {\n 20_01: 'date',\n 20_02: 'map',\n 20_03: 'set',\n 17_01: 'params',\n} as const;\n\nexport type AnyKindName = keyof typeof ReflectionKind | keyof typeof ReflectionSubKind;\n\nexport function getReflectionName(rt: RunType): AnyKindName {\n if (rt.src.subKind) return ReflectionSubNames[rt.src.subKind];\n return ReflectionKindName[rt.src.kind];\n}\n"],"names":[],"mappings":";;AAUO,MAAM,qBAAmE;AAAA,EAC5E,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;;AAID,MAAM,oBAAoB;AAAA;AAAA,EAE7B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AAAA,EACL,iBAAiB;AAAA,EAEjB,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,SAAS;;AAGN,MAAM,qBAAsE;AAAA,EAC/E,MAAO;AAAA,EACP,MAAO;AAAA,EACP,MAAO;AAAA,EACP,MAAO;;;AAKL,SAAU,kBAAkB,IAAW;AACzC,MAAI,GAAG,IAAI;AAAS,WAAO,mBAAmB,GAAG,IAAI,OAAO;AAC5D,SAAO,mBAAmB,GAAG,IAAI,IAAI;AACzC;;"}