pinokiod 8.3.22 → 8.3.26
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 +16 -55
- package/package.json +1 -1
- package/server/index.js +14 -9
- package/server/lib/app_run_tabs.js +51 -0
- package/server/public/agent-bar.js +1 -1
- package/server/public/app-run-tabs.js +30 -0
- package/server/public/files-app/open-folder.js +77 -0
- package/server/public/files-app/toolbar.css +28 -0
- package/server/public/git-page.css +521 -0
- package/server/public/git-page.js +625 -0
- package/server/public/universal-launcher.js +4 -4
- package/server/public/urldropdown.js +0 -1
- package/server/routes/git_page.js +30 -0
- package/server/views/app.ejs +24 -29
- package/server/views/file_browser.ejs +17 -31
- package/server/views/git_page.ejs +21 -0
- package/server/views/index.ejs +2 -2
- package/server/views/partials/home_action_modal.ejs +0 -7
- package/test/launch-settings-ui.test.js +1 -1
- package/test/url-split-modal.test.js +1 -1
- package/test/windows-console.test.js +27 -112
|
@@ -1,30 +1,22 @@
|
|
|
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. There are two copies of it
|
|
4
|
+
// the program and the terminal page. There are two copies of it: the one built
|
|
5
|
+
// into Windows, and a newer one the pty library ships with itself.
|
|
5
6
|
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
7
|
+
// The copy built into Windows 10 dates from around 2020 and is no longer
|
|
8
|
+
// updated. It keeps a full-screen program's "I own the screen" and "send me the
|
|
9
|
+
// mouse" requests to itself, so the page never hears them: it keeps its own
|
|
10
|
+
// scrollback and scrollbar next to the one the program draws, and the wheel and
|
|
11
|
+
// clicks never reach the program. The shipped copy passes both on.
|
|
10
12
|
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
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.
|
|
13
|
+
// So shells on Windows 10 start on the shipped copy. Windows 11 and later keep
|
|
14
|
+
// the one built into Windows, and anywhere but Windows nothing here does
|
|
15
|
+
// anything.
|
|
21
16
|
const fs = require('fs')
|
|
22
17
|
const os = require('os')
|
|
23
18
|
const path = require('path')
|
|
24
19
|
|
|
25
|
-
const KEY = "terminal_engine"
|
|
26
|
-
const SYSTEM = "system"
|
|
27
|
-
const PINOKIO = "pinokio"
|
|
28
20
|
// the first Windows 11 build
|
|
29
21
|
const WINDOWS_11_BUILD = 22000
|
|
30
22
|
|
|
@@ -51,50 +43,19 @@ const bundledAvailable = (files = bundledFiles()) => {
|
|
|
51
43
|
}
|
|
52
44
|
}
|
|
53
45
|
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
const defaultFor = (release = os.release()) => {
|
|
46
|
+
// `release` is os.release(), "10.0.19045" on Windows 10 22H2. A version that
|
|
47
|
+
// cannot be read counts as not Windows 10.
|
|
48
|
+
const isWindows10 = (release = os.release()) => {
|
|
58
49
|
const match = /^\d+\.\d+\.(\d+)/.exec(release || "")
|
|
59
50
|
const build = match ? parseInt(match[1], 10) : 0
|
|
60
|
-
return build > 0 && build < WINDOWS_11_BUILD
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const choice = (store, release) => {
|
|
64
|
-
const saved = store && store.get(KEY)
|
|
65
|
-
return saved === SYSTEM || saved === PINOKIO ? saved : defaultFor(release)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// The row for the Settings page's General list: none except on Windows.
|
|
69
|
-
const settings = (kernel, release) => {
|
|
70
|
-
if (!kernel || kernel.platform !== "win32") return []
|
|
71
|
-
return [{
|
|
72
|
-
key: KEY,
|
|
73
|
-
val: choice(kernel.store, release),
|
|
74
|
-
options: [SYSTEM, PINOKIO],
|
|
75
|
-
description: [
|
|
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.",
|
|
78
|
-
]
|
|
79
|
-
}]
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Called with what the Settings page posted. The row is absent off Windows, and
|
|
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) => {
|
|
87
|
-
const value = config && config[KEY]
|
|
88
|
-
if (value !== SYSTEM && value !== PINOKIO) return
|
|
89
|
-
if (value === defaultFor(release)) store.delete(KEY)
|
|
90
|
-
else store.set(KEY, value)
|
|
51
|
+
return build > 0 && build < WINDOWS_11_BUILD
|
|
91
52
|
}
|
|
92
53
|
|
|
93
54
|
// Extra options for the pty library when a shell is started.
|
|
94
55
|
const ptyOptions = (kernel, available = bundledAvailable, release) => {
|
|
95
56
|
if (!kernel || kernel.platform !== "win32") return {}
|
|
96
|
-
if (
|
|
57
|
+
if (!isWindows10(release)) return {}
|
|
97
58
|
return available() ? { useConptyDll: true } : {}
|
|
98
59
|
}
|
|
99
60
|
|
|
100
|
-
module.exports = {
|
|
61
|
+
module.exports = { ptyOptions, isWindows10, bundledAvailable, bundledFiles, outsideArchive }
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -30,6 +30,8 @@ const registerFileRoutes = require('./routes/files')
|
|
|
30
30
|
const registerAppRoutes = require('./routes/apps')
|
|
31
31
|
const registerConnectRoutes = require('./routes/connect')
|
|
32
32
|
const registerGithubAuthRoutes = require('./routes/github_auth')
|
|
33
|
+
const registerGitPageRoutes = require('./routes/git_page')
|
|
34
|
+
const AppRunTabs = require('./lib/app_run_tabs')
|
|
33
35
|
const ServerAutolaunch = require('./autolaunch')
|
|
34
36
|
const Git = require("../kernel/git")
|
|
35
37
|
const TerminalApi = require('../kernel/api/terminal')
|
|
@@ -76,7 +78,6 @@ const Socket = require('./socket')
|
|
|
76
78
|
const Kernel = require("../kernel")
|
|
77
79
|
const packagejson = require("../package.json")
|
|
78
80
|
const Environment = require("../kernel/environment")
|
|
79
|
-
const WindowsConsole = require("../kernel/windows_console")
|
|
80
81
|
const Cloudflare = require("../kernel/api/cloudflare")
|
|
81
82
|
const Util = require("../kernel/util")
|
|
82
83
|
const Info = require("../kernel/info")
|
|
@@ -2005,6 +2006,7 @@ class Server {
|
|
|
2005
2006
|
editor_tab: editor_tab,
|
|
2006
2007
|
dev_initial_tab,
|
|
2007
2008
|
vault_initial_reveal,
|
|
2009
|
+
...AppRunTabs.locals(req, type, config),
|
|
2008
2010
|
config,
|
|
2009
2011
|
protection_enabled: protectionPreference ? protectionPreference.protection_enabled !== false : false,
|
|
2010
2012
|
autolaunch_app: autolaunchAppState,
|
|
@@ -3310,7 +3312,7 @@ class Server {
|
|
|
3310
3312
|
key: "mode",
|
|
3311
3313
|
val: this.mode,
|
|
3312
3314
|
options: ["desktop", "background"]
|
|
3313
|
-
},
|
|
3315
|
+
}, {
|
|
3314
3316
|
key: "HTTP_PROXY",
|
|
3315
3317
|
val: (system_env.HTTP_PROXY || ""),
|
|
3316
3318
|
show_on_click: "#proxy",
|
|
@@ -5572,7 +5574,6 @@ class Server {
|
|
|
5572
5574
|
}
|
|
5573
5575
|
this.kernel.store.set("mode", config.mode)
|
|
5574
5576
|
}
|
|
5575
|
-
WindowsConsole.save(this.kernel.store, config)
|
|
5576
5577
|
// // 3. Handle Drive
|
|
5577
5578
|
// if (config.drive) {
|
|
5578
5579
|
// // if the home is different from the existing home, go forward
|
|
@@ -10602,7 +10603,7 @@ class Server {
|
|
|
10602
10603
|
key: "mode",
|
|
10603
10604
|
val: this.mode,
|
|
10604
10605
|
options: ["desktop", "background"]
|
|
10605
|
-
},
|
|
10606
|
+
}, {
|
|
10606
10607
|
key: "HTTP_PROXY",
|
|
10607
10608
|
val: (system_env.HTTP_PROXY || ""),
|
|
10608
10609
|
show_on_click: "#proxy",
|
|
@@ -12640,6 +12641,10 @@ class Server {
|
|
|
12640
12641
|
agent: req.agent
|
|
12641
12642
|
})
|
|
12642
12643
|
})
|
|
12644
|
+
registerGitPageRoutes(this.app, {
|
|
12645
|
+
kernel: this.kernel,
|
|
12646
|
+
getPageContext: (req) => ({ theme: this.theme, agent: req.agent })
|
|
12647
|
+
})
|
|
12643
12648
|
/*
|
|
12644
12649
|
* GET /connect/x
|
|
12645
12650
|
* GET /connect/discord
|
|
@@ -16414,10 +16419,10 @@ class Server {
|
|
|
16414
16419
|
await this.chrome(req, res, "launch")
|
|
16415
16420
|
}))
|
|
16416
16421
|
this.app.get("/pinokio/browser/:name/dev", ex(async (req, res) => {
|
|
16417
|
-
|
|
16422
|
+
AppRunTabs.redirectDev(req, res)
|
|
16418
16423
|
}))
|
|
16419
16424
|
this.app.get("/pinokio/browser/:name/browse", ex(async (req, res) => {
|
|
16420
|
-
|
|
16425
|
+
AppRunTabs.redirectDev(req, res)
|
|
16421
16426
|
}))
|
|
16422
16427
|
this.app.get("/pinokio/browser/:name", ex(async (req, res) => {
|
|
16423
16428
|
await this.chrome(req, res, "run")
|
|
@@ -16461,13 +16466,13 @@ class Server {
|
|
|
16461
16466
|
})
|
|
16462
16467
|
}))
|
|
16463
16468
|
this.app.get("/p/:name/dev", ex(async (req, res) => {
|
|
16464
|
-
|
|
16469
|
+
AppRunTabs.redirectDev(req, res)
|
|
16465
16470
|
}))
|
|
16466
16471
|
this.app.get("/p/:name/files", ex(async (req, res) => {
|
|
16467
|
-
|
|
16472
|
+
AppRunTabs.redirectDev(req, res, "files")
|
|
16468
16473
|
}))
|
|
16469
16474
|
this.app.get("/p/:name/browse", ex(async (req, res) => {
|
|
16470
|
-
|
|
16475
|
+
AppRunTabs.redirectDev(req, res)
|
|
16471
16476
|
}))
|
|
16472
16477
|
this.app.get("/p/:name/snapshot_status", ex(async (req, res) => {
|
|
16473
16478
|
let d = Date.now()
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// The app page has one mode, Run. What used to be its Dev mode is now two tabs in
|
|
2
|
+
// the Run sidebar: Files and Git. This module holds the two things the server
|
|
3
|
+
// needs for that:
|
|
4
|
+
//
|
|
5
|
+
// locals(req, type, config) which tab the page should open on
|
|
6
|
+
// ?pinokio_tab=files|git a link asked for it
|
|
7
|
+
// ?git_publish=1 the Git tab, on its Publish section
|
|
8
|
+
// no launcher in the folder Files, since there is nothing to run yet
|
|
9
|
+
// redirectDev(req, res, tab) sends an old Dev mode address to the Run page,
|
|
10
|
+
// without launching the app (Dev mode never launched it), keeping its query
|
|
11
|
+
const TABS = new Set(["files", "git"])
|
|
12
|
+
|
|
13
|
+
const locals = (req, type, config) => {
|
|
14
|
+
const query = (req && req.query) || {}
|
|
15
|
+
const publish = type === "run" && query.git_publish === "1"
|
|
16
|
+
let tab = ""
|
|
17
|
+
if (type === "run") {
|
|
18
|
+
if (publish) {
|
|
19
|
+
tab = "git"
|
|
20
|
+
} else if (TABS.has(query.pinokio_tab)) {
|
|
21
|
+
tab = query.pinokio_tab
|
|
22
|
+
} else if (config && config.init_required && !query.plugin) {
|
|
23
|
+
tab = "files"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return { run_initial_tab: tab, git_initial_publish: publish }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const redirectDev = (req, res, tab) => {
|
|
30
|
+
const query = new URLSearchParams()
|
|
31
|
+
let chosen = tab || ""
|
|
32
|
+
for (const [key, value] of Object.entries(req.query || {})) {
|
|
33
|
+
if (typeof value !== "string") {
|
|
34
|
+
continue
|
|
35
|
+
}
|
|
36
|
+
if (key === "pinokio_dev_tab") {
|
|
37
|
+
if (value === "files") chosen = "files"
|
|
38
|
+
} else if (key === "pinokio.publish") {
|
|
39
|
+
if (value === "1") query.set("git_publish", "1")
|
|
40
|
+
} else {
|
|
41
|
+
query.set(key, value)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (chosen && !query.has("git_publish")) {
|
|
45
|
+
query.set("pinokio_tab", chosen)
|
|
46
|
+
}
|
|
47
|
+
const search = query.toString()
|
|
48
|
+
res.redirect(`/v/${encodeURIComponent(req.params.name)}${search ? `?${search}` : ""}`)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = { locals, redirectDev }
|
|
@@ -1185,7 +1185,7 @@
|
|
|
1185
1185
|
throw new Error(payload && payload.error ? payload.error : 'Failed to create app.');
|
|
1186
1186
|
}
|
|
1187
1187
|
if (handOver('create_app', payload, tool)) return;
|
|
1188
|
-
setStatus('Opening
|
|
1188
|
+
setStatus('Opening the app', 'Redirecting to the new app.');
|
|
1189
1189
|
api.navigate(payload.url);
|
|
1190
1190
|
} catch (error) {
|
|
1191
1191
|
fail(error, 'Failed to continue.');
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Loaded last on the app page (server/views/app.ejs), in Run mode.
|
|
2
|
+
//
|
|
3
|
+
// - Opens the sidebar tab a link asked for (Files or Git; the server passes it
|
|
4
|
+
// in data-tab). This is a chosen tab, so it also applies when the page was
|
|
5
|
+
// opened without launching the app.
|
|
6
|
+
// - Starts the plugin a link asked for (?plugin=...&prompt=...), as its own tab.
|
|
7
|
+
// The page already knows how; it only did it in the old Dev mode.
|
|
8
|
+
(() => {
|
|
9
|
+
const script = document.currentScript
|
|
10
|
+
const tab = script && script.dataset ? script.dataset.tab : ''
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
const url = new URL(window.location.href)
|
|
14
|
+
const had = url.searchParams.has('pinokio_tab') || url.searchParams.has('git_publish')
|
|
15
|
+
url.searchParams.delete('pinokio_tab')
|
|
16
|
+
url.searchParams.delete('git_publish')
|
|
17
|
+
if (had) {
|
|
18
|
+
window.history.replaceState(window.history.state, '', `${url.pathname}${url.search}${url.hash}`)
|
|
19
|
+
}
|
|
20
|
+
} catch (_) {}
|
|
21
|
+
|
|
22
|
+
const link = tab === 'files' || tab === 'git' ? document.querySelector(`#${tab}-tab.frame-link`) : null
|
|
23
|
+
if (link && typeof renderSelection === 'function') {
|
|
24
|
+
renderSelection({ target: link, force: true })
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
if (typeof maybeLaunchPluginFromQuery === 'function') {
|
|
28
|
+
maybeLaunchPluginFromQuery()
|
|
29
|
+
}
|
|
30
|
+
})()
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// The File Explorer button on the Files page (server/views/file_browser.ejs).
|
|
2
|
+
//
|
|
3
|
+
// Opens a folder in the system's file explorer, following the row last clicked
|
|
4
|
+
// in the file list:
|
|
5
|
+
// a folder -> that folder
|
|
6
|
+
// a file -> the folder that holds it
|
|
7
|
+
// nothing -> the app's own folder
|
|
8
|
+
//
|
|
9
|
+
// The file list itself only highlights the open file; clicking a folder just
|
|
10
|
+
// expands it. So this also highlights the clicked folder, the same way a file is
|
|
11
|
+
// highlighted, to show which folder the button will open. The button's tooltip
|
|
12
|
+
// names it too.
|
|
13
|
+
(() => {
|
|
14
|
+
const button = document.getElementById('files-app-open-explorer')
|
|
15
|
+
const tree = document.getElementById('files-app-tree')
|
|
16
|
+
if (!button || !tree) {
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
const root = button.dataset.root || ''
|
|
20
|
+
let target = '' // folder to open, relative to the app's folder; '' is the app's folder
|
|
21
|
+
let markedRow = null // the folder row this script highlighted
|
|
22
|
+
|
|
23
|
+
const describe = () => {
|
|
24
|
+
const label = `Open ${target || 'the app folder'} in File Explorer`
|
|
25
|
+
button.title = label
|
|
26
|
+
button.setAttribute('aria-label', label)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
tree.addEventListener('click', (event) => {
|
|
30
|
+
const row = event.target.closest('.files-app__tree-row')
|
|
31
|
+
if (!row || !tree.contains(row)) {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
// the row's own buttons (open, rename, delete, more) are not a selection
|
|
35
|
+
if (event.target.closest('.files-app__tree-actions, .files-app__tree-more')) {
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
const path = row.dataset.path || ''
|
|
39
|
+
const isFolder = row.dataset.type === 'directory'
|
|
40
|
+
if (markedRow && markedRow !== row) {
|
|
41
|
+
markedRow.dataset.selected = 'false'
|
|
42
|
+
}
|
|
43
|
+
markedRow = null
|
|
44
|
+
const parts = path.split('/').filter(Boolean)
|
|
45
|
+
if (isFolder) {
|
|
46
|
+
row.dataset.selected = 'true'
|
|
47
|
+
markedRow = row
|
|
48
|
+
} else {
|
|
49
|
+
parts.pop()
|
|
50
|
+
}
|
|
51
|
+
target = parts.join('/')
|
|
52
|
+
describe()
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
button.addEventListener('click', () => {
|
|
56
|
+
if (!root) {
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
// a folder that was renamed or deleted since it was clicked falls back to the app's folder
|
|
60
|
+
if (markedRow && !markedRow.isConnected) {
|
|
61
|
+
markedRow = null
|
|
62
|
+
target = ''
|
|
63
|
+
describe()
|
|
64
|
+
}
|
|
65
|
+
const separator = root.includes('\\') ? '\\' : '/'
|
|
66
|
+
const folder = target
|
|
67
|
+
? `${root.replace(/[\\/]+$/, '')}${separator}${target.split('/').join(separator)}`
|
|
68
|
+
: root
|
|
69
|
+
fetch('/openfs', {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers: { 'Content-Type': 'application/json' },
|
|
72
|
+
body: JSON.stringify({ path: folder, command: 'open' }),
|
|
73
|
+
}).catch(() => {})
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
describe()
|
|
77
|
+
})()
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* The Files page has no header. Its two buttons sit in the bar that holds the
|
|
2
|
+
open-file tabs, at the right: File Explorer (opens the folder selected in the
|
|
3
|
+
file list) and Save. On a phone the "back to files" button is at the left of
|
|
4
|
+
the same bar. They stay reachable while the file list is hidden. */
|
|
5
|
+
.files-app__tabbar {
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
gap: 8px;
|
|
9
|
+
padding: 0 10px;
|
|
10
|
+
border-bottom: 1px solid var(--border-color);
|
|
11
|
+
}
|
|
12
|
+
.files-app__tabbar .files-app__tabs {
|
|
13
|
+
flex: 1 1 auto;
|
|
14
|
+
min-width: 0;
|
|
15
|
+
padding-left: 0;
|
|
16
|
+
padding-right: 0;
|
|
17
|
+
border-bottom: none;
|
|
18
|
+
}
|
|
19
|
+
/* with no file open the tab list hides itself; keep its room so the buttons stay at the right */
|
|
20
|
+
.files-app__tabbar .files-app__tabs:empty {
|
|
21
|
+
display: block;
|
|
22
|
+
min-height: 30px;
|
|
23
|
+
}
|
|
24
|
+
.files-app__tabbar .files-app__meta,
|
|
25
|
+
.files-app__tabbar .files-app__save,
|
|
26
|
+
.files-app__tabbar .files-app__mobile-back {
|
|
27
|
+
flex: 0 0 auto;
|
|
28
|
+
}
|