@coldsmirk/inkstone-monaco 0.18.0 → 0.19.1

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
@@ -16,6 +16,7 @@ Part of [inkstone](https://github.com/coldsmirk/inkstone). For a drop-in React c
16
16
  - **`StreamingEditorController`** — stream generated text into an editor without routing every token through app state: `begin()` / `append(chunk)` / `end()` / `discard()`, `attach(editor)` / `detach(editor)` with buffered replay for late-mounting editors (and for a model swapped onto the attached editor mid-stream, including after the final chunk), and `isStreaming()` for the onChange guard. The stream locks every editor it touches read-only and `end()` / `discard()` restore each one's own setting — by handle, so an editor detached mid-stream is restored too; `discard()` puts every displaced document back into the model it came from, and `end()` does the same for every model except the one keeping the streamed text. Full-buffer writes and restorations preserve each model's UTF-8 BOM. Editors and models the app disposed mid-stream are skipped, never touched — teardown can race the stream without wedging it.
17
17
  - **`replaceInEditor(editor, old, new, all)`** — exact find-and-replace on an editor handle via `executeEdits`, preserving undo/cursor/folds; returns whether the edit landed (`false` = no editor / empty search / no match / a read-only editor refused it — e.g. one locked by a stream in progress), so a tool-call handler knows to fall back to a state write.
18
18
  - **`registerShikiHighlighting(monaco, highlighter)`** — wire `@coldsmirk/inkstone-core`'s shared Shiki highlighter onto a monaco module, once per distinct module: registers the canonical grammar names as Monaco languages, applies `@shikijs/monaco`'s tokenizer/themes, and repairs its `setTheme` patch so non-Shiki theme ids (vs/vs-dark, caller-defined) keep Monaco's original path. A failed registration is restored and retried on the next call.
19
+ - **`installDesignTokens()`** — defines the VS Code design tokens monaco-editor 0.56's chrome reads and the standalone editor never does ([microsoft/monaco-editor#5408](https://github.com/microsoft/monaco-editor/issues/5408)): `--vscode-cornerRadius-{small,medium,large,xLarge}` and `--vscode-shadow-{md,lg,xl}`, on `.monaco-editor` (the context menu's shadow root and a host's `overflowWidgetsDomNode` inherit them). Without them the context menu, completion, hover, and find widgets ship square and shadowless. Each resolves through the host's `--inkstone-radius-*` / `--inkstone-shadow-*` token first (see `@coldsmirk/inkstone-core`), then a fallback scale in the spirit of 0.55's look. `ensureMonacoHost` installs it; idempotent.
19
20
  - **`DEFAULT_MONACO_OPTIONS`** — the inkstone construction-option baseline (no minimap, 14px/1.6 type on the shared `--inkstone-font-family-code` token, embedded-friendly find widget, tuned completion, thin scrollbars). Spread it to extend: `{ ...DEFAULT_MONACO_OPTIONS, wordWrap: "on" }`.
20
21
  - **`reconcileModelValue` / `modelValueMatches`** — the controlled-value reconcile: diff an external value against a live model (normalized to the model's EOL) and apply one minimal `applyEdits` replace that never lands on the undo stack or moves a caret outside the changed region.
21
22
 
package/dist/index.d.ts CHANGED
@@ -75,6 +75,15 @@ interface AutoImportCompletionOptions {
75
75
  */
76
76
  declare function installAutoImportCompletions(monaco: MonacoModule, options: AutoImportCompletionOptions): monacoEditor.IDisposable;
77
77
  //#endregion
78
+ //#region src/design-tokens.d.ts
79
+ /**
80
+ * Define the VS Code design tokens Monaco's chrome reads but the standalone editor lacks —
81
+ * corner radii and widget shadows — on `.monaco-editor`, resolved through the host's
82
+ * `--inkstone-radius-*` / `--inkstone-shadow-*` tokens with inkstone's fallbacks. Installed by
83
+ * `ensureMonacoHost`; idempotent, so a host that brings monaco up on its own can call it too.
84
+ */
85
+ declare function installDesignTokens(): void;
86
+ //#endregion
78
87
  //#region src/hover-dead-band.d.ts
79
88
  /**
80
89
  * The slice of a standalone editor the install touches — structural, so the install is
@@ -366,4 +375,4 @@ declare class StreamingEditorController {
366
375
  discard(): void;
367
376
  }
368
377
  //#endregion
369
- export { type AutoImportCompletionOptions, DEFAULT_MONACO_OPTIONS, type HoverDeadBandTargetEditor, type JsxTagClosingTargetEditor, type JsxTagClosingTargetModel, type KeybindingTargetEditor, type MonacoBuiltInLanguage, type MonacoHostOptions, type MonacoLanguage, type MonacoModule, type MonacoUiLocale, type StreamTargetEditor, StreamingEditorController, type SwallowedKeybindings, disabledKeybindings, ensureMonacoHost, installAutoImportCompletions, installDisabledKeybindings, installHoverDeadBandFix, installJsxTagClosing, modelValueMatches, monacoLanguages, reconcileModelValue, registerShikiHighlighting, replaceInEditor };
378
+ export { type AutoImportCompletionOptions, DEFAULT_MONACO_OPTIONS, type HoverDeadBandTargetEditor, type JsxTagClosingTargetEditor, type JsxTagClosingTargetModel, type KeybindingTargetEditor, type MonacoBuiltInLanguage, type MonacoHostOptions, type MonacoLanguage, type MonacoModule, type MonacoUiLocale, type StreamTargetEditor, StreamingEditorController, type SwallowedKeybindings, disabledKeybindings, ensureMonacoHost, installAutoImportCompletions, installDesignTokens, installDisabledKeybindings, installHoverDeadBandFix, installJsxTagClosing, modelValueMatches, monacoLanguages, reconcileModelValue, registerShikiHighlighting, replaceInEditor };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CODE_FONT_FAMILY } from "@coldsmirk/inkstone-core";
1
+ import { CODE_FONT_FAMILY, inkstoneRadius, inkstoneShadow } from "@coldsmirk/inkstone-core";
2
2
  import { shikiToMonaco } from "@shikijs/monaco";
3
3
  //#region src/auto-imports.ts
4
4
  const MISSING_LOOKUP_REJECTION$1 = "Missing requestHandler or method: getAutoImportCompletionsAtPosition";
@@ -123,6 +123,25 @@ function installAutoImportCompletions(monaco, options) {
123
123
  return install;
124
124
  }
125
125
  //#endregion
126
+ //#region src/design-tokens.ts
127
+ const DESIGN_TOKENS_STYLE_SELECTOR = "style[data-inkstone=\"monaco-design-tokens\"]";
128
+ const DESIGN_TOKENS = [
129
+ `--vscode-cornerRadius-small: ${inkstoneRadius("small", "2px")}`,
130
+ `--vscode-cornerRadius-medium: ${inkstoneRadius("medium", "4px")}`,
131
+ `--vscode-cornerRadius-large: ${inkstoneRadius("large", "6px")}`,
132
+ `--vscode-cornerRadius-xLarge: ${inkstoneRadius("xlarge", "8px")}`,
133
+ `--vscode-shadow-md: ${inkstoneShadow("medium", "0 1px 4px var(--vscode-widget-shadow)")}`,
134
+ `--vscode-shadow-lg: ${inkstoneShadow("large", "0 2px 8px var(--vscode-widget-shadow)")}`,
135
+ `--vscode-shadow-xl: ${inkstoneShadow("xlarge", "0 4px 16px var(--vscode-widget-shadow)")}`
136
+ ];
137
+ function installDesignTokens() {
138
+ if (document.querySelector(DESIGN_TOKENS_STYLE_SELECTOR)) return;
139
+ const style = document.createElement("style");
140
+ style.dataset.inkstone = "monaco-design-tokens";
141
+ style.textContent = `.monaco-editor { ${DESIGN_TOKENS.join("; ")}; }`;
142
+ document.head.append(style);
143
+ }
144
+ //#endregion
126
145
  //#region src/geometry-fixes.ts
127
146
  const HOVER_GEOMETRY_STYLE_SELECTOR = "style[data-inkstone=\"monaco-hover-geometry\"]";
128
147
  function installHoverGeometryFix() {
@@ -207,6 +226,7 @@ function ensureMonacoHost(options = {}) {
207
226
  let restoreNls;
208
227
  try {
209
228
  if (locale === "zh-cn") restoreNls = await applyZhCnCatalog();
229
+ installDesignTokens();
210
230
  installHoverGeometryFix();
211
231
  installSuggestGeometryFix();
212
232
  const monaco = await import("monaco-editor");
@@ -666,4 +686,4 @@ var StreamingEditorController = class {
666
686
  }
667
687
  };
668
688
  //#endregion
669
- export { DEFAULT_MONACO_OPTIONS, StreamingEditorController, disabledKeybindings, ensureMonacoHost, installAutoImportCompletions, installDisabledKeybindings, installHoverDeadBandFix, installJsxTagClosing, modelValueMatches, monacoLanguages, reconcileModelValue, registerShikiHighlighting, replaceInEditor };
689
+ export { DEFAULT_MONACO_OPTIONS, StreamingEditorController, disabledKeybindings, ensureMonacoHost, installAutoImportCompletions, installDesignTokens, installDisabledKeybindings, installHoverDeadBandFix, installJsxTagClosing, modelValueMatches, monacoLanguages, reconcileModelValue, registerShikiHighlighting, replaceInEditor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coldsmirk/inkstone-monaco",
3
- "version": "0.18.0",
3
+ "version": "0.19.1",
4
4
  "description": "Framework-agnostic Monaco assembly: lazy offline host (all language workers bundled, no CDN), opt-in Simplified-Chinese UI via monaco's official NLS catalog, a streaming editor controller for AI-typed content, and the shared Shiki highlighting bridge.",
5
5
  "keywords": [
6
6
  "monaco",
@@ -40,7 +40,7 @@
40
40
  ],
41
41
  "dependencies": {
42
42
  "@shikijs/monaco": "^4.4.3",
43
- "@coldsmirk/inkstone-core": "^0.18.0"
43
+ "@coldsmirk/inkstone-core": "^0.19.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "monaco-editor": "^0.56.0",