@codingame/monaco-vscode-theme-service-override 34.0.2 → 34.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-theme-service-override",
3
- "version": "34.0.2",
3
+ "version": "34.1.0",
4
4
  "private": false,
5
5
  "description": "VSCode public API plugged on the monaco editor - theme service-override",
6
6
  "keywords": [],
@@ -15,8 +15,8 @@
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "@codingame/monaco-vscode-api": "34.0.2",
19
- "@codingame/monaco-vscode-files-service-override": "34.0.2"
18
+ "@codingame/monaco-vscode-api": "34.1.0",
19
+ "@codingame/monaco-vscode-files-service-override": "34.1.0"
20
20
  },
21
21
  "main": "index.js",
22
22
  "module": "index.js",
@@ -18,7 +18,7 @@ import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/even
18
18
  import { registerFileIconThemeSchemas } from '../common/fileIconThemeSchema.js';
19
19
  import { Disposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
20
20
  import { FileIconThemeData, FileIconThemeLoader } from './fileIconThemeData.js';
21
- import { createStyleSheet } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/domStylesheets';
21
+ import { createStyleSheet, shadowRootContainer } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/domStylesheets';
22
22
  import { IBrowserWorkbenchEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/browser/environmentService.service';
23
23
  import { FileChangeType } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
24
24
  import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
@@ -799,8 +799,26 @@ class ThemeFileWatcher {
799
799
  this.watchedLocation = undefined;
800
800
  }
801
801
  }
802
+ const injectedFontFaces = ( new Set());
803
+ function injectFontFacesInHead(styleSheetContent) {
804
+ const sheet = new mainWindow.CSSStyleSheet();
805
+ sheet.replaceSync(styleSheetContent);
806
+ const fontFaces = ( Array.from(sheet.cssRules).filter(rule => rule instanceof mainWindow.CSSFontFaceRule).map(r => r.cssText));
807
+ const missingFontFaces = fontFaces.filter(fontFace => !( injectedFontFaces.has(fontFace)));
808
+ if (missingFontFaces.length > 0) {
809
+ const fontFaceStyleSheet = new mainWindow.CSSStyleSheet();
810
+ for (const fontFace of missingFontFaces) {
811
+ fontFaceStyleSheet.insertRule(fontFace);
812
+ }
813
+ mainWindow.document.adoptedStyleSheets = [...mainWindow.document.adoptedStyleSheets, fontFaceStyleSheet];
814
+ }
815
+ }
802
816
  function _applyRules(styleSheetContent, rulesClassName) {
803
- const themeStyles = mainWindow.document.head.querySelectorAll(`.${rulesClassName}`);
817
+ if (shadowRootContainer) {
818
+ injectFontFacesInHead(styleSheetContent);
819
+ }
820
+ const container = shadowRootContainer ?? mainWindow.document.head;
821
+ const themeStyles = container.querySelectorAll(`.${rulesClassName}`);
804
822
  if (themeStyles.length === 0) {
805
823
  const elStyle = createStyleSheet();
806
824
  elStyle.className = rulesClassName;