akanjs 2.3.6-rc.3 → 2.3.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # akanjs
2
2
 
3
+ ## 2.3.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 0a4815a: Improve `akan start` stability for incremental dev changes.
8
+
3
9
  ## 2.3.5
4
10
 
5
11
  ### Patch Changes
@@ -20,10 +20,10 @@ export type PageSafeAreaConfig =
20
20
  export interface PageConfig {
21
21
  transition?: TransitionType;
22
22
  safeArea?: PageSafeAreaConfig;
23
- /** Top chrome reservation in px. Use 0 or omit for no reservation. */
24
- topInset?: number;
25
- /** Bottom chrome reservation in px. Use 0 or omit for no reservation. */
26
- bottomInset?: number;
23
+ /** Top chrome reservation in px. Use true for the default 48px reservation. */
24
+ topInset?: number | boolean;
25
+ /** Bottom chrome reservation in px. Use true for the default 48px reservation. */
26
+ bottomInset?: number | boolean;
27
27
  gesture?: boolean;
28
28
  cache?: boolean;
29
29
  /**
@@ -24,6 +24,7 @@ const pageConfigKeys = new Set<keyof PageConfig>([
24
24
  "bottomSafeAreaColor",
25
25
  ]);
26
26
  const transitionTypes = new Set<TransitionType>(["none", "fade", "bottomUp", "stack", "scaleOut"]);
27
+ const DEFAULT_BOOLEAN_INSET = 48;
27
28
 
28
29
  const isRecord = (value: unknown): value is Record<string, unknown> =>
29
30
  typeof value === "object" && value !== null && !Array.isArray(value);
@@ -43,26 +44,24 @@ export function validatePageConfig(routeKey: string, config?: PageConfig) {
43
44
  throw new Error(`[route-convention] unsupported pageConfig.transition "${pageConfig.transition}" in ${routeKey}`);
44
45
  }
45
46
  if (pageConfig.topInset !== undefined && !isValidInsetValue(pageConfig.topInset)) {
46
- throw new Error(`[route-convention] pageConfig.topInset in ${routeKey} must be a non-negative px number.`);
47
+ throw new Error(
48
+ `[route-convention] pageConfig.topInset in ${routeKey} must be a boolean or non-negative px number.`,
49
+ );
47
50
  }
48
51
  if (pageConfig.bottomInset !== undefined && !isValidInsetValue(pageConfig.bottomInset)) {
49
- throw new Error(`[route-convention] pageConfig.bottomInset in ${routeKey} must be a non-negative px number.`);
52
+ throw new Error(
53
+ `[route-convention] pageConfig.bottomInset in ${routeKey} must be a boolean or non-negative px number.`,
54
+ );
50
55
  }
51
56
  validateSafeAreaConfig(routeKey, pageConfig.safeArea);
52
57
  }
53
58
 
54
- function isValidInsetValue(value: unknown): value is number {
55
- return typeof value === "number" && Number.isFinite(value) && value >= 0;
59
+ function isValidInsetValue(value: unknown): value is NonNullable<PageConfig["topInset"]> {
60
+ return typeof value === "boolean" || (typeof value === "number" && Number.isFinite(value) && value >= 0);
56
61
  }
57
62
 
58
63
  function validateSafeAreaConfig(routeKey: string, safeArea?: PageSafeAreaConfig) {
59
- if (
60
- safeArea === undefined ||
61
- typeof safeArea === "boolean" ||
62
- safeArea === "top" ||
63
- safeArea === "bottom"
64
- )
65
- return;
64
+ if (safeArea === undefined || typeof safeArea === "boolean" || safeArea === "top" || safeArea === "bottom") return;
66
65
  if (!isRecord(safeArea)) throw new Error(`[route-convention] pageConfig.safeArea in ${routeKey} is invalid.`);
67
66
  for (const key of Object.keys(safeArea)) {
68
67
  if (key !== "top" && key !== "bottom" && key !== "android") {
@@ -134,15 +133,25 @@ export function resolvePageState({
134
133
  transition,
135
134
  topSafeArea: safeArea.top,
136
135
  bottomSafeArea: safeArea.bottom,
137
- topInset: config.topInset ?? 0,
138
- bottomInset: config.bottomInset ?? 0,
139
- gesture: explicitKeys.gesture ? (config.gesture ?? false) : transition === "none" ? false : (config.gesture ?? false),
136
+ topInset: resolveInset(config.topInset),
137
+ bottomInset: resolveInset(config.bottomInset),
138
+ gesture: explicitKeys.gesture
139
+ ? (config.gesture ?? false)
140
+ : transition === "none"
141
+ ? false
142
+ : (config.gesture ?? false),
140
143
  cache: config.cache ?? false,
141
144
  topSafeAreaColor: config.topSafeAreaColor ?? "var(--color-base-100, Canvas)",
142
145
  bottomSafeAreaColor: config.bottomSafeAreaColor ?? "var(--color-base-100, Canvas)",
143
146
  };
144
147
  }
145
148
 
149
+ function resolveInset(inset: PageConfig["topInset"]): number {
150
+ if (inset === true) return DEFAULT_BOOLEAN_INSET;
151
+ if (inset === false || inset === undefined) return 0;
152
+ return inset;
153
+ }
154
+
146
155
  function getPlatformFrameProfile(platform: DevicePlatform): PageConfig {
147
156
  if (platform === "ios") return { safeArea: true, transition: "stack" };
148
157
  if (platform === "android") return { safeArea: { android: "auto" }, transition: "scaleOut", gesture: false };
@@ -184,7 +193,9 @@ function resolveSafeArea({
184
193
  safeArea === "bottom" ||
185
194
  (isRecord(safeArea) ? safeArea.bottom !== false : safeArea === undefined && platform !== "web");
186
195
  if (platform === "android") {
187
- const androidMode = isRecord(safeArea) ? (safeArea.android as "auto" | "edge-to-edge" | "none" | undefined) : "auto";
196
+ const androidMode = isRecord(safeArea)
197
+ ? (safeArea.android as "auto" | "edge-to-edge" | "none" | undefined)
198
+ : "auto";
188
199
  if (androidMode === "none") return { top: 0, bottom: 0 };
189
200
  const source =
190
201
  androidMode === "edge-to-edge"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
3
- "version": "2.3.6-rc.3",
3
+ "version": "2.3.6",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -14,10 +14,10 @@ export type PageSafeAreaConfig = boolean | "top" | "bottom" | {
14
14
  export interface PageConfig {
15
15
  transition?: TransitionType;
16
16
  safeArea?: PageSafeAreaConfig;
17
- /** Top chrome reservation in px. Use 0 or omit for no reservation. */
18
- topInset?: number;
19
- /** Bottom chrome reservation in px. Use 0 or omit for no reservation. */
20
- bottomInset?: number;
17
+ /** Top chrome reservation in px. Use true for the default 48px reservation. */
18
+ topInset?: number | boolean;
19
+ /** Bottom chrome reservation in px. Use true for the default 48px reservation. */
20
+ bottomInset?: number | boolean;
21
21
  gesture?: boolean;
22
22
  cache?: boolean;
23
23
  /**