diff --git a/esbuild.config.mjs b/esbuild.config.mjs index 73f0deb..2906811 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -1,6 +1,6 @@ import esbuild from "esbuild"; import process from "process"; -import builtins from "builtin-modules"; +import { builtinModules } from "node:module"; const banner = `/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD @@ -28,7 +28,8 @@ const context = await esbuild.context({ "@lezer/common", "@lezer/highlight", "@lezer/lr", - ...builtins, + ...builtinModules, + ...builtinModules.map((m) => `node:${m}`), ], format: "cjs", target: "es2018", diff --git a/main.ts b/main.ts index 7d9ccaa..b18a8da 100644 --- a/main.ts +++ b/main.ts @@ -62,7 +62,9 @@ export default class PracticePlannerPlugin extends Plugin { } async loadSettings() { - this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); + const data = + (await this.loadData()) as Partial | null; + this.settings = Object.assign({}, DEFAULT_SETTINGS, data); } async saveSettings() { @@ -238,9 +240,9 @@ class PracticePlannerSettingTab extends PluginSettingTab { text .setPlaceholder("Practice") .setValue(this.plugin.settings.folderPath) - .onChange(async (value) => { + .onChange((value) => { this.plugin.settings.folderPath = value || "Practice"; - await this.plugin.saveSettings(); + void this.plugin.saveSettings(); }), ); @@ -250,18 +252,22 @@ class PracticePlannerSettingTab extends PluginSettingTab { "First day of the practice week. Weeks that cross into a new year are stored under the year they started.", ) .addDropdown((dd) => { - DAY_NAMES.forEach((name, i) => dd.addOption(String(i), name)); + DAY_NAMES.forEach((name, i) => { + dd.addOption(String(i), name); + }); dd.setValue(String(this.plugin.settings.weekStartDay)); - dd.onChange(async (value) => { + dd.onChange((value) => { this.plugin.settings.weekStartDay = Number(value) as DayIndex; - await this.plugin.saveSettings(); + void this.plugin.saveSettings(); }); }); - this.renderSkills(containerEl); + this.renderSkills(containerEl.createDiv()); } private renderSkills(containerEl: HTMLElement): void { + containerEl.empty(); + new Setting(containerEl) .setName("Default skills") .setDesc("Rows used in each new week's skill table. Edit a name inline, remove a skill, add new ones, or reset to the built-in defaults.") @@ -272,18 +278,18 @@ class PracticePlannerSettingTab extends PluginSettingTab { text .setPlaceholder("Skill name") .setValue(skill) - .onChange(async (value) => { + .onChange((value) => { this.plugin.settings.skills[index] = value.trim(); - await this.plugin.saveSettings(); + void this.plugin.saveSettings(); }); }).addExtraButton((btn) => { btn .setIcon("trash") .setTooltip("Remove skill") - .onClick(async () => { + .onClick(() => { this.plugin.settings.skills.splice(index, 1); - await this.plugin.saveSettings(); - this.display(); + void this.plugin.saveSettings(); + this.renderSkills(containerEl); }); }); }); @@ -292,20 +298,20 @@ class PracticePlannerSettingTab extends PluginSettingTab { .addButton((btn) => { btn .setButtonText("Add skill") - .onClick(async () => { + .onClick(() => { this.plugin.settings.skills.push(""); - await this.plugin.saveSettings(); - this.display(); + void this.plugin.saveSettings(); + this.renderSkills(containerEl); }); }) .addButton((btn) => { btn .setButtonText("Reset to default") .setCta() - .onClick(async () => { + .onClick(() => { this.plugin.settings.skills = [...DEFAULT_SETTINGS.skills]; - await this.plugin.saveSettings(); - this.display(); + void this.plugin.saveSettings(); + this.renderSkills(containerEl); }); }); } diff --git a/manifest.json b/manifest.json index 12ee49e..1dfbfeb 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "id": "practice-planner", "name": "Weekly Music Practice Planner", "version": "0.1.1", - "minAppVersion": "0.15.0", + "minAppVersion": "1.4.0", "description": "Plan and track weekly music practice: per-skill progress by day, plus per-day notes.", "author": "Patrick Driggett", "authorUrl": "", diff --git a/package-lock.json b/package-lock.json index 6e90a40..c0a1b7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,6 @@ "@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.28.1", "obsidian": "latest", "tslib": "2.4.0", @@ -1003,19 +1002,6 @@ "node": ">=8" } }, - "node_modules/builtin-modules": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", - "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", diff --git a/package.json b/package.json index f4bf237..b3a05e5 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "@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.28.1", "obsidian": "latest", "tslib": "2.4.0",