mirror of
https://github.com/ful1e5/Bibata_Cursor.git
synced 2025-05-28 14:04:22 -04:00
🚀 Cursors class init
This commit is contained in:
parent
82956fe5a3
commit
688317c390
1 changed files with 46 additions and 0 deletions
46
packages/core/src/Schema/Cursors.ts
Normal file
46
packages/core/src/Schema/Cursors.ts
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
|
export class Cursors {
|
||||||
|
constructor(private svgDir: string) {
|
||||||
|
if (!fs.existsSync(this.svgDir)) {
|
||||||
|
throw new Error(`🚨 .svg files not found in ${this.svgDir}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getStaticCursors(): string[] | null {
|
||||||
|
const cursorDir = path.resolve(this.svgDir, "static");
|
||||||
|
|
||||||
|
if (!fs.existsSync(cursorDir)) {
|
||||||
|
throw new Error("🚨 Static Cursors directory not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
const staticCursors = fs
|
||||||
|
.readdirSync(cursorDir)
|
||||||
|
.map((f) => path.resolve(cursorDir, f));
|
||||||
|
|
||||||
|
if (staticCursors.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return staticCursors;
|
||||||
|
}
|
||||||
|
|
||||||
|
getAnimatedCursors(): string[] | null {
|
||||||
|
const cursorDir = path.resolve(this.svgDir, "animated");
|
||||||
|
|
||||||
|
if (!fs.existsSync(cursorDir)) {
|
||||||
|
throw new Error("🚨 Animated Cursors directory not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
const animatedCursors = fs
|
||||||
|
.readdirSync(cursorDir)
|
||||||
|
.map((f) => path.resolve(cursorDir, f));
|
||||||
|
|
||||||
|
if (animatedCursors.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return animatedCursors;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue