stream-monaco 0.0.8 → 0.0.9
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/dist/index.cjs +16 -5
- package/dist/index.js +16 -5
- package/package.json +15 -17
package/dist/index.cjs
CHANGED
|
@@ -2083,8 +2083,8 @@ async function registerMonacoThemes(themes, languages$1) {
|
|
|
2083
2083
|
const highlighter = await getOrCreateHighlighter(themes, languages$1);
|
|
2084
2084
|
(0, __shikijs_monaco.shikiToMonaco)(highlighter, monaco_shim_exports);
|
|
2085
2085
|
themesRegistered = true;
|
|
2086
|
-
currentThemes = themes;
|
|
2087
|
-
currentLanguages = languages$1;
|
|
2086
|
+
currentThemes = themes.slice();
|
|
2087
|
+
currentLanguages = languages$1.slice();
|
|
2088
2088
|
return highlighter;
|
|
2089
2089
|
})();
|
|
2090
2090
|
setThemeRegisterPromise(p);
|
|
@@ -2287,6 +2287,12 @@ function useMonaco(monacoOptions = {}) {
|
|
|
2287
2287
|
console.warn("onThemeChange callback threw an error:", err);
|
|
2288
2288
|
}
|
|
2289
2289
|
}
|
|
2290
|
+
async function ensureThemeRegistered(themeName) {
|
|
2291
|
+
const availableNames = themes.map((t) => typeof t === "string" ? t : t.name);
|
|
2292
|
+
const list = availableNames.includes(themeName) ? themes : themes.concat(themeName);
|
|
2293
|
+
const p = setThemeRegisterPromise(registerMonacoThemes(list, languages$1));
|
|
2294
|
+
if (p) await p;
|
|
2295
|
+
}
|
|
2290
2296
|
function hasVerticalScrollbar() {
|
|
2291
2297
|
if (!editorView) return false;
|
|
2292
2298
|
if (_hasScrollBar) return true;
|
|
@@ -2327,11 +2333,16 @@ function useMonaco(monacoOptions = {}) {
|
|
|
2327
2333
|
const ds = monacoOptions.onBeforeCreate(monaco_shim_exports);
|
|
2328
2334
|
if (ds) disposals.push(...ds);
|
|
2329
2335
|
}
|
|
2330
|
-
await setThemeRegisterPromise(registerMonacoThemes(themes, languages$1));
|
|
2331
2336
|
const initialThemeName = monacoOptions.theme ?? currentTheme.value;
|
|
2332
|
-
|
|
2337
|
+
await ensureThemeRegistered(initialThemeName);
|
|
2333
2338
|
editorMgr = new EditorManager(monacoOptions, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, monacoOptions.revealDebounceMs);
|
|
2334
2339
|
editorView = await editorMgr.createEditor(container, code, language, initialThemeName);
|
|
2340
|
+
lastAppliedTheme = initialThemeName;
|
|
2341
|
+
if (pendingUpdate && editorMgr) {
|
|
2342
|
+
const { code: queuedCode, lang: queuedLang } = pendingUpdate;
|
|
2343
|
+
pendingUpdate = null;
|
|
2344
|
+
editorMgr.updateCode(queuedCode, queuedLang);
|
|
2345
|
+
}
|
|
2335
2346
|
if (typeof monacoOptions.onThemeChange === "function") monacoOptions.onThemeChange(initialThemeName);
|
|
2336
2347
|
if (editorView) lastKnownCode = editorView.getValue();
|
|
2337
2348
|
return editorView;
|
|
@@ -2354,8 +2365,8 @@ function useMonaco(monacoOptions = {}) {
|
|
|
2354
2365
|
const ds = monacoOptions.onBeforeCreate(monaco_shim_exports);
|
|
2355
2366
|
if (ds) disposals.push(...ds);
|
|
2356
2367
|
}
|
|
2357
|
-
await setThemeRegisterPromise(registerMonacoThemes(themes, languages$1));
|
|
2358
2368
|
const initialThemeName = monacoOptions.theme ?? currentTheme.value;
|
|
2369
|
+
await ensureThemeRegistered(initialThemeName);
|
|
2359
2370
|
try {
|
|
2360
2371
|
monaco_shim_exports.editor.setTheme(initialThemeName);
|
|
2361
2372
|
lastAppliedTheme = initialThemeName;
|
package/dist/index.js
CHANGED
|
@@ -2055,8 +2055,8 @@ async function registerMonacoThemes(themes, languages$1) {
|
|
|
2055
2055
|
const highlighter = await getOrCreateHighlighter(themes, languages$1);
|
|
2056
2056
|
shikiToMonaco(highlighter, monaco_shim_exports);
|
|
2057
2057
|
themesRegistered = true;
|
|
2058
|
-
currentThemes = themes;
|
|
2059
|
-
currentLanguages = languages$1;
|
|
2058
|
+
currentThemes = themes.slice();
|
|
2059
|
+
currentLanguages = languages$1.slice();
|
|
2060
2060
|
return highlighter;
|
|
2061
2061
|
})();
|
|
2062
2062
|
setThemeRegisterPromise(p);
|
|
@@ -2259,6 +2259,12 @@ function useMonaco(monacoOptions = {}) {
|
|
|
2259
2259
|
console.warn("onThemeChange callback threw an error:", err);
|
|
2260
2260
|
}
|
|
2261
2261
|
}
|
|
2262
|
+
async function ensureThemeRegistered(themeName) {
|
|
2263
|
+
const availableNames = themes.map((t) => typeof t === "string" ? t : t.name);
|
|
2264
|
+
const list = availableNames.includes(themeName) ? themes : themes.concat(themeName);
|
|
2265
|
+
const p = setThemeRegisterPromise(registerMonacoThemes(list, languages$1));
|
|
2266
|
+
if (p) await p;
|
|
2267
|
+
}
|
|
2262
2268
|
function hasVerticalScrollbar() {
|
|
2263
2269
|
if (!editorView) return false;
|
|
2264
2270
|
if (_hasScrollBar) return true;
|
|
@@ -2299,11 +2305,16 @@ function useMonaco(monacoOptions = {}) {
|
|
|
2299
2305
|
const ds = monacoOptions.onBeforeCreate(monaco_shim_exports);
|
|
2300
2306
|
if (ds) disposals.push(...ds);
|
|
2301
2307
|
}
|
|
2302
|
-
await setThemeRegisterPromise(registerMonacoThemes(themes, languages$1));
|
|
2303
2308
|
const initialThemeName = monacoOptions.theme ?? currentTheme.value;
|
|
2304
|
-
|
|
2309
|
+
await ensureThemeRegistered(initialThemeName);
|
|
2305
2310
|
editorMgr = new EditorManager(monacoOptions, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, monacoOptions.revealDebounceMs);
|
|
2306
2311
|
editorView = await editorMgr.createEditor(container, code, language, initialThemeName);
|
|
2312
|
+
lastAppliedTheme = initialThemeName;
|
|
2313
|
+
if (pendingUpdate && editorMgr) {
|
|
2314
|
+
const { code: queuedCode, lang: queuedLang } = pendingUpdate;
|
|
2315
|
+
pendingUpdate = null;
|
|
2316
|
+
editorMgr.updateCode(queuedCode, queuedLang);
|
|
2317
|
+
}
|
|
2307
2318
|
if (typeof monacoOptions.onThemeChange === "function") monacoOptions.onThemeChange(initialThemeName);
|
|
2308
2319
|
if (editorView) lastKnownCode = editorView.getValue();
|
|
2309
2320
|
return editorView;
|
|
@@ -2326,8 +2337,8 @@ function useMonaco(monacoOptions = {}) {
|
|
|
2326
2337
|
const ds = monacoOptions.onBeforeCreate(monaco_shim_exports);
|
|
2327
2338
|
if (ds) disposals.push(...ds);
|
|
2328
2339
|
}
|
|
2329
|
-
await setThemeRegisterPromise(registerMonacoThemes(themes, languages$1));
|
|
2330
2340
|
const initialThemeName = monacoOptions.theme ?? currentTheme.value;
|
|
2341
|
+
await ensureThemeRegistered(initialThemeName);
|
|
2331
2342
|
try {
|
|
2332
2343
|
monaco_shim_exports.editor.setTheme(initialThemeName);
|
|
2333
2344
|
lastAppliedTheme = initialThemeName;
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stream-monaco",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"packageManager": "pnpm@10.24.0",
|
|
4
|
+
"version": "0.0.9",
|
|
6
5
|
"description": "A framework-agnostic library for integrating Monaco Editor with Shiki highlighting, optimized for streaming updates.",
|
|
7
6
|
"author": "Simon He",
|
|
8
7
|
"license": "MIT",
|
|
@@ -54,20 +53,6 @@
|
|
|
54
53
|
"files": [
|
|
55
54
|
"dist"
|
|
56
55
|
],
|
|
57
|
-
"scripts": {
|
|
58
|
-
"build": "tsdown",
|
|
59
|
-
"dev": "npm run build -- --watch src",
|
|
60
|
-
"format": "prettier --write --cache .",
|
|
61
|
-
"lint": "eslint . --cache",
|
|
62
|
-
"lint:fix": "pnpm run lint --fix",
|
|
63
|
-
"prepublishOnly": "nr build",
|
|
64
|
-
"release": "bumpp && npm publish",
|
|
65
|
-
"start": "esno src/index.ts",
|
|
66
|
-
"bench": "node scripts/stream-benchmark.mjs",
|
|
67
|
-
"bench:playwright": "node scripts/playwright-bench.mjs",
|
|
68
|
-
"test": "vitest",
|
|
69
|
-
"typecheck": "tsc --noEmit"
|
|
70
|
-
},
|
|
71
56
|
"peerDependencies": {
|
|
72
57
|
"monaco-editor": "^0.52.2"
|
|
73
58
|
},
|
|
@@ -96,5 +81,18 @@
|
|
|
96
81
|
"prettier --write --cache --ignore-unknown"
|
|
97
82
|
],
|
|
98
83
|
"*.{vue,js,ts,jsx,tsx,md,json}": "eslint --fix"
|
|
84
|
+
},
|
|
85
|
+
"scripts": {
|
|
86
|
+
"build": "tsdown",
|
|
87
|
+
"dev": "npm run build -- --watch src",
|
|
88
|
+
"format": "prettier --write --cache .",
|
|
89
|
+
"lint": "eslint . --cache",
|
|
90
|
+
"lint:fix": "pnpm run lint --fix",
|
|
91
|
+
"release": "bumpp && npm publish",
|
|
92
|
+
"start": "esno src/index.ts",
|
|
93
|
+
"bench": "node scripts/stream-benchmark.mjs",
|
|
94
|
+
"bench:playwright": "node scripts/playwright-bench.mjs",
|
|
95
|
+
"test": "vitest",
|
|
96
|
+
"typecheck": "tsc --noEmit"
|
|
99
97
|
}
|
|
100
|
-
}
|
|
98
|
+
}
|