@nifrajs/web-solid 5.9.0 → 5.11.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.
package/src/router.ts CHANGED
@@ -1,13 +1,12 @@
1
1
  import type { InferOutput, StandardSchemaV1 } from "@nifrajs/core/server"
2
2
  // `import type` + a local re-export, NOT `export type { … } from "@nifrajs/web"`: that form leaves a
3
3
  // bare `import "@nifrajs/web"` in the output, which pulls the server graph into the browser under
4
- // Vite's dev server. Sourced from the ROOT so the generated `RouteSearch` augmentation applies.
4
+ // Vite's dev server. Sourced from the ROOT so the generated `RouteTable` augmentation applies.
5
5
  import type {
6
6
  Blocker,
7
7
  BlockerFunction,
8
8
  BlockerState,
9
9
  NavigateFunction,
10
- RenderProps,
11
10
  UIMatch,
12
11
  } from "@nifrajs/web"
13
12
  // `/client`, not the root - these are DOM values, and the root's graph carries the
@@ -23,19 +22,16 @@ import { navigateNow } from "@nifrajs/web/internal/navigate-runtime"
23
22
  * DOM-free bridges (`getBrowserNavigate` / `registerBlocker`, populated by `installHistory`); `useSearch`
24
23
  * reads the accessor `compose` provides on SSR + client mount alike. Imports only `solid-js`. No JSX.
25
24
  */
26
- import {
27
- type Accessor,
28
- type Context,
29
- createContext,
30
- createMemo,
31
- createSignal,
32
- onCleanup,
33
- useContext,
34
- } from "solid-js"
25
+ import { type Accessor, createMemo, createSignal, onCleanup, useContext } from "solid-js"
35
26
  import { PageContext } from "./page-visibility.ts"
27
+ import { RenderPropsContext, SearchContext } from "./router-context.ts"
36
28
 
29
+ export { href, rawHref } from "@nifrajs/web/client"
37
30
  export { onPageHide, onPageShow, usePageVisibility } from "./page-visibility.ts"
31
+ export type { RouteSlotController, RouteSlotProps } from "./route-slot.tsx"
32
+ export { RouteSlot, useRouteSlot } from "./route-slot.tsx"
38
33
  export type { Blocker, BlockerFunction, BlockerState, NavigateFunction, UIMatch }
34
+ export { RenderPropsContext, SearchContext }
39
35
 
40
36
  // Frozen empty search + a stable accessor for a `useSearch` used outside a nifra route tree.
41
37
  const EMPTY_SEARCH: Readonly<Record<string, unknown>> = Object.freeze({})
@@ -48,22 +44,6 @@ const EMPTY_SEARCH_ACCESSOR: Accessor<Record<string, unknown>> = () => EMPTY_SEA
48
44
  * code under Bun provides; route modules through Vite's SSR runner read), and Solid matches provider
49
45
  * to reader by context object identity - two `createContext` results make `useSearch` SSR-render its
50
46
  * empty default in dev. */
51
- const SEARCH_CONTEXT_SLOT = Symbol.for("nifra.web-solid.search-context")
52
- const searchContextSlot = globalThis as {
53
- [SEARCH_CONTEXT_SLOT]?: Context<Accessor<Record<string, unknown>> | undefined>
54
- }
55
- export const SearchContext =
56
- searchContextSlot[SEARCH_CONTEXT_SLOT] ?? createContext<Accessor<Record<string, unknown>>>()
57
- searchContextSlot[SEARCH_CONTEXT_SLOT] = SearchContext
58
-
59
- /** The props `compose` rendered the chain with - getters over the router snapshot on the client - which
60
- * {@link useMatches} reads. A `globalThis` singleton for the same reason as {@link SearchContext}. */
61
- const PROPS_CONTEXT_SLOT = Symbol.for("nifra.web-solid.props-context")
62
- const propsContextSlot = globalThis as { [PROPS_CONTEXT_SLOT]?: Context<RenderProps | undefined> }
63
- export const RenderPropsContext =
64
- propsContextSlot[PROPS_CONTEXT_SLOT] ?? createContext<RenderProps>()
65
- propsContextSlot[PROPS_CONTEXT_SLOT] = RenderPropsContext
66
-
67
47
  const NO_MATCHES: readonly UIMatch[] = Object.freeze([])
68
48
 
69
49
  /**
@@ -104,7 +84,7 @@ export function useSearch<Schema extends StandardSchemaV1 | undefined = undefine
104
84
  >
105
85
  }
106
86
 
107
- /** Get the {@link NavigateFunction} (a string path, a history delta, or a typed `{ to, search }` object).
87
+ /** Get the {@link NavigateFunction} (an `Href` from `href()` or `rawHref()`, or a history delta).
108
88
  * Resolves the browser navigate at call time, so it works as soon as `installHistory` has run and no-ops
109
89
  * before then / on the server. */
110
90
  export function useNavigate(): NavigateFunction {