@tacoshell/shell 0.1.0 → 0.1.1
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/package.json +2 -2
- package/src/core/bus.ts +30 -6
- package/src/core/contrib.ts +70 -0
- package/src/core/csvfeature.ts +57 -0
- package/src/core/datasets.ts +100 -9
- package/src/core/indicators.ts +62 -0
- package/src/core/jobs.ts +37 -0
- package/src/core/nav.ts +6 -3
- package/src/core/page.ts +11 -1
- package/src/core/prefs.ts +5 -0
- package/src/core/services.ts +29 -12
- package/src/core/sessions.ts +23 -2
- package/src/core/text.ts +6 -0
- package/src/index.ts +2 -0
- package/src/styles.css +105 -2
- package/src/types.ts +23 -3
- package/src/ui/ActionModal.tsx +22 -0
- package/src/ui/App.tsx +14 -2
- package/src/ui/CsvFeature.tsx +151 -0
- package/src/ui/ItemFeature.tsx +39 -0
- package/src/ui/Rail.tsx +54 -8
- package/src/ui/RelatedMenu.tsx +57 -0
- package/src/ui/Sessions.tsx +4 -0
- package/src/ui/SidePanel.tsx +3 -1
- package/src/ui/ViewHost.tsx +39 -19
- package/src/ui/hooks.ts +9 -2
- package/src/ui/settings/Datasets.tsx +12 -2
- package/src/ui/settings/ReleaseNotes.tsx +84 -7
- package/src/ui/settings/Settings.tsx +36 -25
- package/src/ui/settings/SettingsTabs.tsx +63 -0
- package/src/ui/useContrib.ts +36 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tacoshell/shell",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "The Taco runtime: app shell (navigation, Activity Log, Help, Settings), vault, message bus, notifications, search, sessions, datasets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"taco",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@fortawesome/fontawesome-free": "^7.3.1",
|
|
34
|
-
"@tacoshell/sdk": "0.1.
|
|
34
|
+
"@tacoshell/sdk": "0.1.1",
|
|
35
35
|
"react": "^19.3.1",
|
|
36
36
|
"react-dom": "^19.3.1"
|
|
37
37
|
},
|
package/src/core/bus.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// The framework API each view gets (ADR-015, ADR-020, ADR-036, ADR-041). One instance per mounted view, scoped to its module:
|
|
2
2
|
// visibility checks use the caller's module, `storage` is namespaced by it, and the auto-log middleware names it.
|
|
3
3
|
|
|
4
|
-
import type
|
|
4
|
+
import { featureUrl, type Context, type Framework, type Message, type NotificationMessage, type SendResult, type TopicRef, type ViewRef } from '@tacoshell/sdk';
|
|
5
5
|
import type { ReactNode } from 'react';
|
|
6
|
-
import { checkContext, type Page } from './page.ts';
|
|
6
|
+
import { checkContext, NO_CONTEXT, type Page } from './page.ts';
|
|
7
|
+
import * as indicators from './indicators.ts';
|
|
7
8
|
import { dedupe, showSystem } from './notifyrules.ts';
|
|
8
9
|
import * as datasets from './datasets.ts';
|
|
9
10
|
import type { Registry } from '../types.ts';
|
|
@@ -39,10 +40,12 @@ async function route(callerModule: string, m: Message<unknown, unknown>): Promis
|
|
|
39
40
|
const s = services.find(type, name);
|
|
40
41
|
if (!s) return fail('unavailable', `No service ${type}/${name} in this app.`);
|
|
41
42
|
const st = services.stateOf(s);
|
|
42
|
-
if (topic === 'status') return { ok: true, value: { enabled: st.enabled, configured: services.isConfigured(s), healthy: !!st.lastTest?.ok, detail: st.lastTest?.detail } };
|
|
43
|
+
if (topic === 'status') return { ok: true, value: { enabled: st.enabled, configured: services.isConfigured(s), healthy: !!st.lastTest?.ok, warning: st.lastTest?.status === 'warn', detail: st.lastTest?.detail } };
|
|
44
|
+
// The service's non-secret field values (declared defaults filled in): how a feature reads e.g. a board id. Secrets are never returned.
|
|
45
|
+
if (topic === 'config') return { ok: true, value: services.configOf(s) };
|
|
43
46
|
if (!st.enabled) return fail('unavailable', `${s.label} is turned off (Settings → Services).`);
|
|
44
47
|
if (!services.isConfigured(s)) return fail('unavailable', `${s.label} isn't set up yet (Settings → Services → ${s.label}).`);
|
|
45
|
-
if (topic === 'test') { const r = await services.test(s); return r.ok ? { ok: true, value: r } : fail('failed', r.detail); }
|
|
48
|
+
if (topic === 'test') { const r = await services.test(s); return r.ok ? { ok: true, value: { ...r, healthy: true } } : fail('failed', r.detail); }
|
|
46
49
|
const decl = s.topics?.[topic];
|
|
47
50
|
if (!decl) return fail('invalid', `${s.label} has no topic "${topic}".`);
|
|
48
51
|
if (decl.visibility === 'protected' && callerModule !== s.module) return fail('denied', `"${topic}" is protected: only ${s.module} may call it (ADR-015).`);
|
|
@@ -66,7 +69,7 @@ async function route(callerModule: string, m: Message<unknown, unknown>): Promis
|
|
|
66
69
|
}
|
|
67
70
|
if (topic === 'refresh') {
|
|
68
71
|
if (d.kind !== 'refreshable') return fail('unavailable', `${d.label} is import-only: import a CSV in Settings → Datasets.`);
|
|
69
|
-
await datasets.refresh(d, createFramework(d.module));
|
|
72
|
+
await datasets.refresh(d, createFramework(d.module), { load: p.load === 'full' ? 'full' : undefined });
|
|
70
73
|
return { ok: true, value: datasets.meta(d) };
|
|
71
74
|
}
|
|
72
75
|
} catch (e) { return fail(e instanceof datasets.LockedError ? 'locked' : 'failed', (e as Error).message); }
|
|
@@ -141,10 +144,31 @@ let renderSlot: (page: Page, name: string) => ReactNode = () => null;
|
|
|
141
144
|
export const setSlotRenderer = (fn: typeof renderSlot) => { renderSlot = fn; };
|
|
142
145
|
|
|
143
146
|
/** A framework instance for one module on one page. Panels from other modules on the same page share the page (ADR-053). */
|
|
144
|
-
export function createFramework(moduleId: string, page?: Page): Framework {
|
|
147
|
+
export function createFramework(moduleId: string, page?: Page, featureView?: string): Framework {
|
|
148
|
+
// Indicators belong to the nav feature of the view this instance serves (its page's view, or the one a background job names).
|
|
149
|
+
const viewName = featureView ?? page?.key.slice(page.key.lastIndexOf('/') + 1);
|
|
150
|
+
const rv = viewName ? registry?.views.find((v) => v.module === moduleId && v.name === viewName) : undefined;
|
|
145
151
|
const flog = log.logger(moduleId === 'self' ? 'this app' : moduleId);
|
|
146
152
|
const noPage = () => { throw new Error('This framework instance is not attached to a page.'); };
|
|
153
|
+
// This module's datasets, live, with refresh and cancel: what its Settings → Datasets tab is built from (ADR-072).
|
|
154
|
+
const ownDatasets = {
|
|
155
|
+
...datasets.infoStore(moduleId),
|
|
156
|
+
async refresh(name: string, opts?: { load?: 'full' | 'incremental' }): Promise<SendResult<ReturnType<typeof datasets.infoOf>>> {
|
|
157
|
+
const d = datasets.find(moduleId, name);
|
|
158
|
+
if (!d) return fail('unavailable', `${moduleId} has no dataset "${name}".`);
|
|
159
|
+
if (d.kind !== 'refreshable') return fail('unavailable', `${d.label} is import-only.`);
|
|
160
|
+
if (vault.status() !== 'unlocked') return fail('locked', `${d.label} is in the vault, which is locked.`);
|
|
161
|
+
try { await datasets.refresh(d, createFramework(moduleId), opts); return { ok: true, value: datasets.infoOf(d) }; }
|
|
162
|
+
catch (e) { return fail((e as Error).message === 'Cancelled' ? 'failed' : e instanceof datasets.LockedError ? 'locked' : 'failed', (e as Error).message); }
|
|
163
|
+
},
|
|
164
|
+
cancel(name: string) { const d = datasets.find(moduleId, name); if (d) datasets.cancel(d); },
|
|
165
|
+
};
|
|
147
166
|
return {
|
|
167
|
+
datasets: ownDatasets,
|
|
168
|
+
expose(ctx) { if (page && plainJson(ctx)) page.exposed.set(ctx ?? NO_CONTEXT); },
|
|
169
|
+
indicators: indicators.forFeature(rv ? `${rv.module}::${rv.nav.feature ?? rv.name}` : undefined),
|
|
170
|
+
urlOf: (t) => ('href' in t ? t.href : featureUrl(t.module, t.component.replace(/^view:/, ''))),
|
|
171
|
+
close: () => page?.close?.(),
|
|
148
172
|
log: flog,
|
|
149
173
|
async send<Req, Res>(m: Message<Req, Res>): Promise<SendResult<Res>> {
|
|
150
174
|
const label = `${m.topic.component}.${m.topic.topic}`;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Related (menu) and Actions (ITEM right rail): which features contribute, and what they say about the feature being viewed.
|
|
2
|
+
// Only views that opted in (manifest `related: true` / `actions: true`) are asked: that flag is the index, so no other feature is ever iterated.
|
|
3
|
+
|
|
4
|
+
import { BUTTON_LABEL_MAX, featureUrl, type ButtonStyleType, type Contribution, type Contributor, type ContributorEnv, type FeatureInfo, type FeatureType } from '@tacoshell/sdk';
|
|
5
|
+
import type { CSSProperties } from 'react';
|
|
6
|
+
import { checkContext } from './page.ts';
|
|
7
|
+
import { clipText } from './text.ts';
|
|
8
|
+
import type { Context } from '@tacoshell/sdk';
|
|
9
|
+
import * as log from './log.ts';
|
|
10
|
+
import { viewKey, type Registry, type RegistryView } from '../types.ts';
|
|
11
|
+
|
|
12
|
+
export type ContribKind = 'related' | 'actions';
|
|
13
|
+
export type Handlers = Record<string, { contributeRelated?: Contributor; contributeActions?: Contributor } | undefined>;
|
|
14
|
+
|
|
15
|
+
/** A Related button, resolved: its action is a registry view of type ACTION and its label is clipped. */
|
|
16
|
+
export interface CollectedButton { label: string; styleType?: ButtonStyleType; styleClass?: string; styleInline?: CSSProperties; context?: Context; action: RegistryView }
|
|
17
|
+
export interface Collected { id: string; view: RegistryView; label: string; icon?: string; href: string; context?: Context; button?: CollectedButton }
|
|
18
|
+
|
|
19
|
+
/** Resolves a contribution's button against the registry; a button whose action isn't an ACTION view of this app is dropped (and logged), the link stays. */
|
|
20
|
+
function resolveButton(reg: Registry, owner: RegistryView, b: Contribution['button']): CollectedButton | undefined {
|
|
21
|
+
if (!b) return undefined;
|
|
22
|
+
const action = b.action && reg.views.find((v) => v.module === b.action.module && v.name === b.action.component.replace(/^view:/, ''));
|
|
23
|
+
if (!action || action.viewType !== 'ACTION') { log.add('error', `${viewKey(owner)}: a Related button's action must be an ACTION view of this app (${b.action ? `${b.action.module}/${b.action.component}` : 'no action given'})`, undefined, owner.module); return undefined; }
|
|
24
|
+
if (!b.label?.trim()) { log.add('error', `${viewKey(owner)}: a Related button needs a label`, undefined, owner.module); return undefined; }
|
|
25
|
+
return { label: clipText(b.label, BUTTON_LABEL_MAX), styleType: b.styleType, styleClass: b.styleClass, styleInline: b.styleInline, context: b.context, action };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Why an ACTION can't be opened with this context (it doesn't match the view's declaration), or null. */
|
|
29
|
+
export const actionProblem = (view: RegistryView, ctx: Context) => checkContext(view.context, ctx);
|
|
30
|
+
|
|
31
|
+
/** The nav feature key: `<module>::<feature or view name>` (matches core/nav.ts). */
|
|
32
|
+
export const featureKeyOf = (v: { module: string; name: string; nav: { feature?: string } }) => `${v.module}::${v.nav.feature ?? v.name}`;
|
|
33
|
+
|
|
34
|
+
export const infoOf = (v: RegistryView): FeatureInfo => ({ module: v.module, view: v.name, id: viewKey(v), feature: v.nav.feature ?? v.label, label: v.label, type: (v.viewType || 'GENERAL') as FeatureType, href: featureUrl(v.module, v.name) });
|
|
35
|
+
|
|
36
|
+
/** The opted-in contributors for a viewed feature: Related never includes ACTION views or the feature itself; Actions are ACTION views only. */
|
|
37
|
+
export const contributors = (reg: Registry, kind: ContribKind, current: RegistryView) =>
|
|
38
|
+
reg.views.filter((v) => (kind === 'related' ? v.related === true && v.viewType !== 'ACTION' && viewKey(v) !== viewKey(current) : v.actions === true && v.viewType === 'ACTION'));
|
|
39
|
+
|
|
40
|
+
export const byLabel = (a: Collected, b: Collected) => a.label.localeCompare(b.label, undefined, { sensitivity: 'base' }) || a.id.localeCompare(b.id);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Asks every contributor in parallel; `onItems` gets the sorted list so far each time one answers, so a menu can show as soon as the first
|
|
44
|
+
* item arrives. A contributor that throws is logged and skipped. Resolves when every contributor has answered.
|
|
45
|
+
*/
|
|
46
|
+
export async function collect(opts: {
|
|
47
|
+
reg: Registry; kind: ContribKind; current: RegistryView; context: Context; handlers: Handlers; usable?: (v: RegistryView) => boolean;
|
|
48
|
+
/** The framework and logger each contributor gets (as its own module). */ env?: (v: RegistryView) => ContributorEnv;
|
|
49
|
+
onItems: (items: Collected[]) => void; cancelled?: () => boolean;
|
|
50
|
+
}): Promise<Collected[]> {
|
|
51
|
+
const { reg, kind, current, context, handlers, onItems } = opts;
|
|
52
|
+
const info = infoOf(current);
|
|
53
|
+
const items: Collected[] = [];
|
|
54
|
+
await Promise.all(contributors(reg, kind, current).filter((v) => opts.usable?.(v) ?? true).map(async (v) => {
|
|
55
|
+
const fn = kind === 'related' ? handlers[viewKey(v)]?.contributeRelated : handlers[viewKey(v)]?.contributeActions;
|
|
56
|
+
if (!fn) return;
|
|
57
|
+
try {
|
|
58
|
+
const out = ((await fn(info, context, opts.env?.(v) as ContributorEnv)) ?? []) as Contribution[];
|
|
59
|
+
if (opts.cancelled?.()) return;
|
|
60
|
+
for (const c of out) if (c && typeof c.label === 'string' && c.label.trim()) items.push({ id: `${viewKey(v)}|${c.label}`, view: v, label: c.label, icon: c.icon, href: featureUrl(v.module, v.name), context: c.context, button: kind === 'related' ? resolveButton(reg, v, c.button) : undefined });
|
|
61
|
+
if (out.length) onItems([...items].sort(byLabel));
|
|
62
|
+
} catch (e) { log.add('error', `${viewKey(v)}: ${kind === 'related' ? 'contributeRelated' : 'contributeActions'} failed: ${(e as Error).message}`, undefined, v.module); }
|
|
63
|
+
}));
|
|
64
|
+
return [...items].sort(byLabel);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The context the target receives: its own keys from the contribution, plus the viewed feature's exact context under the reserved `referrer`. */
|
|
68
|
+
export const targetContext = (c: Pick<Collected, 'context'>, viewed: Context): Context => ({ ...(c.context ?? {}), referrer: viewed });
|
|
69
|
+
/** The context a Related button's action receives: its own `context` as the primary, the viewed feature's under `referrer`. */
|
|
70
|
+
export const buttonContext = (b: Pick<CollectedButton, 'context'>, viewed: Context): Context => ({ ...(b.context ?? {}), referrer: viewed });
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// CSV feature type: template, upload parsing, per-column value filters and row results. Pure, so it is unit-tested (the UI is ui/CsvFeature.tsx).
|
|
2
|
+
|
|
3
|
+
import type { CsvColumn, CsvFeatureDef, RowResult, RowStatus } from '@tacoshell/sdk';
|
|
4
|
+
import { parseCsv, stringifyCsv } from './csv.ts';
|
|
5
|
+
|
|
6
|
+
export type CsvRow = Record<string, string>;
|
|
7
|
+
export const BLANK = '(blank)';
|
|
8
|
+
export const labelOf = (c: CsvColumn) => c.label ?? c.key;
|
|
9
|
+
export const shownColumns = (def: Pick<CsvFeatureDef, 'columns'>) => def.columns.filter((c) => c.show !== false);
|
|
10
|
+
|
|
11
|
+
/** The template CSV: the feature's `template.rows`, else one row built from each column's `sample`. */
|
|
12
|
+
export function templateCsv(def: Pick<CsvFeatureDef, 'columns' | 'template'>): string {
|
|
13
|
+
const keys = def.columns.map((c) => c.key);
|
|
14
|
+
const rows = def.template?.rows?.length ? def.template.rows : [Object.fromEntries(def.columns.map((c) => [c.key, c.sample ?? '']))];
|
|
15
|
+
return stringifyCsv(keys, rows);
|
|
16
|
+
}
|
|
17
|
+
export const templateName = (def: Pick<CsvFeatureDef, 'template'>, view: string) => def.template?.filename ?? `${view}-template.csv`;
|
|
18
|
+
|
|
19
|
+
export interface Parsed { rows: CsvRow[]; headers: string[]; problems: string[]; skipped: string[] }
|
|
20
|
+
|
|
21
|
+
/** Header → objects (extra columns are kept, so the processor gets the full row). `line` is the row's line in the file (the header is line 1). */
|
|
22
|
+
export function parseUpload(text: string, def: Pick<CsvFeatureDef, 'columns' | 'validateRow' | 'skipRow'>): Parsed {
|
|
23
|
+
const table = parseCsv(text);
|
|
24
|
+
const out: Parsed = { rows: [], headers: [], problems: [], skipped: [] };
|
|
25
|
+
if (!table.length) { out.problems.push('The file is empty.'); return out; }
|
|
26
|
+
out.headers = table[0].map((h) => h.trim());
|
|
27
|
+
const missing = def.columns.filter((c) => c.required && !out.headers.includes(c.key)).map((c) => c.key);
|
|
28
|
+
if (missing.length) { out.problems.push(`Missing column${missing.length > 1 ? 's' : ''}: ${missing.join(', ')}. Start from the template and keep its header.`); return out; }
|
|
29
|
+
table.slice(1).forEach((cells, i) => {
|
|
30
|
+
const line = i + 2;
|
|
31
|
+
const row: CsvRow = Object.fromEntries(out.headers.map((h, c) => [h, (cells[c] ?? '').trim()]));
|
|
32
|
+
const why = def.skipRow?.(row, line);
|
|
33
|
+
if (why) { out.skipped.push(`Line ${line}: ${why}`); return; }
|
|
34
|
+
const bad = def.validateRow?.(row, line);
|
|
35
|
+
if (bad) out.problems.push(`Line ${line}: ${bad}`);
|
|
36
|
+
out.rows.push(row);
|
|
37
|
+
});
|
|
38
|
+
if (!out.problems.length && !out.rows.length) out.problems.push(out.skipped.length ? 'Every row was removed.' : 'The file has no data rows.');
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Distinct values of a column, sorted (blank last): what its filter dropdown lists. */
|
|
43
|
+
export function distinct(rows: CsvRow[], key: string): string[] {
|
|
44
|
+
const set = new Set(rows.map((r) => (r[key] ?? '') || BLANK));
|
|
45
|
+
return [...set].sort((a, b) => (a === BLANK ? 1 : b === BLANK ? -1 : a.localeCompare(b, undefined, { numeric: true })));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** `excluded[col]` = values the user unticked. Default (nothing excluded) shows every row. Returns indexes into `rows`. */
|
|
49
|
+
export function visibleIndexes(rows: CsvRow[], excluded: Record<string, ReadonlySet<string>>): number[] {
|
|
50
|
+
const cols = Object.entries(excluded).filter(([, set]) => set.size);
|
|
51
|
+
return rows.flatMap((r, i) => (cols.every(([k, set]) => !set.has((r[k] ?? '') || BLANK)) ? [i] : []));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const normalizeResult = (r: RowStatus | RowResult | void | undefined): RowResult => (typeof r === 'string' ? { status: r } : r && (r as RowResult).status ? (r as RowResult) : { status: 'ok' });
|
|
55
|
+
export const ICON: Record<RowStatus, string> = { ok: '✅', warn: '⚠️', error: '❌' };
|
|
56
|
+
|
|
57
|
+
export const sleep = (ms: number) => new Promise<void>((r) => setTimeout(r, ms));
|
package/src/core/datasets.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// kind importOnly = CSV import only; refreshable = a module routine produces the rows (CSV import still works). Rows are stored ONLY in the vault
|
|
4
4
|
// (one encrypted, gzipped blob per dataset), typed on read from the schema, cached in memory while unlocked, and dropped from memory on lock.
|
|
5
5
|
|
|
6
|
-
import type { Framework, Routine } from '@tacoshell/sdk';
|
|
6
|
+
import type { DatasetInfo, Framework, Routine, Store } from '@tacoshell/sdk';
|
|
7
7
|
import type { Registry, RegistryDataset } from '../types.ts';
|
|
8
8
|
import { parseCsv, stringifyCsv } from './csv.ts';
|
|
9
9
|
import * as log from './log.ts';
|
|
@@ -15,6 +15,7 @@ import * as vault from './vault.ts';
|
|
|
15
15
|
|
|
16
16
|
export type Row = Record<string, unknown>;
|
|
17
17
|
export interface DatasetState { rows: number; columns: string[]; updatedAt?: string; source?: 'csv' | 'routine' | 'set'; durations: number[]; refreshing?: boolean; lastError?: string;
|
|
18
|
+
/** The user's choice for an incremental dataset: what the next refresh does. */ load?: 'full' | 'incremental';
|
|
18
19
|
/** The user's schedule (Settings → Datasets → Schedule); wins over the developer's default in the manifest. `cron: null` = manual only. */
|
|
19
20
|
schedule?: { cron: string | null }; scheduleSetAt?: number; lastAttemptAt?: number }
|
|
20
21
|
|
|
@@ -147,24 +148,88 @@ export async function clear(d: RegistryDataset) {
|
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
/** Refreshable datasets: runs the module's routine (a Full Load) and records how long it took; the estimate is the average of the last 3. */
|
|
150
|
-
|
|
151
|
+
/** Datasets refreshing right now (ids). The header's database icon shows while this is non-empty. */
|
|
152
|
+
export const refreshingNow = createStore<string[]>([]);
|
|
153
|
+
const queued = new Set<string>();
|
|
154
|
+
let chain: Promise<unknown> = Promise.resolve();
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Refreshes one dataset. The framework serializes every refresh (scheduled or manual) so two datasets never run on top of each other:
|
|
158
|
+
* a request made while another runs waits its turn. Asking for a dataset that is already running or waiting is refused.
|
|
159
|
+
*/
|
|
160
|
+
export function refresh(d: RegistryDataset, framework: Framework, opts: { load?: 'full' | 'incremental' } = {}): Promise<number> {
|
|
161
|
+
const id = idOf(d);
|
|
162
|
+
if (queued.has(id)) return Promise.reject(new Error(`${d.label} is already refreshing.`));
|
|
163
|
+
queued.add(id);
|
|
164
|
+
const run = chain.then(async () => {
|
|
165
|
+
refreshingNow.set([...refreshingNow.get(), id]);
|
|
166
|
+
try { return await runRefresh(d, framework, opts.load); }
|
|
167
|
+
finally { refreshingNow.set(refreshingNow.get().filter((x) => x !== id)); progressNow.set(without(progressNow.get(), id)); controllers.delete(id); }
|
|
168
|
+
}).finally(() => queued.delete(id));
|
|
169
|
+
chain = run.catch(() => {});
|
|
170
|
+
return run;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** What each running refresh says it is doing, and whether the user asked it to stop. */
|
|
174
|
+
export const progressNow = createStore<Record<string, { text?: string; cancelling: boolean }>>({});
|
|
175
|
+
const controllers = new Map<string, AbortController>();
|
|
176
|
+
const without = <T,>(o: Record<string, T>, k: string) => { const { [k]: _gone, ...rest } = o; return rest; };
|
|
177
|
+
|
|
178
|
+
/** The load the next refresh will do: incremental only for a dataset that declares it, once it has data, unless the user chose Full. */
|
|
179
|
+
export function loadOf(d: RegistryDataset, ask?: 'full' | 'incremental'): 'full' | 'incremental' {
|
|
180
|
+
if (!d.incremental || !stateOf(d).rows) return 'full';
|
|
181
|
+
return (ask ?? stateOf(d).load ?? 'incremental') === 'full' ? 'full' : 'incremental';
|
|
182
|
+
}
|
|
183
|
+
export const setLoad = (d: RegistryDataset, load: 'full' | 'incremental') => setState(d, { load });
|
|
184
|
+
|
|
185
|
+
/** Asks the running refresh of a dataset to stop. Its routine sees `ctx.signal`; whatever it returns afterwards is discarded. */
|
|
186
|
+
export function cancel(d: RegistryDataset) {
|
|
187
|
+
const c = controllers.get(idOf(d));
|
|
188
|
+
if (!c || c.signal.aborted) return;
|
|
189
|
+
c.abort();
|
|
190
|
+
progressNow.set({ ...progressNow.get(), [idOf(d)]: { ...progressNow.get()[idOf(d)], cancelling: true } });
|
|
191
|
+
log.add('info', `Cancelling the refresh of ${d.label}…`, undefined, 'Datasets');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async function runRefresh(d: RegistryDataset, framework: Framework, ask?: 'full' | 'incremental'): Promise<number> {
|
|
151
195
|
const routine = routines[idOf(d)];
|
|
152
196
|
if (d.kind !== 'refreshable' || !routine) throw new Error(`${d.label} is import-only: import a CSV in Settings → Datasets.`);
|
|
153
197
|
if (stateOf(d).refreshing) throw new Error(`${d.label} is already refreshing.`);
|
|
154
198
|
const started = Date.now();
|
|
155
199
|
await setState(d, { refreshing: true, lastAttemptAt: started });
|
|
156
200
|
const dlog = log.logger(`Datasets › ${d.label}`);
|
|
201
|
+
const id = idOf(d);
|
|
202
|
+
const controller = new AbortController();
|
|
203
|
+
controllers.set(id, controller);
|
|
204
|
+
progressNow.set({ ...progressNow.get(), [id]: { cancelling: false } });
|
|
205
|
+
const load = loadOf(d, ask);
|
|
157
206
|
try {
|
|
158
|
-
const result = await routine.run({
|
|
207
|
+
const result = await routine.run({
|
|
208
|
+
framework, log: dlog, previous: { rows: stateOf(d).rows, updatedAt: stateOf(d).updatedAt }, load, signal: controller.signal,
|
|
209
|
+
progress: (text) => { progressNow.set({ ...progressNow.get(), [id]: { ...progressNow.get()[id], text, cancelling: controller.signal.aborted } }); dlog.debug(text); },
|
|
210
|
+
});
|
|
211
|
+
if (controller.signal.aborted) throw new Error('Cancelled');
|
|
159
212
|
const next = result.rows.map((r) => typedRow(d, r));
|
|
160
|
-
|
|
213
|
+
const mode = load === 'full' ? 'replace' : result.mode ?? 'upsert'; // an incremental load that doesn't say how to merge upserts when there is a key, else appends
|
|
214
|
+
let stored = next, total = next.length;
|
|
215
|
+
if (mode !== 'replace') {
|
|
216
|
+
const existing = await rows(d);
|
|
217
|
+
if (mode === 'upsert' && d.key) {
|
|
218
|
+
const byKey = new Map(existing.map((r) => [r[d.key!], r]));
|
|
219
|
+
for (const r of next) byKey.set(r[d.key], { ...(byKey.get(r[d.key]) ?? {}), ...r });
|
|
220
|
+
stored = [...byKey.values()];
|
|
221
|
+
} else stored = [...existing, ...next];
|
|
222
|
+
total = stored.length;
|
|
223
|
+
}
|
|
224
|
+
await write(d, stored, 'routine', result.columns);
|
|
161
225
|
await setState(d, { refreshing: false, durations: [...stateOf(d).durations, Date.now() - started].slice(-3) });
|
|
162
|
-
dlog.info(`Refreshed: ${next.length} row(s) in ${Math.round((Date.now() - started) / 100) / 10} s`);
|
|
226
|
+
dlog.info(`${load === 'incremental' ? `Incremental load (${mode})` : 'Refreshed'}: ${next.length} row(s) loaded, ${total} total, in ${Math.round((Date.now() - started) / 100) / 10} s`);
|
|
163
227
|
return next.length;
|
|
164
228
|
} catch (e) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
229
|
+
const cancelled = controller.signal.aborted;
|
|
230
|
+
await setState(d, { refreshing: false, lastError: cancelled ? undefined : (e as Error).message });
|
|
231
|
+
if (cancelled) dlog.warn('Refresh cancelled; the data is unchanged.'); else dlog.error(`Refresh failed: ${(e as Error).message}`);
|
|
232
|
+
throw cancelled ? new Error('Cancelled') : e;
|
|
168
233
|
}
|
|
169
234
|
}
|
|
170
235
|
// ── Schedules: the developer ships a default (manifest `schedule.cron`), the user chooses when and how often ─────────────
|
|
@@ -270,7 +335,33 @@ export async function remove(d: RegistryDataset, ids: unknown[]): Promise<number
|
|
|
270
335
|
return all.length - keep.length;
|
|
271
336
|
}
|
|
272
337
|
|
|
338
|
+
const planOf = (d: RegistryDataset) => loadOf(d);
|
|
339
|
+
/** This module's datasets as the framework hands them to a Settings tab: live (rows, refreshing, progress) as states change. Snapshots are cached so React can compare them. */
|
|
340
|
+
export function infoOf(d: RegistryDataset): DatasetInfo {
|
|
341
|
+
const st = stateOf(d), id = idOf(d), p = progressNow.get()[id];
|
|
342
|
+
return {
|
|
343
|
+
name: d.name, label: d.label, kind: d.kind, key: d.key, rows: st.rows, columns: st.columns, updatedAt: st.updatedAt, source: st.source,
|
|
344
|
+
refreshing: refreshingNow.get().includes(id), progress: p?.text, cancelling: !!p?.cancelling, schedule: describeSchedule(d), lastError: st.lastError,
|
|
345
|
+
incremental: !!d.incremental, load: planOf(d),
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
let sourceVersion = 0;
|
|
349
|
+
for (const src of [states, refreshingNow, progressNow]) src.subscribe(() => { sourceVersion++; });
|
|
350
|
+
const infoCache = new Map<string, { version: number; list: DatasetInfo[] }>();
|
|
351
|
+
export function infoStore(module: string): Store<DatasetInfo[]> {
|
|
352
|
+
return {
|
|
353
|
+
get() {
|
|
354
|
+
const c = infoCache.get(module);
|
|
355
|
+
if (c && c.version === sourceVersion) return c.list;
|
|
356
|
+
const list = (registry?.datasets ?? []).filter((d) => d.module === module).map(infoOf);
|
|
357
|
+
infoCache.set(module, { version: sourceVersion, list });
|
|
358
|
+
return list;
|
|
359
|
+
},
|
|
360
|
+
subscribe(fn) { const offs = [states, refreshingNow, progressNow].map((s) => s.subscribe(fn)); return () => offs.forEach((o) => o()); },
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
273
364
|
export const meta = (d: RegistryDataset) => {
|
|
274
365
|
const st = stateOf(d);
|
|
275
|
-
return { rows: st.rows, key: d.key, kind: d.kind, lastRefreshed: st.updatedAt, source: st.source, schema: d.schema, columns: st.columns, estimateMs: estimateMs(d), schedule: describeSchedule(d), nextRefresh: nextDue(d) ? new Date(nextDue(d)!).toISOString() : undefined };
|
|
366
|
+
return { rows: st.rows, refreshing: refreshingNow.get().includes(idOf(d)), progress: progressNow.get()[idOf(d)]?.text, incremental: !!d.incremental, load: planOf(d), key: d.key, kind: d.kind, lastRefreshed: st.updatedAt, source: st.source, schema: d.schema, columns: st.columns, estimateMs: estimateMs(d), schedule: describeSchedule(d), nextRefresh: nextDue(d) ? new Date(nextDue(d)!).toISOString() : undefined };
|
|
276
367
|
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Indicator bubbles (left navigation): any feature may have any number, set from its view or its background job.
|
|
2
|
+
// State is per feature (`<module>::<feature>`, the nav feature key), in memory only: a background job repopulates it.
|
|
3
|
+
|
|
4
|
+
import type { Indicator, Indicators } from '@tacoshell/sdk';
|
|
5
|
+
import { createStore } from './prefs.ts';
|
|
6
|
+
import { clipText } from './text.ts';
|
|
7
|
+
|
|
8
|
+
export const PALETTE_SIZE = 16;
|
|
9
|
+
export const MAX_BUBBLES = 4;
|
|
10
|
+
export const MAX_CHARS = 4;
|
|
11
|
+
|
|
12
|
+
export const all = createStore<Record<string, Indicator[]>>({});
|
|
13
|
+
|
|
14
|
+
/** At most 4 characters; emoji and other multi-code-unit characters count once. */
|
|
15
|
+
export const clip = (text: string): string => clipText(text, MAX_CHARS);
|
|
16
|
+
|
|
17
|
+
const put = (feature: string, list: Indicator[]) => { const next = { ...all.get() }; if (list.length) next[feature] = list; else delete next[feature]; all.set(next); };
|
|
18
|
+
const same = (a: Indicator, b: Indicator) => a.id === b.id && a.text === b.text && a.color === b.color && a.background === b.background && a.title === b.title && a.view === b.view;
|
|
19
|
+
|
|
20
|
+
/** The API a feature gets as `framework.indicators`. */
|
|
21
|
+
export function forFeature(feature: string | undefined): Indicators {
|
|
22
|
+
const get = () => (feature ? all.get()[feature] ?? [] : []);
|
|
23
|
+
return {
|
|
24
|
+
add(i) {
|
|
25
|
+
if (!feature) return;
|
|
26
|
+
const next = { ...i, text: clip(i.text) };
|
|
27
|
+
const cur = get();
|
|
28
|
+
const old = cur.find((x) => x.id === i.id);
|
|
29
|
+
if (old && same(old, next)) return;
|
|
30
|
+
put(feature, [...cur.filter((x) => x.id !== i.id), next]);
|
|
31
|
+
},
|
|
32
|
+
update(id, patch) {
|
|
33
|
+
if (!feature) return;
|
|
34
|
+
const cur = get();
|
|
35
|
+
if (!cur.some((x) => x.id === id)) return;
|
|
36
|
+
put(feature, cur.map((x) => (x.id === id ? { ...x, ...patch, ...(patch.text !== undefined ? { text: clip(patch.text) } : {}), id } : x)));
|
|
37
|
+
},
|
|
38
|
+
remove(id) { if (feature && get().some((x) => x.id === id)) put(feature, get().filter((x) => x.id !== id)); },
|
|
39
|
+
clear() { if (feature && get().length) put(feature, []); },
|
|
40
|
+
list: () => [...get()],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Stable palette slot (0–15) for an indicator, so its color doesn't change between renders. */
|
|
45
|
+
export function slotOf(feature: string, id: string): number {
|
|
46
|
+
let h = 0;
|
|
47
|
+
for (const ch of `${feature}|${id}`) h = (h * 31 + ch.charCodeAt(0)) >>> 0;
|
|
48
|
+
return h % PALETTE_SIZE;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** CSS colors: the indicator's own, else the theme's `--taco-ind-N-bg` / `-fg` pair. */
|
|
52
|
+
export const styleOf = (feature: string, i: Indicator) => {
|
|
53
|
+
const n = slotOf(feature, i.id) + 1;
|
|
54
|
+
return { background: i.background ?? `var(--taco-ind-${n}-bg)`, color: i.color ?? `var(--taco-ind-${n}-fg)` };
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export interface Bubble { feature: string; indicator: Indicator }
|
|
58
|
+
/** Bubbles of the given features (a row's own, or a collapsed parent's children) in order: the first `max`, and how many more there are. */
|
|
59
|
+
export function bubblesOf(map: Record<string, Indicator[]>, features: string[], max = MAX_BUBBLES, pick: (i: Indicator) => boolean = () => true): { shown: Bubble[]; more: number } {
|
|
60
|
+
const every = features.flatMap((feature) => (map[feature] ?? []).filter(pick).map((indicator) => ({ feature, indicator })));
|
|
61
|
+
return { shown: every.slice(0, max), more: Math.max(0, every.length - max) };
|
|
62
|
+
}
|
package/src/core/jobs.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Feature background jobs (manifest `background: { entry, everySeconds }`): run inside the app, like dataset refreshes, one at a time and only
|
|
2
|
+
// while the vault is unlocked. They typically update `framework.indicators`. Anything they log goes to the Activity Log.
|
|
3
|
+
|
|
4
|
+
import type { BackgroundJob, Framework } from '@tacoshell/sdk';
|
|
5
|
+
import * as log from './log.ts';
|
|
6
|
+
import * as services from './services.ts';
|
|
7
|
+
import * as vault from './vault.ts';
|
|
8
|
+
import { viewKey, type Registry } from '../types.ts';
|
|
9
|
+
|
|
10
|
+
export function startJobs(reg: Registry, jobs: Record<string, BackgroundJob>, framework: (module: string, featureView: string) => Framework, tickMs = 5_000): () => void {
|
|
11
|
+
const due = new Map<string, number>();
|
|
12
|
+
let running = false;
|
|
13
|
+
const tick = async () => {
|
|
14
|
+
if (running || vault.status() !== 'unlocked') return;
|
|
15
|
+
running = true;
|
|
16
|
+
try {
|
|
17
|
+
for (const v of reg.views) {
|
|
18
|
+
const job = jobs[viewKey(v)];
|
|
19
|
+
if (!job || !v.background) continue;
|
|
20
|
+
const key = viewKey(v);
|
|
21
|
+
if ((due.get(key) ?? 0) > Date.now()) continue;
|
|
22
|
+
due.set(key, Date.now() + Math.max(10, v.background.everySeconds) * 1000);
|
|
23
|
+
try { await job.run({ framework: framework(v.module, v.name), log: log.logger(`Background › ${v.label}`) }); }
|
|
24
|
+
catch (e) { log.add('error', `Background job for ${v.label} failed: ${(e as Error).message}`, undefined, `Background › ${v.label}`); }
|
|
25
|
+
if (vault.status() !== 'unlocked') break;
|
|
26
|
+
}
|
|
27
|
+
} finally { running = false; }
|
|
28
|
+
};
|
|
29
|
+
const timer = setInterval(() => void tick(), tickMs);
|
|
30
|
+
const off = vault.subscribe((s) => { if (s === 'unlocked') void tick(); });
|
|
31
|
+
// What a job shows (counts, indicators) depends on its services' settings: when one is saved, turned on / off or tested, every job runs again soon
|
|
32
|
+
// (debounced, so Save followed by Test is one re-run).
|
|
33
|
+
let rerun: ReturnType<typeof setTimeout> | undefined;
|
|
34
|
+
const offServices = services.states.subscribe(() => { clearTimeout(rerun); rerun = setTimeout(() => { due.clear(); void tick(); }, 500); });
|
|
35
|
+
void tick();
|
|
36
|
+
return () => { clearInterval(timer); clearTimeout(rerun); off(); offServices(); };
|
|
37
|
+
}
|
package/src/core/nav.ts
CHANGED
|
@@ -15,6 +15,9 @@ export function groupLabelOf(reg: Registry, v: RegistryView): string | undefined
|
|
|
15
15
|
return v.nav.group ?? (v.nav.bucket === 'services' ? (serviceType ? reg.services.find((s) => s.type === serviceType)?.label ?? serviceType : 'Services') : 'Tools');
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/** "Display in NavBars": a heuristic of every feature, true unless the view says otherwise (ACTION views default to false). */
|
|
19
|
+
export const inNav = (v: RegistryView) => v.showInNavBars ?? v.viewType !== 'ACTION';
|
|
20
|
+
|
|
18
21
|
export interface BarItem { view: RegistryView; label: string }
|
|
19
22
|
|
|
20
23
|
/**
|
|
@@ -24,13 +27,13 @@ export interface BarItem { view: RegistryView; label: string }
|
|
|
24
27
|
export function barItems(reg: Registry, current: RegistryView): BarItem[] {
|
|
25
28
|
const group = groupLabelOf(reg, current);
|
|
26
29
|
const section = current.nav.section ?? 'home';
|
|
27
|
-
const peers = group === undefined ? [current] : reg.views.filter((v) => (v.nav.section ?? 'home') === section && v.nav.bucket === current.nav.bucket && groupLabelOf(reg, v) === group);
|
|
30
|
+
const peers = group === undefined ? [current] : reg.views.filter((v) => inNav(v) && (v.nav.section ?? 'home') === section && v.nav.bucket === current.nav.bucket && groupLabelOf(reg, v) === group);
|
|
28
31
|
const features = new Map<string, RegistryView[]>();
|
|
29
32
|
for (const v of peers) features.set(`${v.module}::${v.nav.feature ?? v.name}`, [...(features.get(`${v.module}::${v.nav.feature ?? v.name}`) ?? []), v]);
|
|
30
33
|
if (group === undefined) {
|
|
31
34
|
// Featured: the feature's own views, wherever they are.
|
|
32
35
|
const key = `${current.module}::${current.nav.feature ?? current.name}`;
|
|
33
|
-
const own = reg.views.filter((v) => `${v.module}::${v.nav.feature ?? v.name}` === key && v.nav.bucket === 'featured');
|
|
36
|
+
const own = reg.views.filter((v) => inNav(v) && `${v.module}::${v.nav.feature ?? v.name}` === key && v.nav.bucket === 'featured');
|
|
34
37
|
features.clear(); features.set(key, own);
|
|
35
38
|
}
|
|
36
39
|
return [...features.values()].flatMap((views) => (views.length === 1 ? [{ view: views[0], label: views[0].nav.feature ?? views[0].label }] : views.map((view) => ({ view, label: view.label }))));
|
|
@@ -51,7 +54,7 @@ export function buildNav(reg: Registry, isUsable: (type: string, name: string) =
|
|
|
51
54
|
const byView = new Map<string, NavFeature>();
|
|
52
55
|
|
|
53
56
|
const section = (id: 'home' | 'reports'): NavSection => {
|
|
54
|
-
const views = reg.views.filter((v) => (v.nav.section ?? 'home') === id);
|
|
57
|
+
const views = reg.views.filter((v) => inNav(v) && (v.nav.section ?? 'home') === id);
|
|
55
58
|
const features = new Map<string, NavFeature & { bucket: string; group: string; serviceType?: string }>();
|
|
56
59
|
for (const v of views) {
|
|
57
60
|
const fkey = `${v.module}::${v.nav.feature ?? v.name}`;
|
package/src/core/page.ts
CHANGED
|
@@ -12,17 +12,26 @@ export interface Page {
|
|
|
12
12
|
/** How many components on the page listen for refresh (usePageRefresh). */
|
|
13
13
|
refreshListeners(): number;
|
|
14
14
|
tools: Store<Tool[]> & { add(tool: Tool): () => void };
|
|
15
|
+
/** What the feature says it is showing (`framework.expose`): the context Related and Actions contributors receive. */
|
|
16
|
+
exposed: Store<Context> & { set(ctx: Context): void };
|
|
17
|
+
/** Set when the page is an ACTION modal: closes it. */
|
|
18
|
+
close?: () => void;
|
|
15
19
|
/** A view's own setContextHandler, called with every live hand-off. */
|
|
16
20
|
handler?: (ctx: Context) => void;
|
|
17
21
|
}
|
|
18
22
|
|
|
23
|
+
/** One shared empty context, so an unset `exposed` is a stable snapshot. */
|
|
24
|
+
export const NO_CONTEXT: Context = Object.freeze({});
|
|
25
|
+
|
|
19
26
|
export function createPage(key: string, initial?: Context): Page {
|
|
20
27
|
const viewContext = createStore<Context | undefined>(initial);
|
|
21
28
|
const state = createStore<Context>({ ...(initial ?? {}) });
|
|
22
29
|
const refreshers = new Set<(reason?: string) => void>();
|
|
23
30
|
const tools = createStore<Tool[]>([]);
|
|
31
|
+
const exposed = createStore<Context>(NO_CONTEXT);
|
|
24
32
|
return {
|
|
25
33
|
key,
|
|
34
|
+
exposed,
|
|
26
35
|
viewContext,
|
|
27
36
|
refreshListeners: () => refreshers.size,
|
|
28
37
|
page: {
|
|
@@ -76,6 +85,7 @@ export function checkContext(decl: Record<string, string> | undefined, ctx: Cont
|
|
|
76
85
|
const ok = base.endsWith('[]') ? Array.isArray(v) : base === 'object' ? typeof v === 'object' && !Array.isArray(v) : base === 'unknown' || typeof v === base;
|
|
77
86
|
if (!ok) problems.push(`"${k}" should be ${base}`);
|
|
78
87
|
}
|
|
79
|
-
|
|
88
|
+
// `referrer` is reserved: the framework adds it when a Related link or an Action opens the view.
|
|
89
|
+
for (const k of Object.keys(ctx)) if (k !== 'referrer' && !(k in decl)) problems.push(`"${k}" isn't declared`);
|
|
80
90
|
return problems.length ? problems.join('; ') : null;
|
|
81
91
|
}
|
package/src/core/prefs.ts
CHANGED
|
@@ -17,6 +17,11 @@ const ls = () => (typeof localStorage !== 'undefined' ? localStorage : undefined
|
|
|
17
17
|
export function pref<T>(key: string, fallback: T): T {
|
|
18
18
|
try { const raw = ls()?.getItem(`taco.${key}`); return raw == null ? fallback : (JSON.parse(raw) as T); } catch { return fallback; }
|
|
19
19
|
}
|
|
20
|
+
/** A preference that must be a list of strings: anything else a browser still has stored under that name (an older version saved a boolean) reads as empty. */
|
|
21
|
+
export function prefList(key: string): string[] {
|
|
22
|
+
const v = pref<unknown>(key, []);
|
|
23
|
+
return Array.isArray(v) ? v.filter((x): x is string => typeof x === 'string') : [];
|
|
24
|
+
}
|
|
20
25
|
export function setPref(key: string, value: unknown) {
|
|
21
26
|
try { ls()?.setItem(`taco.${key}`, JSON.stringify(value)); } catch { /* private window or storage blocked: the pref just isn't remembered */ }
|
|
22
27
|
}
|