Skip to content

Commit

Permalink
Merge pull request #53 from benrbray/benrbray/fix/typecheck-and-static
Browse files Browse the repository at this point in the history
[fix] invoke typecheck on build and fix default themes
  • Loading branch information
benrbray authored Jun 2, 2023
2 parents c3eac3f + c9fbe02 commit a0969eb
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 30 deletions.
2 changes: 2 additions & 0 deletions noteworthy-electron/electron.vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default defineConfig({
"@extensions" : resolve("src/extensions"),
'@main' : resolve('src/main'),
'@renderer' : resolve('src/renderer/src'),
'@resources' : resolve('resources'),
}
}
},
Expand All @@ -30,6 +31,7 @@ export default defineConfig({
'@main' : resolve('src/main'),
'@preload' : resolve('src/preload'),
'@renderer' : resolve('src/renderer/src'),
'@resources' : resolve('resources'),
}
},
plugins: [solid()]
Expand Down
4 changes: 2 additions & 2 deletions noteworthy-electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"build": "npm run typecheck && electron-vite build",
"postinstall": "electron-builder install-app-deps",
"build:win": "npm run build && electron-builder --win --config",
"build:mac": "electron-vite build && electron-builder --mac --config",
"build:linux": "electron-vite build && electron-builder --linux --config"
"build:mac": "npm run build && electron-builder --mac --config",
"build:linux": "npm run build && electron-builder --linux --config"
},
"dependencies": {
"@benrbray/mdast-util-cite": "^1.1.0",
Expand Down
16 changes: 2 additions & 14 deletions noteworthy-electron/src/common/extensions/noteworthy-extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NoteworthyExtensionApi } from "@renderer/extensions/extension-api";
import { NoteworthyExtensionApi } from "@common/extensions/extension-api";
import * as PS from "prosemirror-state";

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -27,19 +27,7 @@ type CommunityExtensionConfig = {
}

export interface CommunityExtensions {
ignore: number,
fooExtension: {
name: "fooExtension",
config: {
logger: (lang: string) => HTMLElement
}
},
barExtension: {
name: "barExtension"
},
bazExtension: {
name: string
}
// intentionally empty, to be extended by module declarations
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import AutocompleteExtension, { Autocomplete, AutocompleteProviders, SuggestData
* loaded dynamically at initialization time. (and perhaps watched for changes)
*/
import "./autocomplete.css"
import { NoteworthyExtensionApi } from "@renderer/extensions/extension-api";
import { NoteworthyExtensionApi } from "@common/extensions/extension-api";

export const autocompleteExtension: NoteworthyExtensionInitializer<Autocomplete.Name> = {
spec: extensionSpec,
Expand Down
29 changes: 17 additions & 12 deletions noteworthy-electron/src/main/theme/theme-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ import { EventEmitter } from "events";
import { FSAL } from "@main/fsal/fsal";
import { FsalEvents, ChokidarEvents } from "@common/events";

// defined by electron-webpack
declare const __static:string;
// @ts-ignore (vite asset)
import themeDefaultLight from "@resources/themes/theme-default-light.css?raw";
// @ts-ignore (vite asset)
import themeDefaultDark from "@resources/themes/theme-default-dark.css?raw";
// @ts-ignore (vite asset)
import themeAcademicLight from "@resources/themes/theme-academic-light.css?raw";
// @ts-ignore (vite asset)
import themeTypewriterLight from "@resources/themes/theme-typewriter-light.css?raw";


export enum ThemeEvent {
THEME_CHANGED = "theme-changed"
Expand All @@ -25,7 +32,7 @@ export enum ThemeEvent {
export type ThemeId = { type: "default", id:string } | { type: "custom", path:string };

export class ThemeService extends EventEmitter {
constructor(private _fsal: FSAL){
constructor(private _fsal: FSAL){
super();
this.initThemeFolder();
}
Expand Down Expand Up @@ -68,18 +75,16 @@ export class ThemeService extends EventEmitter {
// default vs custom themes
if(theme.type == "default"){
// find default theme
let themeCssPath:string = "";
let cssString:string = "";
switch(theme.id){
/** @todo (9/14/20) these should be defined elsewhere */
case "default-dark" : themeCssPath = pathlib.resolve(__static, 'themes/theme-default-dark.css'); break;
case "default-light" : themeCssPath = pathlib.resolve(__static, 'themes/theme-default-light.css'); break;
case "typewriter-light" : themeCssPath = pathlib.resolve(__static, 'themes/theme-typewriter-light.css'); break;
case "academic-light" : themeCssPath = pathlib.resolve(__static, 'themes/theme-academic-light.css'); break;
case "default-dark" : cssString = themeDefaultDark; break;
case "default-light" : cssString = themeDefaultLight; break;
case "typewriter-light" : cssString = themeTypewriterLight; break;
case "academic-light" : cssString = themeAcademicLight; break;
default: console.error(`theme '${theme.id}' not found`); return;
}

// read and apply theme
let cssString:string = await fs.readFile(themeCssPath, { encoding : 'utf8' });
this.emit(ThemeEvent.THEME_CHANGED, cssString);

// save theme to user settings
Expand Down Expand Up @@ -118,7 +123,7 @@ export class ThemeService extends EventEmitter {
let themeFolder = this.getThemeFolder();

let filePaths:string[] = [];
try {
try {
filePaths = await fs.readdir(themeFolder);
} catch(err){
console.error("themes folder does not exist\n", err);
Expand All @@ -132,4 +137,4 @@ export class ThemeService extends EventEmitter {
return ({ title: fileName, path: path })
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { NoteworthyExtension, NoteworthyExtensionInitializer, RegisteredExtensio
import codeMirrorPreviewExtension from "@extensions/noteworthy-codemirror-preview";
import tikzJaxExtension from "@extensions/noteworthy-tikzjax";
import autocompleteExtension from "@extensions/noteworthy-autocomplete";
import { NoteworthyExtensionApi } from "@renderer/extensions/extension-api";
import { NoteworthyExtensionApi } from "@common/extensions/extension-api";

////////////////////////////////////////////////////////////

Expand Down

0 comments on commit a0969eb

Please sign in to comment.