Gleaming0427/videotex-ui
关于
React UI kit inspired by the Minitel and French Videotex: 40 × 25 grid, mosaic graphics, 8 colors, function keys
网站与应用开发可以做什么
- 14 components: Screen, FunctionKeys, Title, BigText, StatusRow, KeyHint, Menu, InputField, TextArea, Table, ProgressBar, Frame, Divider and Mosaic. Placed on a screen, they are drawn with its cells; anywhere else in a page, they keep the Videotex font and colors.
- A screen drawn like a Minitel 1B: progressive display at 1,200 baud, mosaic characters, double sizes, blinking, zone attributes, 8 colors or 8 greys, an optional CRT effect. The values come from the Minitel 1B specifications: docs/SPECS.md gives the source of each one, or says when it is our choice.
- Accessible: components stay real headings, lists, buttons, inputs and tables; screen readers read the text of the page; the interactive components work with a keyboard; prefers-reduced-motion turns off blinking, flicker and progressive display.
- Videotex UI, the project's own pixel font, served with your site.
实测星标增长
- 24小时
- 0
- 7天
- 正在收集历史
- 15天
- 正在收集历史
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文videotex-ui
A React UI kit inspired by the French Minitel and Videotex: a 40 × 25 screen drawn at 1,200 baud, mosaic graphics, 8 colors, function keys.

Try the demo: a fictional Videotex service, a converter that turns your own picture into mosaic characters, the switch between web and Videotex modes, and every component on its own. Any address that does not exist, such as /nowhere, shows its 404 page.
Edit an example on StackBlitz: a small service with a menu, tables and function keys (examples/vite), in your browser, with nothing to install.
Features
- 14 components:
Screen,FunctionKeys,Title,BigText,StatusRow,KeyHint,Menu,InputField,TextArea,Table,ProgressBar,Frame,DividerandMosaic. Placed on a screen, they are drawn with its cells; anywhere else in a page, they keep the Videotex font and colors. - A screen drawn like a Minitel 1B: progressive display at 1,200 baud, mosaic characters, double sizes, blinking, zone attributes, 8 colors or 8 greys, an optional CRT effect. The values come from the Minitel 1B specifications: docs/SPECS.md gives the source of each one, or says when it is our choice.
- Accessible: components stay real headings, lists, buttons, inputs and tables; screen readers read the text of the page; the interactive components work with a keyboard;
prefers-reduced-motionturns off blinking, flicker and progressive display. - Videotex UI, the project's own pixel font, served with your site.
- Two renderers, DOM or canvas, which draw the characters of the font dot for dot the same, and PNG export.
- Videotex streams: read and write
.vdtfiles. The demo pages read back the same in the MiEdit emulator (details). - Live services:
useVideotexSocketconnects a screen to a Videotex service over a WebSocket; keys and text go back as a Minitel keyboard sends them. - Minitel services written in React:
videotex-ui/serverdraws the same components on a server for a Minitel or an emulator, echoes what is typed in the input zones and handles the keys of a form, as the Minitel 1B specifications recommend. - Without React:
<videotex-screen>, a custom element for Vue, Svelte, Angular or plain HTML. - Pictures to mosaics: any image converted to 2 × 3 mosaic characters in 8 colors, and the camera, live.
- No dependency besides React 18 or later, and none at all for the custom element. ES modules with TypeScript types, and a shadcn registry to copy the source instead.
Contents
Install · Usage · PageBuilder · Screen · Components · Mosaic · FunctionKeys · 404 page example · Videotex streams · Live services · Services in React · Without React · Development · License
Install
With npm
React 18 or later.
npm install videotex-ui
import { Screen, PageBuilder } from 'videotex-ui';
import 'videotex-ui/styles.css';
The package is made of ES modules only: use import, not require(). Its types work with every TypeScript moduleResolution (bundler, node16, nodenext).
With the shadcn CLI
The CLI copies the source of a component into your project, in components/videotex/, with the core and the stylesheet:
npx shadcn@latest add https://cdn.jsdelivr.net/npm/videotex-ui/r/screen.json
Then import the stylesheet once, for example in your root layout, and the components from that folder:
import '@/components/videotex/videotex.css';
import { Screen } from '@/components/videotex/react/Screen';
import { PageBuilder } from '@/components/videotex/core';
Items: screen, function-keys, title, status-row, frame, input-field, menu, mosaic, key-hint, progress-bar, big-text, table, divider, text-area, and videotex-ui for all of them. Every item brings the core and the stylesheet; the CLI skips the files you already have. To pin a version, write it in the address: [email protected]/r/screen.json.
React Server Components
The components are client components ('use client'). The core (PageBuilder, palettes, mosaics…) has no React code, so a server component can build a page and pass it to Screen.
Usage
import { Screen, PageBuilder } from 'videotex-ui';
import 'videotex-ui/styles.css';
const page = new PageBuilder()
.moveTo(3, 2).print('HELLO', { fg: 'yellow', size: 'double-size' })
.moveTo(5, 2).print('Type your choice then ')
.print(' Send ', { inverse: true })
.build();
export function Home() {
return <Screen page={page} crt baud={1200} aria-label="Home" />;
}
The stylesheet embeds Videotex UI, the project's own pixel font: 5 × 7 glyphs drawn for the 8 × 10 cell, so every dot lands on whole pixels. It covers ASCII, the French accented lowercase letters, œ and Œ, the line drawing of the Minitel (─ ‾ ▏ │ ▕), the arrows (← ↑ → ↓) and a few signs (« » ° £ § ß € × ÷ ± · ’); other characters fall back to the system's monospace font. It is served with your site, with no request to another server, and it is under the SIL Open Font License 1.1 (OFL.txt). To use another font, change --vtx-font, then adjust --vtx-font-scale and --vtx-font-stretch (1.35 and 1.4 for VT323). glyphBitmap(char) gives the dots of a glyph, for your own renderers.
PageBuilder
Writes a page the way a Videotex server does: place the cursor, pick attributes, write.
| Method | What it does |
|---|---|
moveTo(row, col) |
Places the cursor (rows 0 to 24, columns 0 to 39) and sets the margin used by \n |
attr({ fg, bg, … }) |
Changes the attributes of the following writes; reset() goes back to the constructor's |
print(text, attrs?) |
Writes text; wraps at column 40 |
mosaic(masks, attrs?) |
Writes mosaic characters (6-bit masks, see maskFromRows) |
mosaicBlock(rows, attrs?) |
Writes several rows of mosaics, for example from bitmapToMasks, or big text from bigTextMasks(text) |
fill(top, left, height, width, attrs?) |
Paints a rectangle |
build() |
Returns the page (frozen) |
Attributes: fg and bg (0 to 7 or 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'), blink, inverse, underline (disjoint mosaic for mosaic characters), size ('normal', 'double-height', 'double-width', 'double-size').
Screen
| Prop | Default | What it does |
|---|---|---|
page |
Page to show | |
palette |
'color' |
'color' or 'monochrome' (8 grey levels) |
crt |
false |
Scanlines, vignette, glow, dark border |
baud |
false |
Progressive display at this speed (1200 on a Minitel) |
revealKey |
When set, only a new key starts a progressive display; other page changes (a typed character, a message) show at once | |
scale |
'auto' |
Size of one screen dot in CSS pixels; 'auto' picks the largest whole number that fits, so pixels stay sharp |
blink |
true |
Enables blinking |
renderer |
'dom' |
'dom' draws the cells as HTML elements; 'canvas' draws the exact 320 × 250 dots in a canvas, scaled up without blur |
onRevealEnd |
Called when the progressive display ends | |
cursor |
A terminal's cursor, { row, col }: the cell alternates with its complementary colors, as on a Minitel |
|
children |
Components placed on the grid (see below) |
Screen readers read the text of the page; the grid itself is hidden from them. prefers-reduced-motion turns off blinking, flicker and progressive display.
Both renderers draw the same picture, dot for dot, and support progressive display and blinking. Differences: with 'canvas', characters missing from the Videotex UI font are blank, except accented letters, which lose their accent (the DOM falls back to a system font), and the CRT effect adds no glow around characters. To get the picture yourself:
| Function | Where | What it does |
|---|---|---|
renderPage(page, { palette, scale, blinkOn, visible }) |
anywhere | The page as RGBA pixels, scale pixels per dot |
pageToPng(page, { palette, scale }) |
browser | A PNG Blob of the page (2 pixels per dot by default) |
drawPage(canvas, page, options) |
browser | Draws the page in your own canvas, one pixel per dot |
Components on the screen, or on their own

Title, BigText, StatusRow, KeyHint, Menu, InputField, TextArea, Table, ProgressBar, Frame, Divider and Mosaic work in two ways:
- On a screen (faithful mode): as children of
Screen, placed withrowandcol. They are drawn with the same cells as the page, over it, and stay real headings, lists, buttons and inputs for keyboards and screen readers. During a progressive display, their characters are sent with the page, in reading order, and show in turn; they can be used once it has ended. - On their own (modern mode): anywhere in a page, with the Videotex font and colors, following the page layout.
<Screen page={background} baud={1200} revealKey={pageName}>
<StatusRow left="MY SERVICE" message={message} right="1/4" />
<Title row={3} col={2} bg="blue">WELCOME</Title>
<Menu row={18} col={2} items={['News', 'Weather']} onSelect={open} />
<InputField row={23} col={15} size={1} type="digits" label="Your choice" value={choice} onChange={setChoice} autoFocus />
<KeyHint name="guide" row={24} col={2} onPress={help}>help</KeyHint>
</Screen>
<FunctionKeys shortcuts onSend={send} />
| Component | Main props | Notes |
|---|---|---|
Title |
children, level (2), size ('double-size'), fg ('yellow'), bg, blink, row, col |
A heading. Double heights grow upwards from row |
StatusRow |
left, message, right, fg ('cyan'), messageFg ('yellow') |
Row 0 on a screen, columns 1 to 36: a Minitel shows its own state in columns 37 to 40. The message is announced to screen readers |
Menu |
items, onSelect(index), start (1), fg, numberFg, row, col, spacing (1) |
Arrow keys move, a digit jumps to its item, Enter or a click chooses. The focused item shows in inverse |
InputField |
label, size, value / defaultValue, onChange, onSubmit, type ('text' or 'digits'), autoFocus, row, col |
On a screen: dots and a blinking cursor over a transparent native input. Enter, Escape, Page Up and Page Down still reach FunctionKeys while typing, unless onSubmit handles Enter |
Frame |
title, fg ('cyan'), fill, row, col, height, width, children |
A mosaic border. On a screen, children keep screen coordinates |
BigText |
children, level, fg ('yellow'), bg, blink, disjoint, row, col, scale (2) |
Mosaic letters drawn from the font, one sixel per dot: 3 × 4 cells per character, 13 per line. A heading with level, else a paragraph. \n starts a new line |
KeyHint |
name, children, labels ('en'), onPress, keyFg, fg ('cyan'), row, col |
The key name in inverse (green for Send), then what it does. A button with onPress, else text |
TextArea |
label, width, rows, value / defaultValue, onChange, onSubmit, autoFocus, row, col |
A multi-line zone of width × rows characters that wraps character by character. Line breaks are refused: Enter goes to FunctionKeys or onSubmit. On a screen the arrow keys move by one line of the zone |
Table |
columns (header, width, align, fg), rows, caption, fg, headerFg ('cyan'), leader, leaderFg ('blue'), spacing (1), gap (1), row, col |
Texts longer than their column are cut on the screen; screen readers get a real table with the full texts. leader="." draws dot leaders |
ProgressBar |
label, value, max (100), width (20), fg ('green'), bg ('blue'), showValue, row, col |
A progressbar for assistive technologies. Moves by half a cell: a mosaic cell has two columns of sixels |
Divider |
fg ('blue'), bg, thickness ('thin' or 'thick'), disjoint, row (22), col, width (40) |
A line of mosaics; disjoint breaks it into dashes |
<Screen page={background}>
<BigText level={1} row={1} col={2} bg="blue">NEWS</BigText>
<Table
row={6} col={2} leader="."
caption="Trains"
columns={[{ header: 'Train', width: 20 }, { header: 'Time', width: 5, align: 'right', fg: 'yellow' }]}
rows={[['Lyon', '08:15'], ['Lille', '09:02']]}
/>
<TextArea row={12} col={2} width={36} rows={3} label="Your message" value={text} onChange={setText} />
<ProgressBar row={16} col={2} width={30} label="Sending" value={sent} showValue />
<Divider row={22} />
<KeyHint name="next" row={23} col={2} onPress={next}>next page</KeyHint>
</Screen>
Mosaic and the image converter
Mosaic turns a picture into mosaic characters: every cell keeps the two colors, out of 8, closest to that part of the picture.
// Converted in the browser (same site, data or blob URL, or a site that allows CORS)
<Mosaic src="/cat.jpg" cols={32} dither alt="A cat" />
// On a screen: fitted and centered in a 40 × 16 box from row 5
<Screen page={page}>
<Mosaic src="/cat.jpg" row={5} col={0} cols={40} rows={16} alt="A cat" />
</Screen>
// Already converted: no canvas, works on the server
const cat = decodeMosaic('32x13:…');
<Mosaic data={cat} alt="A cat" />
| Prop | Default | What it does |
|---|---|---|
alt |
Text alternative (required) | |
src / data |
A picture to convert, or one already converted (data wins) |
|
cols, rows |
40 columns | One keeps the proportions; both fit the picture in that box |
palette |
the screen's, else 'color' |
'monochrome' matches the 8 greys |
dither |
false |
Ordered dithering (4 × 4 Bayer pattern) for smoother gradients |
row, col |
Position on a screen | |
scale |
2 |
Off screen: CSS pixels per screen dot |
onConvert(image), onError(error) |
After converting src |
Functions, for your own tools:
| Function | Where | What it does |
|---|---|---|
imageToMosaic(pixels, { cols, rows, palette, dither }) |
anywhere | RGBA pixels to a MosaicImage |
mosaicSize(width, height, { cols, rows }) |
anywhere | Cells needed without stretching the picture |
renderMosaic(image, { palette, scale }) |
anywhere | A MosaicImage back to RGBA pixels |
encodeMosaic(image), decodeMosaic(text) |
anywhere | Compact text form, two characters per cell |
mosaicToCode(image, { name, alt }) |
anywhere | A ready-to-paste React component |
PageBuilder.mosaicImage(image) |
anywhere | Writes the picture into a page from the cursor |
convertImage(src, options) |
browser | Loads and converts a picture |
mosaicToPng(image, { palette, scale }) |
browser | A PNG Blob |
useCameraMosaic(options) does the same with the camera of the device, as it films: the middle of the video is cut to the shape of the cells, mirrored like a front camera, and converted about 10 times a second. The video stays in the browser.
const camera = useCameraMosaic({ dither: true });
const page = useMemo(() => {
const b = new PageBuilder();
if (camera.image) b.moveTo(1, 0).mosaicImage(camera.image);
return b.build();
}, [camera.image]);
<button onClick={() => camera.start()}>Start the camera</button>
<Screen page={page} renderer="canvas" />
It takes cols and rows (40 × 24, the screen under its service row), palette, dither, fps (10), mirror (true) and facingMode ('user'), and returns image (null before the first picture), status ('off', 'starting', 'on', 'denied', 'unavailable' or 'error'), start() and stop(). The browser asks the visitor first, and only on https pages or localhost. The demo has a camera section.
To build your own component for the screen, use useScreen() (null when off screen), gridArea() and CellGrid (give it origin so its cells show in turn during a progressive display), with the cell helpers of the core (titleRegion, fieldRegion, cropPage…).
FunctionKeys
The 8 Minitel function keys, as real buttons.
<FunctionKeys
shortcuts
onSend={() => submit()}
onNext={() => setPage((p) => p + 1)}
onBack={() => setPage((p) => p - 1)}
onIndex={() => setPage(0)}
/>
| Prop | Default | What it does |
|---|---|---|
onKey(name) |
Called for every key, before the key's own handler | |
onIndex, onGuide, onCancel, onCorrection, onBack, onNext, onRepeat, onSend |
One handler per key | |
layout |
'faithful' |
'faithful': two rows of four, like the Minitel 1B; 'compact': one wrapping row |
labels |
'en' |
'en', 'fr' (the labels printed on the Minitel: Sommaire, Envoi…) or your own labels |
shortcuts |
false |
true for the default shortcuts, or an object to change some of them (null removes one) |
Default shortcuts:
| Key | Shortcut | Key | Shortcut | |
|---|---|---|---|---|
| Index | Home | Guide | ? | |
| Cancel | Escape | Correction | Backspace | |
| Back | Page Up | Next | Page Down | |
| Repeat | End | Send | Enter |
Shortcuts are off by default because they listen on the whole window and take over keys such as Enter or Page Down. When on, they ignore text fields, key repeats and combinations with Ctrl, Alt or Meta, and leave Enter and Space to a focused button or link.
Example: a 404 page
The demo's 404 page is a background drawn with PageBuilder, a Title for the heading and FunctionKeys to leave. Its big "404" is a bitmap at sixel resolution, cut into mosaic characters by bitmapToMasks. Source: demo/NotFound.tsx.
const page = new PageBuilder()
.fill(1, 0, 3, 40, { bg: 'blue' })
.moveTo(14, 2).print('This page is not on the service.')
.moveTo(23, 2).print(' Index ', { inverse: true }).print(' main menu', { fg: 'cyan' })
.build();
export function NotFound() {
return (
<>
<Screen page={page} crt baud={1200} aria-label="Page not found">
<Title level={1} row={3} col={2} bg="blue">PAGE NOT FOUND</Title>
</Screen>
<FunctionKeys shortcuts onIndex={() => location.assign('/')} onBack={() => history.back()} />
</>
);
}
Videotex streams (.vdt)
A .vdt file holds the bytes a Minitel receives: cursor moves, attributes, characters.
import { decodeVideotex, encodeVideotex, videotexMismatches } from 'videotex-ui';
// Show a .vdt file
const page = decodeVideotex(new Uint8Array(await file.arrayBuffer()));
<Screen page={page} />;
// Save a page as a .vdt file
const blob = new Blob([encodeVideotex(page)], { type: 'application/octet-stream' });
| Function | What it does |
|---|---|
decodeVideotex(stream) |
Draws a stream like a Minitel 1B in Videotex mode: positioning (US, CSI), attributes, repetition (REP), the G0, G1 and G2 sets, row 0, erasing, masking. A string is read as one byte per character |
encodeVideotex(page) |
Writes a page as a stream: FF, then each row with its attributes, REP for repeats |
videotexMismatches(page) |
The cells a Minitel cannot show exactly |
new VideotexDecoder(), .write(bytes), .page |
Draws a stream that arrives in parts: a sequence cut between two parts waits for the rest. Also .cursor, .bells, and .takeReplies(): the answers the service asked for |
keyboardBytes(text) |
The bytes a Minitel keyboard sends for some text: G0 codes, SS2 for £ § ß Œ œ and the accents (STUM 1B, part 2, ch. 3, §5.1) |
functionKeyBytes(key) |
The bytes of a function key: SEP then its code |
new VideotexInputDecoder(), .write(bytes) |
Reads what a Minitel sends: characters (an accent and its letter as one), function keys, its identification, its cursor position, other codes as they are |
encodeVideotexCells(page, row, from, to) |
Rewrites some cells of a row in place, without clearing the screen: for an echo, or a change |
On a Minitel, the background of text, its underline and masking are zone attributes: they change on a delimiter, the first space after the attribute or a mosaic, and a delimiter is never underlined. decodeVideotex follows these rules. PageBuilder gives each cell its own attributes, so a page can ask for what a Minitel cannot do, such as a new background starting on a letter at the left edge. encodeVideotex then gets as close as it can, and videotexMismatches lists the cells that differ. Characters outside the Minitel's sets become a low bar. Not supported: scroll mode, and double-size characters that overlap each other.
Pages written by encodeVideotex read back the same in MiEdit, a Minitel page editor: the 16 pages of the demo, and 600 random pages except for known cases (characters MiEdit lacks, double width on row 0, overlapping double sizes, inverse double heights over two backgrounds). Details and how to run the check: docs/SPECS.md.
Live services over WebSocket
VideotexTerminal is a Minitel connected to a Videotex service: the screen, with its cursor, and the function keys. What the service sends is drawn as a Minitel 1B would, at 1,200 baud by default; the function keys and what is typed go back as a Minitel keyboard sends them. Tap or click the screen, then type: an input laid over it takes the characters, and brings up the keyboard of a phone.
import { VideotexTerminal } from 'videotex-ui';
<VideotexTerminal url="wss://example.org/videotex" crt />;
It takes the props of Screen (except page), and options (below), keys (true: shows the function keys), labels, layout, inputLabel and onStatusChange(status).
Like a Minitel, it answers the service on its own: its cursor position when asked with ESC 0x61, and its identification when asked with PRO1 ENQROM (SOH, maker, type, version, EOT: Cu<, a Minitel 1B, by default). It shows the cursor when the service turns it on (codes 0x11 and 0x14), and calls onBeep on the code BEL (STUM 1B, part 2, ch. 2, §1.2.6 and ch. 6, §6).
For another layout, useVideotexSocket(url, options) gives the parts:
import { FunctionKeys, Screen, useVideotexSocket } from 'videotex-ui';
export function Terminal() {
const service = useVideotexSocket('wss://example.org/videotex');
return (
<>
<div className="vtx-terminal-screen">
<Screen page={service.page} cursor={service.cursor} aria-label="Videotex service" />
<input className="vtx-terminal-input" aria-label="Type to the service" {...service.inputProps} />
</div>
<FunctionKeys shortcuts onKey={service.sendKey} />
</>
);
}
| Option | Default | What it does |
|---|---|---|
baud |
1200 |
Draws what arrives at this speed, so pages build up as on a Minitel; false draws it as it comes |
sendAs |
'text' |
'text' frames with one character per byte, as MiEdit's emulator sends them, or 'binary' |
localEcho |
false |
Shows what is typed without waiting for the service to send it back |
onBeep |
Called on the code BEL: a Minitel makes a sound of less than a second | |
identity |
'Cu<' |
The 3 bytes of the identification: maker, type, software version (STUM 1B, part 1, ch. 1, §4) |
protocols, createSocket |
WebSocket subprotocols; another way to make the socket (tests, another transport) |
It returns page, cursor (null while hidden), status ('idle', 'connecting', 'open', 'closed' or 'error'), sendKey(key), sendText(text), sendBytes(bytes), inputProps (for an input over the screen: what is typed goes to the service, a deletion as Correction), onKeyDown (for any focusable element instead) and close(). A null address stays disconnected; a new address starts a new screen. A page served over https can only open wss:// addresses (MDN), except on localhost. The demo can connect to a service: enter its address under the screen.
Minitel services in React: videotex-ui/server
The same components, drawn on a server for a Minitel or an emulator connected over a WebSocket (the demo can connect to one, and so can VideotexTerminal). A page is a React tree with one Screen. VideotexSession sends it as a Videotex stream, echoes what is typed in its InputField and TextArea zones, and gives the service the keys it has to act on.
import { InputField, PageBuilder, Screen, StatusRow, Title } from 'videotex-ui';
import { VideotexSession } from 'videotex-ui/server';
import { WebSocketServer } from 'ws';
const background = new PageBuilder().moveTo(10, 2).print('Code:', { fg: 'cyan' }).build();
function Login({ message = '' }) {
return (
<Screen page={background}>
<StatusRow left="MY SERVICE" message={message} />
<InputField label="Code" name="code" type="digits" row={10} col={8} size={4} />
</Screen>
);
}
new WebSocketServer({ port: 8080 }).on('connection', (socket) => {
// One character per byte, in text frames, as Minitel emulators expect.
const session = new VideotexSession({ send: (bytes) => socket.send(Buffer.from(bytes).toString('latin1')) });
session.show(<Login />);
socket.on('message', (data) => {
for (const event of session.receive(data as Buffer)) {
if (event.type !== 'key' || event.key !== 'send') continue;
if (event.values.code === '3615') session.show(<Screen page={background}><Title>WELCOME</Title></Screen>);
// Only the message goes: a few bytes, and the code typed stays.
else session.update(<Login message="WRONG CODE" />);
}
});
});
While a page has input zones, the session handles the keys of a form as the STUM 1B recommends to services (part 1, ch. 4, table "Usage des touches de fonction"); the other keys come out as events:
| Key | What the session does |
|---|---|
| Correction | Erases the last character. On an empty zone: an event |
| Annulation | Erases the zone; *Annulation erases every zone. On an empty zone: an event |
| Suite, Retour | Next or previous zone, with two zones or more; from the last zone, Suite goes to the first (our choice) |
| Répétition | Sends the page again, with what was typed |
| Envoi, Sommaire, Guide, other starred keys | An event, with the values typed |
Typed characters are echoed in place, in 4 to 8 bytes each (US and the position, the color when it is not white, the character), and a zone keeps to its size and, for type="digits", to digits. Each echo is checked against what a Minitel 1B would show, as decodeVideotex draws it; when a background or an underline needs a delimiter before the zone, the session rewrites the whole row if that comes closer.
VideotexSession |
What it does |
|---|---|
show(content, { field }) |
Sends a page: a React tree, a Page, or { page, fields }. The cursor goes to the end of the first zone, or of the one named; without zones it is hidden |
update(content) |
Sends only the cells that change: a message on the service row, a clock. Zones that keep their name keep what was typed |
receive(data) |
Takes what the Minitel sent and returns events: key (key, starred, field, values), char (typed on a page without zones), identity, cursor, control |
values, field, page |
The zones by name, the zone with the cursor, what the Minitel shows |
focus(name), setValue(name, value), bell(), write(bytes) |
Moves the cursor, changes a zone, rings (BEL), sends bytes as they are |
renderToPage(element) gives the page and its zones without a session, and renderToVideotex(element) its bytes. Pages are drawn with react-dom/server: effects do not run, so give the data as props.
examples/service is a small service to run with npm start: a menu, a guestbook shared by everyone connected, a form, and a page with the identification of the Minitel and a clock updated once a second.
Without React: <videotex-screen>
videotex-ui/element is a custom element that works in any page or framework. It draws on a canvas with the same renderer as Screen renderer="canvas", keeps the text of the page for screen readers, and imports no React.
<videotex-screen src="home.vdt" baud="1200"></videotex-screen>
<script type="module">
import { defineVideotexScreen } from 'videotex-ui/element';
defineVideotexScreen();
const screen = document.querySelector('videotex-screen');
// A page made with PageBuilder or decodeVideotex: screen.page = page;
// Or a stream, part by part: screen.write(bytes);
</script>
| Attribute | What it does |
|---|---|
src |
A .vdt file to show |
baud |
Draws each new page at this speed (1200 on a Minitel); a stream written with write() shows as it comes |
palette |
color (default) or monochrome |
scale |
CSS pixels per dot; by default the largest whole number that fits the width |
blink |
false stops blinking |
Properties and methods: page, write(bytes) (with the stream's cursor), clear(). Events: load and error for src, revealend at the end of a progressive display. The element is a figure named "Videotex screen" unless the page gives it another role or aria-label. defineVideotexScreen(name) registers it under another name; on a server, it does nothing.
Development
npm install
npm run dev # demo on http://localhost:5173
npm test # tests
npm run build # library in dist/
npm run registry # rewrites registry.json after a source file is added or moved
npm run registry:build # shadcn registry in r/
npm run check:package # packs the package and tries it in a throwaway project (types, Node)
npm run font # rebuilds the font in videotex.css from src/core/font.ts (Node 22.18 or later)
npm run record # GIF and screenshots in docs/media/, sharing picture of the demo (needs Google Chrome and ffmpeg)
npm run check:miedit -- path/to/miedit # reads our .vdt streams with MiEdit's emulator (after npm run build; needs Chrome)
npm pack and npm publish build the library and the registry first; npm publish also runs the typecheck, the tests and check:package, and stops if one fails. The demo is published on GitHub Pages after every change on main. Changes go in CHANGELOG.md.
Roadmap
The steps are described in ROADMAP.md and tracked in the repository issues. The technical values in use, and what is still to be verified, are listed in docs/SPECS.md.
Trademarks
Minitel is a registered trademark of Orange. videotex-ui is an independent project inspired by the Minitel: it is not affiliated with Orange, nor sponsored or endorsed by it. See docs/LEGAL.md.
License
The code is under the MIT license. The Videotex UI font (the glyphs in src/core/font.ts and the font they make) is under the SIL Open Font License 1.1.
探索相关项目
加载中…