mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-04-02 07:05:18 +00:00
### Fixed (This should be backported to 0.25.22 if the beta phase is prolonged) - No longer larger files will not create a chunks during preparing `Reset Synchronisation on This Device`. ### Behaviour changes - Setup wizard is now more `goal-oriented`. Brand-new screens are introduced. - `Fetch everything` and `Rebuild everything` is now `Reset Synchronisation on This Device` and `Overwrite Server Data with This Device's Files`. - Remote configuration and E2EE settings are now separated to each modal dialogue. - Peer-to-Peer settings is also separated into its own modal dialogue. - Setup-URI, and Report for the Issue are now not copied to clipboard automatically. Instead, there are copy dialogue and buttons to copy them explicitly. - No longer optional features are introduced during the setup or `Reset Synchronisation on This Device`, `Overwrite Server Data with This Device's Files`. - We cannot preform `Fetch everything` and `Rebuild everything` (Removed, so the old name) without restarting Obsidian now. ### Miscellaneous - Setup QR Code generation is separated into a src/lib/src/API/processSetting.ts file. Please use it as a subrepository if you want to generate QR codes in your own application. - Setup-URI is also separated into a src/lib/src/API/processSetting.ts - Some direct access to web-APIs are now wrapped into the services layer. ### Dependency updates - Many dependencies are updated. Please see `package.json`. - As upgrading TypeScript, Fixed many UInt8Array<ArrayBuffer> and Uint8Array type mismatches.
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { mount, type Component, unmount } from "svelte";
|
|
import { type Writable, writable, get } from "svelte/store";
|
|
|
|
/**
|
|
* Props passed to Svelte panels, containing a writable port
|
|
* to communicate with the panel
|
|
*/
|
|
export type SveltePanelProps<T = any> = {
|
|
port: Writable<T | undefined>;
|
|
};
|
|
|
|
/**
|
|
* A class to manage a Svelte panel within Obsidian
|
|
* Especially useful for settings panels
|
|
*/
|
|
export class SveltePanel<T = any> {
|
|
private _mountedComponent: ReturnType<typeof mount>;
|
|
private _componentValue = writable<T | undefined>(undefined);
|
|
/**
|
|
* Creates a Svelte panel instance
|
|
* @param component Component to mount
|
|
* @param mountTo HTMLElement to mount the component to
|
|
* @param valueStore Optional writable store to bind to the component's port, if not provided a new one will be created
|
|
* @returns The SveltePanel instance
|
|
*/
|
|
constructor(component: Component<SveltePanelProps<T>>, mountTo: HTMLElement, valueStore?: Writable<T>) {
|
|
this._componentValue = valueStore ?? writable<T | undefined>(undefined);
|
|
this._mountedComponent = mount(component, {
|
|
target: mountTo,
|
|
props: {
|
|
port: this._componentValue,
|
|
},
|
|
});
|
|
return this;
|
|
}
|
|
/**
|
|
* Destroys the Svelte panel instance by unmounting the component
|
|
*/
|
|
destroy() {
|
|
if (this._mountedComponent) {
|
|
void unmount(this._mountedComponent);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Gets or sets the current value of the component's port
|
|
*/
|
|
get componentValue() {
|
|
return get(this._componentValue);
|
|
}
|
|
set componentValue(value: T | undefined) {
|
|
this._componentValue.set(value);
|
|
}
|
|
}
|