gemi 0.58.0 → 0.58.1

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.
@@ -3,6 +3,52 @@ export declare function loadViewModule(name: string): Promise<any>;
3
3
  export declare function subscribeViewModules(listener: () => void): () => void;
4
4
  export declare function getViewModule(name: string): Record<string, any>;
5
5
  declare let viewImportMap: Record<string, ReturnType<typeof lazy>> | null;
6
+ /**
7
+ * Resolves once the views the document was server-rendered with are in the
8
+ * registry — which is what `init` waits for before it hydrates.
9
+ *
10
+ * Hydrating before then is what made a cold load blank its own content. The
11
+ * server renders each route segment through a real component, so the shell
12
+ * ships complete `<Suspense>` boundaries; the browser renders the same
13
+ * segments through `lazy()`, so on the first client render every one of them
14
+ * suspends. React keeps the server HTML up while a boundary is merely
15
+ * suspended, but the moment any update reaches one — the module registry
16
+ * announcing the chunk, an effect, a settling query — it gives up on that
17
+ * boundary and shows the fallback instead, which for a view without a
18
+ * `Loading` export is `null`. The page then sits with its layout and no
19
+ * content until the chunk's `import()` and dictionaries resolve.
20
+ *
21
+ * What this buys is NOT a synchronous `lazy()`. `lazy` suspends on its first
22
+ * render no matter what: the initializer calls the ctor, attaches `.then`,
23
+ * and re-reads a status its callback only sets a microtask later, so even an
24
+ * already-settled promise goes to `Pending` and throws. The render still
25
+ * suspends here — it just suspends *untouched*. `loadViewModule` notifies its
26
+ * listeners only on a view's FIRST registration, so once the module is in
27
+ * `viewModules` the call `lazy` makes during hydration is a silent one, the
28
+ * boundary sees no update, and React keeps the server HTML until it settles.
29
+ *
30
+ * The invariant to preserve, then, is "no first registration for a mounted
31
+ * view happens during hydration" — not anything about how `lazy` resolves.
32
+ * Notifying on every call, or memoizing the promise so the `isNew` guard
33
+ * stops being the discriminator, would reintroduce the flash while leaving
34
+ * this preload apparently intact.
35
+ *
36
+ * It is not free. The view chunks themselves are already `modulepreload`ed by
37
+ * the shell, but `loadViewModule` also awaits `preloadDictionaries`, and
38
+ * dictionary locale chunks are dynamic imports, which `collectModulePreloads`
39
+ * deliberately leaves out of those hints. So hydration is gated on a
40
+ * serially-discovered round trip — view chunk, parse, dictionary chunk — and
41
+ * the layout's own handlers stay dead across it. That wait is deliberate
42
+ * rather than incidental: a view whose dictionary is still in flight suspends
43
+ * on `use()` inside this same boundary, which is the same blank arriving by a
44
+ * different route. Warming the current locale's dictionaries from the shell
45
+ * would buy the interactivity back; awaiting less here would not.
46
+ *
47
+ * Never rejects and never waits forever: a chunk that fails or hangs must
48
+ * still leave the app to hydrate and surface the error through the route's
49
+ * error boundary.
50
+ */
51
+ export declare const initialViewModulesReady: Promise<unknown>;
6
52
  export declare const ComponentsContext: import("react").Context<{
7
53
  viewImportMap: Record<string, import("react").LazyExoticComponent<import("react").ComponentType<any>>>;
8
54
  getViewModule: typeof getViewModule;
@@ -1 +1 @@
1
- {"version":3,"file":"ComponentContext.d.ts","sourceRoot":"","sources":["../../client/ComponentContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,IAAI,EAAW,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AA8B7E,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAgCzD;AAcD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,IAAI,cAKxD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,uBAEzC;AAED,QAAA,IAAI,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,IAAW,CAAC;AAUzE,eAAO,MAAM,iBAAiB;;;EAG5B,CAAC;AAEH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,iBAAiB,CAAC;IACvB,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;CAC/C,CAAC,4CAiBH,CAAC"}
1
+ {"version":3,"file":"ComponentContext.d.ts","sourceRoot":"","sources":["../../client/ComponentContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,IAAI,EAAW,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AA8B7E,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAuCzD;AAcD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,IAAI,cAKxD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,uBAEzC;AAED,QAAA,IAAI,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,IAAW,CAAC;AAqBzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,uBAAuB,EAAE,OAAO,CAAC,OAAO,CAY9B,CAAC;AAaxB,eAAO,MAAM,iBAAiB;;;EAG5B,CAAC;AAEH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,iBAAiB,CAAC;IACvB,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;CAC/C,CAAC,4CAiBH,CAAC"}
@@ -1,4 +1,4 @@
1
- import { B as QueryError, C as I18nContext, D as useLocation, E as ServerDataProvider, F as applyParams$1, I as QueryConfigContext, L as QueryManagerContext, M as RouteStateContext, N as RouteStateProvider, P as toVariantKey, R as QueryManagerProvider, S as useNavigate, T as ServerDataContext, V as Subject, _ as setActiveLocale, a as m, b as useRoute, c as ClientRouterContext, d as ComponentsProvider, f as loadViewModule, g as registerDictionary, h as loadDictionaryForRender, i as WebSocketContextProvider, j as useParams, k as Action, l as ClientRouterProvider, m as loadDictionary, n as useTheme, o as RouteTransitionProvider, p as subscribeViewModules, r as WebSocketContext, s as useRouteTransition, t as ThemeProvider, u as ComponentsContext, v as readRoutePayload, w as I18nProvider, x as useSearchParams, y as routeDataUrl, z as DEFAULT_STALE_TIME } from "../chunks/ThemeProvider-li1J_igh.js";
1
+ import { A as Action, B as DEFAULT_STALE_TIME, C as useNavigate, D as ServerDataProvider, E as ServerDataContext, F as toVariantKey, H as Subject, I as applyParams$1, L as QueryConfigContext, M as useParams, N as RouteStateContext, O as useLocation, P as RouteStateProvider, R as QueryManagerContext, S as useSearchParams, T as I18nProvider, V as QueryError, _ as registerDictionary, a as m, b as routeDataUrl, c as ClientRouterContext, d as ComponentsProvider, f as initialViewModulesReady, g as loadDictionaryForRender, h as loadDictionary, i as WebSocketContextProvider, l as ClientRouterProvider, m as subscribeViewModules, n as useTheme, o as RouteTransitionProvider, p as loadViewModule, r as WebSocketContext, s as useRouteTransition, t as ThemeProvider, u as ComponentsContext, v as setActiveLocale, w as I18nContext, x as useRoute, y as readRoutePayload, z as QueryManagerProvider } from "../chunks/ThemeProvider-ByU4BQdL.js";
2
2
  import { Fragment, StrictMode, Suspense, createContext, createElement, isValidElement, memo, use, useCallback, useContext, useDeferredValue, useEffect, useMemo, useRef, useState, useSyncExternalStore, useTransition } from "react";
3
3
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
4
4
  import { createRoot as createRoot$1, hydrateRoot } from "react-dom/client";
@@ -1352,7 +1352,14 @@ var StackTrace = () => {
1352
1352
  };
1353
1353
  function init(RootLayout, options = {}) {
1354
1354
  if (typeof window !== "undefined" && window.render_error) createRoot$1(document.body).render(/* @__PURE__ */ jsx(StackTrace, {}));
1355
- else hydrateRoot(document, /* @__PURE__ */ jsxs(Fragment$1, { children: [
1355
+ else initialViewModulesReady.then(() => hydrate(RootLayout, options)).catch((e) => {
1356
+ setTimeout(() => {
1357
+ throw e;
1358
+ });
1359
+ });
1360
+ }
1361
+ function hydrate(RootLayout, options) {
1362
+ hydrateRoot(document, /* @__PURE__ */ jsxs(Fragment$1, { children: [
1356
1363
  /* @__PURE__ */ jsx(Fragment$1, {}),
1357
1364
  /* @__PURE__ */ jsx(Fragment$1, {}),
1358
1365
  /* @__PURE__ */ jsx(m, {