@coldsmirk/inkstone-core 0.27.4 → 0.28.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 CHANGED
@@ -10,7 +10,7 @@ Part of [inkstone](https://github.com/coldsmirk/inkstone). The editor layers ([`
10
10
  - **`configureHighlighter(config)`** — extend or replace the default grammar / theme set, and choose the regex engine, once, before any editor mounts. `DEFAULT_HIGHLIGHTER_LANGS` is exported so extension is additive. `engine` takes the engine itself, a promise of one, or a factory called once when the highlighter is first built — configuration stays synchronous while the engine may be async to make: the strict JavaScript engine by default, `createJavaScriptRegexEngine({ forgiving: true })` for grammars the strict one refuses, or `onigurumaEngine`.
11
11
  - **`onigurumaEngine`** — the Oniguruma engine on its WASM, inlined into a chunk of your own bundle (about 600 KB, nothing fetched from anywhere else) and instantiated once, in about 20 ms. Which engine: the JavaScript one translates each grammar's patterns into JavaScript at the first tokenization, on the main thread, and pays for it on whole files — a TypeScript file's first sixty lines cost it about 170 ms, against Oniguruma's 20. Colouring fenced snippets, keep the default; reading whole files in an editor (`@coldsmirk/inkstone-monaco`'s Shiki bridge, `<MonacoEditor>`), pass `onigurumaEngine` as the factory. `onigurumaEngine(wasm)` takes the WASM from elsewhere in any form Shiki's `createOnigurumaEngine` accepts, such as a `fetch("/onig.wasm")`.
12
12
  - **`shikiThemeId(dark)`** plus the `INKSTONE_LIGHT_THEME` / `INKSTONE_DARK_THEME` constants — the theme names to pass wherever a Shiki theme id is expected.
13
- - **`configureEditorSurface(surfaces)`** — re-light the editors' own surfaces in your design language, once, before any editor mounts: per-scheme CSS color literals for `background` (content and gutter), `lineHighlight`, `lineNumber`, `widget` (completion, hover, parameter hints, the find widget and search panels), `widgetBorder`, and `widgetSelection`. The catppuccin pair keeps its syntax palette and gets these baked into its theme colors — Monaco, static rendering, and CodeMirror's chrome all read the same values — so an editor sits inside the app instead of bringing a second dark. A role or scheme left out keeps the flavor's own color, a later call replaces the schemes it names, and values must be hex colors (`#rrggbb`, `#rrggbbaa`) — Monaco parses theme colors as hex and paints red for anything else, so a `var()` reference or an `rgb(…)` is refused up front. Keep `lineHighlight` translucent: CodeMirror draws selections behind the content, so an opaque active line would hide them. `getEditorSurface(dark)` reads what was configured.
13
+ - **`configureEditorSurface(surfaces)`** — re-light every color the editors paint that is not syntax, in your design language, once, before any editor mounts. Per scheme, CSS color literals for the editor (`background` — content, gutter and the fields of its chrome — `lineHighlight`, `lineNumber`, `lineNumberActive`, `cursor`, `selection`, `scrollbar`), its floating chrome — completion, hover, parameter hints, the find widget and search panels, the context menu — (`widget`, `widgetBorder`, `widgetSelection`, `widgetForeground`, `widgetForegroundMuted`), the `accent` that rings a focused field and marks what a completion matched, and the diagnostic severities `error`, `warning`, `info` and `hint`, named as CodeMirror's `Diagnostic.severity` names them. The catppuccin pair keeps its syntax palette — token colors, the editor's default text, the completion-kind icons that mirror them — and gets these baked into its theme colors — Monaco, static rendering, and CodeMirror's chrome all read the same values — so an editor sits inside the app instead of bringing a second dark. A role or scheme left out keeps the flavor's own color, a later call replaces the schemes it names, and values must be hex colors (`#rrggbb`, `#rrggbbaa`) — Monaco parses theme colors as hex and paints red for anything else, so a `var()` reference or an `rgb(…)` is refused up front. Keep `lineHighlight` translucent: CodeMirror draws selections behind the content, so an opaque active line would hide them. `selection` shows at half its alpha while the editor is unfocused, in both engines; `scrollbar` has no hover state (CodeMirror's `scrollbar-color` has none, so Monaco's slider keeps it too). `getEditorSurface(dark)` reads what was configured.
14
14
  - **`CODE_FONT_FAMILY`** — the shared code font stack both editor engines render with: the page's `--inkstone-font-family-code` CSS token when defined, else the platform's native monospace.
15
15
  - **`inkstoneRadius(size, fallback)` / `inkstoneShadow(size, fallback)`** — `var()` references to the host's `--inkstone-radius-{small,medium,large,xlarge}` and `--inkstone-shadow-{medium,large,xlarge}` tokens. Set them once on your root and both engines' chrome follows: the Monaco host maps them onto VS Code's `--vscode-cornerRadius-*` / `--vscode-shadow-*` design tokens (which the standalone editor never defines), CodeMirror's polish reads them directly; unset, each engine keeps the look it ships with.
16
16
 
@@ -32,10 +32,10 @@ import yaml from "@shikijs/langs/yaml";
32
32
  // for an app that reads whole files in an editor, the Oniguruma engine (see above).
33
33
  configureHighlighter({ langs: [...DEFAULT_HIGHLIGHTER_LANGS, yaml], engine: onigurumaEngine });
34
34
 
35
- // Optional: paint the editors' surfaces in your own tokens (syntax colors stay catppuccin's).
35
+ // Optional: paint the editors' chrome in your own tokens (syntax colors stay catppuccin's).
36
36
  configureEditorSurface({
37
- light: { background: "#f7f7fa", lineHighlight: "#ffffff", widget: "#ffffff", widgetBorder: "#ced4da" },
38
- dark: { background: "#1d1b22", lineHighlight: "#232129", widget: "#302e38", widgetBorder: "#423f4b" }
37
+ light: { background: "#f7f7fa", lineHighlight: "#16171a0a", widget: "#ffffff", widgetBorder: "#ced4da", accent: "#228be6", error: "#e03131" },
38
+ dark: { background: "#1d1b22", lineHighlight: "#ffffff0a", widget: "#302e38", widgetBorder: "#423f4b", accent: "#4dabf7", error: "#ff6b6b" }
39
39
  });
40
40
 
41
41
  const highlighter = await getHighlighter();
package/dist/index.d.ts CHANGED
@@ -10,10 +10,11 @@ declare const CODE_FONT_FAMILY = "var(--inkstone-font-family-code, ui-monospace,
10
10
  //#endregion
11
11
  //#region src/surface.d.ts
12
12
  /**
13
- * The surfaces an editor paints, as a host's design language names them. A host that
14
- * configures these keeps the catppuccin flavors' syntax palette and gets the editor's own
15
- * chrome — background, gutter, current line, the floating completion / hover / find widgets —
16
- * in its own tokens, so an editor sits inside the app instead of bringing a second dark.
13
+ * The colors an editor paints that are not its syntax, as a host's design language names
14
+ * them. A host that configures these keeps the catppuccin flavors' syntax palette and gets the
15
+ * editor's own chrome — background, gutter, current line, caret and selection, the floating
16
+ * completion / hover / find widgets and the signals on them — in its own tokens, so an editor
17
+ * sits inside the app instead of bringing a second dark.
17
18
  *
18
19
  * Every value is a hex color (`#rrggbb`, `#rrggbbaa`): Monaco parses its theme colors itself,
19
20
  * as hex only, and cannot follow a custom property. An omitted role keeps the flavor's own
@@ -21,7 +22,8 @@ declare const CODE_FONT_FAMILY = "var(--inkstone-font-family-code, ui-monospace,
21
22
  */
22
23
  interface EditorSurface {
23
24
  /**
24
- * The editor's own background: the content area and the gutter.
25
+ * The editor's own background: the content area and the gutter, and the fields inside
26
+ * floating chrome.
25
27
  */
26
28
  background?: string;
27
29
  /**
@@ -34,19 +36,69 @@ interface EditorSurface {
34
36
  * Line numbers.
35
37
  */
36
38
  lineNumber?: string;
39
+ /**
40
+ * The current line's number.
41
+ */
42
+ lineNumberActive?: string;
43
+ /**
44
+ * The caret, and the drop cursor of a drag.
45
+ */
46
+ cursor?: string;
47
+ /**
48
+ * Selected text while the editor has focus. Unfocused, both editors show it at half its
49
+ * alpha (Monaco's own `editor.inactiveSelectionBackground` rule).
50
+ */
51
+ selection?: string;
52
+ /**
53
+ * The scrollbar's thumb, the same under the pointer: CodeMirror's scrollers paint it through
54
+ * the standard `scrollbar-color`, which has no hover state, and Monaco's slider takes it at
55
+ * rest, hovered and dragged alike.
56
+ */
57
+ scrollbar?: string;
37
58
  /**
38
59
  * Floating chrome: completion, hover and parameter hints, the find widget and the search
39
- * panels.
60
+ * panels, the context menu.
40
61
  */
41
62
  widget?: string;
42
63
  /**
43
- * The hairline around floating chrome and its fields.
64
+ * The hairline around floating chrome and its fields, and between a menu's groups.
44
65
  */
45
66
  widgetBorder?: string;
46
67
  /**
47
- * A hovered or selected row inside floating chrome.
68
+ * A hovered or selected row inside floating chrome, and a hovered or toggled-on control.
48
69
  */
49
70
  widgetSelection?: string;
71
+ /**
72
+ * Text on floating chrome, its fields and its buttons.
73
+ */
74
+ widgetForeground?: string;
75
+ /**
76
+ * Secondary text and icons on floating chrome: a completion's detail, an option's label, a
77
+ * field's placeholder, a close button, a diagnostic's source.
78
+ */
79
+ widgetForegroundMuted?: string;
80
+ /**
81
+ * The host's accent: the ring around a focused field, a checked option, the characters a
82
+ * completion or quick pick matched.
83
+ */
84
+ accent?: string;
85
+ /**
86
+ * An error diagnostic: its squiggle, gutter marker and message bar, and its marks in the
87
+ * overview ruler and minimap.
88
+ */
89
+ error?: string;
90
+ /**
91
+ * A warning diagnostic, marked as an error is.
92
+ */
93
+ warning?: string;
94
+ /**
95
+ * An info diagnostic, marked as an error is.
96
+ */
97
+ info?: string;
98
+ /**
99
+ * A hint diagnostic: its squiggle (dots under the range in Monaco) and message bar.
100
+ */
101
+ hint?: string;
50
102
  }
51
103
  /**
52
104
  * One surface per color scheme; an omitted scheme keeps the flavor's own surfaces.
package/dist/index.js CHANGED
@@ -30,26 +30,95 @@ const SURFACE_COLORS = {
30
30
  ],
31
31
  lineHighlight: ["editor.lineHighlightBackground", "editorStickyScrollHover.background"],
32
32
  lineNumber: ["editorLineNumber.foreground"],
33
+ lineNumberActive: ["editorLineNumber.activeForeground"],
34
+ cursor: ["editorCursor.foreground"],
35
+ selection: ["editor.selectionBackground"],
36
+ scrollbar: [
37
+ "scrollbarSlider.background",
38
+ "scrollbarSlider.hoverBackground",
39
+ "scrollbarSlider.activeBackground"
40
+ ],
33
41
  widget: [
34
42
  "editorWidget.background",
35
43
  "editorSuggestWidget.background",
36
44
  "editorHoverWidget.background",
37
- "dropdown.background"
45
+ "dropdown.background",
46
+ "menu.background"
38
47
  ],
39
48
  widgetBorder: [
40
49
  "editorWidget.border",
41
50
  "editorWidget.resizeBorder",
42
51
  "editorSuggestWidget.border",
43
52
  "editorHoverWidget.border",
44
- "dropdown.border"
53
+ "dropdown.border",
54
+ "input.border",
55
+ "menu.border",
56
+ "menu.separatorBackground"
45
57
  ],
46
58
  widgetSelection: [
47
59
  "editorSuggestWidget.selectedBackground",
48
60
  "list.activeSelectionBackground",
49
61
  "list.inactiveSelectionBackground",
50
62
  "list.focusBackground",
51
- "list.hoverBackground"
52
- ]
63
+ "list.focusAndSelectionBackground",
64
+ "list.hoverBackground",
65
+ "menu.selectionBackground",
66
+ "toolbar.hoverBackground",
67
+ "inputOption.hoverBackground",
68
+ "inputOption.activeBackground"
69
+ ],
70
+ widgetForeground: [
71
+ "editorWidget.foreground",
72
+ "editorSuggestWidget.foreground",
73
+ "editorHoverWidget.foreground",
74
+ "dropdown.foreground",
75
+ "input.foreground",
76
+ "inputOption.activeForeground",
77
+ "list.activeSelectionForeground",
78
+ "list.inactiveSelectionForeground",
79
+ "list.focusForeground",
80
+ "list.hoverForeground",
81
+ "menu.foreground",
82
+ "menu.selectionForeground"
83
+ ],
84
+ widgetForegroundMuted: [
85
+ "descriptionForeground",
86
+ "input.placeholderForeground",
87
+ "icon.foreground"
88
+ ],
89
+ accent: [
90
+ "focusBorder",
91
+ "inputOption.activeBorder",
92
+ "list.highlightForeground",
93
+ "list.focusHighlightForeground",
94
+ "editorSuggestWidget.highlightForeground",
95
+ "editorSuggestWidget.focusHighlightForeground",
96
+ "pickerGroup.foreground",
97
+ "sash.hoverBorder"
98
+ ],
99
+ error: [
100
+ "editorError.foreground",
101
+ "editorOverviewRuler.errorForeground",
102
+ "editorMarkerNavigationError.background",
103
+ "minimap.errorHighlight",
104
+ "problemsErrorIcon.foreground",
105
+ "errorForeground"
106
+ ],
107
+ warning: [
108
+ "editorWarning.foreground",
109
+ "editorOverviewRuler.warningForeground",
110
+ "editorMarkerNavigationWarning.background",
111
+ "minimap.warningHighlight",
112
+ "problemsWarningIcon.foreground"
113
+ ],
114
+ info: [
115
+ "editorInfo.foreground",
116
+ "editorOverviewRuler.infoForeground",
117
+ "editorMarkerNavigationInfo.background",
118
+ "minimap.infoHighlight",
119
+ "problemsInfoIcon.foreground"
120
+ ],
121
+ hint: ["editorHint.foreground"]
53
122
  };
54
123
  function surfacedTheme(theme, surface) {
55
124
  const roles = Object.entries(SURFACE_COLORS);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coldsmirk/inkstone-core",
3
- "version": "0.27.4",
3
+ "version": "0.28.0",
4
4
  "description": "Shared Shiki highlighter service for the inkstone editor toolkit: one fine-grained singleton (catppuccin themes, the JS regex engine by default or Oniguruma on request) reused by Monaco, static rendering, and markdown surfaces.",
5
5
  "keywords": [
6
6
  "shiki",