Files
SnowLuma/.pnpm-store/v11/files/ac/c5602c32998c6e4b7cfa5ea63d12160c2103edf288e6af1a9c59e571430bb9ebe7eab4ff07e7aefb467d6ba909a235700193e9a50eecfb28e24880e0ffa05c
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

1 line
1.6 KiB
Plaintext

{"version":3,"file":"ShallowErrorPlugin.js","names":[],"sources":["../../../../src/ssr/serializer/ShallowErrorPlugin.ts"],"sourcesContent":["import { createPlugin } from 'seroval'\nimport type { PluginInfo, SerovalNode } from 'seroval'\n\nexport interface ErrorNode extends PluginInfo {\n message: SerovalNode\n}\n\n/**\n * this plugin serializes only the `message` part of an Error\n * this helps with serializing e.g. a ZodError which has functions attached that cannot be serialized\n */\nexport const ShallowErrorPlugin = /* @__PURE__ */ createPlugin<\n Error,\n ErrorNode\n>({\n tag: '$TSR/Error',\n test(value) {\n return value instanceof Error\n },\n parse: {\n sync(value, ctx) {\n return {\n message: ctx.parse(value.message),\n }\n },\n async async(value, ctx) {\n return {\n message: await ctx.parse(value.message),\n }\n },\n stream(value, ctx) {\n return {\n message: ctx.parse(value.message),\n }\n },\n },\n serialize(node, ctx) {\n return 'new Error(' + ctx.serialize(node.message) + ')'\n },\n deserialize(node, ctx) {\n return new Error(ctx.deserialize(node.message))\n },\n})\n"],"mappings":";;;;;;AAWA,MAAa,qBAAqC,6BAGhD;CACA,KAAK;CACL,KAAK,OAAO;AACV,SAAO,iBAAiB;;CAE1B,OAAO;EACL,KAAK,OAAO,KAAK;AACf,UAAO,EACL,SAAS,IAAI,MAAM,MAAM,QAAQ,EAClC;;EAEH,MAAM,MAAM,OAAO,KAAK;AACtB,UAAO,EACL,SAAS,MAAM,IAAI,MAAM,MAAM,QAAQ,EACxC;;EAEH,OAAO,OAAO,KAAK;AACjB,UAAO,EACL,SAAS,IAAI,MAAM,MAAM,QAAQ,EAClC;;EAEJ;CACD,UAAU,MAAM,KAAK;AACnB,SAAO,eAAe,IAAI,UAAU,KAAK,QAAQ,GAAG;;CAEtD,YAAY,MAAM,KAAK;AACrB,SAAO,IAAI,MAAM,IAAI,YAAY,KAAK,QAAQ,CAAC;;CAElD,CAAC"}