akanjs 3.3.0-rc.35 → 3.3.0-rc.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
3
- "version": "3.3.0-rc.35",
3
+ "version": "3.3.0-rc.36",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -0,0 +1,2 @@
1
+ import type { PathContextType } from "akanjs/client";
2
+ export declare const isSamePathValue: (shown: PathContextType, next: PathContextType) => boolean;
@@ -2,14 +2,14 @@
2
2
  export declare const badgeRecipe: (variants?: Omit<({
3
3
  size?: "lg" | "md" | "sm" | "xs" | undefined;
4
4
  outline?: boolean | undefined;
5
- variant?: "default" | "error" | "info" | "warning" | "success" | "primary" | "outline" | "secondary" | "accent" | "neutral" | undefined;
5
+ variant?: "error" | "default" | "info" | "warning" | "success" | "primary" | "outline" | "secondary" | "accent" | "neutral" | undefined;
6
6
  } & {
7
7
  class?: import("tailwind-variants/lite").ClassValue;
8
8
  className?: never;
9
9
  }) | ({
10
10
  size?: "lg" | "md" | "sm" | "xs" | undefined;
11
11
  outline?: boolean | undefined;
12
- variant?: "default" | "error" | "info" | "warning" | "success" | "primary" | "outline" | "secondary" | "accent" | "neutral" | undefined;
12
+ variant?: "error" | "default" | "info" | "warning" | "success" | "primary" | "outline" | "secondary" | "accent" | "neutral" | undefined;
13
13
  } & {
14
14
  class?: never;
15
15
  className?: import("tailwind-variants/lite").ClassValue;
@@ -2,7 +2,7 @@
2
2
  export declare const buttonRecipe: (variants?: Omit<({
3
3
  size?: "xl" | "lg" | "md" | "sm" | "xs" | "icon" | undefined;
4
4
  outline?: boolean | undefined;
5
- variant?: "default" | "link" | "info" | "warning" | "success" | "destructive" | "primary" | "outline" | "secondary" | "accent" | "neutral" | "ghost" | undefined;
5
+ variant?: "link" | "default" | "info" | "warning" | "success" | "destructive" | "primary" | "outline" | "secondary" | "accent" | "neutral" | "ghost" | undefined;
6
6
  shape?: "default" | "circle" | "square" | undefined;
7
7
  } & {
8
8
  class?: import("tailwind-variants/lite").ClassValue;
@@ -10,7 +10,7 @@ export declare const buttonRecipe: (variants?: Omit<({
10
10
  }) | ({
11
11
  size?: "xl" | "lg" | "md" | "sm" | "xs" | "icon" | undefined;
12
12
  outline?: boolean | undefined;
13
- variant?: "default" | "link" | "info" | "warning" | "success" | "destructive" | "primary" | "outline" | "secondary" | "accent" | "neutral" | "ghost" | undefined;
13
+ variant?: "link" | "default" | "info" | "warning" | "success" | "destructive" | "primary" | "outline" | "secondary" | "accent" | "neutral" | "ghost" | undefined;
14
14
  shape?: "default" | "circle" | "square" | undefined;
15
15
  } & {
16
16
  class?: never;
@@ -2,14 +2,14 @@
2
2
  export declare const inputRecipe: (variants?: Omit<({
3
3
  kind?: "field" | "select" | "area" | undefined;
4
4
  size?: "xl" | "lg" | "md" | "sm" | "xs" | undefined;
5
- tone?: "default" | "error" | "primary" | undefined;
5
+ tone?: "error" | "default" | "primary" | undefined;
6
6
  } & {
7
7
  class?: import("tailwind-variants/lite").ClassValue;
8
8
  className?: never;
9
9
  }) | ({
10
10
  kind?: "field" | "select" | "area" | undefined;
11
11
  size?: "xl" | "lg" | "md" | "sm" | "xs" | undefined;
12
- tone?: "default" | "error" | "primary" | undefined;
12
+ tone?: "error" | "default" | "primary" | undefined;
13
13
  } & {
14
14
  class?: never;
15
15
  className?: import("tailwind-variants/lite").ClassValue;
@@ -17,8 +17,8 @@ export declare const useCsrRefs: () => {
17
17
  pageContentRef: import("react").RefObject<HTMLDivElement | null>;
18
18
  prevPageContentRef: import("react").RefObject<HTMLDivElement | null>;
19
19
  onBack: import("react").RefObject<{
20
- none?: (() => Promise<void>) | undefined;
21
20
  stack?: (() => Promise<void>) | undefined;
21
+ none?: (() => Promise<void>) | undefined;
22
22
  fade?: (() => Promise<void>) | undefined;
23
23
  bottomUp?: (() => Promise<void>) | undefined;
24
24
  scaleOut?: (() => Promise<void>) | undefined;
@@ -54,6 +54,7 @@ import { readRscRoutePatch, subscribeRscRoutePatch } from "../../client/rscRoute
54
54
  import { FrameRootVars } from "../../webkit/FrameRootVars";
55
55
  import { useTransitionStore } from "../../webkit/useTransitionStore";
56
56
  import { getFrameCssVars, isResponsiveFrame } from "./Common";
57
+ import { isSamePathValue } from "./isSamePathValue";
57
58
  import { Messages } from "./Messages";
58
59
  import { Reconnect } from "./Reconnect";
59
60
 
@@ -185,12 +186,13 @@ export const ClientPathWrapper = ({
185
186
  renderLayouts: [],
186
187
  };
187
188
  const csr = useCsr();
189
+ const isPending = pageType === "pending";
188
190
  const registerFrameSlot = useCallback(
189
191
  (slot: Parameters<NonNullable<typeof csr.registerFrameSlot>>[1]) =>
190
192
  typeof csr.registerFrameSlot === "function"
191
- ? csr.registerFrameSlot(pathRoute.path, slot, pageType === "pending" ? "pending" : "active")
193
+ ? csr.registerFrameSlot(pathRoute.path, slot, isPending ? "pending" : "active")
192
194
  : () => undefined,
193
- [csr.registerFrameSlot, pathRoute.path, pageType],
195
+ [csr.registerFrameSlot, pathRoute.path, isPending],
194
196
  );
195
197
 
196
198
  const [gestureEnabled, setGestureEnabled] = useState(true);
@@ -247,8 +249,11 @@ export const ClientPathWrapper = ({
247
249
  registerFrameSlot,
248
250
  ],
249
251
  );
252
+
253
+ const shownValue = useRef(pathValue);
254
+ if (activity !== "hidden" && !isSamePathValue(shownValue.current, pathValue)) shownValue.current = pathValue;
250
255
  return (
251
- <pathContext.Provider value={pathValue}>
256
+ <pathContext.Provider value={shownValue.current}>
252
257
  <pageActivityContext.Provider value={pageActivity}>
253
258
  <Frame
254
259
  {...bindProps}
@@ -0,0 +1,13 @@
1
+ import type { PathContextType } from "akanjs/client";
2
+
3
+ export const isSamePathValue = (shown: PathContextType, next: PathContextType) =>
4
+ shown.pageKey === next.pageKey &&
5
+ shown.location.href === next.location.href &&
6
+ shown.location.hash === next.location.hash &&
7
+ shown.location.pathRoute.path === next.location.pathRoute.path &&
8
+ shown.location.pathRoute.renderPage === next.location.pathRoute.renderPage &&
9
+ shown.location.entryId === next.location.entryId &&
10
+ shown.followsRouter === next.followsRouter &&
11
+ shown.prefix === next.prefix &&
12
+ shown.gestureEnabled === next.gestureEnabled &&
13
+ shown.registerFrameSlot === next.registerFrameSlot;
@@ -241,11 +241,19 @@ export const useCsrNavigation = (input: CsrNavigationInput) => {
241
241
  (kind: "push" | "replace", href: string, { scrollToTop }: RouteOptions = {}) => {
242
242
  const fromLocation = getCurrentLocation();
243
243
  const target = getLocation(href);
244
-
244
+ const cached = target.pathRoute.pageState.cache
245
+ ? nav.history.current.cachedLocationMap.get(target.pathRoute.path)
246
+ : undefined;
247
+
245
248
  const toLocation =
246
249
  kind === "replace" && target.pathRoute.path === fromLocation.pathRoute.path
247
250
  ? { ...target, entryId: fromLocation.entryId }
248
- : target;
251
+ : cached &&
252
+ cached.pathname === target.pathname &&
253
+ cached.search === target.search &&
254
+ cached.hash === target.hash
255
+ ? cached
256
+ : target;
249
257
  const scrollTop = pageContentRef.current?.scrollTop ?? 0;
250
258
  const slides =
251
259
  CsrStack.keyOf(toLocation) !== CsrStack.keyOf(fromLocation) &&