@mionjs/core 0.8.4-alpha.0 → 0.8.6

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 (42) hide show
  1. package/.dist/cjs/index.cjs +4 -0
  2. package/.dist/cjs/index.cjs.map +1 -1
  3. package/.dist/cjs/src/binary/bodyDeserializer.cjs +5 -0
  4. package/.dist/cjs/src/binary/bodyDeserializer.cjs.map +1 -1
  5. package/.dist/cjs/src/binary/bodySerializer.cjs +1 -6
  6. package/.dist/cjs/src/binary/bodySerializer.cjs.map +1 -1
  7. package/.dist/cjs/src/constants.cjs +5 -3
  8. package/.dist/cjs/src/constants.cjs.map +1 -1
  9. package/.dist/cjs/src/constants.d.ts +1 -1
  10. package/.dist/cjs/src/pureFns/pureFn.cjs +6 -4
  11. package/.dist/cjs/src/pureFns/pureFn.cjs.map +1 -1
  12. package/.dist/cjs/src/pureFns/restoreJitFns.cjs +3 -3
  13. package/.dist/cjs/src/pureFns/restoreJitFns.cjs.map +1 -1
  14. package/.dist/cjs/src/routerUtils.cjs +16 -17
  15. package/.dist/cjs/src/routerUtils.cjs.map +1 -1
  16. package/.dist/cjs/src/routerUtils.d.ts +1 -1
  17. package/.dist/cjs/src/types/general.types.cjs +15 -5
  18. package/.dist/cjs/src/types/general.types.cjs.map +1 -1
  19. package/.dist/cjs/src/types/general.types.d.ts +17 -8
  20. package/.dist/cjs/src/types/pureFunctions.types.cjs +1 -1
  21. package/.dist/cjs/src/types/pureFunctions.types.d.ts +1 -1
  22. package/.dist/esm/index.js +5 -1
  23. package/.dist/esm/src/binary/bodyDeserializer.js +5 -0
  24. package/.dist/esm/src/binary/bodyDeserializer.js.map +1 -1
  25. package/.dist/esm/src/binary/bodySerializer.js +1 -6
  26. package/.dist/esm/src/binary/bodySerializer.js.map +1 -1
  27. package/.dist/esm/src/constants.d.ts +1 -1
  28. package/.dist/esm/src/constants.js +5 -3
  29. package/.dist/esm/src/constants.js.map +1 -1
  30. package/.dist/esm/src/pureFns/pureFn.js +6 -4
  31. package/.dist/esm/src/pureFns/pureFn.js.map +1 -1
  32. package/.dist/esm/src/pureFns/restoreJitFns.js +3 -3
  33. package/.dist/esm/src/pureFns/restoreJitFns.js.map +1 -1
  34. package/.dist/esm/src/routerUtils.d.ts +1 -1
  35. package/.dist/esm/src/routerUtils.js +16 -17
  36. package/.dist/esm/src/routerUtils.js.map +1 -1
  37. package/.dist/esm/src/types/general.types.d.ts +17 -8
  38. package/.dist/esm/src/types/general.types.js +16 -6
  39. package/.dist/esm/src/types/general.types.js.map +1 -1
  40. package/.dist/esm/src/types/pureFunctions.types.d.ts +1 -1
  41. package/.dist/esm/src/types/pureFunctions.types.js +1 -1
  42. package/package.json +2 -2
@@ -26,6 +26,10 @@ exports.__ΩAnyErrorParams = src_types_general_types.__ΩAnyErrorParams;
26
26
  exports.__ΩAnyFn = src_types_general_types.__ΩAnyFn;
27
27
  exports.__ΩAnyObject = src_types_general_types.__ΩAnyObject;
28
28
  exports.__ΩBinaryInput = src_types_general_types.__ΩBinaryInput;
29
+ exports.__ΩClientSrcCodeCompiledPureFunction = src_types_general_types.__ΩClientSrcCodeCompiledPureFunction;
30
+ exports.__ΩClientSrcCodeJITCompiledFnsCache = src_types_general_types.__ΩClientSrcCodeJITCompiledFnsCache;
31
+ exports.__ΩClientSrcCodeJitCompiledFn = src_types_general_types.__ΩClientSrcCodeJitCompiledFn;
32
+ exports.__ΩClientSrcCodePureFunctionsCache = src_types_general_types.__ΩClientSrcCodePureFunctionsCache;
29
33
  exports.__ΩCoreRouterOptions = src_types_general_types.__ΩCoreRouterOptions;
30
34
  exports.__ΩDataOnly = src_types_general_types.__ΩDataOnly;
31
35
  exports.__ΩDataViewDeserializer = src_types_general_types.__ΩDataViewDeserializer;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -38,6 +38,11 @@ function deserializeBinaryBody(path, buffer, isResponse) {
38
38
  }
39
39
  function deserializeMethod(key, method, deserializer, isResponse) {
40
40
  const jitFns = isResponse ? method.returnJitFns : method.paramsJitFns;
41
+ if (!jitFns.fromBinary?.fn)
42
+ throw new src_errors.RpcError({
43
+ type: "missing-fromBinary-jit-fn",
44
+ publicMessage: `Missing fromBinary JIT function for method ${key}`
45
+ });
41
46
  try {
42
47
  return jitFns.fromBinary.fn(void 0, deserializer);
43
48
  } catch (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"bodyDeserializer.cjs","sources":["../../../../src/binary/bodyDeserializer.ts"],"sourcesContent":["import {createDataViewDeserializer} from './dataView.ts';\nimport {StatusCodes} from '../constants.ts';\nimport {RpcError} from '../errors.ts';\nimport type {BinaryInput, DataViewDeserializer} from '../types/general.types.ts';\nimport type {MethodWithJitFns} from '../types/method.types.ts';\nimport {routesCache} from '../routerUtils.ts';\n\n/**\n * Deserializes API body from binary format using JIT-compiled deserialization functions.\n * Reads the binary buffer and reconstructs the body record.\n * Method metadata is looked up from routesCache automatically.\n */\nexport function deserializeBinaryBody(\n path: string,\n buffer: BinaryInput,\n /** If true, the body is a response body, otherwise it's a request body */\n isResponse: boolean\n): {\n deserializer: DataViewDeserializer;\n body: Record<string, any>;\n} {\n try {\n // Create deserializer from buffer\n const deserializer = createDataViewDeserializer(path, buffer);\n const body: Record<string, any> = {};\n\n // Read items length from first 32 bits\n const itemsLength = deserializer.view.getUint32(0, true);\n deserializer.index += 4;\n\n // Deserialize each item\n for (let i = 0; i < itemsLength; i++) {\n // Deserialize key (method id)\n const key = deserializer.desString();\n\n // Find the corresponding method from routesCache\n const method = routesCache.getMethodJitFns(key);\n if (!method) {\n throw new RpcError({\n statusCode: StatusCodes.UNEXPECTED_ERROR,\n type: isResponse\n ? 'binary-response-method-Deserialization-error'\n : 'binary-request-method-Deserialization-error',\n publicMessage: `Unknown method key in binary body: ${key}`,\n errorData: {methodId: key},\n });\n }\n\n // Deserialize value using the appropriate JIT function\n const value = deserializeMethod(key, method, deserializer, isResponse);\n body[key] = value;\n }\n\n deserializer.markAsEnded();\n return {deserializer, body};\n } catch (err: any) {\n if (err instanceof RpcError) throw err;\n throw new RpcError({\n statusCode: StatusCodes.UNEXPECTED_ERROR,\n type: isResponse ? 'binary-response-Deserialize-error' : 'binary-request-Deserialization-error',\n publicMessage: `Failed to deserialize body from binary: ${err?.message || 'unknown error'}`,\n originalError: err,\n });\n }\n}\n\n/** Deserializes a single method's value from binary format */\nfunction deserializeMethod(key: string, method: MethodWithJitFns, deserializer: DataViewDeserializer, isResponse: boolean): any {\n const jitFns = isResponse ? method.returnJitFns : method.paramsJitFns;\n try {\n return jitFns.fromBinary.fn(undefined, deserializer);\n } catch (e: any) {\n throw new RpcError({\n statusCode: StatusCodes.UNEXPECTED_ERROR,\n type: isResponse ? 'binary-response-method-Deserialization-error' : 'binary-request-method-Deserialization-error',\n publicMessage: `Failed to deserialize method ${key} from binary`,\n originalError: e,\n errorData: {methodId: key},\n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AM,aAAa,iDAAiD;AAAA,MACpE,eAAe,gCAAgC,GAAG;AAAA,MAClD,eAAe;AAAA,MACf,WAAW,EAAC,UAAU,IAAA;AAAA,IAAG,CAC5B;AAAA,EACL;AACJ;;"}
1
+ {"version":3,"file":"bodyDeserializer.cjs","sources":["../../../../src/binary/bodyDeserializer.ts"],"sourcesContent":["import {createDataViewDeserializer} from './dataView.ts';\nimport {StatusCodes} from '../constants.ts';\nimport {RpcError} from '../errors.ts';\nimport type {BinaryInput, DataViewDeserializer} from '../types/general.types.ts';\nimport type {MethodWithJitFns} from '../types/method.types.ts';\nimport {routesCache} from '../routerUtils.ts';\n\n/**\n * Deserializes API body from binary format using JIT-compiled deserialization functions.\n * Reads the binary buffer and reconstructs the body record.\n * Method metadata is looked up from routesCache automatically.\n */\nexport function deserializeBinaryBody(\n path: string,\n buffer: BinaryInput,\n /** If true, the body is a response body, otherwise it's a request body */\n isResponse: boolean\n): {\n deserializer: DataViewDeserializer;\n body: Record<string, any>;\n} {\n try {\n // Create deserializer from buffer\n const deserializer = createDataViewDeserializer(path, buffer);\n const body: Record<string, any> = {};\n\n // Read items length from first 32 bits\n const itemsLength = deserializer.view.getUint32(0, true);\n deserializer.index += 4;\n\n // Deserialize each item\n for (let i = 0; i < itemsLength; i++) {\n // Deserialize key (method id)\n const key = deserializer.desString();\n\n // Find the corresponding method from routesCache\n const method = routesCache.getMethodJitFns(key);\n if (!method) {\n throw new RpcError({\n statusCode: StatusCodes.UNEXPECTED_ERROR,\n type: isResponse\n ? 'binary-response-method-Deserialization-error'\n : 'binary-request-method-Deserialization-error',\n publicMessage: `Unknown method key in binary body: ${key}`,\n errorData: {methodId: key},\n });\n }\n\n // Deserialize value using the appropriate JIT function\n const value = deserializeMethod(key, method, deserializer, isResponse);\n body[key] = value;\n }\n\n deserializer.markAsEnded();\n return {deserializer, body};\n } catch (err: any) {\n if (err instanceof RpcError) throw err;\n throw new RpcError({\n statusCode: StatusCodes.UNEXPECTED_ERROR,\n type: isResponse ? 'binary-response-Deserialize-error' : 'binary-request-Deserialization-error',\n publicMessage: `Failed to deserialize body from binary: ${err?.message || 'unknown error'}`,\n originalError: err,\n });\n }\n}\n\n/** Deserializes a single method's value from binary format */\nfunction deserializeMethod(key: string, method: MethodWithJitFns, deserializer: DataViewDeserializer, isResponse: boolean): any {\n const jitFns = isResponse ? method.returnJitFns : method.paramsJitFns;\n if (!jitFns.fromBinary?.fn)\n throw new RpcError({\n type: 'missing-fromBinary-jit-fn',\n publicMessage: `Missing fromBinary JIT function for method ${key}`,\n });\n try {\n return jitFns.fromBinary.fn(undefined, deserializer);\n } catch (e: any) {\n throw new RpcError({\n statusCode: StatusCodes.UNEXPECTED_ERROR,\n type: isResponse ? 'binary-response-method-Deserialization-error' : 'binary-request-method-Deserialization-error',\n publicMessage: `Failed to deserialize method ${key} from binary`,\n originalError: e,\n errorData: {methodId: key},\n });\n }\n}\n"],"names":["createDataViewDeserializer","routesCache","RpcError","StatusCodes"],"mappings":";;;;;;AAYO,SAAS,sBACZ,MACA,QAEA,YAIF;AACE,MAAI;AAEA,UAAM,eAAeA,oBAAAA,2BAA2B,MAAM,MAAM;AAC5D,UAAM,OAA4B,CAAA;AAGlC,UAAM,cAAc,aAAa,KAAK,UAAU,GAAG,IAAI;AACvD,iBAAa,SAAS;AAGtB,aAAS,IAAI,GAAG,IAAI,aAAa,KAAK;AAElC,YAAM,MAAM,aAAa,UAAA;AAGzB,YAAM,SAASC,gBAAAA,YAAY,gBAAgB,GAAG;AAC9C,UAAI,CAAC,QAAQ;AACT,cAAM,IAAIC,WAAAA,SAAS;AAAA,UACf,YAAYC,cAAAA,YAAY;AAAA,UACxB,MAAM,aACA,iDACA;AAAA,UACN,eAAe,sCAAsC,GAAG;AAAA,UACxD,WAAW,EAAC,UAAU,IAAA;AAAA,QAAG,CAC5B;AAAA,MACL;AAGA,YAAM,QAAQ,kBAAkB,KAAK,QAAQ,cAAc,UAAU;AACrE,WAAK,GAAG,IAAI;AAAA,IAChB;AAEA,iBAAa,YAAA;AACb,WAAO,EAAC,cAAc,KAAA;AAAA,EAC1B,SAAS,KAAU;AACf,QAAI,eAAeD,WAAAA,SAAU,OAAM;AACnC,UAAM,IAAIA,WAAAA,SAAS;AAAA,MACf,YAAYC,cAAAA,YAAY;AAAA,MACxB,MAAM,aAAa,sCAAsC;AAAA,MACzD,eAAe,2CAA2C,KAAK,WAAW,eAAe;AAAA,MACzF,eAAe;AAAA,IAAA,CAClB;AAAA,EACL;AACJ;AAGA,SAAS,kBAAkB,KAAa,QAA0B,cAAoC,YAA0B;AAC5H,QAAM,SAAS,aAAa,OAAO,eAAe,OAAO;AACzD,MAAI,CAAC,OAAO,YAAY;AACpB,UAAM,IAAID,WAAAA,SAAS;AAAA,MACf,MAAM;AAAA,MACN,eAAe,8CAA8C,GAAG;AAAA,IAAA,CACnE;AACL,MAAI;AACA,WAAO,OAAO,WAAW,GAAG,QAAW,YAAY;AAAA,EACvD,SAAS,GAAQ;AACb,UAAM,IAAIA,WAAAA,SAAS;AAAA,MACf,YAAYC,cAAAA,YAAY;AAAA,MACxB,MAAM,aAAa,iDAAiD;AAAA,MACpE,eAAe,gCAAgC,GAAG;AAAA,MAClD,eAAe;AAAA,MACf,WAAW,EAAC,UAAU,IAAA;AAAA,IAAG,CAC5B;AAAA,EACL;AACJ;;"}
@@ -32,12 +32,7 @@ function serializeBinaryBody(path, executionChain, body, isResponse, workflowRou
32
32
  }
33
33
  function serializeMethod(key, method, value, serializer, isResponse) {
34
34
  const toBinary = isResponse ? method.returnJitFns.toBinary : method.paramsJitFns.toBinary;
35
- if (!toBinary?.fn)
36
- throw new src_errors.RpcError({
37
- type: "missing-toBinary-jit-fn",
38
- publicMessage: `Missing toBinary JIT function for method ${method.id}`
39
- });
40
- if (toBinary.isNoop) return false;
35
+ if (!toBinary?.fn || toBinary.isNoop) return false;
41
36
  if (key === src_constants.MION_ROUTES.thrownErrors) return false;
42
37
  if (isResponse && (!method.hasReturnData || typeof value === "undefined")) return false;
43
38
  if (!isResponse && typeof value === "undefined") return false;
@@ -1 +1 @@
1
- {"version":3,"file":"bodySerializer.cjs","sources":["../../../../src/binary/bodySerializer.ts"],"sourcesContent":["import {createDataViewSerializer} from './dataView.ts';\nimport {MION_ROUTES, StatusCodes} from '../constants.ts';\nimport {RpcError} from '../errors.ts';\nimport type {DataViewSerializer} from '../types/general.types.ts';\nimport type {MethodWithJitFns} from '../types/method.types.ts';\n\n/**\n * Serializes API body to binary format using JIT-compiled serialization functions.\n * Combines the results of all body methods into a single binary buffer.\n *\n * Note: This function assumes all methods in executionChain have valid JIT functions.\n * Methods with noop JIT functions or undefined values should be filtered out before calling this function,\n * or handled by the caller. Any serialization errors will be thrown as RpcError.\n *\n */\nexport function serializeBinaryBody(\n path: string,\n executionChain: MethodWithJitFns[],\n body: Record<string, any>,\n isResponse: boolean,\n workflowRouteIds?: string[]\n): {\n serializer: DataViewSerializer;\n buffer: ReturnType<DataViewSerializer['getBuffer']>;\n} {\n try {\n const serializer = createDataViewSerializer(path, workflowRouteIds);\n\n // Reserve space for items length at index 0 (will be written after counting)\n const itemsLengthIndex = serializer.index;\n serializer.index += 4;\n\n let itemsLength = 0;\n // serialize each method's value (return value for responses, params for requests)\n for (let i = 0; i < executionChain.length; i++) {\n const method = executionChain[i];\n const key = method.id;\n const value = body[key];\n if (serializeMethod(key, method, value, serializer, isResponse)) {\n itemsLength++;\n }\n }\n // Write items length at reserved index 0\n serializer.view.setUint32(itemsLengthIndex, itemsLength, true);\n serializer.markAsEnded();\n\n return {serializer, buffer: serializer.getBuffer()};\n } catch (err: any) {\n if (err instanceof RpcError) throw err;\n throw new RpcError({\n statusCode: StatusCodes.UNEXPECTED_ERROR,\n type: isResponse ? 'binary-response-Serialization-error' : 'binary-request-Serialization-error',\n publicMessage: `Failed to serialize body to binary: ${err?.message || 'unknown error'}`,\n originalError: err,\n });\n }\n}\n\n/**\n * Serializes a single method's value to binary format.\n * Returns true if the method was serialized, false if it was skipped.\n */\nfunction serializeMethod(\n key: string,\n method: MethodWithJitFns,\n value: any,\n serializer: DataViewSerializer,\n isResponse: boolean\n): boolean {\n const toBinary = isResponse ? method.returnJitFns.toBinary : method.paramsJitFns.toBinary;\n if (!toBinary?.fn)\n throw new RpcError({\n type: 'missing-toBinary-jit-fn',\n publicMessage: `Missing toBinary JIT function for method ${method.id}`,\n });\n if (toBinary.isNoop) return false;\n // skip @thrownErrors - should be handled separately by the caller if needed\n if (key === MION_ROUTES.thrownErrors) return false;\n // skip methods without return data or undefined values (for responses)\n if (isResponse && (!method.hasReturnData || typeof value === 'undefined')) return false;\n // skip methods with no params (for requests) or noop serialization\n if (!isResponse && typeof value === 'undefined') return false;\n // serialize key\n serializer.serString(key);\n // serialize value\n toBinary.fn(value, serializer);\n return true;\n}\n"],"names":["createDataViewSerializer","RpcError","StatusCodes","MION_ROUTES"],"mappings":";;;;;AAeO,SAAS,oBACZ,MACA,gBACA,MACA,YACA,kBAIF;AACE,MAAI;AACA,UAAM,aAAaA,oBAAAA,yBAAyB,MAAM,gBAAgB;AAGlE,UAAM,mBAAmB,WAAW;AACpC,eAAW,SAAS;AAEpB,QAAI,cAAc;AAElB,aAAS,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;AAC5C,YAAM,SAAS,eAAe,CAAC;AAC/B,YAAM,MAAM,OAAO;AACnB,YAAM,QAAQ,KAAK,GAAG;AACtB,UAAI,gBAAgB,KAAK,QAAQ,OAAO,YAAY,UAAU,GAAG;AAC7D;AAAA,MACJ;AAAA,IACJ;AAEA,eAAW,KAAK,UAAU,kBAAkB,aAAa,IAAI;AAC7D,eAAW,YAAA;AAEX,WAAO,EAAC,YAAY,QAAQ,WAAW,YAAU;AAAA,EACrD,SAAS,KAAU;AACf,QAAI,eAAeC,WAAAA,SAAU,OAAM;AACnC,UAAM,IAAIA,WAAAA,SAAS;AAAA,MACf,YAAYC,cAAAA,YAAY;AAAA,MACxB,MAAM,aAAa,wCAAwC;AAAA,MAC3D,eAAe,uCAAuC,KAAK,WAAW,eAAe;AAAA,MACrF,eAAe;AAAA,IAAA,CAClB;AAAA,EACL;AACJ;AAMA,SAAS,gBACL,KACA,QACA,OACA,YACA,YACO;AACP,QAAM,WAAW,aAAa,OAAO,aAAa,WAAW,OAAO,aAAa;AACjF,MAAI,CAAC,UAAU;AACX,UAAM,IAAID,WAAAA,SAAS;AAAA,MACf,MAAM;AAAA,MACN,eAAe,4CAA4C,OAAO,EAAE;AAAA,IAAA,CACvE;AACL,MAAI,SAAS,OAAQ,QAAO;AAE5B,MAAI,QAAQE,cAAAA,YAAY,aAAc,QAAO;AAE7C,MAAI,eAAe,CAAC,OAAO,iBAAiB,OAAO,UAAU,aAAc,QAAO;AAElF,MAAI,CAAC,cAAc,OAAO,UAAU,YAAa,QAAO;AAExD,aAAW,UAAU,GAAG;AAExB,WAAS,GAAG,OAAO,UAAU;AAC7B,SAAO;AACX;;"}
1
+ {"version":3,"file":"bodySerializer.cjs","sources":["../../../../src/binary/bodySerializer.ts"],"sourcesContent":["import {createDataViewSerializer} from './dataView.ts';\nimport {MION_ROUTES, StatusCodes} from '../constants.ts';\nimport {RpcError} from '../errors.ts';\nimport type {DataViewSerializer} from '../types/general.types.ts';\nimport type {MethodWithJitFns} from '../types/method.types.ts';\n\n/**\n * Serializes API body to binary format using JIT-compiled serialization functions.\n * Combines the results of all body methods into a single binary buffer.\n *\n * Note: This function assumes all methods in executionChain have valid JIT functions.\n * Methods with noop JIT functions or undefined values should be filtered out before calling this function,\n * or handled by the caller. Any serialization errors will be thrown as RpcError.\n *\n */\nexport function serializeBinaryBody(\n path: string,\n executionChain: MethodWithJitFns[],\n body: Record<string, any>,\n isResponse: boolean,\n workflowRouteIds?: string[]\n): {\n serializer: DataViewSerializer;\n buffer: ReturnType<DataViewSerializer['getBuffer']>;\n} {\n try {\n const serializer = createDataViewSerializer(path, workflowRouteIds);\n\n // Reserve space for items length at index 0 (will be written after counting)\n const itemsLengthIndex = serializer.index;\n serializer.index += 4;\n\n let itemsLength = 0;\n // serialize each method's value (return value for responses, params for requests)\n for (let i = 0; i < executionChain.length; i++) {\n const method = executionChain[i];\n const key = method.id;\n const value = body[key];\n if (serializeMethod(key, method, value, serializer, isResponse)) {\n itemsLength++;\n }\n }\n // Write items length at reserved index 0\n serializer.view.setUint32(itemsLengthIndex, itemsLength, true);\n serializer.markAsEnded();\n\n return {serializer, buffer: serializer.getBuffer()};\n } catch (err: any) {\n if (err instanceof RpcError) throw err;\n throw new RpcError({\n statusCode: StatusCodes.UNEXPECTED_ERROR,\n type: isResponse ? 'binary-response-Serialization-error' : 'binary-request-Serialization-error',\n publicMessage: `Failed to serialize body to binary: ${err?.message || 'unknown error'}`,\n originalError: err,\n });\n }\n}\n\n/**\n * Serializes a single method's value to binary format.\n * Returns true if the method was serialized, false if it was skipped.\n */\nfunction serializeMethod(\n key: string,\n method: MethodWithJitFns,\n value: any,\n serializer: DataViewSerializer,\n isResponse: boolean\n): boolean {\n const toBinary = isResponse ? method.returnJitFns.toBinary : method.paramsJitFns.toBinary;\n if (!toBinary?.fn || toBinary.isNoop) return false;\n // skip @thrownErrors - should be handled separately by the caller if needed\n if (key === MION_ROUTES.thrownErrors) return false;\n // skip methods without return data or undefined values (for responses)\n if (isResponse && (!method.hasReturnData || typeof value === 'undefined')) return false;\n // skip methods with no params (for requests) or noop serialization\n if (!isResponse && typeof value === 'undefined') return false;\n // serialize key\n serializer.serString(key);\n // serialize value\n toBinary.fn(value, serializer);\n return true;\n}\n"],"names":["createDataViewSerializer","RpcError","StatusCodes","MION_ROUTES"],"mappings":";;;;;AAeO,SAAS,oBACZ,MACA,gBACA,MACA,YACA,kBAIF;AACE,MAAI;AACA,UAAM,aAAaA,oBAAAA,yBAAyB,MAAM,gBAAgB;AAGlE,UAAM,mBAAmB,WAAW;AACpC,eAAW,SAAS;AAEpB,QAAI,cAAc;AAElB,aAAS,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;AAC5C,YAAM,SAAS,eAAe,CAAC;AAC/B,YAAM,MAAM,OAAO;AACnB,YAAM,QAAQ,KAAK,GAAG;AACtB,UAAI,gBAAgB,KAAK,QAAQ,OAAO,YAAY,UAAU,GAAG;AAC7D;AAAA,MACJ;AAAA,IACJ;AAEA,eAAW,KAAK,UAAU,kBAAkB,aAAa,IAAI;AAC7D,eAAW,YAAA;AAEX,WAAO,EAAC,YAAY,QAAQ,WAAW,YAAU;AAAA,EACrD,SAAS,KAAU;AACf,QAAI,eAAeC,WAAAA,SAAU,OAAM;AACnC,UAAM,IAAIA,WAAAA,SAAS;AAAA,MACf,YAAYC,cAAAA,YAAY;AAAA,MACxB,MAAM,aAAa,wCAAwC;AAAA,MAC3D,eAAe,uCAAuC,KAAK,WAAW,eAAe;AAAA,MACrF,eAAe;AAAA,IAAA,CAClB;AAAA,EACL;AACJ;AAMA,SAAS,gBACL,KACA,QACA,OACA,YACA,YACO;AACP,QAAM,WAAW,aAAa,OAAO,aAAa,WAAW,OAAO,aAAa;AACjF,MAAI,CAAC,UAAU,MAAM,SAAS,OAAQ,QAAO;AAE7C,MAAI,QAAQC,cAAAA,YAAY,aAAc,QAAO;AAE7C,MAAI,eAAe,CAAC,OAAO,iBAAiB,OAAO,UAAU,aAAc,QAAO;AAElF,MAAI,CAAC,cAAc,OAAO,UAAU,YAAa,QAAO;AAExD,aAAW,UAAU,GAAG;AAExB,WAAS,GAAG,OAAO,UAAU;AAC7B,SAAO;AACX;;"}
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const DEFAULT_CORE_OPTIONS = {
4
4
  /** automatically generate and uuid */
5
- autoGenerateErrorId: false
5
+ autoGenerateErrorId: false,
6
+ basePath: "",
7
+ suffix: ""
6
8
  };
7
9
  const PATH_SEPARATOR = "/";
8
10
  const ROUTE_PATH_ROOT = PATH_SEPARATOR;
@@ -12,8 +14,8 @@ const MAX_STACK_DEPTH = 50;
12
14
  const MION_ROUTES = {
13
15
  /** get remote methods metadata by method id */
14
16
  methodsMetadataById: "mion@methodsMetadataById",
15
- /** get remote methods metadata by route path, this include all middleFns in the ExecutionChain of the route. */
16
- methodsMetadataByPath: "mion@methodsMetadataByPath",
17
+ /** Middleware that returns methods metadata alongside any route response */
18
+ methodsMetadata: "mion@methodsMetadata",
17
19
  /** Platform or adapters errors that occur before reaching the router or outside the router and are platform/adapter related */
18
20
  platformError: "mion@platformError",
19
21
  /** not-found route. This route is called when a requested route doesn't exist */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs","sources":["../../../src/constants.ts"],"sourcesContent":["/* ########\n * 2022 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport type {CoreRouterOptions} from './types/general.types.ts';\n\nexport const DEFAULT_CORE_OPTIONS: CoreRouterOptions = {\n /** automatically generate and uuid */\n autoGenerateErrorId: false,\n};\n\nexport const PATH_SEPARATOR = '/';\nexport const ROUTE_PATH_ROOT = PATH_SEPARATOR;\nexport const ROUTER_ITEM_SEPARATOR_CHAR = '/';\nexport const MAX_UNKNOWN_KEYS = 10;\nexport const MAX_STACK_DEPTH = 50;\n\n/**\n * Mion internal routes.\n */\nexport const MION_ROUTES = {\n /** get remote methods metadata by method id */\n methodsMetadataById: 'mion@methodsMetadataById',\n /** get remote methods metadata by route path, this include all middleFns in the ExecutionChain of the route. */\n methodsMetadataByPath: 'mion@methodsMetadataByPath',\n /** Platform or adapters errors that occur before reaching the router or outside the router and are platform/adapter related */\n platformError: 'mion@platformError',\n /** not-found route. This route is called when a requested route doesn't exist */\n notFound: 'mion@notFound',\n /**\n * !IMPORTANT!!\n * This is technically not a route, but a special key used to store unexpected errors in the response body.\n * is declared as a route to reuse existing router serialization/deserialization logic.\n * Errors thrown by routes/middleFns, these are not strongly typed\n * */\n thrownErrors: '@thrownErrors',\n} as const;\n\n/**\n * Mime types used by mion.\n * Only json and binary are supported out of the box.\n */\nexport const MIME_TYPES = {\n json: 'application/json',\n octetStream: 'application/octet-stream',\n} as const;\n\n/**\n * Standard HTTP status codes used by mion.\n * Status codes are a bit irrelevant in mion apps, the important part is the error type, that is a human readable code.\n * They are used mostly for backwards compatibility with HTTP.\n */\nexport const StatusCodes = {\n /** Any error in the server that is not related to the application, ie: server not ready, etc... */\n SERVER_ERROR: 500,\n /** Any expected and strongly typed error returned by a route/middleFn. ie: entity not found, etc. */\n APPLICATION_ERROR: 400,\n /** Any thrown or unexpected error in the application, ie: validation error, not found, etc, database error, serialization error, etc...\n * These are are typically irrecoverable and can be handled globally, ie redirect to login page if auth fails\n */\n UNEXPECTED_ERROR: 422,\n /** Not found error */\n NOT_FOUND: 404,\n /** Standard success code */\n OK: 200,\n} as const;\n\nexport const HandlerType = {\n route: 1,\n middleFn: 2,\n headersMiddleFn: 3,\n rawMiddleFn: 4,\n} as const;\n\nexport const JIT_FUNCTION_IDS = {\n isType: 'is',\n typeErrors: 'te',\n prepareForJson: 'tj',\n restoreFromJson: 'fj',\n stringifyJson: 'sj',\n toJSCode: 'tc',\n toBinary: 'tBi',\n fromBinary: 'fBi',\n format: 'fmt',\n unknownKeyErrors: 'uk',\n hasUnknownKeys: 'hk',\n stripUnknownKeys: 'sk',\n unknownKeysToUndefined: 'ku',\n aux: 'aux',\n mock: 'mock',\n pureFunction: 'pf',\n} as const;\n\n/** Empty hash used when no params exist or return type is void (no JIT functions generated) */\nexport const EMPTY_HASH = '';\n"],"names":[],"mappings":";;AASO,MAAM,uBAA0C;AAAA;AAAA,EAEnD,qBAAqB;;AAGlB,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AACxB,MAAM,6BAA6B;AACnC,MAAM,mBAAmB;AACzB,MAAM,kBAAkB;AAKxB,MAAM,cAAc;AAAA;AAAA,EAEvB,qBAAqB;AAAA;AAAA,EAErB,uBAAuB;AAAA;AAAA,EAEvB,eAAe;AAAA;AAAA,EAEf,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOV,cAAc;;AAOX,MAAM,aAAa;AAAA,EACtB,MAAM;AAAA,EACN,aAAa;;AAQV,MAAM,cAAc;AAAA;AAAA,EAEvB,cAAc;AAAA;AAAA,EAEd,mBAAmB;AAAA;AAAA;AAAA;AAAA,EAInB,kBAAkB;AAAA;AAAA,EAElB,WAAW;AAAA;AAAA,EAEX,IAAI;;AAGD,MAAM,cAAc;AAAA,EACvB,OAAO;AAAA,EACP,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,aAAa;;AAGV,MAAM,mBAAmB;AAAA,EAC5B,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,UAAU;AAAA,EACV,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,wBAAwB;AAAA,EACxB,KAAK;AAAA,EACL,MAAM;AAAA,EACN,cAAc;;AAIX,MAAM,aAAa;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"constants.cjs","sources":["../../../src/constants.ts"],"sourcesContent":["/* ########\n * 2022 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport type {CoreRouterOptions} from './types/general.types.ts';\n\nexport const DEFAULT_CORE_OPTIONS: CoreRouterOptions = {\n /** automatically generate and uuid */\n autoGenerateErrorId: false,\n basePath: '',\n suffix: '',\n};\n\nexport const PATH_SEPARATOR = '/';\nexport const ROUTE_PATH_ROOT = PATH_SEPARATOR;\nexport const ROUTER_ITEM_SEPARATOR_CHAR = '/';\nexport const MAX_UNKNOWN_KEYS = 10;\nexport const MAX_STACK_DEPTH = 50;\n\n/**\n * Mion internal routes.\n */\nexport const MION_ROUTES = {\n /** get remote methods metadata by method id */\n methodsMetadataById: 'mion@methodsMetadataById',\n /** Middleware that returns methods metadata alongside any route response */\n methodsMetadata: 'mion@methodsMetadata',\n /** Platform or adapters errors that occur before reaching the router or outside the router and are platform/adapter related */\n platformError: 'mion@platformError',\n /** not-found route. This route is called when a requested route doesn't exist */\n notFound: 'mion@notFound',\n /**\n * !IMPORTANT!!\n * This is technically not a route, but a special key used to store unexpected errors in the response body.\n * is declared as a route to reuse existing router serialization/deserialization logic.\n * Errors thrown by routes/middleFns, these are not strongly typed\n * */\n thrownErrors: '@thrownErrors',\n} as const;\n\n/**\n * Mime types used by mion.\n * Only json and binary are supported out of the box.\n */\nexport const MIME_TYPES = {\n json: 'application/json',\n octetStream: 'application/octet-stream',\n} as const;\n\n/**\n * Standard HTTP status codes used by mion.\n * Status codes are a bit irrelevant in mion apps, the important part is the error type, that is a human readable code.\n * They are used mostly for backwards compatibility with HTTP.\n */\nexport const StatusCodes = {\n /** Any error in the server that is not related to the application, ie: server not ready, etc... */\n SERVER_ERROR: 500,\n /** Any expected and strongly typed error returned by a route/middleFn. ie: entity not found, etc. */\n APPLICATION_ERROR: 400,\n /** Any thrown or unexpected error in the application, ie: validation error, not found, etc, database error, serialization error, etc...\n * These are are typically irrecoverable and can be handled globally, ie redirect to login page if auth fails\n */\n UNEXPECTED_ERROR: 422,\n /** Not found error */\n NOT_FOUND: 404,\n /** Standard success code */\n OK: 200,\n} as const;\n\nexport const HandlerType = {\n route: 1,\n middleFn: 2,\n headersMiddleFn: 3,\n rawMiddleFn: 4,\n} as const;\n\nexport const JIT_FUNCTION_IDS = {\n isType: 'is',\n typeErrors: 'te',\n prepareForJson: 'tj',\n restoreFromJson: 'fj',\n stringifyJson: 'sj',\n toJSCode: 'tc',\n toBinary: 'tBi',\n fromBinary: 'fBi',\n format: 'fmt',\n unknownKeyErrors: 'uk',\n hasUnknownKeys: 'hk',\n stripUnknownKeys: 'sk',\n unknownKeysToUndefined: 'ku',\n aux: 'aux',\n mock: 'mock',\n pureFunction: 'pf',\n} as const;\n\n/** Empty hash used when no params exist or return type is void (no JIT functions generated) */\nexport const EMPTY_HASH = '';\n"],"names":[],"mappings":";;AASO,MAAM,uBAA0C;AAAA;AAAA,EAEnD,qBAAqB;AAAA,EACrB,UAAU;AAAA,EACV,QAAQ;;AAGL,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AACxB,MAAM,6BAA6B;AACnC,MAAM,mBAAmB;AACzB,MAAM,kBAAkB;AAKxB,MAAM,cAAc;AAAA;AAAA,EAEvB,qBAAqB;AAAA;AAAA,EAErB,iBAAiB;AAAA;AAAA,EAEjB,eAAe;AAAA;AAAA,EAEf,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOV,cAAc;;AAOX,MAAM,aAAa;AAAA,EACtB,MAAM;AAAA,EACN,aAAa;;AAQV,MAAM,cAAc;AAAA;AAAA,EAEvB,cAAc;AAAA;AAAA,EAEd,mBAAmB;AAAA;AAAA;AAAA;AAAA,EAInB,kBAAkB;AAAA;AAAA,EAElB,WAAW;AAAA;AAAA,EAEX,IAAI;;AAGD,MAAM,cAAc;AAAA,EACvB,OAAO;AAAA,EACP,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,aAAa;;AAGV,MAAM,mBAAmB;AAAA,EAC5B,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,UAAU;AAAA,EACV,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,wBAAwB;AAAA,EACxB,KAAK;AAAA,EACL,MAAM;AAAA,EACN,cAAc;;AAIX,MAAM,aAAa;;;;;;;;;;;;;"}
@@ -7,7 +7,7 @@ export declare const MAX_UNKNOWN_KEYS = 10;
7
7
  export declare const MAX_STACK_DEPTH = 50;
8
8
  export declare const MION_ROUTES: {
9
9
  readonly methodsMetadataById: "mion@methodsMetadataById";
10
- readonly methodsMetadataByPath: "mion@methodsMetadataByPath";
10
+ readonly methodsMetadata: "mion@methodsMetadata";
11
11
  readonly platformError: "mion@platformError";
12
12
  readonly notFound: "mion@notFound";
13
13
  readonly thrownErrors: "@thrownErrors";
@@ -19,8 +19,7 @@ function registerPureFnFactory(namespace, functionID, createPureFn, parsedFn) {
19
19
  fnName: functionID,
20
20
  bodyHash: parsedFn.bodyHash,
21
21
  paramNames: parsedFn.paramNames,
22
- code: parsedFn.code,
23
- pureFnDependencies: []
22
+ code: parsedFn.code
24
23
  };
25
24
  const { proxy, getDependencies } = createDependencyTrackingProxy();
26
25
  try {
@@ -31,8 +30,11 @@ function registerPureFnFactory(namespace, functionID, createPureFn, parsedFn) {
31
30
  for (const dep of detectedDeps) {
32
31
  if (dep === functionID)
33
32
  continue;
34
- if (!compiled.pureFnDependencies.includes(dep))
35
- compiled.pureFnDependencies.push(dep);
33
+ if (compiled.pureFnDependencies?.includes(dep))
34
+ continue;
35
+ if (!compiled.pureFnDependencies)
36
+ compiled.pureFnDependencies = [];
37
+ compiled.pureFnDependencies.push(dep);
36
38
  }
37
39
  src_jit_jitUtils.getJitUtils().addPureFn(namespace, compiled);
38
40
  return compiled;
@@ -1 +1 @@
1
- {"version":3,"file":"pureFn.cjs","sources":["../../../../src/pureFns/pureFn.ts"],"sourcesContent":["/* ########\n * 2026 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport type {CompiledPureFunction, ParsedFactoryFn, PureFunctionFactory} from '../types/pureFunctions.types.ts';\nimport {getJitUtils, type JITUtils} from '../jit/jitUtils.ts';\n\n// ╔══════════════════════════════════════════════════════════════════════════════╗\n// ║ WARNING: This function's call signature is parsed by the mion vite plugin ║\n// ║ at build time (see devtools/src/vite-plugin/extractPureFn.ts). ║\n// ║ Do NOT rename, change the parameter order, or modify the function ║\n// ║ signature without updating the corresponding AST extraction and ║\n// ║ transformer logic in @mionjs/devtools. ║\n// ╚══════════════════════════════════════════════════════════════════════════════╝\n\n/**\n * Registers a pure function factory with automatic dependency tracking.\n * The `parsedFn` argument (containing bodyHash, paramNames, and code) is injected\n * at build time by the mion vite plugin's transform hook — it must never be passed manually.\n * If the function is already registered under the same namespace + functionID, the existing\n * compiled entry is returned (idempotent). Dependencies on other pure functions are\n * auto-detected by running the factory once with a tracking proxy.\n *\n * This is intended to share util functions between server and clients\n */\nexport function registerPureFnFactory(\n namespace: string,\n functionID: string,\n createPureFn: PureFunctionFactory,\n parsedFn?: ParsedFactoryFn // injected by mion vite plugin\n): CompiledPureFunction {\n if (!parsedFn) throw new Error('registerPureFnFactory requires mion vite plugin transform to inject parsedFn');\n const existing = getJitUtils().getCompiledPureFn(namespace, functionID);\n if (existing) return existing;\n\n const compiled: CompiledPureFunction = {\n createPureFn,\n fn: null as any, // will be set later so all possible dependencies are resolved\n namespace,\n fnName: functionID,\n bodyHash: parsedFn.bodyHash,\n paramNames: parsedFn.paramNames,\n code: parsedFn.code,\n pureFnDependencies: [],\n };\n\n // Run the factory once with a tracking proxy to auto-detect dependencies\n const {proxy, getDependencies} = createDependencyTrackingProxy();\n try {\n createPureFn(proxy);\n } catch {\n // Factory may fail if dependencies aren't registered yet, that's ok\n // We still capture whatever was accessed before the error\n }\n const detectedDeps = getDependencies();\n for (const dep of detectedDeps) {\n if (dep === functionID) continue;\n if (!compiled.pureFnDependencies.includes(dep)) compiled.pureFnDependencies.push(dep);\n }\n\n getJitUtils().addPureFn(namespace, compiled);\n return compiled;\n}\n\n/** Creates a proxy of jitUtils that records all pure function accesses (getPureFn, usePureFn, etc.) */\nfunction createDependencyTrackingProxy(): {proxy: JITUtils; getDependencies: () => Set<string>} {\n const dependencies = new Set<string>();\n const realUtils = getJitUtils();\n\n const noopFn = () => () => {};\n\n const proxy = new Proxy(realUtils, {\n get(target, prop, receiver) {\n if (prop === 'getPureFn' || prop === 'usePureFn') {\n return (ns: string, fnName: string) => {\n dependencies.add(fnName);\n // Return a noop function so the factory can execute without errors\n const real = target.getPureFn(ns, fnName);\n return real ?? noopFn;\n };\n }\n if (prop === 'getCompiledPureFn') {\n return (ns: string, fnName: string) => {\n dependencies.add(fnName);\n return target.getCompiledPureFn(ns, fnName);\n };\n }\n if (prop === 'hasPureFn') {\n return (ns: string, fnName: string) => {\n dependencies.add(fnName);\n return target.hasPureFn(ns, fnName);\n };\n }\n if (prop === 'findCompiledPureFn') {\n return (fnName: string) => {\n dependencies.add(fnName);\n return target.findCompiledPureFn(fnName);\n };\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n\n return {proxy, getDependencies: () => dependencies};\n}\n"],"names":["getJitUtils"],"mappings":";;;;;;;AA4BM,SAAU,sBACZ,WACA,YACA,cACA;AAEA,MAAI,CAAC;AAAU,UAAM,IAAI,MAAM,8EAA8E;AAC7G,QAAM,WAAWA,iBAAAA,YAAA,EAAc,kBAAkB,WAAW,UAAU;AACtE,MAAI;AAAU,WAAO;AAErB,QAAM,WAAiC;AAAA,IACnC;AAAA,IACA,IAAI;AAAA;AAAA,IACJ;AAAA,IACA,QAAQ;AAAA,IACR,UAAU,SAAS;AAAA,IACnB,YAAY,SAAS;AAAA,IACrB,MAAM,SAAS;AAAA,IACf,oBAAoB,CAAA;AAAA,EAAA;AAIxB,QAAM,EAAC,OAAO,gBAAA,IAAmB,8BAAA;AACjC,MAAI;AACA,iBAAa,KAAK;AAAA,EACtB,QAAQ;AAAA,EAGR;AACA,QAAM,eAAe,gBAAA;AACrB,aAAW,OAAO,cAAc;AAC5B,QAAI,QAAQ;AAAY;AACxB,QAAI,CAAC,SAAS,mBAAmB,SAAS,GAAG;AAAG,eAAS,mBAAmB,KAAK,GAAG;AAAA,EACxF;AAEAA,mBAAAA,cAAc,UAAU,WAAW,QAAQ;AAC3C,SAAO;AACX;;AAGA,SAAS,gCAA6B;AAClC,QAAM,gBAAmB,IAAG,IAAA,CAAA,CAAA,GAAA,CAAA,GAAP,oBAAI;AACzB,QAAM,YAAYA,iBAAAA,YAAA;AAElB,QAAM,SAAS,MAAM,MAAK;AAAA,EAAE;AAE5B,QAAM,QAAQ,IAAI,MAAM,WAAW;AAAA,IAC/B,IAAI,QAAQ,MAAM,UAAQ;AACtB,UAAI,SAAS,eAAe,SAAS,aAAa;AAC9C,eAAA,aAAO,CAAC,IAAY,WAAkB;AAClC,uBAAa,IAAI,MAAM;AAEvB,gBAAM,OAAO,OAAO,UAAU,IAAI,MAAM;AACxC,iBAAO,QAAQ;AAAA,QACnB,GAAC,CAAA,MAAA,UAAA,IAAA,YAAA,CAAA;AAAA,MACL;AACA,UAAI,SAAS,qBAAqB;AAC9B,eAAA,aAAO,CAAC,IAAY,WAAkB;AAClC,uBAAa,IAAI,MAAM;AACvB,iBAAO,OAAO,kBAAkB,IAAI,MAAM;AAAA,QAC9C,GAAC,CAAA,MAAA,UAAA,IAAA,YAAA,CAAA;AAAA,MACL;AACA,UAAI,SAAS,aAAa;AACtB,eAAA,aAAO,CAAC,IAAY,WAAkB;AAClC,uBAAa,IAAI,MAAM;AACvB,iBAAO,OAAO,UAAU,IAAI,MAAM;AAAA,QACtC,GAAC,CAAA,MAAA,UAAA,IAAA,YAAA,CAAA;AAAA,MACL;AACA,UAAI,SAAS,sBAAsB;AAC/B,eAAA,aAAO,CAAC,WAAkB;AACtB,uBAAa,IAAI,MAAM;AACvB,iBAAO,OAAO,mBAAmB,MAAM;AAAA,QAC3C,GAAC,CAAA,UAAA,IAAA,SAAA,CAAA;AAAA,MACL;AACA,aAAO,QAAQ,IAAI,QAAQ,MAAM,QAAQ;AAAA,IAC7C;AAAA,EAAA,CACH;AAED,SAAO,EAAC,OAAO,iBAAiB,MAAM,aAAA;AAC1C;;;"}
1
+ {"version":3,"file":"pureFn.cjs","sources":["../../../../src/pureFns/pureFn.ts"],"sourcesContent":["/* ########\n * 2026 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport type {CompiledPureFunction, ParsedFactoryFn, PureFunctionFactory} from '../types/pureFunctions.types.ts';\nimport {getJitUtils, type JITUtils} from '../jit/jitUtils.ts';\n\n// ╔══════════════════════════════════════════════════════════════════════════════╗\n// ║ WARNING: This function's call signature is parsed by the mion vite plugin ║\n// ║ at build time (see devtools/src/vite-plugin/extractPureFn.ts). ║\n// ║ Do NOT rename, change the parameter order, or modify the function ║\n// ║ signature without updating the corresponding AST extraction and ║\n// ║ transformer logic in @mionjs/devtools. ║\n// ╚══════════════════════════════════════════════════════════════════════════════╝\n\n/**\n * Registers a pure function factory with automatic dependency tracking.\n * The `parsedFn` argument (containing bodyHash, paramNames, and code) is injected\n * at build time by the mion vite plugin's transform hook — it must never be passed manually.\n * If the function is already registered under the same namespace + functionID, the existing\n * compiled entry is returned (idempotent). Dependencies on other pure functions are\n * auto-detected by running the factory once with a tracking proxy.\n *\n * This is intended to share util functions between server and clients\n */\nexport function registerPureFnFactory(\n namespace: string,\n functionID: string,\n createPureFn: PureFunctionFactory,\n parsedFn?: ParsedFactoryFn // injected by mion vite plugin\n): CompiledPureFunction {\n if (!parsedFn) throw new Error('registerPureFnFactory requires mion vite plugin transform to inject parsedFn');\n const existing = getJitUtils().getCompiledPureFn(namespace, functionID);\n if (existing) return existing;\n\n const compiled: CompiledPureFunction = {\n createPureFn,\n fn: null as any, // will be set later so all possible dependencies are resolved\n namespace,\n fnName: functionID,\n bodyHash: parsedFn.bodyHash,\n paramNames: parsedFn.paramNames,\n code: parsedFn.code,\n };\n\n // Run the factory once with a tracking proxy to auto-detect dependencies\n const {proxy, getDependencies} = createDependencyTrackingProxy();\n try {\n createPureFn(proxy);\n } catch {\n // Factory may fail if dependencies aren't registered yet, that's ok\n // We still capture whatever was accessed before the error\n }\n const detectedDeps = getDependencies();\n for (const dep of detectedDeps) {\n if (dep === functionID) continue;\n if (compiled.pureFnDependencies?.includes(dep)) continue;\n if (!compiled.pureFnDependencies) (compiled as any).pureFnDependencies = [];\n compiled.pureFnDependencies!.push(dep);\n }\n\n getJitUtils().addPureFn(namespace, compiled);\n return compiled;\n}\n\n/** Creates a proxy of jitUtils that records all pure function accesses (getPureFn, usePureFn, etc.) */\nfunction createDependencyTrackingProxy(): {proxy: JITUtils; getDependencies: () => Set<string>} {\n const dependencies = new Set<string>();\n const realUtils = getJitUtils();\n\n const noopFn = () => () => {};\n\n const proxy = new Proxy(realUtils, {\n get(target, prop, receiver) {\n if (prop === 'getPureFn' || prop === 'usePureFn') {\n return (ns: string, fnName: string) => {\n dependencies.add(fnName);\n // Return a noop function so the factory can execute without errors\n const real = target.getPureFn(ns, fnName);\n return real ?? noopFn;\n };\n }\n if (prop === 'getCompiledPureFn') {\n return (ns: string, fnName: string) => {\n dependencies.add(fnName);\n return target.getCompiledPureFn(ns, fnName);\n };\n }\n if (prop === 'hasPureFn') {\n return (ns: string, fnName: string) => {\n dependencies.add(fnName);\n return target.hasPureFn(ns, fnName);\n };\n }\n if (prop === 'findCompiledPureFn') {\n return (fnName: string) => {\n dependencies.add(fnName);\n return target.findCompiledPureFn(fnName);\n };\n }\n return Reflect.get(target, prop, receiver);\n },\n });\n\n return {proxy, getDependencies: () => dependencies};\n}\n"],"names":["getJitUtils"],"mappings":";;;;;;;AA4BM,SAAU,sBACZ,WACA,YACA,cACA;AAEA,MAAI,CAAC;AAAU,UAAM,IAAI,MAAM,8EAA8E;AAC7G,QAAM,WAAWA,iBAAAA,YAAA,EAAc,kBAAkB,WAAW,UAAU;AACtE,MAAI;AAAU,WAAO;AAErB,QAAM,WAAiC;AAAA,IACnC;AAAA,IACA,IAAI;AAAA;AAAA,IACJ;AAAA,IACA,QAAQ;AAAA,IACR,UAAU,SAAS;AAAA,IACnB,YAAY,SAAS;AAAA,IACrB,MAAM,SAAS;AAAA,EAAA;AAInB,QAAM,EAAC,OAAO,gBAAA,IAAmB,8BAAA;AACjC,MAAI;AACA,iBAAa,KAAK;AAAA,EACtB,QAAQ;AAAA,EAGR;AACA,QAAM,eAAe,gBAAA;AACrB,aAAW,OAAO,cAAc;AAC5B,QAAI,QAAQ;AAAY;AACxB,QAAI,SAAS,oBAAoB,SAAS,GAAG;AAAG;AAChD,QAAI,CAAC,SAAS;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AAA,CACH;AAED,SAAO,EAAC,OAAO,iBAAiB,MAAM,aAAA;AAC1C;;;"}
@@ -21,7 +21,7 @@ function restoreCompiledPureFn(pureCache, namespace, fnName, jUtil, visited) {
21
21
  const pureCompiled = nsCache[fnName];
22
22
  if (!pureCompiled) throw new Error(`Pure function ${fnName} not found in namespace ${namespace}`);
23
23
  if (pureCompiled.fn) return;
24
- const dependencies = pureCompiled.pureFnDependencies;
24
+ const dependencies = pureCompiled.pureFnDependencies || [];
25
25
  dependencies.forEach((depName) => restoreCompiledPureFn(pureCache, namespace, depName, jUtil, visited));
26
26
  if (pureCompiled.createPureFn) {
27
27
  pureCompiled.fn = pureCompiled.createPureFn(jUtil);
@@ -35,14 +35,14 @@ function restoreCompiledJitFn(jitCache, pureCache, fnHash, jUtil, visitedPure, v
35
35
  const jitCompiled = jitCache[fnHash];
36
36
  if (!jitCompiled) throw new Error(`Jit function ${fnHash} not found`);
37
37
  if (jitCompiled.fn) return;
38
- const pureDependencies = jitCompiled.pureFnDependencies;
38
+ const pureDependencies = jitCompiled.pureFnDependencies || [];
39
39
  pureDependencies.forEach((dep) => {
40
40
  const parts = dep.split("::");
41
41
  if (parts.length !== 2) throw new Error(`Invalid pure function dependency format: ${dep}, expected "namespace::fnHash"`);
42
42
  const [namespace, fnHash2] = parts;
43
43
  restoreCompiledPureFn(pureCache, namespace, fnHash2, jUtil, visitedPure);
44
44
  });
45
- const dependencies = jitCompiled.jitDependencies;
45
+ const dependencies = jitCompiled.jitDependencies || [];
46
46
  dependencies.forEach((dep) => restoreCompiledJitFn(jitCache, pureCache, dep, jUtil, visitedPure, visitedJit));
47
47
  if (jitCompiled.createJitFn) {
48
48
  jitCompiled.fn = jitCompiled.createJitFn(jUtil);
@@ -1 +1 @@
1
- {"version":3,"file":"restoreJitFns.cjs","sources":["../../../../src/pureFns/restoreJitFns.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 {\n Mutable,\n JitCompiledFn,\n PersistedJitFunctionsCache,\n PersistedPureFunctionsCache,\n FnsDataCache,\n PureFnsDataCache,\n PureFunctionsCache,\n JitCompiledFnData,\n PersistedJitFn,\n} from '../types/general.types.ts';\nimport {JITUtils} from '../jit/jitUtils.ts';\nimport type {PersistedPureFunction} from '../types/pureFunctions.types.ts';\nimport type {CompiledPureFunction} from '../types/pureFunctions.types.ts';\nimport type {PureFunctionData} from '../types/pureFunctions.types.ts';\nimport type {PureFunctionFactory} from '../types/pureFunctions.types.ts';\nimport {TypedError} from '../errors.ts';\n\n/**\n * Restores the full state of a persisted/serialized jit functions.\n * This functions mutates the input caches!!!\n * Persisted functions are jit functions written to code that contains the createJitFn closure but not the fn.\n * Serialized functions are jit functions sent over the network that contains the code to recreate the createJitFn closure and fn.\n * The JIT fn itself can't be compiled to code as it contains references to context code and jitUtils.\n * So we need to restore it manually by invoking the closure function.\n * */\nexport function restoreCompiledJitFns(\n jitCache: PersistedJitFunctionsCache | FnsDataCache,\n pureCache: PureFunctionsCache | PersistedPureFunctionsCache | PureFnsDataCache,\n jUtil: JITUtils\n): void {\n // Use visited sets to prevent infinite recursion on circular dependencies\n // This is needed because during restoration, the `fn` property is not set until after\n // all dependencies are restored, so checking `fn` alone can't prevent circular calls\n const visitedPure = new Set<string>();\n const visitedJit = new Set<string>();\n\n // Iterate over all namespaces and restore pure functions\n for (const namespace in pureCache) {\n const nsCache = pureCache[namespace];\n const keysPureFns = Object.keys(nsCache);\n keysPureFns.forEach((key) => restoreCompiledPureFn(pureCache, namespace, key, jUtil, visitedPure));\n }\n const keysJitFns = Object.keys(jitCache);\n keysJitFns.forEach((key) => restoreCompiledJitFn(jitCache, pureCache, key, jUtil, visitedPure, visitedJit));\n}\n\nfunction restoreCompiledPureFn(\n pureCache: PureFunctionsCache | PersistedPureFunctionsCache | PureFnsDataCache,\n namespace: string,\n fnName: string,\n jUtil: JITUtils,\n visited: Set<string>\n) {\n // Use namespace:fnName as the visited key to handle same function names in different namespaces\n const visitedKey = `${namespace}:${fnName}`;\n // Skip if already visited (handles circular dependencies)\n if (visited.has(visitedKey)) return;\n visited.add(visitedKey);\n\n const nsCache = pureCache[namespace];\n if (!nsCache) throw new Error(`Pure function namespace ${namespace} not found`);\n const pureCompiled = nsCache[fnName];\n if (!pureCompiled) throw new Error(`Pure function ${fnName} not found in namespace ${namespace}`);\n if ((pureCompiled as CompiledPureFunction).fn) return;\n const dependencies = pureCompiled.pureFnDependencies;\n // Dependencies are in the same namespace\n dependencies.forEach((depName) => restoreCompiledPureFn(pureCache, namespace, depName, jUtil, visited));\n // persisted pure functions (AOT code caches) have the createJitFn but not the fn\n if ((pureCompiled as PersistedPureFunction).createPureFn) {\n (pureCompiled as any as Mutable<CompiledPureFunction>).fn = (pureCompiled as PersistedPureFunction).createPureFn(jUtil);\n return;\n }\n // serialized pure functions (network sent) do not contains neither createJitFn nor fn\n restorePureFunction(pureCompiled, jUtil);\n}\n\nfunction restoreCompiledJitFn(\n jitCache: PersistedJitFunctionsCache | FnsDataCache,\n pureCache: PureFunctionsCache | PersistedPureFunctionsCache | PureFnsDataCache,\n fnHash: string,\n jUtil: JITUtils,\n visitedPure: Set<string>,\n visitedJit: Set<string>\n) {\n // Skip if already visited (handles circular dependencies)\n if (visitedJit.has(fnHash)) return;\n visitedJit.add(fnHash);\n\n const jitCompiled = jitCache[fnHash];\n if (!jitCompiled) throw new Error(`Jit function ${fnHash} not found`);\n if ((jitCompiled as JitCompiledFn).fn) return;\n const pureDependencies = jitCompiled.pureFnDependencies;\n // Pure function dependencies are stored as \"namespace::fnHash\"\n pureDependencies.forEach((dep) => {\n const parts = dep.split('::');\n if (parts.length !== 2) throw new Error(`Invalid pure function dependency format: ${dep}, expected \"namespace::fnHash\"`);\n const [namespace, fnHash] = parts;\n restoreCompiledPureFn(pureCache, namespace, fnHash, jUtil, visitedPure);\n });\n const dependencies = jitCompiled.jitDependencies;\n dependencies.forEach((dep) => restoreCompiledJitFn(jitCache, pureCache, dep, jUtil, visitedPure, visitedJit));\n if ((jitCompiled as PersistedJitFn).createJitFn) {\n (jitCompiled as any as Mutable<JitCompiledFn>).fn = (jitCompiled as PersistedJitFn).createJitFn(jUtil);\n return;\n }\n restoreCreateJitFn(jitCompiled, jUtil);\n}\n\n/**\n * Restores a JIT function from serialized function data.\n * This functionsMutates the input data!!!\n * Creates a dynamic function using the serialized code (which already contains the complete function with context),\n * then executes it with jitUtils to produce the final JIT function.\n * @param fnData - The serialized function data containing code, args, and metadata\n * @returns A JitCompiledFn with both the createJitFn closure and the executed fn\n */\nfunction restoreCreateJitFn(fnData: JitCompiledFnData, jUtil: JITUtils): JitCompiledFn {\n const fnName = fnData.jitFnHash;\n // fnData.code already contains the complete function with context (e.g., \"const x = ...; return function fnName(args){...}\")\n const fnWithContext = `'use strict'; ${fnData.code}`;\n try {\n // Create wrapper function that works as a factory and returns the actual jit function\n const wrapperWithContext = new Function('utl', fnWithContext) as (utl: JITUtils) => (...args: any[]) => any;\n // Execute the wrapper with jitUtils to get the final function\n const fn = wrapperWithContext(jUtil);\n const jitFn = fnData as Mutable<JitCompiledFn>;\n jitFn.createJitFn = wrapperWithContext;\n jitFn.fn = fn;\n return jitFn;\n } catch (e: any) {\n throw new TypedError({\n type: 'jit-fn-restore-error',\n message: `Failed to restore JIT function ${fnName}: ${e?.message}`,\n });\n }\n}\n\n/**\n * Restores a pure function from serialized function data.\n * This function mutates the input data!!!\n * Creates a dynamic function using the serialized code (which already contains the complete function with context),\n * then executes it with jitUtils to produce the final pure function.\n * @param pureFnData - The serialized pure function data containing code and metadata\n * @returns A CompiledPureFunction with both the createJitFn closure and the executed fn\n */\nfunction restorePureFunction(pureFnData: PureFunctionData, jUtil: JITUtils): CompiledPureFunction {\n const fnName = pureFnData.fnName;\n // pureFnData.code already contains the complete function with context\n const fnWithContext = `'use strict'; ${pureFnData.code}`;\n try {\n // Create wrapper function that works as a factory and returns the actual pure function\n const wrapperWithContext = new Function('utl', fnWithContext) as PureFunctionFactory;\n // Execute the wrapper with jitUtils to get the final function\n const fn = wrapperWithContext(jUtil);\n const pureFn = pureFnData as Mutable<CompiledPureFunction>;\n pureFn.createPureFn = wrapperWithContext;\n pureFn.fn = fn;\n return pureFn;\n } catch (e: any) {\n throw new TypedError({\n type: 'pure-fn-restore-error',\n message: `Failed to restore pure function ${fnName}: ${e?.message}`,\n });\n }\n}\n"],"names":["fnHash","TypedError"],"mappings":";;;AAiCO,SAAS,sBACZ,UACA,WACA,OACI;AAIJ,QAAM,kCAAkB,IAAA;AACxB,QAAM,iCAAiB,IAAA;AAGvB,aAAW,aAAa,WAAW;AAC/B,UAAM,UAAU,UAAU,SAAS;AACnC,UAAM,cAAc,OAAO,KAAK,OAAO;AACvC,gBAAY,QAAQ,CAAC,QAAQ,sBAAsB,WAAW,WAAW,KAAK,OAAO,WAAW,CAAC;AAAA,EACrG;AACA,QAAM,aAAa,OAAO,KAAK,QAAQ;AACvC,aAAW,QAAQ,CAAC,QAAQ,qBAAqB,UAAU,WAAW,KAAK,OAAO,aAAa,UAAU,CAAC;AAC9G;AAEA,SAAS,sBACL,WACA,WACA,QACA,OACA,SACF;AAEE,QAAM,aAAa,GAAG,SAAS,IAAI,MAAM;AAEzC,MAAI,QAAQ,IAAI,UAAU,EAAG;AAC7B,UAAQ,IAAI,UAAU;AAEtB,QAAM,UAAU,UAAU,SAAS;AACnC,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,2BAA2B,SAAS,YAAY;AAC9E,QAAM,eAAe,QAAQ,MAAM;AACnC,MAAI,CAAC,aAAc,OAAM,IAAI,MAAM,iBAAiB,MAAM,2BAA2B,SAAS,EAAE;AAChG,MAAK,aAAsC,GAAI;AAC/C,QAAM,eAAe,aAAa;AAElC,eAAa,QAAQ,CAAC,YAAY,sBAAsB,WAAW,WAAW,SAAS,OAAO,OAAO,CAAC;AAEtG,MAAK,aAAuC,cAAc;AACrD,iBAAsD,KAAM,aAAuC,aAAa,KAAK;AAC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AAM,SAAS,WAAW;AAE1B,QAAM,gBAAgB,iBAAiB,WAAW,IAAI;AACtD,MAAI;AAEA,UAAM,qBAAqB,IAAI,SAAS,OAAO,aAAa;AAE5D,UAAM,KAAK,mBAAmB,KAAK;AACnC,UAAM,SAAS;AACf,WAAO,eAAe;AACtB,WAAO,KAAK;AACZ,WAAO;AAAA,EACX,SAAS,GAAQ;AACb,UAAM,IAAIA,WAAAA,WAAW;AAAA,MACjB,MAAM;AAAA,MACN,SAAS,mCAAmC,MAAM,KAAK,GAAG,OAAO;AAAA,IAAA,CACpE;AAAA,EACL;AACJ;;"}
1
+ {"version":3,"file":"restoreJitFns.cjs","sources":["../../../../src/pureFns/restoreJitFns.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 {\n Mutable,\n JitCompiledFn,\n PersistedJitFunctionsCache,\n PersistedPureFunctionsCache,\n FnsDataCache,\n PureFnsDataCache,\n PureFunctionsCache,\n JitCompiledFnData,\n PersistedJitFn,\n} from '../types/general.types.ts';\nimport {JITUtils} from '../jit/jitUtils.ts';\nimport type {PersistedPureFunction} from '../types/pureFunctions.types.ts';\nimport type {CompiledPureFunction} from '../types/pureFunctions.types.ts';\nimport type {PureFunctionData} from '../types/pureFunctions.types.ts';\nimport type {PureFunctionFactory} from '../types/pureFunctions.types.ts';\nimport {TypedError} from '../errors.ts';\n\n/**\n * Restores the full state of a persisted/serialized jit functions.\n * This functions mutates the input caches!!!\n * Persisted functions are jit functions written to code that contains the createJitFn closure but not the fn.\n * Serialized functions are jit functions sent over the network that contains the code to recreate the createJitFn closure and fn.\n * The JIT fn itself can't be compiled to code as it contains references to context code and jitUtils.\n * So we need to restore it manually by invoking the closure function.\n * */\nexport function restoreCompiledJitFns(\n jitCache: PersistedJitFunctionsCache | FnsDataCache,\n pureCache: PureFunctionsCache | PersistedPureFunctionsCache | PureFnsDataCache,\n jUtil: JITUtils\n): void {\n // Use visited sets to prevent infinite recursion on circular dependencies\n // This is needed because during restoration, the `fn` property is not set until after\n // all dependencies are restored, so checking `fn` alone can't prevent circular calls\n const visitedPure = new Set<string>();\n const visitedJit = new Set<string>();\n\n // Iterate over all namespaces and restore pure functions\n for (const namespace in pureCache) {\n const nsCache = pureCache[namespace];\n const keysPureFns = Object.keys(nsCache);\n keysPureFns.forEach((key) => restoreCompiledPureFn(pureCache, namespace, key, jUtil, visitedPure));\n }\n const keysJitFns = Object.keys(jitCache);\n keysJitFns.forEach((key) => restoreCompiledJitFn(jitCache, pureCache, key, jUtil, visitedPure, visitedJit));\n}\n\nfunction restoreCompiledPureFn(\n pureCache: PureFunctionsCache | PersistedPureFunctionsCache | PureFnsDataCache,\n namespace: string,\n fnName: string,\n jUtil: JITUtils,\n visited: Set<string>\n) {\n // Use namespace:fnName as the visited key to handle same function names in different namespaces\n const visitedKey = `${namespace}:${fnName}`;\n // Skip if already visited (handles circular dependencies)\n if (visited.has(visitedKey)) return;\n visited.add(visitedKey);\n\n const nsCache = pureCache[namespace];\n if (!nsCache) throw new Error(`Pure function namespace ${namespace} not found`);\n const pureCompiled = nsCache[fnName];\n if (!pureCompiled) throw new Error(`Pure function ${fnName} not found in namespace ${namespace}`);\n if ((pureCompiled as CompiledPureFunction).fn) return;\n const dependencies = pureCompiled.pureFnDependencies || [];\n // Dependencies are in the same namespace\n dependencies.forEach((depName) => restoreCompiledPureFn(pureCache, namespace, depName, jUtil, visited));\n // persisted pure functions (AOT code caches) have the createJitFn but not the fn\n if ((pureCompiled as PersistedPureFunction).createPureFn) {\n (pureCompiled as any as Mutable<CompiledPureFunction>).fn = (pureCompiled as PersistedPureFunction).createPureFn(jUtil);\n return;\n }\n // serialized pure functions (network sent) do not contains neither createJitFn nor fn\n restorePureFunction(pureCompiled, jUtil);\n}\n\nfunction restoreCompiledJitFn(\n jitCache: PersistedJitFunctionsCache | FnsDataCache,\n pureCache: PureFunctionsCache | PersistedPureFunctionsCache | PureFnsDataCache,\n fnHash: string,\n jUtil: JITUtils,\n visitedPure: Set<string>,\n visitedJit: Set<string>\n) {\n // Skip if already visited (handles circular dependencies)\n if (visitedJit.has(fnHash)) return;\n visitedJit.add(fnHash);\n\n const jitCompiled = jitCache[fnHash];\n if (!jitCompiled) throw new Error(`Jit function ${fnHash} not found`);\n if ((jitCompiled as JitCompiledFn).fn) return;\n const pureDependencies = jitCompiled.pureFnDependencies || [];\n // Pure function dependencies are stored as \"namespace::fnHash\"\n pureDependencies.forEach((dep) => {\n const parts = dep.split('::');\n if (parts.length !== 2) throw new Error(`Invalid pure function dependency format: ${dep}, expected \"namespace::fnHash\"`);\n const [namespace, fnHash] = parts;\n restoreCompiledPureFn(pureCache, namespace, fnHash, jUtil, visitedPure);\n });\n const dependencies = jitCompiled.jitDependencies || [];\n dependencies.forEach((dep) => restoreCompiledJitFn(jitCache, pureCache, dep, jUtil, visitedPure, visitedJit));\n if ((jitCompiled as PersistedJitFn).createJitFn) {\n (jitCompiled as any as Mutable<JitCompiledFn>).fn = (jitCompiled as PersistedJitFn).createJitFn(jUtil);\n return;\n }\n restoreCreateJitFn(jitCompiled, jUtil);\n}\n\n/**\n * Restores a JIT function from serialized function data.\n * This functionsMutates the input data!!!\n * Creates a dynamic function using the serialized code (which already contains the complete function with context),\n * then executes it with jitUtils to produce the final JIT function.\n * @param fnData - The serialized function data containing code, args, and metadata\n * @returns A JitCompiledFn with both the createJitFn closure and the executed fn\n */\nfunction restoreCreateJitFn(fnData: JitCompiledFnData, jUtil: JITUtils): JitCompiledFn {\n const fnName = fnData.jitFnHash;\n // fnData.code already contains the complete function with context (e.g., \"const x = ...; return function fnName(args){...}\")\n const fnWithContext = `'use strict'; ${fnData.code}`;\n try {\n // Create wrapper function that works as a factory and returns the actual jit function\n const wrapperWithContext = new Function('utl', fnWithContext) as (utl: JITUtils) => (...args: any[]) => any;\n // Execute the wrapper with jitUtils to get the final function\n const fn = wrapperWithContext(jUtil);\n const jitFn = fnData as Mutable<JitCompiledFn>;\n jitFn.createJitFn = wrapperWithContext;\n jitFn.fn = fn;\n return jitFn;\n } catch (e: any) {\n throw new TypedError({\n type: 'jit-fn-restore-error',\n message: `Failed to restore JIT function ${fnName}: ${e?.message}`,\n });\n }\n}\n\n/**\n * Restores a pure function from serialized function data.\n * This function mutates the input data!!!\n * Creates a dynamic function using the serialized code (which already contains the complete function with context),\n * then executes it with jitUtils to produce the final pure function.\n * @param pureFnData - The serialized pure function data containing code and metadata\n * @returns A CompiledPureFunction with both the createJitFn closure and the executed fn\n */\nfunction restorePureFunction(pureFnData: PureFunctionData, jUtil: JITUtils): CompiledPureFunction {\n const fnName = pureFnData.fnName;\n // pureFnData.code already contains the complete function with context\n const fnWithContext = `'use strict'; ${pureFnData.code}`;\n try {\n // Create wrapper function that works as a factory and returns the actual pure function\n const wrapperWithContext = new Function('utl', fnWithContext) as PureFunctionFactory;\n // Execute the wrapper with jitUtils to get the final function\n const fn = wrapperWithContext(jUtil);\n const pureFn = pureFnData as Mutable<CompiledPureFunction>;\n pureFn.createPureFn = wrapperWithContext;\n pureFn.fn = fn;\n return pureFn;\n } catch (e: any) {\n throw new TypedError({\n type: 'pure-fn-restore-error',\n message: `Failed to restore pure function ${fnName}: ${e?.message}`,\n });\n }\n}\n"],"names":["fnHash","TypedError"],"mappings":";;;AAiCO,SAAS,sBACZ,UACA,WACA,OACI;AAIJ,QAAM,kCAAkB,IAAA;AACxB,QAAM,iCAAiB,IAAA;AAGvB,aAAW,aAAa,WAAW;AAC/B,UAAM,UAAU,UAAU,SAAS;AACnC,UAAM,cAAc,OAAO,KAAK,OAAO;AACvC,gBAAY,QAAQ,CAAC,QAAQ,sBAAsB,WAAW,WAAW,KAAK,OAAO,WAAW,CAAC;AAAA,EACrG;AACA,QAAM,aAAa,OAAO,KAAK,QAAQ;AACvC,aAAW,QAAQ,CAAC,QAAQ,qBAAqB,UAAU,WAAW,KAAK,OAAO,aAAa,UAAU,CAAC;AAC9G;AAEA,SAAS,sBACL,W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AC5G,MAAK,YAA+B,aAAa;AAC5C,gBAA8C,KAAM,YAA+B,YAAY,KAAK;AACrG;AAAA,EACJ;AACA,qBAAmB,aAAa,KAAK;AACzC;AAUA,SAAS,mBAAmB,QAA2B,OAAgC;AACnF,QAAM,SAAS,OAAO;AAEtB,QAAM,gBAAgB,iBAAiB,OAAO,IAAI;AAClD,MAAI;AAEA,UAAM,qBAAqB,IAAI,SAAS,OAAO,aAAa;AAE5D,UAAM,KAAK,mBAAmB,KAAK;AACnC,UAAM,QAAQ;AACd,UAAM,cAAc;AACpB,UAAM,KAAK;AACX,WAAO;AAAA,EACX,SAAS,GAAQ;AACb,UAAM,IAAIC,WAAAA,WAAW;AAAA,MACjB,MAAM;AAAA,MACN,SAAS,kCAAkC,MAAM,KAAK,GAAG,OAAO;AAAA,IAAA,CACnE;AAAA,EACL;AACJ;AAUA,SAAS,oBAAoB,YAA8B,OAAuC;AAC9F,QAAM,SAAS,WAAW;AAE1B,QAAM,gBAAgB,iBAAiB,WAAW,IAAI;AACtD,MAAI;AAEA,UAAM,qBAAqB,IAAI,SAAS,OAAO,aAAa;AAE5D,UAAM,KAAK,mBAAmB,KAAK;AACnC,UAAM,SAAS;AACf,WAAO,eAAe;AACtB,WAAO,KAAK;AACZ,WAAO;AAAA,EACX,SAAS,GAAQ;AACb,UAAM,IAAIA,WAAAA,WAAW;AAAA,MACjB,MAAM;AAAA,MACN,SAAS,mCAAmC,MAAM,KAAK,GAAG,OAAO;AAAA,IAAA,CACpE;AAAA,EACL;AACJ;;"}
@@ -104,33 +104,36 @@ function addRoutesToCache(newCache) {
104
104
  }
105
105
  }
106
106
  }
107
- function getJitFnHashes(jitHash) {
107
+ function getJitFnHashes(jitHash, needsBinary = false) {
108
108
  return {
109
109
  isType: `${src_constants.JIT_FUNCTION_IDS.isType}_${jitHash}`,
110
110
  typeErrors: `${src_constants.JIT_FUNCTION_IDS.typeErrors}_${jitHash}`,
111
111
  prepareForJson: `${src_constants.JIT_FUNCTION_IDS.prepareForJson}_${jitHash}`,
112
112
  restoreFromJson: `${src_constants.JIT_FUNCTION_IDS.restoreFromJson}_${jitHash}`,
113
113
  stringifyJson: `${src_constants.JIT_FUNCTION_IDS.stringifyJson}_${jitHash}`,
114
- toBinary: `${src_constants.JIT_FUNCTION_IDS.toBinary}_${jitHash}`,
115
- fromBinary: `${src_constants.JIT_FUNCTION_IDS.fromBinary}_${jitHash}`
114
+ ...needsBinary ? {
115
+ toBinary: `${src_constants.JIT_FUNCTION_IDS.toBinary}_${jitHash}`,
116
+ fromBinary: `${src_constants.JIT_FUNCTION_IDS.fromBinary}_${jitHash}`
117
+ } : {}
116
118
  };
117
119
  }
118
120
  function getJitFunctionsFromHash(jitHash) {
119
121
  if (jitHash === src_constants.EMPTY_HASH) return noopJitFns;
120
122
  const cached = jitFunctionsCache.get(jitHash);
121
123
  if (cached) return cached;
122
- const hashes = getJitFnHashes(jitHash);
123
124
  const jUtils = src_jit_jitUtils.getJitUtils();
124
125
  const jitFns = {
125
- isType: jUtils.getJIT(hashes.isType),
126
- typeErrors: jUtils.getJIT(hashes.typeErrors),
127
- prepareForJson: jUtils.getJIT(hashes.prepareForJson),
128
- restoreFromJson: jUtils.getJIT(hashes.restoreFromJson),
129
- stringifyJson: jUtils.getJIT(hashes.stringifyJson),
130
- toBinary: jUtils.getJIT(hashes.toBinary),
131
- fromBinary: jUtils.getJIT(hashes.fromBinary)
126
+ isType: jUtils.getJIT(`${src_constants.JIT_FUNCTION_IDS.isType}_${jitHash}`),
127
+ typeErrors: jUtils.getJIT(`${src_constants.JIT_FUNCTION_IDS.typeErrors}_${jitHash}`),
128
+ prepareForJson: jUtils.getJIT(`${src_constants.JIT_FUNCTION_IDS.prepareForJson}_${jitHash}`),
129
+ restoreFromJson: jUtils.getJIT(`${src_constants.JIT_FUNCTION_IDS.restoreFromJson}_${jitHash}`),
130
+ stringifyJson: jUtils.getJIT(`${src_constants.JIT_FUNCTION_IDS.stringifyJson}_${jitHash}`)
132
131
  };
133
- for (const key in jitFns) {
132
+ const toBinaryJit = jUtils.getJIT(`${src_constants.JIT_FUNCTION_IDS.toBinary}_${jitHash}`);
133
+ const fromBinaryJit = jUtils.getJIT(`${src_constants.JIT_FUNCTION_IDS.fromBinary}_${jitHash}`);
134
+ if (toBinaryJit) jitFns.toBinary = toBinaryJit;
135
+ if (fromBinaryJit) jitFns.fromBinary = fromBinaryJit;
136
+ for (const key of ["isType", "typeErrors", "prepareForJson", "restoreFromJson", "stringifyJson"]) {
134
137
  if (!jitFns[key]) throw new Error(`Jit function ${key} not found for jitHash ${jitHash}`);
135
138
  }
136
139
  jitFunctionsCache.set(jitHash, jitFns);
@@ -169,9 +172,7 @@ const noopJitFns = {
169
172
  typeErrors: fakeJitFn(src_constants.JIT_FUNCTION_IDS.typeErrors),
170
173
  prepareForJson: fakeJitFn(src_constants.JIT_FUNCTION_IDS.prepareForJson),
171
174
  restoreFromJson: fakeJitFn(src_constants.JIT_FUNCTION_IDS.restoreFromJson),
172
- stringifyJson: fakeJitFn(src_constants.JIT_FUNCTION_IDS.stringifyJson),
173
- toBinary: fakeJitFn(src_constants.JIT_FUNCTION_IDS.toBinary),
174
- fromBinary: fakeJitFn(src_constants.JIT_FUNCTION_IDS.fromBinary)
175
+ stringifyJson: fakeJitFn(src_constants.JIT_FUNCTION_IDS.stringifyJson)
175
176
  };
176
177
  function fakeJitFn(fnID) {
177
178
  return {
@@ -182,8 +183,6 @@ function fakeJitFn(fnID) {
182
183
  defaultParamValues: { vλl: "v" },
183
184
  isNoop: true,
184
185
  code: "",
185
- jitDependencies: [],
186
- pureFnDependencies: [],
187
186
  createJitFn: () => {
188
187
  throw new Error("isNoop JIT functions should not be called, this is a function when jit is never used");
189
188
  },
@@ -1 +1 @@
1
- {"version":3,"file":"routerUtils.cjs","sources":["../../../src/routerUtils.ts"],"sourcesContent":["/* ########\n * 2023 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport {JIT_FUNCTION_IDS, PATH_SEPARATOR, ROUTER_ITEM_SEPARATOR_CHAR, ROUTE_PATH_ROOT, EMPTY_HASH} from './constants.ts';\nimport type {RemoteMethodOpts, MethodWithOptions, MethodsCache, MethodWithOptsAndJitFns} from './types/method.types.ts';\nimport type {CoreRouterOptions, JitCompiledFn, JitCompiledFunctions, JitFunctionsHashes} from './types/general.types.ts';\nimport {getJitUtils} from './jit/jitUtils.ts';\n\nconst methodsCache: MethodsCache = {};\nconst methodsOptionsCache: Record<string, RemoteMethodOpts> = {};\n\n// Cache for JitCompiledFunctions objects keyed by jitHash\nconst jitFunctionsCache = new Map<string, JitCompiledFunctions>();\nconst headerJitFunctionsCache = new Map<string, Pick<JitCompiledFunctions, 'isType' | 'typeErrors'>>();\n\n/**\n * Utilities for accessing and modifying the router cache.\n * The router cache stores method metadata for routes registered via addRoutesToCache() or virtual modules.\n */\nexport const routesCache = {\n /**\n * Get method metadata from the router cache by id.\n * @param id - The method id\n * @returns The method metadata or undefined if not found\n */\n getMetadata(id: string): MethodWithOptions | undefined {\n return methodsCache[id] as MethodWithOptions | undefined;\n },\n\n /**\n * Set method metadata in the router cache\n * @param id - The method id\n * @param methodData - The method metadata\n */\n setMetadata(id: string, methodData: MethodWithOptions): void {\n methodsCache[id] = methodData as any;\n },\n\n /**\n * Check if the router cache contains a method by id.\n * @param id - The method id\n * @returns True if the method exists in the cache\n */\n hasMetadata(id: string): boolean {\n return id in methodsCache;\n },\n\n /**\n * Get the raw router cache object.\n * Use with caution - prefer using get/set/has methods.\n * @returns The router cache object\n */\n getCache(): MethodsCache {\n return methodsCache;\n },\n\n /**\n * Get method metadata with JIT functions restored from the router cache by id.\n * This augments the MethodWithOptions with paramsJitFns and returnJitFns.\n * JIT functions are cached in the entry after first access for performance.\n * @param id - The method id\n * @returns The method metadata with JIT functions or undefined if not found\n */\n getMethodJitFns(id: string): MethodWithOptsAndJitFns | undefined {\n if (id in methodsCache) {\n const cached = methodsCache[id] as any;\n if (cached.paramsJitFns && cached.returnJitFns) {\n return cached as MethodWithOptsAndJitFns;\n }\n }\n\n const metadata = this.getMetadata(id);\n if (!metadata) return undefined;\n\n const paramsJitFns = getJitFunctionsFromHash(metadata.paramsJitHash);\n const returnJitFns = getJitFunctionsFromHash(metadata.returnJitHash);\n const headersParam = metadata.headersParam\n ? {...metadata.headersParam, jitFns: getHeaderJitFunctionsFromHash(metadata.headersParam.jitHash)}\n : undefined;\n const headersReturn = metadata.headersReturn\n ? {...metadata.headersReturn, jitFns: getHeaderJitFunctionsFromHash(metadata.headersReturn.jitHash)}\n : undefined;\n\n const result: MethodWithOptsAndJitFns = {\n ...metadata,\n paramsJitFns,\n returnJitFns,\n headersParam,\n headersReturn,\n };\n\n methodsCache[id] = result;\n return result as MethodWithOptsAndJitFns;\n },\n\n /**\n * Get method metadata with JIT functions restored from the router cache by id.\n * @param id\n * @returns\n */\n useMethodJitFns(id: string): MethodWithOptsAndJitFns {\n const MethodWithOptsAndJitFns = this.getMethodJitFns(id);\n if (!MethodWithOptsAndJitFns) throw new Error(`Metadata for remote method ${id} not found`);\n return MethodWithOptsAndJitFns;\n },\n\n /**\n * Set method metadata with JIT functions in the router cache.\n * This stores the complete MethodWithOptsAndJitFns object directly.\n * @param id - The method id\n * @param MethodWithOptsAndJitFns - The method metadata with JIT functions\n */\n setMethodJitFns(id: string, MethodWithOptsAndJitFns: MethodWithOptsAndJitFns): void {\n methodsCache[id] = MethodWithOptsAndJitFns as any;\n },\n};\n\nexport const methodOptsCache = {\n getMethodOptions(id: string): RemoteMethodOpts | undefined {\n return methodsOptionsCache[id];\n },\n setMethodOptions(id: string, options: RemoteMethodOpts): void {\n methodsOptionsCache[id] = options;\n },\n};\n\n/**\n * Adds new routes to the router cache.\n * This is the public API for registering routes - called by virtual modules or directly.\n * @param newCache\n */\nexport function addRoutesToCache(newCache: MethodsCache) {\n for (const key in newCache) {\n if (!(key in methodsCache)) {\n // Clone the cache entry to avoid mutating the original\n methodsCache[key] = {...newCache[key]} as MethodWithOptions;\n }\n }\n}\n\nexport function getJitFnHashes(jitHash: string): JitFunctionsHashes {\n return {\n isType: `${JIT_FUNCTION_IDS.isType}_${jitHash}`,\n typeErrors: `${JIT_FUNCTION_IDS.typeErrors}_${jitHash}`,\n prepareForJson: `${JIT_FUNCTION_IDS.prepareForJson}_${jitHash}`,\n restoreFromJson: `${JIT_FUNCTION_IDS.restoreFromJson}_${jitHash}`,\n stringifyJson: `${JIT_FUNCTION_IDS.stringifyJson}_${jitHash}`,\n toBinary: `${JIT_FUNCTION_IDS.toBinary}_${jitHash}`,\n fromBinary: `${JIT_FUNCTION_IDS.fromBinary}_${jitHash}`,\n };\n}\n\n/**\n * Helper function to get JIT functions from a JIT hash\n * Returns nullJitFns for empty hash (handlers with no params or void return)\n * Results are cached to avoid creating duplicate objects.\n */\nexport function getJitFunctionsFromHash(jitHash: string): JitCompiledFunctions {\n // Empty hash means no JIT functions were generated (optimization for no params or void return)\n if (jitHash === EMPTY_HASH) return noopJitFns;\n\n // Check cache first\n const cached = jitFunctionsCache.get(jitHash);\n if (cached) return cached;\n\n const hashes = getJitFnHashes(jitHash);\n const jUtils = getJitUtils();\n const jitFns = {\n isType: jUtils.getJIT(hashes.isType),\n typeErrors: jUtils.getJIT(hashes.typeErrors),\n prepareForJson: jUtils.getJIT(hashes.prepareForJson),\n restoreFromJson: jUtils.getJIT(hashes.restoreFromJson),\n stringifyJson: jUtils.getJIT(hashes.stringifyJson),\n toBinary: jUtils.getJIT(hashes.toBinary),\n fromBinary: jUtils.getJIT(hashes.fromBinary),\n } as JitCompiledFunctions;\n for (const key in jitFns) {\n if (!jitFns[key]) throw new Error(`Jit function ${key} not found for jitHash ${jitHash}`);\n }\n\n // Cache for future calls\n jitFunctionsCache.set(jitHash, jitFns);\n return jitFns;\n}\n\n/**\n * Helper function to get header JIT functions from a JIT hash\n * Results are cached to avoid creating duplicate objects.\n */\nexport function getHeaderJitFunctionsFromHash(jitHash: string): Pick<JitCompiledFunctions, 'isType' | 'typeErrors'> {\n // Check cache first\n const cached = headerJitFunctionsCache.get(jitHash);\n if (cached) return cached;\n\n const hashes = getJitFnHashes(jitHash);\n const jUtils = getJitUtils();\n const jitFns = {\n isType: jUtils.getJIT(hashes.isType),\n typeErrors: jUtils.getJIT(hashes.typeErrors),\n } as Pick<JitCompiledFunctions, 'isType' | 'typeErrors'>;\n\n // Cache for future calls\n headerJitFunctionsCache.set(jitHash, jitFns);\n return jitFns;\n}\n\n/**\n * Get the router id for Routes or MiddleFns\n * @param itemPointer - The pointer to the item within the Routes object\n * i.e:\n * const routes = {\n * auth: () => {},\n * users: {\n * getUser: () => {}\n * }\n * login: () => {}\n * }\n *\n * then the pointer for getUser is => ['users', 'getUser']\n */\nexport function getRouterItemId(itemPointer: string[]) {\n return itemPointer.join(ROUTER_ITEM_SEPARATOR_CHAR);\n}\n\n/** Gets a route path from a route pointer */\nexport function getRoutePath(pathPointer: string[], routerOptions: CoreRouterOptions) {\n const pathId = getRouterItemId(pathPointer);\n const basePath = routerOptions.basePath.startsWith(ROUTE_PATH_ROOT)\n ? routerOptions.basePath\n : `${ROUTE_PATH_ROOT}${routerOptions.basePath}`;\n const routePath = basePath.endsWith(PATH_SEPARATOR) ? `${basePath}${pathId}` : `${basePath}${PATH_SEPARATOR}${pathId}`;\n return routerOptions.suffix ? routePath + routerOptions.suffix : routePath;\n}\n\nexport function resetRoutesCache() {\n for (const k in methodsCache) delete methodsCache[k];\n}\n\n/** Resets the JIT functions cache. Useful for testing purposes only. */\nexport function resetJitFunctionsCache(): void {\n jitFunctionsCache.clear();\n headerJitFunctionsCache.clear();\n}\n\n// Noop JIT functions used for handlers with no params or void return\n// prettier-ignore\nconst noopJitFns: JitCompiledFunctions = {\n isType: fakeJitFn(JIT_FUNCTION_IDS.isType),\n typeErrors: fakeJitFn(JIT_FUNCTION_IDS.typeErrors),\n prepareForJson: fakeJitFn(JIT_FUNCTION_IDS.prepareForJson),\n restoreFromJson: fakeJitFn(JIT_FUNCTION_IDS.restoreFromJson),\n stringifyJson: fakeJitFn(JIT_FUNCTION_IDS.stringifyJson),\n toBinary: fakeJitFn(JIT_FUNCTION_IDS.toBinary),\n fromBinary: fakeJitFn(JIT_FUNCTION_IDS.fromBinary),\n} as any;\n\n/** Creates a fake JIT function with isNoop=true for handlers with no params or void return */\nfunction fakeJitFn(fnID: string): JitCompiledFn<any> {\n return {\n typeName: 'mionNoopJit',\n fnID,\n jitFnHash: EMPTY_HASH,\n args: {vλl: 'v'},\n defaultParamValues: {vλl: 'v'},\n isNoop: true,\n code: '',\n jitDependencies: [],\n pureFnDependencies: [],\n createJitFn: () => {\n throw new Error('isNoop JIT functions should not be called, this is a function when jit is never used');\n },\n fn: () => {\n throw new Error('isNoop JIT functions should not be called, this is a function when jit is never used');\n },\n };\n}\n\nexport function getNoopJitFns(): JitCompiledFunctions {\n return noopJitFns;\n}\n"],"names":["JIT_FUNCTION_IDS","EMPTY_HASH","getJitUtils","ROUTER_ITEM_SEPARATOR_CHAR","ROUTE_PATH_ROOT","PATH_SEPARATOR"],"mappings":";;;;AAYA,MAAM,eAA6B,CAAA;AACnC,MAAM,sBAAwD,CAAA;AAG9D,MAAM,wCAAwB,IAAA;AAC9B,MAAM,8CAA8B,IAAA;AAM7B,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvB,YAAY,IAA2C;AACnD,WAAO,aAAa,EAAE;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY,IAAY,YAAqC;AACzD,iBAAa,EAAE,IAAI;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY,IAAqB;AAC7B,WAAO,MAAM;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAyB;AACrB,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,gBAAgB,IAAiD;AAC7D,QAAI,MAAM,cAAc;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UAAU;AAAA,IACV;AAAA,IACA,WAAWC,cAAAA;AAAAA,IACX,MAAM,EAAC,KAAK,IAAA;AAAA,IACZ,oBAAoB,EAAC,KAAK,IAAA;AAAA,IAC1B,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,iBAAiB,CAAA;AAAA,IACjB,oBAAoB,CAAA;AAAA,IACpB,aAAa,MAAM;AACf,YAAM,IAAI,MAAM,sFAAsF;AAAA,IAC1G;AAAA,IACA,IAAI,MAAM;AACN,YAAM,IAAI,MAAM,sFAAsF;AAAA,IAC1G;AAAA,EAAA;AAER;AAEO,SAAS,gBAAsC;AAClD,SAAO;AACX;;;;;;;;;;;;"}
1
+ {"version":3,"file":"routerUtils.cjs","sources":["../../../src/routerUtils.ts"],"sourcesContent":["/* ########\n * 2023 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport {JIT_FUNCTION_IDS, PATH_SEPARATOR, ROUTER_ITEM_SEPARATOR_CHAR, ROUTE_PATH_ROOT, EMPTY_HASH} from './constants.ts';\nimport type {RemoteMethodOpts, MethodWithOptions, MethodsCache, MethodWithOptsAndJitFns} from './types/method.types.ts';\nimport type {CoreRouterOptions, JitCompiledFn, JitCompiledFunctions, JitFunctionsHashes} from './types/general.types.ts';\nimport {getJitUtils} from './jit/jitUtils.ts';\n\nconst methodsCache: MethodsCache = {};\nconst methodsOptionsCache: Record<string, RemoteMethodOpts> = {};\n\n// Cache for JitCompiledFunctions objects keyed by jitHash\nconst jitFunctionsCache = new Map<string, JitCompiledFunctions>();\nconst headerJitFunctionsCache = new Map<string, Pick<JitCompiledFunctions, 'isType' | 'typeErrors'>>();\n\n/**\n * Utilities for accessing and modifying the router cache.\n * The router cache stores method metadata for routes registered via addRoutesToCache() or virtual modules.\n */\nexport const routesCache = {\n /**\n * Get method metadata from the router cache by id.\n * @param id - The method id\n * @returns The method metadata or undefined if not found\n */\n getMetadata(id: string): MethodWithOptions | undefined {\n return methodsCache[id] as MethodWithOptions | undefined;\n },\n\n /**\n * Set method metadata in the router cache\n * @param id - The method id\n * @param methodData - The method metadata\n */\n setMetadata(id: string, methodData: MethodWithOptions): void {\n methodsCache[id] = methodData as any;\n },\n\n /**\n * Check if the router cache contains a method by id.\n * @param id - The method id\n * @returns True if the method exists in the cache\n */\n hasMetadata(id: string): boolean {\n return id in methodsCache;\n },\n\n /**\n * Get the raw router cache object.\n * Use with caution - prefer using get/set/has methods.\n * @returns The router cache object\n */\n getCache(): MethodsCache {\n return methodsCache;\n },\n\n /**\n * Get method metadata with JIT functions restored from the router cache by id.\n * This augments the MethodWithOptions with paramsJitFns and returnJitFns.\n * JIT functions are cached in the entry after first access for performance.\n * @param id - The method id\n * @returns The method metadata with JIT functions or undefined if not found\n */\n getMethodJitFns(id: string): MethodWithOptsAndJitFns | undefined {\n if (id in methodsCache) {\n const cached = methodsCache[id] as any;\n if (cached.paramsJitFns && cached.returnJitFns) {\n return cached as MethodWithOptsAndJitFns;\n }\n }\n\n const metadata = this.getMetadata(id);\n if (!metadata) return undefined;\n\n const paramsJitFns = getJitFunctionsFromHash(metadata.paramsJitHash);\n const returnJitFns = getJitFunctionsFromHash(metadata.returnJitHash);\n const headersParam = metadata.headersParam\n ? {...metadata.headersParam, jitFns: getHeaderJitFunctionsFromHash(metadata.headersParam.jitHash)}\n : undefined;\n const headersReturn = metadata.headersReturn\n ? {...metadata.headersReturn, jitFns: getHeaderJitFunctionsFromHash(metadata.headersReturn.jitHash)}\n : undefined;\n\n const result: MethodWithOptsAndJitFns = {\n ...metadata,\n paramsJitFns,\n returnJitFns,\n headersParam,\n headersReturn,\n };\n\n methodsCache[id] = result;\n return result as MethodWithOptsAndJitFns;\n },\n\n /**\n * Get method metadata with JIT functions restored from the router cache by id.\n * @param id\n * @returns\n */\n useMethodJitFns(id: string): MethodWithOptsAndJitFns {\n const MethodWithOptsAndJitFns = this.getMethodJitFns(id);\n if (!MethodWithOptsAndJitFns) throw new Error(`Metadata for remote method ${id} not found`);\n return MethodWithOptsAndJitFns;\n },\n\n /**\n * Set method metadata with JIT functions in the router cache.\n * This stores the complete MethodWithOptsAndJitFns object directly.\n * @param id - The method id\n * @param MethodWithOptsAndJitFns - The method metadata with JIT functions\n */\n setMethodJitFns(id: string, MethodWithOptsAndJitFns: MethodWithOptsAndJitFns): void {\n methodsCache[id] = MethodWithOptsAndJitFns as any;\n },\n};\n\nexport const methodOptsCache = {\n getMethodOptions(id: string): RemoteMethodOpts | undefined {\n return methodsOptionsCache[id];\n },\n setMethodOptions(id: string, options: RemoteMethodOpts): void {\n methodsOptionsCache[id] = options;\n },\n};\n\n/**\n * Adds new routes to the router cache.\n * This is the public API for registering routes - called by virtual modules or directly.\n * @param newCache\n */\nexport function addRoutesToCache(newCache: MethodsCache) {\n for (const key in newCache) {\n if (!(key in methodsCache)) {\n // Clone the cache entry to avoid mutating the original\n methodsCache[key] = {...newCache[key]} as MethodWithOptions;\n }\n }\n}\n\nexport function getJitFnHashes(jitHash: string, needsBinary: boolean = false): JitFunctionsHashes {\n return {\n isType: `${JIT_FUNCTION_IDS.isType}_${jitHash}`,\n typeErrors: `${JIT_FUNCTION_IDS.typeErrors}_${jitHash}`,\n prepareForJson: `${JIT_FUNCTION_IDS.prepareForJson}_${jitHash}`,\n restoreFromJson: `${JIT_FUNCTION_IDS.restoreFromJson}_${jitHash}`,\n stringifyJson: `${JIT_FUNCTION_IDS.stringifyJson}_${jitHash}`,\n ...(needsBinary\n ? {\n toBinary: `${JIT_FUNCTION_IDS.toBinary}_${jitHash}`,\n fromBinary: `${JIT_FUNCTION_IDS.fromBinary}_${jitHash}`,\n }\n : {}),\n };\n}\n\n/**\n * Helper function to get JIT functions from a JIT hash\n * Returns nullJitFns for empty hash (handlers with no params or void return)\n * Results are cached to avoid creating duplicate objects.\n */\nexport function getJitFunctionsFromHash(jitHash: string): JitCompiledFunctions {\n // Empty hash means no JIT functions were generated (optimization for no params or void return)\n if (jitHash === EMPTY_HASH) return noopJitFns;\n\n // Check cache first\n const cached = jitFunctionsCache.get(jitHash);\n if (cached) return cached;\n\n const jUtils = getJitUtils();\n const jitFns = {\n isType: jUtils.getJIT(`${JIT_FUNCTION_IDS.isType}_${jitHash}`),\n typeErrors: jUtils.getJIT(`${JIT_FUNCTION_IDS.typeErrors}_${jitHash}`),\n prepareForJson: jUtils.getJIT(`${JIT_FUNCTION_IDS.prepareForJson}_${jitHash}`),\n restoreFromJson: jUtils.getJIT(`${JIT_FUNCTION_IDS.restoreFromJson}_${jitHash}`),\n stringifyJson: jUtils.getJIT(`${JIT_FUNCTION_IDS.stringifyJson}_${jitHash}`),\n } as JitCompiledFunctions;\n // Only include binary functions if they exist in the store\n const toBinaryJit = jUtils.getJIT(`${JIT_FUNCTION_IDS.toBinary}_${jitHash}`);\n const fromBinaryJit = jUtils.getJIT(`${JIT_FUNCTION_IDS.fromBinary}_${jitHash}`);\n if (toBinaryJit) jitFns.toBinary = toBinaryJit;\n if (fromBinaryJit) jitFns.fromBinary = fromBinaryJit;\n\n for (const key of ['isType', 'typeErrors', 'prepareForJson', 'restoreFromJson', 'stringifyJson'] as const) {\n if (!jitFns[key]) throw new Error(`Jit function ${key} not found for jitHash ${jitHash}`);\n }\n\n // Cache for future calls\n jitFunctionsCache.set(jitHash, jitFns);\n return jitFns;\n}\n\n/**\n * Helper function to get header JIT functions from a JIT hash\n * Results are cached to avoid creating duplicate objects.\n */\nexport function getHeaderJitFunctionsFromHash(jitHash: string): Pick<JitCompiledFunctions, 'isType' | 'typeErrors'> {\n // Check cache first\n const cached = headerJitFunctionsCache.get(jitHash);\n if (cached) return cached;\n\n const hashes = getJitFnHashes(jitHash);\n const jUtils = getJitUtils();\n const jitFns = {\n isType: jUtils.getJIT(hashes.isType),\n typeErrors: jUtils.getJIT(hashes.typeErrors),\n } as Pick<JitCompiledFunctions, 'isType' | 'typeErrors'>;\n\n // Cache for future calls\n headerJitFunctionsCache.set(jitHash, jitFns);\n return jitFns;\n}\n\n/**\n * Get the router id for Routes or MiddleFns\n * @param itemPointer - The pointer to the item within the Routes object\n * i.e:\n * const routes = {\n * auth: () => {},\n * users: {\n * getUser: () => {}\n * }\n * login: () => {}\n * }\n *\n * then the pointer for getUser is => ['users', 'getUser']\n */\nexport function getRouterItemId(itemPointer: string[]) {\n return itemPointer.join(ROUTER_ITEM_SEPARATOR_CHAR);\n}\n\n/** Gets a route path from a route pointer */\nexport function getRoutePath(pathPointer: string[], routerOptions: CoreRouterOptions) {\n const pathId = getRouterItemId(pathPointer);\n const basePath = routerOptions.basePath.startsWith(ROUTE_PATH_ROOT)\n ? routerOptions.basePath\n : `${ROUTE_PATH_ROOT}${routerOptions.basePath}`;\n const routePath = basePath.endsWith(PATH_SEPARATOR) ? `${basePath}${pathId}` : `${basePath}${PATH_SEPARATOR}${pathId}`;\n return routerOptions.suffix ? routePath + routerOptions.suffix : routePath;\n}\n\nexport function resetRoutesCache() {\n for (const k in methodsCache) delete methodsCache[k];\n}\n\n/** Resets the JIT functions cache. Useful for testing purposes only. */\nexport function resetJitFunctionsCache(): void {\n jitFunctionsCache.clear();\n headerJitFunctionsCache.clear();\n}\n\n// Noop JIT functions used for handlers with no params or void return\n// prettier-ignore\nconst noopJitFns: JitCompiledFunctions = {\n isType: fakeJitFn(JIT_FUNCTION_IDS.isType),\n typeErrors: fakeJitFn(JIT_FUNCTION_IDS.typeErrors),\n prepareForJson: fakeJitFn(JIT_FUNCTION_IDS.prepareForJson),\n restoreFromJson: fakeJitFn(JIT_FUNCTION_IDS.restoreFromJson),\n stringifyJson: fakeJitFn(JIT_FUNCTION_IDS.stringifyJson),\n} as any;\n\n/** Creates a fake JIT function with isNoop=true for handlers with no params or void return */\nfunction fakeJitFn(fnID: string): JitCompiledFn<any> {\n return {\n typeName: 'mionNoopJit',\n fnID,\n jitFnHash: EMPTY_HASH,\n args: {vλl: 'v'},\n defaultParamValues: {vλl: 'v'},\n isNoop: true,\n code: '',\n createJitFn: () => {\n throw new Error('isNoop JIT functions should not be called, this is a function when jit is never used');\n },\n fn: () => {\n throw new Error('isNoop JIT functions should not be called, this is a function when jit is never used');\n },\n };\n}\n\nexport function getNoopJitFns(): JitCompiledFunctions {\n return noopJitFns;\n}\n"],"names":["JIT_FUNCTION_IDS","EMPTY_HASH","getJitUtils","ROUTER_ITEM_SEPARATOR_CHAR","ROUTE_PATH_ROOT","PATH_SEPARATOR"],"mappings":";;;;AAYA,MAAM,eAA6B,CAAA;AACnC,MAAM,sBAAwD,CAAA;AAG9D,MAAM,wCAAwB,IAAA;AAC9B,MAAM,8CAA8B,IAAA;AAM7B,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvB,YAAY,IAA2C;AACnD,WAAO,aAAa,EAAE;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY,IAAY,YAAqC;AACzD,iBAAa,EAAE,IAAI;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY,IAAqB;AAC7B,WAAO,MAAM;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAyB;AACrB,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,gBAAgB,IAAiD;AAC7D,QAAI,MAAM,cAAc;AACpB,YAAM,SAAS,aAAa,EAAE;AAC9B,UAAI,OAAO,gBAAgB,OAAO,cAAc;AAC5C,eAAO;AAAA,MACX;AAAA,IACJ;AAEA,UAAM,WAAW,KAAK,YAAY,EAAE;AACpC,QAAI,CAAC,SAAU,QAAO;AAEtB,UAAM,eAAe,wBAAwB,SAAS,aAAa;AACnE,UAAM,eAAe,wBAAwB,SAAS,aAAa;AACnE,UAAM,eAAe,SAAS,eACxB,EAAC,GAAG,SAAS,cAAc,QAAQ,8BAA8B,SAAS,aAAa,OAAO,MAC9F;AACN,UAAM,gBAAgB,SAAS,gBACzB,EAAC,GAAG,SAAS,eAAe,QAAQ,8BAA8B,SAAS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A,IACR,MAAM;AAAA,IACN,aAAa,MAAM;AACf,YAAM,IAAI,MAAM,sFAAsF;AAAA,IAC1G;AAAA,IACA,IAAI,MAAM;AACN,YAAM,IAAI,MAAM,sFAAsF;AAAA,IAC1G;AAAA,EAAA;AAER;AAEO,SAAS,gBAAsC;AAClD,SAAO;AACX;;;;;;;;;;;;"}
@@ -14,7 +14,7 @@ export declare const methodOptsCache: {
14
14
  setMethodOptions(id: string, options: RemoteMethodOpts): void;
15
15
  };
16
16
  export declare function addRoutesToCache(newCache: MethodsCache): void;
17
- export declare function getJitFnHashes(jitHash: string): JitFunctionsHashes;
17
+ export declare function getJitFnHashes(jitHash: string, needsBinary?: boolean): JitFunctionsHashes;
18
18
  export declare function getJitFunctionsFromHash(jitHash: string): JitCompiledFunctions;
19
19
  export declare function getHeaderJitFunctionsFromHash(jitHash: string): Pick<JitCompiledFunctions, 'isType' | 'typeErrors'>;
20
20
  export declare function getRouterItemId(itemPointer: string[]): string;
@@ -28,7 +28,9 @@ const SerializerModes = {
28
28
  /** Use toBinary JIT function for binary serialization */
29
29
  binary: 2,
30
30
  /** Use stringifyJson JIT function that do not mutates objects. */
31
- stringifyJson: 3
31
+ stringifyJson: 3,
32
+ /** Client-only: sends plain JSON without JIT, fetches metadata in the same response */
33
+ optimistic: 4
32
34
  };
33
35
  const __ΩSerializerMode = [() => SerializerModes, "SerializerMode", 'i!gw"y'];
34
36
  const __ΩSerializerCode = [() => SerializerModes, () => __ΩSerializerMode, "SerializerCode", 'i!n"fw#y'];
@@ -45,12 +47,12 @@ const __ΩSetItemPathSegment = ["key", "index", "SetItemPathSegment", `P#4!'4"Mw
45
47
  const __ΩPathSegment = [() => __ΩStrNumber, () => __ΩMapKeyPathSegment, () => __ΩMapValuePathSegment, () => __ΩSetItemPathSegment, "PathSegment", 'Pn!n"n#n$Jw%y'];
46
48
  const __ΩRunTypeError = [() => __ΩPathSegment, "path", "expected", () => src_types_formats_formats_types.__ΩTypeFormatError, "format", "RunTypeError", 'Pn!F4"&4#n$4%8Mw&y'];
47
49
  const __ΩJitFnArgs = ["vλl", "JitFnArgs", 'P&4!&&LMw"y'];
48
- const __ΩJitCompiledFnData = ["typeName", "fnID", "jitFnHash", () => __ΩJitFnArgs, "args", () => __ΩJitFnArgs, "defaultParamValues", "isNoop", "code", "jitDependencies", "pureFnDependencies", "paramNames", "JitCompiledFnData", `P&4!9&4"9&4#9n$4%9n&4'9)4(89&4)9&F4*9&F4+9&F4,8Mw-y`];
50
+ const __ΩJitCompiledFnData = ["typeName", "fnID", "jitFnHash", () => __ΩJitFnArgs, "args", () => __ΩJitFnArgs, "defaultParamValues", "isNoop", "code", "jitDependencies", "pureFnDependencies", "paramNames", "JitCompiledFnData", `P&4!9&4"9&4#9n$4%9n&4'9)4(89&4)9&F4*89&F4+89&F4,8Mw-y`];
49
51
  const __ΩJitCompiledFn = [() => __ΩAnyFn, "Fn", () => __ΩJitCompiledFnData, "JITUtils", "utl", "", "createJitFn", "fn", "JitCompiledFn", `n!c"Pn#P"w$2%e#!/&4'9e"!4(9Mw)y`];
50
52
  const __ΩPersistedJitFn = [() => __ΩOmit, () => __ΩJitCompiledFn, "fn", "fn", "PersistedJitFn", 'Pn".#o!#-4$9Mw%y'];
51
- const __ΩJitCompiledFunctions = [() => __ΩJitCompiledFn, () => __ΩIsTypeFn, "isType", () => __ΩJitCompiledFn, () => __ΩTypeErrorsFn, "typeErrors", () => __ΩJitCompiledFn, () => __ΩPrepareForJsonFn, "prepareForJson", () => __ΩJitCompiledFn, () => __ΩRestoreFromJsonFn, "restoreFromJson", () => __ΩJitCompiledFn, () => __ΩJsonStringifyFn, "stringifyJson", () => __ΩJitCompiledFn, () => __ΩToBinaryFn, "toBinary", () => __ΩJitCompiledFn, () => __ΩFromBinaryFn, "fromBinary", "JitCompiledFunctions", `Pn"o!"4#n%o$"4&n(o'"4)n+o*"4,n.o-"4/n1o0"42n4o3"45Mw6y`];
52
- const __ΩSerializableJITFunctions = [() => __ΩJitCompiledFnData, "isType", () => __ΩJitCompiledFnData, "typeErrors", () => __ΩJitCompiledFnData, "prepareForJson", () => __ΩJitCompiledFnData, "restoreFromJson", () => __ΩJitCompiledFnData, "stringifyJson", () => __ΩJitCompiledFnData, "toBinary", () => __ΩJitCompiledFnData, "fromBinary", "SerializableJITFunctions", `Pn!4"n#4$n%4&n'4(n)4*n+4,n-4.Mw/y`];
53
- const __ΩJitFunctionsHashes = ["isType", "typeErrors", "prepareForJson", "restoreFromJson", "stringifyJson", "toBinary", "fromBinary", "JitFunctionsHashes", `P&4!&4"&4#&4$&4%&4&&4'Mw(y`];
53
+ const __ΩJitCompiledFunctions = [() => __ΩJitCompiledFn, () => __ΩIsTypeFn, "isType", () => __ΩJitCompiledFn, () => __ΩTypeErrorsFn, "typeErrors", () => __ΩJitCompiledFn, () => __ΩPrepareForJsonFn, "prepareForJson", () => __ΩJitCompiledFn, () => __ΩRestoreFromJsonFn, "restoreFromJson", () => __ΩJitCompiledFn, () => __ΩJsonStringifyFn, "stringifyJson", () => __ΩJitCompiledFn, () => __ΩToBinaryFn, "toBinary", () => __ΩJitCompiledFn, () => __ΩFromBinaryFn, "fromBinary", "JitCompiledFunctions", `Pn"o!"4#n%o$"4&n(o'"4)n+o*"4,n.o-"4/n1o0"428n4o3"458Mw6y`];
54
+ const __ΩSerializableJITFunctions = [() => __ΩJitCompiledFnData, "isType", () => __ΩJitCompiledFnData, "typeErrors", () => __ΩJitCompiledFnData, "prepareForJson", () => __ΩJitCompiledFnData, "restoreFromJson", () => __ΩJitCompiledFnData, "stringifyJson", () => __ΩJitCompiledFnData, "toBinary", () => __ΩJitCompiledFnData, "fromBinary", "SerializableJITFunctions", `Pn!4"n#4$n%4&n'4(n)4*n+4,8n-4.8Mw/y`];
55
+ const __ΩJitFunctionsHashes = ["isType", "typeErrors", "prepareForJson", "restoreFromJson", "stringifyJson", "toBinary", "fromBinary", "JitFunctionsHashes", `P&4!&4"&4#&4$&4%&4&8&4'8Mw(y`];
54
56
  const __ΩJsonStringifyFn = ["value", () => __ΩJSONString, "", "JsonStringifyFn", 'P"2!n"/#w$y'];
55
57
  const __ΩRestoreFromJsonFn = [() => __ΩJSONValue, "value", "", "RestoreFromJsonFn", 'Pn!2""/#w$y'];
56
58
  const __ΩPrepareForJsonFn = ["value", () => __ΩJSONValue, "", "PrepareForJsonFn", 'P"2!n"/#w$y'];
@@ -69,6 +71,10 @@ const __ΩSrcCodeJitCompiledFn = [() => __ΩJitCompiledFnData, "JITUtils", "utl"
69
71
  const __ΩSrcCodeCompiledPureFunction = [() => src_types_pureFunctions_types.__ΩPureFunctionData, "JITUtils", "utl", () => __ΩAnyFn, "", "createPureFn", "fn", "SrcCodeCompiledPureFunction", `Pn!P"w"2#n$/%4&9-4'9Mw(y`];
70
72
  const __ΩSrcCodeJITCompiledFnsCache = [() => __ΩRecord, () => __ΩSrcCodeJitCompiledFn, "SrcCodeJITCompiledFnsCache", '&n"o!#w#y'];
71
73
  const __ΩSrcCodePureFunctionsCache = [() => __ΩRecord, () => __ΩRecord, () => __ΩSrcCodeCompiledPureFunction, "SrcCodePureFunctionsCache", '&&n#o"#o!#w$y'];
74
+ const __ΩClientSrcCodeJitCompiledFn = [() => __ΩOmit, () => __ΩSrcCodeJitCompiledFn, "code", "args", "defaultParamValues", "fnID", "paramNames", "ClientSrcCodeJitCompiledFn", `n"P.#.$.%.&.'Jo!#w(y`];
75
+ const __ΩClientSrcCodeCompiledPureFunction = [() => __ΩOmit, () => __ΩSrcCodeCompiledPureFunction, "code", "paramNames", "ClientSrcCodeCompiledPureFunction", 'n"P.#.$Jo!#w%y'];
76
+ const __ΩClientSrcCodeJITCompiledFnsCache = [() => __ΩRecord, () => __ΩClientSrcCodeJitCompiledFn, "ClientSrcCodeJITCompiledFnsCache", '&n"o!#w#y'];
77
+ const __ΩClientSrcCodePureFunctionsCache = [() => __ΩRecord, () => __ΩRecord, () => __ΩClientSrcCodeCompiledPureFunction, "ClientSrcCodePureFunctionsCache", '&&n#o"#o!#w$y'];
72
78
  const __ΩStrNumber = ["StrNumber", "P&'Jw!y"];
73
79
  const __ΩAnyFn = ["args", "", "AnyFn", 'P"@2!"/"w#y'];
74
80
  const __ΩAnyObject = [() => __ΩRecord, "AnyObject", '&#o!#w"y'];
@@ -92,6 +98,10 @@ exports.__ΩAnyErrorParams = __ΩAnyErrorParams;
92
98
  exports.__ΩAnyFn = __ΩAnyFn;
93
99
  exports.__ΩAnyObject = __ΩAnyObject;
94
100
  exports.__ΩBinaryInput = __ΩBinaryInput;
101
+ exports.__ΩClientSrcCodeCompiledPureFunction = __ΩClientSrcCodeCompiledPureFunction;
102
+ exports.__ΩClientSrcCodeJITCompiledFnsCache = __ΩClientSrcCodeJITCompiledFnsCache;
103
+ exports.__ΩClientSrcCodeJitCompiledFn = __ΩClientSrcCodeJitCompiledFn;
104
+ exports.__ΩClientSrcCodePureFunctionsCache = __ΩClientSrcCodePureFunctionsCache;
95
105
  exports.__ΩCoreRouterOptions = __ΩCoreRouterOptions;
96
106
  exports.__ΩDataOnly = __ΩDataOnly;
97
107
  exports.__ΩDataViewDeserializer = __ΩDataViewDeserializer;