pinokiod 8.3.28 → 8.3.30
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/shell.js +3 -0
- package/kernel/shell_size.js +99 -0
- package/kernel/shells.js +2 -0
- package/package.json +1 -1
- package/server/index.js +2 -0
- package/server/public/agent-bar-about.css +67 -0
- package/server/public/agent-bar-about.js +205 -0
- package/server/public/agent-bar-compose.js +4 -1
- package/server/public/agent-bar-modes.css +78 -0
- package/server/public/agent-bar-modes.js +97 -0
- package/server/public/agent-bar-panel.js +38 -12
- package/server/public/agent-bar.css +7 -5
- package/server/public/agent-bar.js +42 -9
- package/server/public/home-actions-menu.css +188 -0
- package/server/public/home-actions-menu.js +135 -0
- package/server/public/home-shell.css +121 -0
- package/server/public/home-shell.js +290 -0
- package/server/views/app.ejs +1 -1
- package/server/views/index.ejs +40 -1
- package/server/views/partials/home_action_modal.ejs +1 -1
- package/server/views/partials/home_ask_button.ejs +15 -0
- package/server/views/partials/home_shell_button.ejs +21 -0
- package/server/views/partials/main_sidebar.ejs +5 -1
- package/server/views/pre.ejs +1 -1
- package/test/agent-bar-about.test.js +252 -0
- package/test/agent-bar-modes.test.js +191 -0
- package/test/home-actions-menu.test.js +187 -0
- package/test/home-shell.test.js +358 -0
- package/test/shell-size.test.js +166 -0
|
@@ -6,8 +6,11 @@
|
|
|
6
6
|
// and shows the agent's own page (the page Pinokio opened before) in the
|
|
7
7
|
// window. Download is not an agent session and still leaves the page.
|
|
8
8
|
// - "N running" in that bar: every running agent session, in workspaces and in
|
|
9
|
-
// apps, and shells opened inside an app
|
|
10
|
-
// listed. Grouped by where it runs. Each row can
|
|
9
|
+
// apps, and shells opened inside an app or in Pinokio's own folder. An app's
|
|
10
|
+
// own running scripts are not listed. Grouped by where it runs. Each row can
|
|
11
|
+
// be opened or stopped.
|
|
12
|
+
// - A shell picked on home (home-shell.js) is handed to PinokioAgentBar.openShell
|
|
13
|
+
// and opens in the window like any other session.
|
|
11
14
|
// - App pages: the app's own bar (agent-bar-app.js) opens its sessions through
|
|
12
15
|
// window.PinokioAgentDock, which this file provides there. Its "N running" is
|
|
13
16
|
// the same count and the same list, with the app's own sessions first.
|
|
@@ -195,10 +198,16 @@
|
|
|
195
198
|
return `${tail}|${cleanPath(cwd)}|${session || ''}`;
|
|
196
199
|
}
|
|
197
200
|
|
|
201
|
+
// Pinokio's own folder, which the server puts on this script's tag
|
|
202
|
+
const homeTag = document.querySelector('script[data-agent-bar-panel]');
|
|
203
|
+
const homeDir = cleanPath(homeTag && homeTag.dataset.pinokioHome);
|
|
204
|
+
|
|
198
205
|
// Where a folder is: a Pinokio workspace, an app (PINOKIO_HOME/api/<folder>),
|
|
199
|
-
// a plugin, or some other folder (shown like a
|
|
206
|
+
// a plugin, Pinokio's own folder, or some other folder (shown like a
|
|
207
|
+
// workspace, by its name).
|
|
200
208
|
function placeOf(rawPath) {
|
|
201
209
|
const path = cleanPath(rawPath);
|
|
210
|
+
if (homeDir && path === homeDir) return { placeKind: 'home', placeName: 'Pinokio home', folder: '', rootPath: path };
|
|
202
211
|
const match = path.match(/^(.*?\/(api|workspaces|plugin)\/([^/]+))(?:\/|$)/);
|
|
203
212
|
// the brain: the one folder every Ask from the home bar runs in
|
|
204
213
|
if (!match && /\/brain$/.test(path)) return { placeKind: 'ask', placeName: 'Ask', folder: '', rootPath: path };
|
|
@@ -257,11 +266,12 @@
|
|
|
257
266
|
}, place));
|
|
258
267
|
return;
|
|
259
268
|
}
|
|
260
|
-
// A shell the user opened inside an app
|
|
261
|
-
// running scripts) was not started from a bar
|
|
269
|
+
// A shell the user opened inside an app or in Pinokio's own folder.
|
|
270
|
+
// Anything else (an app's own running scripts) was not started from a bar
|
|
271
|
+
// and is not listed.
|
|
262
272
|
if (!id.startsWith('shell/')) return;
|
|
263
273
|
const place = placeOf(shell.path);
|
|
264
|
-
if (place.placeKind !== 'app') return;
|
|
274
|
+
if (place.placeKind !== 'app' && place.placeKind !== 'home') return;
|
|
265
275
|
if (seen.has(id)) return;
|
|
266
276
|
seen.add(id);
|
|
267
277
|
const idQuery = id.indexOf('?');
|
|
@@ -278,7 +288,7 @@
|
|
|
278
288
|
shellSession,
|
|
279
289
|
url: '',
|
|
280
290
|
fullUrl: '',
|
|
281
|
-
appHref: `/p/${encodeURIComponent(place.folder)}
|
|
291
|
+
appHref: place.placeKind === 'app' ? `/p/${encodeURIComponent(place.folder)}` : '',
|
|
282
292
|
}, place));
|
|
283
293
|
});
|
|
284
294
|
found.sort((a, b) => Number(b.start || 0) - Number(a.start || 0));
|
|
@@ -1270,7 +1280,9 @@
|
|
|
1270
1280
|
}
|
|
1271
1281
|
// The session an address belongs to: the running one, as the list has it, or
|
|
1272
1282
|
// one made up from the address (a session that is only being started now).
|
|
1273
|
-
|
|
1283
|
+
// `folder` is where a shell that is being started runs, when it is not this
|
|
1284
|
+
// page's own app (a shell opened from home).
|
|
1285
|
+
function sessionAt(url, label, folder) {
|
|
1274
1286
|
const sessionId = url.searchParams.get('session') || '';
|
|
1275
1287
|
const address = `${url.pathname}${url.search}`;
|
|
1276
1288
|
if (url.pathname.startsWith('/shell/')) {
|
|
@@ -1282,11 +1294,12 @@
|
|
|
1282
1294
|
}
|
|
1283
1295
|
const running = sessions.find((item) => item.kind === 'shell' && item.shellId === shellId && (item.shellSession || '') === sessionId);
|
|
1284
1296
|
if (running) return Object.assign({}, running, { url: address, tabUrl: address });
|
|
1285
|
-
const place = placeOf(appCwd);
|
|
1297
|
+
const place = placeOf(folder || appCwd);
|
|
1286
1298
|
return Object.assign({
|
|
1287
1299
|
key: shellKey(shellId, sessionId), kind: 'shell', label: label || 'Shell',
|
|
1288
1300
|
iconClass: 'fa-solid fa-terminal', start: Date.now(), shellId, shellSession: sessionId,
|
|
1289
|
-
url: address, fullUrl: '', tabUrl: address,
|
|
1301
|
+
url: address, fullUrl: '', tabUrl: address,
|
|
1302
|
+
appHref: place.placeKind === 'app' ? `/p/${encodeURIComponent(place.folder)}` : '',
|
|
1290
1303
|
}, place);
|
|
1291
1304
|
}
|
|
1292
1305
|
const tail = H.pluginTail(url.pathname);
|
|
@@ -1308,7 +1321,7 @@
|
|
|
1308
1321
|
const settings = options || {};
|
|
1309
1322
|
const prompt = typeof settings.prompt === 'string' ? settings.prompt.trim() : '';
|
|
1310
1323
|
const url = launchAddress(rawUrl, prompt);
|
|
1311
|
-
const session = url ? sessionAt(url, settings.label) : null;
|
|
1324
|
+
const session = url ? sessionAt(url, settings.label, settings.folder) : null;
|
|
1312
1325
|
if (!session) return false;
|
|
1313
1326
|
const address = `${url.pathname}${url.search}`;
|
|
1314
1327
|
// What the session is listed by is the user's words (`said`), not the line
|
|
@@ -1327,6 +1340,16 @@
|
|
|
1327
1340
|
}
|
|
1328
1341
|
return true;
|
|
1329
1342
|
}
|
|
1343
|
+
// Pages with the main sidebar: a new shell in `folder` (an app's folder, or
|
|
1344
|
+
// Pinokio's own), with a session of its own. False when there is no docked
|
|
1345
|
+
// window to show it in; the caller then opens the shell's own page.
|
|
1346
|
+
function openShellIn(shell, folder) {
|
|
1347
|
+
if (!shell || typeof shell.href !== 'string' || !folder) return false;
|
|
1348
|
+
if (!document.querySelector('.agent-bar__top')) return false;
|
|
1349
|
+
let href = shell.href;
|
|
1350
|
+
if (!href.includes('session=')) href += `${href.includes('?') ? '&' : '?'}session=${encodeURIComponent(H.newSession())}`;
|
|
1351
|
+
return openFromUrl(href, { launch: true, label: shell.label, folder });
|
|
1352
|
+
}
|
|
1330
1353
|
function offerDock() {
|
|
1331
1354
|
const drawer = document.getElementById('ask-ai-drawer');
|
|
1332
1355
|
appCwd = drawer ? (drawer.dataset.workspaceCwd || '') : '';
|
|
@@ -1945,7 +1968,10 @@
|
|
|
1945
1968
|
}
|
|
1946
1969
|
H = bar.helpers;
|
|
1947
1970
|
if (APP) offerDock();
|
|
1948
|
-
else
|
|
1971
|
+
else {
|
|
1972
|
+
bar.deliver = deliver;
|
|
1973
|
+
bar.openShell = openShellIn;
|
|
1974
|
+
}
|
|
1949
1975
|
document.addEventListener('pointerdown', (event) => {
|
|
1950
1976
|
wins.forEach((win) => {
|
|
1951
1977
|
const part = win.part;
|
|
@@ -842,20 +842,22 @@ body.dark.is-home form.home-search-form input[type="search"]:focus {
|
|
|
842
842
|
background: rgba(255, 255, 255, 0.055);
|
|
843
843
|
}
|
|
844
844
|
|
|
845
|
-
/* the
|
|
846
|
-
|
|
845
|
+
/* the row's boxed buttons (Stop, a status) stay crisp on the highlight instead
|
|
846
|
+
of sinking into it; the icon-only ones (star, actions, share, shell) have
|
|
847
|
+
no box, here or anywhere */
|
|
848
|
+
body.is-home .home-app-line:hover .menu-btns > .btn:not(.home-icon-btn):not(.open-actions-modal) {
|
|
847
849
|
border-color: rgba(15, 23, 42, 0.12) !important;
|
|
848
850
|
background: #ffffff !important;
|
|
849
851
|
}
|
|
850
|
-
body.dark.is-home .home-app-line:hover .menu-btns > .btn {
|
|
852
|
+
body.dark.is-home .home-app-line:hover .menu-btns > .btn:not(.home-icon-btn):not(.open-actions-modal) {
|
|
851
853
|
border-color: rgba(255, 255, 255, 0.12) !important;
|
|
852
854
|
background: rgba(255, 255, 255, 0.08) !important;
|
|
853
855
|
}
|
|
854
|
-
body.is-home .home-app-line:hover .menu-btns > .btn:hover {
|
|
856
|
+
body.is-home .home-app-line:hover .menu-btns > .btn:not(.home-icon-btn):not(.open-actions-modal):hover {
|
|
855
857
|
border-color: rgba(15, 23, 42, 0.22) !important;
|
|
856
858
|
background: #ffffff !important;
|
|
857
859
|
}
|
|
858
|
-
body.dark.is-home .home-app-line:hover .menu-btns > .btn:hover {
|
|
860
|
+
body.dark.is-home .home-app-line:hover .menu-btns > .btn:not(.home-icon-btn):not(.open-actions-modal):hover {
|
|
859
861
|
border-color: rgba(255, 255, 255, 0.22) !important;
|
|
860
862
|
background: rgba(255, 255, 255, 0.13) !important;
|
|
861
863
|
}
|
|
@@ -123,6 +123,11 @@
|
|
|
123
123
|
// and resolves to where each one is; `clear` drops them once a send has
|
|
124
124
|
// been handed over.
|
|
125
125
|
attachments: { token: async () => '', paths: async () => [], clear: () => {} },
|
|
126
|
+
// An Ask pointed at one app (see agent-bar-about.js, which replaces these):
|
|
127
|
+
// `app` is that app ({ id, name }) or null; `prepare` readies its Ask and
|
|
128
|
+
// resolves to what the bar's own request resolves to; `clear` points the
|
|
129
|
+
// bar back at nothing once a send has been handed over.
|
|
130
|
+
about: { app: () => null, prepare: null, clear: () => {} },
|
|
126
131
|
// shared with agent-bar-app.js (function declarations below are hoisted)
|
|
127
132
|
helpers: {
|
|
128
133
|
el, faIcon, menuRow, toolIcon, mapPluginMenuToTools, getStoredTool, setStoredTool,
|
|
@@ -786,6 +791,12 @@
|
|
|
786
791
|
const isDownload = () => state.item === 'download';
|
|
787
792
|
const activeName = () => (isDownload() ? downloadName : (isCreate() ? createName : null));
|
|
788
793
|
const selectedTool = () => state.tools.find((tool) => tool.value === state.tool) || null;
|
|
794
|
+
// the app an Ask is pointed at, if any (only Ask can be)
|
|
795
|
+
const aboutApp = () => (state.item === 'ask' ? api.about.app() : null);
|
|
796
|
+
const hintNow = () => {
|
|
797
|
+
const about = aboutApp();
|
|
798
|
+
return about ? `Ask Pinokio about ${about.name}…` : ITEMS[state.item].placeholder;
|
|
799
|
+
};
|
|
789
800
|
const promptText = () => (state.item === 'create_plugin' && input.value.startsWith(PLUGIN_PROMPT_SEED)
|
|
790
801
|
? input.value.slice(PLUGIN_PROMPT_SEED.length)
|
|
791
802
|
: input.value);
|
|
@@ -918,11 +929,13 @@
|
|
|
918
929
|
root.dataset.item = state.item;
|
|
919
930
|
root.dataset.busy = String(state.busy);
|
|
920
931
|
root.dataset.engaged = String(state.engaged);
|
|
921
|
-
|
|
932
|
+
const about = aboutApp();
|
|
933
|
+
root.dataset.about = about ? about.id : '';
|
|
934
|
+
scopeLabel.textContent = about ? `${item.label} · ${about.name}` : item.label;
|
|
922
935
|
scope.disabled = state.busy;
|
|
923
936
|
scope.classList.toggle('is-open', state.menu === 'mode');
|
|
924
937
|
scope.setAttribute('aria-expanded', String(state.menu === 'mode'));
|
|
925
|
-
input.placeholder =
|
|
938
|
+
input.placeholder = hintNow();
|
|
926
939
|
input.disabled = state.busy;
|
|
927
940
|
input.setAttribute('aria-label', download ? 'Git URL' : 'Message for the agent');
|
|
928
941
|
// the agent: one small icon in the field. Download does not use one.
|
|
@@ -985,7 +998,19 @@
|
|
|
985
998
|
// what the empty text says at rest
|
|
986
999
|
api.leave = leave;
|
|
987
1000
|
api.tool = selectedTool;
|
|
988
|
-
api.hint =
|
|
1001
|
+
api.hint = hintNow;
|
|
1002
|
+
// what the open view's face says, when it is not the mode's own line
|
|
1003
|
+
api.greeting = () => {
|
|
1004
|
+
const about = aboutApp();
|
|
1005
|
+
return about ? `Ask Pinokio about ${about.name}` : '';
|
|
1006
|
+
};
|
|
1007
|
+
// draw the bar again (what an Ask is pointed at changed)
|
|
1008
|
+
api.refresh = () => render();
|
|
1009
|
+
// the modes and choosing one, for the row that names them all (agent-bar-modes.js)
|
|
1010
|
+
api.modes = () => Object.keys(ITEMS).map((key) => ({ key, label: ITEMS[key].label }));
|
|
1011
|
+
// (This can be the first thing done in the bar, so the agents are read here
|
|
1012
|
+
// too: going to the text afterwards no longer does it, the bar is already in use.)
|
|
1013
|
+
api.choose = (key) => { loadTools(); setItem(key); focusInputAtEnd(); };
|
|
989
1014
|
|
|
990
1015
|
function toggleMenu(which) {
|
|
991
1016
|
if (state.busy) return;
|
|
@@ -1118,6 +1143,7 @@
|
|
|
1118
1143
|
setInputValue('');
|
|
1119
1144
|
createName.setValue('');
|
|
1120
1145
|
api.attachments.clear();
|
|
1146
|
+
api.about.clear();
|
|
1121
1147
|
setMsg('');
|
|
1122
1148
|
if (document.activeElement && root.contains(document.activeElement)) document.activeElement.blur();
|
|
1123
1149
|
render();
|
|
@@ -1129,12 +1155,16 @@
|
|
|
1129
1155
|
if (!tool) return;
|
|
1130
1156
|
setBusy(true);
|
|
1131
1157
|
try {
|
|
1132
|
-
//
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1158
|
+
// An Ask from this bar runs in the one shared brain folder
|
|
1159
|
+
// (server/lib/brain.js); one pointed at an app runs in that app's folder.
|
|
1160
|
+
const about = aboutApp();
|
|
1161
|
+
const { response, payload } = about && api.about.prepare
|
|
1162
|
+
? await api.about.prepare(about, input.value.trim(), tool)
|
|
1163
|
+
: await postJson('/brain/ask', {
|
|
1164
|
+
prompt: input.value.trim(),
|
|
1165
|
+
tool: tool.value,
|
|
1166
|
+
uploadToken: await api.attachments.token(),
|
|
1167
|
+
});
|
|
1138
1168
|
if (!response.ok || !payload || !payload.ok || !payload.url) {
|
|
1139
1169
|
throw new Error(payload && payload.error ? payload.error : 'Failed to prepare launcher.');
|
|
1140
1170
|
}
|
|
@@ -1426,6 +1456,9 @@
|
|
|
1426
1456
|
|
|
1427
1457
|
render();
|
|
1428
1458
|
syncActive();
|
|
1459
|
+
// The agents are read as the bar goes in, so the one that is remembered is
|
|
1460
|
+
// shown from the start, not only once the bar is first used.
|
|
1461
|
+
loadTools();
|
|
1429
1462
|
return true;
|
|
1430
1463
|
}
|
|
1431
1464
|
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/* Home: an app row's actions as a dropdown (see home-actions-menu.js).
|
|
2
|
+
On a wide window the page opens the row's actions dialog "docked"; here that
|
|
3
|
+
is drawn as a small menu under the row's button instead of a panel down the
|
|
4
|
+
side of the page. The script puts it in place (left / top). It matches the
|
|
5
|
+
row's shell menu. A narrow window keeps the dialog as it was. */
|
|
6
|
+
@media only screen and (min-width: 961px) {
|
|
7
|
+
@keyframes homeActionsMenuIn {
|
|
8
|
+
from { opacity: 0; transform: translateY(-3px); }
|
|
9
|
+
to { opacity: 1; transform: translateY(0); }
|
|
10
|
+
}
|
|
11
|
+
@keyframes homeActionsMenuOut {
|
|
12
|
+
from { opacity: 1; }
|
|
13
|
+
to { opacity: 0; }
|
|
14
|
+
}
|
|
15
|
+
body.home-actions-menu .home-actions-dialog.is-docked[open] {
|
|
16
|
+
--home-actions-menu-text: #111827;
|
|
17
|
+
--home-actions-menu-muted: rgba(55, 65, 81, 0.78);
|
|
18
|
+
--home-actions-menu-border: rgba(15, 23, 42, 0.16);
|
|
19
|
+
--home-actions-menu-line: rgba(15, 23, 42, 0.09);
|
|
20
|
+
--home-actions-menu-surface: #ffffff;
|
|
21
|
+
--home-actions-menu-hover: rgba(15, 23, 42, 0.06);
|
|
22
|
+
top: 0;
|
|
23
|
+
right: auto;
|
|
24
|
+
bottom: auto;
|
|
25
|
+
left: 0;
|
|
26
|
+
width: 280px;
|
|
27
|
+
max-width: calc(100vw - 16px);
|
|
28
|
+
height: auto;
|
|
29
|
+
max-height: min(70vh, 560px);
|
|
30
|
+
overflow-y: auto;
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
padding: 6px;
|
|
33
|
+
border: 1px solid var(--home-actions-menu-border);
|
|
34
|
+
border-radius: 12px;
|
|
35
|
+
background: var(--home-actions-menu-surface);
|
|
36
|
+
box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.08);
|
|
37
|
+
font: 400 13px system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
38
|
+
letter-spacing: 0;
|
|
39
|
+
color: var(--home-actions-menu-text);
|
|
40
|
+
text-align: left;
|
|
41
|
+
animation: homeActionsMenuIn 100ms ease-out;
|
|
42
|
+
will-change: auto;
|
|
43
|
+
}
|
|
44
|
+
body.dark.home-actions-menu .home-actions-dialog.is-docked[open] {
|
|
45
|
+
--home-actions-menu-text: rgba(250, 250, 250, 0.96);
|
|
46
|
+
--home-actions-menu-muted: rgba(161, 161, 170, 0.92);
|
|
47
|
+
--home-actions-menu-border: rgba(255, 255, 255, 0.16);
|
|
48
|
+
--home-actions-menu-line: rgba(255, 255, 255, 0.1);
|
|
49
|
+
--home-actions-menu-surface: #323334;
|
|
50
|
+
--home-actions-menu-hover: rgba(255, 255, 255, 0.08);
|
|
51
|
+
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
|
|
52
|
+
}
|
|
53
|
+
body.home-actions-menu .home-actions-dialog.is-docked.is-closing[open] {
|
|
54
|
+
animation: homeActionsMenuOut 80ms ease-in forwards;
|
|
55
|
+
}
|
|
56
|
+
@media (prefers-reduced-motion: reduce) {
|
|
57
|
+
body.home-actions-menu .home-actions-dialog.is-docked[open],
|
|
58
|
+
body.home-actions-menu .home-actions-dialog.is-docked.is-closing[open] {
|
|
59
|
+
animation: none;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* the row the menu hangs from already shows the app's icon, name and folder,
|
|
64
|
+
and has the "Open on another device" button */
|
|
65
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-actions-header,
|
|
66
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-actions-section--share {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-actions-shell {
|
|
71
|
+
display: block;
|
|
72
|
+
height: auto;
|
|
73
|
+
min-height: 0;
|
|
74
|
+
overflow: visible;
|
|
75
|
+
}
|
|
76
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-actions-body {
|
|
77
|
+
padding: 0;
|
|
78
|
+
overflow: visible;
|
|
79
|
+
}
|
|
80
|
+
/* sections: a small heading, and a line between them */
|
|
81
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-actions-section + .home-actions-section {
|
|
82
|
+
margin-top: 5px;
|
|
83
|
+
padding-top: 5px;
|
|
84
|
+
border-top: 1px solid var(--home-actions-menu-line);
|
|
85
|
+
}
|
|
86
|
+
/* (the Share section is not shown, so the one after it needs no second line) */
|
|
87
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-actions-section--share:first-child + .home-actions-section {
|
|
88
|
+
margin-top: 0;
|
|
89
|
+
padding-top: 0;
|
|
90
|
+
border-top: 0;
|
|
91
|
+
}
|
|
92
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-actions-section-title {
|
|
93
|
+
margin: 0;
|
|
94
|
+
padding: 7px 8px 4px;
|
|
95
|
+
font-size: 11px;
|
|
96
|
+
font-weight: 600;
|
|
97
|
+
line-height: 1.2;
|
|
98
|
+
letter-spacing: 0.04em;
|
|
99
|
+
text-transform: uppercase;
|
|
100
|
+
color: var(--home-actions-menu-muted);
|
|
101
|
+
}
|
|
102
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-menu-list,
|
|
103
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-actions-command-list,
|
|
104
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-menu-children {
|
|
105
|
+
gap: 1px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* rows: no box of their own, a soft background under the pointer */
|
|
109
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-command,
|
|
110
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-mode-command {
|
|
111
|
+
min-height: 32px;
|
|
112
|
+
gap: 9px;
|
|
113
|
+
padding: 0 8px;
|
|
114
|
+
border: 0;
|
|
115
|
+
border-radius: 7px;
|
|
116
|
+
background: transparent;
|
|
117
|
+
font: inherit;
|
|
118
|
+
color: inherit;
|
|
119
|
+
}
|
|
120
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-command:hover,
|
|
121
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-command:focus-visible,
|
|
122
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-mode-command:hover,
|
|
123
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-mode-command:focus-visible,
|
|
124
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-stop:hover,
|
|
125
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-stop:focus-visible,
|
|
126
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-menu-summary:hover {
|
|
127
|
+
border-color: transparent;
|
|
128
|
+
background: var(--home-actions-menu-hover);
|
|
129
|
+
}
|
|
130
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-mode-command > i,
|
|
131
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-menu-label > i:first-child {
|
|
132
|
+
width: 18px;
|
|
133
|
+
font-size: 12px;
|
|
134
|
+
color: var(--home-actions-menu-muted);
|
|
135
|
+
}
|
|
136
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-command > i:last-child {
|
|
137
|
+
font-size: 10px;
|
|
138
|
+
color: var(--home-actions-menu-muted);
|
|
139
|
+
}
|
|
140
|
+
/* a launcher item that is running: its Stop beside it */
|
|
141
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-menu-row {
|
|
142
|
+
gap: 2px;
|
|
143
|
+
}
|
|
144
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-stop {
|
|
145
|
+
width: 32px;
|
|
146
|
+
min-height: 32px;
|
|
147
|
+
border: 0;
|
|
148
|
+
border-radius: 7px;
|
|
149
|
+
background: transparent;
|
|
150
|
+
}
|
|
151
|
+
/* a launcher's group of items: its name, and the items a step in */
|
|
152
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-menu-group {
|
|
153
|
+
border: 0;
|
|
154
|
+
border-radius: 0;
|
|
155
|
+
overflow: visible;
|
|
156
|
+
}
|
|
157
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-menu-summary {
|
|
158
|
+
min-height: 30px;
|
|
159
|
+
padding: 0 8px;
|
|
160
|
+
border-radius: 7px;
|
|
161
|
+
background: transparent;
|
|
162
|
+
color: var(--home-actions-menu-muted);
|
|
163
|
+
}
|
|
164
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-run-menu-children {
|
|
165
|
+
padding: 0 0 0 12px;
|
|
166
|
+
}
|
|
167
|
+
/* Delete: set apart from the commands above it */
|
|
168
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-mode-command.is-danger {
|
|
169
|
+
position: relative;
|
|
170
|
+
margin-top: 10px;
|
|
171
|
+
color: #b42318;
|
|
172
|
+
}
|
|
173
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-mode-command.is-danger::before {
|
|
174
|
+
content: "";
|
|
175
|
+
position: absolute;
|
|
176
|
+
left: 0;
|
|
177
|
+
right: 0;
|
|
178
|
+
top: -6px;
|
|
179
|
+
border-top: 1px solid var(--home-actions-menu-line);
|
|
180
|
+
pointer-events: none;
|
|
181
|
+
}
|
|
182
|
+
body.dark.home-actions-menu .home-actions-dialog.is-docked .home-mode-command.is-danger {
|
|
183
|
+
color: #f97066;
|
|
184
|
+
}
|
|
185
|
+
body.home-actions-menu .home-actions-dialog.is-docked .home-mode-command.is-danger > i {
|
|
186
|
+
color: inherit;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Home: an app row's actions as a dropdown.
|
|
2
|
+
//
|
|
3
|
+
// The actions button on a row of My Apps (the list icon) opens the row's
|
|
4
|
+
// actions: what the app's launcher offers, and the app's own commands (Settings,
|
|
5
|
+
// Edit launcher, Copy, Move, Delete ...). On a wide window that used to be a
|
|
6
|
+
// panel down the right side of the page. With this file it is a small menu
|
|
7
|
+
// under the button, like the row's other buttons open.
|
|
8
|
+
//
|
|
9
|
+
// The menu is the page's own actions dialog (partials/home_action_modal.ejs),
|
|
10
|
+
// opened and closed by the page's own code, with every button in it working as
|
|
11
|
+
// before. This file only:
|
|
12
|
+
// - marks the page (body.home-actions-menu), which the stylesheet uses to
|
|
13
|
+
// draw the opened dialog as a menu: no header (the row it hangs from already
|
|
14
|
+
// names the app), no Share section (the row has that button), compact rows;
|
|
15
|
+
// - puts the dialog under the button that opened it;
|
|
16
|
+
// - closes it on a press outside it (which does not also open the row under
|
|
17
|
+
// the pointer), when the page scrolls or the window is resized, and once
|
|
18
|
+
// one of its commands has been clicked.
|
|
19
|
+
// A narrow window keeps the dialog as it was: the page does not open it
|
|
20
|
+
// "docked" there, and only a docked dialog is treated as a menu.
|
|
21
|
+
(function (window, document) {
|
|
22
|
+
'use strict';
|
|
23
|
+
|
|
24
|
+
if (window.PinokioHomeActionsMenu || !document.body) return;
|
|
25
|
+
window.PinokioHomeActionsMenu = true;
|
|
26
|
+
document.body.classList.add('home-actions-menu');
|
|
27
|
+
|
|
28
|
+
const DIALOG = '.home-actions-dialog';
|
|
29
|
+
// what the menu offers: a launcher item, an app command, a Stop
|
|
30
|
+
const COMMAND = '.home-run-command, .home-mode-command, .home-run-stop';
|
|
31
|
+
|
|
32
|
+
const openMenu = () => document.querySelector(`${DIALOG}.is-docked[open]`);
|
|
33
|
+
|
|
34
|
+
function triggerOf(dialog) {
|
|
35
|
+
if (!dialog.id) return null;
|
|
36
|
+
return Array.from(document.querySelectorAll('.open-actions-modal'))
|
|
37
|
+
.find((button) => button.getAttribute('data-dialog-id') === dialog.id) || null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function close(dialog) {
|
|
41
|
+
if (!dialog || !dialog.open) return;
|
|
42
|
+
if (typeof dialog.close === 'function') dialog.close();
|
|
43
|
+
else dialog.removeAttribute('open');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Under the button, its left edge on the button's; kept on screen. With no
|
|
47
|
+
// room below it goes above the button; with no room there either, as low as
|
|
48
|
+
// it fits.
|
|
49
|
+
function place(dialog) {
|
|
50
|
+
const button = triggerOf(dialog);
|
|
51
|
+
if (!button) return;
|
|
52
|
+
const rect = button.getBoundingClientRect();
|
|
53
|
+
const gap = 6;
|
|
54
|
+
const edge = 8;
|
|
55
|
+
const width = dialog.offsetWidth;
|
|
56
|
+
const height = dialog.offsetHeight;
|
|
57
|
+
let left = Math.min(rect.left, window.innerWidth - width - edge);
|
|
58
|
+
left = Math.max(edge, left);
|
|
59
|
+
let top = rect.bottom + gap;
|
|
60
|
+
if (top + height > window.innerHeight - edge) {
|
|
61
|
+
const above = rect.top - gap - height;
|
|
62
|
+
top = above >= edge ? above : Math.max(edge, window.innerHeight - height - edge);
|
|
63
|
+
}
|
|
64
|
+
dialog.style.left = `${Math.round(left)}px`;
|
|
65
|
+
dialog.style.top = `${Math.round(top)}px`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// The page opens a dialog by giving it `open`. A dialog that is not docked
|
|
69
|
+
// (a narrow window) is the page's own centred one: its place is not this
|
|
70
|
+
// file's, so what was set for a menu is taken off.
|
|
71
|
+
function opened(dialog) {
|
|
72
|
+
if (!dialog.matches || !dialog.matches(DIALOG)) return;
|
|
73
|
+
if (dialog.open && dialog.classList.contains('is-docked')) {
|
|
74
|
+
place(dialog);
|
|
75
|
+
} else {
|
|
76
|
+
dialog.style.left = '';
|
|
77
|
+
dialog.style.top = '';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
new MutationObserver((records) => {
|
|
81
|
+
records.forEach((record) => opened(record.target));
|
|
82
|
+
}).observe(document.body, { attributes: true, attributeFilter: ['open'], subtree: true });
|
|
83
|
+
|
|
84
|
+
// A row of My Apps opens its app on a click anywhere on it, and the rows fill
|
|
85
|
+
// the page. The press that closes the menu must not also be that click: the
|
|
86
|
+
// click that follows it is cancelled when it would open a row. A click on a
|
|
87
|
+
// button or a link is left alone.
|
|
88
|
+
function keepRowShut() {
|
|
89
|
+
const done = () => {
|
|
90
|
+
document.removeEventListener('click', cancel, true);
|
|
91
|
+
document.removeEventListener('pointerdown', done, true);
|
|
92
|
+
};
|
|
93
|
+
function cancel(event) {
|
|
94
|
+
done();
|
|
95
|
+
const target = event.target;
|
|
96
|
+
if (!(target instanceof Element) || !target.closest('.home-app-line')) return;
|
|
97
|
+
if (target.closest('button, a, input, select, textarea, label, summary, dialog')) return;
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
event.stopPropagation();
|
|
100
|
+
}
|
|
101
|
+
document.addEventListener('click', cancel, true);
|
|
102
|
+
// (the next press is something else: a press that was not followed by a click)
|
|
103
|
+
document.addEventListener('pointerdown', done, true);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// a press anywhere else closes it; a press on its own button is the page's (it toggles)
|
|
107
|
+
document.addEventListener('pointerdown', (event) => {
|
|
108
|
+
const dialog = openMenu();
|
|
109
|
+
if (!dialog) return;
|
|
110
|
+
const target = event.target;
|
|
111
|
+
if (!(target instanceof Node) || dialog.contains(target)) return;
|
|
112
|
+
const button = triggerOf(dialog);
|
|
113
|
+
if (button && button.contains(target)) return;
|
|
114
|
+
// a question the page is asking over the menu (a confirm, an editor)
|
|
115
|
+
if (target.closest && target.closest('.swal2-container')) return;
|
|
116
|
+
close(dialog);
|
|
117
|
+
keepRowShut();
|
|
118
|
+
}, true);
|
|
119
|
+
|
|
120
|
+
// The button moves with the page; the menu does not follow it.
|
|
121
|
+
window.addEventListener('scroll', (event) => {
|
|
122
|
+
const dialog = openMenu();
|
|
123
|
+
if (dialog && !(event.target instanceof Node && dialog.contains(event.target))) close(dialog);
|
|
124
|
+
}, true);
|
|
125
|
+
window.addEventListener('resize', () => close(openMenu()));
|
|
126
|
+
|
|
127
|
+
// A command was picked: the menu has done its job. After the page's own
|
|
128
|
+
// handlers, which read the row from where the button is.
|
|
129
|
+
document.addEventListener('click', (event) => {
|
|
130
|
+
const dialog = openMenu();
|
|
131
|
+
if (!dialog || !(event.target instanceof Element) || !dialog.contains(event.target)) return;
|
|
132
|
+
if (!event.target.closest(COMMAND)) return;
|
|
133
|
+
window.setTimeout(() => close(dialog), 0);
|
|
134
|
+
}, true);
|
|
135
|
+
})(window, document);
|