|
|
|
@ -53,6 +53,18 @@ class MethodRouterBuilber {
|
|
|
|
|
+delete(handler: Handler): this
|
|
|
|
|
+build(): Handler
|
|
|
|
|
}
|
|
|
|
|
class ResponseBuilder {
|
|
|
|
|
+status: Status
|
|
|
|
|
+headers: Record<string, string>
|
|
|
|
|
+body?: BodyInit
|
|
|
|
|
+setStatus(status: Status): this
|
|
|
|
|
+setHeader(key: string, value: string): this
|
|
|
|
|
+setBody(body: BodyInit): this
|
|
|
|
|
+redirect(location: string): this
|
|
|
|
|
+build(): Response
|
|
|
|
|
}
|
|
|
|
|
class MatchContext
|
|
|
|
|
<<Interface>> MatchContext
|
|
|
|
|
class Router~T~ {
|
|
|
|
|
+match(path: string, ctx: MatchContext): T
|
|
|
|
|
}
|
|
|
|
@ -75,23 +87,9 @@ class TreeRouter~T~ {
|
|
|
|
|
MethodRouter <-- MethodRouterBuilber: Create
|
|
|
|
|
Router <|.. MethodRouter
|
|
|
|
|
Router <|.. FsRouter
|
|
|
|
|
```
|
|
|
|
|
```mermaid
|
|
|
|
|
classDiagram
|
|
|
|
|
class ResponseBuilder {
|
|
|
|
|
+status: Status
|
|
|
|
|
+headers: Record<string, string>
|
|
|
|
|
+body?: BodyInit
|
|
|
|
|
+setStatus(status: Status): this
|
|
|
|
|
+setHeader(key: string, value: string): this
|
|
|
|
|
+setBody(body: BodyInit): this
|
|
|
|
|
+redirect(location: string): this
|
|
|
|
|
+build(): Response
|
|
|
|
|
}
|
|
|
|
|
class MatchContext
|
|
|
|
|
<<Interface>> MatchContext
|
|
|
|
|
Response <-- ResponseBuilder: Create
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```mermaid
|
|
|
|
|
classDiagram
|
|
|
|
|
class ChunkMethodAction {
|
|
|
|
@ -131,6 +129,17 @@ class ChunkMoveAction {
|
|
|
|
|
```
|
|
|
|
|
```mermaid
|
|
|
|
|
classDiagram
|
|
|
|
|
DocumentObject <|.. FileDocumentObject
|
|
|
|
|
class FileDocumentObject {
|
|
|
|
|
+docPath: string
|
|
|
|
|
+chunks: Chunk[]
|
|
|
|
|
+tags: string[]
|
|
|
|
|
+updatedAt: number
|
|
|
|
|
+tagsUpdatedAt: number
|
|
|
|
|
+open(): Promise<void>
|
|
|
|
|
+parse(content: unknown[]): void
|
|
|
|
|
+save(): Promise<void>
|
|
|
|
|
}
|
|
|
|
|
class Participant {
|
|
|
|
|
+id: string
|
|
|
|
|
+user: UserSession
|
|
|
|
@ -158,21 +167,6 @@ class ParticipantList {
|
|
|
|
|
+unicast(id: string, message: string): void
|
|
|
|
|
+broadcast(message: string): void
|
|
|
|
|
}
|
|
|
|
|
ParticipantList o-- Participant
|
|
|
|
|
```
|
|
|
|
|
```mermaid
|
|
|
|
|
classDiagram
|
|
|
|
|
DocumentObject <|.. FileDocumentObject
|
|
|
|
|
class FileDocumentObject {
|
|
|
|
|
+docPath: string
|
|
|
|
|
+chunks: Chunk[]
|
|
|
|
|
+tags: string[]
|
|
|
|
|
+updatedAt: number
|
|
|
|
|
+tagsUpdatedAt: number
|
|
|
|
|
+open(): Promise<void>
|
|
|
|
|
+parse(content: unknown[]): void
|
|
|
|
|
+save(): Promise<void>
|
|
|
|
|
}
|
|
|
|
|
FileDocumentObject <|-- ActiveDocumentObject
|
|
|
|
|
class ActiveDocumentObject {
|
|
|
|
|
+conns: Set<Participant>
|
|
|
|
@ -189,6 +183,7 @@ class DocumentStore {
|
|
|
|
|
+close(conn: Participant, docPath: string): void
|
|
|
|
|
+closeAll(conn: Participant): void
|
|
|
|
|
}
|
|
|
|
|
ParticipantList o-- Participant
|
|
|
|
|
DocumentStore o-- ActiveDocumentObject
|
|
|
|
|
```
|
|
|
|
|
```mermaid
|
|
|
|
@ -220,84 +215,47 @@ class RPCNotificationEvent {
|
|
|
|
|
```
|
|
|
|
|
```mermaid
|
|
|
|
|
classDiagram
|
|
|
|
|
class IDisposable {
|
|
|
|
|
+dispose(): void
|
|
|
|
|
class ViewModelBase {
|
|
|
|
|
+updateAsSource(path: string, updatedAt: number): void
|
|
|
|
|
}
|
|
|
|
|
<<Interface>> IDisposable
|
|
|
|
|
<<Interface>> ViewModelBase
|
|
|
|
|
ViewModelBase <|.. IViewModel
|
|
|
|
|
class IViewModel {
|
|
|
|
|
+pageView: IPageViewModel
|
|
|
|
|
}
|
|
|
|
|
<<Interface>> IViewModel
|
|
|
|
|
IPageViewModel <|.. BlankPage
|
|
|
|
|
class BlankPage {
|
|
|
|
|
+type: string
|
|
|
|
|
+updateAsSource(_path: string, _updatedAt: number): void
|
|
|
|
|
}
|
|
|
|
|
IViewModel <|.. ViewModel
|
|
|
|
|
class ViewModel {
|
|
|
|
|
+pageView: IPageViewModel
|
|
|
|
|
+updateAsSource(path: string, updatedAt: number): void
|
|
|
|
|
}
|
|
|
|
|
ViewModelBase <|.. IPageViewModel
|
|
|
|
|
class IPageViewModel {
|
|
|
|
|
+type: string
|
|
|
|
|
}
|
|
|
|
|
<<Interface>> IPageViewModel
|
|
|
|
|
IPageViewModel <|.. IDocumentViewModel
|
|
|
|
|
class IDocumentViewModel {
|
|
|
|
|
+docPath: string
|
|
|
|
|
+writable: boolean
|
|
|
|
|
+updateOnNotification(notification: RPCNotification): void
|
|
|
|
|
+useChunks(): [IChunkViewModel[], ChunkListMutator]
|
|
|
|
|
+useTags(): [string[], (tags: string[]) => Promise<void>]
|
|
|
|
|
+useWritable(): [boolean, (writable: boolean) => Promise<void>]
|
|
|
|
|
+updateOnNotification(notification: ChunkNotification): void
|
|
|
|
|
}
|
|
|
|
|
<<Interface>> IDocumentViewModel
|
|
|
|
|
IDocumentViewModel <|.. DocumentViewModel
|
|
|
|
|
IDisposable <|.. DocumentViewModel
|
|
|
|
|
class DocumentViewModel {
|
|
|
|
|
+type: "document"
|
|
|
|
|
+docPath: string
|
|
|
|
|
+chunks: ChunkListViewModel
|
|
|
|
|
+tags: string[]
|
|
|
|
|
+tagsUpdatedAt: number
|
|
|
|
|
+manager: IRPCMessageManager
|
|
|
|
|
+writable: boolean
|
|
|
|
|
+updateOnNotification(notification: RPCNotification): void
|
|
|
|
|
+useChunks(): [IChunkViewModel[], ChunkListMutator]
|
|
|
|
|
+updateTags(tags: string[], updatedAt: number): void
|
|
|
|
|
+useTags(): [string[], (tags: string[]) => Promise<void>]
|
|
|
|
|
+useWritable(): [boolean, (writable: boolean) => Promise<void>]
|
|
|
|
|
}
|
|
|
|
|
ChunkListViewModel ..* DocumentViewModel
|
|
|
|
|
```
|
|
|
|
|
```mermaid
|
|
|
|
|
classDiagram
|
|
|
|
|
class IChunkListViewModel {
|
|
|
|
|
+docPath: string
|
|
|
|
|
+updateOnNotification(notification: RPCNotification): void
|
|
|
|
|
+useChunks(): [IChunkViewModel[], ChunkListMutator]
|
|
|
|
|
}
|
|
|
|
|
<<Interface>> IChunkListViewModel
|
|
|
|
|
|
|
|
|
|
EventTarget <|-- ChunkListViewModel
|
|
|
|
|
IChunkListViewModel <|.. ChunkListViewModel
|
|
|
|
|
class ChunkListViewModel {
|
|
|
|
|
+chunks: ChunkViewModel[]
|
|
|
|
|
+history: ChunkListHistory
|
|
|
|
|
+buffer: Inline
|
|
|
|
|
+seq: number
|
|
|
|
|
+updatedAt: number
|
|
|
|
|
+docPath: string
|
|
|
|
|
+manager: IRPCMessageManager
|
|
|
|
|
+nextSeq: number
|
|
|
|
|
+updateOnNotification(notification: RPCNotification): void
|
|
|
|
|
-updateMark(updatedAt: number): void
|
|
|
|
|
+apply(mutator: ChunkListStateMutator, updatedAt: number, seq: number, refresh?: boolean): void
|
|
|
|
|
+refresh(chunks: Chunk[], updatedAt: number): void
|
|
|
|
|
-refreshWith(chunkList: (Chunk | ChunkState)[], currentUpdatedAt: number, refresh?: boolean): void
|
|
|
|
|
-resolveError(e: Error): void
|
|
|
|
|
+useChunks(): [ChunkViewModel[], ChunkListMutator]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ChunkListMutator {
|
|
|
|
|
+add(i?: number, chunkContent?: ChunkContent): void
|
|
|
|
|
+add(i?: number | undefined, chunkContent?: ChunkContent | undefined): void
|
|
|
|
|
+create(i?: number | undefined): void
|
|
|
|
|
+addFromText(i: number, text: string): void
|
|
|
|
|
+del(id: string): void
|
|
|
|
|
+move(id: string, pos: number): void
|
|
|
|
|
}
|
|
|
|
|
<<interface>> ChunkListMutator
|
|
|
|
|
class ChunkListHistory {
|
|
|
|
|
+history: ChunkListHistoryElem[]
|
|
|
|
|
+limit: number
|
|
|
|
|
-applyLast(mutator: ChunkListStateMutator, updatedAt: number): void
|
|
|
|
|
+current: ChunkListState
|
|
|
|
|
+currentUpdatedAt: number
|
|
|
|
|
+revoke(): void
|
|
|
|
|
+apply(mutator: ChunkListStateMutator, updatedAt: number): boolean
|
|
|
|
|
<<Interface>> ChunkListMutator
|
|
|
|
|
class ChunkListState {
|
|
|
|
|
+chunks: Chunk[]
|
|
|
|
|
+cloen(): ChunkListState
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ChunkListStateMutator
|
|
|
|
|
<<Interface>> ChunkListStateMutator
|
|
|
|
|
class ChunkListHistory {
|
|
|
|
@ -309,12 +267,38 @@ class ChunkListHistory {
|
|
|
|
|
+revoke(): void
|
|
|
|
|
+apply(mutator: ChunkListStateMutator, updatedAt: number): boolean
|
|
|
|
|
}
|
|
|
|
|
class ChunkMutator {
|
|
|
|
|
+setType(t: ChunkContentType): void
|
|
|
|
|
+setContent(s: string): void
|
|
|
|
|
}
|
|
|
|
|
<<Interface>> ChunkMutator
|
|
|
|
|
IDocumentViewModel <|.. DocumentViewModel
|
|
|
|
|
class DocumentViewModel {
|
|
|
|
|
+type: "document"
|
|
|
|
|
+docPath: string
|
|
|
|
|
+chunks: Chunk[]
|
|
|
|
|
+history: ChunkListHistory
|
|
|
|
|
+buffer: Inline
|
|
|
|
|
+seq: number
|
|
|
|
|
+tags: string[]
|
|
|
|
|
+updatedAt: number
|
|
|
|
|
+tagsUpdatedAt: number
|
|
|
|
|
+updateOnNotification(notification: ChunkNotification): void
|
|
|
|
|
-updateMark(updatedAt: number): void
|
|
|
|
|
+apply(mutator: ChunkListStateMutator, updatedAt: number, seq: number, refresh?: boolean): void
|
|
|
|
|
+updateAsSource(_path: string, _updatedAt: number): void
|
|
|
|
|
+useChunks(): [Chunk[], ChunkListMutator]
|
|
|
|
|
+useTags(): [string[], (tags: string[]) => Promise<void>]
|
|
|
|
|
+useChunk(chunk_arg: Chunk): [Chunk, ChunkMutator]
|
|
|
|
|
}
|
|
|
|
|
IViewModel ..> "1" IPageViewModel
|
|
|
|
|
ViewModel ..> "1" IPageViewModel
|
|
|
|
|
ChunkListHistory ..> "1" ChunkListStateMutator
|
|
|
|
|
ChunkListHistory ..> "1" ChunkListState
|
|
|
|
|
ChunkListViewModel *.. ChunkListHistory
|
|
|
|
|
ChunkListViewModel ..> "1" ChunkListStateMutator
|
|
|
|
|
IChunkListViewModel ..> "1" ChunkListMutator
|
|
|
|
|
ChunkViewModel ..* ChunkListViewModel
|
|
|
|
|
DocumentViewModel ..> "1" ChunkListHistory
|
|
|
|
|
DocumentViewModel ..> "1" ChunkListStateMutator
|
|
|
|
|
DocumentViewModel ..> "1" ChunkListMutator
|
|
|
|
|
DocumentViewModel ..> "1" ChunkMutator
|
|
|
|
|
```
|
|
|
|
|
```mermaid
|
|
|
|
|
classDiagram
|
|
|
|
@ -329,78 +313,35 @@ ChunkListStateMutator <|.. ChunkListStateDeleteMutator
|
|
|
|
|
ChunkListStateMutator <|.. ChunkListStateModifyMutator
|
|
|
|
|
ChunkListStateMutator <|.. ChunkListStateMoveMutator
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```mermaid
|
|
|
|
|
classDiagram
|
|
|
|
|
class ChunkMutator {
|
|
|
|
|
+setType(t: ChunkType): void
|
|
|
|
|
+setContent(s: string): void
|
|
|
|
|
}
|
|
|
|
|
<<Interface>> ChunkMutator
|
|
|
|
|
class IChunkViewModel {
|
|
|
|
|
+parent: IChunkListViewModel
|
|
|
|
|
+id: string
|
|
|
|
|
+focus(): void
|
|
|
|
|
+unfocus(): void
|
|
|
|
|
+useFocus(): boolean
|
|
|
|
|
+useChunk(): [Chunk, ChunkMutator]
|
|
|
|
|
+setState(state: ChunkState): void
|
|
|
|
|
}
|
|
|
|
|
<<Interface>> IChunkViewModel
|
|
|
|
|
EventTarget <|-- ChunkViewModel
|
|
|
|
|
IChunkViewModel <|.. ChunkViewModel
|
|
|
|
|
class ChunkViewModel {
|
|
|
|
|
+chunk: Chunk
|
|
|
|
|
+updatedAt: number
|
|
|
|
|
+focused: boolean
|
|
|
|
|
+overwrite?: Chunk | undefined
|
|
|
|
|
+parent: ChunkListViewModel
|
|
|
|
|
+manager: IRPCMessageManager
|
|
|
|
|
+id: string
|
|
|
|
|
+focus(): void
|
|
|
|
|
+unfocus(): void
|
|
|
|
|
+useFocus(): boolean
|
|
|
|
|
+content: ChunkContent
|
|
|
|
|
+setState(state: ChunkState): void
|
|
|
|
|
+useChunk(): [Chunk, ChunkMutator]
|
|
|
|
|
}
|
|
|
|
|
IChunkViewModel ..> "1" ChunkMutator
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```mermaid
|
|
|
|
|
classDiagram
|
|
|
|
|
EventTarget <|.. IRPCMessageManager
|
|
|
|
|
class IRPCMessageManager {
|
|
|
|
|
+opened: boolean
|
|
|
|
|
+close(): void
|
|
|
|
|
+sendNotification(notification: RPCNotification): void
|
|
|
|
|
+sendNotification(notification: ChunkNotification): void
|
|
|
|
|
+addEventListener(name: "notification", listener: RPCMessageMessagerEventListener): void
|
|
|
|
|
+addEventListener(name: string, listener: EventListenerOrEventListenerObject): void
|
|
|
|
|
+removeEventListener(name: "notification", listener: RPCMessageMessagerEventListener): void
|
|
|
|
|
+removeEventListener(name: string, listener: EventListenerOrEventListenerObject): void
|
|
|
|
|
+invokeMethod(m: RPCMessageBody): Promise<RPCResponse>
|
|
|
|
|
}
|
|
|
|
|
<<Interface>> IRPCMessageManager
|
|
|
|
|
EventTarget <|-- RPCMessageManager
|
|
|
|
|
IRPCMessageManager <|.. RPCMessageManager
|
|
|
|
|
class RPCMessageManager {
|
|
|
|
|
-callbackList: Map<number, RPCCallback>
|
|
|
|
|
-curId: number
|
|
|
|
|
-ws?: WebSocket | undefined
|
|
|
|
|
+opened: boolean
|
|
|
|
|
+openedURL: string | undefined
|
|
|
|
|
+open(url: string | URL, protocals?: string | undefined): Promise<void>
|
|
|
|
|
+close(): void
|
|
|
|
|
-genId(): number
|
|
|
|
|
+genHeader(): Inline
|
|
|
|
|
+send(message: RPCMethod): Promise<RPCResponse>
|
|
|
|
|
+sendNotification(message: RPCNotification): void
|
|
|
|
|
+sendNotification(message: ChunkNotification): void
|
|
|
|
|
+addEventListener(type: "notification", callback: RPCMessageMessagerEventListener): void
|
|
|
|
|
+removeEventListener(type: "notification", callback: RPCMessageMessagerEventListener): void
|
|
|
|
|
+invokeMethod(m: RPCMessageBody): Promise<RPCResponse>
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
```mermaid
|
|
|
|
|
classDiagram
|
|
|
|
|
|
|
|
|
|
class FsDirEntry {
|
|
|
|
|
+name: string
|
|
|
|
|
+isDirectory: boolean
|
|
|
|
@ -423,48 +364,33 @@ class FsGetResult {
|
|
|
|
|
+entries?: FsDirEntry[] | undefined
|
|
|
|
|
}
|
|
|
|
|
<<Interface>> FsGetResult
|
|
|
|
|
Event <|-- FileEvent
|
|
|
|
|
class FileEvent~T~ {
|
|
|
|
|
+kind: T
|
|
|
|
|
+path: string[]
|
|
|
|
|
}
|
|
|
|
|
class IFsEventMap {
|
|
|
|
|
+modify: FileEvent<"modify">
|
|
|
|
|
+create: FileEvent<"create">
|
|
|
|
|
+remove: FileEvent<"remove">
|
|
|
|
|
+modify: (this: IFsManager, event: MessageEvent<NotImplemented>) => void
|
|
|
|
|
+create: (this: IFsManager, event: MessageEvent<NotImplemented>) => void
|
|
|
|
|
+delete: (this: IFsManager, event: MessageEvent<NotImplemented>) => void
|
|
|
|
|
}
|
|
|
|
|
<<Interface>> IFsEventMap
|
|
|
|
|
EventTarget <|.. IFsManager
|
|
|
|
|
class IFsManager {
|
|
|
|
|
+getURL(filePath: string): URL
|
|
|
|
|
+get(path: string): Promise<Response>
|
|
|
|
|
+getStat(path: string): Promise<FsGetResult>
|
|
|
|
|
+upload(filePath: string, data: BodyInit): Promise<number>
|
|
|
|
|
+delete(filePath: string): Promise<number>
|
|
|
|
|
+rename(oldPath: string, newPath: string): Promise<number>
|
|
|
|
|
+mkdir(path: string): Promise<number>
|
|
|
|
|
+addEventListener(type: T, listener: EventHandler~T~): void
|
|
|
|
|
+removeEventListener(type: T, listener: EventHandler~T~): void
|
|
|
|
|
+addEventListener(name: string, listener: EventListenerOrEventListenerObject): void
|
|
|
|
|
+removeEventListener(name: string, listener: EventListenerOrEventListenerObject): void
|
|
|
|
|
+dispatchEvent(event: Event): boolean
|
|
|
|
|
}
|
|
|
|
|
<<Interface>> IFsManager
|
|
|
|
|
EventTarget <|-- FsManager
|
|
|
|
|
IFsManager <|.. FsManager
|
|
|
|
|
class FsManager {
|
|
|
|
|
-manager: IRPCMessageManager
|
|
|
|
|
-url: string
|
|
|
|
|
+addEventListener(type: T, listener: EventHandler~T~): void
|
|
|
|
|
+removeEventListener(type: T, listener: EventHandler~T~): void
|
|
|
|
|
+getURL(filePath: string): URL
|
|
|
|
|
-#fetchRequest(filePath: string | URL, init?: RequestInit | undefined): Promise<Response>
|
|
|
|
|
+get(filePath: string): Promise<Response>
|
|
|
|
|
-manager: RPCMessageManager
|
|
|
|
|
-prefix: string
|
|
|
|
|
+get(path: string): Promise<Response>
|
|
|
|
|
+getStat(filePath: string): Promise<FsGetResult>
|
|
|
|
|
+upload(filePath: string, data: BodyInit): Promise<number>
|
|
|
|
|
+mkdir(filePath: string): Promise<number>
|
|
|
|
|
+delete(filePath: string): Promise<number>
|
|
|
|
|
+rename(oldPath: string, newPath: string): Promise<number>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FsGetResult ..> "*" FsDirEntry
|
|
|
|
|
IFsEventMap ..> "1" IFsManager
|
|
|
|
|
IFsManager ..> "1" FsGetResult
|
|
|
|
|