@getcronit/pylon 3.0.0-canary-20250328152343.40b45e7f1112cde4b3669206a81904062ae419cf → 3.0.0-canary-20250407104538.a60dfeae82297f043070d0cbbaf98568962159d4

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.
package/dist/index.js CHANGED
@@ -878,7 +878,7 @@ function useViewer() {
878
878
  import { html as html2 } from "hono/html";
879
879
 
880
880
  // package.json
881
- var version = "3.0.0-canary-20250328152343.40b45e7f1112cde4b3669206a81904062ae419cf";
881
+ var version = "3.0.0-canary-20250407104538.a60dfeae82297f043070d0cbbaf98568962159d4";
882
882
 
883
883
  // src/plugins/use-unhandled-route.ts
884
884
  function useUnhandledRoute() {
@@ -1063,15 +1063,15 @@ import { useDisableIntrospection } from "@graphql-yoga/plugin-disable-introspect
1063
1063
  var resolveLazyObject = (obj) => {
1064
1064
  return typeof obj === "function" ? obj() : obj;
1065
1065
  };
1066
- var loadPluginsMiddleware = (plugins) => {
1066
+ var loadPluginsMiddleware = async (plugins) => {
1067
1067
  for (const plugin of plugins) {
1068
- plugin.setup?.(app);
1068
+ await plugin.setup?.(app);
1069
1069
  if (plugin.middleware) {
1070
1070
  pluginsMiddleware.push(plugin.middleware);
1071
1071
  }
1072
1072
  }
1073
1073
  };
1074
- var executeConfig = (config) => {
1074
+ var executeConfig = async (config) => {
1075
1075
  const plugins = [useSentry(), useViewer(), ...config?.plugins || []];
1076
1076
  if (config?.landingPage ?? true) {
1077
1077
  plugins.push(useUnhandledRoute());
@@ -1079,7 +1079,7 @@ var executeConfig = (config) => {
1079
1079
  if (config?.graphiql === false) {
1080
1080
  plugins.push(useDisableIntrospection());
1081
1081
  }
1082
- loadPluginsMiddleware(plugins);
1082
+ await loadPluginsMiddleware(plugins);
1083
1083
  config.plugins = plugins;
1084
1084
  app.config = config;
1085
1085
  };
@@ -1199,22 +1199,13 @@ import fs2 from "fs";
1199
1199
  import path3 from "path";
1200
1200
  import reactServer from "react-dom/server";
1201
1201
  import { trimTrailingSlash } from "hono/trailing-slash";
1202
- import { StaticRouter } from "react-router";
1202
+ import {
1203
+ createStaticHandler,
1204
+ createStaticRouter,
1205
+ StaticRouterProvider
1206
+ } from "react-router";
1203
1207
  import { PassThrough, Readable as Readable2 } from "stream";
1204
1208
 
1205
- // src/plugins/use-pages/setup/app-loader.tsx
1206
- import { useMemo } from "react";
1207
- import { jsx } from "react/jsx-runtime";
1208
- var AppLoader = (props) => {
1209
- props.client.useHydrateCache({ cacheSnapshot: props.pylonData.cacheSnapshot });
1210
- const data = props.client.useQuery();
1211
- const page = useMemo(() => {
1212
- const page2 = /* @__PURE__ */ jsx(props.App, { data });
1213
- return page2;
1214
- }, [props]);
1215
- return /* @__PURE__ */ jsx(props.Router, { ...props.routerProps, children: page });
1216
- };
1217
-
1218
1209
  // src/components/global-error-page.tsx
1219
1210
  import { useEffect } from "react";
1220
1211
 
@@ -1226,7 +1217,7 @@ function cn(...inputs) {
1226
1217
  }
1227
1218
 
1228
1219
  // src/components/logo.tsx
1229
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
1220
+ import { jsx, jsxs } from "react/jsx-runtime";
1230
1221
  var Logo = (props) => {
1231
1222
  return /* @__PURE__ */ jsxs(
1232
1223
  "svg",
@@ -1240,15 +1231,15 @@ var Logo = (props) => {
1240
1231
  version: "1.0",
1241
1232
  children: [
1242
1233
  /* @__PURE__ */ jsxs("defs", { children: [
1243
- /* @__PURE__ */ jsx2("g", {}),
1244
- /* @__PURE__ */ jsx2("clipPath", { id: "38f6fcde47", children: /* @__PURE__ */ jsx2(
1234
+ /* @__PURE__ */ jsx("g", {}),
1235
+ /* @__PURE__ */ jsx("clipPath", { id: "38f6fcde47", children: /* @__PURE__ */ jsx(
1245
1236
  "path",
1246
1237
  {
1247
1238
  d: "M 0.339844 42 L 10 42 L 10 79 L 0.339844 79 Z M 0.339844 42 ",
1248
1239
  clipRule: "nonzero"
1249
1240
  }
1250
1241
  ) }),
1251
- /* @__PURE__ */ jsx2("clipPath", { id: "af000f7256", children: /* @__PURE__ */ jsx2(
1242
+ /* @__PURE__ */ jsx("clipPath", { id: "af000f7256", children: /* @__PURE__ */ jsx(
1252
1243
  "path",
1253
1244
  {
1254
1245
  d: "M 64 23.925781 L 72.789062 23.925781 L 72.789062 96.378906 L 64 96.378906 Z M 64 23.925781 ",
@@ -1256,12 +1247,12 @@ var Logo = (props) => {
1256
1247
  }
1257
1248
  ) })
1258
1249
  ] }),
1259
- /* @__PURE__ */ jsx2("g", { fill: "currentColor", fillOpacity: "1", children: /* @__PURE__ */ jsx2("g", { transform: "translate(107.11969, 78.49768)", children: /* @__PURE__ */ jsx2("g", { children: /* @__PURE__ */ jsx2("path", { d: "M 10.078125 -25.046875 C 11.109375 -26.398438 12.507812 -27.535156 14.28125 -28.453125 C 16.0625 -29.378906 18.070312 -29.84375 20.3125 -29.84375 C 22.863281 -29.84375 25.195312 -29.210938 27.3125 -27.953125 C 29.425781 -26.691406 31.085938 -24.921875 32.296875 -22.640625 C 33.503906 -20.367188 34.109375 -17.757812 34.109375 -14.8125 C 34.109375 -11.863281 33.503906 -9.222656 32.296875 -6.890625 C 31.085938 -4.566406 29.425781 -2.753906 27.3125 -1.453125 C 25.195312 -0.160156 22.863281 0.484375 20.3125 0.484375 C 18.070312 0.484375 16.078125 0.03125 14.328125 -0.875 C 12.585938 -1.78125 11.171875 -2.910156 10.078125 -4.265625 L 10.078125 13.96875 L 4 13.96875 L 4 -29.359375 L 10.078125 -29.359375 Z M 27.921875 -14.8125 C 27.921875 -16.84375 27.503906 -18.59375 26.671875 -20.0625 C 25.835938 -21.539062 24.734375 -22.660156 23.359375 -23.421875 C 21.992188 -24.179688 20.53125 -24.5625 18.96875 -24.5625 C 17.445312 -24.5625 16 -24.171875 14.625 -23.390625 C 13.257812 -22.609375 12.160156 -21.472656 11.328125 -19.984375 C 10.492188 -18.492188 10.078125 -16.734375 10.078125 -14.703125 C 10.078125 -12.679688 10.492188 -10.914062 11.328125 -9.40625 C 12.160156 -7.894531 13.257812 -6.75 14.625 -5.96875 C 16 -5.1875 17.445312 -4.796875 18.96875 -4.796875 C 20.53125 -4.796875 21.992188 -5.191406 23.359375 -5.984375 C 24.734375 -6.785156 25.835938 -7.953125 26.671875 -9.484375 C 27.503906 -11.015625 27.921875 -12.789062 27.921875 -14.8125 Z M 27.921875 -14.8125 " }) }) }) }),
1260
- /* @__PURE__ */ jsx2("g", { fill: "currentColor", fillOpacity: "1", children: /* @__PURE__ */ jsx2("g", { transform: "translate(143.259256, 78.49768)", children: /* @__PURE__ */ jsx2("g", { children: /* @__PURE__ */ jsx2("path", { d: "M 30.4375 -29.359375 L 12.421875 13.796875 L 6.125 13.796875 L 12.09375 -0.484375 L 0.53125 -29.359375 L 7.296875 -29.359375 L 15.5625 -6.984375 L 24.140625 -29.359375 Z M 30.4375 -29.359375 " }) }) }) }),
1261
- /* @__PURE__ */ jsx2("g", { fill: "currentColor", fillOpacity: "1", children: /* @__PURE__ */ jsx2("g", { transform: "translate(174.281707, 78.49768)", children: /* @__PURE__ */ jsx2("g", { children: /* @__PURE__ */ jsx2("path", { d: "M 10.078125 -39.4375 L 10.078125 0 L 4 0 L 4 -39.4375 Z M 10.078125 -39.4375 " }) }) }) }),
1262
- /* @__PURE__ */ jsx2("g", { fill: "currentColor", fillOpacity: "1", children: /* @__PURE__ */ jsx2("g", { transform: "translate(188.353752, 78.49768)", children: /* @__PURE__ */ jsx2("g", { children: /* @__PURE__ */ jsx2("path", { d: "M 16.734375 0.484375 C 13.960938 0.484375 11.457031 -0.144531 9.21875 -1.40625 C 6.976562 -2.664062 5.21875 -4.441406 3.9375 -6.734375 C 2.664062 -9.035156 2.03125 -11.691406 2.03125 -14.703125 C 2.03125 -17.691406 2.6875 -20.335938 4 -22.640625 C 5.3125 -24.953125 7.101562 -26.726562 9.375 -27.96875 C 11.65625 -29.21875 14.195312 -29.84375 17 -29.84375 C 19.8125 -29.84375 22.351562 -29.21875 24.625 -27.96875 C 26.894531 -26.726562 28.6875 -24.953125 30 -22.640625 C 31.320312 -20.335938 31.984375 -17.691406 31.984375 -14.703125 C 31.984375 -11.722656 31.304688 -9.078125 29.953125 -6.765625 C 28.597656 -4.453125 26.757812 -2.664062 24.4375 -1.40625 C 22.113281 -0.144531 19.546875 0.484375 16.734375 0.484375 Z M 16.734375 -4.796875 C 18.296875 -4.796875 19.757812 -5.164062 21.125 -5.90625 C 22.5 -6.65625 23.613281 -7.773438 24.46875 -9.265625 C 25.320312 -10.765625 25.75 -12.578125 25.75 -14.703125 C 25.75 -16.835938 25.335938 -18.640625 24.515625 -20.109375 C 23.703125 -21.585938 22.617188 -22.695312 21.265625 -23.4375 C 19.910156 -24.1875 18.453125 -24.5625 16.890625 -24.5625 C 15.328125 -24.5625 13.878906 -24.1875 12.546875 -23.4375 C 11.210938 -22.695312 10.15625 -21.585938 9.375 -20.109375 C 8.59375 -18.640625 8.203125 -16.835938 8.203125 -14.703125 C 8.203125 -11.546875 9.007812 -9.101562 10.625 -7.375 C 12.25 -5.65625 14.285156 -4.796875 16.734375 -4.796875 Z M 16.734375 -4.796875 " }) }) }) }),
1263
- /* @__PURE__ */ jsx2("g", { fill: "currentColor", fillOpacity: "1", children: /* @__PURE__ */ jsx2("g", { transform: "translate(222.361196, 78.49768)", children: /* @__PURE__ */ jsx2("g", { children: /* @__PURE__ */ jsx2("path", { d: "M 18.8125 -29.84375 C 21.125 -29.84375 23.191406 -29.363281 25.015625 -28.40625 C 26.847656 -27.445312 28.28125 -26.023438 29.3125 -24.140625 C 30.34375 -22.253906 30.859375 -19.984375 30.859375 -17.328125 L 30.859375 0 L 24.84375 0 L 24.84375 -16.421875 C 24.84375 -19.046875 24.179688 -21.054688 22.859375 -22.453125 C 21.546875 -23.859375 19.753906 -24.5625 17.484375 -24.5625 C 15.210938 -24.5625 13.410156 -23.859375 12.078125 -22.453125 C 10.742188 -21.054688 10.078125 -19.046875 10.078125 -16.421875 L 10.078125 0 L 4 0 L 4 -29.359375 L 10.078125 -29.359375 L 10.078125 -26.015625 C 11.066406 -27.222656 12.332031 -28.160156 13.875 -28.828125 C 15.425781 -29.503906 17.070312 -29.84375 18.8125 -29.84375 Z M 18.8125 -29.84375 " }) }) }) }),
1264
- /* @__PURE__ */ jsx2(
1250
+ /* @__PURE__ */ jsx("g", { fill: "currentColor", fillOpacity: "1", children: /* @__PURE__ */ jsx("g", { transform: "translate(107.11969, 78.49768)", children: /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx("path", { d: "M 10.078125 -25.046875 C 11.109375 -26.398438 12.507812 -27.535156 14.28125 -28.453125 C 16.0625 -29.378906 18.070312 -29.84375 20.3125 -29.84375 C 22.863281 -29.84375 25.195312 -29.210938 27.3125 -27.953125 C 29.425781 -26.691406 31.085938 -24.921875 32.296875 -22.640625 C 33.503906 -20.367188 34.109375 -17.757812 34.109375 -14.8125 C 34.109375 -11.863281 33.503906 -9.222656 32.296875 -6.890625 C 31.085938 -4.566406 29.425781 -2.753906 27.3125 -1.453125 C 25.195312 -0.160156 22.863281 0.484375 20.3125 0.484375 C 18.070312 0.484375 16.078125 0.03125 14.328125 -0.875 C 12.585938 -1.78125 11.171875 -2.910156 10.078125 -4.265625 L 10.078125 13.96875 L 4 13.96875 L 4 -29.359375 L 10.078125 -29.359375 Z M 27.921875 -14.8125 C 27.921875 -16.84375 27.503906 -18.59375 26.671875 -20.0625 C 25.835938 -21.539062 24.734375 -22.660156 23.359375 -23.421875 C 21.992188 -24.179688 20.53125 -24.5625 18.96875 -24.5625 C 17.445312 -24.5625 16 -24.171875 14.625 -23.390625 C 13.257812 -22.609375 12.160156 -21.472656 11.328125 -19.984375 C 10.492188 -18.492188 10.078125 -16.734375 10.078125 -14.703125 C 10.078125 -12.679688 10.492188 -10.914062 11.328125 -9.40625 C 12.160156 -7.894531 13.257812 -6.75 14.625 -5.96875 C 16 -5.1875 17.445312 -4.796875 18.96875 -4.796875 C 20.53125 -4.796875 21.992188 -5.191406 23.359375 -5.984375 C 24.734375 -6.785156 25.835938 -7.953125 26.671875 -9.484375 C 27.503906 -11.015625 27.921875 -12.789062 27.921875 -14.8125 Z M 27.921875 -14.8125 " }) }) }) }),
1251
+ /* @__PURE__ */ jsx("g", { fill: "currentColor", fillOpacity: "1", children: /* @__PURE__ */ jsx("g", { transform: "translate(143.259256, 78.49768)", children: /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx("path", { d: "M 30.4375 -29.359375 L 12.421875 13.796875 L 6.125 13.796875 L 12.09375 -0.484375 L 0.53125 -29.359375 L 7.296875 -29.359375 L 15.5625 -6.984375 L 24.140625 -29.359375 Z M 30.4375 -29.359375 " }) }) }) }),
1252
+ /* @__PURE__ */ jsx("g", { fill: "currentColor", fillOpacity: "1", children: /* @__PURE__ */ jsx("g", { transform: "translate(174.281707, 78.49768)", children: /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx("path", { d: "M 10.078125 -39.4375 L 10.078125 0 L 4 0 L 4 -39.4375 Z M 10.078125 -39.4375 " }) }) }) }),
1253
+ /* @__PURE__ */ jsx("g", { fill: "currentColor", fillOpacity: "1", children: /* @__PURE__ */ jsx("g", { transform: "translate(188.353752, 78.49768)", children: /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx("path", { d: "M 16.734375 0.484375 C 13.960938 0.484375 11.457031 -0.144531 9.21875 -1.40625 C 6.976562 -2.664062 5.21875 -4.441406 3.9375 -6.734375 C 2.664062 -9.035156 2.03125 -11.691406 2.03125 -14.703125 C 2.03125 -17.691406 2.6875 -20.335938 4 -22.640625 C 5.3125 -24.953125 7.101562 -26.726562 9.375 -27.96875 C 11.65625 -29.21875 14.195312 -29.84375 17 -29.84375 C 19.8125 -29.84375 22.351562 -29.21875 24.625 -27.96875 C 26.894531 -26.726562 28.6875 -24.953125 30 -22.640625 C 31.320312 -20.335938 31.984375 -17.691406 31.984375 -14.703125 C 31.984375 -11.722656 31.304688 -9.078125 29.953125 -6.765625 C 28.597656 -4.453125 26.757812 -2.664062 24.4375 -1.40625 C 22.113281 -0.144531 19.546875 0.484375 16.734375 0.484375 Z M 16.734375 -4.796875 C 18.296875 -4.796875 19.757812 -5.164062 21.125 -5.90625 C 22.5 -6.65625 23.613281 -7.773438 24.46875 -9.265625 C 25.320312 -10.765625 25.75 -12.578125 25.75 -14.703125 C 25.75 -16.835938 25.335938 -18.640625 24.515625 -20.109375 C 23.703125 -21.585938 22.617188 -22.695312 21.265625 -23.4375 C 19.910156 -24.1875 18.453125 -24.5625 16.890625 -24.5625 C 15.328125 -24.5625 13.878906 -24.1875 12.546875 -23.4375 C 11.210938 -22.695312 10.15625 -21.585938 9.375 -20.109375 C 8.59375 -18.640625 8.203125 -16.835938 8.203125 -14.703125 C 8.203125 -11.546875 9.007812 -9.101562 10.625 -7.375 C 12.25 -5.65625 14.285156 -4.796875 16.734375 -4.796875 Z M 16.734375 -4.796875 " }) }) }) }),
1254
+ /* @__PURE__ */ jsx("g", { fill: "currentColor", fillOpacity: "1", children: /* @__PURE__ */ jsx("g", { transform: "translate(222.361196, 78.49768)", children: /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx("path", { d: "M 18.8125 -29.84375 C 21.125 -29.84375 23.191406 -29.363281 25.015625 -28.40625 C 26.847656 -27.445312 28.28125 -26.023438 29.3125 -24.140625 C 30.34375 -22.253906 30.859375 -19.984375 30.859375 -17.328125 L 30.859375 0 L 24.84375 0 L 24.84375 -16.421875 C 24.84375 -19.046875 24.179688 -21.054688 22.859375 -22.453125 C 21.546875 -23.859375 19.753906 -24.5625 17.484375 -24.5625 C 15.210938 -24.5625 13.410156 -23.859375 12.078125 -22.453125 C 10.742188 -21.054688 10.078125 -19.046875 10.078125 -16.421875 L 10.078125 0 L 4 0 L 4 -29.359375 L 10.078125 -29.359375 L 10.078125 -26.015625 C 11.066406 -27.222656 12.332031 -28.160156 13.875 -28.828125 C 15.425781 -29.503906 17.070312 -29.84375 18.8125 -29.84375 Z M 18.8125 -29.84375 " }) }) }) }),
1255
+ /* @__PURE__ */ jsx(
1265
1256
  "path",
1266
1257
  {
1267
1258
  fill: "currentColor",
@@ -1270,7 +1261,7 @@ var Logo = (props) => {
1270
1261
  fillRule: "nonzero"
1271
1262
  }
1272
1263
  ),
1273
- /* @__PURE__ */ jsx2("g", { clipPath: "url(#38f6fcde47)", children: /* @__PURE__ */ jsx2(
1264
+ /* @__PURE__ */ jsx("g", { clipPath: "url(#38f6fcde47)", children: /* @__PURE__ */ jsx(
1274
1265
  "path",
1275
1266
  {
1276
1267
  fill: "currentColor",
@@ -1279,7 +1270,7 @@ var Logo = (props) => {
1279
1270
  fillRule: "nonzero"
1280
1271
  }
1281
1272
  ) }),
1282
- /* @__PURE__ */ jsx2("g", { clipPath: "url(#af000f7256)", children: /* @__PURE__ */ jsx2(
1273
+ /* @__PURE__ */ jsx("g", { clipPath: "url(#af000f7256)", children: /* @__PURE__ */ jsx(
1283
1274
  "path",
1284
1275
  {
1285
1276
  fill: "currentColor",
@@ -1288,7 +1279,7 @@ var Logo = (props) => {
1288
1279
  fillRule: "nonzero"
1289
1280
  }
1290
1281
  ) }),
1291
- /* @__PURE__ */ jsx2(
1282
+ /* @__PURE__ */ jsx(
1292
1283
  "path",
1293
1284
  {
1294
1285
  fill: "currentColor",
@@ -1297,7 +1288,7 @@ var Logo = (props) => {
1297
1288
  fillRule: "nonzero"
1298
1289
  }
1299
1290
  ),
1300
- /* @__PURE__ */ jsx2(
1291
+ /* @__PURE__ */ jsx(
1301
1292
  "path",
1302
1293
  {
1303
1294
  fill: "currentColor",
@@ -1306,7 +1297,7 @@ var Logo = (props) => {
1306
1297
  fillRule: "nonzero"
1307
1298
  }
1308
1299
  ),
1309
- /* @__PURE__ */ jsx2(
1300
+ /* @__PURE__ */ jsx(
1310
1301
  "path",
1311
1302
  {
1312
1303
  fill: "currentColor",
@@ -1322,8 +1313,8 @@ var Logo = (props) => {
1322
1313
  var logo_default = Logo;
1323
1314
 
1324
1315
  // src/components/global-error-page.tsx
1325
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1326
- function GlobalError({ error }) {
1316
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
1317
+ function GlobalError({ error, ...rest }) {
1327
1318
  useEffect(() => {
1328
1319
  console.error("Global error:", error);
1329
1320
  }, [error]);
@@ -1332,9 +1323,9 @@ function GlobalError({ error }) {
1332
1323
  };
1333
1324
  return /* @__PURE__ */ jsxs2("html", { lang: "en", children: [
1334
1325
  /* @__PURE__ */ jsxs2("head", { children: [
1335
- /* @__PURE__ */ jsx3("meta", { charSet: "utf-8" }),
1336
- /* @__PURE__ */ jsx3("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }),
1337
- /* @__PURE__ */ jsx3(
1326
+ /* @__PURE__ */ jsx2("meta", { charSet: "utf-8" }),
1327
+ /* @__PURE__ */ jsx2("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }),
1328
+ /* @__PURE__ */ jsx2(
1338
1329
  "link",
1339
1330
  {
1340
1331
  rel: "stylesheet",
@@ -1343,17 +1334,17 @@ function GlobalError({ error }) {
1343
1334
  }
1344
1335
  )
1345
1336
  ] }),
1346
- /* @__PURE__ */ jsx3("body", { children: /* @__PURE__ */ jsx3("div", { className: "fixed inset-0 bg-black/90 z-50 overflow-y-auto p-4 flex items-center justify-center", children: /* @__PURE__ */ jsxs2("div", { className: "w-full max-w-3xl bg-black border border-red-600 rounded-lg overflow-hidden text-white font-sans", children: [
1347
- /* @__PURE__ */ jsx3("div", { className: "flex items-center justify-between border-b border-neutral-800 p-4", children: /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-3", children: [
1348
- /* @__PURE__ */ jsx3("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx3(logo_default, { className: "h-8 w-auto text-white" }) }),
1349
- /* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsx3("h1", { className: "text-xl font-medium text-red-500", children: "Application Crashed" }) })
1337
+ /* @__PURE__ */ jsx2("body", { children: /* @__PURE__ */ jsx2("div", { className: "fixed inset-0 bg-black/90 z-50 overflow-y-auto p-4 flex items-center justify-center", children: /* @__PURE__ */ jsxs2("div", { className: "w-full max-w-3xl bg-black border border-red-600 rounded-lg overflow-hidden text-white font-sans", children: [
1338
+ /* @__PURE__ */ jsx2("div", { className: "flex items-center justify-between border-b border-neutral-800 p-4", children: /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-3", children: [
1339
+ /* @__PURE__ */ jsx2("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx2(logo_default, { className: "h-8 w-auto text-white" }) }),
1340
+ /* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2("h1", { className: "text-xl font-medium text-red-500", children: "Application Crashed" }) })
1350
1341
  ] }) }),
1351
1342
  /* @__PURE__ */ jsxs2("div", { className: "p-4", children: [
1352
- /* @__PURE__ */ jsx3("div", { className: "mb-4 text-neutral-400", children: "The application encountered a critical error and could not continue." }),
1353
- /* @__PURE__ */ jsx3("h2", { className: "text-2xl font-bold mb-4 text-white", children: error.message || "A critical error occurred" }),
1343
+ /* @__PURE__ */ jsx2("div", { className: "mb-4 text-neutral-400", children: "The application encountered a critical error and could not continue." }),
1344
+ /* @__PURE__ */ jsx2("h2", { className: "text-2xl font-bold mb-4 text-white", children: error.message || "A critical error occurred" }),
1354
1345
  error.digest && /* @__PURE__ */ jsxs2("div", { className: "mb-4", children: [
1355
- /* @__PURE__ */ jsx3("h3", { className: "text-sm uppercase tracking-wider text-neutral-500 font-medium mb-2", children: "Error ID" }),
1356
- /* @__PURE__ */ jsx3("div", { className: "bg-neutral-900 rounded-md p-3 text-neutral-300 font-mono", children: error.digest })
1346
+ /* @__PURE__ */ jsx2("h3", { className: "text-sm uppercase tracking-wider text-neutral-500 font-medium mb-2", children: "Error ID" }),
1347
+ /* @__PURE__ */ jsx2("div", { className: "bg-neutral-900 rounded-md p-3 text-neutral-300 font-mono", children: error.digest })
1357
1348
  ] })
1358
1349
  ] })
1359
1350
  ] }) }) })
@@ -1441,7 +1432,8 @@ var serveFilePath = async ({
1441
1432
  };
1442
1433
 
1443
1434
  // src/plugins/use-pages/setup/index.tsx
1444
- import { jsx as jsx4 } from "react/jsx-runtime";
1435
+ import { __PYLON_INTERNALS_DO_NOT_USE } from "@getcronit/pylon/pages";
1436
+ import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
1445
1437
  var disableCacheMiddleware = async (c, next) => {
1446
1438
  const env3 = getEnv();
1447
1439
  if (true) {
@@ -1455,139 +1447,73 @@ var disableCacheMiddleware = async (c, next) => {
1455
1447
  }
1456
1448
  return next();
1457
1449
  };
1458
- var setup = (app2) => {
1450
+ var setup = async (app2) => {
1459
1451
  const cacheBustingSuffix = `?v=${Date.now()}`;
1460
- const pagesFilePath = path3.resolve(process.cwd(), ".pylon", "pages.json");
1461
- let pageRoutes = [];
1462
- try {
1463
- pageRoutes = JSON.parse(fs2.readFileSync(pagesFilePath, "utf-8"));
1464
- } catch (error) {
1465
- console.error("Error reading pages.json", error);
1466
- }
1452
+ const slugs = (await import(`${process.cwd()}/.pylon/slugs.js`)).default;
1453
+ const routes = (await import(`${process.cwd()}/.pylon/__pylon/pages/app.js`)).default;
1454
+ const client = await import(`${process.cwd()}/.pylon/client/index.js`);
1455
+ let handler2 = createStaticHandler(routes);
1467
1456
  app2.use(trimTrailingSlash());
1468
- let App = void 0;
1469
- let client = void 0;
1470
- app2.on(
1471
- "GET",
1472
- pageRoutes.map((pageRoute) => pageRoute.slug),
1473
- disableCacheMiddleware,
1474
- async (c) => {
1457
+ app2.get("/test1234", async (c) => {
1458
+ return c.json({ hello: "world" });
1459
+ });
1460
+ app2.on("GET", slugs, disableCacheMiddleware, async (c) => {
1461
+ const context = await handler2.query(c.req.raw);
1462
+ if (context instanceof Response) {
1463
+ return context;
1464
+ }
1465
+ const router = createStaticRouter(handler2.dataRoutes, context);
1466
+ const component = /* @__PURE__ */ jsx3(__PYLON_INTERNALS_DO_NOT_USE.DataClientProvider, { client, children: /* @__PURE__ */ jsx3(StaticRouterProvider, { router, context }) });
1467
+ if (c.req.header("accept")?.includes("application/json")) {
1468
+ const prepared = await client.prepareReactRender(component);
1469
+ const data = prepared.cacheSnapshot;
1470
+ return c.json(data);
1471
+ }
1472
+ try {
1473
+ let cacheSnapshot = void 0;
1475
1474
  try {
1476
- if (!App) {
1477
- const module = await import(`${process.cwd()}/.pylon/__pylon/pages/app.js`);
1478
- App = module.default;
1479
- }
1480
- if (!client) {
1481
- client = await import(`${process.cwd()}/.pylon/client/index.js`);
1482
- }
1483
- const requestUrl = new URL(c.req.url);
1484
- let cacheSnapshot = void 0;
1475
+ const prepared = await client.prepareReactRender(/* @__PURE__ */ jsx3(Fragment, {}));
1476
+ cacheSnapshot = prepared.cacheSnapshot;
1477
+ } catch (error) {
1478
+ }
1479
+ if (reactServer.renderToReadableStream) {
1485
1480
  try {
1486
- const prepared = await client.prepareReactRender(
1487
- /* @__PURE__ */ jsx4(
1488
- AppLoader,
1489
- {
1490
- Router: StaticRouter,
1491
- routerProps: {
1492
- location: {
1493
- pathname: requestUrl.pathname,
1494
- search: requestUrl.search,
1495
- hash: requestUrl.hash
1496
- }
1497
- },
1498
- App,
1499
- client,
1500
- pylonData: {
1501
- cacheSnapshot: void 0
1502
- }
1503
- }
1504
- )
1505
- );
1506
- cacheSnapshot = prepared.cacheSnapshot;
1481
+ const stream = await reactServer.renderToReadableStream(component, {
1482
+ bootstrapModules: ["/__pylon/static/app.js" + cacheBustingSuffix]
1483
+ });
1484
+ return c.body(stream);
1507
1485
  } catch (error) {
1486
+ throw error;
1508
1487
  }
1509
- if (reactServer.renderToReadableStream) {
1510
- try {
1511
- const stream = await reactServer.renderToReadableStream(
1512
- /* @__PURE__ */ jsx4(
1513
- AppLoader,
1514
- {
1515
- Router: StaticRouter,
1516
- routerProps: {
1517
- location: c.req.path
1518
- },
1519
- App,
1520
- client,
1521
- pylonData: {
1522
- cacheSnapshot
1523
- }
1524
- }
1525
- ),
1526
- {
1527
- bootstrapModules: [
1528
- "/__pylon/static/app.js" + cacheBustingSuffix
1529
- ],
1530
- bootstrapScriptContent: `window.__PYLON_DATA__ = ${JSON.stringify(
1531
- {
1532
- cacheSnapshot
1533
- }
1534
- )}`
1535
- }
1536
- );
1537
- return c.body(stream);
1538
- } catch (error) {
1539
- throw error;
1540
- }
1541
- } else if (reactServer.renderToPipeableStream) {
1542
- return await new Promise((resolve, reject) => {
1543
- const { pipe } = reactServer.renderToPipeableStream(
1544
- /* @__PURE__ */ jsx4(
1545
- AppLoader,
1546
- {
1547
- Router: StaticRouter,
1548
- routerProps: {
1549
- location: c.req.path
1550
- },
1551
- App,
1552
- client,
1553
- pylonData: {
1554
- cacheSnapshot
1555
- }
1556
- }
1557
- ),
1558
- {
1559
- bootstrapModules: [
1560
- "/__pylon/static/app.js" + cacheBustingSuffix
1561
- ],
1562
- bootstrapScriptContent: `window.__PYLON_DATA__ = ${JSON.stringify(
1563
- {
1564
- cacheSnapshot
1565
- }
1566
- )}`,
1567
- onShellReady: async () => {
1568
- c.header("Content-Type", "text/html");
1569
- const passThrough = new PassThrough();
1570
- pipe(passThrough);
1571
- resolve(c.body(Readable2.toWeb(passThrough)));
1572
- },
1573
- onShellError: async (error) => {
1574
- reject(error);
1575
- }
1488
+ } else if (reactServer.renderToPipeableStream) {
1489
+ return await new Promise((resolve, reject) => {
1490
+ const { pipe } = reactServer.renderToPipeableStream(
1491
+ component,
1492
+ {
1493
+ bootstrapModules: ["/__pylon/static/app.js" + cacheBustingSuffix],
1494
+ onShellReady: async () => {
1495
+ c.header("Content-Type", "text/html");
1496
+ const passThrough = new PassThrough();
1497
+ pipe(passThrough);
1498
+ resolve(c.body(Readable2.toWeb(passThrough)));
1499
+ },
1500
+ onShellError: async (error) => {
1501
+ reject(error);
1576
1502
  }
1577
- );
1578
- });
1579
- } else {
1580
- throw new Error("Environment not supported");
1581
- }
1582
- } catch (error) {
1583
- c.header("Content-Type", "text/html");
1584
- c.status(500);
1585
- return c.html(
1586
- reactServer.renderToString(/* @__PURE__ */ jsx4(GlobalError, { error }))
1587
- );
1503
+ }
1504
+ );
1505
+ });
1506
+ } else {
1507
+ throw new Error("Environment not supported");
1588
1508
  }
1509
+ } catch (error) {
1510
+ c.header("Content-Type", "text/html");
1511
+ c.status(500);
1512
+ return c.html(
1513
+ reactServer.renderToString(/* @__PURE__ */ jsx3(GlobalError, { error }))
1514
+ );
1589
1515
  }
1590
- );
1516
+ });
1591
1517
  const publicFilesPath = path3.resolve(
1592
1518
  process.cwd(),
1593
1519
  ".pylon",
@@ -1800,184 +1726,207 @@ var downloadImage = async (url) => {
1800
1726
  import path7 from "path";
1801
1727
 
1802
1728
  // src/plugins/use-pages/build/app-utils.ts
1729
+ import fs3 from "fs";
1803
1730
  import path4 from "path";
1804
- import glob2 from "tiny-glob";
1805
- function fnv1aHash(str) {
1806
- let hash = 2166136261;
1807
- for (let i = 0; i < str.length; i++) {
1808
- hash ^= str.charCodeAt(i);
1809
- hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
1731
+ var PAGES_DIR = "./pages";
1732
+ var imports = [];
1733
+ var routeSlugs = [];
1734
+ function getLayoutComponentName(filePath) {
1735
+ return filePath.replace(PAGES_DIR, "").replace(/\\/g, "/").replace(/layout\.tsx$/, "").split("/").filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join("") + "Layout";
1736
+ }
1737
+ function convertToDynamicRoute(segment) {
1738
+ if (segment.startsWith("[") && segment.endsWith("]")) {
1739
+ return `:${segment.slice(1, -1)}`;
1810
1740
  }
1811
- return (hash >>> 0).toString(16);
1741
+ return segment;
1812
1742
  }
1813
- var APP_DIR = path4.join(process.cwd(), "pages");
1814
- async function getPageRoutes(dir = APP_DIR) {
1815
- const routes = [];
1816
- const pagePattern = path4.join(dir, "**/page.{ts,tsx,js}");
1817
- const layoutPattern = path4.join(dir, "**/layout.tsx");
1818
- const pageFiles = await glob2(pagePattern);
1819
- const layoutFiles = await glob2(layoutPattern);
1820
- for (const pagePath of pageFiles) {
1821
- const relativePagePath = path4.relative(APP_DIR, pagePath);
1822
- let slug = "/" + relativePagePath.replace(/page\.(ts|tsx|js)$/, "").replace(/\[([\w-]+)\]/g, ":$1");
1823
- slug = slug.replace(/\/$/, "");
1824
- const layouts = layoutFiles.filter((layout) => {
1825
- return pagePath.startsWith(layout.replace("layout.tsx", ""));
1826
- });
1827
- const layoutsWithoutRootLayout = layouts.slice(1);
1828
- routes.push({
1829
- pagePath,
1830
- slug: slug || "/",
1831
- layouts: layoutsWithoutRootLayout
1832
- });
1743
+ function scanDirectory(directory, basePath = "") {
1744
+ const items = fs3.readdirSync(directory, { withFileTypes: true });
1745
+ const route = { path: basePath || "/", children: [] };
1746
+ let hasLayout = false;
1747
+ let pageFound = false;
1748
+ for (const item of items) {
1749
+ const itemPath = path4.join(directory, item.name);
1750
+ const relativePath = path4.join(basePath, item.name).replace(/\\/g, "/");
1751
+ const importPath = `"./${path4.join("..", PAGES_DIR, relativePath).replace(/\.tsx$/, "")}"`;
1752
+ if (item.isDirectory()) {
1753
+ const childRoute = scanDirectory(itemPath, relativePath);
1754
+ if (childRoute) {
1755
+ route.children.push(childRoute);
1756
+ }
1757
+ } else if (item.name === "layout.tsx") {
1758
+ const layoutComponentName = getLayoutComponentName(relativePath);
1759
+ imports.push(`import ${layoutComponentName} from ${importPath};`);
1760
+ const componentName = layoutComponentName === "Layout" ? `RootLayout` : `${layoutComponentName}`;
1761
+ route.Component = `withLoaderData(() => <${componentName} children={<Outlet />} />)`;
1762
+ if (route.path === "/") {
1763
+ route.errorElement = "<ErrorElement />";
1764
+ }
1765
+ hasLayout = true;
1766
+ } else if (item.name === "page.tsx") {
1767
+ route.children.push({
1768
+ path: void 0,
1769
+ index: true,
1770
+ lazy: `async () => {const i = await import(${importPath}); return {Component: withLoaderData(i.default)}}`,
1771
+ loader: `loader`
1772
+ });
1773
+ pageFound = true;
1774
+ }
1775
+ }
1776
+ if (route.path) {
1777
+ const segments = route.path.split("/").map((segment) => convertToDynamicRoute(segment)).filter(Boolean);
1778
+ const fullPath = segments.length > 0 ? `/${segments.join("/")}` : "/";
1779
+ route.path = segments[segments.length - 1] || "/";
1780
+ if (hasLayout || pageFound) {
1781
+ routeSlugs.push(fullPath);
1782
+ }
1783
+ }
1784
+ if (hasLayout || route.lazy || route.children && route.children.length > 0) {
1785
+ return route;
1833
1786
  }
1834
- return routes;
1787
+ return null;
1835
1788
  }
1836
- var generateAppFile = (pageRoutes) => {
1837
- const makePageMap = (routes) => {
1838
- const pageMap2 = {};
1839
- for (const route of routes) {
1840
- pageMap2[route.pagePath] = `Page${fnv1aHash(route.pagePath)}`;
1789
+ function serialize(obj, parentKey) {
1790
+ if (Array.isArray(obj)) {
1791
+ return `[${obj.map(serialize).join(", ")}]`;
1792
+ } else if (obj && typeof obj === "object") {
1793
+ const entries = Object.entries(obj).map(
1794
+ ([key, value]) => `${JSON.stringify(key)}: ${serialize(value, key)}`
1795
+ );
1796
+ return `{${entries.join(", ")}}`;
1797
+ } else if (typeof obj === "string") {
1798
+ if (parentKey === "lazy" || parentKey === "loader" || parentKey === "Component" || parentKey === "errorElement") {
1799
+ return obj;
1841
1800
  }
1842
- return pageMap2;
1801
+ return JSON.stringify(obj);
1802
+ } else {
1803
+ return String(obj);
1804
+ }
1805
+ }
1806
+ function makeAppFiles() {
1807
+ imports = [];
1808
+ routeSlugs = [];
1809
+ const rootRoute = scanDirectory(PAGES_DIR);
1810
+ const notFoundRoute = {
1811
+ path: "*",
1812
+ Component: "NotFoundPage"
1843
1813
  };
1844
- const makeLayoutMap = (routes) => {
1845
- const layoutMap2 = {};
1846
- for (const route of routes) {
1847
- for (const layout of route.layouts) {
1848
- layoutMap2[layout] = `Layout${fnv1aHash(layout)}`;
1849
- }
1850
- }
1851
- return layoutMap2;
1814
+ const routes = `${imports.join("\n")}
1815
+
1816
+ import {__PYLON_ROUTER_INTERNALS_DO_NOT_USE, __PYLON_INTERNALS_DO_NOT_USE, GlobalErrorPage} from '@getcronit/pylon/pages'
1817
+ const Outlet = __PYLON_ROUTER_INTERNALS_DO_NOT_USE.Outlet
1818
+
1819
+ const ErrorElement = () => {
1820
+ const error = __PYLON_ROUTER_INTERNALS_DO_NOT_USE.useRouteError()
1821
+
1822
+ return <GlobalErrorPage error={error} />
1823
+ }
1824
+
1825
+ function withLoaderData<T>(Component: React.ComponentType<{ data: T }>) {
1826
+ return function WithLoaderDataWrapper(props: T) {
1827
+ const client = __PYLON_INTERNALS_DO_NOT_USE.useDataClient()
1828
+ const cacheSnapshot = __PYLON_ROUTER_INTERNALS_DO_NOT_USE.useLoaderData()
1829
+
1830
+
1831
+ const location = __PYLON_ROUTER_INTERNALS_DO_NOT_USE.useLocation()
1832
+ const [searchParams] = __PYLON_ROUTER_INTERNALS_DO_NOT_USE.useSearchParams()
1833
+ const searchParamsObject = Object.fromEntries(searchParams.entries())
1834
+ const params = __PYLON_ROUTER_INTERNALS_DO_NOT_USE.useParams()
1835
+
1836
+ client.useHydrateCache({cacheSnapshot})
1837
+ const data = client.useQuery()
1838
+
1839
+ return <Component {...(props as any)} path={location.pathname} params={params} searchParams={searchParamsObject} data={data} />;
1852
1840
  };
1853
- const pageMap = makePageMap(pageRoutes);
1854
- const layoutMap = makeLayoutMap(pageRoutes);
1855
- const importPages = Object.keys(pageMap).map((pagePath, index) => {
1856
- const importLocation = `../${pagePath}`.replace(".tsx", ".js");
1857
- const componentName = pageMap[pagePath];
1858
- return `const ${componentName} = lazy(() => import('${importLocation}'))
1859
- `;
1860
- }).join("\n");
1861
- const importLayouts = Object.keys(layoutMap).map((layoutPath, index) => {
1862
- const importLocation = `../${layoutPath}`.replace(".tsx", ".js");
1863
- const componentName = layoutMap[layoutPath];
1864
- return `const ${componentName} = lazy(() => import('${importLocation}'))
1865
- `;
1866
- }).join("\n");
1867
- const appComponent = `"use client";
1868
- import {lazy, Suspense, useMemo} from 'react'
1869
- import { __PYLON_ROUTER_INTERNALS_DO_NOT_USE, DevOverlay, PageProps} from '@getcronit/pylon/pages';
1870
- const {Routes, Route, useParams, useSearchParams, useLocation} = __PYLON_ROUTER_INTERNALS_DO_NOT_USE
1871
- ${importPages}
1872
- const RootLayout = lazy(() => import('../pages/layout.js'))
1873
- ${importLayouts}
1874
-
1875
- const InjectPageProps: React.FC<{Page: React.FC, data: PageProps["data"]}> = ({Page, data}) => {
1876
- const params = useParams();
1877
- const [searchParams] = useSearchParams();
1878
- const location = useLocation();
1879
-
1880
- const pageProps = useMemo(() => {
1881
- return {
1882
- data,
1883
- params,
1884
- searchParams: Object.fromEntries(searchParams.entries()),
1885
- location: location.pathname
1886
- }
1887
- }, [data, params, searchParams, location.pathname])
1841
+ }
1888
1842
 
1889
- return <Page {...pageProps} />
1890
- }
1891
-
1892
- const App: React.FC<{data: PageProps["data"]}> = (props) => {
1893
- return (
1894
- <DevOverlay>
1895
- <RootLayout>
1896
- <meta charSet="utf-8" />
1897
- <meta name="viewport" content="width=device-width, initial-scale=1" />
1898
- <link rel="stylesheet" href="/__pylon/static/app.css" precedence="high" />
1899
- <Routes>
1900
- ${pageRoutes.map((route, index) => {
1901
- return `<Route key={${index}} index={${index === 0 ? "true" : "false"}} path="${route.slug}" element={
1902
- ${route.layouts.reduceRight(
1903
- (child, layoutPath, layoutIndex) => {
1904
- const layoutName = layoutMap[layoutPath];
1905
- return `<${layoutName}>${child}</${layoutName}>`;
1906
- },
1907
- `<InjectPageProps Page={${pageMap[route.pagePath]} as React.FC} data={props.data} />`
1908
- )}
1909
- } />`;
1910
- }).join("\n")}
1911
- </Routes>
1912
- </RootLayout>
1913
- </DevOverlay>
1914
- )
1843
+ const loader: __PYLON_ROUTER_INTERNALS_DO_NOT_USE.LoaderFunction = async ({ request }) => {
1844
+ if (
1845
+ request.headers.has('accept') &&
1846
+ request.headers.get('accept') === 'application/json'
1847
+ ) {
1848
+ // Skip the loader if the request is for JSON
1849
+ return null
1915
1850
  }
1916
-
1917
- export default App;
1918
- `;
1919
- return appComponent;
1920
- };
1851
+ const url = new URL(request.url)
1852
+ const headers = new Headers()
1853
+ headers.set('Accept', 'application/json')
1854
+ try {
1855
+ const response = await fetch(url, {
1856
+ method: 'GET',
1857
+ headers: headers,
1858
+ })
1859
+ const data = await response.json<object>()
1860
+ return data
1861
+ } catch (error) {
1862
+ return null
1863
+ }
1864
+ }
1865
+
1866
+ const RootLayout = (props: { children: React.ReactNode; [key: string]: any }) => {
1867
+ return (
1868
+ <Layout {...props}>
1869
+ <meta charSet="utf-8" />
1870
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
1871
+ <link rel="stylesheet" href="/__pylon/static/app.css" precedence="high" />
1872
+ {props.children}
1873
+ </Layout>
1874
+ )
1875
+ }
1876
+
1877
+ const NotFoundPage = () => {
1878
+ return <div>Page Not Found</div>
1879
+ }
1880
+
1881
+ const routes = ${serialize([rootRoute, notFoundRoute].filter(Boolean))}
1882
+
1883
+ export default routes
1884
+
1885
+ `;
1886
+ const slugs = `export default ${JSON.stringify(routeSlugs, null, 2)}`;
1887
+ return {
1888
+ routes,
1889
+ slugs
1890
+ };
1891
+ }
1921
1892
 
1922
1893
  // src/plugins/use-pages/build/index.ts
1923
1894
  import chokidar from "chokidar";
1924
- import fs6 from "fs/promises";
1895
+ import fs7 from "fs/promises";
1925
1896
  import esbuild from "esbuild";
1926
1897
 
1927
1898
  // src/plugins/use-pages/build/plugins/inject-app-hydration.ts
1928
1899
  import path5 from "path";
1929
- import fs3 from "fs/promises";
1900
+ import fs4 from "fs/promises";
1930
1901
  var injectAppHydrationPlugin = {
1931
1902
  name: "inject-hydration",
1932
1903
  setup(build2) {
1933
1904
  build2.onLoad({ filter: /.*/, namespace: "file" }, async (args) => {
1934
1905
  if (args.path === path5.resolve(process.cwd(), ".pylon", "app.tsx")) {
1935
- let contents = await fs3.readFile(args.path, "utf-8");
1906
+ let contents = await fs4.readFile(args.path, "utf-8");
1936
1907
  const clientPath = path5.resolve(process.cwd(), ".pylon/client");
1937
1908
  const pathToClient = path5.relative(path5.dirname(args.path), clientPath);
1938
1909
  contents += `
1939
1910
  import {hydrateRoot} from 'react-dom/client'
1940
1911
  import * as client from './${pathToClient}'
1941
- import { __PYLON_ROUTER_INTERNALS_DO_NOT_USE, DevOverlay, onCaughtErrorProd, onRecoverableErrorProd, onUncaughtErrorProd } from '@getcronit/pylon/pages';
1942
- const {BrowserRouter} = __PYLON_ROUTER_INTERNALS_DO_NOT_USE
1912
+ import { __PYLON_ROUTER_INTERNALS_DO_NOT_USE, __PYLON_INTERNALS_DO_NOT_USE, DevOverlay, onCaughtErrorProd, onRecoverableErrorProd, onUncaughtErrorProd } from '@getcronit/pylon/pages';
1913
+ const {createBrowserRouter, RouterProvider} = __PYLON_ROUTER_INTERNALS_DO_NOT_USE
1914
+ const {DataClientProvider} = __PYLON_INTERNALS_DO_NOT_USE
1943
1915
  import React, {useMemo} from 'react'
1944
1916
 
1945
- const pylonData = window.__PYLON_DATA__
1946
-
1947
- const AppLoader = (props: {
1948
- client: any
1949
- pylonData: {
1950
- cacheSnapshot?: any
1951
- }
1952
- App: React.FC<{
1953
- data: PageProps['data']
1954
- }>
1955
- Router: React.FC<any>
1956
- routerProps: any
1957
- }) => {
1958
- props.client.useHydrateCache({cacheSnapshot: props.pylonData.cacheSnapshot})
1959
-
1960
- const data = props.client.useQuery()
1961
- const page = useMemo(() => {
1962
- const page = (
1963
- <props.App data={data} />
1964
- )
1965
-
1966
- return page
1967
- }, [props])
1968
-
1969
- return <props.Router {...props.routerProps}>{page}</props.Router>
1970
- }
1971
-
1972
-
1973
-
1917
+ const router = createBrowserRouter(routes)
1974
1918
 
1975
1919
  hydrateRoot(
1976
- document,
1977
- <AppLoader Router={BrowserRouter} client={client} pylonData={pylonData} App={App} />, {
1978
- onCaughtError: onCaughtErrorProd,
1979
- onRecoverableError: onRecoverableErrorProd,
1980
- onUncaughtError: onUncaughtErrorProd,
1920
+ document,
1921
+ <DevOverlay>
1922
+ <DataClientProvider client={client}>
1923
+ <RouterProvider router={router} />
1924
+ </DataClientProvider>
1925
+ </DevOverlay>,
1926
+ {
1927
+ onCaughtError: onCaughtErrorProd,
1928
+ onRecoverableError: onRecoverableErrorProd,
1929
+ onUncaughtError: onUncaughtErrorProd
1981
1930
  }
1982
1931
  )
1983
1932
  `;
@@ -1993,7 +1942,7 @@ var injectAppHydrationPlugin = {
1993
1942
  // src/plugins/use-pages/build/plugins/image-plugin.ts
1994
1943
  import { createHash as createHash2 } from "crypto";
1995
1944
  import path6 from "path";
1996
- import fs4 from "fs/promises";
1945
+ import fs5 from "fs/promises";
1997
1946
  var imagePlugin = {
1998
1947
  name: "image-plugin",
1999
1948
  setup(build2) {
@@ -2006,11 +1955,11 @@ var imagePlugin = {
2006
1955
  const filePath = path6.resolve(args.resolveDir, args.path);
2007
1956
  const fileName = path6.basename(filePath);
2008
1957
  const extname = path6.extname(filePath);
2009
- const hash = createHash2("md5").update(filePath + await fs4.readFile(filePath)).digest("hex").slice(0, 8);
1958
+ const hash = createHash2("md5").update(filePath + await fs5.readFile(filePath)).digest("hex").slice(0, 8);
2010
1959
  const newFilename = `${fileName}-${hash}${extname}`;
2011
1960
  const newFilePath = path6.join(outdir, "media", newFilename);
2012
- await fs4.mkdir(path6.dirname(newFilePath), { recursive: true });
2013
- await fs4.copyFile(filePath, newFilePath);
1961
+ await fs5.mkdir(path6.dirname(newFilePath), { recursive: true });
1962
+ await fs5.copyFile(filePath, newFilePath);
2014
1963
  return {
2015
1964
  path: newFilePath,
2016
1965
  namespace: "image"
@@ -2048,7 +1997,7 @@ var imagePlugin = {
2048
1997
  };
2049
1998
 
2050
1999
  // src/plugins/use-pages/build/plugins/postcss-plugin.ts
2051
- import fs5 from "fs/promises";
2000
+ import fs6 from "fs/promises";
2052
2001
  import loadConfig from "postcss-load-config";
2053
2002
  import postcss from "postcss";
2054
2003
  var postcssPlugin = {
@@ -2056,7 +2005,7 @@ var postcssPlugin = {
2056
2005
  setup(build2) {
2057
2006
  build2.onLoad({ filter: /.css$/, namespace: "file" }, async (args) => {
2058
2007
  const { plugins, options } = await loadConfig();
2059
- const css = await fs5.readFile(args.path, "utf-8");
2008
+ const css = await fs6.readFile(args.path, "utf-8");
2060
2009
  const result = await postcss(plugins).process(css, {
2061
2010
  ...options,
2062
2011
  from: args.path
@@ -2074,32 +2023,27 @@ var DIST_STATIC_DIR = path7.join(process.cwd(), ".pylon/__pylon/static");
2074
2023
  var DIST_PAGES_DIR = path7.join(process.cwd(), ".pylon/__pylon/pages");
2075
2024
  async function updateFileIfChanged(path8, newContent) {
2076
2025
  try {
2077
- const currentContent = await fs6.readFile(path8);
2026
+ const currentContent = await fs7.readFile(path8);
2078
2027
  if (currentContent.equals(newContent)) {
2079
2028
  return false;
2080
2029
  }
2081
2030
  } catch (err) {
2082
2031
  if (err.code !== "ENOENT") throw err;
2083
2032
  }
2084
- await fs6.writeFile(path8, newContent);
2033
+ await fs7.writeFile(path8, newContent);
2085
2034
  return true;
2086
2035
  }
2087
2036
  var build = async () => {
2088
2037
  const buildAppFile = async () => {
2089
- const pagesRoutes = await getPageRoutes();
2090
- const appContent = generateAppFile(pagesRoutes);
2091
- const pagesFile = path7.resolve(process.cwd(), ".pylon", "pages.json");
2038
+ const appFiles = makeAppFiles();
2092
2039
  await updateFileIfChanged(
2093
- pagesFile,
2094
- Buffer.from(JSON.stringify(pagesRoutes, null, 2))
2040
+ path7.resolve(process.cwd(), ".pylon", "app.tsx"),
2041
+ Buffer.from(appFiles.routes)
2095
2042
  );
2096
- const appFilePath = path7.resolve(process.cwd(), ".pylon", "app.tsx");
2097
- const state = await updateFileIfChanged(
2098
- appFilePath,
2099
- Buffer.from(appContent)
2043
+ await updateFileIfChanged(
2044
+ path7.resolve(process.cwd(), ".pylon", "slugs.js"),
2045
+ Buffer.from(appFiles.slugs)
2100
2046
  );
2101
- if (state) {
2102
- }
2103
2047
  };
2104
2048
  const copyPublicDir = async () => {
2105
2049
  const publicDir = path7.resolve(process.cwd(), "public");
@@ -2110,9 +2054,9 @@ var build = async () => {
2110
2054
  "public"
2111
2055
  );
2112
2056
  try {
2113
- await fs6.access(publicDir);
2114
- await fs6.mkdir(pylonPublicDir, { recursive: true });
2115
- await fs6.cp(publicDir, pylonPublicDir, { recursive: true });
2057
+ await fs7.access(publicDir);
2058
+ await fs7.mkdir(pylonPublicDir, { recursive: true });
2059
+ await fs7.cp(publicDir, pylonPublicDir, { recursive: true });
2116
2060
  } catch (err) {
2117
2061
  if (err.code !== "ENOENT") throw err;
2118
2062
  }
@@ -2129,12 +2073,12 @@ var build = async () => {
2129
2073
  "__pylon",
2130
2074
  "static"
2131
2075
  );
2132
- await fs6.mkdir(pylonCssDestDir, { recursive: true });
2133
- await fs6.cp(
2076
+ await fs7.mkdir(pylonCssDestDir, { recursive: true });
2077
+ await fs7.cp(
2134
2078
  path7.join(pylonCssPathDir, "index.css"),
2135
2079
  path7.join(pylonCssDestDir, "pylon.css")
2136
2080
  );
2137
- await fs6.cp(
2081
+ await fs7.cp(
2138
2082
  path7.join(pylonCssPathDir, "index.css.map"),
2139
2083
  path7.join(pylonCssDestDir, "pylon.css.map")
2140
2084
  );
@@ -2145,7 +2089,7 @@ var build = async () => {
2145
2089
  build2.onEnd(async (result) => {
2146
2090
  await Promise.all(
2147
2091
  result.outputFiles.map(async (file) => {
2148
- await fs6.mkdir(path7.dirname(file.path), { recursive: true });
2092
+ await fs7.mkdir(path7.dirname(file.path), { recursive: true });
2149
2093
  await updateFileIfChanged(file.path, file.contents);
2150
2094
  })
2151
2095
  );