| author | |
| committer | |
| log | 3382b26c4f29bcbc709edf135c5486b7f1e0e211 |
| tree | 27d47b393ee02a6470ec0861df2038d677f46cf5 |
| parent | 1c59d3b72cbddefa186ce18bea5cd7e6e0ae4874 |
| signature | Signed by PGP key B5690EEEBB952194 |
3 files changed, 0 insertions(+), 33 deletions(-)
apps/mobile/src/features/files/nativeSourceFileAdapter.test.ts-20| ... | @@ -3,30 +3,10 @@ import { describe, expect, it } from "vite-plus/test"; | ... | @@ -3,30 +3,10 @@ import { describe, expect, it } from "vite-plus/test"; |
| 3 | import { | 3 | import { |
| 4 | buildNativeSourceRows, | 4 | buildNativeSourceRows, |
| 5 | buildNativeSourceTokens, | 5 | buildNativeSourceTokens, |
| 6 | NATIVE_SOURCE_ROW_HEIGHT, | ||
| 7 | NATIVE_SOURCE_STYLE, | ||
| 8 | nativeSourceRowId, | 6 | nativeSourceRowId, |
| 9 | } from "./nativeSourceFileAdapter"; | 7 | } from "./nativeSourceFileAdapter"; |
| 10 | import { | ||
| 11 | NATIVE_REVIEW_DIFF_ROW_HEIGHT, | ||
| 12 | NATIVE_REVIEW_DIFF_STYLE, | ||
| 13 | } from "../review/nativeReviewDiffAdapter"; | ||
| 14 | 8 | ||
| 15 | describe("nativeSourceFileAdapter", () => { | 9 | describe("nativeSourceFileAdapter", () => { |
| 16 | it("uses the same compact code typography as the diff viewer", () => { | ||
| 17 | expect(NATIVE_SOURCE_ROW_HEIGHT).toBe(NATIVE_REVIEW_DIFF_ROW_HEIGHT); | ||
| 18 | expect(NATIVE_SOURCE_STYLE).toMatchObject({ | ||
| 19 | rowHeight: NATIVE_REVIEW_DIFF_STYLE.rowHeight, | ||
| 20 | gutterWidth: NATIVE_REVIEW_DIFF_STYLE.gutterWidth, | ||
| 21 | codePadding: NATIVE_REVIEW_DIFF_STYLE.codePadding, | ||
| 22 | textVerticalInset: NATIVE_REVIEW_DIFF_STYLE.textVerticalInset, | ||
| 23 | codeFontSize: NATIVE_REVIEW_DIFF_STYLE.codeFontSize, | ||
| 24 | codeFontWeight: NATIVE_REVIEW_DIFF_STYLE.codeFontWeight, | ||
| 25 | lineNumberFontSize: NATIVE_REVIEW_DIFF_STYLE.lineNumberFontSize, | ||
| 26 | lineNumberFontWeight: NATIVE_REVIEW_DIFF_STYLE.lineNumberFontWeight, | ||
| 27 | }); | ||
| 28 | }); | ||
| 29 | |||
| 30 | it("maps plain source lines onto context rows with stable line numbers", () => { | 10 | it("maps plain source lines onto context rows with stable line numbers", () => { |
| 31 | expect(buildNativeSourceRows(["const value = 1;", "\treturn value;"])).toEqual([ | 11 | expect(buildNativeSourceRows(["const value = 1;", "\treturn value;"])).toEqual([ |
| 32 | { | 12 | { |
apps/mobile/src/features/files/nativeSourceFileAdapter.ts-6| ... | @@ -4,17 +4,11 @@ import type { | ... | @@ -4,17 +4,11 @@ import type { |
| 4 | NativeReviewDiffToken, | 4 | NativeReviewDiffToken, |
| 5 | } from "../diffs/nativeReviewDiffSurface"; | 5 | } from "../diffs/nativeReviewDiffSurface"; |
| 6 | import type { ResolvedMobileCodeSurface } from "../../lib/appearancePreferences"; | 6 | import type { ResolvedMobileCodeSurface } from "../../lib/appearancePreferences"; |
| 7 | import { resolveMobileCodeSurface } from "../../lib/appearancePreferences"; | ||
| 8 | import { MOBILE_CODE_SURFACE, MOBILE_TYPOGRAPHY } from "../../lib/typography"; | 7 | import { MOBILE_CODE_SURFACE, MOBILE_TYPOGRAPHY } from "../../lib/typography"; |
| 9 | import type { SourceHighlightTokens } from "./sourceHighlightingState"; | 8 | import type { SourceHighlightTokens } from "./sourceHighlightingState"; |
| 10 | 9 | ||
| 11 | export const NATIVE_SOURCE_ROW_HEIGHT = MOBILE_CODE_SURFACE.rowHeight; | ||
| 12 | export const NATIVE_SOURCE_CONTENT_WIDTH = 32_000; | 10 | export const NATIVE_SOURCE_CONTENT_WIDTH = 32_000; |
| 13 | 11 | ||
| 14 | export const NATIVE_SOURCE_STYLE: NativeReviewDiffStyle = createNativeSourceStyle( | ||
| 15 | resolveMobileCodeSurface(MOBILE_CODE_SURFACE.fontSize), | ||
| 16 | ); | ||
| 17 | |||
| 18 | export function createNativeSourceStyle( | 12 | export function createNativeSourceStyle( |
| 19 | codeSurface: ResolvedMobileCodeSurface, | 13 | codeSurface: ResolvedMobileCodeSurface, |
| 20 | ): NativeReviewDiffStyle { | 14 | ): NativeReviewDiffStyle { |
apps/mobile/src/features/review/nativeReviewDiffAdapter.ts-7| ... | @@ -6,8 +6,6 @@ import type { | ... | @@ -6,8 +6,6 @@ import type { |
| 6 | import * as Arr from "effect/Array"; | 6 | import * as Arr from "effect/Array"; |
| 7 | import { pipe } from "effect/Function"; | 7 | import { pipe } from "effect/Function"; |
| 8 | import type { ResolvedMobileCodeSurface } from "../../lib/appearancePreferences"; | 8 | import type { ResolvedMobileCodeSurface } from "../../lib/appearancePreferences"; |
| 9 | import { resolveMobileCodeSurface } from "../../lib/appearancePreferences"; | ||
| 10 | import { MOBILE_CODE_SURFACE } from "../../lib/typography"; | ||
| 11 | import { type MobileThemeId, type MobileThemeVariables } from "../../lib/mobileTheme"; | 9 | import { type MobileThemeId, type MobileThemeVariables } from "../../lib/mobileTheme"; |
| 12 | import { getMobileTerminalTheme, type TerminalAppearanceScheme } from "../terminal/terminalTheme"; | 10 | import { getMobileTerminalTheme, type TerminalAppearanceScheme } from "../terminal/terminalTheme"; |
| 13 | import { computeWordAltDiffRanges } from "./reviewWordDiffs"; | 11 | import { computeWordAltDiffRanges } from "./reviewWordDiffs"; |
| ... | @@ -25,13 +23,8 @@ const NATIVE_HEX_COLOR = /^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i; | ... | @@ -25,13 +23,8 @@ const NATIVE_HEX_COLOR = /^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i; |
| 25 | const NATIVE_RGBA_COLOR = | 23 | const NATIVE_RGBA_COLOR = |
| 26 | /^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?\s*\)$/; | 24 | /^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?\s*\)$/; |
| 27 | 25 | ||
| 28 | export const NATIVE_REVIEW_DIFF_ROW_HEIGHT = MOBILE_CODE_SURFACE.rowHeight; | ||
| 29 | export const NATIVE_REVIEW_DIFF_CONTENT_WIDTH = 2_800; | 26 | export const NATIVE_REVIEW_DIFF_CONTENT_WIDTH = 2_800; |
| 30 | 27 | ||
| 31 | export const NATIVE_REVIEW_DIFF_STYLE = createNativeReviewDiffStyle( | ||
| 32 | resolveMobileCodeSurface(MOBILE_CODE_SURFACE.fontSize), | ||
| 33 | ); | ||
| 34 | |||
| 35 | function opaqueNativeHexColor(color: string, background: string): string { | 28 | function opaqueNativeHexColor(color: string, background: string): string { |
| 36 | const hex = NATIVE_HEX_COLOR.exec(color); | 29 | const hex = NATIVE_HEX_COLOR.exec(color); |
| 37 | if (hex) return color; | 30 | if (hex) return color; |