@coldsmirk/inkstone-core 0.19.0 → 0.19.2
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 +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Part of [inkstone](https://github.com/coldsmirk/inkstone). The editor layers ([`
|
|
|
9
9
|
- **`getHighlighter()`** — the process-wide `HighlighterCore` promise. JavaScript / TypeScript / JSON / SQL grammars and the catppuccin theme pair load by default.
|
|
10
10
|
- **`configureHighlighter(config)`** — extend or replace the default grammar / theme set, once, before any editor mounts. `DEFAULT_HIGHLIGHTER_LANGS` is exported so extension is additive.
|
|
11
11
|
- **`shikiThemeId(dark)`** plus the `INKSTONE_LIGHT_THEME` / `INKSTONE_DARK_THEME` constants — the theme names to pass wherever a Shiki theme id is expected.
|
|
12
|
-
- **`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
|
|
12
|
+
- **`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
13
|
- **`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.
|
|
14
14
|
- **`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.
|
|
15
15
|
|
package/dist/index.d.ts
CHANGED
|
@@ -15,8 +15,9 @@ declare const CODE_FONT_FAMILY = "var(--inkstone-font-family-code, ui-monospace,
|
|
|
15
15
|
* chrome — background, gutter, current line, the floating completion / hover / find widgets —
|
|
16
16
|
* in its own tokens, so an editor sits inside the app instead of bringing a second dark.
|
|
17
17
|
*
|
|
18
|
-
* Every value is a
|
|
19
|
-
*
|
|
18
|
+
* Every value is a hex color (`#rrggbb`, `#rrggbbaa`): Monaco parses its theme colors itself,
|
|
19
|
+
* as hex only, and cannot follow a custom property. An omitted role keeps the flavor's own
|
|
20
|
+
* color.
|
|
20
21
|
*/
|
|
21
22
|
interface EditorSurface {
|
|
22
23
|
/**
|
|
@@ -124,8 +125,9 @@ declare function configureHighlighter(options: HighlighterConfig): void;
|
|
|
124
125
|
* role's flavor color; a later call replaces the schemes it names. Process-global like the
|
|
125
126
|
* highlighter itself, for the same reason: one palette across every editor and rendered block.
|
|
126
127
|
*
|
|
127
|
-
* Every value must be a
|
|
128
|
-
*
|
|
128
|
+
* Every value must be a hex color (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`) — Monaco parses
|
|
129
|
+
* theme colors as hex and paints red for anything else, a custom property reference or an
|
|
130
|
+
* `rgb(…)` alike, so those are refused here instead of failing on screen.
|
|
129
131
|
*/
|
|
130
132
|
declare function configureEditorSurface(surfaces: EditorSurfaces): void;
|
|
131
133
|
/**
|
package/dist/index.js
CHANGED
|
@@ -101,12 +101,13 @@ function configureHighlighter(options) {
|
|
|
101
101
|
...options
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
+
const HEX_COLOR = /^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;
|
|
104
105
|
function configureEditorSurface(surfaces) {
|
|
105
106
|
const registry = getHighlighterRegistry();
|
|
106
107
|
assertConfigurable(registry, "configureEditorSurface");
|
|
107
108
|
for (const [scheme, surface] of Object.entries(surfaces)) {
|
|
108
109
|
const roles = Object.entries(surface ?? {});
|
|
109
|
-
for (const [role, value] of roles) if (typeof value === "string" &&
|
|
110
|
+
for (const [role, value] of roles) if (typeof value === "string" && !HEX_COLOR.test(value)) throw new Error(`configureEditorSurface: ${scheme}.${role} must be a hex color, which is all Monaco parses (${value})`);
|
|
110
111
|
}
|
|
111
112
|
registry.surfaces = {
|
|
112
113
|
...registry.surfaces,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coldsmirk/inkstone-core",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.2",
|
|
4
4
|
"description": "Shared Shiki highlighter service for the inkstone editor toolkit: one fine-grained singleton (catppuccin themes, JS regex engine) reused by Monaco, static rendering, and markdown surfaces.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shiki",
|