pinokiod 8.3.21 → 8.3.22
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/kernel/windows_console.js +50 -24
- package/package.json +1 -1
- package/test/windows-console.test.js +84 -37
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
// Which console layer a shell starts on, on Windows.
|
|
2
2
|
//
|
|
3
3
|
// Every Windows shell runs behind a console layer (ConPTY) that sits between
|
|
4
|
-
// the program and the terminal page.
|
|
5
|
-
// full-screen program's "I own the screen" and "send me the mouse" requests to
|
|
6
|
-
// itself, so the page never hears them: it keeps its own scrollback and
|
|
7
|
-
// scrollbar next to the one the program draws, and the wheel and clicks never
|
|
8
|
-
// reach the program. The pty library ships a newer copy of the layer that
|
|
9
|
-
// passes both on.
|
|
4
|
+
// the program and the terminal page. There are two copies of it to choose from:
|
|
10
5
|
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
6
|
+
// "system" the one built into Windows. How old it is depends on the Windows
|
|
7
|
+
// version: on Windows 10 it dates from around 2020 and is no
|
|
8
|
+
// longer updated.
|
|
9
|
+
// "pinokio" a newer one that comes with Pinokio (the pty library ships it).
|
|
10
|
+
//
|
|
11
|
+
// The Windows 10 copy keeps a full-screen program's "I own the screen" and
|
|
12
|
+
// "send me the mouse" requests to itself, so the page never hears them: it
|
|
13
|
+
// keeps its own scrollback and scrollbar next to the one the program draws, and
|
|
14
|
+
// the wheel and clicks never reach the program. Pinokio's copy passes both on.
|
|
15
|
+
//
|
|
16
|
+
// So the copy used when nothing is chosen depends on the Windows version:
|
|
17
|
+
// pinokio on Windows 10, system on Windows 11 and later. Settings shows which
|
|
18
|
+
// one is in use and lets the user try the other. The choice is read each time a
|
|
19
|
+
// shell starts, so it applies to shells started after it is saved. Anywhere but
|
|
20
|
+
// Windows nothing here does anything.
|
|
14
21
|
const fs = require('fs')
|
|
22
|
+
const os = require('os')
|
|
15
23
|
const path = require('path')
|
|
16
24
|
|
|
17
|
-
const KEY = "
|
|
18
|
-
const
|
|
19
|
-
const
|
|
25
|
+
const KEY = "terminal_engine"
|
|
26
|
+
const SYSTEM = "system"
|
|
27
|
+
const PINOKIO = "pinokio"
|
|
28
|
+
// the first Windows 11 build
|
|
29
|
+
const WINDOWS_11_BUILD = 22000
|
|
20
30
|
|
|
21
31
|
// Inside the desktop app the library resolves to a path in the app archive
|
|
22
32
|
// (app.asar), while its native module and these files are real files in the
|
|
@@ -41,34 +51,50 @@ const bundledAvailable = (files = bundledFiles()) => {
|
|
|
41
51
|
}
|
|
42
52
|
}
|
|
43
53
|
|
|
44
|
-
|
|
54
|
+
// What a Windows version gets when the user has not chosen. `release` is
|
|
55
|
+
// os.release(), "10.0.19045" on Windows 10 22H2. A version that cannot be read
|
|
56
|
+
// gets the system copy.
|
|
57
|
+
const defaultFor = (release = os.release()) => {
|
|
58
|
+
const match = /^\d+\.\d+\.(\d+)/.exec(release || "")
|
|
59
|
+
const build = match ? parseInt(match[1], 10) : 0
|
|
60
|
+
return build > 0 && build < WINDOWS_11_BUILD ? PINOKIO : SYSTEM
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const choice = (store, release) => {
|
|
64
|
+
const saved = store && store.get(KEY)
|
|
65
|
+
return saved === SYSTEM || saved === PINOKIO ? saved : defaultFor(release)
|
|
66
|
+
}
|
|
45
67
|
|
|
46
68
|
// The row for the Settings page's General list: none except on Windows.
|
|
47
|
-
const settings = (kernel) => {
|
|
69
|
+
const settings = (kernel, release) => {
|
|
48
70
|
if (!kernel || kernel.platform !== "win32") return []
|
|
49
71
|
return [{
|
|
50
72
|
key: KEY,
|
|
51
|
-
val: choice(kernel.store),
|
|
52
|
-
options: [
|
|
73
|
+
val: choice(kernel.store, release),
|
|
74
|
+
options: [SYSTEM, PINOKIO],
|
|
53
75
|
description: [
|
|
54
|
-
"
|
|
55
|
-
"
|
|
76
|
+
"What terminals run on: \"system\" is the one built into Windows, \"pinokio\" is a newer one that comes with Pinokio.",
|
|
77
|
+
"Windows 10 starts on pinokio, Windows 11 and later on system. If terminals misbehave, try the other one. Applies to terminals started after saving.",
|
|
56
78
|
]
|
|
57
79
|
}]
|
|
58
80
|
}
|
|
59
81
|
|
|
60
82
|
// Called with what the Settings page posted. The row is absent off Windows, and
|
|
61
|
-
// anything but the two choices is ignored.
|
|
62
|
-
|
|
83
|
+
// anything but the two choices is ignored. Only a choice that differs from the
|
|
84
|
+
// Windows version's own is kept: the page posts this row with every save, and
|
|
85
|
+
// someone who never touched it should keep following their Windows version.
|
|
86
|
+
const save = (store, config, release) => {
|
|
63
87
|
const value = config && config[KEY]
|
|
64
|
-
if (value
|
|
88
|
+
if (value !== SYSTEM && value !== PINOKIO) return
|
|
89
|
+
if (value === defaultFor(release)) store.delete(KEY)
|
|
90
|
+
else store.set(KEY, value)
|
|
65
91
|
}
|
|
66
92
|
|
|
67
93
|
// Extra options for the pty library when a shell is started.
|
|
68
|
-
const ptyOptions = (kernel, available = bundledAvailable) => {
|
|
94
|
+
const ptyOptions = (kernel, available = bundledAvailable, release) => {
|
|
69
95
|
if (!kernel || kernel.platform !== "win32") return {}
|
|
70
|
-
if (choice(kernel.store) !==
|
|
96
|
+
if (choice(kernel.store, release) !== PINOKIO) return {}
|
|
71
97
|
return available() ? { useConptyDll: true } : {}
|
|
72
98
|
}
|
|
73
99
|
|
|
74
|
-
module.exports = { KEY, settings, save, ptyOptions, bundledAvailable, bundledFiles, outsideArchive }
|
|
100
|
+
module.exports = { KEY, settings, save, ptyOptions, defaultFor, bundledAvailable, bundledFiles, outsideArchive }
|
package/package.json
CHANGED
|
@@ -13,58 +13,105 @@ const WindowsConsole = require('../kernel/windows_console')
|
|
|
13
13
|
|
|
14
14
|
const store = (initial = {}) => {
|
|
15
15
|
const data = { ...initial }
|
|
16
|
-
return {
|
|
16
|
+
return {
|
|
17
|
+
get: (key) => (key in data ? data[key] : null),
|
|
18
|
+
set: (key, val) => { data[key] = val },
|
|
19
|
+
delete: (key) => { delete data[key] },
|
|
20
|
+
data,
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
const kernel = (platform, initial) => ({ platform, store: store(initial) })
|
|
19
24
|
const present = () => true
|
|
20
25
|
const missing = () => false
|
|
26
|
+
// os.release() on each
|
|
27
|
+
const WIN10 = '10.0.19045'
|
|
28
|
+
const WIN11 = '10.0.22000'
|
|
29
|
+
const WIN11_25H2 = '10.0.26200'
|
|
21
30
|
|
|
22
|
-
test('
|
|
23
|
-
assert.
|
|
24
|
-
assert.
|
|
31
|
+
test('Windows 10 gets Pinokio\'s layer and Windows 11 and later the system one', () => {
|
|
32
|
+
assert.equal(WindowsConsole.defaultFor('10.0.18363'), 'pinokio')
|
|
33
|
+
assert.equal(WindowsConsole.defaultFor(WIN10), 'pinokio')
|
|
34
|
+
assert.equal(WindowsConsole.defaultFor('10.0.21999'), 'pinokio')
|
|
35
|
+
assert.equal(WindowsConsole.defaultFor(WIN11), 'system')
|
|
36
|
+
assert.equal(WindowsConsole.defaultFor('10.0.22631'), 'system')
|
|
37
|
+
assert.equal(WindowsConsole.defaultFor(WIN11_25H2), 'system')
|
|
38
|
+
// a version that cannot be read stays on what Windows has
|
|
39
|
+
assert.equal(WindowsConsole.defaultFor(''), 'system')
|
|
40
|
+
assert.equal(WindowsConsole.defaultFor('nonsense'), 'system')
|
|
41
|
+
// and on the machine running this, whatever it is, it is one of the two
|
|
42
|
+
assert.ok(['system', 'pinokio'].includes(WindowsConsole.defaultFor()))
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
test('the Settings row exists on Windows only and shows the layer in use', () => {
|
|
46
|
+
assert.deepEqual(WindowsConsole.settings(kernel('darwin'), WIN10), [])
|
|
47
|
+
assert.deepEqual(WindowsConsole.settings(kernel('linux'), WIN10), [])
|
|
25
48
|
|
|
26
|
-
const [row, ...rest] = WindowsConsole.settings(kernel('win32'))
|
|
49
|
+
const [row, ...rest] = WindowsConsole.settings(kernel('win32'), WIN10)
|
|
27
50
|
assert.equal(rest.length, 0)
|
|
28
|
-
assert.equal(row.key, '
|
|
29
|
-
assert.
|
|
30
|
-
|
|
51
|
+
assert.equal(row.key, 'terminal_engine')
|
|
52
|
+
assert.deepEqual(row.options, ['system', 'pinokio'])
|
|
53
|
+
// nothing chosen: what the Windows version gets
|
|
54
|
+
assert.equal(row.val, 'pinokio')
|
|
55
|
+
assert.equal(WindowsConsole.settings(kernel('win32'), WIN11)[0].val, 'system')
|
|
31
56
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
assert.equal(WindowsConsole.settings(kernel('win32', {
|
|
57
|
+
// a choice wins over the Windows version, either way
|
|
58
|
+
assert.equal(WindowsConsole.settings(kernel('win32', { terminal_engine: 'system' }), WIN10)[0].val, 'system')
|
|
59
|
+
assert.equal(WindowsConsole.settings(kernel('win32', { terminal_engine: 'pinokio' }), WIN11)[0].val, 'pinokio')
|
|
60
|
+
// a value that is not one of the two reads as nothing chosen
|
|
61
|
+
assert.equal(WindowsConsole.settings(kernel('win32', { terminal_engine: 'nonsense' }), WIN10)[0].val, 'pinokio')
|
|
62
|
+
assert.equal(WindowsConsole.settings(kernel('win32', { terminal_engine: 'default' }), WIN11)[0].val, 'system')
|
|
35
63
|
})
|
|
36
64
|
|
|
37
|
-
test('saving
|
|
65
|
+
test('saving keeps only a choice that differs from the Windows version\'s own', () => {
|
|
38
66
|
const s = store()
|
|
39
|
-
WindowsConsole.save(s, { theme: 'dark' }) // the row is absent off Windows
|
|
67
|
+
WindowsConsole.save(s, { theme: 'dark' }, WIN10) // the row is absent off Windows
|
|
40
68
|
assert.deepEqual(s.data, {})
|
|
41
|
-
WindowsConsole.save(s, {
|
|
69
|
+
WindowsConsole.save(s, { terminal_engine: 'nonsense' }, WIN10)
|
|
70
|
+
assert.deepEqual(s.data, {})
|
|
71
|
+
|
|
72
|
+
// the page posts the row with every save: an untouched row stores nothing
|
|
73
|
+
WindowsConsole.save(s, { terminal_engine: 'pinokio' }, WIN10)
|
|
74
|
+
assert.deepEqual(s.data, {})
|
|
75
|
+
WindowsConsole.save(s, { terminal_engine: 'system' }, WIN11)
|
|
76
|
+
assert.deepEqual(s.data, {})
|
|
77
|
+
|
|
78
|
+
// the other one is kept
|
|
79
|
+
WindowsConsole.save(s, { terminal_engine: 'system' }, WIN10)
|
|
80
|
+
assert.deepEqual(s.data, { terminal_engine: 'system' })
|
|
81
|
+
// and going back to the Windows version's own clears it
|
|
82
|
+
WindowsConsole.save(s, { terminal_engine: 'pinokio' }, WIN10)
|
|
42
83
|
assert.deepEqual(s.data, {})
|
|
43
|
-
WindowsConsole.save(s, { windows_console: 'bundled' })
|
|
44
|
-
assert.deepEqual(s.data, { windows_console: 'bundled' })
|
|
45
|
-
WindowsConsole.save(s, { windows_console: 'default' })
|
|
46
|
-
assert.deepEqual(s.data, { windows_console: 'default' })
|
|
47
|
-
})
|
|
48
84
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
85
|
+
WindowsConsole.save(s, { terminal_engine: 'pinokio' }, WIN11)
|
|
86
|
+
assert.deepEqual(s.data, { terminal_engine: 'pinokio' })
|
|
87
|
+
WindowsConsole.save(s, { terminal_engine: 'system' }, WIN11)
|
|
88
|
+
assert.deepEqual(s.data, {})
|
|
89
|
+
})
|
|
52
90
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
assert.deepEqual(WindowsConsole.ptyOptions(kernel('
|
|
57
|
-
|
|
58
|
-
assert.deepEqual(WindowsConsole.ptyOptions(kernel('win32',
|
|
91
|
+
test('a shell gets the bundled layer only on Windows, only when it is the one in use, only when its files are there', () => {
|
|
92
|
+
const on = { useConptyDll: true }
|
|
93
|
+
// nothing chosen
|
|
94
|
+
assert.deepEqual(WindowsConsole.ptyOptions(kernel('win32'), present, WIN10), on)
|
|
95
|
+
assert.deepEqual(WindowsConsole.ptyOptions(kernel('win32'), present, WIN11), {})
|
|
96
|
+
assert.deepEqual(WindowsConsole.ptyOptions(kernel('win32'), present, WIN11_25H2), {})
|
|
97
|
+
// chosen
|
|
98
|
+
assert.deepEqual(WindowsConsole.ptyOptions(kernel('win32', { terminal_engine: 'system' }), present, WIN10), {})
|
|
99
|
+
assert.deepEqual(WindowsConsole.ptyOptions(kernel('win32', { terminal_engine: 'pinokio' }), present, WIN11), on)
|
|
100
|
+
// never off Windows
|
|
101
|
+
assert.deepEqual(WindowsConsole.ptyOptions(kernel('darwin', { terminal_engine: 'pinokio' }), present, WIN10), {})
|
|
102
|
+
assert.deepEqual(WindowsConsole.ptyOptions(kernel('linux', { terminal_engine: 'pinokio' }), present, WIN10), {})
|
|
103
|
+
// in use, but the install has no copy: the shell starts on the system one
|
|
104
|
+
assert.deepEqual(WindowsConsole.ptyOptions(kernel('win32'), missing, WIN10), {})
|
|
105
|
+
assert.deepEqual(WindowsConsole.ptyOptions(kernel('win32', { terminal_engine: 'pinokio' }), missing, WIN11), {})
|
|
59
106
|
})
|
|
60
107
|
|
|
61
108
|
test('the choice is read each time a shell starts', () => {
|
|
62
109
|
const k = kernel('win32')
|
|
63
|
-
assert.deepEqual(WindowsConsole.ptyOptions(k, present), {})
|
|
64
|
-
WindowsConsole.save(k.store, {
|
|
65
|
-
assert.deepEqual(WindowsConsole.ptyOptions(k, present), { useConptyDll: true })
|
|
66
|
-
WindowsConsole.save(k.store, {
|
|
67
|
-
assert.deepEqual(WindowsConsole.ptyOptions(k, present), {})
|
|
110
|
+
assert.deepEqual(WindowsConsole.ptyOptions(k, present, WIN11), {})
|
|
111
|
+
WindowsConsole.save(k.store, { terminal_engine: 'pinokio' }, WIN11)
|
|
112
|
+
assert.deepEqual(WindowsConsole.ptyOptions(k, present, WIN11), { useConptyDll: true })
|
|
113
|
+
WindowsConsole.save(k.store, { terminal_engine: 'system' }, WIN11)
|
|
114
|
+
assert.deepEqual(WindowsConsole.ptyOptions(k, present, WIN11), {})
|
|
68
115
|
})
|
|
69
116
|
|
|
70
117
|
test('the bundled layer counts as there only when both of its files are', (t) => {
|
|
@@ -109,10 +156,10 @@ test('the Settings page draws the row as a dropdown with its explanation', async
|
|
|
109
156
|
const start = view.indexOf('<% config.forEach((c) => { %>')
|
|
110
157
|
const end = view.indexOf('<% }) %>', view.indexOf("<div class='explanation'><%=c.description%></div>")) + '<% }) %>'.length
|
|
111
158
|
assert.ok(start > 0 && end > start)
|
|
112
|
-
const html = ejs.render(view.slice(start, end), { config: WindowsConsole.settings(kernel('win32',
|
|
159
|
+
const html = ejs.render(view.slice(start, end), { config: WindowsConsole.settings(kernel('win32'), WIN10) })
|
|
113
160
|
|
|
114
|
-
assert.match(html, /<select name="
|
|
115
|
-
assert.match(html, /<option value="
|
|
116
|
-
assert.match(html, /<option value="
|
|
161
|
+
assert.match(html, /<select name="terminal_engine">/)
|
|
162
|
+
assert.match(html, /<option value="system">system<\/option>/)
|
|
163
|
+
assert.match(html, /<option value="pinokio" selected>pinokio<\/option>/)
|
|
117
164
|
assert.equal((html.match(/class='explanation'/g) || []).length, 2)
|
|
118
165
|
})
|