gemi 0.42.1 → 0.43.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.
Files changed (149) hide show
  1. package/dist/app/index.js +1 -1
  2. package/dist/bin/gemi.js +392 -70
  3. package/dist/bin/gemi.js.map +15 -12
  4. package/dist/broadcasting/index.js +1 -1
  5. package/dist/bun/plugin.js +1 -1
  6. package/dist/bun/preload.js +1 -1
  7. package/dist/{chunk-522q81af.js → chunk-20376aj6.js} +3 -3
  8. package/dist/{chunk-522q81af.js.map → chunk-20376aj6.js.map} +1 -1
  9. package/dist/{chunk-wa84ybnt.js → chunk-25d4feyv.js} +22 -22
  10. package/dist/{chunk-wa84ybnt.js.map → chunk-25d4feyv.js.map} +8 -6
  11. package/dist/{chunk-qyn10pv7.js → chunk-32ct42e2.js} +1 -1
  12. package/dist/{chunk-cx38xsyf.js → chunk-3xqyzegw.js} +2 -2
  13. package/dist/{chunk-cx38xsyf.js.map → chunk-3xqyzegw.js.map} +1 -1
  14. package/dist/{chunk-358x9aca.js → chunk-5kx4hw7c.js} +2 -2
  15. package/dist/{chunk-358x9aca.js.map → chunk-5kx4hw7c.js.map} +1 -1
  16. package/dist/{chunk-cwq1vdcb.js → chunk-6gtmkbh0.js} +2 -2
  17. package/dist/{chunk-cwq1vdcb.js.map → chunk-6gtmkbh0.js.map} +1 -1
  18. package/dist/{chunk-z9vdcpqr.js → chunk-87keq057.js} +2 -2
  19. package/dist/{chunk-z9vdcpqr.js.map → chunk-87keq057.js.map} +1 -1
  20. package/dist/{chunk-ayjtdck4.js → chunk-8b461343.js} +2 -2
  21. package/dist/{chunk-ayjtdck4.js.map → chunk-8b461343.js.map} +1 -1
  22. package/dist/{chunk-0pjn1a5d.js → chunk-9cw39se2.js} +2 -2
  23. package/dist/{chunk-0pjn1a5d.js.map → chunk-9cw39se2.js.map} +1 -1
  24. package/dist/{chunk-b3qebxqh.js → chunk-9r2k5ykk.js} +2 -2
  25. package/dist/{chunk-b3qebxqh.js.map → chunk-9r2k5ykk.js.map} +1 -1
  26. package/dist/{chunk-8cqkdzyh.js → chunk-9s3te5pa.js} +3 -3
  27. package/dist/{chunk-8cqkdzyh.js.map → chunk-9s3te5pa.js.map} +1 -1
  28. package/dist/{chunk-9byxbqnn.js → chunk-bsfbba90.js} +2 -2
  29. package/dist/{chunk-9byxbqnn.js.map → chunk-bsfbba90.js.map} +1 -1
  30. package/dist/{chunk-8mgsjrcc.js → chunk-cbvq4keh.js} +2 -2
  31. package/dist/{chunk-8mgsjrcc.js.map → chunk-cbvq4keh.js.map} +1 -1
  32. package/dist/{chunk-xpk460d1.js → chunk-drbqadx7.js} +1 -1
  33. package/dist/{chunk-akbepc3f.js → chunk-errq965d.js} +3 -3
  34. package/dist/{chunk-akbepc3f.js.map → chunk-errq965d.js.map} +1 -1
  35. package/dist/chunk-fk9xtngd.js +4 -0
  36. package/dist/chunk-fk9xtngd.js.map +33 -0
  37. package/dist/{chunk-ratbccpg.js → chunk-fvtfwssb.js} +2 -2
  38. package/dist/{chunk-ratbccpg.js.map → chunk-fvtfwssb.js.map} +1 -1
  39. package/dist/{chunk-shpca068.js → chunk-gv4v6qsg.js} +2 -2
  40. package/dist/{chunk-shpca068.js.map → chunk-gv4v6qsg.js.map} +1 -1
  41. package/dist/chunk-h4rd3cwd.js +6 -0
  42. package/dist/{chunk-pn30zsrt.js.map → chunk-h4rd3cwd.js.map} +2 -2
  43. package/dist/{chunk-pygcsw1f.js → chunk-h509r9s3.js} +2 -2
  44. package/dist/{chunk-pygcsw1f.js.map → chunk-h509r9s3.js.map} +1 -1
  45. package/dist/{chunk-fb78bz10.js → chunk-j3x1fffh.js} +1 -1
  46. package/dist/{chunk-pfaq2mer.js → chunk-jvcbdxtq.js} +2 -2
  47. package/dist/{chunk-pfaq2mer.js.map → chunk-jvcbdxtq.js.map} +1 -1
  48. package/dist/{chunk-1kmbs8cd.js → chunk-kkdtznm5.js} +2 -2
  49. package/dist/{chunk-1kmbs8cd.js.map → chunk-kkdtznm5.js.map} +1 -1
  50. package/dist/{chunk-qeq8hv3t.js → chunk-knrx23te.js} +2 -2
  51. package/dist/{chunk-qeq8hv3t.js.map → chunk-knrx23te.js.map} +1 -1
  52. package/dist/{chunk-gsvzrj5r.js → chunk-m359awjw.js} +2 -2
  53. package/dist/{chunk-gsvzrj5r.js.map → chunk-m359awjw.js.map} +1 -1
  54. package/dist/{chunk-rrwtgt86.js → chunk-mfwbdztp.js} +2 -2
  55. package/dist/{chunk-rrwtgt86.js.map → chunk-mfwbdztp.js.map} +1 -1
  56. package/dist/{chunk-syaxsp9y.js → chunk-ngnrytfh.js} +2 -2
  57. package/dist/{chunk-syaxsp9y.js.map → chunk-ngnrytfh.js.map} +1 -1
  58. package/dist/{chunk-pr3pvtmh.js → chunk-nhyc69tx.js} +2 -2
  59. package/dist/{chunk-pr3pvtmh.js.map → chunk-nhyc69tx.js.map} +1 -1
  60. package/dist/{chunk-pxcv9ccp.js → chunk-nx8t65g3.js} +2 -2
  61. package/dist/{chunk-pxcv9ccp.js.map → chunk-nx8t65g3.js.map} +1 -1
  62. package/dist/chunk-q8haepmm.js +79 -0
  63. package/dist/{chunk-pjgfvdr6.js.map → chunk-q8haepmm.js.map} +5 -5
  64. package/dist/{chunk-hzw2y2rz.js → chunk-qy3aczt9.js} +2 -2
  65. package/dist/{chunk-hzw2y2rz.js.map → chunk-qy3aczt9.js.map} +1 -1
  66. package/dist/{chunk-zaa3yt2w.js → chunk-s49529x2.js} +2 -2
  67. package/dist/{chunk-zaa3yt2w.js.map → chunk-s49529x2.js.map} +1 -1
  68. package/dist/{chunk-qzemjynx.js → chunk-sdj112nj.js} +2 -2
  69. package/dist/{chunk-qzemjynx.js.map → chunk-sdj112nj.js.map} +1 -1
  70. package/dist/{chunk-bfnh3gwv.js → chunk-sdx8r2qb.js} +2 -2
  71. package/dist/{chunk-bfnh3gwv.js.map → chunk-sdx8r2qb.js.map} +1 -1
  72. package/dist/chunk-tatd75jn.js +5 -0
  73. package/dist/{chunk-tb8yy4rf.js.map → chunk-tatd75jn.js.map} +1 -1
  74. package/dist/{chunk-sbmg0hfr.js → chunk-ty3q916e.js} +3 -3
  75. package/dist/{chunk-sbmg0hfr.js.map → chunk-ty3q916e.js.map} +1 -1
  76. package/dist/{chunk-22pr1w8v.js → chunk-w7czqgx2.js} +2 -2
  77. package/dist/{chunk-22pr1w8v.js.map → chunk-w7czqgx2.js.map} +1 -1
  78. package/dist/chunk-whj1a3vr.js +5 -0
  79. package/dist/chunk-whj1a3vr.js.map +15 -0
  80. package/dist/{chunk-n78kxce1.js → chunk-wrp2v923.js} +2 -2
  81. package/dist/{chunk-n78kxce1.js.map → chunk-wrp2v923.js.map} +1 -1
  82. package/dist/{chunk-x3vy6dbw.js → chunk-x2cq1qp8.js} +2 -2
  83. package/dist/{chunk-x3vy6dbw.js.map → chunk-x2cq1qp8.js.map} +1 -1
  84. package/dist/{chunk-nccmdkf1.js → chunk-yrtvjmrj.js} +1 -1
  85. package/dist/{chunk-q0y425d3.js → chunk-ytr22fm4.js} +2 -2
  86. package/dist/{chunk-q0y425d3.js.map → chunk-ytr22fm4.js.map} +1 -1
  87. package/dist/{chunk-81yxskss.js → chunk-ywhazhqt.js} +2 -2
  88. package/dist/{chunk-81yxskss.js.map → chunk-ywhazhqt.js.map} +1 -1
  89. package/dist/config/index.js +1 -1
  90. package/dist/email/Email.d.ts.map +1 -1
  91. package/dist/email/index.js +3 -2
  92. package/dist/email/index.js.map +15 -4
  93. package/dist/facades/FileStorage.d.ts +14 -1
  94. package/dist/facades/FileStorage.d.ts.map +1 -1
  95. package/dist/facades/index.js +2 -2
  96. package/dist/facades/index.js.map +1 -1
  97. package/dist/http/ApiRouter.d.ts +41 -1
  98. package/dist/http/ApiRouter.d.ts.map +1 -1
  99. package/dist/http/HttpRequest.d.ts +7 -0
  100. package/dist/http/HttpRequest.d.ts.map +1 -1
  101. package/dist/http/ViewRouter.d.ts.map +1 -1
  102. package/dist/http/contentDisposition.d.ts +9 -0
  103. package/dist/http/contentDisposition.d.ts.map +1 -0
  104. package/dist/http/createStreamResponse.d.ts +38 -0
  105. package/dist/http/createStreamResponse.d.ts.map +1 -0
  106. package/dist/http/errors.d.ts +16 -0
  107. package/dist/http/errors.d.ts.map +1 -1
  108. package/dist/http/index.d.ts +3 -1
  109. package/dist/http/index.d.ts.map +1 -1
  110. package/dist/http/index.js +2 -2
  111. package/dist/http/index.js.map +1 -1
  112. package/dist/http/range.d.ts +63 -0
  113. package/dist/http/range.d.ts.map +1 -0
  114. package/dist/http/requestContext.d.ts +11 -0
  115. package/dist/http/requestContext.d.ts.map +1 -1
  116. package/dist/i18n/index.js +1 -1
  117. package/dist/kernel/index.js +2 -2
  118. package/dist/kernel/index.js.map +1 -1
  119. package/dist/server/index.js +2 -2
  120. package/dist/server/index.js.map +1 -1
  121. package/dist/services/file-storage/drivers/AzureBlobDriver.d.ts +78 -0
  122. package/dist/services/file-storage/drivers/AzureBlobDriver.d.ts.map +1 -0
  123. package/dist/services/file-storage/drivers/FileStorageDriver.d.ts +17 -1
  124. package/dist/services/file-storage/drivers/FileStorageDriver.d.ts.map +1 -1
  125. package/dist/services/file-storage/drivers/FileSystemDriver.d.ts +3 -1
  126. package/dist/services/file-storage/drivers/FileSystemDriver.d.ts.map +1 -1
  127. package/dist/services/file-storage/drivers/S3Driver.d.ts +3 -1
  128. package/dist/services/file-storage/drivers/S3Driver.d.ts.map +1 -1
  129. package/dist/services/file-storage/drivers/types.d.ts +45 -0
  130. package/dist/services/file-storage/drivers/types.d.ts.map +1 -1
  131. package/dist/services/index.d.ts +4 -1
  132. package/dist/services/index.d.ts.map +1 -1
  133. package/dist/services/index.js +2 -2
  134. package/dist/services/index.js.map +1 -1
  135. package/dist/services/router/ApiRouterServiceContainer.d.ts +5 -0
  136. package/dist/services/router/ApiRouterServiceContainer.d.ts.map +1 -1
  137. package/dist/services/router/createFlatApiRoutes.d.ts.map +1 -1
  138. package/package.json +7 -1
  139. package/dist/chunk-n1xpxhm0.js +0 -5
  140. package/dist/chunk-n1xpxhm0.js.map +0 -13
  141. package/dist/chunk-pjgfvdr6.js +0 -79
  142. package/dist/chunk-pn30zsrt.js +0 -6
  143. package/dist/chunk-tb8yy4rf.js +0 -5
  144. package/dist/chunk-yeqwzeq7.js +0 -4
  145. package/dist/chunk-yeqwzeq7.js.map +0 -32
  146. /package/dist/{chunk-qyn10pv7.js.map → chunk-32ct42e2.js.map} +0 -0
  147. /package/dist/{chunk-xpk460d1.js.map → chunk-drbqadx7.js.map} +0 -0
  148. /package/dist/{chunk-fb78bz10.js.map → chunk-j3x1fffh.js.map} +0 -0
  149. /package/dist/{chunk-nccmdkf1.js.map → chunk-yrtvjmrj.js.map} +0 -0
package/dist/app/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{o as a,p as b}from"../chunk-gsvzrj5r.js";import"../chunk-pjgfvdr6.js";import"../chunk-yeqwzeq7.js";import"../chunk-sbmg0hfr.js";import"../chunk-b3qebxqh.js";import"../chunk-n1xpxhm0.js";import"../chunk-bfnh3gwv.js";import"../chunk-cwq1vdcb.js";export{b as prismaExtension,a as App};
2
+ import{o as a,p as b}from"../chunk-m359awjw.js";import"../chunk-q8haepmm.js";import"../chunk-fk9xtngd.js";import"../chunk-ty3q916e.js";import"../chunk-9r2k5ykk.js";import"../chunk-whj1a3vr.js";import"../chunk-sdx8r2qb.js";import"../chunk-6gtmkbh0.js";export{b as prismaExtension,a as App};
3
3
 
4
4
  //# debugId=15EBDBCE0B2D702364756E2164756E21
package/dist/bin/gemi.js CHANGED
@@ -14098,7 +14098,7 @@ var require_util = __commonJS((exports) => {
14098
14098
  return url;
14099
14099
  }
14100
14100
  exports.urlGenerate = urlGenerate;
14101
- function normalize(aPath) {
14101
+ function normalize2(aPath) {
14102
14102
  var path2 = aPath;
14103
14103
  var url = urlParse(aPath);
14104
14104
  if (url) {
@@ -14135,7 +14135,7 @@ var require_util = __commonJS((exports) => {
14135
14135
  }
14136
14136
  return path2;
14137
14137
  }
14138
- exports.normalize = normalize;
14138
+ exports.normalize = normalize2;
14139
14139
  function join2(aRoot, aPath) {
14140
14140
  if (aRoot === "") {
14141
14141
  aRoot = ".";
@@ -14161,7 +14161,7 @@ var require_util = __commonJS((exports) => {
14161
14161
  aRootUrl.host = aPath;
14162
14162
  return urlGenerate(aRootUrl);
14163
14163
  }
14164
- var joined = aPath.charAt(0) === "/" ? aPath : normalize(aRoot.replace(/\/+$/, "") + "/" + aPath);
14164
+ var joined = aPath.charAt(0) === "/" ? aPath : normalize2(aRoot.replace(/\/+$/, "") + "/" + aPath);
14165
14165
  if (aRootUrl) {
14166
14166
  aRootUrl.path = joined;
14167
14167
  return urlGenerate(aRootUrl);
@@ -14343,7 +14343,7 @@ var require_util = __commonJS((exports) => {
14343
14343
  }
14344
14344
  sourceURL = join2(urlGenerate(parsed), sourceURL);
14345
14345
  }
14346
- return normalize(sourceURL);
14346
+ return normalize2(sourceURL);
14347
14347
  }
14348
14348
  exports.computeSourceURL = computeSourceURL;
14349
14349
  });
@@ -22105,7 +22105,7 @@ var require_options = __commonJS((exports) => {
22105
22105
  tokens: true
22106
22106
  };
22107
22107
  var hasOwn = defaults.hasOwnProperty;
22108
- function normalize(opts) {
22108
+ function normalize2(opts) {
22109
22109
  var options = opts || defaults;
22110
22110
  function get(key) {
22111
22111
  return hasOwn.call(options, key) ? options[key] : defaults[key];
@@ -22132,7 +22132,7 @@ var require_options = __commonJS((exports) => {
22132
22132
  tokens: !!get("tokens")
22133
22133
  };
22134
22134
  }
22135
- exports.normalize = normalize;
22135
+ exports.normalize = normalize2;
22136
22136
  });
22137
22137
 
22138
22138
  // ../../node_modules/.bun/recast@0.23.11/node_modules/recast/lib/mapping.js
@@ -49979,6 +49979,85 @@ class Controller {
49979
49979
  constructor() {}
49980
49980
  }
49981
49981
 
49982
+ // http/range.ts
49983
+ function parseInteger(raw) {
49984
+ if (!/^\d+$/.test(raw)) {
49985
+ return null;
49986
+ }
49987
+ const value = Number(raw);
49988
+ return Number.isSafeInteger(value) ? value : null;
49989
+ }
49990
+ function parseRangeHeader(header) {
49991
+ if (!header) {
49992
+ return null;
49993
+ }
49994
+ const trimmed = header.trim();
49995
+ if (!/^bytes=/i.test(trimmed)) {
49996
+ return null;
49997
+ }
49998
+ const specs = trimmed.slice("bytes=".length).split(",").map((spec2) => spec2.trim());
49999
+ const present = specs.filter((spec2) => spec2 !== "");
50000
+ if (present.length !== 1) {
50001
+ return null;
50002
+ }
50003
+ const spec = present[0];
50004
+ const separator = spec.indexOf("-");
50005
+ if (separator === -1) {
50006
+ return null;
50007
+ }
50008
+ const rawStart = spec.slice(0, separator);
50009
+ const rawEnd = spec.slice(separator + 1);
50010
+ if (rawStart === "") {
50011
+ const suffixLength = parseInteger(rawEnd);
50012
+ if (suffixLength === null) {
50013
+ return null;
50014
+ }
50015
+ return { kind: "suffix", suffixLength };
50016
+ }
50017
+ const start = parseInteger(rawStart);
50018
+ if (start === null) {
50019
+ return null;
50020
+ }
50021
+ if (rawEnd === "") {
50022
+ return { kind: "offset", start, end: null };
50023
+ }
50024
+ const end = parseInteger(rawEnd);
50025
+ if (end === null || end < start) {
50026
+ return null;
50027
+ }
50028
+ return { kind: "offset", start, end };
50029
+ }
50030
+ function resolveRange(range, total) {
50031
+ if (!Number.isFinite(total) || total <= 0) {
50032
+ return null;
50033
+ }
50034
+ let start;
50035
+ let end;
50036
+ if (range.kind === "suffix") {
50037
+ if (range.suffixLength <= 0) {
50038
+ return null;
50039
+ }
50040
+ start = Math.max(0, total - range.suffixLength);
50041
+ end = total - 1;
50042
+ } else {
50043
+ if (range.start >= total) {
50044
+ return null;
50045
+ }
50046
+ start = range.start;
50047
+ end = range.end === null ? total - 1 : Math.min(range.end, total - 1);
50048
+ if (end < start) {
50049
+ return null;
50050
+ }
50051
+ }
50052
+ return { start, end, length: end - start + 1 };
50053
+ }
50054
+ function formatContentRange(start, end, total) {
50055
+ return `bytes ${start}-${end}/${total}`;
50056
+ }
50057
+ function formatUnsatisfiedContentRange(total) {
50058
+ return `bytes */${total}`;
50059
+ }
50060
+
49982
50061
  // http/requestContext.ts
49983
50062
  import { AsyncLocalStorage } from "async_hooks";
49984
50063
 
@@ -50065,6 +50144,7 @@ class Store {
50065
50144
  csrfHmac = null;
50066
50145
  locale = null;
50067
50146
  metadata = new Metadata;
50147
+ rangeRequest = null;
50068
50148
  constructor(req) {
50069
50149
  this.req = req;
50070
50150
  }
@@ -50325,6 +50405,9 @@ class HttpRequest {
50325
50405
  ctx() {
50326
50406
  return RequestContext.getStore();
50327
50407
  }
50408
+ range() {
50409
+ return parseRangeHeader(this.rawRequest.headers.get("Range"));
50410
+ }
50328
50411
  refine(_input) {
50329
50412
  return {};
50330
50413
  }
@@ -50428,6 +50511,214 @@ function isConstructor(value) {
50428
50511
  return typeof value === "function" && value.prototype !== undefined;
50429
50512
  }
50430
50513
 
50514
+ // http/contentDisposition.ts
50515
+ function contentDisposition(name, download) {
50516
+ const kind = download ? "attachment" : "inline";
50517
+ const fallback = name.replace(/["\\]/g, "").replace(/[^\x20-\x7e]/g, "_");
50518
+ return `${kind}; filename="${fallback}"; filename*=UTF-8''${encodeURIComponent(name)}`;
50519
+ }
50520
+
50521
+ // http/createStreamResponse.ts
50522
+ function isReadResult(output) {
50523
+ return "total" in output && "partial" in output && "body" in output;
50524
+ }
50525
+ function createUnsatisfiableResponse(total) {
50526
+ return new Response(null, {
50527
+ status: 416,
50528
+ headers: {
50529
+ "Accept-Ranges": "bytes",
50530
+ "Content-Range": formatUnsatisfiedContentRange(total),
50531
+ "Content-Length": "0",
50532
+ "Cache-Control": "no-store"
50533
+ }
50534
+ });
50535
+ }
50536
+ async function normalize(output) {
50537
+ if (output instanceof Blob) {
50538
+ return {
50539
+ body: output,
50540
+ start: 0,
50541
+ end: output.size - 1,
50542
+ total: output.size,
50543
+ partial: false,
50544
+ type: output.type,
50545
+ name: output.name,
50546
+ download: false,
50547
+ status: 200,
50548
+ extraHeaders: {}
50549
+ };
50550
+ }
50551
+ if (isReadResult(output)) {
50552
+ return {
50553
+ body: output.body,
50554
+ start: output.start,
50555
+ end: output.end,
50556
+ total: output.total,
50557
+ partial: output.partial,
50558
+ type: output.type,
50559
+ name: output.name,
50560
+ download: false,
50561
+ etag: output.etag,
50562
+ lastModified: output.lastModified,
50563
+ status: 200,
50564
+ extraHeaders: {}
50565
+ };
50566
+ }
50567
+ const body = output.file;
50568
+ const blob = body instanceof Blob ? body : null;
50569
+ const total = output.total ?? blob?.size ?? -1;
50570
+ return {
50571
+ body,
50572
+ start: output.start ?? 0,
50573
+ end: output.end ?? total - 1,
50574
+ total,
50575
+ partial: output.partial ?? false,
50576
+ type: output.type ?? blob?.type ?? "",
50577
+ name: output.name ?? body?.name,
50578
+ download: output.download ?? false,
50579
+ etag: output.etag,
50580
+ lastModified: output.lastModified,
50581
+ status: output.status ?? 200,
50582
+ extraHeaders: output.headers ?? {}
50583
+ };
50584
+ }
50585
+ async function createStreamResponse(output, options) {
50586
+ if (output instanceof Response) {
50587
+ return output;
50588
+ }
50589
+ if (!output) {
50590
+ return new Response("Not found", { status: 404 });
50591
+ }
50592
+ const normalized = await normalize(output);
50593
+ let { body, start, end, total, partial } = normalized;
50594
+ if (body instanceof Blob && "exists" in body && typeof body.exists === "function") {
50595
+ if (!await body.exists()) {
50596
+ return new Response("Not found", { status: 404 });
50597
+ }
50598
+ }
50599
+ const { range } = options;
50600
+ if (range) {
50601
+ if (total <= 0) {
50602
+ return createUnsatisfiableResponse(Math.max(total, 0));
50603
+ }
50604
+ if (!partial) {
50605
+ if (body instanceof Blob) {
50606
+ const resolved = resolveRange(range, total);
50607
+ if (!resolved) {
50608
+ return createUnsatisfiableResponse(total);
50609
+ }
50610
+ body = body.slice(resolved.start, resolved.end + 1);
50611
+ start = resolved.start;
50612
+ end = resolved.end;
50613
+ partial = true;
50614
+ }
50615
+ }
50616
+ }
50617
+ const isPartial = Boolean(range) && partial;
50618
+ const status = isPartial ? 206 : normalized.status;
50619
+ const headers = new Headers;
50620
+ headers.set("Accept-Ranges", "bytes");
50621
+ headers.set("Content-Type", normalized.type || "application/octet-stream");
50622
+ if (isPartial) {
50623
+ headers.set("Content-Range", formatContentRange(start, end, total));
50624
+ headers.set("Content-Length", String(end - start + 1));
50625
+ } else if (total >= 0) {
50626
+ headers.set("Content-Length", String(total));
50627
+ }
50628
+ if (normalized.name) {
50629
+ headers.set("Content-Disposition", contentDisposition(normalized.name, normalized.download));
50630
+ }
50631
+ if (normalized.etag) {
50632
+ headers.set("ETag", normalized.etag);
50633
+ }
50634
+ if (normalized.lastModified) {
50635
+ headers.set("Last-Modified", normalized.lastModified.toUTCString());
50636
+ }
50637
+ for (const [key, value] of Object.entries(normalized.extraHeaders)) {
50638
+ headers.set(key, value);
50639
+ }
50640
+ if ((options.method ?? "GET").toUpperCase() === "HEAD") {
50641
+ if (body && "cancel" in body && typeof body.cancel === "function") {
50642
+ await body.cancel();
50643
+ }
50644
+ return new Response(null, { status, headers });
50645
+ }
50646
+ return new Response(body, { status, headers });
50647
+ }
50648
+
50649
+ // http/errors.ts
50650
+ class AuthorizationError extends RequestBreakerError {
50651
+ error;
50652
+ constructor(error = "Not authorized") {
50653
+ super("Authentication error");
50654
+ this.name = "AuthenticationError";
50655
+ this.error = error;
50656
+ this.payload = {
50657
+ api: {
50658
+ status: 401,
50659
+ data: { error: this.error }
50660
+ },
50661
+ view: {}
50662
+ };
50663
+ }
50664
+ }
50665
+
50666
+ class InsufficientPermissionsError extends RequestBreakerError {
50667
+ error;
50668
+ constructor(error = "Insufficient permissions") {
50669
+ super("Authentication error");
50670
+ this.name = "AuthenticationError";
50671
+ this.error = error;
50672
+ this.payload = {
50673
+ api: {
50674
+ status: 401,
50675
+ data: { error: this.error }
50676
+ },
50677
+ view: {}
50678
+ };
50679
+ }
50680
+ }
50681
+
50682
+ class RangeNotSatisfiableError extends RequestBreakerError {
50683
+ total;
50684
+ constructor(total) {
50685
+ super("Range not satisfiable");
50686
+ this.total = total;
50687
+ this.name = "RangeNotSatisfiableError";
50688
+ this.payload = {
50689
+ api: {
50690
+ status: 416,
50691
+ data: { error: { message: "Range not satisfiable" } },
50692
+ headers: {
50693
+ "Content-Range": formatUnsatisfiedContentRange(total),
50694
+ "Accept-Ranges": "bytes",
50695
+ "Cache-Control": "no-store"
50696
+ }
50697
+ },
50698
+ view: {}
50699
+ };
50700
+ }
50701
+ }
50702
+ class AuthenticationError extends RequestBreakerError {
50703
+ constructor() {
50704
+ super("Authentication error");
50705
+ this.name = "AuthenticationError";
50706
+ }
50707
+ payload = {
50708
+ api: {
50709
+ status: 401,
50710
+ data: { error: "Authentication error" }
50711
+ },
50712
+ view: {
50713
+ status: 302,
50714
+ headers: {
50715
+ "Cache-Control": "private, no-cache, no-store, max-age=0, must-revalidate",
50716
+ Location: "/auth/sign-in"
50717
+ }
50718
+ }
50719
+ };
50720
+ }
50721
+
50431
50722
  // http/ApiRouter.ts
50432
50723
  function isController(candidate) {
50433
50724
  return isConstructor(candidate);
@@ -50494,6 +50785,40 @@ class FileHandler {
50494
50785
  }
50495
50786
  }
50496
50787
 
50788
+ class StreamRouteHandler extends RouteHandler {
50789
+ __internal_brand = "StreamHandler";
50790
+ async run(_req) {
50791
+ const ctx = RequestContext.getStore();
50792
+ const rawRequest = ctx?.req?.rawRequest;
50793
+ const range = parseRangeHeader(rawRequest?.headers.get("Range"));
50794
+ if (ctx) {
50795
+ ctx.rangeRequest = range;
50796
+ }
50797
+ try {
50798
+ const output = await super.run(_req);
50799
+ return await createStreamResponse(output, {
50800
+ range,
50801
+ method: rawRequest?.method
50802
+ });
50803
+ } catch (err) {
50804
+ if (err instanceof RangeNotSatisfiableError) {
50805
+ return createUnsatisfiableResponse(err.total);
50806
+ }
50807
+ throw err;
50808
+ } finally {
50809
+ if (ctx) {
50810
+ ctx.rangeRequest = null;
50811
+ }
50812
+ }
50813
+ }
50814
+ }
50815
+
50816
+ class StreamHandler {
50817
+ constructor(...args) {
50818
+ return new StreamRouteHandler(...args);
50819
+ }
50820
+ }
50821
+
50497
50822
  class ResourceRouteHandlers {
50498
50823
  __internal_brand = "ResourceRoutes";
50499
50824
  first;
@@ -50550,6 +50875,9 @@ class ApiRouter {
50550
50875
  file(handler, methodName) {
50551
50876
  return new FileHandler("GET", handler, methodName);
50552
50877
  }
50878
+ stream(handler, methodName) {
50879
+ return new StreamHandler("GET", handler, methodName);
50880
+ }
50553
50881
  proxy(url, headers = {}) {
50554
50882
  return new ProxyHandler(url, headers);
50555
50883
  }
@@ -50651,11 +50979,6 @@ class RedirectRoute {
50651
50979
  return this;
50652
50980
  }
50653
50981
  }
50654
- function contentDisposition(name, download) {
50655
- const kind = download ? "attachment" : "inline";
50656
- const fallback = name.replace(/["\\]/g, "").replace(/[^\x20-\x7e]/g, "_");
50657
- return `${kind}; filename="${fallback}"; filename*=UTF-8''${encodeURIComponent(name)}`;
50658
- }
50659
50982
  async function createFileResponse(output, headers) {
50660
50983
  if (output instanceof Response) {
50661
50984
  return output;
@@ -50826,58 +51149,6 @@ import { randomBytes } from "crypto";
50826
51149
  // services/ServiceProvider.ts
50827
51150
  class ServiceProvider {
50828
51151
  }
50829
- // http/errors.ts
50830
- class AuthorizationError extends RequestBreakerError {
50831
- error;
50832
- constructor(error = "Not authorized") {
50833
- super("Authentication error");
50834
- this.name = "AuthenticationError";
50835
- this.error = error;
50836
- this.payload = {
50837
- api: {
50838
- status: 401,
50839
- data: { error: this.error }
50840
- },
50841
- view: {}
50842
- };
50843
- }
50844
- }
50845
-
50846
- class InsufficientPermissionsError extends RequestBreakerError {
50847
- error;
50848
- constructor(error = "Insufficient permissions") {
50849
- super("Authentication error");
50850
- this.name = "AuthenticationError";
50851
- this.error = error;
50852
- this.payload = {
50853
- api: {
50854
- status: 401,
50855
- data: { error: this.error }
50856
- },
50857
- view: {}
50858
- };
50859
- }
50860
- }
50861
-
50862
- class AuthenticationError extends RequestBreakerError {
50863
- constructor() {
50864
- super("Authentication error");
50865
- this.name = "AuthenticationError";
50866
- }
50867
- payload = {
50868
- api: {
50869
- status: 401,
50870
- data: { error: "Authentication error" }
50871
- },
50872
- view: {
50873
- status: 302,
50874
- headers: {
50875
- "Cache-Control": "private, no-cache, no-store, max-age=0, must-revalidate",
50876
- Location: "/auth/sign-in"
50877
- }
50878
- }
50879
- };
50880
- }
50881
51152
  // kernel/context.ts
50882
51153
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
50883
51154
  var kernelContext = new AsyncLocalStorage2;
@@ -52140,6 +52411,12 @@ function isProxyHandler(option) {
52140
52411
  }
52141
52412
  return false;
52142
52413
  }
52414
+ function isStreamHandler(option) {
52415
+ if ("__internal_brand" in option) {
52416
+ return option.__internal_brand === "StreamHandler";
52417
+ }
52418
+ return false;
52419
+ }
52143
52420
  function createFlatApiRoutes(routes, rootPath = "", rootMiddleware = []) {
52144
52421
  const flatApiRoutes = {};
52145
52422
  function addRoute(path, method, exec, middleware) {
@@ -52176,6 +52453,9 @@ function createFlatApiRoutes(routes, rootPath = "", rootMiddleware = []) {
52176
52453
  const middleware = routeHandler.middlewares;
52177
52454
  const exec = routeHandler.run.bind(routeHandler);
52178
52455
  addRoute(path, method, exec, middleware);
52456
+ if (isStreamHandler(option)) {
52457
+ addRoute(path, "HEAD", exec, middleware);
52458
+ }
52179
52459
  }
52180
52460
  if (isRouteHandlers(option)) {
52181
52461
  for (const [method, routeHandler] of Object.entries(option)) {
@@ -68426,6 +68706,42 @@ class ApiRouterServiceContainer extends ServiceContainer {
68426
68706
  }
68427
68707
  return data;
68428
68708
  }
68709
+ mergeContextIntoResponse(response, headers, cookies) {
68710
+ const entries = [];
68711
+ headers?.forEach((value, key) => entries.push([key, value]));
68712
+ const setCookies = [
68713
+ ...typeof headers?.getSetCookie === "function" ? headers.getSetCookie() : [],
68714
+ ...Array.from(cookies ?? [])
68715
+ ];
68716
+ if (entries.length === 0 && setCookies.length === 0) {
68717
+ return response;
68718
+ }
68719
+ const apply = (target) => {
68720
+ for (const [key, value] of entries) {
68721
+ if (key.toLowerCase() === "set-cookie") {
68722
+ continue;
68723
+ }
68724
+ if (!target.has(key)) {
68725
+ target.set(key, value);
68726
+ }
68727
+ }
68728
+ for (const cookie of setCookies) {
68729
+ target.append("Set-Cookie", cookie);
68730
+ }
68731
+ };
68732
+ try {
68733
+ apply(response.headers);
68734
+ return response;
68735
+ } catch {
68736
+ const merged = new Headers(response.headers);
68737
+ apply(merged);
68738
+ return new Response(response.body, {
68739
+ status: response.status,
68740
+ statusText: response.statusText,
68741
+ headers: merged
68742
+ });
68743
+ }
68744
+ }
68429
68745
  async handleApiRequest(req) {
68430
68746
  const { params, path } = this.getRouteHandlerAndParams(req);
68431
68747
  const routeHandler = this.flatRoutes[path];
@@ -68451,16 +68767,22 @@ class ApiRouterServiceContainer extends ServiceContainer {
68451
68767
  return middlewareResponse;
68452
68768
  }
68453
68769
  const data = await this.getRouteData(path);
68770
+ const headers = ctx.headers;
68771
+ const cookies = ctx.cookies;
68454
68772
  if (data instanceof Response) {
68455
- return data;
68773
+ const response = this.mergeContextIntoResponse(data, headers, cookies);
68774
+ if (!req.url.includes("/__gemi__")) {
68775
+ this.service.onRequestEnd(httpRequest);
68776
+ }
68777
+ ctx.destroy();
68778
+ return response;
68456
68779
  }
68457
- const headers = ctx.headers;
68458
- headers.append("Content-Type", "application/json");
68459
- ctx.cookies.forEach((cookie) => headers.append("Set-Cookie", cookie.toString()));
68460
- ctx.destroy();
68780
+ headers.set("Content-Type", "application/json");
68781
+ cookies.forEach((cookie) => headers.append("Set-Cookie", cookie.toString()));
68461
68782
  if (!req.url.includes("/__gemi__")) {
68462
68783
  this.service.onRequestEnd(httpRequest);
68463
68784
  }
68785
+ ctx.destroy();
68464
68786
  return new Response(JSON.stringify(data), {
68465
68787
  headers
68466
68788
  });
@@ -69077,7 +69399,7 @@ class ApiManifestGenerator {
69077
69399
  if (!this.routes.has(finalRoutePath)) {
69078
69400
  this.routes.set(finalRoutePath, new Map);
69079
69401
  }
69080
- if (method === "file") {
69402
+ if (method === "file" || method === "stream") {
69081
69403
  return;
69082
69404
  } else if (method === "resource") {
69083
69405
  const idPrefixer = (path3) => path3 === "/" ? ":id" : `${path3}/:${toCamelCase(path3.split("/").pop())}Id`;
@@ -69291,5 +69613,5 @@ program.command("app:route-manifest").action(async () => {
69291
69613
  });
69292
69614
  program.parse();
69293
69615
 
69294
- //# debugId=71D97BBCCC12C4B064756E2164756E21
69616
+ //# debugId=5C74742BDDA86B8864756E2164756E21
69295
69617
  //# sourceMappingURL=gemi.js.map