chore: migrate plugin source to TypeScript scaffold

This commit is contained in:
Chenyan Wang 2026-05-03 18:39:58 +08:00
parent 81f659b6f9
commit 05df8187bc
7 changed files with 2402 additions and 1 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
node_modules/
.DS_Store

View file

@ -54,11 +54,25 @@ After approval and publication, install Smart Folder View from Obsidian's Commun
## Development Notes
- Runtime entry: `main.js`
- Source entry: `src/main.ts`
- Build output: `main.js`
- Release metadata: `manifest.json`
- Version compatibility map: `versions.json`
- Local state file: `data.json` (not a release asset)
### Build
```bash
npm install
npm run build
```
### Watch mode
```bash
npm run dev
```
## Release Checklist
1. Update `manifest.json` version and minimum compatible Obsidian version.

22
esbuild.config.mjs Normal file
View file

@ -0,0 +1,22 @@
import esbuild from "esbuild";
const prod = process.argv[2] === "production";
const context = await esbuild.context({
entryPoints: ["src/main.ts"],
bundle: true,
external: ["obsidian"],
format: "cjs",
target: "es2020",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: "main.js",
});
if (prod) {
await context.rebuild();
await context.dispose();
} else {
await context.watch();
}

23
package.json Normal file
View file

@ -0,0 +1,23 @@
{
"name": "smart-folder-view",
"version": "0.1.0",
"description": "Interactive folder dashboard with timeline and board views, filters, drag sorting, and saved page presets.",
"main": "main.js",
"scripts": {
"build": "node esbuild.config.mjs production",
"dev": "node esbuild.config.mjs",
"version": "node version-bump.mjs && git add manifest.json versions.json package.json"
},
"keywords": [
"obsidian",
"obsidian-plugin"
],
"author": "cyanwang",
"license": "MIT",
"devDependencies": {
"esbuild": "^0.25.4",
"obsidian": "latest",
"tslib": "^2.8.1",
"typescript": "^5.8.3"
}
}

2299
src/main.ts Normal file

File diff suppressed because it is too large Load diff

22
tsconfig.json Normal file
View file

@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "ES2020",
"lib": [
"DOM",
"ES2020"
],
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": false,
"allowJs": false,
"esModuleInterop": true,
"skipLibCheck": true,
"sourceMap": true,
"inlineSources": true,
"resolveJsonModule": true,
"types": []
},
"include": [
"src/**/*.ts"
]
}

19
version-bump.mjs Normal file
View file

@ -0,0 +1,19 @@
import fs from "fs";
const manifestPath = "manifest.json";
const versionsPath = "versions.json";
const packagePath = "package.json";
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
const versions = JSON.parse(fs.readFileSync(versionsPath, "utf8"));
const pkg = JSON.parse(fs.readFileSync(packagePath, "utf8"));
if (!manifest.version || !manifest.minAppVersion) {
throw new Error("manifest.json must include version and minAppVersion");
}
versions[manifest.version] = manifest.minAppVersion;
pkg.version = manifest.version;
fs.writeFileSync(versionsPath, JSON.stringify(versions, null, 2) + "\n");
fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 2) + "\n");