@effing/fn 0.38.4 → 0.39.0

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.
@@ -15,7 +15,11 @@ function imageResponse(bytes, options = {}) {
15
15
  if (!(bytes.buffer instanceof ArrayBuffer)) {
16
16
  throw new TypeError("SharedArrayBuffer is not supported");
17
17
  }
18
- return new Response(bytes.buffer, { status: 200, headers });
18
+ const body = bytes.buffer.slice(
19
+ bytes.byteOffset,
20
+ bytes.byteOffset + bytes.byteLength
21
+ );
22
+ return new Response(body, { status: 200, headers });
19
23
  }
20
24
  function annieResponse(frames, options = {}) {
21
25
  const {
@@ -49,4 +53,4 @@ export {
49
53
  annieResponse,
50
54
  effieResponse
51
55
  };
52
- //# sourceMappingURL=chunk-UHDIQDAF.js.map
56
+ //# sourceMappingURL=chunk-ANDDDI6X.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/responses.ts"],"sourcesContent":["import type { EffieData, EffieSources } from \"@effing/effie\";\nimport { annieStream } from \"@effing/annie\";\nimport type { AnnieStreamOptions } from \"@effing/annie\";\n\nexport type ImageResponseOptions = {\n headers?: HeadersInit;\n cacheControl?: string;\n};\n\nfunction detectImageContentType(bytes: Uint8Array): string {\n if (bytes[0] === 0x89 && bytes[1] === 0x50) return \"image/png\";\n if (bytes[0] === 0xff && bytes[1] === 0xd8) return \"image/jpeg\";\n throw new Error(\"Unsupported image format: expected PNG or JPEG\");\n}\n\nexport function imageResponse(\n bytes: Uint8Array,\n options: ImageResponseOptions = {},\n): Response {\n const { headers: extraHeaders, cacheControl = \"public, max-age=3600\" } =\n options;\n\n const headers = new Headers(extraHeaders);\n headers.set(\"Content-Type\", detectImageContentType(bytes));\n if (cacheControl) {\n headers.set(\"Cache-Control\", cacheControl);\n }\n\n if (!(bytes.buffer instanceof ArrayBuffer)) {\n throw new TypeError(\"SharedArrayBuffer is not supported\");\n }\n\n // Serve only the window `bytes` describes, not its whole backing buffer:\n // `bytes` may be a view (offset/length) into a larger pooled buffer, and\n // serving the backing buffer would corrupt the body and leak adjacent bytes.\n const body = bytes.buffer.slice(\n bytes.byteOffset,\n bytes.byteOffset + bytes.byteLength,\n );\n\n return new Response(body, { status: 200, headers });\n}\n\nexport type AnnieResponseOptions = AnnieStreamOptions & {\n headers?: HeadersInit;\n cacheControl?: string;\n filename?: string;\n};\n\nexport function annieResponse(\n frames: AsyncIterable<Buffer>,\n options: AnnieResponseOptions = {},\n): Response {\n const {\n headers: extraHeaders,\n cacheControl = \"public, max-age=3600\",\n filename,\n ...streamOptions\n } = options;\n\n const stream = annieStream(frames, streamOptions);\n\n const headers = new Headers(extraHeaders);\n headers.set(\"Content-Type\", \"application/x-tar\");\n if (cacheControl) {\n headers.set(\"Cache-Control\", cacheControl);\n }\n if (filename) {\n headers.set(\"Content-Disposition\", `inline; filename=\"${filename}.tar\"`);\n }\n\n return new Response(stream, { status: 200, headers });\n}\n\nexport type EffieResponseOptions = {\n headers?: HeadersInit;\n cacheControl?: string;\n};\n\nexport function effieResponse<S extends EffieSources>(\n data: EffieData<S>,\n options: EffieResponseOptions = {},\n): Response {\n const { headers: extraHeaders, cacheControl = \"public, max-age=3600\" } =\n options;\n\n const headers = new Headers(extraHeaders);\n if (cacheControl) {\n headers.set(\"Cache-Control\", cacheControl);\n }\n\n return Response.json(data, { status: 200, headers });\n}\n"],"mappings":";AACA,SAAS,mBAAmB;AAQ5B,SAAS,uBAAuB,OAA2B;AACzD,MAAI,MAAM,CAAC,MAAM,OAAQ,MAAM,CAAC,MAAM,GAAM,QAAO;AACnD,MAAI,MAAM,CAAC,MAAM,OAAQ,MAAM,CAAC,MAAM,IAAM,QAAO;AACnD,QAAM,IAAI,MAAM,gDAAgD;AAClE;AAEO,SAAS,cACd,OACA,UAAgC,CAAC,GACvB;AACV,QAAM,EAAE,SAAS,cAAc,eAAe,uBAAuB,IACnE;AAEF,QAAM,UAAU,IAAI,QAAQ,YAAY;AACxC,UAAQ,IAAI,gBAAg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duleLoader = null;
@@ -2,7 +2,7 @@ import {
2
2
  annieResponse,
3
3
  effieResponse,
4
4
  imageResponse
5
- } from "../chunk-UHDIQDAF.js";
5
+ } from "../chunk-ANDDDI6X.js";
6
6
 
7
7
  // src/server/segments.ts
8
8
  import { deserialize, serialize } from "@effing/serde";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effing/fn",
3
- "version": "0.38.4",
3
+ "version": "0.39.0",
4
4
  "description": "Effing function runtime — pluggable module loading and URL building",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,9 +22,9 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@effing/annie": "0.38.4",
26
- "@effing/effie": "0.38.4",
27
- "@effing/serde": "0.38.4"
25
+ "@effing/annie": "0.39.0",
26
+ "@effing/effie": "0.39.0",
27
+ "@effing/serde": "0.39.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "tsup": "^8.0.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/responses.ts"],"sourcesContent":["import type { EffieData, EffieSources } from \"@effing/effie\";\nimport { annieStream } from \"@effing/annie\";\nimport type { AnnieStreamOptions } from \"@effing/annie\";\n\nexport type ImageResponseOptions = {\n headers?: HeadersInit;\n cacheControl?: string;\n};\n\nfunction detectImageContentType(bytes: Uint8Array): string {\n if (bytes[0] === 0x89 && bytes[1] === 0x50) return \"image/png\";\n if (bytes[0] === 0xff && bytes[1] === 0xd8) return \"image/jpeg\";\n throw new Error(\"Unsupported image format: expected PNG or JPEG\");\n}\n\nexport function imageResponse(\n bytes: Uint8Array,\n options: ImageResponseOptions = {},\n): Response {\n const { headers: extraHeaders, cacheControl = \"public, max-age=3600\" } =\n options;\n\n const headers = new Headers(extraHeaders);\n headers.set(\"Content-Type\", detectImageContentType(bytes));\n if (cacheControl) {\n headers.set(\"Cache-Control\", cacheControl);\n }\n\n if (!(bytes.buffer instanceof ArrayBuffer)) {\n throw new TypeError(\"SharedArrayBuffer is not supported\");\n }\n\n return new Response(bytes.buffer, { status: 200, headers });\n}\n\nexport type AnnieResponseOptions = AnnieStreamOptions & {\n headers?: HeadersInit;\n cacheControl?: string;\n filename?: string;\n};\n\nexport function annieResponse(\n frames: AsyncIterable<Buffer>,\n options: AnnieResponseOptions = {},\n): Response {\n const {\n headers: extraHeaders,\n cacheControl = \"public, max-age=3600\",\n filename,\n ...streamOptions\n } = options;\n\n const stream = annieStream(frames, streamOptions);\n\n const headers = new Headers(extraHeaders);\n headers.set(\"Content-Type\", \"application/x-tar\");\n if (cacheControl) {\n headers.set(\"Cache-Control\", cacheControl);\n }\n if (filename) {\n headers.set(\"Content-Disposition\", `inline; filename=\"${filename}.tar\"`);\n }\n\n return new Response(stream, { status: 200, headers });\n}\n\nexport type EffieResponseOptions = {\n headers?: HeadersInit;\n cacheControl?: string;\n};\n\nexport function effieResponse<S extends EffieSources>(\n data: EffieData<S>,\n options: EffieResponseOptions = {},\n): Response {\n const { headers: extraHeaders, cacheControl = \"public, max-age=3600\" } =\n options;\n\n const headers = new Headers(extraHeaders);\n if (cacheControl) {\n headers.set(\"Cache-Control\", cacheControl);\n }\n\n return Response.json(data, { status: 200, headers });\n}\n"],"mappings":";AACA,SAAS,mBAAmB;AAQ5B,SAAS,uBAAuB,OAA2B;AACzD,MAAI,MAAM,CAAC,MAAM,OAAQ,MAAM,CAAC,MAAM,GAAM,QAAO;AACnD,MAAI,MAAM,CAAC,MAAM,OAAQ,MAAM,CAAC,MAAM,IAAM,QAAO;AACnD,QAAM,IAAI,MAAM,gDAAgD;AAClE;AAEO,SAAS,cACd,OACA,UAAgC,CAAC,GACvB;AACV,QAAM,EAAE,SAAS,cAAc,eAAe,uBAAuB,IACnE;AAEF,QAAM,UAAU,IAAI,QAAQ,YAAY;AACxC,UAAQ,IAAI,gBAAgB,uBAAuB,KAAK,CAAC;AACzD,MAAI,cAAc;AAChB,YAAQ,IAAI,iBAAiB,YAAY;AAAA,EAC3C;AAEA,MAAI,EAAE,MAA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