Files
element-x-ios/ElementX/Sources/Other/HTMLParsing/HTMLFixtures.swift
T
Mauro a520d94760 Swift 6 Migration (#5733)
* Enable Swift 6.2 with default main actor isolation for the app target

Turn on SWIFT_VERSION 6.2, SWIFT_APPROACHABLE_CONCURRENCY and SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor for the ElementX target, matching the NSE and Share Extension (which already use 6.2 without the main actor default).

# Conflicts:
#	ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

* Update the code generation templates for Swift 6

Emit nonisolated/@unchecked Sendable mocks and nonisolated string enums, and mark async mock methods @concurrent so they keep suspending like the real implementations (otherwise intermediate states are unobservable in tests). Includes the regenerated mocks and strings.

# Conflicts:
#	ElementX/Sources/Mocks/Generated/GeneratedMocks.swift

* Make the data layer and services nonisolated and Sendable

Annotate the value-type models, Rust SDK proxy wrappers, timeline item graph, settings, logging and NSE-shared types as nonisolated, and conform the service protocols to Sendable so their existentials can cross isolation boundaries. These types run off the main actor and no longer inherit the target's default main actor isolation.

* Adopt the new isolation across call sites, mocks and signatures

Update call sites, closure signatures and mock configuration helpers to match the nonisolated/Sendable data layer, including the main actor isolated mock inits and the @Sendable filter on recentlyVisitedRooms.

^ Conflicts:
^	ElementX/Sources/Services/SecureBackup/SecureBackupController.swift

* Remove redundant @MainActor annotations

With the app target defaulting to main actor isolation, the explicit @MainActor on view models, coordinators, views and their protocols is no longer required.

* Fix concurrency hotspots surfaced by the migration

Resolve the room summary main-thread deadlock by moving diff processing onto AsyncStreams, add the SDKListener.onMainActor FIFO bridge for SDK callbacks, hop KVO/timer/UIKit callbacks to the main actor via assumeIsolated, add isolated deinits, and apply the few justified nonisolated(unsafe) escapes for queue-confined Apple APIs.

* Fix the unit tests for Swift 6 concurrency

Hop the waitForConfirmation body onto the caller's actor (Swift Testing runs confirmation closures off-actor), and adjust the affected suites and async signatures.

* offload diffs on concurrent threads instead of main actor

* make room info protocols sendable

* use a task group for fetching data so that everything runs concurrently in the TextRoomTimelineView when getting the preview.

* use the generic onMainActor implementation, which already makes a stream and send the continuation on the main actor.

* small pr comments issues being addressed

* update enterprise

* Update StaticCode to 1.1.0 and specify the required Swift isolation.

* fix ElementCallServiceTests

* update enterprise

* re-generate mocks

* update enterprise

* enterprise new code conformed to swift 6

---------

Co-authored-by: Doug <douglase@element.io>
2026-06-18 17:55:31 +02:00

129 lines
5.3 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// Copyright 2025 Element Creations Ltd.
// Copyright 2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
nonisolated enum HTMLFixtures: String, CaseIterable {
case plainText
case headers
case paragraphs
case matrixIdentifiers
case links
case textFormatting
case groupedBlockQuotes
case separatedBlockQuotes
case code
case wideCodeBlock
case unorderedList
case orderedList
var rawValue: String {
switch self {
case .plainText:
"""
Nothing is as permanent as a temporary solution that works.
Experience is the name everyone gives to their mistakes.
If debugging is the process of removing bugs, then programming must be the process of putting them in.
"""
case .headers:
"""
<h1>H1 Header</h1>\
<h2>H2 Header</h2>\
<h3>H3 Header</h3>\
<h4>H4 Header</h4>\
<h5>H5 Header</h5>\
<h6>H6 Header</h6>
"""
case .paragraphs:
"""
<p>This is a paragraph.</p><p>And this is another one.</p>\
<div>And this is a division.</div>\
New lines outside of tags are not ignored.\n\nLike so.</br>\
This line comes after a line break.</br>
"""
case .matrixIdentifiers:
"""
We expect various identifiers to be (partially) detected:</br>
!room:matrix.org, #room:matrix.org, $event:matrix.org, @user:matrix.org</br>
matrix://roomid/room:matrix.org, matrix://r/room:matrix.org, matrix://roomid/room:matrix.org/e/event:matrix.org, matrix://roomid/room:matrix.org/u/user:matrix.org</br>
"""
case .links:
"""
Links too:</br><a href=\"https://www.alpha.org/\">Matrix rules! 🤘</a>, beta.org, www.gamma.org, http://delta.org
"""
case .textFormatting:
"""
<b>Text</b> <i>formatting</i> <u>should</u> <s>work</s> properly.
<strong>Text</strong> <em>formatting</em> does <del>work!</del>.
<b>And <i>mixed</i></b> <em><s>formatting</s></em> <del><strong>works</strong></del> <u><b>too!!1!</b></u>.
<sup>Thumbs</sup> if you liked it, <sub>sub</sub> if you loved it!
"""
case .groupedBlockQuotes:
"""
<blockquote>First blockquote with a <a href=\"https://www.matrix.org/\">link</a> in it</blockquote>
<blockquote>Second blockquote with a <a href=\"https://www.matrix.org/\">link</a> in it</blockquote>
<blockquote>Third blockquote with a <a href=\"https://www.matrix.org/\">link</a> in it</blockquote>
"""
case .separatedBlockQuotes:
"""
Text before blockquote\
<blockquote>Some blockquote</blockquote>\
Text after first blockquote\
<blockquote>Some other blockquote</blockquote>\
Text after second blockquote
"""
case .code:
"""
<pre>A pre-formatted code block
<code>struct ContentView: View {
var body: some View {
VStack {
Text("Knock, knock!")
.padding()
.background(Color.yellow, in: RoundedRectangle(cornerRadius: 8))
Text("Who's there?")
}
.padding()
}
}</code></pre></br>
Followed by some inline code</br>
<p>Plain text <code>code here</code> more text</p>
<p><code>Hello, world!</code></p>
<p><code><b>Hello</b>, <i>world!</i></code></p>
<p><code>&lt;b&gt;Hello&lt;/b&gt;, &lt;i&gt;world!&lt;/i&gt;</code></p>
<p><code><a href="https://www.matrix.org">This link should not be interpreted as such</a></code></p>
<p><code>And this https://www.matrix.org should be not highlighted</code></p>
"""
case .wideCodeBlock:
"""
<pre><code>CHHapticPattern.mm:487 +[CHHapticPattern patternForKey:error:]: Failed to read pattern library data: Error Domain=NSCocoaErrorDomain Code=260 \
"The file “hapticpatternlibrary.plist” couldn’t be opened because there is no such file." \
UserInfo={NSFilePath=/Library/Audio/Tunings/Generic/Haptics/Library/hapticpatternlibrary.plist, \
NSURL=file:///Library/Audio/Tunings/Generic/Haptics/Library/hapticpatternlibrary.plist, \
NSUnderlyingError=0x600000da69d0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}</code></pre>
"""
case .unorderedList:
"""
This is an unordered list
<ul>
<li>Jones’ <b>Crumpets</b></li>
<li><i>Crumpetorium</i></li>
<li>Village <u>Bakery</u></li>
</ul>
"""
case .orderedList:
"""
This is an ordered list
<ol>
<li>Jelly Belly</li>
<li>Starburst</li>
<li>Skittles</li>
</ol>
"""
}
}
}