@buffcore/admin-shell 0.8.43 → 0.8.45
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/Markdown.d.ts +9 -3
- package/dist/components/Markdown.js +84 -34
- package/dist/components/Sheet.d.ts +5 -1
- package/dist/components/Sheet.js +8 -2
- package/dist/components/TextArea.d.ts +3 -1
- package/dist/components/TextArea.js +3 -3
- package/dist/components/icons.d.ts +1 -0
- package/dist/components/icons.js +1 -0
- package/dist/workbench/app/ServedPrototype.d.ts +2 -0
- package/dist/workbench/app/ServedPrototype.js +11 -1
- package/dist/workbench/app/__snapshots__/places-dom.test.tsx.snap +30 -3
- package/dist/workbench/app/actions.d.ts +4 -2
- package/dist/workbench/app/actions.js +9 -4
- package/dist/workbench/app/brief-short.d.ts +14 -0
- package/dist/workbench/app/brief-short.js +103 -0
- package/dist/workbench/app/chat-session.d.ts +5 -5
- package/dist/workbench/app/chat-session.js +8 -3
- package/dist/workbench/app/chat.d.ts +17 -4
- package/dist/workbench/app/chat.js +9 -4
- package/dist/workbench/app/frame.js +5 -1
- package/dist/workbench/app/loop.js +2 -18
- package/dist/workbench/app/pages.js +10 -2
- package/dist/workbench/app/prototype.js +3 -0
- package/dist/workbench/app/test/loop-fixture.d.ts +13 -1
- package/dist/workbench/app/useStudio.d.ts +2 -1
- package/dist/workbench/studio/frame/AgentPanel.js +24 -1
- package/dist/workbench/studio/frame/Composer.js +13 -10
- package/dist/workbench/studio/frame/PanelList.js +1 -1
- package/dist/workbench/studio/frame/Segmented.d.ts +3 -1
- package/dist/workbench/studio/frame/Segmented.js +4 -3
- package/dist/workbench/studio/frame/SettingsSheet.js +10 -9
- package/dist/workbench/studio/frame/StudioFrame.js +7 -6
- package/dist/workbench/studio/frame/StudioRegions.js +4 -1
- package/dist/workbench/studio/frame/TurnControls.d.ts +2 -1
- package/dist/workbench/studio/frame/TurnControls.js +4 -1
- package/dist/workbench/studio/frame/layout.d.ts +2 -0
- package/dist/workbench/studio/frame/layout.js +2 -0
- package/dist/workbench/studio/frame/panelControls.d.ts +21 -1
- package/dist/workbench/studio/frame/scrollbars.d.ts +1 -0
- package/dist/workbench/studio/frame/scrollbars.js +12 -0
- package/dist/workbench/studio/frame/useTurnDraft.d.ts +22 -2
- package/dist/workbench/studio/frame/useTurnDraft.js +48 -16
- package/dist/workbench/studio/i18n/frame.en.d.ts +3 -0
- package/dist/workbench/studio/i18n/frame.en.js +4 -1
- package/dist/workbench/studio/i18n/frame.es.json +4 -1
- package/dist/workbench/studio/i18n/index.js +6 -0
- package/dist/workbench/studio/i18n/loop.en.d.ts +11 -38
- package/dist/workbench/studio/i18n/loop.en.js +11 -38
- package/dist/workbench/studio/i18n/loop.es.json +11 -38
- package/dist/workbench/studio/i18n/marks.en.d.ts +41 -0
- package/dist/workbench/studio/i18n/marks.en.js +42 -0
- package/dist/workbench/studio/i18n/marks.es.json +40 -0
- package/dist/workbench/studio/i18n/start.en.d.ts +5 -0
- package/dist/workbench/studio/i18n/start.en.js +7 -2
- package/dist/workbench/studio/i18n/start.es.json +7 -2
- package/dist/workbench/studio/i18n/workspace.en.d.ts +45 -0
- package/dist/workbench/studio/i18n/workspace.en.js +46 -0
- package/dist/workbench/studio/i18n/workspace.es.json +44 -0
- package/dist/workbench/studio/loop/BriefDocument.d.ts +9 -6
- package/dist/workbench/studio/loop/BriefDocument.js +48 -76
- package/dist/workbench/studio/loop/BriefLists.d.ts +11 -0
- package/dist/workbench/studio/loop/BriefLists.js +42 -0
- package/dist/workbench/studio/loop/BriefPage.d.ts +6 -2
- package/dist/workbench/studio/loop/BriefPage.js +32 -4
- package/dist/workbench/studio/loop/BriefReading.d.ts +19 -0
- package/dist/workbench/studio/loop/BriefReading.js +22 -0
- package/dist/workbench/studio/loop/BriefSection.d.ts +22 -0
- package/dist/workbench/studio/loop/BriefSection.js +47 -0
- package/dist/workbench/studio/loop/BriefWho.d.ts +6 -0
- package/dist/workbench/studio/loop/BriefWho.js +56 -0
- package/dist/workbench/studio/loop/CanvasBar.d.ts +0 -1
- package/dist/workbench/studio/loop/CanvasBar.js +2 -3
- package/dist/workbench/studio/loop/ConsoleFrame.d.ts +13 -0
- package/dist/workbench/studio/loop/ConsoleFrame.js +29 -0
- package/dist/workbench/studio/loop/NotThisCard.d.ts +6 -1
- package/dist/workbench/studio/loop/NotThisCard.js +28 -20
- package/dist/workbench/studio/loop/ProtoJourneys.d.ts +1 -8
- package/dist/workbench/studio/loop/ProtoJourneys.js +0 -14
- package/dist/workbench/studio/loop/PrototypeApp.d.ts +12 -1
- package/dist/workbench/studio/loop/PrototypeApp.js +30 -13
- package/dist/workbench/studio/loop/PrototypeAttempt.d.ts +2 -1
- package/dist/workbench/studio/loop/PrototypeAttempt.js +94 -29
- package/dist/workbench/studio/loop/PrototypePage.d.ts +4 -2
- package/dist/workbench/studio/loop/PrototypePage.js +25 -1
- package/dist/workbench/studio/loop/PrototypePreview.d.ts +35 -6
- package/dist/workbench/studio/loop/PrototypePreview.js +127 -76
- package/dist/workbench/studio/loop/PrototypePreviewSlot.d.ts +13 -0
- package/dist/workbench/studio/loop/PrototypePreviewSlot.js +23 -0
- package/dist/workbench/studio/loop/PrototypeScenes.d.ts +1 -1
- package/dist/workbench/studio/loop/ServedPlanning.js +1 -1
- package/dist/workbench/studio/loop/StudioLoop.d.ts +7 -2
- package/dist/workbench/studio/loop/StudioLoop.js +4 -10
- package/dist/workbench/studio/loop/WorkspaceBar.d.ts +15 -0
- package/dist/workbench/studio/loop/WorkspaceBar.js +52 -0
- package/dist/workbench/studio/loop/WorkspaceJourneys.d.ts +17 -0
- package/dist/workbench/studio/loop/WorkspaceJourneys.js +99 -0
- package/dist/workbench/studio/loop/WorkspaceLeft.d.ts +14 -0
- package/dist/workbench/studio/loop/WorkspaceLeft.js +42 -0
- package/dist/workbench/studio/loop/WorkspaceStage.d.ts +24 -0
- package/dist/workbench/studio/loop/WorkspaceStage.js +142 -0
- package/dist/workbench/studio/loop/WorkspaceSteps.d.ts +20 -0
- package/dist/workbench/studio/loop/WorkspaceSteps.js +96 -0
- package/dist/workbench/studio/loop/moments.js +0 -3
- package/dist/workbench/studio/loop/prototype-bridge.d.ts +8 -0
- package/dist/workbench/studio/loop/prototype-bridge.js +16 -0
- package/dist/workbench/studio/loop/prototype-document.d.ts +9 -0
- package/dist/workbench/studio/loop/prototype-document.js +90 -2
- package/dist/workbench/studio/loop/prototype-part.d.ts +43 -0
- package/dist/workbench/studio/loop/prototype-part.js +104 -0
- package/dist/workbench/studio/loop/types.d.ts +26 -26
- package/dist/workbench/studio/loop/types.js +0 -3
- package/dist/workbench/studio/loop/usePrototypeFrame.d.ts +6 -1
- package/dist/workbench/studio/loop/usePrototypeFrame.js +4 -0
- package/dist/workbench/studio/loop/workspace-journeys.d.ts +22 -0
- package/dist/workbench/studio/loop/workspace-journeys.js +63 -0
- package/dist/workbench/studio/loop/workspace-state.d.ts +94 -0
- package/dist/workbench/studio/loop/workspace-state.js +50 -0
- package/dist/workbench/studio/marks/ChangeList.d.ts +7 -0
- package/dist/workbench/studio/marks/ChangeList.js +70 -0
- package/dist/workbench/studio/marks/MarkHint.d.ts +18 -0
- package/dist/workbench/studio/marks/MarkHint.js +58 -0
- package/dist/workbench/studio/marks/MarkNumber.d.ts +6 -0
- package/dist/workbench/studio/marks/MarkNumber.js +24 -0
- package/dist/workbench/studio/marks/MarksLayer.d.ts +15 -0
- package/dist/workbench/studio/marks/MarksLayer.js +144 -0
- package/dist/workbench/studio/marks/PinNote.d.ts +13 -0
- package/dist/workbench/studio/marks/PinNote.js +49 -0
- package/dist/workbench/studio/marks/QueuedChanges.d.ts +6 -0
- package/dist/workbench/studio/marks/QueuedChanges.js +51 -0
- package/dist/workbench/studio/marks/WorkspaceMarks.d.ts +15 -0
- package/dist/workbench/studio/marks/WorkspaceMarks.js +67 -0
- package/dist/workbench/studio/marks/marks-message.d.ts +13 -0
- package/dist/workbench/studio/marks/marks-message.js +93 -0
- package/dist/workbench/studio/marks/marks.d.ts +105 -0
- package/dist/workbench/studio/marks/marks.js +133 -0
- package/dist/workbench/studio/marks/useMarking.d.ts +36 -0
- package/dist/workbench/studio/marks/useMarking.js +111 -0
- package/dist/workbench/studio/marks/useSendMarks.d.ts +18 -0
- package/dist/workbench/studio/marks/useSendMarks.js +80 -0
- package/dist/workbench/studio/types.d.ts +2 -0
- package/dist/workbench/studio/work/StudioLater.js +0 -1
- package/dist/workbench/studio/work/work-test-data.d.ts +6 -0
- package/package.json +6 -6
- package/dist/workbench/studio/loop/FsPlan.d.ts +0 -7
- package/dist/workbench/studio/loop/FsPlan.js +0 -64
- package/dist/workbench/studio/loop/FsStage.d.ts +0 -6
- package/dist/workbench/studio/loop/FsStage.js +0 -74
- package/dist/workbench/studio/loop/FsToolbar.d.ts +0 -6
- package/dist/workbench/studio/loop/FsToolbar.js +0 -61
- package/dist/workbench/studio/loop/FullScreen.d.ts +0 -5
- package/dist/workbench/studio/loop/FullScreen.js +0 -89
- package/dist/workbench/studio/loop/PrototypePreviewMenus.d.ts +0 -18
- package/dist/workbench/studio/loop/PrototypePreviewMenus.js +0 -75
- package/dist/workbench/studio/loop/PrototypePreviewToolbar.d.ts +0 -27
- package/dist/workbench/studio/loop/PrototypePreviewToolbar.js +0 -52
- package/dist/workbench/studio/loop/fsViews.d.ts +0 -12
- package/dist/workbench/studio/loop/fsViews.js +0 -6
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** What a mark is, for people: "Comment on Price", "Area", "Drawing". */
|
|
2
|
+
export function markWhat(mark, t) {
|
|
3
|
+
if (mark.kind === 'comment')
|
|
4
|
+
return t('studio.marks.mark.comment', { part: mark.part ?? t('studio.marks.mark.spot') });
|
|
5
|
+
return t(mark.kind === 'area' ? 'studio.marks.mark.area' : 'studio.marks.mark.draw');
|
|
6
|
+
}
|
|
7
|
+
/** Where a mark is, for people: "Plant detail · Desktop". */
|
|
8
|
+
export function markWhere(mark, t) {
|
|
9
|
+
return t('studio.marks.mark.where', {
|
|
10
|
+
screen: mark.place.screen,
|
|
11
|
+
device: t(`studio.loop.proto.device.${mark.place.device}`),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
/** The marked screens, one picture each: a mark's screen and device, in the marks' order. */
|
|
15
|
+
export function markedScreens(list) {
|
|
16
|
+
const screens = new Map();
|
|
17
|
+
for (const mark of list) {
|
|
18
|
+
const key = JSON.stringify([mark.place, mark.view, mark.scroll]);
|
|
19
|
+
screens.set(key, [...(screens.get(key) ?? []), mark]);
|
|
20
|
+
}
|
|
21
|
+
return [...screens.values()];
|
|
22
|
+
}
|
|
23
|
+
function box(mark) {
|
|
24
|
+
if (mark.box)
|
|
25
|
+
return mark.box;
|
|
26
|
+
const points = mark.points ?? [];
|
|
27
|
+
const xs = points.map(([x]) => x);
|
|
28
|
+
const ys = points.map(([, y]) => y);
|
|
29
|
+
if (!xs.length)
|
|
30
|
+
return;
|
|
31
|
+
const x = Math.min(...xs);
|
|
32
|
+
const y = Math.min(...ys);
|
|
33
|
+
return { x, y, w: Math.max(...xs) - x, h: Math.max(...ys) - y };
|
|
34
|
+
}
|
|
35
|
+
/** A mark's box in page terms: on the screen, plus how far the page and its scroller were scrolled. */
|
|
36
|
+
function pageBox(mark) {
|
|
37
|
+
const area = box(mark);
|
|
38
|
+
const scroll = mark.scroll;
|
|
39
|
+
if (!area || !scroll)
|
|
40
|
+
return area;
|
|
41
|
+
return {
|
|
42
|
+
...area,
|
|
43
|
+
x: area.x + scroll.page.x + scroll.inner.x,
|
|
44
|
+
y: area.y + scroll.page.y + scroll.inner.y,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function place(mark, t, number) {
|
|
48
|
+
const area = pageBox(mark);
|
|
49
|
+
const size = { width: number(mark.view.width), height: number(mark.view.height) };
|
|
50
|
+
const parts = [
|
|
51
|
+
area &&
|
|
52
|
+
(mark.kind === 'comment'
|
|
53
|
+
? t('studio.marks.message.point', { x: number(area.x), y: number(area.y), ...size })
|
|
54
|
+
: t('studio.marks.message.box', {
|
|
55
|
+
x: number(area.x),
|
|
56
|
+
y: number(area.y),
|
|
57
|
+
w: number(area.w),
|
|
58
|
+
h: number(area.h),
|
|
59
|
+
...size,
|
|
60
|
+
})),
|
|
61
|
+
mark.place.journey &&
|
|
62
|
+
t('studio.marks.message.journey', {
|
|
63
|
+
journey: JSON.stringify(mark.place.journey),
|
|
64
|
+
step: number((mark.place.step ?? 0) + 1),
|
|
65
|
+
}),
|
|
66
|
+
mark.place.data && t('studio.marks.message.data', { data: mark.place.data }),
|
|
67
|
+
];
|
|
68
|
+
return parts.filter(Boolean).join('; ');
|
|
69
|
+
}
|
|
70
|
+
export function marksMessage(sheet, about, t, locale) {
|
|
71
|
+
const format = new Intl.NumberFormat(locale, { maximumFractionDigits: 0 });
|
|
72
|
+
const number = (value) => format.format(value);
|
|
73
|
+
const lines = [
|
|
74
|
+
t('studio.marks.message.head', {
|
|
75
|
+
count: sheet.marks.length,
|
|
76
|
+
change: about.change,
|
|
77
|
+
version: about.version,
|
|
78
|
+
}),
|
|
79
|
+
...(about.pictures ? [t('studio.marks.message.pictures', { count: about.pictures })] : []),
|
|
80
|
+
'',
|
|
81
|
+
...sheet.marks.map((mark, i) => t('studio.marks.message.mark', {
|
|
82
|
+
n: number(i + 1),
|
|
83
|
+
what: markWhat(mark, t),
|
|
84
|
+
where: markWhere(mark, t),
|
|
85
|
+
place: place(mark, t, number),
|
|
86
|
+
note: mark.note.trim() || t('studio.marks.message.noNote'),
|
|
87
|
+
})),
|
|
88
|
+
];
|
|
89
|
+
const more = sheet.more.trim();
|
|
90
|
+
if (more)
|
|
91
|
+
lines.push('', t('studio.marks.message.more', { text: more }));
|
|
92
|
+
return lines.join('\n');
|
|
93
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Attachment, MarkScroll, MarkShotBody } from '@buffcore/contracts/workbench';
|
|
2
|
+
export type MarkTool = 'select' | 'comment' | 'draw' | 'area';
|
|
3
|
+
export type MarkKind = Exclude<MarkTool, 'select'>;
|
|
4
|
+
export type MarkDevice = 'mobile' | 'tablet' | 'desktop';
|
|
5
|
+
export type MarkBox = {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
w: number;
|
|
9
|
+
h: number;
|
|
10
|
+
};
|
|
11
|
+
/** Where a mark was made: the screen's name for people, and the choice that shows it again. */
|
|
12
|
+
export type MarkApp = 'app' | 'console';
|
|
13
|
+
export interface MarkPlace {
|
|
14
|
+
/** The customer app or the console; none is the customer app. */
|
|
15
|
+
app?: MarkApp;
|
|
16
|
+
screen: string;
|
|
17
|
+
device: MarkDevice;
|
|
18
|
+
/** A tablet turned on its side; none is upright. */
|
|
19
|
+
orientation?: 'landscape';
|
|
20
|
+
journey?: string;
|
|
21
|
+
step?: number;
|
|
22
|
+
data?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface Mark {
|
|
25
|
+
id: number;
|
|
26
|
+
kind: MarkKind;
|
|
27
|
+
note: string;
|
|
28
|
+
/** A comment's part, as the app named it; none for "this spot". */
|
|
29
|
+
part?: string;
|
|
30
|
+
place: MarkPlace;
|
|
31
|
+
/** The app's page size when marked, in its own px: the picture is shot at this size. */
|
|
32
|
+
view: {
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
};
|
|
36
|
+
/** A comment's point (w = h = 0) or an area's box, in the app's px. */
|
|
37
|
+
box?: MarkBox;
|
|
38
|
+
/** A drawing's points, in the app's px. */
|
|
39
|
+
points?: readonly (readonly [number, number])[];
|
|
40
|
+
/** How far the app was scrolled (as it said): the px above are on the screen at that scroll. */
|
|
41
|
+
scroll?: MarkScroll;
|
|
42
|
+
}
|
|
43
|
+
export interface MarkSheet {
|
|
44
|
+
marks: readonly Mark[];
|
|
45
|
+
more: string;
|
|
46
|
+
}
|
|
47
|
+
/** The open Prototype page: its sheet, and how it shoots a marked screen. */
|
|
48
|
+
export interface MarksPage {
|
|
49
|
+
key: string;
|
|
50
|
+
change: string;
|
|
51
|
+
version: string;
|
|
52
|
+
locale: string;
|
|
53
|
+
mode: 'light' | 'dark';
|
|
54
|
+
shoot?: (body: MarkShotBody) => Promise<Attachment | undefined>;
|
|
55
|
+
}
|
|
56
|
+
/** The most marks one message carries, and the most points one drawing keeps. */
|
|
57
|
+
export declare const MARKS = 20;
|
|
58
|
+
export declare const DRAWN_POINTS = 400;
|
|
59
|
+
/**
|
|
60
|
+
* The same place: a mark is drawn only on the screen and device it was made on (the journey step
|
|
61
|
+
* or data state that shows it; the screen's name is for people and may arrive later).
|
|
62
|
+
*/
|
|
63
|
+
export declare function samePlace(a: MarkPlace, b: MarkPlace): boolean;
|
|
64
|
+
export declare const marks: {
|
|
65
|
+
sheet: (key: string) => MarkSheet;
|
|
66
|
+
add(key: string, mark: Omit<Mark, 'id'>): number | undefined;
|
|
67
|
+
update(key: string, id: number, patch: Partial<Pick<Mark, 'note' | 'part' | 'scroll'>>): void;
|
|
68
|
+
remove(key: string, id: number): void;
|
|
69
|
+
more(key: string, more: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* The marks that went (by id) leave the sheet; marks made or notes changed since stay, and so do
|
|
72
|
+
* the words for anything else unless they are the ones that went.
|
|
73
|
+
*/
|
|
74
|
+
sent(key: string, went: MarkSheet): void;
|
|
75
|
+
/** The app's answer for mark `id` is on its way: a Send waits for it. */
|
|
76
|
+
asked(id: number, answer: Promise<unknown>): void;
|
|
77
|
+
/** Once every answer for these marks has come (or given up). */
|
|
78
|
+
answered: (list: readonly Mark[]) => Promise<undefined>;
|
|
79
|
+
/** Sent, or Clear all: the sheet starts again. */
|
|
80
|
+
clear(key: string): void;
|
|
81
|
+
/** The Prototype page that is open names its sheet; the panel lists that one. */
|
|
82
|
+
activate(page: MarksPage | undefined): void;
|
|
83
|
+
active: () => MarksPage | undefined;
|
|
84
|
+
/** A click on a mark in the list asks the page to show its screen and device. */
|
|
85
|
+
show(key: string, id: number): void;
|
|
86
|
+
shown: () => {
|
|
87
|
+
key: string;
|
|
88
|
+
id: number;
|
|
89
|
+
at: number;
|
|
90
|
+
} | undefined;
|
|
91
|
+
/** Tests only: forget every sheet. */
|
|
92
|
+
reset(): void;
|
|
93
|
+
};
|
|
94
|
+
/** The sheet for `key`, kept up to date. */
|
|
95
|
+
export declare function useMarkSheet(key: string | undefined): MarkSheet;
|
|
96
|
+
/** The open Prototype page, for the panel. */
|
|
97
|
+
export declare function useActiveMarks(): MarksPage | undefined;
|
|
98
|
+
/** The latest "show this mark" request. */
|
|
99
|
+
export declare function useShownMark(): {
|
|
100
|
+
key: string;
|
|
101
|
+
id: number;
|
|
102
|
+
at: number;
|
|
103
|
+
} | undefined;
|
|
104
|
+
/** While the page is open, its sheet is the one the panel lists. */
|
|
105
|
+
export declare function useMarksPage(page: MarksPage | undefined): void;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { useEffect, useSyncExternalStore } from 'react';
|
|
2
|
+
/** The most marks one message carries, and the most points one drawing keeps. */
|
|
3
|
+
export const MARKS = 20;
|
|
4
|
+
export const DRAWN_POINTS = 400;
|
|
5
|
+
const empty = { marks: [], more: '' };
|
|
6
|
+
const sheets = new Map();
|
|
7
|
+
const listeners = new Set();
|
|
8
|
+
let active;
|
|
9
|
+
let shown;
|
|
10
|
+
let nextId = 1;
|
|
11
|
+
/** A mark's answer from the app (its part and scroll) that has not come yet; at most 1.5 s. */
|
|
12
|
+
const asking = new Map();
|
|
13
|
+
const emit = () => {
|
|
14
|
+
for (const listener of listeners)
|
|
15
|
+
listener();
|
|
16
|
+
};
|
|
17
|
+
const put = (key, sheet) => {
|
|
18
|
+
sheets.set(key, sheet);
|
|
19
|
+
emit();
|
|
20
|
+
};
|
|
21
|
+
const subscribe = (listener) => {
|
|
22
|
+
listeners.add(listener);
|
|
23
|
+
return () => listeners.delete(listener);
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The same place: a mark is drawn only on the screen and device it was made on (the journey step
|
|
27
|
+
* or data state that shows it; the screen's name is for people and may arrive later).
|
|
28
|
+
*/
|
|
29
|
+
export function samePlace(a, b) {
|
|
30
|
+
return ((a.app ?? 'app') === (b.app ?? 'app') &&
|
|
31
|
+
a.device === b.device &&
|
|
32
|
+
a.orientation === b.orientation &&
|
|
33
|
+
a.journey === b.journey &&
|
|
34
|
+
a.step === b.step &&
|
|
35
|
+
a.data === b.data);
|
|
36
|
+
}
|
|
37
|
+
export const marks = {
|
|
38
|
+
sheet: (key) => sheets.get(key) ?? empty,
|
|
39
|
+
add(key, mark) {
|
|
40
|
+
const sheet = marks.sheet(key);
|
|
41
|
+
if (sheet.marks.length >= MARKS)
|
|
42
|
+
return;
|
|
43
|
+
const id = nextId++;
|
|
44
|
+
put(key, { ...sheet, marks: [...sheet.marks, { ...mark, id }] });
|
|
45
|
+
return id;
|
|
46
|
+
},
|
|
47
|
+
update(key, id, patch) {
|
|
48
|
+
const sheet = marks.sheet(key);
|
|
49
|
+
put(key, { ...sheet, marks: sheet.marks.map((m) => (m.id === id ? { ...m, ...patch } : m)) });
|
|
50
|
+
},
|
|
51
|
+
remove(key, id) {
|
|
52
|
+
const sheet = marks.sheet(key);
|
|
53
|
+
put(key, { ...sheet, marks: sheet.marks.filter((m) => m.id !== id) });
|
|
54
|
+
},
|
|
55
|
+
more(key, more) {
|
|
56
|
+
put(key, { ...marks.sheet(key), more });
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* The marks that went (by id) leave the sheet; marks made or notes changed since stay, and so do
|
|
60
|
+
* the words for anything else unless they are the ones that went.
|
|
61
|
+
*/
|
|
62
|
+
sent(key, went) {
|
|
63
|
+
const sheet = marks.sheet(key);
|
|
64
|
+
const gone = new Map(went.marks.map((mark) => [mark.id, mark.note]));
|
|
65
|
+
const left = sheet.marks.filter((mark) => gone.get(mark.id) !== mark.note);
|
|
66
|
+
const more = sheet.more === went.more ? '' : sheet.more;
|
|
67
|
+
if (!left.length && !more)
|
|
68
|
+
return marks.clear(key);
|
|
69
|
+
put(key, { marks: left, more });
|
|
70
|
+
},
|
|
71
|
+
/** The app's answer for mark `id` is on its way: a Send waits for it. */
|
|
72
|
+
asked(id, answer) {
|
|
73
|
+
const settled = answer.then(() => undefined, () => undefined);
|
|
74
|
+
asking.set(id, settled);
|
|
75
|
+
void settled.then(() => {
|
|
76
|
+
if (asking.get(id) === settled)
|
|
77
|
+
asking.delete(id);
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
/** Once every answer for these marks has come (or given up). */
|
|
81
|
+
answered: (list) => Promise.all(list.map((mark) => asking.get(mark.id))).then(() => undefined),
|
|
82
|
+
/** Sent, or Clear all: the sheet starts again. */
|
|
83
|
+
clear(key) {
|
|
84
|
+
sheets.delete(key);
|
|
85
|
+
emit();
|
|
86
|
+
},
|
|
87
|
+
/** The Prototype page that is open names its sheet; the panel lists that one. */
|
|
88
|
+
activate(page) {
|
|
89
|
+
active = page;
|
|
90
|
+
emit();
|
|
91
|
+
},
|
|
92
|
+
active: () => active,
|
|
93
|
+
/** A click on a mark in the list asks the page to show its screen and device. */
|
|
94
|
+
show(key, id) {
|
|
95
|
+
shown = { key, id, at: (shown?.at ?? 0) + 1 };
|
|
96
|
+
emit();
|
|
97
|
+
},
|
|
98
|
+
shown: () => shown,
|
|
99
|
+
/** Tests only: forget every sheet. */
|
|
100
|
+
reset() {
|
|
101
|
+
sheets.clear();
|
|
102
|
+
asking.clear();
|
|
103
|
+
active = undefined;
|
|
104
|
+
shown = undefined;
|
|
105
|
+
emit();
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
/** The sheet for `key`, kept up to date. */
|
|
109
|
+
export function useMarkSheet(key) {
|
|
110
|
+
return useSyncExternalStore(subscribe, () => (key ? marks.sheet(key) : empty), () => empty);
|
|
111
|
+
}
|
|
112
|
+
/** The open Prototype page, for the panel. */
|
|
113
|
+
export function useActiveMarks() {
|
|
114
|
+
return useSyncExternalStore(subscribe, marks.active, () => undefined);
|
|
115
|
+
}
|
|
116
|
+
/** The latest "show this mark" request. */
|
|
117
|
+
export function useShownMark() {
|
|
118
|
+
return useSyncExternalStore(subscribe, marks.shown, () => undefined);
|
|
119
|
+
}
|
|
120
|
+
/** While the page is open, its sheet is the one the panel lists. */
|
|
121
|
+
export function useMarksPage(page) {
|
|
122
|
+
const { key, change, version, locale, mode, shoot } = page ?? {};
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
const next = key && change && version && locale && mode
|
|
125
|
+
? { key, change, version, locale, mode, shoot }
|
|
126
|
+
: undefined;
|
|
127
|
+
marks.activate(next);
|
|
128
|
+
return () => {
|
|
129
|
+
if (marks.active() === next)
|
|
130
|
+
marks.activate(undefined);
|
|
131
|
+
};
|
|
132
|
+
}, [key, change, version, locale, mode, shoot]);
|
|
133
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type PointerEvent, type RefObject } from 'react';
|
|
2
|
+
import { type Mark, type MarkTool } from './marks.ts';
|
|
3
|
+
export interface FrameGeometry {
|
|
4
|
+
/** The frame's offset inside the layer, in layer px. */
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
/** Layer px per app px (the stage may zoom the device to fit). */
|
|
8
|
+
scale: number;
|
|
9
|
+
/** The app's page size, in its own px. */
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
/** Follows the frame's place and zoom under the layer as either resizes. */
|
|
14
|
+
export declare function useFrameGeometry(layer: RefObject<HTMLElement | null>, frame: RefObject<HTMLElement | null>): FrameGeometry | undefined;
|
|
15
|
+
type Draft = {
|
|
16
|
+
kind: 'area' | 'draw';
|
|
17
|
+
points: [number, number][];
|
|
18
|
+
};
|
|
19
|
+
export type NewMark = Pick<Mark, 'kind' | 'box' | 'points'>;
|
|
20
|
+
/** The pointer handlers for the chosen tool; a finished shape is handed to `onMark`. */
|
|
21
|
+
export declare function useMarkingPointer(tool: MarkTool, geometry: FrameGeometry | undefined, layer: RefObject<HTMLElement | null>, onMark: (mark: NewMark) => void): {
|
|
22
|
+
draft: Draft | undefined;
|
|
23
|
+
handlers: {
|
|
24
|
+
onPointerDown: (event: PointerEvent<HTMLElement>) => void;
|
|
25
|
+
onPointerMove: (event: PointerEvent<HTMLElement>) => void;
|
|
26
|
+
onPointerUp: () => void;
|
|
27
|
+
onPointerCancel: () => void;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export declare function draftBox(points: readonly (readonly [number, number])[]): {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
w: number;
|
|
34
|
+
h: number;
|
|
35
|
+
} | undefined;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Where the framed app sits under the marks layer, and the pointer work of each tool. Every mark
|
|
2
|
+
// is kept in the app's own px (its page as the frame lays it out), so the layer draws it at any
|
|
3
|
+
// zoom and the snapshot's browser draws it at the device's size.
|
|
4
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
5
|
+
import { DRAWN_POINTS } from './marks.js';
|
|
6
|
+
/** Follows the frame's place and zoom under the layer as either resizes. */
|
|
7
|
+
export function useFrameGeometry(layer, frame) {
|
|
8
|
+
const [geometry, setGeometry] = useState();
|
|
9
|
+
useLayoutEffect(() => {
|
|
10
|
+
const measure = () => {
|
|
11
|
+
const element = frame.current;
|
|
12
|
+
const own = layer.current?.getBoundingClientRect();
|
|
13
|
+
if (!element || !own)
|
|
14
|
+
return setGeometry(undefined);
|
|
15
|
+
const rect = element.getBoundingClientRect();
|
|
16
|
+
const width = element.clientWidth || rect.width;
|
|
17
|
+
const height = element.clientHeight || rect.height;
|
|
18
|
+
const scale = width ? rect.width / width : 1;
|
|
19
|
+
const next = { x: rect.left - own.left, y: rect.top - own.top, scale, width, height };
|
|
20
|
+
setGeometry((current) => current && JSON.stringify(current) === JSON.stringify(next) ? current : next);
|
|
21
|
+
};
|
|
22
|
+
measure();
|
|
23
|
+
if (typeof ResizeObserver === 'undefined')
|
|
24
|
+
return;
|
|
25
|
+
const observer = new ResizeObserver(measure);
|
|
26
|
+
if (frame.current)
|
|
27
|
+
observer.observe(frame.current);
|
|
28
|
+
if (layer.current)
|
|
29
|
+
observer.observe(layer.current);
|
|
30
|
+
window.addEventListener('resize', measure);
|
|
31
|
+
return () => {
|
|
32
|
+
observer.disconnect();
|
|
33
|
+
window.removeEventListener('resize', measure);
|
|
34
|
+
};
|
|
35
|
+
}, [layer, frame]);
|
|
36
|
+
return geometry;
|
|
37
|
+
}
|
|
38
|
+
const SMALLEST = 6;
|
|
39
|
+
const STEP = 3;
|
|
40
|
+
/** The pointer handlers for the chosen tool; a finished shape is handed to `onMark`. */
|
|
41
|
+
export function useMarkingPointer(tool, geometry, layer, onMark) {
|
|
42
|
+
const [draft, setDraft] = useState();
|
|
43
|
+
const drafting = useRef(undefined);
|
|
44
|
+
const toApp = (event) => {
|
|
45
|
+
const own = layer.current?.getBoundingClientRect();
|
|
46
|
+
if (!geometry || !own)
|
|
47
|
+
return;
|
|
48
|
+
const x = (event.clientX - own.left - geometry.x) / geometry.scale;
|
|
49
|
+
const y = (event.clientY - own.top - geometry.y) / geometry.scale;
|
|
50
|
+
if (x < 0 || y < 0 || x > geometry.width || y > geometry.height)
|
|
51
|
+
return;
|
|
52
|
+
return [Math.round(x), Math.round(y)];
|
|
53
|
+
};
|
|
54
|
+
const set = (next) => {
|
|
55
|
+
drafting.current = next;
|
|
56
|
+
setDraft(next);
|
|
57
|
+
};
|
|
58
|
+
const onPointerDown = (event) => {
|
|
59
|
+
const point = toApp(event);
|
|
60
|
+
if (!point || tool === 'select' || event.button !== 0)
|
|
61
|
+
return;
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
if (tool === 'comment')
|
|
64
|
+
return onMark({ kind: 'comment', box: { ...xy(point), w: 0, h: 0 } });
|
|
65
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
66
|
+
set({ kind: tool, points: [point] });
|
|
67
|
+
};
|
|
68
|
+
const onPointerMove = (event) => {
|
|
69
|
+
const current = drafting.current;
|
|
70
|
+
const point = current && toApp(event);
|
|
71
|
+
if (!current || !point)
|
|
72
|
+
return;
|
|
73
|
+
if (current.kind === 'area')
|
|
74
|
+
return set({ ...current, points: [current.points[0] ?? point, point] });
|
|
75
|
+
const last = current.points.at(-1) ?? point;
|
|
76
|
+
if (Math.hypot(point[0] - last[0], point[1] - last[1]) < STEP)
|
|
77
|
+
return;
|
|
78
|
+
if (current.points.length < DRAWN_POINTS)
|
|
79
|
+
set({ ...current, points: [...current.points, point] });
|
|
80
|
+
};
|
|
81
|
+
const onPointerUp = () => {
|
|
82
|
+
const current = drafting.current;
|
|
83
|
+
set(undefined);
|
|
84
|
+
if (!current)
|
|
85
|
+
return;
|
|
86
|
+
if (current.kind === 'draw') {
|
|
87
|
+
if (current.points.length >= 2)
|
|
88
|
+
onMark({ kind: 'draw', points: current.points });
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const box = draftBox(current.points);
|
|
92
|
+
if (box && box.w >= SMALLEST && box.h >= SMALLEST)
|
|
93
|
+
onMark({ kind: 'area', box });
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
draft,
|
|
97
|
+
handlers: { onPointerDown, onPointerMove, onPointerUp, onPointerCancel: () => set(undefined) },
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const xy = ([x, y]) => ({ x, y });
|
|
101
|
+
export function draftBox(points) {
|
|
102
|
+
const [a, b] = [points[0], points.at(-1)];
|
|
103
|
+
if (!a || !b)
|
|
104
|
+
return;
|
|
105
|
+
return {
|
|
106
|
+
x: Math.min(a[0], b[0]),
|
|
107
|
+
y: Math.min(a[1], b[1]),
|
|
108
|
+
w: Math.abs(a[0] - b[0]),
|
|
109
|
+
h: Math.abs(a[1] - b[1]),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MarkShotBody } from '@buffcore/contracts/workbench';
|
|
2
|
+
import type { TurnControls } from '../frame/panelControls.ts';
|
|
3
|
+
import { type Mark, type MarkSheet, type MarksPage } from './marks.ts';
|
|
4
|
+
/** A chat message carries at most this many pictures (the send route's limit). */
|
|
5
|
+
export declare const PICTURES = 8;
|
|
6
|
+
/** One marked screen's picture request: where it is, its size, and its marks with their numbers. */
|
|
7
|
+
export declare function shotBody(screen: readonly Mark[], all: readonly Mark[], page: Pick<MarksPage, 'locale' | 'mode'>): MarkShotBody;
|
|
8
|
+
/**
|
|
9
|
+
* Send every mark as one message; `shooting` while the pictures are taken. A picture that could
|
|
10
|
+
* not be taken stops the send and says so (`missing`): the marks stay, Send tries again, and
|
|
11
|
+
* `send(true)` sends without the pictures. Only the marks that went leave the sheet.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useSendMarks(page: MarksPage, sheet: MarkSheet, composer: TurnControls['composer']): {
|
|
14
|
+
send: (withoutPictures?: boolean) => Promise<void>;
|
|
15
|
+
shooting: boolean;
|
|
16
|
+
missing: number;
|
|
17
|
+
ready: boolean;
|
|
18
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useLocale, useT } from '@buffcore/i18n/react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { marks } from './marks.js';
|
|
4
|
+
import { markedScreens, marksMessage } from './marks-message.js';
|
|
5
|
+
/** A chat message carries at most this many pictures (the send route's limit). */
|
|
6
|
+
export const PICTURES = 8;
|
|
7
|
+
/** One marked screen's picture request: where it is, its size, and its marks with their numbers. */
|
|
8
|
+
export function shotBody(screen, all, page) {
|
|
9
|
+
const first = screen[0];
|
|
10
|
+
const { journey, step, data } = first.place;
|
|
11
|
+
return {
|
|
12
|
+
...(journey ? { journey, step: step ?? 0 } : {}),
|
|
13
|
+
...(!journey && data ? { data: data } : {}),
|
|
14
|
+
locale: page.locale,
|
|
15
|
+
mode: page.mode,
|
|
16
|
+
...(first.scroll ? { scroll: first.scroll } : {}),
|
|
17
|
+
view: first.view,
|
|
18
|
+
marks: screen.map((mark) => ({
|
|
19
|
+
n: all.indexOf(mark) + 1,
|
|
20
|
+
kind: mark.kind,
|
|
21
|
+
...(mark.box ? { box: mark.box } : {}),
|
|
22
|
+
...(mark.points ? { points: mark.points.map(([x, y]) => [x, y]) } : {}),
|
|
23
|
+
})),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** A picture of each marked screen; `missing` counts the screens that could not be shot. */
|
|
27
|
+
async function pictures(sheet, page) {
|
|
28
|
+
const screens = markedScreens(sheet.marks).slice(0, PICTURES);
|
|
29
|
+
if (!page.shoot)
|
|
30
|
+
return { attachments: [], missing: 0 };
|
|
31
|
+
const shot = await Promise.all(
|
|
32
|
+
// Only the customer app is shot: the console is not pictured (its marks are not made yet).
|
|
33
|
+
screens.map((screen) => screen[0]?.place.app === 'console'
|
|
34
|
+
? undefined
|
|
35
|
+
: page.shoot?.(shotBody(screen, sheet.marks, page)).catch(() => undefined)));
|
|
36
|
+
const attachments = shot.filter((picture) => !!picture);
|
|
37
|
+
return { attachments, missing: screens.length - attachments.length };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Send every mark as one message; `shooting` while the pictures are taken. A picture that could
|
|
41
|
+
* not be taken stops the send and says so (`missing`): the marks stay, Send tries again, and
|
|
42
|
+
* `send(true)` sends without the pictures. Only the marks that went leave the sheet.
|
|
43
|
+
*/
|
|
44
|
+
export function useSendMarks(page, sheet, composer) {
|
|
45
|
+
const t = useT();
|
|
46
|
+
const { locale } = useLocale();
|
|
47
|
+
const [shooting, setShooting] = useState(false);
|
|
48
|
+
const [missing, setMissing] = useState(0);
|
|
49
|
+
const send = async (withoutPictures = false) => {
|
|
50
|
+
if (shooting || !sheet.marks.length || !composer?.onMarks)
|
|
51
|
+
return;
|
|
52
|
+
setMissing(0);
|
|
53
|
+
setShooting(true);
|
|
54
|
+
// The marks on screen now go, once the app said how far each was scrolled (or gave up); what
|
|
55
|
+
// is marked meanwhile stays.
|
|
56
|
+
await marks.answered(sheet.marks);
|
|
57
|
+
const ids = new Set(sheet.marks.map((mark) => mark.id));
|
|
58
|
+
const latest = marks.sheet(page.key);
|
|
59
|
+
const going = { ...latest, marks: latest.marks.filter((mark) => ids.has(mark.id)) };
|
|
60
|
+
if (!going.marks.length)
|
|
61
|
+
return setShooting(false);
|
|
62
|
+
let attachments = [];
|
|
63
|
+
if (withoutPictures)
|
|
64
|
+
setShooting(false);
|
|
65
|
+
else {
|
|
66
|
+
const shot = await pictures(going, page).finally(() => setShooting(false));
|
|
67
|
+
if (shot.missing)
|
|
68
|
+
return setMissing(shot.missing);
|
|
69
|
+
attachments = shot.attachments;
|
|
70
|
+
}
|
|
71
|
+
const about = { change: page.change, version: page.version, pictures: attachments.length };
|
|
72
|
+
composer.onMarks({
|
|
73
|
+
text: marksMessage(going, about, t, locale),
|
|
74
|
+
attachments,
|
|
75
|
+
card: { ...about, marks: going.marks },
|
|
76
|
+
sent: () => marks.sent(page.key, going),
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
return { send, shooting, missing, ready: !!composer?.onMarks };
|
|
80
|
+
}
|
|
@@ -41,6 +41,8 @@ export interface StudioProduct {
|
|
|
41
41
|
branch: string;
|
|
42
42
|
/** Where the work runs, when a host names it; on a person's own computer, none: "This computer". */
|
|
43
43
|
machine?: string;
|
|
44
|
+
/** The host's own launcher starts the agent's turns and applies their limits. */
|
|
45
|
+
hostLaunched?: boolean;
|
|
44
46
|
agent: AgentCard;
|
|
45
47
|
}
|
|
46
48
|
export interface AgentMessage {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare function scaleFacts(): {
|
|
2
2
|
contained?: boolean | undefined;
|
|
3
|
+
hostLaunched?: boolean | undefined;
|
|
3
4
|
viewer?: {
|
|
4
5
|
name: string;
|
|
5
6
|
email?: string | undefined;
|
|
@@ -159,6 +160,11 @@ export declare function scaleFacts(): {
|
|
|
159
160
|
brief: {
|
|
160
161
|
sections: Record<string, string>;
|
|
161
162
|
kind?: "b2b" | "b2c" | undefined;
|
|
163
|
+
parts?: {
|
|
164
|
+
heading: string;
|
|
165
|
+
summary: string[];
|
|
166
|
+
text: string;
|
|
167
|
+
}[] | undefined;
|
|
162
168
|
} | null;
|
|
163
169
|
milestones: {
|
|
164
170
|
name: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buffcore/admin-shell",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.45",
|
|
4
4
|
"description": "The React DOM admin console for a BuffCore product, with its prototype viewer.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "BuffApe",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"@tanstack/react-router": "1.170.42",
|
|
38
38
|
"firebase": "12.19.0",
|
|
39
39
|
"qrcode": "1.5.4",
|
|
40
|
-
"@buffcore/
|
|
41
|
-
"@buffcore/
|
|
42
|
-
"@buffcore/
|
|
43
|
-
"@buffcore/
|
|
44
|
-
"@buffcore/
|
|
40
|
+
"@buffcore/sdk": "0.8.45",
|
|
41
|
+
"@buffcore/config": "0.8.45",
|
|
42
|
+
"@buffcore/tokens": "0.8.45",
|
|
43
|
+
"@buffcore/contracts": "0.8.45",
|
|
44
|
+
"@buffcore/i18n": "0.8.45"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=19",
|