gemi 0.49.0-rc.2 → 0.49.0-rc.4

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/app/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{o as a,p as b}from"../chunk-qz5jz43n.js";import"../chunk-r3hacxdr.js";import"../chunk-x5f4e2fp.js";import"../chunk-p5r0t9jh.js";import"../chunk-xkrthw08.js";import"../chunk-4z53shav.js";import"../chunk-m0earq80.js";import"../chunk-f18weffa.js";export{b as prismaExtension,a as App};
2
+ import{o as a,p as b}from"../chunk-p2k3cckx.js";import"../chunk-j0c51zzj.js";import"../chunk-x5f4e2fp.js";import"../chunk-p5r0t9jh.js";import"../chunk-xkrthw08.js";import"../chunk-4z53shav.js";import"../chunk-m0earq80.js";import"../chunk-f18weffa.js";export{b as prismaExtension,a as App};
3
3
 
4
4
  //# debugId=15EBDBCE0B2D702364756E2164756E21
package/dist/bin/gemi.js CHANGED
@@ -51537,6 +51537,7 @@ class ServerQueryStore {
51537
51537
  shipped = new Set;
51538
51538
  requestStartedAt = performance.now();
51539
51539
  renderStartedAt = null;
51540
+ discoveryHintsMuted = false;
51540
51541
  constructor(fetcher) {
51541
51542
  this.fetcher = fetcher;
51542
51543
  }
@@ -51551,6 +51552,27 @@ class ServerQueryStore {
51551
51552
  this.renderStartedAt = performance.now();
51552
51553
  }
51553
51554
  }
51555
+ muteDiscoveryHints() {
51556
+ this.discoveryHintsMuted = true;
51557
+ }
51558
+ maybeLogLateDiscovery(entry) {
51559
+ if (!entry.lateBy || this.discoveryHintsMuted)
51560
+ return;
51561
+ if (entry.status !== "resolved")
51562
+ return;
51563
+ if (false)
51564
+ ;
51565
+ let size = "";
51566
+ try {
51567
+ const bytes = JSON.stringify(entry.data)?.length ?? 0;
51568
+ size = bytes >= 1024 ? `${(bytes / 1024).toFixed(1)} kB` : `${bytes} B`;
51569
+ } catch {
51570
+ size = "an unserializable payload";
51571
+ }
51572
+ const duration = (entry.settledAt ?? 0) - entry.startedAt;
51573
+ const searchHint = entry.variantKey ? `, { search: ${JSON.stringify(Object.fromEntries(new URLSearchParams(entry.variantKey)))} }` : "";
51574
+ console.warn(`[gemi] useQuery("${entry.patternPath}") was discovered ${entry.lateBy}ms into the ` + `server render \u2014 under a suspended segment, so its fetch (${duration}ms, resolved ` + `${size}) could not overlap the others. It still streamed. If the query belongs on ` + `this route, \`Query.prefetch("${entry.patternPath}"${searchHint})\` in the view ` + `handler starts it at request time \u2014 but note prefetched data is also awaited by and ` + `serialized into every client-side navigation payload for the route, so weigh that ` + `against the ${size}. If the data is only needed conditionally (a closed popover, a ` + `hidden tab), \`{ lazy: true }\` + \`trigger()\` avoids running it here at all. ` + `\`Query.noPrefetch()\` in the handler marks the omission intentional and silences ` + `this hint for the route.`);
51575
+ }
51554
51576
  read(path, variantKey) {
51555
51577
  return this.entries.get(this.keyFor(path, variantKey));
51556
51578
  }
@@ -51565,11 +51587,11 @@ class ServerQueryStore {
51565
51587
  const existing = this.entries.get(key);
51566
51588
  if (existing)
51567
51589
  return existing;
51568
- if (source === "render" && this.renderStartedAt !== null && true) {
51590
+ let lateBy;
51591
+ if (source === "render" && this.renderStartedAt !== null) {
51569
51592
  const delay = Math.round(performance.now() - this.renderStartedAt);
51570
51593
  if (delay > LATE_DISCOVERY_THRESHOLD_MS) {
51571
- const searchHint = variantKey ? `, { search: ${JSON.stringify(Object.fromEntries(searchParams))} }` : "";
51572
- console.warn(`[gemi] useQuery("${patternPath}") started ${delay}ms into the server render \u2014 ` + `it was discovered under a suspended segment, so its fetch could not overlap ` + `the others. It still streams, but \`Query.prefetch("${patternPath}"${searchHint})\` ` + `in the route's view handler would start it at request time.`);
51594
+ lateBy = delay;
51573
51595
  }
51574
51596
  }
51575
51597
  let settle;
@@ -51578,7 +51600,9 @@ class ServerQueryStore {
51578
51600
  });
51579
51601
  const entry = {
51580
51602
  path,
51603
+ patternPath,
51581
51604
  variantKey,
51605
+ lateBy,
51582
51606
  status: "pending",
51583
51607
  promise,
51584
51608
  source,
@@ -51593,6 +51617,7 @@ class ServerQueryStore {
51593
51617
  entry.error = error;
51594
51618
  }).then(() => {
51595
51619
  entry.settledAt = this.elapsed();
51620
+ this.maybeLogLateDiscovery(entry);
51596
51621
  if (this.settleListener) {
51597
51622
  this.settleListener(entry);
51598
51623
  } else {
@@ -68611,6 +68636,7 @@ class ViewRouterServiceContainer extends ServiceContainer {
68611
68636
  pathname,
68612
68637
  serverQueries,
68613
68638
  userAgent,
68639
+ noStream,
68614
68640
  url,
68615
68641
  user,
68616
68642
  viewData,
@@ -68701,7 +68727,7 @@ class ViewRouterServiceContainer extends ServiceContainer {
68701
68727
  serverQueries.markRenderStart();
68702
68728
  const deadline = new AbortController;
68703
68729
  const deadlineTimer = setTimeout(() => deadline.abort(), STREAM_DEADLINE_MS);
68704
- const isBot = isBotUserAgent(userAgent);
68730
+ const settled = isBotUserAgent(userAgent) || noStream;
68705
68731
  try {
68706
68732
  const stream = await renderToReadableStream(import_react.createElement(import_react.Fragment, {
68707
68733
  children: [
@@ -68724,7 +68750,7 @@ class ViewRouterServiceContainer extends ServiceContainer {
68724
68750
  bootstrapScriptContent: `window.__GEMI_DATA__ = ${JSON.stringify(result.data)}; window.loaders=${loaders}`,
68725
68751
  bootstrapModules,
68726
68752
  signal: deadline.signal,
68727
- ...isBot ? { progressiveChunkSize: Number.MAX_SAFE_INTEGER } : {},
68753
+ ...settled ? { progressiveChunkSize: Number.MAX_SAFE_INTEGER } : {},
68728
68754
  onError(error) {
68729
68755
  if (true) {
68730
68756
  console.error(error);
@@ -68732,7 +68758,7 @@ class ViewRouterServiceContainer extends ServiceContainer {
68732
68758
  }
68733
68759
  });
68734
68760
  stream.allReady.catch(() => {}).finally(() => clearTimeout(deadlineTimer));
68735
- if (isBot) {
68761
+ if (settled) {
68736
68762
  await stream.allReady.catch(() => {});
68737
68763
  }
68738
68764
  return new Response(injectQueryPayloads(stream, serverQueries), {
@@ -68788,6 +68814,7 @@ class ViewRouterServiceContainer extends ServiceContainer {
68788
68814
  let currentPathName = null;
68789
68815
  let params = {};
68790
68816
  let partial = null;
68817
+ let noStream = false;
68791
68818
  try {
68792
68819
  const match = matchViewRoute(this.flatViewRoutes, urlPathname);
68793
68820
  if (match) {
@@ -68795,6 +68822,7 @@ class ViewRouterServiceContainer extends ServiceContainer {
68795
68822
  params = match.params;
68796
68823
  handlers = match.route.exec;
68797
68824
  middlewares = match.route.middleware;
68825
+ noStream = middlewares.includes("no-stream");
68798
68826
  if (isViewDataRequest && this.service.partialRendering) {
68799
68827
  const from = req.headers.get(PARTIAL_RENDER_HEADER);
68800
68828
  const plan = resolvePartialRender({
@@ -68934,6 +68962,7 @@ class ViewRouterServiceContainer extends ServiceContainer {
68934
68962
  pathname: url.pathname,
68935
68963
  serverQueries: ctx.serverQueries,
68936
68964
  userAgent: req.headers.get("user-agent"),
68965
+ noStream,
68937
68966
  url,
68938
68967
  user,
68939
68968
  viewData,
@@ -69981,5 +70010,5 @@ program.command("app:route-manifest").action(async () => {
69981
70010
  });
69982
70011
  program.parse();
69983
70012
 
69984
- //# debugId=98CFC1ED06DD2FFA64756E2164756E21
70013
+ //# debugId=4B7C38AF6FD3DF1064756E2164756E21
69985
70014
  //# sourceMappingURL=gemi.js.map