afield 0.0.0-stage → 0.1.0
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/LICENSE +15 -0
- package/README.md +165 -2
- package/afield +214 -0
- package/package.json +42 -4
- package/pi-extensions/afield-session.ts +59 -0
- package/pi-extensions/elastic-footer.ts +167 -0
- package/server/attach.js +264 -0
- package/server/auth.js +169 -0
- package/server/client.js +64 -0
- package/server/control.js +65 -0
- package/server/identity.js +45 -0
- package/server/index.js +375 -0
- package/server/mirror.js +159 -0
- package/server/origin.js +51 -0
- package/server/picker.js +187 -0
- package/server/places.js +348 -0
- package/server/protocol.js +51 -0
- package/server/quick-tunnel.js +40 -0
- package/server/registry.js +190 -0
- package/server/serve.js +100 -0
- package/server/session-main.js +27 -0
- package/server/session.js +112 -0
- package/server/supervisor.js +432 -0
- package/server/viewer.js +65 -0
- package/src/app.js +1683 -0
- package/src/apple-touch-icon.png +0 -0
- package/src/index.html +96 -0
- package/src/keys.js +59 -0
- package/src/pi-icon.svg +13 -0
- package/src/style.css +559 -0
- package/src/transport.js +153 -0
- package/src/ttyd.js +51 -0
- package/src/viewport.js +168 -0
- package/tsconfig.json +14 -0
- package/vendor/wterm/LICENSE +191 -0
- package/vendor/wterm/README.md +7 -0
- package/vendor/wterm/packages/@wterm/dom/src/debug.ts +347 -0
- package/vendor/wterm/packages/@wterm/dom/src/hyperlink.ts +8 -0
- package/vendor/wterm/packages/@wterm/dom/src/index.ts +13 -0
- package/vendor/wterm/packages/@wterm/dom/src/input.ts +662 -0
- package/vendor/wterm/packages/@wterm/dom/src/renderer.ts +725 -0
- package/vendor/wterm/packages/@wterm/dom/src/terminal.css +195 -0
- package/vendor/wterm/packages/@wterm/dom/src/wterm.ts +609 -0
|
Binary file
|
package/src/index.html
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en" class="%THEME_CLASS%">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>afield</title>
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
|
|
7
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
8
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
9
|
+
<meta name="apple-mobile-web-app-title" content="Afield">
|
|
10
|
+
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
|
11
|
+
<meta name="theme-color" content="%THEME_COLOR%">
|
|
12
|
+
<meta name="build" content="%BUILD_ID%">
|
|
13
|
+
<meta name="scrollback" content="%SCROLLBACK%">
|
|
14
|
+
<style>/*%CSS%*/</style>
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<!-- The shell the client fills in: terminal, key bar and its arrow pad, menu,
|
|
18
|
+
and the two overlays that report state a phone otherwise cannot show. -->
|
|
19
|
+
<div id="safe-probe"></div>
|
|
20
|
+
<span id="cell-probe">MMMMMMMMMM</span>
|
|
21
|
+
<div id="scroll-probe"><div></div></div>
|
|
22
|
+
|
|
23
|
+
<pre id="diag-overlay" hidden></pre>
|
|
24
|
+
|
|
25
|
+
<div id="app">
|
|
26
|
+
<div id="viewport">
|
|
27
|
+
<div id="stage"><div id="screen"></div></div>
|
|
28
|
+
</div>
|
|
29
|
+
<div id="loading" hidden></div>
|
|
30
|
+
|
|
31
|
+
<div id="conn" hidden></div>
|
|
32
|
+
<div id="tabs" hidden></div>
|
|
33
|
+
<button id="tabs-left" class="tabs-arrow" aria-label="scroll tabs left" hidden>‹</button>
|
|
34
|
+
<button id="tabs-right" class="tabs-arrow" aria-label="scroll tabs right" hidden>›</button>
|
|
35
|
+
<button id="to-bottom" hidden>↓ latest</button>
|
|
36
|
+
|
|
37
|
+
<div id="bar">
|
|
38
|
+
<div id="keys"></div>
|
|
39
|
+
<div id="pad" hidden></div>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<div id="menu" hidden>
|
|
44
|
+
<div class="menu-card">
|
|
45
|
+
<!-- A first visit (#menu.first-visit) shows only the session list under
|
|
46
|
+
its own title: there is nothing to go back to, and nothing to tune
|
|
47
|
+
yet. Reload stays, for a list that will not load. -->
|
|
48
|
+
<div class="menu-row">
|
|
49
|
+
<span id="menu-state">no session selected</span><button data-act="close">Done</button>
|
|
50
|
+
<span class="first-visit-only">Choose a session</span><button class="first-visit-only" data-act="reload">↻ Reload app</button>
|
|
51
|
+
</div>
|
|
52
|
+
<div id="menu-notice" hidden></div>
|
|
53
|
+
<!-- Under the connection state deliberately, which is what makes it read
|
|
54
|
+
without a heading of its own: the line above says what is wrong, and
|
|
55
|
+
these are the three things to try about it. -->
|
|
56
|
+
<div class="menu-row" id="menu-repair">
|
|
57
|
+
<button data-act="reconnect">⇄ Reconnect</button>
|
|
58
|
+
<button data-act="clear-view">✕ Clear view</button>
|
|
59
|
+
<button data-act="reload">↻ Reload app</button>
|
|
60
|
+
</div>
|
|
61
|
+
<!-- Everything the diagnostics view stands in for. -->
|
|
62
|
+
<div id="menu-main">
|
|
63
|
+
<div class="menu-head">Folder <span id="place-now"></span></div>
|
|
64
|
+
<div id="places"></div>
|
|
65
|
+
<div class="menu-row"><button id="tabs-toggle" data-act="tabs"></button></div>
|
|
66
|
+
<div class="menu-head">Scroll</div>
|
|
67
|
+
<div class="menu-row">
|
|
68
|
+
<button data-act="top">Top</button>
|
|
69
|
+
<button data-act="bottom">Bottom</button>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="menu-head">Paste</div>
|
|
72
|
+
<div class="menu-row">
|
|
73
|
+
<input id="paste" type="text" placeholder="tap here to paste"
|
|
74
|
+
autocorrect="off" autocapitalize="off" spellcheck="false" autocomplete="off">
|
|
75
|
+
<button data-act="send-paste">Send</button>
|
|
76
|
+
</div>
|
|
77
|
+
<details id="advanced">
|
|
78
|
+
<summary class="menu-head menu-toggle">Advanced</summary>
|
|
79
|
+
<div class="menu-head">Grid and theme</div>
|
|
80
|
+
<div class="menu-row" id="presets"></div>
|
|
81
|
+
<div class="menu-head">Zoom <span id="scale-val"></span></div>
|
|
82
|
+
<div class="menu-row">
|
|
83
|
+
<button data-act="zoom-out">−</button>
|
|
84
|
+
<button data-act="zoom-reset">100%</button>
|
|
85
|
+
<button data-act="zoom-in">+</button>
|
|
86
|
+
</div>
|
|
87
|
+
</details>
|
|
88
|
+
</div>
|
|
89
|
+
<div class="menu-head menu-toggle" data-act="diag">Diagnostics <span id="diag-caret">▸</span></div>
|
|
90
|
+
<pre id="diag" hidden></pre>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<script type="module">/*%JS%*/</script>
|
|
95
|
+
</body>
|
|
96
|
+
</html>
|
package/src/keys.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Key names to the bytes a terminal expects.
|
|
2
|
+
//
|
|
3
|
+
// A complete table on purpose, not a mirror of the key bar and its arrow pad:
|
|
4
|
+
// those reach only the arrows, Tab, Escape, Enter and Backspace. The rest are
|
|
5
|
+
// here because the encodings are the part worth getting right — Home/End are
|
|
6
|
+
// \e[H and \e[F rather than \e[1~ and \e[4~, and Delete is \e[3~ rather than
|
|
7
|
+
// \x7f. Keys typed on the software keyboard never come through here; wterm
|
|
8
|
+
// encodes those.
|
|
9
|
+
|
|
10
|
+
const ESC = '\x1b'
|
|
11
|
+
|
|
12
|
+
// Arrows and Home/End take a different prefix in DECCKM application mode, and
|
|
13
|
+
// grow a parameter when modified. The rest are fixed strings.
|
|
14
|
+
const CURSOR = { Up: 'A', Down: 'B', Right: 'C', Left: 'D', Home: 'H', End: 'F' }
|
|
15
|
+
|
|
16
|
+
const FIXED = {
|
|
17
|
+
Tab: '\t',
|
|
18
|
+
Escape: ESC,
|
|
19
|
+
Enter: '\r',
|
|
20
|
+
Backspace: '\x7f',
|
|
21
|
+
Delete: `${ESC}[3~`,
|
|
22
|
+
PageUp: `${ESC}[5~`,
|
|
23
|
+
PageDown: `${ESC}[6~`,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// CSI modifier parameter: 1 + shift(1) + alt(2) + ctrl(4).
|
|
27
|
+
const modifierParam = ({ shift, alt, ctrl }) => 1 + (shift ? 1 : 0) + (alt ? 2 : 0) + (ctrl ? 4 : 0)
|
|
28
|
+
|
|
29
|
+
export function keySequence(name, opts = {}) {
|
|
30
|
+
const { shift = false, alt = false, ctrl = false, cursorKeysApp = false } = opts
|
|
31
|
+
|
|
32
|
+
if (name === 'Tab' && shift) return `${ESC}[Z`
|
|
33
|
+
|
|
34
|
+
const final = CURSOR[name]
|
|
35
|
+
if (final) {
|
|
36
|
+
const param = modifierParam(opts)
|
|
37
|
+
if (param > 1) return `${ESC}[1;${param}${final}`
|
|
38
|
+
return cursorKeysApp ? `${ESC}O${final}` : `${ESC}[${final}`
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Meta is an ESC prefix, the same as for a letter — alt+Backspace is
|
|
42
|
+
// delete-word-backwards. Ctrl is absent on purpose: these keys already *are*
|
|
43
|
+
// control codes (Ctrl-I is Tab, Ctrl-[ is Escape), so it has nothing to add
|
|
44
|
+
// without a CSI-u style protocol, which the renderer never confirms to pi.
|
|
45
|
+
if (name in FIXED) return alt ? ESC + FIXED[name] : FIXED[name]
|
|
46
|
+
|
|
47
|
+
if (name.length === 1) {
|
|
48
|
+
if (ctrl) {
|
|
49
|
+
const code = name.toUpperCase().charCodeAt(0)
|
|
50
|
+
// Only @ through _ have control codes. Terminals send the bare key for
|
|
51
|
+
// everything else — ctrl+1 is '1' — rather than inventing an encoding.
|
|
52
|
+
if (code < 0x40 || code > 0x5f) return name
|
|
53
|
+
return String.fromCharCode(code - 0x40)
|
|
54
|
+
}
|
|
55
|
+
return alt ? ESC + name : name
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
throw new Error(`keys: unknown key ${name}`)
|
|
59
|
+
}
|
package/src/pi-icon.svg
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 180 180" width="180" height="180">
|
|
2
|
+
<!-- iOS home-screen icon for afield: the Pi mark on the app's dark background.
|
|
3
|
+
Full-bleed opaque square -- iOS applies its own corner mask, so there are no
|
|
4
|
+
rounded corners or transparency here.
|
|
5
|
+
The mark is a 4x4 grid of 24px cells, so it is 96px square and dead center with
|
|
6
|
+
42px (23%) of clear space per side -- just outside the corner mask iOS applies.
|
|
7
|
+
The cell size divides evenly into 180, 120 and 60, so the icon stays pixel-exact
|
|
8
|
+
at every size iOS renders it. -->
|
|
9
|
+
<rect width="180" height="180" fill="#0b0b0d"/>
|
|
10
|
+
<path fill="#F09082" d="M42 42H114V90H90V66H42Z"/>
|
|
11
|
+
<path fill="#4D9ABF" d="M42 66H66V90H90V114H66V138H42Z"/>
|
|
12
|
+
<path fill="#F1BE58" d="M114 90H138V138H114Z"/>
|
|
13
|
+
</svg>
|