Skip to content

Commit

Permalink
Upgrade libs and fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed Aug 24, 2024
1 parent 5cbf4e7 commit f26cfa0
Show file tree
Hide file tree
Showing 26 changed files with 538 additions and 579 deletions.
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
};
49 changes: 49 additions & 0 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";

const banner =
`/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;

const prod = (process.argv[2] === "production");

const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ["src/main.ts"],
bundle: true,
external: [
"obsidian",
"electron",
"@codemirror/autocomplete",
"@codemirror/collab",
"@codemirror/commands",
"@codemirror/language",
"@codemirror/lint",
"@codemirror/search",
"@codemirror/state",
"@codemirror/view",
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
...builtins],
format: "cjs",
target: "es2018",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: "main.js",
minify: prod,
});

if (prod) {
await context.rebuild();
process.exit(0);
} else {
await context.watch();
}
6 changes: 6 additions & 0 deletions main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 21 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,41 @@
"description": "Offers controls for adjusting theme, plugin, and CSS snippet styles.",
"main": "main.js",
"scripts": {
"dev": "rollup --config rollup.config.js -w",
"build": "rollup --config rollup.config.js --environment BUILD:production",
"prettier": "prettier --write \"./src/**/*.{ts,tsx}\"",
"lint": "eslint ./src",
"lint:fix": "eslint ./src --fix",
"clean": "yarn prettier && yarn lint:fix",
"rlnotes": "git log $(git describe --tags --abbrev=0)..HEAD --oneline > release-notes.md && git add release-notes.md",
"bump": "node version-bump.mjs && git add manifest.json versions.json package.json && yarn rlnotes",
"typecheck": "tsc --noemit",
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"lint": "eslint ./src",
"lint:fix": "eslint ./src/**/*.ts --fix",
"prettier": "prettier --write \"./src/**/*.{ts,tsx}\"",
"clean": "yarn prettier && yarn lint:fix",
"rlnotes": "git log $(git describe --tags --abbrev=0)..HEAD --oneline > release-notes.md && git add release-notes.md",
"bump": "node version-bump.mjs && git add manifest.json versions.json && yarn rlnotes",
"release": "git commit -m $npm_package_version && git tag $npm_package_version && git push && git push --tags"
},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-typescript": "^6.0.0",
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
"@types/node": "^14.14.2",
"eslint": "^8.33.0",
"obsidian": "^1.1.1",
"prettier": "^2.8.3",
"rollup": "^2.32.1",
"tslib": "^2.0.3",
"typescript": "^4.0.3"
"@trivago/prettier-plugin-sort-imports": "4.2.0",
"@types/node": "16.11.6",
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
"builtin-modules": "3.3.0",
"esbuild": "0.17.3",
"eslint": "8.47.0",
"obsidian": "latest",
"prettier": "3.0.2",
"tslib": "2.4.0",
"typescript": "4.7.4"
},
"dependencies": {
"@simonwep/pickr": "https://github.com/nothingislost/pickr/archive/a17739f7aa1871b44da778cbb79ae76dae77d839.tar.gz",
"@types/chroma-js": "^2.1.3",
"@types/js-yaml": "^4.0.3",
"@typescript-eslint/eslint-plugin": "^5.50.0",
"@typescript-eslint/parser": "^5.50.0",
"chroma-js": "^2.1.2",
"detect-indent": "^7.0.0",
"dotenv": "^10.0.0",
"fuzzysort": "^2.0.4",
"js-yaml": "^4.1.0",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-css-only": "^3.1.0"
"js-yaml": "^4.1.0"
}
}
34 changes: 0 additions & 34 deletions rollup.config.js

This file was deleted.

8 changes: 7 additions & 1 deletion src/ImportModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,19 @@ export class ImportModal extends Modal {
(importInput) => {
// Set up a FileReader so we can parse the file contents
importInput.addEventListener('change', (e) => {
if (!e.target) return;

const reader = new FileReader();

reader.onload = async (e: ProgressEvent<FileReader>) => {
if (!e.target?.result) return;
await importAndClose(e.target.result.toString().trim());
};

reader.readAsText((e.target as HTMLInputElement).files[0]);
const target = e.target as HTMLInputElement;
if (target.files) {
reader.readAsText(target.files[0]);
}
});
}
);
Expand Down
34 changes: 18 additions & 16 deletions src/SettingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,24 +268,26 @@ function getCSSVariables(
const color =
value !== undefined ? value.toString() : colorSetting.default;

vars.push(
...generateColorVariables(
if (color) {
vars.push(
...generateColorVariables(
setting.id,
colorSetting.format,
color,
colorSetting.opacity,
colorSetting['alt-format']
)
);

generateColorVariables(
setting.id,
colorSetting.format,
'rgb',
color,
colorSetting.opacity,
colorSetting['alt-format']
)
);

generateColorVariables(
setting.id,
'rgb',
color,
colorSetting.opacity
).forEach((kv) => {
gradientCandidates[kv.key] = kv.value;
});
colorSetting.opacity
).forEach((kv) => {
gradientCandidates[kv.key] = kv.value;
});
}

continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function getTitle<T extends Meta>(config: T): string {
return config.title;
}

export function getDescription<T extends Meta>(config: T): string {
export function getDescription<T extends Meta>(config: T): string | undefined {
if (lang) {
return (
config[`description.${lang}` as keyof WithDescription] ||
Expand Down
2 changes: 1 addition & 1 deletion src/lang/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { uk } from './locale/uk';
import { zh } from './locale/zh';
import { zhTw } from './locale/zhTw';

export const lang: string = window.localStorage.getItem('language');
export const lang: string | null = window.localStorage.getItem('language');

const localeMap: { [k: string]: Partial<typeof en> } = {
ar,
Expand Down
Loading

0 comments on commit f26cfa0

Please sign in to comment.