Squashed commit of the following:

commit aa38adaa89
Author: The Phrench Frog <phrog123@icloud.com>
Date:   Sun Jan 26 01:10:43 2025 -0500

    Delete src directory

commit 8277107e6f
Author: The Phrench Frog <phrog123@icloud.com>
Date:   Sun Jan 26 00:49:15 2025 -0500

    2.6.1

    fixed

commit 06751f1ca1
Author: The Phrench Frog <phrog123@icloud.com>
Date:   Sat Jan 25 23:33:56 2025 -0500

    Add files via upload

commit a8fea95e68
Author: The Phrench Frog <phrog123@icloud.com>
Date:   Sat Jan 25 23:28:30 2025 -0500

    renamed .ts to .js

    why is brat now allowing for .ts files?

commit 9b71655e47
Author: The Phrench Frog <phrog123@icloud.com>
Date:   Sat Jan 25 23:17:49 2025 -0500

    Update Main.ts take 2

    wrong character for '

commit a0ca62c2ae
Author: The Phrench Frog <phrog123@icloud.com>
Date:   Sat Jan 25 23:07:34 2025 -0500

    Fix UI for 2.6.0

    2.6.0 no longer uses Screen Mirroring but 'Browse and Access'.
This commit is contained in:
The Phrench Frog 2025-01-26 01:20:56 -05:00
parent 5fc4afbf56
commit e42b85d28e
3 changed files with 0 additions and 171 deletions

View file

@ -1,122 +0,0 @@
import { App, SuggestModal, Notice, MarkdownView } from 'obsidian';
import { SupernotePluginSettings } from './main';
interface SupernoteFile {
name: string;
size: number;
date: string;
uri: string;
extension: string;
isDirectory: boolean;
}
interface SupernoteResponse {
deviceName: string;
fileList: SupernoteFile[];
routeList: { name: string; path: string; }[];
totalByteSize: number;
totalMemory: number;
usedMemory: number;
}
export class FileListModal extends SuggestModal<SupernoteFile> {
settings: SupernotePluginSettings;
files: SupernoteFile[] = [];
currentPath: string = '/';
constructor(app: App, settings: SupernotePluginSettings) {
super(app);
this.settings = settings;
this.setPlaceholder("Select a file to download or directory to open");
}
private async loadFiles() {
try {
const response = await fetch(`http://${this.settings.mirrorIP}:8089${this.currentPath}`);
if (!response.ok) {
throw new Error(`Failed to fetch file list: ${response.statusText}`);
}
const html = await response.text();
// Extract the JSON data from the script tag
const match = html.match(/const json = '(.+?)'/);
if (!match) {
throw new Error("Could not find file list data");
}
const data: SupernoteResponse = JSON.parse(match[1]);
this.files = data.fileList;
} catch (err) {
new Notice(`Failed to load files: ${err.message}`);
this.close();
}
}
async getSuggestions(query: string): Promise<SupernoteFile[]> {
if (this.files.length === 0) {
await this.loadFiles();
}
return this.files.filter(file =>
file.name.toLowerCase().includes(query.toLowerCase())
);
}
renderSuggestion(file: SupernoteFile, el: HTMLElement) {
const container = el.createDiv({ cls: "suggestion-item" });
// Add directory icon or file icon
const iconEl = container.createSpan({ cls: "suggestion-icon" });
iconEl.textContent = file.isDirectory ? "📁" : "📄";
const contentEl = container.createDiv({ cls: "suggestion-content" });
contentEl.createDiv({ text: file.name, cls: "suggestion-title" });
if (!file.isDirectory) {
contentEl.createDiv({
text: `${this.formatSize(file.size)} - ${file.date}`,
cls: "suggestion-note"
});
} else {
contentEl.createDiv({
text: file.date,
cls: "suggestion-note"
});
}
}
private formatSize(bytes: number): string {
if (bytes < 1024) return bytes + ' B';
if (bytes < 1048576) return (bytes / 1024).toFixed(2) + ' KB';
if (bytes < 1073741824) return (bytes / 1048576).toFixed(2) + ' MB';
return (bytes / 1073741824).toFixed(2) + ' GB';
}
async onChooseSuggestion(file: SupernoteFile) {
if (file.isDirectory) {
// Navigate into directory
this.currentPath = file.uri;
await this.loadFiles();
// Reopen the modal to show new directory contents
this.open();
} else {
try {
const fileResponse = await fetch(`http://${this.settings.mirrorIP}:8089${file.uri}`);
if (!fileResponse.ok) {
throw new Error(`Failed to download file: ${fileResponse.statusText}`);
}
const buffer = await fileResponse.arrayBuffer();
const filename = await this.app.fileManager.getAvailablePathForAttachment(file.name);
const tfile = await this.app.vault.createBinary(filename, buffer);
new Notice(`Downloaded ${file.name}`);
const view = this.app.workspace.getActiveViewOfType(MarkdownView);
if (view) {
const link = this.app.fileManager.generateMarkdownLink(tfile, filename);
view.editor.replaceSelection(link);
}
} catch (err) {
new Notice(`Failed to download file: ${err.message}`);
}
}
}
}

View file

@ -1,45 +0,0 @@
import { SupernoteX, toImage } from 'supernote-typescript';
import { Image } from 'image-js'
export {};
export type SupernoteWorkerMessage = {
type: 'convert';
note: SupernoteX;
pageNumbers?: number[];
}
export type SupernoteWorkerResponse = {
type: 'result';
images: string[];
error?: string;
}
self.onmessage = async (e: MessageEvent<SupernoteWorkerMessage>) => {
try {
const { type, note, pageNumbers } = e.data;
if (type === 'convert') {
const results = await toImage(note, pageNumbers);
// Convert canvas/images to data URLs before sending
const dataUrls = results.map(result => {
if (result && typeof result.toDataURL === 'function') {
return result.toDataURL();
}
console.error('Result is not a canvas or does not support toDataURL');
return null;
});
self.postMessage({
type: 'result',
images: dataUrls
});
}
} catch (error) {
self.postMessage({
type: 'result',
images: [],
error: error instanceof Error ? error.message : 'Unknown error occurred'
});
}
};

4
src/worker.d.ts vendored
View file

@ -1,4 +0,0 @@
declare module 'myworker.worker' {
const WorkerFactory: new () => Worker;
export default WorkerFactory;
}