akanjs 3.3.0-rc.44 → 3.3.0-rc.46

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.
@@ -70,7 +70,7 @@ const canonicalOf = (value: unknown, holding: Set<object>): unknown => {
70
70
  if (Array.isArray(value)) return value.map((item) => canonicalOf(item, holding) ?? null);
71
71
 
72
72
  const record: Record<string, unknown> = Object.create(null);
73
- for (const key of Object.keys(value).sort()) {
73
+ for (const key of Object.keys(value).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))) {
74
74
  const item = canonicalOf((value as Record<string, unknown>)[key], holding);
75
75
  if (item !== undefined) record[key] = item;
76
76
  }
@@ -15,7 +15,10 @@ export const makeRequestQueryCacheKey = (
15
15
  url,
16
16
  headers: Object.entries(headers).sort(([a], [b]) => a.localeCompare(b)),
17
17
  timeout: budget.timeout ?? DEFAULT_TIMEOUT_MS,
18
- retry: JSON.stringify(budget.retry, Object.keys(budget.retry).sort()),
18
+ retry: JSON.stringify(
19
+ budget.retry,
20
+ Object.keys(budget.retry).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0)),
21
+ ),
19
22
  });
20
23
  };
21
24
  export const deepCopy = <T>(value: T): T => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
3
- "version": "3.3.0-rc.44",
3
+ "version": "3.3.0-rc.46",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -548,7 +548,7 @@
548
548
  }
549
549
  },
550
550
  "devDependencies": {
551
- "@biomejs/biome": "2.5.14",
551
+ "@biomejs/biome": "2.5.15",
552
552
  "@types/bun": "^1.4.4"
553
553
  },
554
554
  "bun": {
@@ -5,7 +5,7 @@ type HistogramFamily = Extract<AkanMetricFamily, { type: "histogram" }>;
5
5
 
6
6
  const keyOf = (labels: Record<string, string>) =>
7
7
  Object.keys(labels)
8
- .sort()
8
+ .sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
9
9
  .map((name) => `${name}\u0000${labels[name]}`)
10
10
  .join("\u0001");
11
11
 
@@ -46,7 +46,7 @@ export class StoreCatalogue {
46
46
  const state = this.#instance.get();
47
47
  const declared = StoreCatalogue.#declaredStateModels();
48
48
  const entries = Object.keys(state)
49
- .sort()
49
+ .sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
50
50
  .map((key): [string, SerializedStoreState] => {
51
51
  const role = this.#instance.sliceStateRoles.get(key);
52
52
  const model = role
@@ -60,7 +60,7 @@ export class DraftStore {
60
60
 
61
61
  const entries = Object.keys(source)
62
62
  .filter((key) => !["undefined", "function", "symbol"].includes(typeof source[key]))
63
- .sort()
63
+ .sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
64
64
  .map((key) => `${JSON.stringify(key)}:${DraftStore.#stableStringify(source[key])}`);
65
65
  return `{${entries.join(",")}}`;
66
66
  }
@@ -74,7 +74,7 @@ export class DraftStore {
74
74
  const source = value as Record<string, unknown>;
75
75
  if (depth > 0 && typeof source.id === "string") return source.id;
76
76
  const entries = Object.keys(source)
77
- .sort()
77
+ .sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
78
78
  .map((key) => [key, DraftStore.#canonicalSeed(source[key], depth + 1)] as const)
79
79
  .filter(([, item]) => item !== undefined);
80
80
  return Object.fromEntries(entries);
@@ -1,3 +1,4 @@
1
1
  type DragAxis = "x" | "y";
2
+ export declare const SWIPE_BACK_EDGE_PX = 24;
2
3
  export declare const scrollerTakesDrag: (target: EventTarget | null, frame: Element | null, axis: DragAxis, movement: number) => boolean;
3
4
  export {};
package/ui/DragAction.tsx CHANGED
@@ -5,6 +5,7 @@ import type { ReactDOMAttributes } from "@use-gesture/react/dist/declarations/sr
5
5
  import { cn } from "akanjs/client";
6
6
  import { type ReactNode, useContext, useRef } from "react";
7
7
  import { sharedContext } from "../client/sharedContext";
8
+ import { SWIPE_BACK_EDGE_PX } from "../webkit/scrollerTakesDrag";
8
9
  import { animated } from "./animated";
9
10
 
10
11
  interface DragActionContextType {
@@ -53,8 +54,12 @@ export const DragAction = ({ className, children, onClick, onLeft, onRight }: Dr
53
54
  if (!action.current) onClick?.();
54
55
  action.current = null;
55
56
  },
56
- onDrag: ({ down, movement: [mx], event }) => {
57
+ onDrag: ({ down, movement: [mx], initial: [ix], cancel }) => {
57
58
  if (!ref.current) return;
59
+ if (ix <= SWIPE_BACK_EDGE_PX) {
60
+ cancel();
61
+ return;
62
+ }
58
63
  void api.start({
59
64
  x: down ? mx : 0,
60
65
  leftOpacity: mx > 0 && down ? mx / ref.current.clientWidth : 0,
@@ -64,8 +69,8 @@ export const DragAction = ({ className, children, onClick, onLeft, onRight }: Dr
64
69
  });
65
70
  action.current = mx > 0 ? "left" : mx < 0 ? "right" : null;
66
71
  },
67
- onDragEnd: ({ movement: [mx] }) => {
68
- if (!ref.current) return;
72
+ onDragEnd: ({ movement: [mx], initial: [ix] }) => {
73
+ if (!ref.current || ix <= SWIPE_BACK_EDGE_PX) return;
69
74
  void api.start({ x: 0, leftOpacity: 0, leftWidth: 0, rightOpacity: 0, rightWidth: 0 });
70
75
  if (mx > ref.current.clientWidth / 2 && onLeft) onLeft();
71
76
  if (mx < -ref.current.clientWidth / 2 && onRight) onRight();
@@ -75,7 +80,7 @@ export const DragAction = ({ className, children, onClick, onLeft, onRight }: Dr
75
80
  );
76
81
  return (
77
82
  <DragActionContext.Provider value={{ bind, x, y, leftOpacity, leftWidth, rightOpacity, rightWidth, onClick }}>
78
- <div ref={ref} className={cn("relative overflow-x-hidden", className)}>
83
+ <div ref={ref} data-akan-drag="x" className={cn("relative overflow-x-hidden", className)}>
79
84
  {children}
80
85
  </div>
81
86
  </DragActionContext.Provider>
@@ -21,7 +21,7 @@ export class EditSeed {
21
21
  const source = value as Record<string, unknown>;
22
22
  const entries = Object.keys(source)
23
23
  .filter((key) => source[key] !== undefined)
24
- .sort()
24
+ .sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
25
25
  .map((key) => `${JSON.stringify(key)}:${EditSeed.#stableStringify(source[key])}`);
26
26
  return `{${entries.join(",")}}`;
27
27
  }
@@ -90,7 +90,7 @@ export function nativeApi(
90
90
  platform,
91
91
  plugins,
92
92
  acl: acl ?? null,
93
- permissions: Object.keys(project.config.permissions).sort(),
93
+ permissions: Object.keys(project.config.permissions).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0)),
94
94
  deepLinks: [...project.config.deepLinks.schemes].sort(),
95
95
  };
96
96
  }
@@ -30,7 +30,7 @@ export function requestedDistribution(
30
30
  ): Distribution {
31
31
  const unused = Object.keys(env)
32
32
  .filter((name) => SIGNING_ENV.test(name) && env[name]?.trim())
33
- .sort();
33
+ .sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
34
34
  if (!sign && !notarize) return { notice: null, unused };
35
35
  if (platform !== "macos" && platform !== "windows")
36
36
  throw new CliError(`--sign and --notarize are for a macOS or Windows app, not ${platform}`);
@@ -350,7 +350,7 @@ export class CsrRouteTable {
350
350
  }
351
351
 
352
352
  static #keysOf(context: CsrRouteContext) {
353
- return Object.keys(context).sort();
353
+ return Object.keys(context).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
354
354
  }
355
355
 
356
356
  static #paramNamesOf(pattern: string) {
@@ -95,7 +95,7 @@ export class McpAppFetchBridge implements FetchBridge {
95
95
  static #callKey(key: string, args: Record<string, unknown>) {
96
96
  const sorted = Object.keys(args)
97
97
  .filter((name) => args[name] !== undefined && args[name] !== null)
98
- .sort()
98
+ .sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
99
99
  .map((name) => [name, args[name]]);
100
100
  return `${key}:${JSON.stringify(sorted)}`;
101
101
  }
@@ -1,5 +1,7 @@
1
1
  type DragAxis = "x" | "y";
2
2
 
3
+ export const SWIPE_BACK_EDGE_PX = 24;
4
+
3
5
  const isScrollable = (overflow: string) => overflow === "auto" || overflow === "scroll";
4
6
 
5
7
  const isReversed = (style: CSSStyleDeclaration, axis: DragAxis) =>
@@ -8,6 +10,7 @@ const isReversed = (style: CSSStyleDeclaration, axis: DragAxis) =>
8
10
  : (style.flexDirection === "row-reverse") !== (style.direction === "rtl");
9
11
 
10
12
  const takes = (node: Element, style: CSSStyleDeclaration, axis: DragAxis, movement: number) => {
13
+ if (node.getAttribute("data-akan-drag") === axis) return true;
11
14
  if (!isScrollable(axis === "x" ? style.overflowX : style.overflowY)) return false;
12
15
  const span = axis === "x" ? node.scrollWidth - node.clientWidth : node.scrollHeight - node.clientHeight;
13
16
  if (span < 1) return false;
@@ -14,7 +14,7 @@ import { clamp } from "akanjs/common";
14
14
  import { type RefObject, useCallback, useEffect, useLayoutEffect, useMemo, useRef } from "react";
15
15
  import { CsrSlide, type CsrSlideFrame } from "./csrSlide";
16
16
  import { isDragLift } from "./isDragLift";
17
- import { scrollerTakesDrag } from "./scrollerTakesDrag";
17
+ import { SWIPE_BACK_EDGE_PX, scrollerTakesDrag } from "./scrollerTakesDrag";
18
18
  import { STACK_TRANSITION_DURATION_MS } from "./useFrameRuntime";
19
19
 
20
20
  const linearEasing = (t: number) => t;
@@ -486,7 +486,8 @@ const useStackTrans = (routeState: RouteState): UseCsrTransition => {
486
486
  const absY = Math.abs(my);
487
487
  const isVertical = absY >= GESTURE_INTENT_THRESHOLD && absY > absX * GESTURE_AXIS_LOCK_RATIO;
488
488
  const isHorizontal = absX >= GESTURE_INTENT_THRESHOLD && absX > absY * GESTURE_AXIS_LOCK_RATIO;
489
- if (isVertical || (isHorizontal && scrollerTakesDrag(target, pageContentRef.current, "x", mx))) {
489
+ const yields = ix > SWIPE_BACK_EDGE_PX && scrollerTakesDrag(target, pageContentRef.current, "x", mx);
490
+ if (isVertical || (isHorizontal && yields)) {
490
491
  gestureIntent.current = "scroll";
491
492
  void transUnit.start(transUnitRange[1], { immediate: true });
492
493
  cancel();