@skillcdn/console 0.5.2 → 0.5.3
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/dist/components/home.d.ts.map +1 -1
- package/dist/components/home.js +12 -20
- package/dist/components/home.js.map +1 -1
- package/dist/home-tiles.d.ts +19 -37
- package/dist/home-tiles.d.ts.map +1 -1
- package/dist/home-tiles.js +52 -328
- package/dist/home-tiles.js.map +1 -1
- package/dist/i18n/en.d.ts +2 -2
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +2 -2
- package/dist/i18n/en.js.map +1 -1
- package/dist/plugin/manifest.d.ts.map +1 -1
- package/dist/plugin/manifest.js +3 -2
- package/dist/plugin/manifest.js.map +1 -1
- package/dist/runner/desk.js +1 -1
- package/docs/specs/plugins.md +3 -3
- package/package.json +1 -1
- package/skills/building-a-plugin/SKILL.md +2 -2
- package/skills/running-an-agent/SKILL.md +2 -2
- package/src/components/home.tsx +13 -34
- package/src/home-tiles.ts +57 -376
- package/src/i18n/en.ts +2 -2
- package/src/plugin/manifest.ts +3 -2
- package/src/runner/desk.ts +1 -1
package/src/home-tiles.ts
CHANGED
|
@@ -12,11 +12,12 @@ import type {
|
|
|
12
12
|
// The front page as a person arranges it (ADR-0061): one grid of square cells, on which the
|
|
13
13
|
// projects and the plugins' widgets are tiles alike, each at a place of its own. What there is
|
|
14
14
|
// comes from what the person may see; where each stands comes from what they kept, one layout
|
|
15
|
-
// for each width of the grid.
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
15
|
+
// for each width of the grid. Where nothing was kept the tiles stand in their order, each at the
|
|
16
|
+
// size it was kept at elsewhere or starts at, at the first room reading from the top: the page
|
|
17
|
+
// looked at and the page being arranged are one, and no size is ever chosen for the person
|
|
18
|
+
// (ADR-0147). On a width they arranged, what is new takes the first room. What they took off
|
|
19
|
+
// stays off, and what they may no longer see waits out of sight for its place. Pure functions, so
|
|
20
|
+
// that the page and the tests read the same arrangement.
|
|
20
21
|
|
|
21
22
|
/** The grid's columns at each width: wide, a laptop's, a tablet's, a phone's. */
|
|
22
23
|
export const HOME_COLUMNS = [12, 8, 6, 4] as const;
|
|
@@ -76,8 +77,6 @@ export interface PlacedTile {
|
|
|
76
77
|
* has things to say.
|
|
77
78
|
*/
|
|
78
79
|
const PROJECT_SIZES: readonly HomeTileSize[] = ["icon", "small", "medium", "large", "wide"];
|
|
79
|
-
/** The sizes the projects take together where a width is closed up: the small ones a person kept them at before a glance existed. */
|
|
80
|
-
const PROJECT_ALIKE_SIZES: readonly HomeTileSize[] = ["icon", "small"];
|
|
81
80
|
|
|
82
81
|
/** Whether a project at a size shows a glance of its board: what is at work in it, and its roadmap (ADR-0105). */
|
|
83
82
|
export function isGlanceSize(size: HomeTileSize): boolean {
|
|
@@ -327,30 +326,21 @@ function keptAt(
|
|
|
327
326
|
return { entries: [], placed: false };
|
|
328
327
|
}
|
|
329
328
|
|
|
330
|
-
/** A tile waiting for a place
|
|
329
|
+
/** A tile waiting for a place, at the size it is to have. */
|
|
331
330
|
interface Wanted {
|
|
332
331
|
readonly tile: HomeTile;
|
|
333
332
|
readonly size: HomeTileSize;
|
|
334
333
|
}
|
|
335
334
|
|
|
336
|
-
/**
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/** The tiles in order, each at its size, at the first room reading from the top. */
|
|
346
|
-
function packed(
|
|
347
|
-
wanted: readonly Wanted[],
|
|
348
|
-
sizes: readonly HomeTileSize[],
|
|
349
|
-
columns: number,
|
|
350
|
-
): PlacedTile[] {
|
|
335
|
+
/**
|
|
336
|
+
* The tiles in order, each at its size, at the first room reading from the top (ADR-0147): how a
|
|
337
|
+
* page nobody arranged stands, a width nobody arranged, and a page closed up when its person asks.
|
|
338
|
+
* No tile is given another size to close a row: a small one after a large one takes the room left
|
|
339
|
+
* beside it.
|
|
340
|
+
*/
|
|
341
|
+
function packed(wanted: readonly Wanted[], columns: number): PlacedTile[] {
|
|
351
342
|
const taken = new Set<number>();
|
|
352
|
-
return wanted.map(({ tile }
|
|
353
|
-
const size = sizes[at] ?? startingSizeAt(tile, columns);
|
|
343
|
+
return wanted.map(({ tile, size }) => {
|
|
354
344
|
const shape = footprintOf(size, columns);
|
|
355
345
|
const place = firstRoom(taken, shape, columns);
|
|
356
346
|
occupy(taken, place, shape, columns);
|
|
@@ -359,102 +349,14 @@ function packed(
|
|
|
359
349
|
}
|
|
360
350
|
|
|
361
351
|
/**
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
* takes no cell from it. A page that closed by turning the projects into cards, or by cutting
|
|
371
|
-
* its lead to a strip, would be another page than the one they looked at, and a lead beside a
|
|
372
|
-
* few icons scores better as a strip, since a strip takes fewer rows to count. What is empty is
|
|
373
|
-
* then counted in the rows the widgets take alone: the projects' last row may end short, as on
|
|
374
|
-
* the composed page (ADR-0108), and a row of icons under the widgets is no gap to close.
|
|
375
|
-
*/
|
|
376
|
-
function closedUp(wanted: readonly Wanted[], columns: number, kept = false): PlacedTile[] {
|
|
377
|
-
const projects = wanted.flatMap((entry, at) => (entry.tile.kind === "project" ? [at] : []));
|
|
378
|
-
// The choices: for each widget its sizes, the one it would rather have first; for the projects
|
|
379
|
-
// together, each its own, then each of the sizes a project comes in, all alike.
|
|
380
|
-
const choices: { readonly at: readonly number[]; readonly options: HomeTileSize[][] }[] = [];
|
|
381
|
-
if (projects.length > 0 && !kept) {
|
|
382
|
-
const own = projects.map((at) => wanted[at]?.size ?? "icon");
|
|
383
|
-
const alike = PROJECT_ALIKE_SIZES.filter(
|
|
384
|
-
(size) => HOME_TILE_CELLS[size].columns <= columns,
|
|
385
|
-
).map((size) => projects.map(() => size));
|
|
386
|
-
const options = [own, ...alike].filter(
|
|
387
|
-
(option, index, all) => all.findIndex((other) => other.join() === option.join()) === index,
|
|
388
|
-
);
|
|
389
|
-
choices.push({ at: projects, options });
|
|
390
|
-
}
|
|
391
|
-
let combinations = choices[0]?.options.length ?? 1;
|
|
392
|
-
wanted.forEach((entry, at) => {
|
|
393
|
-
if (entry.tile.kind !== "widget") {
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
|
-
const cells = (size: HomeTileSize) => {
|
|
397
|
-
const { w, h } = footprintOf(size, columns);
|
|
398
|
-
return w * h;
|
|
399
|
-
};
|
|
400
|
-
const others = sizesAt(entry.tile, columns).filter(
|
|
401
|
-
(size) => size !== entry.size && (!kept || cells(size) >= cells(entry.size)),
|
|
402
|
-
);
|
|
403
|
-
const all = [entry.size, ...others];
|
|
404
|
-
// Past what can be tried at once, a widget keeps the size it would rather have.
|
|
405
|
-
const options = combinations * all.length <= MOST_COMBINATIONS ? all : [entry.size];
|
|
406
|
-
combinations *= options.length;
|
|
407
|
-
choices.push({ at: [at], options: options.map((size) => [size]) });
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
const preferred = wanted.map((entry) => entry.size);
|
|
411
|
-
let best: { readonly placed: PlacedTile[]; readonly score: readonly number[] } | undefined;
|
|
412
|
-
const trying = (index: number, sizes: HomeTileSize[], changed: number): void => {
|
|
413
|
-
const choice = choices[index];
|
|
414
|
-
if (choice === undefined) {
|
|
415
|
-
const placed = packed(wanted, sizes, columns);
|
|
416
|
-
const rows = rowsOf(placed, columns);
|
|
417
|
-
// The rows what is empty is counted in: the page's, or those the widgets take.
|
|
418
|
-
const counted = kept
|
|
419
|
-
? Math.max(
|
|
420
|
-
0,
|
|
421
|
-
...placed
|
|
422
|
-
.filter(({ tile }) => tile.kind === "widget")
|
|
423
|
-
.map((tile) => tile.y + footprintOf(tile.size, columns).h),
|
|
424
|
-
)
|
|
425
|
-
: rows;
|
|
426
|
-
const filled = placed.reduce((cells, { size, y }) => {
|
|
427
|
-
const { w, h } = footprintOf(size, columns);
|
|
428
|
-
return cells + w * Math.max(0, Math.min(y + h, counted) - y);
|
|
429
|
-
}, 0);
|
|
430
|
-
const score = [counted * columns - filled, changed, rows];
|
|
431
|
-
if (best === undefined || lessThan(score, best.score)) {
|
|
432
|
-
best = { placed, score };
|
|
433
|
-
}
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
choice.options.forEach((option) => {
|
|
437
|
-
const next = [...sizes];
|
|
438
|
-
choice.at.forEach((at, nth) => {
|
|
439
|
-
next[at] = option[nth] ?? (preferred[at] as HomeTileSize);
|
|
440
|
-
});
|
|
441
|
-
const differs = choice.at.some((at) => next[at] !== preferred[at]) ? 1 : 0;
|
|
442
|
-
trying(index + 1, next, changed + differs);
|
|
443
|
-
});
|
|
444
|
-
};
|
|
445
|
-
trying(0, [...preferred], 0);
|
|
446
|
-
return best?.placed ?? packed(wanted, preferred, columns);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
* The page as it stands on the grid: what the person kept for this width where they stand; for
|
|
451
|
-
* someone who has arranged nothing, the composed page on the cells nearest it; for a width nobody
|
|
452
|
-
* arranged when another was, the order kept there, closed up so that no cell stands empty where
|
|
453
|
-
* the sizes the tiles come in allow it (ADR-0082). A tile they may no longer
|
|
454
|
-
* see stays out, a size it no longer comes in, or that is too wide for this grid, becomes the one
|
|
455
|
-
* it starts at here, and a tile on another's cells moves to the nearest room. What they have not
|
|
456
|
-
* seen yet takes the first room of a width they arranged, a plugin's widgets as soon as it is on;
|
|
457
|
-
* what they took off stays off.
|
|
352
|
+
* The page as it stands on the grid, looked at and being arranged alike (ADR-0147): what the
|
|
353
|
+
* person kept for this width where they stand. Where they kept nothing for it, the tiles stand
|
|
354
|
+
* packed from the top: in the order and at the sizes kept at another width, where they arranged
|
|
355
|
+
* one; in the page's own order at the sizes the tiles start at, where they arranged none. A tile
|
|
356
|
+
* they may no longer see stays out, a size it no longer comes in, or that is too wide for this
|
|
357
|
+
* grid, becomes the one it starts at here, and a tile on another's cells moves to the nearest
|
|
358
|
+
* room. What they have not seen yet takes the first room of a width they arranged, a plugin's
|
|
359
|
+
* widgets as soon as it is on; what they took off stays off.
|
|
458
360
|
*/
|
|
459
361
|
export function arranged(
|
|
460
362
|
tiles: readonly HomeTile[],
|
|
@@ -464,39 +366,16 @@ export function arranged(
|
|
|
464
366
|
const byId = new Map(tiles.map((tile) => [tile.id, tile]));
|
|
465
367
|
const hidden = new Set(home?.hidden ?? []);
|
|
466
368
|
const { entries, placed: keepsPlaces } = keptAt(home, columns);
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
// (ADR-0139), arranging starts on those very cells: the page and its arranging do not differ.
|
|
471
|
-
const boxes = composed(tiles, home, columns);
|
|
472
|
-
const whole = boxes.every(({ x, y, w, h, size }) => {
|
|
473
|
-
const shape = footprintOf(size, columns);
|
|
474
|
-
return Number.isInteger(x) && Number.isInteger(y) && shape.w === w && shape.h === h;
|
|
475
|
-
});
|
|
476
|
-
if (whole) {
|
|
477
|
-
return boxes.map(({ tile, size, x, y }) => ({ tile, size, x, y }));
|
|
478
|
-
}
|
|
479
|
-
// Otherwise it starts from the page closed up (ADR-0139): the tiles in the page's order, a
|
|
480
|
-
// widget at the size the composed page told it, or at another of its own that takes no cell
|
|
481
|
-
// from it where the rows close with that, the projects icons as they were. Put on the cells
|
|
482
|
-
// nearest where the composed page drew them, a tile drawn wider than any size it comes in
|
|
483
|
-
// left a band of empty cells beside it, and Done kept the bands.
|
|
484
|
-
const told = new Map(boxes.map(({ tile, size }) => [tile.id, size]));
|
|
485
|
-
const wanted = tiles
|
|
486
|
-
.filter((tile) => !hidden.has(tile.id))
|
|
487
|
-
.map((tile) => ({ tile, size: told.get(tile.id) ?? startingSizeAt(tile, columns) }));
|
|
488
|
-
return closedUp(wanted, columns, true);
|
|
489
|
-
}
|
|
369
|
+
/** The size a tile has here: the one kept, where this grid has it, else the one it starts at. */
|
|
370
|
+
const sizeHere = (tile: HomeTile, kept: HomeTileSize) =>
|
|
371
|
+
sizesAt(tile, columns).includes(kept) ? kept : startingSizeAt(tile, columns);
|
|
490
372
|
if (!keepsPlaces) {
|
|
491
373
|
const wanted: Wanted[] = [];
|
|
492
374
|
const seen = new Set<string>();
|
|
493
375
|
for (const entry of entries) {
|
|
494
376
|
const tile = byId.get(entry.tile);
|
|
495
377
|
if (tile !== undefined && !hidden.has(tile.id) && !seen.has(tile.id)) {
|
|
496
|
-
|
|
497
|
-
? entry.size
|
|
498
|
-
: startingSizeAt(tile, columns);
|
|
499
|
-
wanted.push({ tile, size });
|
|
378
|
+
wanted.push({ tile, size: sizeHere(tile, entry.size) });
|
|
500
379
|
seen.add(tile.id);
|
|
501
380
|
}
|
|
502
381
|
}
|
|
@@ -505,7 +384,7 @@ export function arranged(
|
|
|
505
384
|
wanted.push({ tile, size: startingSizeAt(tile, columns) });
|
|
506
385
|
}
|
|
507
386
|
}
|
|
508
|
-
return
|
|
387
|
+
return packed(wanted, columns);
|
|
509
388
|
}
|
|
510
389
|
const taken = new Set<number>();
|
|
511
390
|
const placed: PlacedTile[] = [];
|
|
@@ -525,10 +404,7 @@ export function arranged(
|
|
|
525
404
|
for (const entry of entries) {
|
|
526
405
|
const tile = byId.get(entry.tile);
|
|
527
406
|
if (tile !== undefined && !hidden.has(tile.id) && !seen.has(tile.id)) {
|
|
528
|
-
|
|
529
|
-
? entry.size
|
|
530
|
-
: startingSizeAt(tile, columns);
|
|
531
|
-
put(tile, size, { x: entry.x, y: entry.y });
|
|
407
|
+
put(tile, sizeHere(tile, entry.size), { x: entry.x, y: entry.y });
|
|
532
408
|
}
|
|
533
409
|
}
|
|
534
410
|
for (const tile of tiles) {
|
|
@@ -540,17 +416,32 @@ export function arranged(
|
|
|
540
416
|
}
|
|
541
417
|
|
|
542
418
|
/**
|
|
543
|
-
* A page being arranged, closed up (ADR-
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
419
|
+
* A page being arranged, closed up (ADR-0147): each tile, in the order the tiles are read, moved
|
|
420
|
+
* to the first room from the top that the others leave it, at the size it has, and again until
|
|
421
|
+
* none moves. What a person asks for when a page they kept has gaps they did not mean, from a
|
|
422
|
+
* tile that left or one they moved. No tile changes its size or goes further down, so the page
|
|
423
|
+
* grows no longer, and a page packed from the top, as nobody arranged it, has nothing to move.
|
|
424
|
+
* Packed again in the order read instead, a small tile could take the cell a large one below it
|
|
425
|
+
* stood on, and the large one went a row down.
|
|
547
426
|
*/
|
|
548
427
|
export function tidied(placed: readonly PlacedTile[], columns: number): PlacedTile[] {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
428
|
+
let tiles = inReadingOrder(placed);
|
|
429
|
+
for (let moved = true; moved; ) {
|
|
430
|
+
moved = false;
|
|
431
|
+
for (const tile of inReadingOrder(tiles)) {
|
|
432
|
+
const others = occupied(
|
|
433
|
+
tiles.filter((other) => other !== tile),
|
|
434
|
+
columns,
|
|
435
|
+
);
|
|
436
|
+
const room = firstRoom(others, footprintOf(tile.size, columns), columns);
|
|
437
|
+
if (room.x !== tile.x || room.y !== tile.y) {
|
|
438
|
+
const at = { ...tile, ...room };
|
|
439
|
+
tiles = tiles.map((other) => (other === tile ? at : other));
|
|
440
|
+
moved = true;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return inReadingOrder(tiles);
|
|
554
445
|
}
|
|
555
446
|
|
|
556
447
|
/** Whether two arrangements stand every tile on the same cells at the same size. */
|
|
@@ -577,224 +468,14 @@ export function nobodyArranged(home: RestHome | null | undefined): boolean {
|
|
|
577
468
|
return home === null || home === undefined || Object.keys(home.layouts).length === 0;
|
|
578
469
|
}
|
|
579
470
|
|
|
580
|
-
/** The page put back as
|
|
581
|
-
export const
|
|
471
|
+
/** The page put back as nobody arranged it: no width arranged, nothing taken off (ADR-0109). */
|
|
472
|
+
export const UNARRANGED_HOME: RestHome = { hidden: [], layouts: {} };
|
|
582
473
|
|
|
583
|
-
/** Whether the page stands as
|
|
584
|
-
export function
|
|
474
|
+
/** Whether the page stands as nobody arranged it, nothing taken off: nothing for putting it back to undo. */
|
|
475
|
+
export function standsUnarranged(home: RestHome | null | undefined): boolean {
|
|
585
476
|
return nobodyArranged(home) && (home?.hidden.length ?? 0) === 0;
|
|
586
477
|
}
|
|
587
478
|
|
|
588
|
-
/**
|
|
589
|
-
* A tile of the composed page: where it stands and how far it reaches, in cells, which need not
|
|
590
|
-
* be whole, and the size its frame is told, the one of its own nearest that shape.
|
|
591
|
-
*/
|
|
592
|
-
export interface ComposedTile extends PlacedTile {
|
|
593
|
-
readonly w: number;
|
|
594
|
-
readonly h: number;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
/** The rows a widget beside the lead takes, and those the lead takes at least. */
|
|
598
|
-
const SIDE_ROWS = 2;
|
|
599
|
-
const LEAD_ROWS = 4;
|
|
600
|
-
/** The widgets that stand beside the lead at most; the others stand below, two to a row. */
|
|
601
|
-
const MOST_BESIDE = 2;
|
|
602
|
-
/** The rows of projects the column beside the lead holds at most; more go below, across the page. */
|
|
603
|
-
const MOST_PROJECT_ROWS_BESIDE = 2;
|
|
604
|
-
|
|
605
|
-
/**
|
|
606
|
-
* Of the sizes a tile comes in on this grid, the one nearest a shape; on a tie the one that fits
|
|
607
|
-
* within it, so that a frame is never told of more room than it has, then its own, then the smaller.
|
|
608
|
-
*/
|
|
609
|
-
function nearestSize(tile: HomeTile, w: number, h: number, columns: number): HomeTileSize {
|
|
610
|
-
if (tile.kind === "project") {
|
|
611
|
-
return "icon";
|
|
612
|
-
}
|
|
613
|
-
const away = (size: HomeTileSize) => {
|
|
614
|
-
const cells = footprintOf(size, columns);
|
|
615
|
-
return Math.abs(cells.w - w) + Math.abs(cells.h - h);
|
|
616
|
-
};
|
|
617
|
-
const within = (size: HomeTileSize) => {
|
|
618
|
-
const cells = footprintOf(size, columns);
|
|
619
|
-
return cells.w <= w && cells.h <= h;
|
|
620
|
-
};
|
|
621
|
-
const area = (size: HomeTileSize) => HOME_TILE_CELLS[size].columns * HOME_TILE_CELLS[size].rows;
|
|
622
|
-
return [...sizesAt(tile, columns)].sort(
|
|
623
|
-
(a, b) =>
|
|
624
|
-
away(a) - away(b) ||
|
|
625
|
-
Number(within(b)) - Number(within(a)) ||
|
|
626
|
-
Number(b === tile.defaultSize) - Number(a === tile.defaultSize) ||
|
|
627
|
-
area(a) - area(b),
|
|
628
|
-
)[0] as HomeTileSize;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
/**
|
|
632
|
-
* The page of someone who has arranged nothing, composed (ADR-0082): the first widget leads,
|
|
633
|
-
* half the page wide, and beside it stand the next two widgets and the projects, the column as
|
|
634
|
-
* high as the lead; on a grid of six columns or fewer they stand one under the other. With nothing
|
|
635
|
-
* beside it, the lead stands at a size it comes in, and the projects follow it in the columns it
|
|
636
|
-
* leaves (ADR-0110). The projects are icons, one to a cell, in rows as long as their column has
|
|
637
|
-
* cells, so that a project is never drawn in a shape it does not come in and the page is the one
|
|
638
|
-
* arranging starts from (ADR-0108); the last row may end short. The other widgets stand below, two
|
|
639
|
-
* to a row.
|
|
640
|
-
*/
|
|
641
|
-
export function composed(
|
|
642
|
-
tiles: readonly HomeTile[],
|
|
643
|
-
home: RestHome | null | undefined,
|
|
644
|
-
columns: HomeColumns,
|
|
645
|
-
): ComposedTile[] {
|
|
646
|
-
const hidden = new Set(home?.hidden ?? []);
|
|
647
|
-
const shown = tiles.filter((tile) => !hidden.has(tile.id));
|
|
648
|
-
const widgets = shown.filter((tile): tile is HomeWidgetTile => tile.kind === "widget");
|
|
649
|
-
const top = widgets.filter((tile) => tile.widget.place === "home:top");
|
|
650
|
-
const bottom = widgets.filter((tile) => tile.widget.place !== "home:top");
|
|
651
|
-
const projects = shown.filter((tile) => tile.kind === "project");
|
|
652
|
-
const boxes: ComposedTile[] = [];
|
|
653
|
-
const put = (tile: HomeTile, x: number, y: number, w: number, h: number) => {
|
|
654
|
-
boxes.push({ tile, size: nearestSize(tile, w, h, columns), x, y, w, h });
|
|
655
|
-
};
|
|
656
|
-
/** The rows the projects take in a column so wide: as many to a row as a cell each allows. */
|
|
657
|
-
const projectRows = (width: number) =>
|
|
658
|
-
projects.length === 0 ? 0 : Math.ceil(projects.length / Math.max(1, Math.floor(width)));
|
|
659
|
-
/** The projects in rows from a place, one to a cell, each row as long as the width has cells. */
|
|
660
|
-
const putProjects = (x: number, y: number, width: number): number => {
|
|
661
|
-
const across = Math.max(1, Math.floor(width));
|
|
662
|
-
projects.forEach((tile, nth) => {
|
|
663
|
-
put(tile, x + (nth % across), y + Math.floor(nth / across), 1, 1);
|
|
664
|
-
});
|
|
665
|
-
return projectRows(width);
|
|
666
|
-
};
|
|
667
|
-
/**
|
|
668
|
-
* The projects beside a tile in the page's corner, so wide and so high: one to a cell in the
|
|
669
|
-
* columns it leaves, no lower than it reaches, then across the page below it. The row after them.
|
|
670
|
-
*/
|
|
671
|
-
const putProjectsBeside = (w: number, h: number, from = 0): number => {
|
|
672
|
-
const across = columns - w;
|
|
673
|
-
const beside = Math.min(projects.length, across * (h - from));
|
|
674
|
-
projects.forEach((tile, nth) => {
|
|
675
|
-
const below = nth - beside;
|
|
676
|
-
if (below < 0) {
|
|
677
|
-
put(tile, w + (nth % across), from + Math.floor(nth / across), 1, 1);
|
|
678
|
-
} else {
|
|
679
|
-
put(tile, below % columns, h + Math.floor(below / columns), 1, 1);
|
|
680
|
-
}
|
|
681
|
-
});
|
|
682
|
-
const left = projects.length - beside;
|
|
683
|
-
return h + Math.ceil(left / columns);
|
|
684
|
-
};
|
|
685
|
-
/**
|
|
686
|
-
* The widgets after the lead that stand beside it where it stands at a size of its own and
|
|
687
|
-
* leaves columns (ADR-0139): in their order, each at the largest of its sizes those columns
|
|
688
|
-
* hold, one under the other, no lower than the lead reaches, and none after the first that
|
|
689
|
-
* has no such size. How many stand there, and how far down they reach.
|
|
690
|
-
*/
|
|
691
|
-
const putWidgetsBeside = (
|
|
692
|
-
list: readonly HomeTile[],
|
|
693
|
-
w: number,
|
|
694
|
-
h: number,
|
|
695
|
-
): { readonly stood: number; readonly down: number } => {
|
|
696
|
-
const across = columns - w;
|
|
697
|
-
const area = (size: HomeTileSize) => HOME_TILE_CELLS[size].columns * HOME_TILE_CELLS[size].rows;
|
|
698
|
-
let down = 0;
|
|
699
|
-
let stood = 0;
|
|
700
|
-
for (const tile of list) {
|
|
701
|
-
const [size] = sizesAt(tile, columns)
|
|
702
|
-
.filter((candidate) => {
|
|
703
|
-
const cells = footprintOf(candidate, columns);
|
|
704
|
-
return cells.w === across && cells.h <= h - down;
|
|
705
|
-
})
|
|
706
|
-
.sort(
|
|
707
|
-
(a, b) =>
|
|
708
|
-
area(b) - area(a) || Number(b === tile.defaultSize) - Number(a === tile.defaultSize),
|
|
709
|
-
);
|
|
710
|
-
if (size === undefined) {
|
|
711
|
-
break;
|
|
712
|
-
}
|
|
713
|
-
const shape = footprintOf(size, columns);
|
|
714
|
-
boxes.push({ tile, size, x: w, y: down, ...shape });
|
|
715
|
-
down += shape.h;
|
|
716
|
-
stood += 1;
|
|
717
|
-
}
|
|
718
|
-
return { stood, down };
|
|
719
|
-
};
|
|
720
|
-
/** Widgets two to a row across the page, one alone as wide as the page. */
|
|
721
|
-
const putInPairs = (list: readonly HomeTile[], from: number): number => {
|
|
722
|
-
let y = from;
|
|
723
|
-
for (let at = 0; at < list.length; at += 2) {
|
|
724
|
-
const first = list[at];
|
|
725
|
-
const second = list[at + 1];
|
|
726
|
-
if (first !== undefined && second !== undefined) {
|
|
727
|
-
put(first, 0, y, columns / 2, SIDE_ROWS);
|
|
728
|
-
put(second, columns / 2, y, columns / 2, SIDE_ROWS);
|
|
729
|
-
} else if (first !== undefined) {
|
|
730
|
-
put(first, 0, y, columns, SIDE_ROWS);
|
|
731
|
-
}
|
|
732
|
-
y += SIDE_ROWS;
|
|
733
|
-
}
|
|
734
|
-
return y;
|
|
735
|
-
};
|
|
736
|
-
|
|
737
|
-
const [lead, ...others] = top;
|
|
738
|
-
const beside = others.slice(0, MOST_BESIDE);
|
|
739
|
-
let y = 0;
|
|
740
|
-
if (lead !== undefined && beside.length > 0 && columns >= 8) {
|
|
741
|
-
const half = columns / 2;
|
|
742
|
-
const projectsBeside = projectRows(half) <= MOST_PROJECT_ROWS_BESIDE;
|
|
743
|
-
const besideRows = beside.length * SIDE_ROWS + (projectsBeside ? projectRows(half) : 0);
|
|
744
|
-
const height = Math.max(besideRows, LEAD_ROWS);
|
|
745
|
-
// A column shorter than the lead gives its widgets the rows left over, alike.
|
|
746
|
-
const widgetRows = SIDE_ROWS + (height - besideRows) / beside.length;
|
|
747
|
-
put(lead, 0, 0, half, height);
|
|
748
|
-
let at = 0;
|
|
749
|
-
for (const tile of beside) {
|
|
750
|
-
put(tile, half, at, half, widgetRows);
|
|
751
|
-
at += widgetRows;
|
|
752
|
-
}
|
|
753
|
-
if (projectsBeside) {
|
|
754
|
-
putProjects(half, at, half);
|
|
755
|
-
}
|
|
756
|
-
y = height;
|
|
757
|
-
if (!projectsBeside) {
|
|
758
|
-
y += putProjects(0, y, columns);
|
|
759
|
-
}
|
|
760
|
-
y = putInPairs([...others.slice(MOST_BESIDE), ...bottom], y);
|
|
761
|
-
} else {
|
|
762
|
-
let projectsPut = false;
|
|
763
|
-
let below = others;
|
|
764
|
-
if (lead !== undefined) {
|
|
765
|
-
// Nothing beside it, the lead is drawn at the size it is told, on that size's cells, and
|
|
766
|
-
// never stretched to the page's width and four rows (ADR-0110).
|
|
767
|
-
const size = nearestSize(lead, columns, LEAD_ROWS, columns);
|
|
768
|
-
const shape = footprintOf(size, columns);
|
|
769
|
-
boxes.push({ tile: lead, size, x: 0, y: 0, ...shape });
|
|
770
|
-
y = shape.h;
|
|
771
|
-
if (shape.w < columns) {
|
|
772
|
-
// In the columns it leaves stand the widgets that come in a size as wide as those
|
|
773
|
-
// columns, then the projects in the rows the widgets leave (ADR-0139): on a grid of six,
|
|
774
|
-
// two small widgets beside a large lead, where the projects alone left most of those
|
|
775
|
-
// columns empty and the widgets stood under the lead, each drawn at no size of its own.
|
|
776
|
-
const { stood, down } = putWidgetsBeside(others, shape.w, shape.h);
|
|
777
|
-
below = others.slice(stood);
|
|
778
|
-
if (projects.length > 0 && (stood === 0 || down < shape.h)) {
|
|
779
|
-
y = putProjectsBeside(shape.w, shape.h, down);
|
|
780
|
-
projectsPut = true;
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
y = putInPairs(below, y);
|
|
785
|
-
if (!projectsPut) {
|
|
786
|
-
y += putProjects(0, y, columns);
|
|
787
|
-
}
|
|
788
|
-
putInPairs(bottom, y);
|
|
789
|
-
}
|
|
790
|
-
return boxes;
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
/** How many rows the composed page takes, which need not be whole. */
|
|
794
|
-
export function composedRows(boxes: readonly ComposedTile[]): number {
|
|
795
|
-
return Math.max(0, ...boxes.map((box) => box.y + box.h));
|
|
796
|
-
}
|
|
797
|
-
|
|
798
479
|
const sameTile = (a: PlacedTile, b: PlacedTile): boolean => a.tile.id === b.tile.id;
|
|
799
480
|
|
|
800
481
|
const overlapping = (a: PlacedTile, b: PlacedTile, columns: number): boolean => {
|
package/src/i18n/en.ts
CHANGED
|
@@ -1681,9 +1681,9 @@ export const en = {
|
|
|
1681
1681
|
home: {
|
|
1682
1682
|
edit: "Edit layout",
|
|
1683
1683
|
hint: "Drag to move. Pick a size at the top right; × takes a tile off this page.",
|
|
1684
|
-
/** Puts the page back as it
|
|
1684
|
+
/** Puts the page back as it stands for someone who has arranged nothing, kept by Done (ADR-0109). */
|
|
1685
1685
|
reset: "Reset to default",
|
|
1686
|
-
/** Closes the page up where it has gaps:
|
|
1686
|
+
/** Closes the page up where it has gaps: each tile moved up into the room the others leave it, at the size it has, none further down (ADR-0147). */
|
|
1687
1687
|
tidy: "Close the gaps",
|
|
1688
1688
|
done: "Done",
|
|
1689
1689
|
add: "Add",
|
package/src/plugin/manifest.ts
CHANGED
|
@@ -489,8 +489,9 @@ const pluginWidgetSchema = z
|
|
|
489
489
|
z.array(z.enum(PLUGIN_WIDGET_SIZE_NAMES)).check(z.minLength(1), z.maxLength(5)),
|
|
490
490
|
),
|
|
491
491
|
/**
|
|
492
|
-
* The size it
|
|
493
|
-
*
|
|
492
|
+
* The size it starts at, one of `sizes`; the first of them when left out. A page nobody
|
|
493
|
+
* arranged shows it at this size, or at the largest of `sizes` that fits a narrower grid
|
|
494
|
+
* (ADR-0147); a larger one is for the person to choose.
|
|
494
495
|
*/
|
|
495
496
|
defaultSize: z.optional(z.enum(PLUGIN_WIDGET_SIZE_NAMES)),
|
|
496
497
|
roles: z.optional(roleList),
|
package/src/runner/desk.ts
CHANGED
|
@@ -109,7 +109,7 @@ The instructions of ${name}'s desk, for whichever agent product runs here.
|
|
|
109
109
|
|
|
110
110
|
## Who I am
|
|
111
111
|
|
|
112
|
-
I am ${name} (@${input.agent.handle})${title.length === 0 ? "" : `, ${title}`}, an agent account of ${plain(input.console.workspace)} (${input.console.url}): a member of my own, signed in as myself, under the rules every member is under. I report to a manager, whom \`console manager\` names, with the administrators who stand in when my manager is away. I work as any member does: my profiles and what I sign carry my name and my role, and nothing else.
|
|
112
|
+
I am ${name} (@${input.agent.handle})${title.length === 0 ? "" : `, ${title}`}, an agent account of ${plain(input.console.workspace)} (${input.console.url}): a member of my own, signed in as myself, under the rules every member is under. I report to a manager, whom \`console manager\` names, with the administrators who stand in when my manager is away. I work as any member does: my profiles and what I sign carry my name and my role, and nothing else.
|
|
113
113
|
|
|
114
114
|
## Where I work
|
|
115
115
|
|