ttyd-mux 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -0
- package/dist/caddy/client.d.ts +23 -0
- package/dist/caddy/client.d.ts.map +1 -1
- package/dist/caddy/client.js +97 -0
- package/dist/caddy/client.js.map +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +34 -8
- package/dist/client/index.js.map +1 -1
- package/dist/commands/caddy.d.ts +2 -1
- package/dist/commands/caddy.d.ts.map +1 -1
- package/dist/commands/caddy.js +232 -45
- package/dist/commands/caddy.js.map +1 -1
- package/dist/commands/deploy.d.ts +7 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +105 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/config/state.js +1 -1
- package/dist/config/state.js.map +1 -1
- package/dist/config/types.d.ts +6 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +4 -1
- package/dist/config/types.js.map +1 -1
- package/dist/daemon/ime-helper.d.ts +8 -0
- package/dist/daemon/ime-helper.d.ts.map +1 -0
- package/dist/daemon/ime-helper.js +827 -0
- package/dist/daemon/ime-helper.js.map +1 -0
- package/dist/daemon/index.d.ts.map +1 -1
- package/dist/daemon/index.js +2 -10
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/server.d.ts.map +1 -1
- package/dist/daemon/server.js +119 -8
- package/dist/daemon/server.js.map +1 -1
- package/dist/deploy/caddyfile.d.ts +8 -0
- package/dist/deploy/caddyfile.d.ts.map +1 -0
- package/dist/deploy/caddyfile.js +62 -0
- package/dist/deploy/caddyfile.js.map +1 -0
- package/dist/deploy/deploy-script.d.ts +8 -0
- package/dist/deploy/deploy-script.d.ts.map +1 -0
- package/dist/deploy/deploy-script.js +72 -0
- package/dist/deploy/deploy-script.js.map +1 -0
- package/dist/deploy/static-portal.d.ts +3 -0
- package/dist/deploy/static-portal.d.ts.map +1 -0
- package/dist/deploy/static-portal.js +130 -0
- package/dist/deploy/static-portal.js.map +1 -0
- package/dist/index.js +24 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IME Helper Script for ttyd
|
|
3
|
+
* Provides a pseudo copy-paste input field for Japanese IME support
|
|
4
|
+
* Optimized for mobile devices
|
|
5
|
+
*/
|
|
6
|
+
export declare const imeHelperScript = "\n<style>\n#ttyd-ime-container {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n background: #1e1e1e;\n border-top: 2px solid #007acc;\n padding: 8px;\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n box-shadow: 0 -2px 10px rgba(0,0,0,0.3);\n}\n\n#ttyd-ime-container.hidden {\n display: none;\n}\n\n#ttyd-ime-buttons {\n display: flex;\n gap: 6px;\n margin-bottom: 8px;\n flex-wrap: wrap;\n}\n\n#ttyd-ime-buttons button {\n background: #3a3a3a;\n border: 1px solid #555;\n border-radius: 6px;\n color: #fff;\n cursor: pointer;\n font-size: 13px;\n padding: 8px 12px;\n min-height: 40px;\n min-width: 44px;\n touch-action: manipulation;\n flex-shrink: 0;\n}\n\n#ttyd-ime-buttons button:hover, #ttyd-ime-buttons button:active {\n background: #4a4a4a;\n}\n\n#ttyd-ime-buttons button.active {\n background: #007acc;\n border-color: #005a9e;\n}\n\n#ttyd-ime-buttons button.modifier {\n background: #2d2d2d;\n font-weight: bold;\n}\n\n#ttyd-ime-buttons button.modifier.active {\n background: #d9534f;\n border-color: #c9302c;\n}\n\n#ttyd-ime-send {\n background: #007acc !important;\n border-color: #005a9e !important;\n font-weight: bold;\n}\n\n#ttyd-ime-send:hover, #ttyd-ime-send:active {\n background: #005a9e !important;\n}\n\n#ttyd-ime-run {\n background: #28a745 !important;\n border-color: #1e7e34 !important;\n font-weight: bold;\n}\n\n#ttyd-ime-run:hover, #ttyd-ime-run:active {\n background: #1e7e34 !important;\n}\n\n#ttyd-ime-auto.active {\n background: #f0ad4e !important;\n border-color: #eea236 !important;\n color: #000;\n}\n\n#ttyd-ime-input-row {\n display: flex;\n gap: 8px;\n align-items: flex-end;\n}\n\n#ttyd-ime-input {\n flex: 1;\n background: #2d2d2d;\n border: 1px solid #555;\n border-radius: 8px;\n color: #fff;\n font-family: monospace;\n font-size: 16px;\n padding: 12px;\n outline: none;\n resize: none;\n min-height: 44px;\n max-height: 120px;\n line-height: 1.4;\n}\n\n#ttyd-ime-input:focus {\n border-color: #007acc;\n}\n\n#ttyd-ime-input::placeholder {\n color: #888;\n}\n\n#ttyd-ime-toggle {\n position: fixed;\n bottom: 16px;\n right: 16px;\n background: #007acc;\n border: 2px solid #005a9e;\n border-radius: 50%;\n color: #fff;\n cursor: pointer;\n font-size: 20px;\n width: 56px;\n height: 56px;\n z-index: 10001;\n touch-action: manipulation;\n box-shadow: 0 2px 8px rgba(0,0,0,0.3);\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n#ttyd-ime-toggle:hover, #ttyd-ime-toggle:active {\n background: #005a9e;\n transform: scale(1.05);\n}\n\n#ttyd-ime-container.hidden ~ #ttyd-ime-toggle {\n bottom: 16px;\n}\n\n/* Adjust terminal height when IME bar is visible */\nbody:has(#ttyd-ime-container:not(.hidden)) .xterm {\n height: calc(100vh - 140px) !important;\n}\n\n/* Mobile optimizations */\n@media (max-width: 768px) {\n #ttyd-ime-container {\n padding: 6px;\n }\n\n #ttyd-ime-buttons {\n gap: 4px;\n margin-bottom: 6px;\n }\n\n #ttyd-ime-buttons button {\n font-size: 12px;\n padding: 6px 10px;\n min-height: 36px;\n min-width: 40px;\n }\n\n #ttyd-ime-input {\n font-size: 16px;\n padding: 10px;\n }\n\n #ttyd-ime-toggle {\n width: 64px;\n height: 64px;\n font-size: 24px;\n }\n\n body:has(#ttyd-ime-container:not(.hidden)) .xterm {\n height: calc(100vh - 130px) !important;\n }\n}\n</style>\n\n<div id=\"ttyd-ime-container\" class=\"hidden\">\n <div id=\"ttyd-ime-buttons\">\n <button id=\"ttyd-ime-ctrl\" class=\"modifier\">Ctrl</button>\n <button id=\"ttyd-ime-alt\" class=\"modifier\">Alt</button>\n <button id=\"ttyd-ime-shift\" class=\"modifier\">Shift</button>\n <button id=\"ttyd-ime-esc\">Esc</button>\n <button id=\"ttyd-ime-tab\">Tab</button>\n <button id=\"ttyd-ime-up\">\u2191</button>\n <button id=\"ttyd-ime-down\">\u2193</button>\n <button id=\"ttyd-ime-enter\">Enter</button>\n <button id=\"ttyd-ime-zoomout\">A-</button>\n <button id=\"ttyd-ime-zoomin\">A+</button>\n <button id=\"ttyd-ime-copy\">Copy</button>\n <button id=\"ttyd-ime-copyall\">All</button>\n <button id=\"ttyd-ime-send\">Send</button>\n <button id=\"ttyd-ime-run\">Run</button>\n <button id=\"ttyd-ime-auto\" class=\"modifier\">Auto</button>\n </div>\n <div id=\"ttyd-ime-input-row\">\n <textarea id=\"ttyd-ime-input\" rows=\"1\" placeholder=\"\u65E5\u672C\u8A9E\u5165\u529B (Enter: \u9001\u4FE1)\"></textarea>\n </div>\n</div>\n<button id=\"ttyd-ime-toggle\">\u2328</button>\n\n<script>\n(function() {\n const container = document.getElementById('ttyd-ime-container');\n const input = document.getElementById('ttyd-ime-input');\n const sendBtn = document.getElementById('ttyd-ime-send');\n const enterBtn = document.getElementById('ttyd-ime-enter');\n const zoomInBtn = document.getElementById('ttyd-ime-zoomin');\n const zoomOutBtn = document.getElementById('ttyd-ime-zoomout');\n const runBtn = document.getElementById('ttyd-ime-run');\n const toggleBtn = document.getElementById('ttyd-ime-toggle');\n const ctrlBtn = document.getElementById('ttyd-ime-ctrl');\n const altBtn = document.getElementById('ttyd-ime-alt');\n const shiftBtn = document.getElementById('ttyd-ime-shift');\n const escBtn = document.getElementById('ttyd-ime-esc');\n const tabBtn = document.getElementById('ttyd-ime-tab');\n const upBtn = document.getElementById('ttyd-ime-up');\n const downBtn = document.getElementById('ttyd-ime-down');\n const copyBtn = document.getElementById('ttyd-ime-copy');\n const copyAllBtn = document.getElementById('ttyd-ime-copyall');\n const autoBtn = document.getElementById('ttyd-ime-auto');\n\n let ws = null;\n let ctrlActive = false;\n let altActive = false;\n let shiftActive = false;\n let autoRunActive = false;\n\n // Detect mobile device\n const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);\n\n // Find the WebSocket connection\n function findWebSocket() {\n if (ws && ws.readyState === WebSocket.OPEN) return ws;\n\n if (window.socket && window.socket.readyState === WebSocket.OPEN) {\n ws = window.socket;\n return ws;\n }\n\n return null;\n }\n\n // Intercept WebSocket creation to capture the connection\n const OriginalWebSocket = window.WebSocket;\n window.WebSocket = function(url, protocols) {\n const socket = new OriginalWebSocket(url, protocols);\n if (url.includes('/ws')) {\n ws = socket;\n }\n return socket;\n };\n window.WebSocket.prototype = OriginalWebSocket.prototype;\n window.WebSocket.CONNECTING = OriginalWebSocket.CONNECTING;\n window.WebSocket.OPEN = OriginalWebSocket.OPEN;\n window.WebSocket.CLOSING = OriginalWebSocket.CLOSING;\n window.WebSocket.CLOSED = OriginalWebSocket.CLOSED;\n\n function sendText(text) {\n const socket = findWebSocket();\n if (!socket) {\n console.error('[IME Helper] WebSocket not found');\n return false;\n }\n\n // ttyd protocol: binary data with '0' (input command) as first byte\n const encoder = new TextEncoder();\n const textBytes = encoder.encode(text);\n const data = new Uint8Array(textBytes.length + 1);\n data[0] = '0'.charCodeAt(0); // Input command\n data.set(textBytes, 1);\n socket.send(data);\n return true;\n }\n\n function sendKey(key) {\n // Apply modifiers\n if (ctrlActive && key.length === 1) {\n // Ctrl+key: send as control character (A=1, B=2, ..., Z=26)\n const code = key.toUpperCase().charCodeAt(0) - 64;\n if (code > 0 && code < 32) {\n sendBytes([code]);\n }\n resetModifiers();\n } else if (altActive && key.length === 1) {\n // Alt+key: send ESC + key\n const keyCode = key.charCodeAt(0);\n sendBytes([0x1B, keyCode]);\n resetModifiers();\n } else {\n sendText(key);\n }\n }\n\n function resetModifiers() {\n ctrlActive = false;\n altActive = false;\n ctrlBtn.classList.remove('active');\n altBtn.classList.remove('active');\n }\n\n // Send raw bytes for special keys\n function sendBytes(bytes) {\n const socket = findWebSocket();\n if (!socket) {\n console.error('[IME Helper] WebSocket not found');\n return false;\n }\n const data = new Uint8Array(bytes.length + 1);\n data[0] = 0x30; // '0' = input command\n data.set(bytes, 1);\n socket.send(data);\n return true;\n }\n\n function sendEnter() {\n sendBytes([0x0D]); // CR\n }\n\n function sendEsc() {\n sendBytes([0x1B]); // ESC\n }\n\n function sendTab() {\n sendBytes([0x09]); // TAB\n }\n\n function sendUp() {\n sendBytes([0x1B, 0x5B, 0x41]); // ESC [ A\n }\n\n function sendDown() {\n sendBytes([0x1B, 0x5B, 0x42]); // ESC [ B\n }\n\n function fitTerminal() {\n if (window.fitAddon && typeof window.fitAddon.fit === 'function') {\n window.fitAddon.fit();\n console.log('[IME Helper] Terminal fitted via fitAddon');\n return;\n }\n\n if (window.term && window.term.fitAddon && typeof window.term.fitAddon.fit === 'function') {\n window.term.fitAddon.fit();\n console.log('[IME Helper] Terminal fitted via term.fitAddon');\n return;\n }\n\n window.dispatchEvent(new Event('resize'));\n console.log('[IME Helper] Dispatched resize event');\n }\n\n function findTerminal() {\n if (window.term) return window.term;\n const termEl = document.querySelector('.xterm');\n if (termEl && termEl._core) return termEl._core;\n return null;\n }\n\n function zoomTerminal(delta) {\n const term = findTerminal();\n\n if (term && term.options) {\n const currentSize = term.options.fontSize || 14;\n const newSize = Math.max(8, Math.min(32, currentSize + delta));\n term.options.fontSize = newSize;\n console.log('[IME Helper] Font size changed to ' + newSize);\n fitTerminal();\n } else {\n console.log('[IME Helper] Terminal not found for zoom');\n }\n }\n\n function copySelection() {\n const term = findTerminal();\n if (!term) {\n console.log('[IME Helper] Terminal not found for copy');\n return;\n }\n const selection = term.getSelection();\n if (selection) {\n navigator.clipboard.writeText(selection).then(function() {\n console.log('[IME Helper] Copied selection to clipboard');\n }).catch(function(err) {\n console.error('[IME Helper] Failed to copy:', err);\n });\n } else {\n console.log('[IME Helper] No text selected');\n }\n }\n\n function copyAll() {\n const term = findTerminal();\n if (!term || !term.buffer || !term.buffer.active) {\n console.log('[IME Helper] Terminal buffer not found');\n return;\n }\n const buffer = term.buffer.active;\n const lines = [];\n for (let i = 0; i < buffer.length; i++) {\n const line = buffer.getLine(i);\n if (line) {\n lines.push(line.translateToString(true));\n }\n }\n const text = lines.join('\\n').trimEnd();\n navigator.clipboard.writeText(text).then(function() {\n console.log('[IME Helper] Copied all text to clipboard');\n }).catch(function(err) {\n console.error('[IME Helper] Failed to copy:', err);\n });\n }\n\n function submitInput() {\n const text = input.value;\n if (!text) return;\n\n if (sendText(text)) {\n input.value = '';\n adjustTextareaHeight();\n // Auto mode: send Enter after 1 second\n if (autoRunActive) {\n setTimeout(function() {\n sendEnter();\n }, 1000);\n }\n }\n }\n\n function runInput() {\n const text = input.value;\n if (!text) return;\n\n if (sendText(text)) {\n input.value = '';\n adjustTextareaHeight();\n // Wait 1 second then send Enter\n setTimeout(function() {\n sendEnter();\n }, 1000);\n }\n }\n\n function toggleIME(show) {\n if (typeof show === 'boolean') {\n container.classList.toggle('hidden', !show);\n } else {\n container.classList.toggle('hidden');\n }\n\n if (!container.classList.contains('hidden')) {\n input.focus();\n // Fit terminal after showing IME bar\n setTimeout(fitTerminal, 100);\n } else {\n const terminal = document.querySelector('.xterm-helper-textarea');\n if (terminal) terminal.focus();\n setTimeout(fitTerminal, 100);\n }\n }\n\n function adjustTextareaHeight() {\n input.style.height = 'auto';\n input.style.height = Math.min(input.scrollHeight, 120) + 'px';\n }\n\n // Event listeners\n sendBtn.addEventListener('click', function(e) {\n e.preventDefault();\n submitInput();\n });\n\n enterBtn.addEventListener('click', function(e) {\n e.preventDefault();\n sendEnter();\n });\n\n runBtn.addEventListener('click', function(e) {\n e.preventDefault();\n runInput();\n });\n\n zoomInBtn.addEventListener('click', function(e) {\n e.preventDefault();\n zoomTerminal(2);\n });\n\n zoomOutBtn.addEventListener('click', function(e) {\n e.preventDefault();\n zoomTerminal(-2);\n });\n\n ctrlBtn.addEventListener('click', function(e) {\n e.preventDefault();\n ctrlActive = !ctrlActive;\n ctrlBtn.classList.toggle('active', ctrlActive);\n if (ctrlActive) {\n altActive = false;\n altBtn.classList.remove('active');\n }\n });\n\n altBtn.addEventListener('click', function(e) {\n e.preventDefault();\n altActive = !altActive;\n altBtn.classList.toggle('active', altActive);\n if (altActive) {\n ctrlActive = false;\n ctrlBtn.classList.remove('active');\n }\n });\n\n shiftBtn.addEventListener('click', function(e) {\n e.preventDefault();\n shiftActive = !shiftActive;\n shiftBtn.classList.toggle('active', shiftActive);\n });\n\n autoBtn.addEventListener('click', function(e) {\n e.preventDefault();\n autoRunActive = !autoRunActive;\n autoBtn.classList.toggle('active', autoRunActive);\n });\n\n escBtn.addEventListener('click', function(e) {\n e.preventDefault();\n sendEsc();\n });\n\n tabBtn.addEventListener('click', function(e) {\n e.preventDefault();\n sendTab();\n });\n\n upBtn.addEventListener('click', function(e) {\n e.preventDefault();\n sendUp();\n });\n\n downBtn.addEventListener('click', function(e) {\n e.preventDefault();\n sendDown();\n });\n\n copyBtn.addEventListener('click', function(e) {\n e.preventDefault();\n copySelection();\n });\n\n copyAllBtn.addEventListener('click', function(e) {\n e.preventDefault();\n copyAll();\n });\n\n input.addEventListener('input', adjustTextareaHeight);\n\n input.addEventListener('keydown', function(e) {\n if (e.key === 'Enter' && !e.shiftKey && !e.isComposing) {\n e.preventDefault();\n submitInput();\n } else if (e.key === 'Escape') {\n e.preventDefault();\n toggleIME(false);\n }\n });\n\n toggleBtn.addEventListener('click', function(e) {\n e.preventDefault();\n toggleIME();\n });\n\n // Keyboard shortcut: Ctrl+J to toggle IME\n document.addEventListener('keydown', function(e) {\n if (e.ctrlKey && e.key === 'j') {\n e.preventDefault();\n toggleIME();\n }\n });\n\n // Inject shiftKey into mouse events when Shift button is active\n // This allows text selection to bypass tmux mouse mode\n ['mousedown', 'mousemove', 'mouseup'].forEach(function(eventType) {\n document.addEventListener(eventType, function(e) {\n // Don't interfere with IME helper buttons\n if (e.target.closest('#ttyd-ime-container') || e.target.closest('#ttyd-ime-toggle')) {\n return;\n }\n if (shiftActive && !e.shiftKey) {\n const newEvent = new MouseEvent(e.type, {\n bubbles: e.bubbles,\n cancelable: e.cancelable,\n view: e.view,\n detail: e.detail,\n screenX: e.screenX,\n screenY: e.screenY,\n clientX: e.clientX,\n clientY: e.clientY,\n ctrlKey: e.ctrlKey,\n altKey: e.altKey,\n shiftKey: true,\n metaKey: e.metaKey,\n button: e.button,\n buttons: e.buttons,\n relatedTarget: e.relatedTarget\n });\n e.stopImmediatePropagation();\n e.preventDefault();\n e.target.dispatchEvent(newEvent);\n }\n }, true);\n });\n\n // Track non-Shift drag operations and show hint after 3 consecutive drags\n let nonShiftDragCount = 0;\n let isDragging = false;\n let dragStartPos = null;\n\n document.addEventListener('mousedown', function(e) {\n if (e.button === 0 && !shiftActive && !e.shiftKey) {\n isDragging = true;\n dragStartPos = { x: e.clientX, y: e.clientY };\n }\n });\n\n document.addEventListener('mouseup', function(e) {\n if (isDragging && dragStartPos) {\n const dx = e.clientX - dragStartPos.x;\n const dy = e.clientY - dragStartPos.y;\n const distance = Math.sqrt(dx * dx + dy * dy);\n\n // Consider it a drag if moved more than 10 pixels\n if (distance > 10) {\n if (shiftActive || e.shiftKey) {\n nonShiftDragCount = 0;\n } else {\n nonShiftDragCount++;\n if (nonShiftDragCount >= 3) {\n alert('\u30C6\u30AD\u30B9\u30C8\u9078\u629E\u3059\u308B\u306B\u306F\u3001Shift \u30DC\u30BF\u30F3\u3092 ON \u306B\u3057\u3066\u304B\u3089\u30C9\u30E9\u30C3\u30B0\u3057\u3066\u304F\u3060\u3055\u3044\u3002\\n\\nTo select text, turn ON the Shift button and then drag.');\n nonShiftDragCount = 0;\n }\n }\n }\n }\n isDragging = false;\n dragStartPos = null;\n });\n\n // Convert touch events to mouse events with shiftKey when Shift is active\n // This enables text selection on mobile devices\n let touchStartPos = null;\n\n function dispatchMouseEvent(type, touch, shiftKey) {\n const mouseEvent = new MouseEvent(type, {\n bubbles: true,\n cancelable: true,\n view: window,\n detail: 1,\n screenX: touch.screenX,\n screenY: touch.screenY,\n clientX: touch.clientX,\n clientY: touch.clientY,\n ctrlKey: false,\n altKey: false,\n shiftKey: shiftKey,\n metaKey: false,\n button: 0,\n buttons: type === 'mouseup' ? 0 : 1,\n relatedTarget: null\n });\n touch.target.dispatchEvent(mouseEvent);\n }\n\n let shiftTouchActive = false; // Track if we're in Shift+touch selection mode\n\n document.addEventListener('touchstart', function(e) {\n // Don't interfere with IME helper buttons\n if (e.target.closest('#ttyd-ime-container') || e.target.closest('#ttyd-ime-toggle')) {\n return;\n }\n // Single finger touch with Shift active -> convert to mouse event for selection\n if (e.touches.length === 1 && shiftActive) {\n const touch = e.touches[0];\n touchStartPos = { x: touch.clientX, y: touch.clientY };\n shiftTouchActive = true;\n e.preventDefault();\n dispatchMouseEvent('mousedown', touch, true);\n }\n // 2nd finger added -> cancel Shift selection mode, allow pinch\n else if (e.touches.length === 2 && shiftTouchActive) {\n dispatchMouseEvent('mouseup', e.touches[0], true);\n shiftTouchActive = false;\n touchStartPos = null;\n // Don't preventDefault - let pinch handlers take over\n }\n // Track non-Shift single touch for hint\n else if (e.touches.length === 1 && !shiftActive) {\n const touch = e.touches[0];\n touchStartPos = { x: touch.clientX, y: touch.clientY };\n }\n }, { passive: false, capture: true });\n\n document.addEventListener('touchmove', function(e) {\n // Only handle single-finger moves when in Shift selection mode\n if (e.touches.length === 1 && shiftTouchActive) {\n e.preventDefault();\n dispatchMouseEvent('mousemove', e.touches[0], true);\n }\n // Don't interfere with 2-finger gestures (pinch)\n }, { passive: false, capture: true });\n\n document.addEventListener('touchend', function(e) {\n // Shift selection mode ending\n if (shiftTouchActive && e.touches.length === 0) {\n const touch = e.changedTouches[0];\n dispatchMouseEvent('mouseup', touch, true);\n shiftTouchActive = false;\n touchStartPos = null;\n nonShiftDragCount = 0;\n }\n // Non-Shift drag tracking\n else if (touchStartPos && !shiftTouchActive && e.touches.length === 0) {\n const touch = e.changedTouches[0];\n const dx = touch.clientX - touchStartPos.x;\n const dy = touch.clientY - touchStartPos.y;\n const distance = Math.sqrt(dx * dx + dy * dy);\n\n if (distance > 10) {\n nonShiftDragCount++;\n if (nonShiftDragCount >= 3) {\n alert('\u30C6\u30AD\u30B9\u30C8\u9078\u629E\u3059\u308B\u306B\u306F\u3001Shift \u30DC\u30BF\u30F3\u3092 ON \u306B\u3057\u3066\u304B\u3089\u30C9\u30E9\u30C3\u30B0\u3057\u3066\u304F\u3060\u3055\u3044\u3002\\n\\nTo select text, turn ON the Shift button and then drag.');\n nonShiftDragCount = 0;\n }\n }\n touchStartPos = null;\n }\n }, { passive: true, capture: true });\n\n // Pinch-to-zoom for font size (when Ctrl or Shift is active)\n let pinchStartDistance = 0;\n let pinchStartFontSize = 14;\n\n function getTouchDistance(touches) {\n const dx = touches[0].clientX - touches[1].clientX;\n const dy = touches[0].clientY - touches[1].clientY;\n return Math.sqrt(dx * dx + dy * dy);\n }\n\n document.addEventListener('touchstart', function(e) {\n if (e.touches.length === 2 && (ctrlActive || shiftActive)) {\n pinchStartDistance = getTouchDistance(e.touches);\n const term = findTerminal();\n pinchStartFontSize = (term && term.options) ? (term.options.fontSize || 14) : 14;\n }\n }, { passive: true });\n\n document.addEventListener('touchmove', function(e) {\n if (e.touches.length === 2 && (ctrlActive || shiftActive) && pinchStartDistance > 0) {\n e.preventDefault(); // Suppress browser zoom\n const currentDistance = getTouchDistance(e.touches);\n const scale = currentDistance / pinchStartDistance;\n const newSize = Math.round(pinchStartFontSize * scale);\n const clampedSize = Math.max(8, Math.min(32, newSize));\n\n const term = findTerminal();\n if (term && term.options && term.options.fontSize !== clampedSize) {\n term.options.fontSize = clampedSize;\n fitTerminal();\n }\n }\n }, { passive: false });\n\n document.addEventListener('touchend', function(e) {\n if (e.touches.length < 2) {\n pinchStartDistance = 0;\n }\n }, { passive: true });\n\n // Double-tap to send Enter (for reconnecting)\n let lastTapTime = 0;\n const DOUBLE_TAP_DELAY = 300; // 300ms \u4EE5\u5185\u306E2\u56DE\u30BF\u30C3\u30D7\n\n document.addEventListener('touchend', function(e) {\n // IME \u30D8\u30EB\u30D1\u30FC\u8981\u7D20\u306F\u9664\u5916\n if (e.target.closest('#ttyd-ime-container') || e.target.closest('#ttyd-ime-toggle')) {\n return;\n }\n // \u30B7\u30F3\u30B0\u30EB\u30BF\u30C3\u30C1\u306E\u307F\n if (e.changedTouches.length !== 1) return;\n\n const now = Date.now();\n if (now - lastTapTime < DOUBLE_TAP_DELAY) {\n // \u30C0\u30D6\u30EB\u30BF\u30C3\u30D7\u691C\u51FA \u2192 Enter \u9001\u4FE1\n sendEnter();\n lastTapTime = 0; // \u30EA\u30BB\u30C3\u30C8\n } else {\n lastTapTime = now;\n }\n }, { passive: true });\n\n // Auto-show on mobile devices\n if (isMobile) {\n setTimeout(function() {\n toggleIME(true);\n }, 1000);\n }\n\n console.log('[IME Helper] Loaded. ' + (isMobile ? 'Mobile mode.' : 'Press Ctrl+J or click keyboard button to toggle.'));\n})();\n</script>\n";
|
|
7
|
+
export declare function injectImeHelper(html: string): string;
|
|
8
|
+
//# sourceMappingURL=ime-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ime-helper.d.ts","sourceRoot":"","sources":["../../src/daemon/ime-helper.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,eAAe,6uuBAgzB3B,CAAC;AAEF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGpD"}
|