-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: change render core export api
- Loading branch information
Showing
30 changed files
with
476 additions
and
150 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface UriComponents { | ||
path: string; | ||
} | ||
|
||
export class URI implements UriComponents { | ||
readonly path: string; | ||
|
||
constructor(path: string) { | ||
this.path = path; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import { URI } from '../../common/uri'; | ||
|
||
export enum FileType { | ||
/** | ||
* File is unknown (neither file, directory). | ||
*/ | ||
Unknown = 0, | ||
|
||
/** | ||
* File is a normal file. | ||
*/ | ||
File = 1, | ||
|
||
/** | ||
* File is a directory. | ||
*/ | ||
Directory = 2, | ||
} | ||
|
||
export interface IStat { | ||
/** | ||
* The file type. | ||
*/ | ||
readonly type: FileType; | ||
|
||
/** | ||
* The last modification date represented as millis from unix epoch. | ||
*/ | ||
readonly mtime: number; | ||
|
||
/** | ||
* The creation date represented as millis from unix epoch. | ||
*/ | ||
readonly ctime: number; | ||
} | ||
|
||
export interface IBaseFileStat { | ||
/** | ||
* The unified resource identifier of this file or folder. | ||
*/ | ||
readonly resource: URI; | ||
|
||
/** | ||
* The name which is the last segment | ||
* of the {{path}}. | ||
*/ | ||
readonly name: string; | ||
|
||
/** | ||
* The size of the file. | ||
* | ||
* The value may or may not be resolved as | ||
* it is optional. | ||
*/ | ||
readonly size?: number; | ||
|
||
/** | ||
* The last modification date represented as millis from unix epoch. | ||
* | ||
* The value may or may not be resolved as | ||
* it is optional. | ||
*/ | ||
readonly mtime?: number; | ||
|
||
/** | ||
* The creation date represented as millis from unix epoch. | ||
* | ||
* The value may or may not be resolved as | ||
* it is optional. | ||
*/ | ||
readonly ctime?: number; | ||
|
||
/** | ||
* A unique identifier that represents the | ||
* current state of the file or directory. | ||
* | ||
* The value may or may not be resolved as | ||
* it is optional. | ||
*/ | ||
readonly etag?: string; | ||
|
||
/** | ||
* File is readonly. Components like editors should not | ||
* offer to edit the contents. | ||
*/ | ||
readonly readonly?: boolean; | ||
|
||
/** | ||
* File is locked. Components like editors should offer | ||
* to edit the contents and ask the user upon saving to | ||
* remove the lock. | ||
*/ | ||
readonly locked?: boolean; | ||
} | ||
|
||
/** | ||
* A file resource with meta information and resolved children if any. | ||
*/ | ||
export interface IFileStat extends IBaseFileStat { | ||
/** | ||
* The resource is a file. | ||
*/ | ||
readonly isFile: boolean; | ||
|
||
/** | ||
* The resource is a directory. | ||
*/ | ||
readonly isDirectory: boolean; | ||
|
||
/** | ||
* The children of the file stat or undefined if none. | ||
*/ | ||
children: IFileStat[] | undefined; | ||
} | ||
|
||
export interface IFileStatWithMetadata extends Required<IFileStat> { | ||
readonly children: IFileStatWithMetadata[]; | ||
} | ||
|
||
export const enum FileOperation { | ||
CREATE, | ||
DELETE, | ||
MOVE, | ||
COPY, | ||
WRITE, | ||
} | ||
|
||
export interface IFileOperationEvent { | ||
readonly resource: URI; | ||
readonly operation: FileOperation; | ||
|
||
isOperation(operation: FileOperation.DELETE | FileOperation.WRITE): boolean; | ||
isOperation( | ||
operation: FileOperation.CREATE | FileOperation.MOVE | FileOperation.COPY, | ||
): this is IFileOperationEventWithMetadata; | ||
} | ||
|
||
export interface IFileOperationEventWithMetadata extends IFileOperationEvent { | ||
readonly target: IFileStatWithMetadata; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* URI -> file content | ||
* URI -> file Stat | ||
*/ | ||
|
||
export interface IFileManagement {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export interface IFileService {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { URI } from '../common/uri'; | ||
|
||
export interface IWorkspaceFolderData { | ||
/** | ||
* The associated URI for this workspace folder. | ||
*/ | ||
readonly uri: URI; | ||
|
||
/** | ||
* The name of this workspace folder. Defaults to | ||
* the basename of its [uri-path](#Uri.path) | ||
*/ | ||
readonly name: string; | ||
|
||
/** | ||
* The ordinal number of this workspace folder. | ||
*/ | ||
readonly index: number; | ||
} | ||
|
||
export interface IWorkspaceFolder extends IWorkspaceFolderData { | ||
/** | ||
* Given workspace folder relative path, returns the resource with the absolute path. | ||
*/ | ||
toResource: (relativePath: string) => URI; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { type Event } from '@alilc/lowcode-shared'; | ||
import { URI } from '../../common/uri'; | ||
|
||
export interface IEditWindow { | ||
// readonly onWillLoad: Event<ILoadEvent>; | ||
readonly onDidSignalReady: Event<void>; | ||
readonly onDidDestroy: Event<void>; | ||
|
||
readonly onDidClose: Event<void>; | ||
|
||
readonly id: number; | ||
|
||
readonly config: IWindowConfiguration | undefined; | ||
|
||
readonly isReady: boolean; | ||
ready(): Promise<IEditWindow>; | ||
|
||
load(config: IWindowConfiguration, options?: { isReload?: boolean }): void; | ||
reload(): void; | ||
} | ||
|
||
export interface IWindowConfiguration { | ||
filesToOpenOrCreate?: IPath[]; | ||
} | ||
|
||
export interface IPath<T = any> { | ||
/** | ||
* Optional editor options to apply in the file | ||
*/ | ||
readonly options?: T; | ||
|
||
/** | ||
* The file path to open within the instance | ||
*/ | ||
fileUri?: URI; | ||
|
||
/** | ||
* Specifies if the file should be only be opened | ||
* if it exists. | ||
*/ | ||
readonly openOnlyIfExists?: boolean; | ||
} | ||
|
||
export const enum WindowMode { | ||
Maximized, | ||
Normal, | ||
Fullscreen, | ||
Custom, | ||
} | ||
|
||
export interface IWindowState { | ||
width?: number; | ||
height?: number; | ||
x?: number; | ||
y?: number; | ||
mode?: WindowMode; | ||
zoomLevel?: number; | ||
readonly display?: number; | ||
} | ||
|
||
export interface IOpenConfiguration { | ||
readonly urisToOpen?: IWindowOpenable[]; | ||
readonly preferNewWindow?: boolean; | ||
readonly forceNewWindow?: boolean; | ||
readonly forceNewTabbedWindow?: boolean; | ||
readonly forceReuseWindow?: boolean; | ||
readonly forceEmpty?: boolean; | ||
} | ||
|
||
export interface IBaseWindowOpenable { | ||
label?: string; | ||
} | ||
|
||
export interface IFolderToOpen extends IBaseWindowOpenable { | ||
readonly folderUri: URI; | ||
} | ||
|
||
export interface IFileToOpen extends IBaseWindowOpenable { | ||
readonly fileUri: URI; | ||
} | ||
|
||
export type IWindowOpenable = IFolderToOpen | IFileToOpen; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { type Event } from '@alilc/lowcode-shared'; | ||
import { IEditWindow, IOpenConfiguration } from './window'; | ||
|
||
export interface IWindowService { | ||
readonly onDidOpenWindow: Event<IEditWindow>; | ||
readonly onDidSignalReadyWindow: Event<IEditWindow>; | ||
readonly onDidChangeFullScreen: Event<{ window: IEditWindow; fullscreen: boolean }>; | ||
readonly onDidDestroyWindow: Event<IEditWindow>; | ||
|
||
open(openConfig: IOpenConfiguration): Promise<IEditWindow[]>; | ||
|
||
sendToFocused(channel: string, ...args: any[]): void; | ||
sendToOpeningWindow(channel: string, ...args: any[]): void; | ||
sendToAll(channel: string, payload?: any, windowIdsToIgnore?: number[]): void; | ||
|
||
getWindows(): IEditWindow[]; | ||
getWindowCount(): number; | ||
|
||
getFocusedWindow(): IEditWindow | undefined; | ||
getLastActiveWindow(): IEditWindow | undefined; | ||
|
||
getWindowById(windowId: number): IEditWindow | undefined; | ||
} | ||
|
||
export class WindowService implements IWindowService { | ||
private readonly windows = new Map<number, IEditWindow>(); | ||
|
||
getWindows(): IEditWindow[] { | ||
return [...this.windows.values()]; | ||
} | ||
|
||
getWindowCount(): number { | ||
return this.windows.size; | ||
} | ||
|
||
getFocusedWindow(): IEditWindow | undefined { | ||
return this.getWindows().find((w) => w.focused); | ||
} | ||
|
||
getLastActiveWindow(): IEditWindow | undefined { | ||
return this.getWindows().find((w) => w.lastActive); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,31 @@ | ||
import { IWorkspaceFolder } from './folder'; | ||
|
||
/** | ||
* 工作空间:一个或多个项目的集合 | ||
* workspace -> one or more folders -> virtual files | ||
* file -> editWindow | ||
* editorView -> component tree schema | ||
* | ||
* project = (one or muti folders -> files) + some configs | ||
*/ | ||
export interface Workspace {} | ||
export interface IWorkspace { | ||
readonly id: string; | ||
|
||
/** | ||
* Folders in the workspace. | ||
*/ | ||
readonly folders: IWorkspaceFolder[]; | ||
} | ||
|
||
export class Workspace implements IWorkspace { | ||
private _folders: IWorkspaceFolder[] = []; | ||
|
||
constructor(private _id: string) {} | ||
|
||
get id() { | ||
return this._id; | ||
} | ||
|
||
get folders() { | ||
return this._folders; | ||
} | ||
} |
Oops, something went wrong.