Auto-commit 2026-04-27 19:13

This commit is contained in:
2026-04-27 19:13:03 -04:00
parent f9a8a2f688
commit bc897f8845
13 changed files with 567 additions and 110 deletions

View File

@@ -4,7 +4,7 @@
*/
import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js';
import { Text, Map as YMap, Array as YArray, Doc, ObservableMapEvent, ObservableArrayEvent } from 'yjs';
import { Text, Map as YMap, Array as YArray, Doc, YEvent } from 'yjs';
/**
* Create a reactive binding to a Yjs Text instance
@@ -39,10 +39,10 @@ export function useYText(yText: Text) {
* Create a reactive binding to a Yjs Map
*/
export function useYMap<T extends Record<string, any>>(yMap: YMap<T>) {
const [data, setData] = createSignal<T>(yMap.toJSON() as T);
const [data, setData] = createSignal<T>(yMap.toJSON() as unknown as T);
const observer = (event: ObservableMapEvent) => {
setData(yMap.toJSON() as T);
const observer = (_event: YEvent<YMap<T>>) => {
setData(() => yMap.toJSON() as unknown as T);
};
yMap.observe(observer);
@@ -53,16 +53,16 @@ export function useYMap<T extends Record<string, any>>(yMap: YMap<T>) {
const updateMap = (updates: Partial<T>) => {
Object.entries(updates).forEach(([key, value]) => {
yMap.set(key as keyof T, value);
yMap.set(key, value as T[string & keyof T]);
});
};
const setValue = <K extends keyof T>(key: K, value: T[K]) => {
const setValue = <K extends string & keyof T>(key: K, value: T[K]) => {
yMap.set(key, value);
};
const getValue = <K extends keyof T>(key: K): T[K] | undefined => {
return yMap.get(key);
const getValue = <K extends string & keyof T>(key: K): T[K] | undefined => {
return yMap.get(key) as T[K] | undefined;
};
return {
@@ -80,7 +80,7 @@ export function useYMap<T extends Record<string, any>>(yMap: YMap<T>) {
export function useYArray<T>(yArray: YArray<T>) {
const [items, setItems] = createSignal<T[]>(yArray.toArray());
const observer = (event: ObservableArrayEvent) => {
const observer = (_event: YEvent<YArray<T>>) => {
setItems(yArray.toArray());
};
@@ -140,9 +140,9 @@ export function useCollaborativeDoc(doc: Doc) {
const getScenes = createMemo(() => doc.getMap('scenes'));
const text = useYText(getText());
const metadata = useYMap(getMetadata());
const characters = useYMap(getCharacters());
const scenes = useYMap(getScenes());
const metadata = useYMap(getMetadata() as YMap<Record<string, any>>);
const characters = useYMap(getCharacters() as YMap<Record<string, any>>);
const scenes = useYMap(getScenes() as YMap<Record<string, any>>);
return {
doc,

View File

@@ -77,7 +77,7 @@ export class ProtonMailClient {
async downloadAttachment(attachmentId: string): Promise<Blob> {
const result = await trpc.mail.attachmentDownload.query({ attachmentId });
return result;
return result as unknown as Blob;
}
}

View File

@@ -10,6 +10,7 @@ interface LineDiffItem {
type: ChangeType;
line: string;
oldLine?: string;
originalLineIndex?: number;
}
function computeLineDiff(
@@ -36,6 +37,7 @@ function computeLineDiff(
type: 'modification',
line: newLine,
oldLine: oldLine,
originalLineIndex: oldIdx,
});
oldIdx++;
newIdx++;
@@ -45,11 +47,12 @@ function computeLineDiff(
type: 'deletion',
line: oldLine,
oldLine: oldLine,
originalLineIndex: oldIdx,
});
oldIdx++;
} else {
const newLine = newLines[newIdx]!;
result.push({ type: 'addition', line: newLine });
result.push({ type: 'addition', line: newLine, originalLineIndex: newIdx });
newIdx++;
}
}
@@ -84,7 +87,7 @@ export function computeDiff(
sceneCounter++;
}
const lineNumber = i + 1;
const lineNumber = (diff.originalLineIndex ?? i) + 1;
const currentPage = Math.ceil(lineNumber / linesPerPage);
const change: RevisionChangeData = {