@gravito/core 2.0.0 → 2.0.3

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.
@@ -4,25 +4,43 @@ var __getProtoOf = Object.getPrototypeOf;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
7
12
  var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
8
20
  target = mod != null ? __create(__getProtoOf(mod)) : {};
9
21
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
22
  for (let key of __getOwnPropNames(mod))
11
23
  if (!__hasOwnProp.call(to, key))
12
24
  __defProp(to, key, {
13
- get: () => mod[key],
25
+ get: __accessProp.bind(mod, key),
14
26
  enumerable: true
15
27
  });
28
+ if (canCache)
29
+ cache.set(mod, to);
16
30
  return to;
17
31
  };
18
32
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+ var __returnValue = (v) => v;
34
+ function __exportSetter(name, newValue) {
35
+ this[name] = __returnValue.bind(null, newValue);
36
+ }
19
37
  var __export = (target, all) => {
20
38
  for (var name in all)
21
39
  __defProp(target, name, {
22
40
  get: all[name],
23
41
  enumerable: true,
24
42
  configurable: true,
25
- set: (newValue) => all[name] = () => newValue
43
+ set: __exportSetter.bind(all, name)
26
44
  });
27
45
  };
28
46
  var __require = import.meta.require;
@@ -38,6 +56,14 @@ __export(exports_engine, {
38
56
  AOTRouter: () => AOTRouter
39
57
  });
40
58
 
59
+ // src/adapters/bun/types.ts
60
+ var NodeType;
61
+ ((NodeType2) => {
62
+ NodeType2[NodeType2["STATIC"] = 0] = "STATIC";
63
+ NodeType2[NodeType2["PARAM"] = 1] = "PARAM";
64
+ NodeType2[NodeType2["WILDCARD"] = 2] = "WILDCARD";
65
+ })(NodeType ||= {});
66
+
41
67
  // src/adapters/bun/RadixNode.ts
42
68
  class RadixNode {
43
69
  segment;
@@ -714,7 +740,12 @@ class RequestScopeManager {
714
740
  }
715
741
 
716
742
  // src/engine/FastContext.ts
717
- var bunEscapeHTML = globalThis.Bun.escapeHTML;
743
+ var bunEscapeHTML = (html) => {
744
+ return html.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
745
+ };
746
+ try {
747
+ bunEscapeHTML = globalThis.Bun.escapeHTML;
748
+ } catch {}
718
749
 
719
750
  class FastRequestImpl {
720
751
  _request;
@@ -1044,7 +1075,12 @@ class FastContext {
1044
1075
  }
1045
1076
 
1046
1077
  // src/engine/MinimalContext.ts
1047
- var bunEscapeHTML2 = globalThis.Bun.escapeHTML;
1078
+ var bunEscapeHTML2 = (html) => {
1079
+ return html.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1080
+ };
1081
+ try {
1082
+ bunEscapeHTML2 = globalThis.Bun.escapeHTML;
1083
+ } catch {}
1048
1084
 
1049
1085
  class MinimalRequest {
1050
1086
  _request;
@@ -1333,7 +1369,13 @@ class ObjectPool {
1333
1369
  }
1334
1370
 
1335
1371
  // src/engine/Gravito.ts
1336
- var bunPeek = globalThis.Bun.peek;
1372
+ var bunPeek = (promise) => promise;
1373
+ var bunFile = (path) => path;
1374
+ try {
1375
+ const bunModule = globalThis.Bun;
1376
+ bunPeek = bunModule.peek;
1377
+ bunFile = bunModule.file;
1378
+ } catch {}
1337
1379
  function compileMiddlewareChain(middleware, handler) {
1338
1380
  if (middleware.length === 0) {
1339
1381
  return handler;
@@ -1495,14 +1537,16 @@ class Gravito {
1495
1537
  response = result;
1496
1538
  }
1497
1539
  const cleanup = ctx.requestScope().cleanup();
1498
- if (cleanup instanceof Promise)
1540
+ if (cleanup instanceof Promise) {
1499
1541
  await cleanup;
1542
+ }
1500
1543
  this.contextPool.release(ctx);
1501
1544
  return response;
1502
1545
  } catch (error) {
1503
1546
  const cleanup = ctx.requestScope().cleanup();
1504
- if (cleanup instanceof Promise)
1547
+ if (cleanup instanceof Promise) {
1505
1548
  await cleanup;
1549
+ }
1506
1550
  this.contextPool.release(ctx);
1507
1551
  return this.handleErrorSync(error, req, path);
1508
1552
  }
@@ -1527,10 +1571,10 @@ class Gravito {
1527
1571
  const optimizeEntry = (entry) => {
1528
1572
  const optimized = { ...entry };
1529
1573
  if (typeof optimized.key === "string" && !optimized.key.startsWith("-----BEGIN")) {
1530
- optimized.key = globalThis.Bun.file(optimized.key);
1574
+ optimized.key = bunFile(optimized.key);
1531
1575
  }
1532
1576
  if (typeof optimized.cert === "string" && !optimized.cert.startsWith("-----BEGIN")) {
1533
- optimized.cert = globalThis.Bun.file(optimized.cert);
1577
+ optimized.cert = bunFile(optimized.cert);
1534
1578
  }
1535
1579
  if (isProd && optimized.lowMemoryMode === undefined) {
1536
1580
  optimized.lowMemoryMode = true;
@@ -1558,14 +1602,16 @@ class Gravito {
1558
1602
  response = result;
1559
1603
  }
1560
1604
  const cleanup = ctx.requestScope().cleanup();
1561
- if (cleanup instanceof Promise)
1605
+ if (cleanup instanceof Promise) {
1562
1606
  await cleanup;
1607
+ }
1563
1608
  this.contextPool.release(ctx);
1564
1609
  return response;
1565
1610
  } catch (error) {
1566
1611
  const cleanup = ctx.requestScope().cleanup();
1567
- if (cleanup instanceof Promise)
1612
+ if (cleanup instanceof Promise) {
1568
1613
  await cleanup;
1614
+ }
1569
1615
  this.contextPool.release(ctx);
1570
1616
  return this.handleErrorSync(error, request, path);
1571
1617
  }
@@ -1594,14 +1640,16 @@ class Gravito {
1594
1640
  response = result;
1595
1641
  }
1596
1642
  const cleanup = ctx.requestScope().cleanup();
1597
- if (cleanup instanceof Promise)
1643
+ if (cleanup instanceof Promise) {
1598
1644
  await cleanup;
1645
+ }
1599
1646
  this.contextPool.release(ctx);
1600
1647
  return response;
1601
1648
  } catch (error) {
1602
1649
  const cleanup = ctx.requestScope().cleanup();
1603
- if (cleanup instanceof Promise)
1650
+ if (cleanup instanceof Promise) {
1604
1651
  await cleanup;
1652
+ }
1605
1653
  this.contextPool.release(ctx);
1606
1654
  return this.handleErrorSync(error, request, path);
1607
1655
  }
@@ -1682,4 +1730,4 @@ export {
1682
1730
  AOTRouter
1683
1731
  };
1684
1732
 
1685
- //# debugId=13A90DBD3E511D5864756E2164756E21
1733
+ //# debugId=1A9EA2323316056B64756E2164756E21