mirror of
https://github.com/svm0n/datadeck.git
synced 2026-07-22 08:31:46 +00:00
Obsidian's automated plugin review flagged this release: inline style mutations instead of CSS classes, unsafe innerHTML writes, async callbacks passed where a void return was expected, and a couple of real bugs the review's style checks happened to surface along the way. - Replace `.style.*` assignments with CSS classes (`is-hidden` etc.); the two genuinely dynamic textarea-autosize resets use `removeProperty` instead. - Replace innerHTML writes (map SVG injection, dashboard stat bars, legend, refresh button) with DOMParser/createEl/appendText. - Embed world-map.svg into main.js via an esbuild text-loader import instead of reading it from the plugin's vault folder at runtime — Obsidian's installer only ever fetches main.js/styles.css/manifest.json from a release, so the travel map was silently broken for any Community Plugins install (only worked for manual/BRAT installs that copied the extra file). - Replace window.confirm() on delete with the same two-click "Confirm?" button pattern already used elsewhere in the plugin (native confirm() doesn't behave reliably on mobile Obsidian). - Settings tab: use Setting().setHeading() instead of raw <h2>/<h3>, drop the redundant plugin-name heading, wrap async onChange/click handlers so they don't return unhandled promises. - MarkdownRenderChild subclasses (chart/inline-view/tasks blocks): onload() must be synchronous per Component's contract; move the async work inside instead of marking onload itself async. - Misc: unused imports/vars, unnecessary type assertions (two of which were actually needed — restored with `querySelector<HTMLElement>` instead of a blind cast), sentence-case UI text, template-literal error interpolation on caught `unknown` values. - Add eslint + eslint-plugin-obsidianmd as a permanent dev dependency (`npm run lint`, wired into `npm run check`) so these surface locally before the next review instead of after. 114 → 112 existing tests still pass (2 net-added assertions from the DOM shim gaining appendText/DOMParser polyfills); typecheck and build clean. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tfyt1TBd7DiNic32s6E4nq
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
import esbuild from "esbuild";
|
|
|
|
const isWatch = process.argv.includes("--watch");
|
|
|
|
// Watch builds skip minification so source maps and identifiers stay readable
|
|
// in the devtools. Production builds minify — biggest single size win we have
|
|
// (about 50% on the SheetJS-heavy bundle).
|
|
// Build-time timestamp injected into the bundle. Lets a tiny "Built: …"
|
|
// menu entry in the plugin show the user which build they're actually
|
|
// running — useful on mobile where sync of the deployed bundle can lag
|
|
// behind the desktop build and there's no obvious way to confirm the new
|
|
// code arrived. Format: "YYYY-MM-DD HH:mm" in local time.
|
|
const now = new Date();
|
|
const pad = (n) => String(n).padStart(2, "0");
|
|
const buildTime = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}`;
|
|
|
|
const buildOptions = {
|
|
entryPoints: ["main.ts"],
|
|
bundle: true,
|
|
external: ["obsidian"],
|
|
format: "cjs",
|
|
target: "es2018",
|
|
outfile: "main.js",
|
|
sourcemap: isWatch ? "inline" : false,
|
|
minify: !isWatch,
|
|
logLevel: "info",
|
|
loader: { ".svg": "text" },
|
|
define: {
|
|
__BUILD_TIME__: JSON.stringify(buildTime),
|
|
},
|
|
};
|
|
|
|
if (isWatch) {
|
|
const ctx = await esbuild.context(buildOptions);
|
|
await ctx.watch();
|
|
console.log("Watching for changes...");
|
|
} else {
|
|
await esbuild.build(buildOptions);
|
|
}
|