@coldsmirk/inkstone-redis 0.22.0
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 +49 -0
- package/dist/commands-BMa2ec02.js +4610 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +85 -0
- package/dist/markers-BlM8eKCj.js +250 -0
- package/dist/markers-gZmuOyuR.d.ts +244 -0
- package/dist/monaco.d.ts +42 -0
- package/dist/monaco.js +184 -0
- package/dist/react.d.ts +95 -0
- package/dist/react.js +104 -0
- package/package.json +77 -0
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @coldsmirk/inkstone-redis
|
|
2
|
+
|
|
3
|
+
Redis command-line editing intelligence for Monaco: the command table of Redis 7.2 (every command's name, syntax, arity and summary, as the server itself states them), redis-cli's own line splitting, completion / hover / signature help, line markers, and a drop-in React `<RedisEditor>`.
|
|
4
|
+
|
|
5
|
+
Part of [inkstone](https://github.com/coldsmirk/inkstone). Built for the [**polyglot**](https://github.com/coldsmirk/polyglot) sidecar's Redis engine, which takes one command line and splits it exactly as this package reads it.
|
|
6
|
+
|
|
7
|
+
## Entries
|
|
8
|
+
|
|
9
|
+
- **`@coldsmirk/inkstone-redis`** — the framework-free core: the table, the line reader, the assist, the markers. Zero editor dependencies.
|
|
10
|
+
- **`@coldsmirk/inkstone-redis/monaco`** — `defineRedisLanguage(monaco)` (the `redis` id with its Monarch grammar, once per monaco module), `registerRedisLanguage(monaco, modelPath, hooks)` (completion, hover and signature help for one model), `setRedisMarkers` (the markers as Monaco's own). Peer: `monaco-editor`.
|
|
11
|
+
- **`@coldsmirk/inkstone-redis/react`** — `<RedisEditor>`: a controlled command editor built on `@coldsmirk/inkstone-react`'s `<MonacoEditor>`, with a run key (Ctrl/Cmd-Enter handing over the live caret), caret tracking, an insert handle for key trees, and each line's markers refreshed on every change. Peers: `monaco-editor`, `react`.
|
|
12
|
+
|
|
13
|
+
## The shape
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createRedisAssist, lineMarkers, runnableLine } from "@coldsmirk/inkstone-redis";
|
|
17
|
+
|
|
18
|
+
const assist = createRedisAssist(); // over the built-in table; takes a vocabulary of your own
|
|
19
|
+
|
|
20
|
+
// What one run should send: the selection where there is one, else the caret's line.
|
|
21
|
+
const runnable = runnableLine(text, from, to);
|
|
22
|
+
|
|
23
|
+
if (runnable.kind === "one") {
|
|
24
|
+
send(runnable.text);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// A code per line fault — the host owns the wording.
|
|
28
|
+
for (const marker of lineMarkers(text)) {
|
|
29
|
+
console.log(marker.code, marker.severity, marker.from, marker.to);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Completion offers every command at a line's start, a container's subcommands after it (`CLIENT` → `LIST`, `KILL` …) and the command's own fixed words among its arguments (`NX`, `EX`, `WITHSCORES`); hover describes the command under its name; signature help follows the caret across the syntax line. Everything reads the line through one splitter, so the three can never disagree about which word the caret is on.
|
|
34
|
+
|
|
35
|
+
## The mirror invariant
|
|
36
|
+
|
|
37
|
+
`splitLine` mirrors the polyglot sidecar's `RedisLine` word for word — bare words on blanks, double quotes with `\xHH` and the C escapes, single quotes with `\'` alone, a closing quote that must be followed by a blank — and refuses exactly what the engine refuses, as a code (`"unbalanced-double-quote"`, `"unbalanced-single-quote"`, `"quote-not-followed-by-blank"`). A change to the engine's splitter requires a matching release of this package; `line.test.ts` carries the engine's own cases.
|
|
38
|
+
|
|
39
|
+
## The table
|
|
40
|
+
|
|
41
|
+
`src/commands.ts` is generated by `scripts/commands.ts` from the `COMMAND DOCS` and `COMMAND` replies of a running Redis 7.2 — the last BSD-3-Clause release, whose command documentation ships inside the server. The script's header says how to regenerate it. A command the table does not know (a module's, a newer server's) is a hint, never an error: the engine runs it all the same.
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pnpm add @coldsmirk/inkstone-redis monaco-editor
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Every peer is optional, because the root entry needs none of them: `/monaco` needs `monaco-editor`, and `/react` additionally needs `react` (>= 19) and `@coldsmirk/inkstone-react`. Never import `monaco-editor` statically — take the module from `onMount` / `ensureMonacoHost()`; type-only imports erase and are fine.
|