@mistriwork/kit 1.0.0-rc.81 → 1.0.0-rc.82
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/client/breakdownBatch.d.ts +15 -0
- package/dist/client/breakdownBatch.js +53 -9
- package/dist/client/components/PageRelated.js +3 -1
- package/dist/client/components/PageSections.js +12 -4
- package/dist/client/components/Sidebar.js +2 -3
- package/dist/client/components/viewLink.js +1 -1
- package/dist/client/features.css +3 -1
- package/dist/client/index.html +1 -0
- package/dist/client/page.js +14 -1
- package/dist/client/startup.js +6 -2
- package/package.json +3 -3
|
@@ -6,17 +6,26 @@ type BreakdownAsk = ({
|
|
|
6
6
|
text: string;
|
|
7
7
|
def?: never;
|
|
8
8
|
run?: never;
|
|
9
|
+
view?: never;
|
|
9
10
|
} | {
|
|
10
11
|
def: HttpBreakdownDefinition;
|
|
11
12
|
text?: never;
|
|
12
13
|
run?: never;
|
|
14
|
+
view?: never;
|
|
13
15
|
} | {
|
|
14
16
|
run: RunAsk;
|
|
15
17
|
text?: never;
|
|
16
18
|
def?: never;
|
|
19
|
+
view?: never;
|
|
20
|
+
} | {
|
|
21
|
+
view: Record<string, unknown>;
|
|
22
|
+
text?: never;
|
|
23
|
+
def?: never;
|
|
24
|
+
run?: never;
|
|
17
25
|
}) & {
|
|
18
26
|
limit?: number;
|
|
19
27
|
owner?: Record<string, string>;
|
|
28
|
+
page?: string;
|
|
20
29
|
};
|
|
21
30
|
interface RunAsk {
|
|
22
31
|
q: string;
|
|
@@ -27,6 +36,12 @@ interface RunAsk {
|
|
|
27
36
|
}
|
|
28
37
|
/** A list's first page, answered as `/api/run` would answer it, asked with the breakdowns of the same moment. */
|
|
29
38
|
export declare function batchedRun<T = unknown>(run: RunAsk, owner?: Record<string, string>): Promise<T>;
|
|
39
|
+
/**
|
|
40
|
+
* A view's rows, answered as `/api/view/run` would answer them (a refusal the
|
|
41
|
+
* language says is `{ errors }`, as there), asked with the reads of the same
|
|
42
|
+
* moment: a free-form page's `useRows`, records and choices (ui-sdk host.tsx).
|
|
43
|
+
*/
|
|
44
|
+
export declare function batchedView<T = unknown>(view: Record<string, unknown>, page?: string): Promise<T>;
|
|
30
45
|
/** One breakdown, answered as `/api/breakdown` would answer it. */
|
|
31
46
|
export declare function batchedBreakdown<T = unknown>(ask: BreakdownAsk): Promise<T>;
|
|
32
47
|
/** For tests: forget that a server refused the batch. */
|
|
@@ -15,8 +15,16 @@
|
|
|
15
15
|
* whose every read is ledgered as the one read it is, answers 404, and so does
|
|
16
16
|
* an older server — is asked one at a time for the rest of the page's life.
|
|
17
17
|
* A tenant or platform lease takes it: one admission for the cards, not one each.
|
|
18
|
+
*
|
|
19
|
+
* A free-form page's reads ride it too (`batchedView`): its `useRows`, its
|
|
20
|
+
* records and its pickers' choices are each a `/api/view/run`, and a page of
|
|
21
|
+
* nineteen lists was nineteen requests at once, each its own admission and
|
|
22
|
+
* person looked up (a field report: 45 ms to the database, so the requests
|
|
23
|
+
* queued behind each other's sockets). They go with the page's name
|
|
24
|
+
* (`x-mistri-page`), so only reads of one page share a request, and the server
|
|
25
|
+
* holds the whole batch to that page's manifest as it would each read.
|
|
18
26
|
*/
|
|
19
|
-
import { api } from './core.js';
|
|
27
|
+
import { api, pageApi } from './core.js';
|
|
20
28
|
import { sameReads } from './liveReads.js';
|
|
21
29
|
import { composedReply, mayBeComposed } from './composedReads.js';
|
|
22
30
|
import { composedConnection } from './composedHook.js';
|
|
@@ -29,14 +37,38 @@ let scheduled = false;
|
|
|
29
37
|
/* Set once a server says it has no such route; the rest of the page's life
|
|
30
38
|
asks one at a time rather than being refused again. */
|
|
31
39
|
let unsupported = false;
|
|
32
|
-
const item = (ask) => ask.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
const item = (ask) => ask.view
|
|
41
|
+
? { view: ask.view }
|
|
42
|
+
: ask.run
|
|
43
|
+
? { run: ask.run }
|
|
44
|
+
: { ...(ask.def ? { def: ask.def } : { text: ask.text }), ...(ask.limit ? { limit: ask.limit } : {}) };
|
|
45
|
+
/* Sent as the page's own request when a page asks, so the server holds it to that page's manifest. */
|
|
46
|
+
const sendAs = (ask, path, body) => ask.page
|
|
47
|
+
? pageApi(ask.page, path, body)
|
|
48
|
+
: api(path, body);
|
|
49
|
+
const single = (ask) => ask.view
|
|
50
|
+
? sendAs(ask, '/api/view/run', { ...ask.view, ...ask.owner })
|
|
51
|
+
: ask.run
|
|
52
|
+
? sendAs(ask, '/api/run', { ...ask.run, ...ask.owner })
|
|
53
|
+
: sendAs(ask, '/api/breakdown', { ...item(ask), ...ask.owner });
|
|
36
54
|
/** A list's first page, answered as `/api/run` would answer it, asked with the breakdowns of the same moment. */
|
|
37
55
|
export function batchedRun(run, owner) {
|
|
38
56
|
return batchedBreakdown({ run, ...(owner ? { owner } : {}) });
|
|
39
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* A view's rows, answered as `/api/view/run` would answer them (a refusal the
|
|
60
|
+
* language says is `{ errors }`, as there), asked with the reads of the same
|
|
61
|
+
* moment: a free-form page's `useRows`, records and choices (ui-sdk host.tsx).
|
|
62
|
+
*/
|
|
63
|
+
export async function batchedView(view, page) {
|
|
64
|
+
/* A record page's custom section reads what the page's compose may have brought (composedReads.ts). */
|
|
65
|
+
if (mayBeComposed('/api/view/run')) {
|
|
66
|
+
const composed = await composedReply('/api/view/run', view);
|
|
67
|
+
if (composed !== undefined)
|
|
68
|
+
return composed;
|
|
69
|
+
}
|
|
70
|
+
return queued({ view, ...(page ? { page } : {}) });
|
|
71
|
+
}
|
|
40
72
|
/** One breakdown, answered as `/api/breakdown` would answer it. */
|
|
41
73
|
export async function batchedBreakdown(ask) {
|
|
42
74
|
/* A record page's figures come with its compose (composedReads.ts). */
|
|
@@ -49,6 +81,9 @@ export async function batchedBreakdown(ask) {
|
|
|
49
81
|
const carried = firstPaintItem(ask.run ? 'run' : 'breakdown', ask.owner?.app ?? ask.owner?.conn ?? composedConnection(), item(ask));
|
|
50
82
|
if (carried !== undefined)
|
|
51
83
|
return carried;
|
|
84
|
+
return queued(ask);
|
|
85
|
+
}
|
|
86
|
+
function queued(ask) {
|
|
52
87
|
if (unsupported)
|
|
53
88
|
return single(ask);
|
|
54
89
|
return new Promise((resolve, reject) => {
|
|
@@ -57,7 +92,12 @@ export async function batchedBreakdown(ask) {
|
|
|
57
92
|
return;
|
|
58
93
|
scheduled = true;
|
|
59
94
|
/* A macrotask, not a microtask: the cards of one render mount their
|
|
60
|
-
queries across several microtasks, and a timer is after all of them.
|
|
95
|
+
queries across several microtasks, and a timer is after all of them.
|
|
96
|
+
So do a free-form page's sections: each `useRows` is a query whose
|
|
97
|
+
fetch TanStack starts from its own effect after the commit, and sibling
|
|
98
|
+
components' effects, and a refetch's invalidated queries, are spread
|
|
99
|
+
over microtasks that one queued microtask would run between. A timer
|
|
100
|
+
of 0 runs after every one of them, before the browser paints again. */
|
|
61
101
|
setTimeout(flush, 0);
|
|
62
102
|
});
|
|
63
103
|
}
|
|
@@ -67,7 +107,7 @@ async function flush() {
|
|
|
67
107
|
queue = [];
|
|
68
108
|
const owners = new Map();
|
|
69
109
|
for (const pending of waiting) {
|
|
70
|
-
const key = JSON.stringify(pending.ask.owner ?? {});
|
|
110
|
+
const key = JSON.stringify([pending.ask.owner ?? {}, pending.ask.page ?? null]);
|
|
71
111
|
owners.set(key, [...(owners.get(key) ?? []), pending]);
|
|
72
112
|
}
|
|
73
113
|
for (const group of owners.values()) {
|
|
@@ -83,7 +123,7 @@ async function send(batch) {
|
|
|
83
123
|
let results;
|
|
84
124
|
let reply;
|
|
85
125
|
try {
|
|
86
|
-
reply = await
|
|
126
|
+
reply = await sendAs(batch[0].ask, '/api/breakdowns', { items: batch.map(({ ask }) => item(ask)), ...batch[0].ask.owner });
|
|
87
127
|
const said = reply;
|
|
88
128
|
results = Array.isArray(said?.results) && said.results.length === batch.length ? said.results : [];
|
|
89
129
|
if (!results.length)
|
|
@@ -99,10 +139,14 @@ async function send(batch) {
|
|
|
99
139
|
single(ask).then(resolve, reject);
|
|
100
140
|
return;
|
|
101
141
|
}
|
|
102
|
-
batch.forEach(({ resolve, reject }, index) => {
|
|
142
|
+
batch.forEach(({ ask, resolve, reject }, index) => {
|
|
103
143
|
const { status, body } = results[index];
|
|
104
144
|
if (status < 400)
|
|
105
145
|
return resolve(sameReads(body, reply));
|
|
146
|
+
/* A page's read the batch refused is asked again alone, so its failure is the one its own request meets — its
|
|
147
|
+
code, its sign-in, the author's cause — wherever the host maps a refusal. A refused read is the rare case. */
|
|
148
|
+
if (ask.view)
|
|
149
|
+
return void single(ask).then(resolve, reject);
|
|
106
150
|
const said = body;
|
|
107
151
|
reject(Object.assign(new Error(said?.message ?? said?.error ?? say('common.requestFailed', { status })), { status }));
|
|
108
152
|
});
|
|
@@ -736,7 +736,9 @@ function RelatedList({ section, plan, base, recordKey, onEdit, collapsed, counte
|
|
|
736
736
|
void openRecord(table.id, record.key, record.label);
|
|
737
737
|
}
|
|
738
738
|
: undefined }));
|
|
739
|
-
return rowVerbs ? (_jsxs(RowTrailHosts, { children: [_jsx(RowActions, { table: table, rows: groupRows, actions: rowVerbs,
|
|
739
|
+
return rowVerbs ? (_jsxs(RowTrailHosts, { children: [_jsx(RowActions, { table: table, rows: groupRows, actions: rowVerbs,
|
|
740
|
+
/* Named as the list draws the row, references followed: a dialog a row's verb opens said its key (a field report). */
|
|
741
|
+
labelOf: (row) => recordForRow(row, data.columns ?? []).label, onDone: () => {
|
|
740
742
|
refreshLists();
|
|
741
743
|
onActionDone?.();
|
|
742
744
|
} }), table_] })) : (table_);
|
|
@@ -172,8 +172,16 @@ export function TabStrip({ tabs, name, entry, onTab, draw, scoped, eager = [], c
|
|
|
172
172
|
const id = useId();
|
|
173
173
|
// An address says a tab as its word (appAddress.ts): matched by the token or by it.
|
|
174
174
|
const asked = tabs.findIndex((tab) => tabMatches(tab.token, entry.tab));
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
/* The reader's pick is held as the tab's key, not its place: a list's tab comes and goes with its `when` and its rows
|
|
176
|
+
(ListTabs), and a place held across that named another tab, or none. A pick that has left falls back to the tab the
|
|
177
|
+
address names, else the first one standing (a field report). */
|
|
178
|
+
const [chosen, setChosen] = useState(undefined);
|
|
179
|
+
const picked = tabs.findIndex((tab) => tab.key === chosen);
|
|
180
|
+
const active = picked !== -1 ? picked : asked === -1 ? 0 : asked;
|
|
181
|
+
/* The tab the page opened on is seen from the start: left for another, its panel stays drawn and hidden, holding the
|
|
182
|
+
page's height, so a shorter tab picked at the bottom of a phone's page does not pull the strip up under the reader. */
|
|
183
|
+
const [seen, setSeen] = useState(() => new Set(tabs[active] ? [tabs[active].key] : []));
|
|
184
|
+
const drawn = { has: (i) => i === active || eager.includes(i) || seen.has(tabs[i]?.key) };
|
|
177
185
|
const buttons = useRef([]);
|
|
178
186
|
/* The tabs that do not fit go under More (useTabFold.ts); the chosen one is never among them. */
|
|
179
187
|
const yields = new Set(tabs.flatMap((tab, i) => (tab.yields ? [i] : [])));
|
|
@@ -187,8 +195,8 @@ export function TabStrip({ tabs, name, entry, onTab, draw, scoped, eager = [], c
|
|
|
187
195
|
focusing.current = undefined;
|
|
188
196
|
});
|
|
189
197
|
const show = (i) => {
|
|
190
|
-
|
|
191
|
-
|
|
198
|
+
setChosen(tabs[i].key);
|
|
199
|
+
setSeen((s) => new Set(s).add(tabs[i].key));
|
|
192
200
|
/* Written into the address bar without re-rendering: what you are looking
|
|
193
201
|
at is what a link should carry. The first tab writes nothing. */
|
|
194
202
|
onTab(!scoped && i === 0 ? undefined : tabs[i].token);
|
|
@@ -162,10 +162,9 @@ export function Sidebar({ host, footerHost: suppliedFooterHost, onSelect, tabNav
|
|
|
162
162
|
host.toggleAttribute('data-marks', host.querySelector('.nav-icon') !== null);
|
|
163
163
|
});
|
|
164
164
|
/* The current row is brought clear of the foot's fade (features.css `scroll-padding-bottom`): a page you are on that
|
|
165
|
-
sits under the fade reads as greyed out, as if disabled.
|
|
165
|
+
sits under the fade reads as greyed out, as if disabled. A dashboard or a form is current with no table row lit
|
|
166
|
+
(`current` is -1 then), so what is lit is asked of the list itself (a field report). */
|
|
166
167
|
useLayoutEffect(() => {
|
|
167
|
-
if (current < 0)
|
|
168
|
-
return;
|
|
169
168
|
host.querySelector(':scope > li > [aria-current="true"]')?.scrollIntoView?.({ block: 'nearest' });
|
|
170
169
|
}, [host, current, dashView, formView]);
|
|
171
170
|
const rail = !tabNavigation && railed();
|
|
@@ -69,7 +69,7 @@ function openView(key, options = {}) {
|
|
|
69
69
|
if (!room)
|
|
70
70
|
return false;
|
|
71
71
|
if (!isListRoom(room)) {
|
|
72
|
-
go(pageView(dashPageId(key)));
|
|
72
|
+
go(pageView(roomPageId(room) ?? dashPageId(key)));
|
|
73
73
|
return true;
|
|
74
74
|
}
|
|
75
75
|
/* A tab, a search and filters are the words an address says (publicAddress.ts addressQuestion), so a list
|
package/dist/client/features.css
CHANGED
|
@@ -713,7 +713,9 @@ body.first-run #db-label {
|
|
|
713
713
|
.free-page-body { isolation: isolate; }
|
|
714
714
|
/* A bare page (definePage layout: 'bare'): the room owns the window. The sidebar, its reveal, the bars and the menu leave the
|
|
715
715
|
flow; the skip link, the pane and its focus are the shell's still. */
|
|
716
|
-
|
|
716
|
+
/* The crumb bar too, whatever the walk says (Crumbs.tsx decides the same from the walk): a param set with `push` made a
|
|
717
|
+
second step, and the sticky bar came over the page's own controls and took their clicks (a field report). */
|
|
718
|
+
body.page-bare :is(.topbar, .sidebar, .sidebar-reveal, #topnav, #explain-pane, .crumbs-host) { display: none; }
|
|
717
719
|
.free-page-body.is-bare { padding: 0; }
|
|
718
720
|
/* The pane's own gutter goes too: a full-bleed root reaches the window's edges. */
|
|
719
721
|
body.app-mode.page-bare .content { padding-inline: 0; }
|
package/dist/client/index.html
CHANGED
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
const signature = JSON.stringify([app === undefined ? first : encodeURIComponent(app), mode,
|
|
76
76
|
localStorage.getItem('mistri.visual-theme'), systemDark,
|
|
77
77
|
localStorage.getItem('mistri.workbench-visual-theme'), localStorage.getItem('mistri.visual-palettes'),
|
|
78
|
+
[...document.querySelectorAll('meta[name="theme-color"]')].map(meta => meta.content).join(' '),
|
|
78
79
|
...(branding ? [branding.value.identity] : [])]);
|
|
79
80
|
const cached = JSON.parse(sessionStorage.getItem('mistri.startup.v1') || 'null');
|
|
80
81
|
if (!branding && cached?.signature === signature && CSS.supports('color', cached.background) && CSS.supports('color', cached.text)) {
|
package/dist/client/page.js
CHANGED
|
@@ -149,8 +149,21 @@ export async function pageById(id, tableId) {
|
|
|
149
149
|
return suggested(asTable.id);
|
|
150
150
|
}
|
|
151
151
|
if (tableId) {
|
|
152
|
-
if (appPagesOnly())
|
|
152
|
+
if (appPagesOnly()) {
|
|
153
|
+
/* A page the App draws this table's records with (its payload's address book lists it) that this reader's
|
|
154
|
+
catalog left out, because not one of its sections reads for their role (readablePage). The record is still
|
|
155
|
+
theirs: its table's own page draws it, as a section they cannot read is left out of a page they can (a field
|
|
156
|
+
report: such a record did not open at all). An id the App never named is still no page. */
|
|
157
|
+
const named = /** @type {{ pages?: unknown }} */ (shell().app() ?? {}).pages;
|
|
158
|
+
const listed = Array.isArray(named) && named.some((p) => p?.id === id && p?.base === tableId);
|
|
159
|
+
if (listed && findTable(tableId)) {
|
|
160
|
+
const own = await recordPageId(tableId);
|
|
161
|
+
assertCurrent(owner);
|
|
162
|
+
if (own !== id)
|
|
163
|
+
return pageById(own, tableId);
|
|
164
|
+
}
|
|
153
165
|
throw new Error(say('thereIsNoPage', { id }));
|
|
166
|
+
}
|
|
154
167
|
return suggested(tableId);
|
|
155
168
|
}
|
|
156
169
|
throw new Error(say('thereIsNoPage', { id }));
|
package/dist/client/startup.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// while boot is still resolving the workspace; native reload remains usable.
|
|
3
3
|
import { say } from './copy/shell/startup.js';
|
|
4
4
|
import { herePath } from './addressMount.js';
|
|
5
|
-
import { addHostListener, removeHostListener, shellBody, shellById, shellRoot } from './shellHost.js';
|
|
5
|
+
import { addHostListener, removeHostListener, shellBody, shellById, shellQueryAll, shellRoot } from './shellHost.js';
|
|
6
6
|
function guardStartupKeys(event) {
|
|
7
7
|
if (!shellRoot().hasAttribute('data-starting'))
|
|
8
8
|
return;
|
|
@@ -15,7 +15,10 @@ export function rememberStartupAppearance() {
|
|
|
15
15
|
return;
|
|
16
16
|
try {
|
|
17
17
|
const colors = getComputedStyle(shellBody());
|
|
18
|
-
|
|
18
|
+
/* The App's id as index.html's first script reads it: the inside address's first segment. And the look the
|
|
19
|
+
server says the page wears (its theme-color grounds): an App whose look is read from the environment wears
|
|
20
|
+
another after a restart with the same address and the same reader picks, and its veil must not keep the
|
|
21
|
+
last look's ground (a field report). */
|
|
19
22
|
const signature = JSON.stringify([
|
|
20
23
|
herePath().split('/')[1] || '',
|
|
21
24
|
localStorage.getItem('mistri.theme'),
|
|
@@ -23,6 +26,7 @@ export function rememberStartupAppearance() {
|
|
|
23
26
|
matchMedia('(prefers-color-scheme: dark)').matches,
|
|
24
27
|
localStorage.getItem('mistri.workbench-visual-theme'),
|
|
25
28
|
localStorage.getItem('mistri.visual-palettes'),
|
|
29
|
+
[...shellQueryAll('meta[name="theme-color"]')].map((meta) => meta.content).join(' '),
|
|
26
30
|
]);
|
|
27
31
|
sessionStorage.setItem('mistri.startup.v1', JSON.stringify({ signature, background: colors.backgroundColor, text: colors.color }));
|
|
28
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mistriwork/kit",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.82",
|
|
4
4
|
"description": "The shared React client both shells are drawn with: the walk and the address, Grid, Value, the record page, lists, filters and charts.",
|
|
5
5
|
"homepage": "https://mistriwork.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"./package.json": "./package.json"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@mistriwork/engine": "1.0.0-rc.
|
|
89
|
-
"@mistriwork/ui": "1.0.0-rc.
|
|
88
|
+
"@mistriwork/engine": "1.0.0-rc.82",
|
|
89
|
+
"@mistriwork/ui": "1.0.0-rc.82",
|
|
90
90
|
"intl-messageformat": "12.1.2",
|
|
91
91
|
"qrcode-generator": "^2.0.4"
|
|
92
92
|
},
|