Skip to content

feat(shared-core): Swift facade for the text-format parser - #1747

Merged
bmc08gt merged 1 commit into
code/cashfrom
feat/text-format-swift-facade
Oct 9, 2026
Merged

bmc08gt merged 1 commit into
code/cashfrom
feat/text-format-swift-facade

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

:libs:text-format is in the XCFramework since shared-core/0.13.0, but SharedCoreKit has no Swift entry point to it, so iOS can't call the parser yet. This adds TextFormat.swift beside the other facades.

TextFormat.parse(_ text: String, ranges: [TextFormat.ProtectedRange] = []) -> TextFormat.FormattedText

The Kotlin types map to Swift ones, nested under TextFormat so they don't collide with the Kotlin names SharedCore exports:

  • ProtectedRange takes an NSRange and a RangeKind (.link, .mention).
  • FormattedText returns display, spans: [Span] and displayRanges: [DisplayRange].
  • Span is an enum with one case per FormatStyle, each carrying its NSRange.
  • DisplayRange carries an NSRange, its kind, and target: URL? for a masked link.

Offsets are UTF-16 code units on both sides, so they cross unchanged. Kotlin enums arrive as classes, so the mapping switches need a default; it traps, and TextFormatTests.mapsEveryKotlinCase walks entries so a style added in Kotlin fails the suite rather than a chat render.

FlipcashCore needs no change: SharedCoreExports.swift already does @_exported import SharedCoreKit.

iOS gets this only after a shared-core release. The iOS feature brief bumps the flipcash-shared-core-spm pin, currently .upToNextMinor(from: "0.10.0"), and adds the FlipcashCoreVectors facade test the spec asks for.

`:libs:text-format` is exported in the XCFramework, but iOS has no Swift
entry point to it. `TextFormat.parse(_:ranges:)` wraps `parseTextFormat`
and maps the Kotlin types to Swift: `NSRange` offsets, a `Span` enum per
style, and `DisplayRange.target` as a `URL`. Offsets are UTF-16 on both
sides, so they pass through unchanged.

FlipcashCore already re-exports SharedCoreKit with `@_exported import`,
so the new types reach it with no change on the iOS side.
@bmc08gt bmc08gt self-assigned this Oct 9, 2026
@github-actions github-actions Bot added the type: feature New functionality label Oct 9, 2026
@bmc08gt
bmc08gt merged commit 673f9af into code/cash Oct 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant