chore(reading): lint-clean lift — local renames, tab escape, DOX pass (#76)
Spike-locals renamed at lift time (identifier_name), literal tab in a string escape fixed (unprintable-ASCII build error), swiftlint force_try disable for the static regex. AGENTS.md reading-mode section rewritten for the apex HTML pipeline; native-only Work Guidance line rescoped to the editing side per ADR-0011.
This commit is contained in:
1 parent
cc04ec236e
commit
f1c915fed1
5 files changed
+111
-83
No files matched your search
@@ -73,18 +73,18 @@ struct ReadingSurface: NSViewRepresentable {
|
||||
return wv
|
||||
}
|
||||
|
||||
func updateNSView(_ wv: WKWebView, context: Context) {
|
||||
let c = context.coordinator
|
||||
c.onEditIntent = onEditIntent
|
||||
c.stateBox = stateBox
|
||||
c.postFolder = postFolder
|
||||
func updateNSView(_: WKWebView, context: Context) {
|
||||
let coordinator = context.coordinator
|
||||
coordinator.onEditIntent = onEditIntent
|
||||
coordinator.stateBox = stateBox
|
||||
coordinator.postFolder = postFolder
|
||||
let key = "\(generation):\(text.hashValue):\(ProseTypography.flowKey)"
|
||||
guard c.loadedKey != key else { return }
|
||||
c.load(text: text, generation: generation, entryCaret: entryCaretLocation, key: key)
|
||||
guard coordinator.loadedKey != key else { return }
|
||||
coordinator.load(text: text, generation: generation, entryCaret: entryCaretLocation, key: key)
|
||||
}
|
||||
|
||||
// Mapping probes: click → source line; ⌘-click → open; scroll → top
|
||||
// visible source line (same map → scroll-sync). Spike-verified (#74).
|
||||
/// Mapping probes: click → source line; ⌘-click → open; scroll → top
|
||||
/// visible source line (same map → scroll-sync). Spike-verified (#74).
|
||||
static let probeJS = """
|
||||
function stamped(el){ return el.closest('[data-source-line]'); }
|
||||
document.addEventListener('click', function(e){
|
||||
@@ -145,7 +145,7 @@ struct ReadingSurface: NSViewRepresentable {
|
||||
|
||||
/// Build + load the page for `text`. All render paths land here
|
||||
/// (updateNSView, typography-change reload).
|
||||
func load(text: String, generation: Int, entryCaret: Int?, key: String) {
|
||||
func load(text: String, generation _: Int, entryCaret: Int?, key: String) {
|
||||
loadedKey = key
|
||||
lastText = text
|
||||
painted = false
|
||||
@@ -174,18 +174,18 @@ struct ReadingSurface: NSViewRepresentable {
|
||||
defaultsObserver = NotificationCenter.default.addObserver(
|
||||
forName: UserDefaults.didChangeNotification,
|
||||
object: nil,
|
||||
queue: .main
|
||||
queue: .main,
|
||||
) { [weak self] _ in
|
||||
Task { @MainActor [weak self] in
|
||||
guard let self else { return }
|
||||
let key = ProseTypography.flowKey
|
||||
guard key != appliedFlowKey else { return }
|
||||
appliedFlowKey = key
|
||||
self.load(
|
||||
load(
|
||||
text: lastText,
|
||||
generation: 0,
|
||||
entryCaret: nil,
|
||||
key: "\(loadedKey)|flow"
|
||||
key: "\(loadedKey)|flow",
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ struct ReadingSurface: NSViewRepresentable {
|
||||
|
||||
// MARK: WKNavigationDelegate
|
||||
|
||||
func webView(_ wv: WKWebView, didFinish nav: WKNavigation!) {
|
||||
func webView(_ wv: WKWebView, didFinish _: WKNavigation!) {
|
||||
guard !painted else { return }
|
||||
painted = true
|
||||
guard let line = pendingEntryScrollLine else { return }
|
||||
@@ -205,16 +205,17 @@ struct ReadingSurface: NSViewRepresentable {
|
||||
wv.evaluateJavaScript(ReadingSurface.entryScrollJS(line))
|
||||
}
|
||||
|
||||
// Allow our own loadHTMLString main-frame load (about:blank); a
|
||||
// blanket .cancel would kill the page before it paints. Everything
|
||||
// else is cancelled — reading never navigates in-app (#74 lesson).
|
||||
/// Allow our own loadHTMLString main-frame load (about:blank); a
|
||||
/// blanket .cancel would kill the page before it paints. Everything
|
||||
/// else is cancelled — reading never navigates in-app (#74 lesson).
|
||||
func webView(
|
||||
_ wv: WKWebView,
|
||||
_: WKWebView,
|
||||
decidePolicyFor nav: WKNavigationAction,
|
||||
decisionHandler: @escaping @MainActor (WKNavigationActionPolicy) -> Void
|
||||
decisionHandler: @escaping @MainActor (WKNavigationActionPolicy) -> Void,
|
||||
) {
|
||||
if nav.targetFrame?.isMainFrame == true,
|
||||
let u = nav.request.url, u.scheme == "file" || u.absoluteString == "about:blank" {
|
||||
let url = nav.request.url, url.scheme == "file" || url.absoluteString == "about:blank"
|
||||
{
|
||||
decisionHandler(.allow)
|
||||
return
|
||||
}
|
||||
@@ -223,12 +224,14 @@ struct ReadingSurface: NSViewRepresentable {
|
||||
|
||||
// MARK: WKScriptMessageHandler — the source map in action
|
||||
|
||||
func userContentController(_ ucc: WKUserContentController, didReceive message: WKScriptMessage) {
|
||||
func userContentController(_: WKUserContentController, didReceive message: WKScriptMessage) {
|
||||
switch message.name {
|
||||
case "openLink":
|
||||
if let s = message.body as? String, let url = URL(string: s) { NSWorkspace.shared.open(url) }
|
||||
if let body = message.body as? String, let url = URL(string: body) {
|
||||
NSWorkspace.shared.open(url)
|
||||
}
|
||||
case "sourceClick", "sourceScroll":
|
||||
guard let s = message.body as? String, let line = Int(s),
|
||||
guard let body = message.body as? String, let line = Int(body),
|
||||
let block = blocks.first(where: { $0.sourceLine == line }) else { return }
|
||||
if message.name == "sourceClick" {
|
||||
onEditIntent?(block.sourceRange.location)
|
||||
|
||||
Reference in new issue
Block a user