const fs = require('fs'); let code = fs.readFileSync('src/components/TerminalPanel.vue', 'utf8'); // I need to ensure touchmove event preventDefault is working nicely WITH touch-action: none. // In iOS Safari, if touch-action is none, you often don't even need preventDefault for scrolling, but since xterm is a beast, we need to completely bypass it. // Let's rewrite the touchmove prevent default logic: // Sometimes stopImmediatePropagation stops our own handlers if there are others attached manually to the DOM. // Since xterm also attaches to `.xterm-viewport` and `.xterm-screen`, we use the capture phase on `containerRef.value`. // The issue: "手指一直滑动,但屏幕没有滚动 但也没有触发 touchcancel" // Wait! If there is no touchcancel and no touchend... how did `pointerup` trigger? // Because pointer events are synthesized by iOS Safari! // In Safari, if a pointer starts but the system decides it is a scroll, it CANCELS the pointer (pointercancel). // But here, we got POINTER UP. This means Safari thought it was a click/drag, NOT a system scroll! // But why did touchmove stop firing? // In iOS, if you do `preventDefault()` on `touchstart` or `touchmove`, it disables system scrolling and gives you ALL `touchmove` events. // Let's check `touchstart`. We did NOT call `preventDefault()` on `touchstart`. // Let's call `preventDefault()` on `touchstart` when `touchGateHadSelectionAtStart` is false! code = code.replace(/onTouchKeyboardTouchStart = \(event: TouchEvent\) => \{/, `onTouchKeyboardTouchStart = (event: TouchEvent) => { // 必须阻止 touchstart 默认行为,否则 iOS 会尝试将其识别为原生手势而截断后续 touchmove if (event.cancelable && !hasActiveNativeSelectionInTerminal()) { event.preventDefault(); }`); fs.writeFileSync('src/components/TerminalPanel.vue', code);