pinokiod 8.3.26 → 8.3.28
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/package.json +1 -1
- package/server/index.js +5 -3
- package/server/lib/app_run_tabs.js +29 -17
- package/server/public/agent-bar-panel.js +3 -1
- package/server/public/app-run-tabs.js +0 -10
- package/server/public/files-app/open-folder.js +58 -41
- package/server/public/files-app/toolbar.css +27 -5
- package/server/public/git-page.css +0 -1
- package/server/public/git-page.js +269 -149
- package/server/routes/git_page.js +4 -6
- package/server/views/app.ejs +18 -4
- package/server/views/file_browser.ejs +3 -4
- package/server/views/index.ejs +2 -2
- package/test/agent-bar-new-tab.test.js +60 -0
- package/test/app-git-files-tabs.test.js +84 -0
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -1857,7 +1857,7 @@ class Server {
|
|
|
1857
1857
|
let autoselect
|
|
1858
1858
|
let run_tab
|
|
1859
1859
|
if (type === "run") {
|
|
1860
|
-
if (options && options.no_autoselect) {
|
|
1860
|
+
if ((options && options.no_autoselect) || AppRunTabs.chosen(req)) {
|
|
1861
1861
|
run_tab = "/v/" + name
|
|
1862
1862
|
autoselect = false
|
|
1863
1863
|
} else {
|
|
@@ -10673,11 +10673,13 @@ class Server {
|
|
|
10673
10673
|
const baseUrl = `${protocol}://${host}`
|
|
10674
10674
|
|
|
10675
10675
|
const wantsCreatePage = Object.prototype.hasOwnProperty.call(req.query, 'create')
|
|
10676
|
-
|
|
10676
|
+
// `page` is one of Pinokio's own pages to show in this window instead of home
|
|
10677
|
+
const startPage = typeof req.query.page === 'string' && /^\/[^/\\]/.test(req.query.page) ? req.query.page : ''
|
|
10678
|
+
const initialUrl = new URL(startPage || (wantsCreatePage ? '/create/page' : '/home'), baseUrl)
|
|
10677
10679
|
const defaultUrl = new URL('/home', baseUrl)
|
|
10678
10680
|
|
|
10679
10681
|
for (const [key, value] of Object.entries(req.query)) {
|
|
10680
|
-
if (key === 'session' || key === 'create') {
|
|
10682
|
+
if (key === 'session' || key === 'create' || key === 'page') {
|
|
10681
10683
|
continue
|
|
10682
10684
|
}
|
|
10683
10685
|
if (Array.isArray(value)) {
|
|
@@ -2,43 +2,55 @@
|
|
|
2
2
|
// the Run sidebar: Files and Git. This module holds the two things the server
|
|
3
3
|
// needs for that:
|
|
4
4
|
//
|
|
5
|
-
//
|
|
6
|
-
// ?pinokio_tab=files|git
|
|
5
|
+
// chosen(req) the tab a link asked for, if any
|
|
6
|
+
// ?pinokio_tab=files|git that tab
|
|
7
7
|
// ?git_publish=1 the Git tab, on its Publish section
|
|
8
|
-
//
|
|
8
|
+
// A link that asks for a tab opens the page without launching the app.
|
|
9
|
+
// locals(req, type, config) which tab the page should open on
|
|
10
|
+
// the chosen tab; or, for a plain visit (an address with nothing after
|
|
11
|
+
// it), Files when the folder has nothing of its own to show: no launcher
|
|
12
|
+
// menu and no index.html, so the only thing Pinokio would open is its
|
|
13
|
+
// plain listing of the folder
|
|
9
14
|
// redirectDev(req, res, tab) sends an old Dev mode address to the Run page,
|
|
10
15
|
// without launching the app (Dev mode never launched it), keeping its query
|
|
11
16
|
const TABS = new Set(["files", "git"])
|
|
12
17
|
|
|
18
|
+
const chosen = (req) => {
|
|
19
|
+
const query = (req && req.query) || {}
|
|
20
|
+
if (query.git_publish === "1") return "git"
|
|
21
|
+
return TABS.has(query.pinokio_tab) ? query.pinokio_tab : ""
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// the folder's default menu item is the plain listing of it that Pinokio falls back to
|
|
25
|
+
const onlyHasListing = (req, config) => {
|
|
26
|
+
const menu = config && Array.isArray(config.menu) ? config.menu : []
|
|
27
|
+
const first = menu.find((item) => item && item.default)
|
|
28
|
+
return Boolean(first && req && req.params && first.href === `/files/api/${req.params.name}`)
|
|
29
|
+
}
|
|
30
|
+
|
|
13
31
|
const locals = (req, type, config) => {
|
|
14
32
|
const query = (req && req.query) || {}
|
|
15
|
-
const publish = type === "run" && query.git_publish === "1"
|
|
16
33
|
let tab = ""
|
|
17
34
|
if (type === "run") {
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
}
|
|
35
|
+
// a link that carries anything else (Settings from Home, a plugin, a file to reveal) keeps its own destination
|
|
36
|
+
tab = chosen(req) || (Object.keys(query).length === 0 && onlyHasListing(req, config) ? "files" : "")
|
|
25
37
|
}
|
|
26
|
-
return { run_initial_tab: tab, git_initial_publish:
|
|
38
|
+
return { run_initial_tab: tab, git_initial_publish: type === "run" && query.git_publish === "1" }
|
|
27
39
|
}
|
|
28
40
|
|
|
29
41
|
const redirectDev = (req, res, tab) => {
|
|
30
42
|
const query = new URLSearchParams()
|
|
31
43
|
let chosen = tab || ""
|
|
32
44
|
for (const [key, value] of Object.entries(req.query || {})) {
|
|
33
|
-
if (typeof value !== "string") {
|
|
34
|
-
continue
|
|
35
|
-
}
|
|
36
45
|
if (key === "pinokio_dev_tab") {
|
|
37
46
|
if (value === "files") chosen = "files"
|
|
38
47
|
} else if (key === "pinokio.publish") {
|
|
39
48
|
if (value === "1") query.set("git_publish", "1")
|
|
40
49
|
} else {
|
|
41
|
-
|
|
50
|
+
// a value given more than once stays given more than once
|
|
51
|
+
for (const item of [].concat(value)) {
|
|
52
|
+
if (typeof item === "string") query.append(key, item)
|
|
53
|
+
}
|
|
42
54
|
}
|
|
43
55
|
}
|
|
44
56
|
if (chosen && !query.has("git_publish")) {
|
|
@@ -48,4 +60,4 @@ const redirectDev = (req, res, tab) => {
|
|
|
48
60
|
res.redirect(`/v/${encodeURIComponent(req.params.name)}${search ? `?${search}` : ""}`)
|
|
49
61
|
}
|
|
50
62
|
|
|
51
|
-
module.exports = { locals, redirectDev }
|
|
63
|
+
module.exports = { chosen, locals, redirectDev }
|
|
@@ -605,7 +605,9 @@
|
|
|
605
605
|
moreRow('Open in a new tab', 'fa-solid fa-arrow-up-right-from-square', () => {
|
|
606
606
|
const session = win.session;
|
|
607
607
|
const url = session && (session.tabUrl || session.fullUrl || session.url);
|
|
608
|
-
|
|
608
|
+
// opened inside a top-level Pinokio window, which in the desktop app is what
|
|
609
|
+
// carries the bar the window is dragged by
|
|
610
|
+
if (url) whenRunning(session, () => window.open(`/?page=${encodeURIComponent(url)}`, '_blank', 'noopener'));
|
|
609
611
|
});
|
|
610
612
|
// the session page's own appearance button, pressed from here (see embed below). Its
|
|
611
613
|
// "sync size" button has no row: Refresh reloads the page, which sends the size too.
|
|
@@ -9,16 +9,6 @@
|
|
|
9
9
|
const script = document.currentScript
|
|
10
10
|
const tab = script && script.dataset ? script.dataset.tab : ''
|
|
11
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
12
|
const link = tab === 'files' || tab === 'git' ? document.querySelector(`#${tab}-tab.frame-link`) : null
|
|
23
13
|
if (link && typeof renderSelection === 'function') {
|
|
24
14
|
renderSelection({ target: link, force: true })
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
// The File Explorer button on the Files page (server/views/file_browser.ejs).
|
|
2
2
|
//
|
|
3
|
-
// Opens a folder in the system's file explorer
|
|
4
|
-
// in the file list
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// nothing -> the app's own folder
|
|
3
|
+
// Opens a folder in the system's file explorer:
|
|
4
|
+
// a folder was clicked in the file list -> that folder
|
|
5
|
+
// otherwise -> the folder of the file being edited
|
|
6
|
+
// nothing is open -> the app's own folder
|
|
8
7
|
//
|
|
9
8
|
// The file list itself only highlights the open file; clicking a folder just
|
|
10
|
-
// expands it. So this
|
|
11
|
-
//
|
|
12
|
-
//
|
|
9
|
+
// expands it. So this highlights the clicked folder too, to show which folder
|
|
10
|
+
// the button will open, and the button's tooltip names it. Opening or switching
|
|
11
|
+
// to a file afterwards takes over again.
|
|
13
12
|
(() => {
|
|
14
13
|
const button = document.getElementById('files-app-open-explorer')
|
|
15
14
|
const tree = document.getElementById('files-app-tree')
|
|
@@ -17,59 +16,77 @@
|
|
|
17
16
|
return
|
|
18
17
|
}
|
|
19
18
|
const root = button.dataset.root || ''
|
|
20
|
-
|
|
21
|
-
let
|
|
19
|
+
const editedFile = () => (window.FilesApp && window.FilesApp.state && window.FilesApp.state.activePath) || ''
|
|
20
|
+
let clicked = null // the clicked folder: { path, row, edited: the file being edited at that moment }
|
|
22
21
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const forget = () => {
|
|
23
|
+
if (clicked && clicked.row.isConnected) {
|
|
24
|
+
clicked.row.dataset.selected = 'false'
|
|
25
|
+
}
|
|
26
|
+
clicked = null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// the folder to open, relative to the app's folder; '' is the app's folder
|
|
30
|
+
const target = () => {
|
|
31
|
+
if (clicked && !clicked.row.isConnected) {
|
|
32
|
+
// the list was redrawn: the folder is still the target if it is still listed
|
|
33
|
+
const row = Array.from(tree.querySelectorAll('.files-app__tree-row'))
|
|
34
|
+
.find((item) => item.dataset.type === 'directory' && item.dataset.path === clicked.row.dataset.path)
|
|
35
|
+
if (row) {
|
|
36
|
+
row.dataset.selected = 'true'
|
|
37
|
+
clicked.row = row
|
|
38
|
+
} else {
|
|
39
|
+
clicked = null
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (clicked && clicked.edited !== editedFile()) {
|
|
43
|
+
forget()
|
|
44
|
+
}
|
|
45
|
+
if (clicked) {
|
|
46
|
+
return clicked.path
|
|
47
|
+
}
|
|
48
|
+
return editedFile().split('/').filter(Boolean).slice(0, -1).join('/')
|
|
27
49
|
}
|
|
28
50
|
|
|
29
51
|
tree.addEventListener('click', (event) => {
|
|
30
52
|
const row = event.target.closest('.files-app__tree-row')
|
|
31
|
-
if (!row || !tree.contains(row)) {
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
53
|
// 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')) {
|
|
54
|
+
if (!row || event.target.closest('.files-app__tree-actions, .files-app__tree-more')) {
|
|
36
55
|
return
|
|
37
56
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (markedRow && markedRow !== row) {
|
|
41
|
-
markedRow.dataset.selected = 'false'
|
|
42
|
-
}
|
|
43
|
-
markedRow = null
|
|
44
|
-
const parts = path.split('/').filter(Boolean)
|
|
45
|
-
if (isFolder) {
|
|
57
|
+
forget()
|
|
58
|
+
if (row.dataset.type === 'directory') {
|
|
46
59
|
row.dataset.selected = 'true'
|
|
47
|
-
|
|
48
|
-
} else {
|
|
49
|
-
parts.pop()
|
|
60
|
+
clicked = { path: (row.dataset.path || '').split('/').filter(Boolean).join('/'), row, edited: editedFile() }
|
|
50
61
|
}
|
|
51
|
-
target = parts.join('/')
|
|
52
|
-
describe()
|
|
53
62
|
})
|
|
54
63
|
|
|
64
|
+
const describe = () => {
|
|
65
|
+
const label = `Open ${target() || 'the app folder'} in File Explorer`
|
|
66
|
+
button.title = label
|
|
67
|
+
button.setAttribute('aria-label', label)
|
|
68
|
+
}
|
|
69
|
+
button.addEventListener('pointerenter', describe)
|
|
70
|
+
button.addEventListener('focus', describe)
|
|
71
|
+
// switching to another open file takes over from a clicked folder right away
|
|
72
|
+
const tabs = document.getElementById('files-app-tabs')
|
|
73
|
+
if (tabs) {
|
|
74
|
+
tabs.addEventListener('click', () => setTimeout(describe, 0))
|
|
75
|
+
}
|
|
76
|
+
|
|
55
77
|
button.addEventListener('click', () => {
|
|
56
78
|
if (!root) {
|
|
57
79
|
return
|
|
58
80
|
}
|
|
59
|
-
|
|
60
|
-
if (markedRow && !markedRow.isConnected) {
|
|
61
|
-
markedRow = null
|
|
62
|
-
target = ''
|
|
63
|
-
describe()
|
|
64
|
-
}
|
|
81
|
+
const folder = target()
|
|
65
82
|
const separator = root.includes('\\') ? '\\' : '/'
|
|
66
|
-
const folder = target
|
|
67
|
-
? `${root.replace(/[\\/]+$/, '')}${separator}${target.split('/').join(separator)}`
|
|
68
|
-
: root
|
|
69
83
|
fetch('/openfs', {
|
|
70
84
|
method: 'POST',
|
|
71
85
|
headers: { 'Content-Type': 'application/json' },
|
|
72
|
-
body: JSON.stringify({
|
|
86
|
+
body: JSON.stringify({
|
|
87
|
+
path: folder ? `${root.replace(/[\\/]+$/, '')}${separator}${folder.split('/').join(separator)}` : root,
|
|
88
|
+
command: 'open',
|
|
89
|
+
}),
|
|
73
90
|
}).catch(() => {})
|
|
74
91
|
})
|
|
75
92
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* The Files page has no header. Its
|
|
2
|
-
open-file tabs
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/* The Files page has no header. Its buttons sit in the bar that holds the
|
|
2
|
+
open-file tabs: at the left, the one that hides or shows the file list (on a
|
|
3
|
+
phone, "back to files" instead); at the right, File Explorer (opens the
|
|
4
|
+
folder selected in the file list) and Save. */
|
|
5
5
|
.files-app__tabbar {
|
|
6
6
|
display: flex;
|
|
7
7
|
align-items: center;
|
|
@@ -23,6 +23,28 @@
|
|
|
23
23
|
}
|
|
24
24
|
.files-app__tabbar .files-app__meta,
|
|
25
25
|
.files-app__tabbar .files-app__save,
|
|
26
|
-
.files-app__tabbar .files-app__mobile-back
|
|
26
|
+
.files-app__tabbar .files-app__mobile-back,
|
|
27
|
+
.files-app__tabbar .files-app__sidebar-toggle {
|
|
27
28
|
flex: 0 0 auto;
|
|
28
29
|
}
|
|
30
|
+
/* On a phone the file list and the editor take turns. The bar stays above the
|
|
31
|
+
file list too, so Save and File Explorer are there in both. */
|
|
32
|
+
.files-app.files-app--mobile[data-mobile-view='list'] .files-app__main {
|
|
33
|
+
display: block;
|
|
34
|
+
flex: 0 0 auto;
|
|
35
|
+
order: -1;
|
|
36
|
+
}
|
|
37
|
+
.files-app.files-app--mobile[data-mobile-view='list'] .files-app__editor,
|
|
38
|
+
.files-app.files-app--mobile[data-mobile-view='list'] .files-app__status {
|
|
39
|
+
display: none;
|
|
40
|
+
}
|
|
41
|
+
/* an ordinary button in the bar, not a tab floating over the edge of the file list */
|
|
42
|
+
.files-app__tabbar .files-app__sidebar-toggle {
|
|
43
|
+
position: static;
|
|
44
|
+
transform: none;
|
|
45
|
+
width: 28px;
|
|
46
|
+
height: 28px;
|
|
47
|
+
border: 1px solid var(--border-color);
|
|
48
|
+
border-radius: 6px;
|
|
49
|
+
box-shadow: none;
|
|
50
|
+
}
|
|
@@ -12,7 +12,6 @@ body.git-page {
|
|
|
12
12
|
--git-danger: #b42318;
|
|
13
13
|
--git-add-bg: #e6ffed;
|
|
14
14
|
--git-del-bg: #ffeef0;
|
|
15
|
-
--git-dirty-bg: rgba(234, 179, 8, 0.18);
|
|
16
15
|
--git-dirty-text: #92600a;
|
|
17
16
|
--git-clean-text: #1c7a43;
|
|
18
17
|
/* the shared stylesheet makes body a flex row, which would shrink the page to its content */
|