@graview/pages 0.1.72 → 0.1.74

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/README.md CHANGED
@@ -84,6 +84,20 @@ this package serves lists, records, forms, problems and history as ordinary link
84
84
  link — a schedule as a PDF — on each change. `staticCss` is its sheet alone. See
85
85
  `docs/static-pages.md`.
86
86
 
87
+ - **A place on a fixed screen, and what each part of it does.** `@graview/pages/device`'s
88
+ `renderScreen(store, declaration, place, { profile: "eink", viewport, viewer, page })`
89
+ draws a place for an e-ink reader at the viewport its host names — its colors the sixteen grays (the host quantizes the picture to its panel), no
90
+ motion, no hover, no script, nothing fetched, type for arm's length, every press at
91
+ least 64 px — at a fixed layout the framework works out itself, a long place on pages.
92
+ It answers `{ html, css, title, found, renderId, page, taps }`: `taps` is each pressable
93
+ region's rectangle in the viewport's pixels and what it does (`go`, `open`, `act`,
94
+ `page`, `refresh`), exactly where the browser draws it. `tapAt` finds the region under a
95
+ point; `resolveTap` says what it does now — a place to hand back to `renderScreen`, never a
96
+ URL to follow — answers only a press the screen still offers, and runs an act only on the
97
+ screen the app still draws for that seat. The strip along its foot is the declaration's
98
+ `devices.screens`, else the home and its jobs, else its bar. It imports no React, so a
99
+ Worker draws it; the host's browser takes the picture. See `docs/static-pages.md`.
100
+
87
101
  - **An opening screen, from the document.** `@graview/pages/splash`'s `splashHtml(brand,
88
102
  { scheme?, name?, title?, kicker?, fade? })` draws a document's `brand.splash` — `plain`, `editorial`, `shader`
89
103
  (one of a few shaders shipped here, named by `shader`, never written in a document) or
@@ -0,0 +1,146 @@
1
+ import { type AnySchema, type AppPlace, type GraviewApp, type Principal, type Store } from "@graview/core";
2
+ /** The profiles a screen is drawn in. One now: a grayscale, motionless, touch-only reader. */
3
+ export type DeviceProfile = "eink";
4
+ /** The screen's size in CSS pixels: 758 × 1024 is a Kindle Paperwhite 3 held upright. */
5
+ export interface DeviceViewport {
6
+ readonly width: number;
7
+ readonly height: number;
8
+ }
9
+ export interface RenderScreenOptions {
10
+ readonly profile: DeviceProfile;
11
+ readonly viewport: DeviceViewport;
12
+ /** Who is looking: the screen holds only what this seat may see, and offers only what it may do. An anonymous person when unsaid. */
13
+ readonly viewer?: Principal;
14
+ /** Which page of a place too long for one screen, from 0. Past the last is the last. */
15
+ readonly page?: number;
16
+ /** The reader's locale; unsaid, the brand's, else en-US. */
17
+ readonly locale?: string;
18
+ /** The reader's time zone; unsaid, the brand's, else the runtime's. */
19
+ readonly timeZone?: string;
20
+ /** The day it is, for dates said relatively; the store's day when unsaid. */
21
+ readonly today?: string;
22
+ /** Put before every address a link on the screen names, as `renderPlace` does. */
23
+ readonly base?: string;
24
+ }
25
+ /** What pressing a region does: exactly one of these. */
26
+ export type TapDoes =
27
+ /** Show a place: its address (`/`, `/tasks`, `/places/the-week`), or one of the app's jobs as `job:<name>`. */
28
+ {
29
+ readonly go: string;
30
+ }
31
+ /** Show a record's page: its id. */
32
+ | {
33
+ readonly open: string;
34
+ }
35
+ /** Run an act this seat may run, with every argument bound. */
36
+ | {
37
+ readonly act: string;
38
+ readonly args: Readonly<Record<string, unknown>>;
39
+ }
40
+ /** Turn to another page of this place, from 0. */
41
+ | {
42
+ readonly page: number;
43
+ }
44
+ /** Draw this screen again as the app now stands. */
45
+ | {
46
+ readonly refresh: true;
47
+ };
48
+ /** One pressable region, in the viewport's CSS pixels, with the words drawn on it. */
49
+ export interface TapRegion {
50
+ readonly x: number;
51
+ readonly y: number;
52
+ readonly width: number;
53
+ readonly height: number;
54
+ readonly label: string;
55
+ readonly does: TapDoes;
56
+ }
57
+ export interface RenderedScreen {
58
+ /** The whole document: its stylesheet inlined, no script, nothing to fetch. */
59
+ readonly html: string;
60
+ /** The stylesheet alone, the same one the document carries. */
61
+ readonly css: string;
62
+ /** As its `<title>` says it: the place's, then the app's name. */
63
+ readonly title: string;
64
+ /** Whether the place was there for this seat; a screen that says nothing lives here when not. */
65
+ readonly found: boolean;
66
+ /**
67
+ * WHICH PICTURE THIS IS: made of what the screen shows — its markup and
68
+ * its regions — and the place, page, viewport and reading it was drawn
69
+ * for, so the same store, declaration, place, seat, profile, viewport and
70
+ * page give the same id, and a change the screen does not show keeps it.
71
+ * A tap is resolved against it (`resolveTap`); it says nothing the screen
72
+ * does not.
73
+ */
74
+ readonly renderId: string;
75
+ readonly page: {
76
+ readonly index: number;
77
+ readonly count: number;
78
+ };
79
+ /** Every region of the screen that can be pressed, at least 64 px on each side. */
80
+ readonly taps: readonly TapRegion[];
81
+ }
82
+ /**
83
+ * The profile's sixteen grays, black to white: every color the screen's sheet names is one of them. The
84
+ * framework does not rasterize: a browser's antialiased type draws grays between them, and the host
85
+ * quantizes the picture to its panel.
86
+ */
87
+ export declare const EINK_GRAYS: readonly string[];
88
+ /** The least a press measures on each side, in CSS pixels: a finger, not a pointer. */
89
+ export declare const EINK_LEAST_TARGET = 64;
90
+ /** The profile's stylesheet: one sheet for every screen, its sizes the rows' own and every color a gray of the ramp. */
91
+ export declare function einkCss(): string;
92
+ /**
93
+ * RENDER ONE PLACE FOR A FIXED SCREEN, with what each region of it does.
94
+ *
95
+ * `place` is what `renderPlace` takes — a slug, a title, an address, a
96
+ * record's id or address — or one of the app's jobs as `job:<name>`. The
97
+ * screen is the place's title, its rows, the page turn when it needs more
98
+ * than one, and the strip of the app's device screens with Refresh, the
99
+ * one it is on marked.
100
+ */
101
+ export declare function renderScreen<S extends AnySchema>(store: Store<S>, declaration: GraviewApp<S>, place: string | AppPlace, options: RenderScreenOptions): RenderedScreen;
102
+ /** The region under a point of the viewport, if a region is there. Regions never overlap, so there is one at most. */
103
+ export declare function tapAt(taps: readonly TapRegion[], x: number, y: number): TapRegion | undefined;
104
+ /**
105
+ * What a tap does now: a screen to draw, an act done, or a refusal in words —
106
+ * each with the screen to draw next. `place` is a place to hand back to
107
+ * `renderScreen` (an address such as `/tasks`, a record's address, or
108
+ * `job:<name>`), never a URL to follow: it is not checked as one.
109
+ */
110
+ export type TapOutcome = {
111
+ readonly ok: true;
112
+ readonly does: "go" | "open" | "page" | "refresh";
113
+ readonly place: string;
114
+ readonly page: number;
115
+ } | {
116
+ readonly ok: true;
117
+ readonly does: "act";
118
+ readonly said: string;
119
+ readonly place: string;
120
+ readonly page: number;
121
+ } | {
122
+ readonly ok: false;
123
+ readonly refused: string;
124
+ readonly place: string;
125
+ readonly page: number;
126
+ };
127
+ export interface ResolveTapOptions {
128
+ /** Who tapped: the seat the screen was drawn for. */
129
+ readonly viewer?: Principal;
130
+ /** The `renderId` of the screen the tap was on. */
131
+ readonly renderId: string;
132
+ }
133
+ /**
134
+ * WHAT A TAP DOES NOW. A press that goes somewhere answers the place to draw
135
+ * next — a place to hand back to `renderScreen`, never a URL to follow —
136
+ * and only when the screen, drawn again as the seat now stands, still has
137
+ * that press: a `go` or an `open` no screen of this place offers is refused,
138
+ * as a forged act is. Turning a page and Refresh answer this place. An act
139
+ * is run only when the screen it was pressed on is the screen the app draws
140
+ * now for this seat — the same `renderId` — and the act is on it, with the
141
+ * same arguments; when what the screen shows has changed since, the act is
142
+ * judged again as the seat now stands and refused in words, never run on a
143
+ * state the picture did not show.
144
+ */
145
+ export declare function resolveTap<S extends AnySchema>(store: Store<S>, declaration: GraviewApp<S>, region: Pick<TapRegion, "label" | "does">, options: ResolveTapOptions): TapOutcome;
146
+ //# sourceMappingURL=device.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../src/device.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAyF,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAQlM,8FAA8F;AAC9F,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC,yFAAyF;AACzF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM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