akanjs 2.3.6-rc.3 → 2.3.6-rc.4
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/client/csrTypes.ts +4 -4
- package/client/frameConfig.ts +15 -6
- package/package.json +1 -1
- package/types/client/csrTypes.d.ts +4 -4
package/client/csrTypes.ts
CHANGED
|
@@ -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
|
|
24
|
-
topInset?: number;
|
|
25
|
-
/** Bottom chrome reservation in px. Use
|
|
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
|
/**
|
package/client/frameConfig.ts
CHANGED
|
@@ -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,16 +44,18 @@ 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(`[route-convention] pageConfig.topInset in ${routeKey} must be a boolean or non-negative px number.`);
|
|
47
48
|
}
|
|
48
49
|
if (pageConfig.bottomInset !== undefined && !isValidInsetValue(pageConfig.bottomInset)) {
|
|
49
|
-
throw new Error(
|
|
50
|
+
throw new Error(
|
|
51
|
+
`[route-convention] pageConfig.bottomInset in ${routeKey} must be a boolean or non-negative px number.`,
|
|
52
|
+
);
|
|
50
53
|
}
|
|
51
54
|
validateSafeAreaConfig(routeKey, pageConfig.safeArea);
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
function isValidInsetValue(value: unknown): value is
|
|
55
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
57
|
+
function isValidInsetValue(value: unknown): value is NonNullable<PageConfig["topInset"]> {
|
|
58
|
+
return typeof value === "boolean" || (typeof value === "number" && Number.isFinite(value) && value >= 0);
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
function validateSafeAreaConfig(routeKey: string, safeArea?: PageSafeAreaConfig) {
|
|
@@ -134,8 +137,8 @@ export function resolvePageState({
|
|
|
134
137
|
transition,
|
|
135
138
|
topSafeArea: safeArea.top,
|
|
136
139
|
bottomSafeArea: safeArea.bottom,
|
|
137
|
-
topInset: config.topInset
|
|
138
|
-
bottomInset: config.bottomInset
|
|
140
|
+
topInset: resolveInset(config.topInset),
|
|
141
|
+
bottomInset: resolveInset(config.bottomInset),
|
|
139
142
|
gesture: explicitKeys.gesture ? (config.gesture ?? false) : transition === "none" ? false : (config.gesture ?? false),
|
|
140
143
|
cache: config.cache ?? false,
|
|
141
144
|
topSafeAreaColor: config.topSafeAreaColor ?? "var(--color-base-100, Canvas)",
|
|
@@ -143,6 +146,12 @@ export function resolvePageState({
|
|
|
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 };
|
package/package.json
CHANGED
|
@@ -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
|
|
18
|
-
topInset?: number;
|
|
19
|
-
/** Bottom chrome reservation in px. Use
|
|
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
|
/**
|