@coldsmirk/inkstone-monaco 0.34.1 → 0.34.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 CHANGED
@@ -21,7 +21,7 @@ Part of [inkstone](https://github.com/coldsmirk/inkstone). For a drop-in React c
21
21
  - **`registerShikiLanguage(monaco, highlighter, language)`** — the lazy path: an app that loads grammars as files are opened calls this after each `highlighter.loadLanguage(...)` and before a model names the language. Registers the language where Monaco lacks it (`toml`, `shellscript`), its tokenization once under the grammar's canonical name (an alias like `ts` collapses), the models of a grammar shiki has built again since (a language it embeds lazily arrived) tokenized again under the new one, and leaves the theme the editor shows alone — the one thing re-running `@shikijs/monaco`'s `shikiToMonaco` cannot promise, which is why the bridge is inkstone's own. Throws for a grammar the highlighter has not loaded.
22
22
  - **`installDesignTokens()`** — defines the VS Code design tokens monaco-editor's chrome has read since 0.56 and the standalone editor still never does ([microsoft/monaco-editor#5408](https://github.com/microsoft/monaco-editor/issues/5408)): `--vscode-cornerRadius-{small,medium,large,xLarge,circle}` and `--vscode-shadow-{md,lg,xl}`, on `.monaco-editor` (a host's `overflowWidgetsDomNode` carries the class) and on `.monaco-component` — every context view, the class Monaco writes its own theme colors on: an element's tooltip and, since 0.57 under `fixedOverflowWidgets`, the editor's context menu stand in the node the editor was created in, outside `.monaco-editor`. Without them the context menu, completion, hover, and find widgets ship square and shadowless. 0.57 also took the completion list off `--vscode-shadow-lg` for a literal `0 2px 8px` shadow; it is put back on the token, so it wears the host's shadow as the hover and the context menu do. 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. It also keeps an input box's focus ring single: the standalone editor outlines both the `.monaco-inputbox` container (its `synthetic-focus` ring, which follows the box's radius) and the inner `<input>` (square, 1px inside), and the inner ring's corners poke out as soon as the box has corners — the container's ring is the one ring. `ensureMonacoHost` installs it; idempotent.
23
23
  - **`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" }`. Left out on purpose: `fullwidthCharacterWidth: "twoCells"`, which centers each full-width character — CJK text among it — in exactly two cells of a monospace font, so it lines up with the grid the way a terminal draws it. It draws every such character as a span of its own, which costs on text dense with them (a Chinese JSON body, a document of prose), so it is a host's to turn on where the alignment matters more.
24
- - **`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.
24
+ - **`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. One leading `U+FEFF` is treated as a BOM, as when Monaco loads a document; it is never inserted into the text. Any further `U+FEFF` remains document content. Reconciliation leaves the model's stored BOM unchanged.
25
25
 
26
26
  ## Install
27
27
 
package/dist/index.d.ts CHANGED
@@ -235,7 +235,7 @@ export declare const DEFAULT_MONACO_OPTIONS: editor.IStandaloneEditorConstructio
235
235
  */
236
236
  export declare function reconcileModelValue(model: editor.ITextModel, externalValue: string): void;
237
237
  /**
238
- * Whether an external value already matches the model after applying its EOL convention.
238
+ * Whether an external value already matches the model's document after BOM and EOL handling.
239
239
  */
240
240
  export declare function modelValueMatches(model: editor.ITextModel, externalValue: string): boolean;
241
241
  //#endregion
package/dist/index.js CHANGED
@@ -642,7 +642,7 @@ function modelValueMatches(model, externalValue) {
642
642
  return model.getValue() === normalizeModelValue(model, externalValue);
643
643
  }
644
644
  function normalizeModelValue(model, externalValue) {
645
- return externalValue.split(/\r\n|\r|\n/).join(model.getEOL());
645
+ return (externalValue.startsWith("") ? externalValue.slice(1) : externalValue).split(/\r\n|\r|\n/).join(model.getEOL());
646
646
  }
647
647
  //#endregion
648
648
  //#region src/replace.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coldsmirk/inkstone-monaco",
3
- "version": "0.34.1",
3
+ "version": "0.34.2",
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",
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "@shikijs/vscode-textmate": "^10.0.2",
43
43
  "shiki": "^4.5.0",
44
- "@coldsmirk/inkstone-core": "^0.34.1"
44
+ "@coldsmirk/inkstone-core": "^0.34.2"
45
45
  },
46
46
  "devDependencies": {
47
47
  "monaco-editor": "^0.57.0",