diff --git a/package-lock.json b/package-lock.json index 5351efd309873..debab5b4edba5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@microsoft/1ds-post-js": "^3.2.13", "@parcel/watcher": "parcel-bundler/watcher#1ca032aa8339260a8a3bcf825c3a1a71e3e43542", "@types/semver": "^7.5.8", + "@vscode/codicons": "^0.0.43", "@vscode/deviceid": "^0.1.1", "@vscode/iconv-lite-umd": "0.7.1", "@vscode/policy-watcher": "^1.3.2", @@ -2625,6 +2626,12 @@ "win32" ] }, + "node_modules/@vscode/codicons": { + "version": "0.0.43", + "resolved": "https://registry.npmjs.org/@vscode/codicons/-/codicons-0.0.43.tgz", + "integrity": "sha512-8sf8WOBoZkyUi8ogCm5ycHJJGhwOEG3E9b64+JIx+m6bCExdkc30VwCwr94cXUU1opmRD0CTCWLcN46I8WLJIg==", + "license": "CC-BY-4.0" + }, "node_modules/@vscode/deviceid": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@vscode/deviceid/-/deviceid-0.1.1.tgz", diff --git a/package.json b/package.json index ccc9212544e9f..04f75f04a01f7 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,7 @@ "@microsoft/1ds-post-js": "^3.2.13", "@parcel/watcher": "parcel-bundler/watcher#1ca032aa8339260a8a3bcf825c3a1a71e3e43542", "@types/semver": "^7.5.8", + "@vscode/codicons": "^0.0.43", "@vscode/deviceid": "^0.1.1", "@vscode/iconv-lite-umd": "0.7.1", "@vscode/policy-watcher": "^1.3.2", diff --git a/src/vs/base/browser/ui/codicons/codicon/codicon.css b/src/vs/base/browser/ui/codicons/codicon/codicon.css index 02154e77b6895..887a327b232b8 100644 --- a/src/vs/base/browser/ui/codicons/codicon/codicon.css +++ b/src/vs/base/browser/ui/codicons/codicon/codicon.css @@ -3,12 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -@font-face { - font-family: "codicon"; - font-display: block; - src: url("./codicon.ttf?5d4d76ab2ce5108968ad644d591a16a6") format("truetype"); -} - .codicon[class*='codicon-'] { font: normal normal normal 16px/1 codicon; display: inline-block; diff --git a/src/vs/editor/standalone/browser/standaloneThemeService.ts b/src/vs/editor/standalone/browser/standaloneThemeService.ts index 0ef9470da842a..2208ff26d8acf 100644 --- a/src/vs/editor/standalone/browser/standaloneThemeService.ts +++ b/src/vs/editor/standalone/browser/standaloneThemeService.ts @@ -245,8 +245,8 @@ export class StandaloneThemeService extends Disposable implements IStandaloneThe this._knownThemes.set(VS_DARK_THEME_NAME, newBuiltInTheme(VS_DARK_THEME_NAME)); this._knownThemes.set(HC_BLACK_THEME_NAME, newBuiltInTheme(HC_BLACK_THEME_NAME)); this._knownThemes.set(HC_LIGHT_THEME_NAME, newBuiltInTheme(HC_LIGHT_THEME_NAME)); - - const iconsStyleSheet = this._register(getIconsStyleSheet(this)); + this._environment.isBuilt = false; + const iconsStyleSheet = this._register(getIconsStyleSheet(this, this._environment)); this._codiconCSS = iconsStyleSheet.getCSS(); this._themeCSS = ''; diff --git a/src/vs/platform/theme/browser/iconsStyleSheet.ts b/src/vs/platform/theme/browser/iconsStyleSheet.ts index 7215f066d452a..e7712b97165fa 100644 --- a/src/vs/platform/theme/browser/iconsStyleSheet.ts +++ b/src/vs/platform/theme/browser/iconsStyleSheet.ts @@ -3,10 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { canASAR } from '../../../amdX.js'; import * as css from '../../../base/browser/cssValue.js'; import { Emitter, Event } from '../../../base/common/event.js'; import { DisposableStore, IDisposable } from '../../../base/common/lifecycle.js'; +import { AppResourcePath, FileAccess, nodeModulesAsarUnpackedPath, nodeModulesPath } from '../../../base/common/network.js'; import { ThemeIcon } from '../../../base/common/themables.js'; +import { IEnvironmentService } from '../../environment/common/environment.js'; import { getIconRegistry, IconContribution, IconFontDefinition } from '../common/iconRegistry.js'; import { IProductIconTheme, IThemeService } from '../common/themeService.js'; @@ -15,7 +18,11 @@ export interface IIconsStyleSheet extends IDisposable { readonly onDidChange: Event; } -export function getIconsStyleSheet(themeService: IThemeService | undefined): IIconsStyleSheet { +export function getModuleLocation(environmentService: IEnvironmentService): AppResourcePath { + return `${(canASAR && environmentService.isBuilt) ? nodeModulesAsarUnpackedPath : nodeModulesPath}/@vscode/codicons/dist/codicon.ttf`; +} + +export function getIconsStyleSheet(themeService: IThemeService | undefined, environmentService: IEnvironmentService): IIconsStyleSheet { const disposable = new DisposableStore(); const onDidChangeEmmiter = disposable.add(new Emitter()); @@ -34,6 +41,7 @@ export function getIconsStyleSheet(themeService: IThemeService | undefined): IIc const rules = new css.Builder(); const rootAttribs = new css.Builder(); + rules.push(css.inline`@font-face { font-family: "codicon"; font-display: block; src: ${css.asCSSUrl(FileAccess.asFileUri(getModuleLocation(environmentService)).with({ query: '5d4d76ab2ce5108968ad644d591a16a6' }))} format("truetype");}`); for (const contribution of iconRegistry.getIcons()) { const definition = productIconTheme.getIcon(contribution); if (!definition) { diff --git a/src/vs/workbench/contrib/issue/browser/baseIssueReporterService.ts b/src/vs/workbench/contrib/issue/browser/baseIssueReporterService.ts index d7d14153f59e5..91ece6cc6ff64 100644 --- a/src/vs/workbench/contrib/issue/browser/baseIssueReporterService.ts +++ b/src/vs/workbench/contrib/issue/browser/baseIssueReporterService.ts @@ -32,6 +32,7 @@ import { IIssueFormService, IssueReporterData, IssueReporterExtensionData, Issue import { normalizeGitHubUrl } from '../common/issueReporterUtil.js'; import { IssueReporterModel, IssueReporterData as IssueReporterModelData } from './issueReporterModel.js'; import { IAuthenticationService } from '../../../services/authentication/common/authentication.js'; +import { IEnvironmentService } from '../../../../platform/environment/common/environment.js'; const MAX_URL_LENGTH = 7500; @@ -92,7 +93,8 @@ export class BaseIssueReporterService extends Disposable { @IFileDialogService public readonly fileDialogService: IFileDialogService, @IContextMenuService public readonly contextMenuService: IContextMenuService, @IAuthenticationService public readonly authenticationService: IAuthenticationService, - @IOpenerService public readonly openerService: IOpenerService + @IOpenerService public readonly openerService: IOpenerService, + @IEnvironmentService private readonly environmentService: IEnvironmentService ) { super(); const targetExtension = data.extensionId ? data.enabledExtensions.find(extension => extension.id.toLocaleLowerCase() === data.extensionId?.toLocaleLowerCase()) : undefined; @@ -175,7 +177,7 @@ export class BaseIssueReporterService extends Disposable { const codiconStyleSheet = createStyleSheet(); codiconStyleSheet.id = 'codiconStyles'; - const iconsStyleSheet = this._register(getIconsStyleSheet(this.themeService)); + const iconsStyleSheet = this._register(getIconsStyleSheet(this.themeService, this.environmentService)); function updateAll() { codiconStyleSheet.textContent = iconsStyleSheet.getCSS(); } diff --git a/src/vs/workbench/contrib/issue/browser/issueReporterService.ts b/src/vs/workbench/contrib/issue/browser/issueReporterService.ts index fd4a56d64b778..65e4b756ea6af 100644 --- a/src/vs/workbench/contrib/issue/browser/issueReporterService.ts +++ b/src/vs/workbench/contrib/issue/browser/issueReporterService.ts @@ -6,6 +6,7 @@ import { IProductConfiguration } from '../../../../base/common/product.js'; import { localize } from '../../../../nls.js'; import { IContextMenuService } from '../../../../platform/contextview/browser/contextView.js'; import { IFileDialogService } from '../../../../platform/dialogs/common/dialogs.js'; +import { IEnvironmentService } from '../../../../platform/environment/common/environment.js'; import { IFileService } from '../../../../platform/files/common/files.js'; import { IOpenerService } from '../../../../platform/opener/common/opener.js'; import { IThemeService } from '../../../../platform/theme/common/themeService.js'; @@ -33,9 +34,10 @@ export class IssueWebReporter extends BaseIssueReporterService { @IFileDialogService fileDialogService: IFileDialogService, @IContextMenuService contextMenuService: IContextMenuService, @IAuthenticationService authenticationService: IAuthenticationService, - @IOpenerService openerService: IOpenerService + @IOpenerService openerService: IOpenerService, + @IEnvironmentService environmentService: IEnvironmentService ) { - super(disableExtensions, data, os, product, window, true, issueFormService, themeService, fileService, fileDialogService, contextMenuService, authenticationService, openerService); + super(disableExtensions, data, os, product, window, true, issueFormService, themeService, fileService, fileDialogService, contextMenuService, authenticationService, openerService, environmentService); // eslint-disable-next-line no-restricted-syntax const target = this.window.document.querySelector('.block-system .block-info'); diff --git a/src/vs/workbench/contrib/issue/electron-browser/issueReporterService.ts b/src/vs/workbench/contrib/issue/electron-browser/issueReporterService.ts index 94230a89c7f13..2bd8d3d032fc5 100644 --- a/src/vs/workbench/contrib/issue/electron-browser/issueReporterService.ts +++ b/src/vs/workbench/contrib/issue/electron-browser/issueReporterService.ts @@ -25,6 +25,7 @@ import { IAuthenticationService } from '../../../services/authentication/common/ import { BaseIssueReporterService } from '../browser/baseIssueReporterService.js'; import { IssueReporterData as IssueReporterModelData } from '../browser/issueReporterModel.js'; import { IIssueFormService, IssueReporterData, IssueType } from '../common/issue.js'; +import { IEnvironmentService } from '../../../../platform/environment/common/environment.js'; // GitHub has let us know that we could up our limit here to 8k. We chose 7500 to play it safe. // ref https://github.com/microsoft/vscode/issues/159191 @@ -57,9 +58,10 @@ export class IssueReporter extends BaseIssueReporterService { @IContextKeyService contextKeyService: IContextKeyService, @IContextMenuService contextMenuService: IContextMenuService, @IAuthenticationService authenticationService: IAuthenticationService, - @IOpenerService openerService: IOpenerService + @IOpenerService openerService: IOpenerService, + @IEnvironmentService environmentService: IEnvironmentService ) { - super(disableExtensions, data, os, product, window, false, issueFormService, themeService, fileService, fileDialogService, contextMenuService, authenticationService, openerService); + super(disableExtensions, data, os, product, window, false, issueFormService, themeService, fileService, fileDialogService, contextMenuService, authenticationService, openerService, environmentService); this.processService = processService; this.processService.getSystemInfo().then(info => { this.issueReporterModel.update({ systemInfo: info }); diff --git a/src/vs/workbench/services/themes/browser/workbenchThemeService.ts b/src/vs/workbench/services/themes/browser/workbenchThemeService.ts index 1440fbb3cce24..29b738c65fbb5 100644 --- a/src/vs/workbench/services/themes/browser/workbenchThemeService.ts +++ b/src/vs/workbench/services/themes/browser/workbenchThemeService.ts @@ -179,7 +179,7 @@ export class WorkbenchThemeService extends Disposable implements IWorkbenchTheme const codiconStyleSheet = createStyleSheet(); codiconStyleSheet.id = 'codiconStyles'; - const iconsStyleSheet = this._register(getIconsStyleSheet(this)); + const iconsStyleSheet = this._register(getIconsStyleSheet(this, this.environmentService)); function updateAll() { codiconStyleSheet.textContent = iconsStyleSheet.getCSS(); }