pinokiod 8.3.14 → 8.3.16

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.
@@ -2404,6 +2404,120 @@ body.dark .terminal-config-menu .terminal-config-input:focus {
2404
2404
  .terminal-config-open .terminal-config-menu {
2405
2405
  display: block;
2406
2406
  }
2407
+ /* The parts terminal-settings-sheet.js adds. They show on a phone only. */
2408
+ .terminal-config-sheet-head,
2409
+ .terminal-config-step,
2410
+ .terminal-config-fold {
2411
+ display: none;
2412
+ }
2413
+ .terminal-config-stepper {
2414
+ display: contents;
2415
+ }
2416
+ /* A phone: the menu is a sheet at the bottom of the screen. (The menu is placed
2417
+ by its own script and, in the agent panel, by the panel: the sheet's place
2418
+ has to win over both.) */
2419
+ @media (max-width: 768px) and (pointer: coarse) {
2420
+ html body > .terminal-config-menu.terminal-config-sheet {
2421
+ left: 0 !important;
2422
+ right: 0 !important;
2423
+ top: auto !important;
2424
+ bottom: 0 !important;
2425
+ max-height: 85%;
2426
+ padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px));
2427
+ border-radius: 16px 16px 0 0;
2428
+ border-width: 1px 0 0;
2429
+ box-sizing: border-box;
2430
+ overscroll-behavior: contain;
2431
+ }
2432
+ .terminal-config-sheet .terminal-config-title {
2433
+ display: none;
2434
+ }
2435
+ .terminal-config-sheet .terminal-config-sheet-head {
2436
+ display: flex;
2437
+ align-items: center;
2438
+ justify-content: space-between;
2439
+ position: sticky;
2440
+ top: 0;
2441
+ z-index: 1;
2442
+ padding: 14px 0 10px;
2443
+ background: inherit;
2444
+ }
2445
+ .terminal-config-sheet .terminal-config-sheet-title {
2446
+ font-size: 16px;
2447
+ font-weight: 600;
2448
+ }
2449
+ .terminal-config-sheet .terminal-config-sheet-done,
2450
+ .terminal-config-sheet .terminal-config-step,
2451
+ .terminal-config-sheet .terminal-config-fold {
2452
+ font: inherit;
2453
+ font-size: 16px;
2454
+ color: inherit;
2455
+ background: transparent;
2456
+ border: 1px solid rgba(128, 128, 128, 0.4);
2457
+ border-radius: 8px;
2458
+ min-height: 44px;
2459
+ cursor: pointer;
2460
+ touch-action: manipulation;
2461
+ }
2462
+ .terminal-config-sheet .terminal-config-sheet-done {
2463
+ padding: 0 16px;
2464
+ font-weight: 600;
2465
+ }
2466
+ .terminal-config-sheet .terminal-config-label,
2467
+ .terminal-config-sheet .terminal-config-note,
2468
+ .terminal-config-sheet .terminal-config-help {
2469
+ font-size: 13px;
2470
+ }
2471
+ /* 16px: smaller text in a field makes the phone zoom the page in on a tap */
2472
+ .terminal-config-sheet .terminal-config-select,
2473
+ .terminal-config-sheet .terminal-config-input {
2474
+ font-size: 16px;
2475
+ min-height: 44px;
2476
+ box-sizing: border-box;
2477
+ }
2478
+ .terminal-config-sheet .terminal-config-stepper {
2479
+ display: flex;
2480
+ gap: 8px;
2481
+ }
2482
+ .terminal-config-sheet .terminal-config-stepper .terminal-config-input {
2483
+ flex: 1;
2484
+ min-width: 0;
2485
+ text-align: center;
2486
+ }
2487
+ .terminal-config-sheet .terminal-config-step {
2488
+ display: block;
2489
+ flex: 0 0 56px;
2490
+ font-size: 22px;
2491
+ line-height: 1;
2492
+ }
2493
+ /* the theme colors are folded away until their row is pressed */
2494
+ .terminal-config-sheet .terminal-config-fold {
2495
+ display: flex;
2496
+ align-items: center;
2497
+ justify-content: space-between;
2498
+ padding: 0 12px;
2499
+ }
2500
+ .terminal-config-sheet .terminal-config-fold::after {
2501
+ content: '\203A';
2502
+ font-size: 20px;
2503
+ transform: rotate(90deg);
2504
+ }
2505
+ .terminal-config-sheet .terminal-config-fold[aria-expanded='true']::after {
2506
+ transform: rotate(-90deg);
2507
+ }
2508
+ .terminal-config-sheet .terminal-config-theme .terminal-config-subtitle,
2509
+ .terminal-config-sheet .terminal-config-theme:not(.terminal-config-theme--open) .terminal-config-help,
2510
+ .terminal-config-sheet .terminal-config-theme:not(.terminal-config-theme--open) .terminal-config-theme-grid {
2511
+ display: none;
2512
+ }
2513
+ .terminal-config-sheet .terminal-config-theme-row {
2514
+ grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr) 44px;
2515
+ }
2516
+ .terminal-config-sheet .terminal-config-theme-clear,
2517
+ .terminal-config-sheet .terminal-config-reset {
2518
+ min-height: 44px;
2519
+ }
2520
+ }
2407
2521
  .terminal-keyboard-backdrop {
2408
2522
  position: fixed;
2409
2523
  inset: 0;
@@ -0,0 +1,66 @@
1
+ // The terminal appearance menu on a phone.
2
+ //
3
+ // terminal-settings.js builds the menu and decides everything it sets. This
4
+ // file adds three parts to it, which the stylesheet shows on a phone only (a
5
+ // narrow screen that is used with a finger) where the menu is a sheet at the
6
+ // bottom of the screen:
7
+ // - a head with a Done button,
8
+ // - a minus and a plus beside the font size,
9
+ // - a row that opens the theme colors, which start folded away.
10
+ // Everywhere else the parts are hidden and the menu is as it was.
11
+ (function (window, document) {
12
+ 'use strict';
13
+ const settings = window.PinokioTerminalSettings;
14
+ if (!settings) return;
15
+
16
+ function el(tag, className, text) {
17
+ const node = document.createElement(tag);
18
+ node.className = className;
19
+ if (tag === 'button') node.type = 'button';
20
+ if (text) node.textContent = text;
21
+ return node;
22
+ }
23
+
24
+ function dress(record) {
25
+ const { menu, sizeInput, themeSection } = record;
26
+ if (menu.classList.contains('terminal-config-sheet')) return;
27
+ menu.classList.add('terminal-config-sheet');
28
+
29
+ const head = el('div', 'terminal-config-sheet-head');
30
+ const done = el('button', 'terminal-config-sheet-done', 'Done');
31
+ done.addEventListener('click', () => record.close());
32
+ head.append(el('span', 'terminal-config-sheet-title', 'Terminal appearance'), done);
33
+ menu.insertBefore(head, menu.firstChild);
34
+
35
+ // one step from the size in use: the one set here, or else the terminal's own
36
+ const step = (by, label, sign) => {
37
+ const button = el('button', 'terminal-config-step', sign);
38
+ button.setAttribute('aria-label', label);
39
+ button.addEventListener('click', () => {
40
+ const size = Number(sizeInput.value || sizeInput.placeholder);
41
+ if (size) settings.updateFontSize(size + by);
42
+ });
43
+ return button;
44
+ };
45
+ const stepper = el('div', 'terminal-config-stepper');
46
+ sizeInput.parentNode.insertBefore(stepper, sizeInput);
47
+ stepper.append(step(-1, 'Smaller text', '\u2212'), sizeInput, step(1, 'Larger text', '+'));
48
+
49
+ const fold = el('button', 'terminal-config-fold', 'Theme colors');
50
+ fold.setAttribute('aria-expanded', 'false');
51
+ fold.addEventListener('click', () => {
52
+ fold.setAttribute('aria-expanded', String(themeSection.classList.toggle('terminal-config-theme--open')));
53
+ });
54
+ themeSection.insertBefore(fold, themeSection.firstChild);
55
+ }
56
+
57
+ // A menu is dressed as its button is pressed, before it opens: terminals, and
58
+ // their menus, can be made at any time.
59
+ document.addEventListener('click', (event) => {
60
+ const button = event.target.closest && event.target.closest('.terminal-config-button');
61
+ if (!button) return;
62
+ settings.menus.forEach((record) => {
63
+ if (record.button === button) dress(record);
64
+ });
65
+ }, true);
66
+ })(window, document);
@@ -1890,7 +1890,12 @@
1890
1890
  }
1891
1891
  });
1892
1892
 
1893
- const handleSizeChange = () => {
1893
+ const handleSizeChange = (event) => {
1894
+ // While typing, a number that is not a size yet ("1" on the way to "14")
1895
+ // is left as typed. Leaving the field settles it.
1896
+ if (event.type === 'input' && !sizeInput.validity.valid) {
1897
+ return;
1898
+ }
1894
1899
  const raw = sizeInput.value.trim();
1895
1900
  if (!raw) {
1896
1901
  settings.updateFontSize(null);
@@ -8378,6 +8378,8 @@ body.dark .pinokio-custom-terminal-header {
8378
8378
  <script src="/storage-sweep.js"></script>
8379
8379
  <script src="/agent-bar.js" data-agent-bar="true"></script>
8380
8380
  <script src="/agent-bar-app.js" data-agent-bar-app="true"></script>
8381
+ <link rel="stylesheet" href="/agent-bar-files.css">
8382
+ <script src="/agent-bar-files.js" data-agent-bar-files="true"></script>
8381
8383
  <link rel="stylesheet" href="/agent-bar-panel.css">
8382
8384
  <script src="/agent-bar-panel.js" data-agent-bar-panel="true"></script>
8383
8385
  <link rel="stylesheet" href="/agent-bar-attach.css">
@@ -89,6 +89,7 @@ body {
89
89
  <script src="/sweetalert2.js"></script>
90
90
  <script src="/Socket.js"></script>
91
91
  <script src="/terminal-settings.js"></script>
92
+ <script src="/terminal-settings-sheet.js"></script>
92
93
  <script>
93
94
  function isASCII(str) {
94
95
  for (let i = 0; i < str.length; i++) {
@@ -16,6 +16,7 @@
16
16
  <script src="/Socket.js"></script>
17
17
  <script src="/resizeSync.js"></script>
18
18
  <script src="/terminal-settings.js"></script>
19
+ <script src="/terminal-settings-sheet.js"></script>
19
20
  <script src="/pinokio-touch.js"></script>
20
21
  <script src="/common.js"></script>
21
22
  <script src="/he.js"></script>
@@ -1500,6 +1500,7 @@ body.dark .ace-editor {
1500
1500
  <script src="/terminal-input.js"></script>
1501
1501
  <script src="/resizeSync.js"></script>
1502
1502
  <script src="/terminal-settings.js"></script>
1503
+ <script src="/terminal-settings-sheet.js"></script>
1503
1504
  <script src="/pinokio-touch.js"></script>
1504
1505
  <script src="/noty.js"></script>
1505
1506
  <script src="/notyq.js"></script>
@@ -502,6 +502,7 @@ body.install-page #terminal .xterm {
502
502
  <script src="/Socket.js"></script>
503
503
  <script src="/terminal-input.js"></script>
504
504
  <script src="/terminal-settings.js"></script>
505
+ <script src="/terminal-settings-sheet.js"></script>
505
506
  <script src="/pinokio-touch.js"></script>
506
507
  <!--
507
508
  <script src="/install.js"></script>
@@ -137,7 +137,9 @@
137
137
  const root = document.documentElement;
138
138
  let lastViewportHeight = null;
139
139
  let lastViewportTop = null;
140
+ const viewportHolds = new Set();
140
141
  const updateViewportHeight = () => {
142
+ if (viewportHolds.size) return;
141
143
  const viewport = window.visualViewport;
142
144
  // Pinch-zoomed in: the visible part is then a magnified piece of the page,
143
145
  // not what a keyboard leaves free. The panes fill the window, as they do
@@ -172,6 +174,17 @@
172
174
  }));
173
175
  };
174
176
 
177
+ // The Agent Bar in a pane protects its terminal tap from both levels of resize.
178
+ window.PinokioLayoutViewport = {
179
+ hold() {
180
+ const token = {};
181
+ viewportHolds.add(token);
182
+ return () => {
183
+ if (viewportHolds.delete(token) && !viewportHolds.size) updateViewportHeight();
184
+ };
185
+ },
186
+ };
187
+
175
188
  const resizeEvents = ['resize', 'orientationchange'];
176
189
  const boundUpdate = () => requestAnimationFrame(updateViewportHeight);
177
190
 
@@ -4,6 +4,8 @@
4
4
  <link rel="stylesheet" href="/agent-bar.css">
5
5
  <script src="/storage-sweep.js"></script>
6
6
  <script src="/agent-bar.js" data-agent-bar="true"></script>
7
+ <link rel="stylesheet" href="/agent-bar-files.css">
8
+ <script src="/agent-bar-files.js" data-agent-bar-files="true"></script>
7
9
  <link rel="stylesheet" href="/agent-bar-panel.css">
8
10
  <script src="/agent-bar-panel.js" data-agent-bar-panel="true"></script>
9
11
  <link rel="stylesheet" href="/agent-bar-attach.css">
@@ -17,6 +17,7 @@
17
17
  <script src="/terminal-input.js"></script>
18
18
  <script src="/resizeSync.js"></script>
19
19
  <script src="/terminal-settings.js"></script>
20
+ <script src="/terminal-settings-sheet.js"></script>
20
21
  <script src="/pinokio-touch.js"></script>
21
22
  <script src="/common.js"></script>
22
23
  <script src="/he.js"></script>
@@ -984,6 +984,7 @@ body.dark .appcanvas {
984
984
  <script src="/terminal-input.js"></script>
985
985
  <script src="/resizeSync.js"></script>
986
986
  <script src="/terminal-settings.js"></script>
987
+ <script src="/terminal-settings-sheet.js"></script>
987
988
  <script src="/pinokio-touch.js"></script>
988
989
  <script src="/noty.js"></script>
989
990
  <script src="/notyq.js"></script>
@@ -20,6 +20,7 @@
20
20
  <script src="/terminal_input_utils.js"></script>
21
21
  <script src="/terminal_key_caption.js"></script>
22
22
  <script src="/terminal-settings.js"></script>
23
+ <script src="/terminal-settings-sheet.js"></script>
23
24
  <script src="/pinokio-touch.js"></script>
24
25
  <script src="/common.js"></script>
25
26
  <script src="/run-task-save.js"></script>
@@ -20,6 +20,7 @@
20
20
  <script src="/terminal_input_utils.js"></script>
21
21
  <script src="/terminal_key_caption.js"></script>
22
22
  <script src="/terminal-settings.js"></script>
23
+ <script src="/terminal-settings-sheet.js"></script>
23
24
  <script src="/pinokio-touch.js"></script>
24
25
  <script src="/common.js"></script>
25
26
  <script src="/run-task-save.js"></script>
@@ -240,6 +240,108 @@ test('on a phone it is the full screen, with a close button and the back gesture
240
240
  assert.equal(p.shape(), '')
241
241
  })
242
242
 
243
+ test('with the large face and no cursor in the text, the empty text says where to type', async (t) => {
244
+ const p = await page(t, { search: '?universal&type=ask' })
245
+ assert.equal(p.window.PinokioAgentBar.open({ type: 'ask' }), true)
246
+ await settle(p.window)
247
+ assert.equal(p.shape(), 'centre')
248
+ assert.equal(p.input.placeholder, '', 'the cursor is there')
249
+ p.input.blur()
250
+ await settle(p.window)
251
+ assert.equal(p.shape(), 'centre')
252
+ assert.equal(p.input.placeholder, 'Ask Pinokio anything…')
253
+ await p.focus()
254
+ assert.equal(p.input.placeholder, '')
255
+ })
256
+
257
+ test('on a phone the cursor counts only with the keyboard up', async (t) => {
258
+ const p = await page(t, { media: [PHONE, TOUCH] })
259
+ // the keyboard takes part of the screen, or none of it
260
+ const vv = { height: 400, offsetTop: 0, addEventListener() {} }
261
+ p.window.visualViewport = vv
262
+ p.window.innerHeight = 800
263
+ await p.focus()
264
+ assert.equal(p.shape(), 'screen')
265
+ assert.equal(p.input.placeholder, '')
266
+ // put away: the cursor is still in the text as far as the page knows
267
+ vv.height = 800
268
+ p.window.dispatchEvent(new p.window.Event('resize'))
269
+ await settle(p.window)
270
+ assert.equal(p.document.activeElement, p.input)
271
+ assert.equal(p.input.placeholder, 'Ask Pinokio anything…')
272
+ // a mode whose line at rest is its greeting does not say it twice
273
+ await p.mode(1)
274
+ assert.equal(p.root.querySelector('.agent-compose__greet').textContent, 'What should this app do?')
275
+ assert.equal(p.input.placeholder, 'Type here…')
276
+ })
277
+
278
+ test('in a layout pane the keyboard is measured on the layout\'s window', async (t) => {
279
+ const p = await page(t, { media: [PHONE, TOUCH] })
280
+ // the pane is cut to what the keyboard leaves: its own sizes show no keyboard
281
+ p.window.visualViewport = { height: 400, offsetTop: 0, addEventListener() {} }
282
+ p.window.innerHeight = 400
283
+ const layout = { innerHeight: 800, visualViewport: { height: 400 } }
284
+ Object.defineProperty(p.window, 'frameElement', { value: {}, configurable: true })
285
+ Object.defineProperty(p.window, 'parent', { value: layout, configurable: true })
286
+ await p.focus()
287
+ assert.equal(p.shape(), 'screen')
288
+ assert.equal(p.input.placeholder, '', 'the cursor is there')
289
+ layout.visualViewport.height = 800
290
+ p.window.dispatchEvent(new p.window.Event('resize'))
291
+ await settle(p.window)
292
+ assert.equal(p.input.placeholder, 'Ask Pinokio anything…')
293
+ })
294
+
295
+ test('on a phone the agent menu opens upward when the keyboard covers the room below', async (t) => {
296
+ // the window is 1000 tall; the agent button's lower edge is at 608
297
+ const hung = async (seen) => {
298
+ const p = await page(t, { media: [PHONE, TOUCH] })
299
+ p.window.visualViewport = { height: seen, offsetTop: 0, addEventListener() {} }
300
+ p.window.innerHeight = 1000
301
+ await p.focus()
302
+ assert.equal(p.shape(), 'screen')
303
+ p.root.querySelector('.agent-bar__agent').click()
304
+ await settle(p.window)
305
+ const menu = p.root.querySelector('.agent-bar__menu[data-menu="agent"]')
306
+ assert.equal(menu.hidden, false)
307
+ return menu.style
308
+ }
309
+ // no keyboard: there is room below the button
310
+ const down = await hung(1000)
311
+ assert.match(down.top, /px$/)
312
+ assert.equal(down.bottom, '')
313
+ // the keyboard covers everything under the button
314
+ const up = await hung(560)
315
+ assert.match(up.bottom, /px$/, 'it hangs above the button')
316
+ assert.equal(up.top, '', 'and not down under the keyboard')
317
+ })
318
+
319
+ test('a press on the box, off its buttons, puts the cursor in the text', async (t) => {
320
+ const p = await page(t, { search: '?universal&type=ask' })
321
+ p.window.PinokioAgentBar.open({ type: 'ask' })
322
+ await settle(p.window)
323
+ p.input.blur()
324
+ await settle(p.window)
325
+ assert.notEqual(p.document.activeElement, p.input)
326
+ const greet = p.root.querySelector('.agent-compose__greet')
327
+ const down = new p.window.Event('pointerdown', { bubbles: true, cancelable: true })
328
+ greet.dispatchEvent(down)
329
+ assert.equal(down.defaultPrevented, true, 'the press does not take the cursor away')
330
+ greet.click()
331
+ await settle(p.window)
332
+ assert.equal(p.document.activeElement, p.input)
333
+ assert.equal(p.shape(), 'centre')
334
+ // a message keeps its own press too: its words can be selected
335
+ const onNote = new p.window.Event('pointerdown', { bubbles: true, cancelable: true })
336
+ p.root.querySelector('.agent-bar__note').dispatchEvent(onNote)
337
+ assert.equal(onNote.defaultPrevented, false)
338
+ // a button of the box keeps its own press
339
+ p.input.blur()
340
+ p.root.querySelector('.agent-bar__scope').click()
341
+ await settle(p.window)
342
+ assert.equal(p.root.querySelector('.agent-bar__menu').hidden, false)
343
+ })
344
+
243
345
  test('on a phone the bar at rest is one button: the mark opens the view, not the mode menu', async (t) => {
244
346
  const p = await page(t, { media: [PHONE, TOUCH] })
245
347
  p.root.querySelector('.agent-bar__scope').click()