@kubohiroya/turbowarp-plus-editor-project-folder 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +5 -1
- package/README.md +4 -0
- package/dist/THIRD_PARTY_NOTICES.md +716 -0
- package/dist/create-folder.d.ts +8 -0
- package/dist/explorer-files.d.ts +15 -0
- package/dist/explorer-menu.d.ts +49 -0
- package/dist/explorer.d.ts +46 -1
- package/dist/explorer.js +1911 -672
- package/dist/file-preview.d.ts +24 -0
- package/dist/folder-registry.d.ts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +1028 -541
- package/dist/session.d.ts +10 -1
- package/dist/shared-JdaDvk2R.js +588 -0
- package/dist/shared-kI7qYraF.js +30130 -0
- package/dist/source.d.ts +4 -2
- package/dist/text-file-editor.d.ts +17 -0
- package/package.json +16 -1
- package/src/create-folder.ts +99 -0
- package/src/explorer-files.ts +167 -0
- package/src/explorer-menu.tsx +125 -0
- package/src/explorer.tsx +351 -16
- package/src/file-preview.ts +134 -0
- package/src/folder-registry.ts +50 -0
- package/src/index.ts +42 -2
- package/src/session.ts +105 -20
- package/src/source.ts +42 -38
- package/src/text-file-editor.ts +356 -0
- package/vite.config.ts +2 -0
- package/dist/shared-DLcytVOx.js +0 -445
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Storage } from './source.js';
|
|
2
|
+
/** Create and validate a project-folder snapshot in a directory chosen by the user. */
|
|
3
|
+
export declare function createProjectFolder({ directory, files, storage, current }: {
|
|
4
|
+
directory: FileSystemDirectoryHandle;
|
|
5
|
+
files: ReadonlyMap<string, Uint8Array>;
|
|
6
|
+
storage: Storage;
|
|
7
|
+
current?: () => boolean;
|
|
8
|
+
}): Promise<import("./source.js").FolderSource>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class ExplorerFileError extends Error {
|
|
2
|
+
readonly code: 'invalidName' | 'exists' | 'sourceChanged' | 'originalKept' | 'cleanupFailed';
|
|
3
|
+
constructor(code: 'invalidName' | 'exists' | 'sourceChanged' | 'originalKept' | 'cleanupFailed');
|
|
4
|
+
}
|
|
5
|
+
export declare function parentPath(path: string): string;
|
|
6
|
+
export declare function resolveExplorerDirectory(root: FileSystemDirectoryHandle, path: string): Promise<FileSystemDirectoryHandle>;
|
|
7
|
+
export declare function copyExplorerFile(directory: FileSystemDirectoryHandle, file: File, guard: () => void): Promise<void>;
|
|
8
|
+
export declare function renameExplorerEntry(parent: FileSystemDirectoryHandle, entry: {
|
|
9
|
+
name: string;
|
|
10
|
+
kind: FileSystemHandleKind;
|
|
11
|
+
}, name: string, guard: () => void): Promise<void>;
|
|
12
|
+
export declare function deleteExplorerEntry(parent: FileSystemDirectoryHandle, entry: {
|
|
13
|
+
name: string;
|
|
14
|
+
kind: FileSystemHandleKind;
|
|
15
|
+
}, guard: () => void): Promise<void>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare const actionMessages: (locale?: string) => {
|
|
3
|
+
actions: string;
|
|
4
|
+
rename: string;
|
|
5
|
+
renameTitle: string;
|
|
6
|
+
delete: string;
|
|
7
|
+
deleteTitle: string;
|
|
8
|
+
newName: string;
|
|
9
|
+
cancel: string;
|
|
10
|
+
remove: (name: string, folder: boolean) => string;
|
|
11
|
+
stage: string;
|
|
12
|
+
unstage: string;
|
|
13
|
+
working: string;
|
|
14
|
+
copyFailed: string;
|
|
15
|
+
filesOnly: string;
|
|
16
|
+
invalidName: string;
|
|
17
|
+
exists: string;
|
|
18
|
+
denied: string;
|
|
19
|
+
conflict: string;
|
|
20
|
+
sourceChanged: string;
|
|
21
|
+
originalKept: string;
|
|
22
|
+
cleanupFailed: string;
|
|
23
|
+
failed: string;
|
|
24
|
+
};
|
|
25
|
+
export type ActionMessages = ReturnType<typeof actionMessages>;
|
|
26
|
+
export type MenuAnchor = {
|
|
27
|
+
row: HTMLButtonElement;
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
};
|
|
31
|
+
export declare const actionCss = "\n.twpf-explorer-actions{position:fixed;z-index:2147483647;max-width:calc(100vw - 8px);padding:4px;\nborder:1px solid GrayText;border-radius:5px;background:Canvas;color:CanvasText;box-shadow:0 2px 8px #0004}\n.twpf-explorer-actions button{display:block;width:100%;border:0;padding:.35em .65em;text-align:start;background:Canvas;color:CanvasText;\nfont:inherit;cursor:pointer;border-radius:3px}\n.twpf-explorer-actions button:is(:hover,:focus-visible){background:Highlight;color:HighlightText}\n.twpf-explorer-dialog{max-width:min(28em,calc(100vw - 2em));color:CanvasText;background:Canvas;\nborder:1px solid GrayText;border-radius:6px;padding:1em;overflow-wrap:anywhere}\n.twpf-explorer-dialog::backdrop{background:#0006}\n.twpf-explorer-dialog h2{font-size:1.1em;margin:0 0 .75em}\n.twpf-explorer-dialog input{display:block;width:100%;box-sizing:border-box;margin-top:.3em}\n.twpf-explorer-dialog-footer{display:flex;justify-content:flex-end;gap:.5em;margin-top:1em}\n.twpf-explorer-drop{min-height:100%;box-sizing:border-box}\n.twpf-explorer [data-drop-active],.twpf-explorer[data-drop-active]{outline:2px solid Highlight;outline-offset:-2px}\n.twpf-explorer-feedback{white-space:pre-wrap;overflow-wrap:anywhere;padding:.25em .5em}\n";
|
|
32
|
+
export declare function ExplorerMenu({ anchor, label, actions, close }: {
|
|
33
|
+
anchor: MenuAnchor;
|
|
34
|
+
label: string;
|
|
35
|
+
actions: readonly {
|
|
36
|
+
label: string;
|
|
37
|
+
run(): void;
|
|
38
|
+
}[];
|
|
39
|
+
close(restoreFocus: boolean): void;
|
|
40
|
+
}): React.ReactPortal;
|
|
41
|
+
export declare function ExplorerFileDialog({ anchor, name, folder, rename, message, close, submit }: {
|
|
42
|
+
anchor: MenuAnchor;
|
|
43
|
+
name: string;
|
|
44
|
+
folder: boolean;
|
|
45
|
+
rename: boolean;
|
|
46
|
+
message: ActionMessages;
|
|
47
|
+
close(): void;
|
|
48
|
+
submit(name: string): void;
|
|
49
|
+
}): React.ReactPortal;
|
package/dist/explorer.d.ts
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import type { ExplorerMutation } from './folder-registry.js';
|
|
2
3
|
import type { Json, Project } from './source.js';
|
|
4
|
+
import type { FilePreviewRequest, ReadFileBaseline } from './file-preview.js';
|
|
3
5
|
export type ExplorerMark = 'added' | 'modified' | 'deleted' | 'untracked';
|
|
6
|
+
export type ExplorerFileStatus = {
|
|
7
|
+
change?: ExplorerMark;
|
|
8
|
+
staged?: boolean;
|
|
9
|
+
revision?: 'committed' | 'pushed' | 'merged';
|
|
10
|
+
};
|
|
4
11
|
export type ExplorerEntry = {
|
|
5
12
|
path: string;
|
|
6
13
|
name: string;
|
|
7
14
|
kind: 'file' | 'directory';
|
|
8
15
|
};
|
|
16
|
+
export type ExplorerGit = {
|
|
17
|
+
change(kind: 'stage' | 'unstage', entry: ExplorerEntry, isCurrent: () => boolean): Promise<{
|
|
18
|
+
done: boolean;
|
|
19
|
+
error?: string;
|
|
20
|
+
}>;
|
|
21
|
+
refresh(): Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
export type FollowExplorerGit = (directory: FileSystemDirectoryHandle, update: (git?: ExplorerGit) => void) => () => void;
|
|
9
24
|
export type ProjectFolderExplorerProps = {
|
|
10
|
-
/** The folder to show: a project folder or a repository root.
|
|
25
|
+
/** The folder to show: a project folder or a repository root. */
|
|
11
26
|
directory: FileSystemDirectoryHandle;
|
|
12
27
|
/** 'ja…' shows Japanese text; anything else shows English. */
|
|
13
28
|
locale?: string;
|
|
@@ -15,10 +30,18 @@ export type ProjectFolderExplorerProps = {
|
|
|
15
30
|
descriptions?: ReadonlyMap<string, string>;
|
|
16
31
|
/** Git status for an entry, by path relative to `directory`. */
|
|
17
32
|
marks?: ReadonlyMap<string, ExplorerMark>;
|
|
33
|
+
fileStatuses?: ReadonlyMap<string, ExplorerFileStatus>;
|
|
34
|
+
unsavedPaths?: ReadonlySet<string>;
|
|
35
|
+
/** Changes after the folder contents have been saved or reloaded. */
|
|
36
|
+
refreshKey?: number;
|
|
18
37
|
/** Called when a file is opened with Enter, Space or a click. */
|
|
19
38
|
onOpen?(entry: ExplorerEntry): void;
|
|
20
39
|
/** The tree's accessible name. Defaults to "Project folder". */
|
|
21
40
|
label?: string;
|
|
41
|
+
/** Runs an explorer write in the host's active folder session. Without this, the tree is read-only. */
|
|
42
|
+
mutate?(operation: ExplorerMutation): Promise<void>;
|
|
43
|
+
git?: ExplorerGit;
|
|
44
|
+
isCurrent?(): boolean;
|
|
22
45
|
};
|
|
23
46
|
/**
|
|
24
47
|
* Describes the files of a project folder for `ProjectFolderExplorer`'s `descriptions`: the project, manifest and
|
|
@@ -35,3 +58,25 @@ export declare function describeProjectFolder(project: Project, locale?: string,
|
|
|
35
58
|
* file. Needs React 16.14–18 from the host.
|
|
36
59
|
*/
|
|
37
60
|
export declare function ProjectFolderExplorer(props: ProjectFolderExplorerProps): React.JSX.Element;
|
|
61
|
+
/** Follows marks for the files under `directory`, by path relative to it. Returns the function that stops it. */
|
|
62
|
+
export type FollowMarks = (directory: FileSystemDirectoryHandle, update: (marks: ReadonlyMap<string, ExplorerMark>) => void) => () => void;
|
|
63
|
+
export type FollowFileStatuses = (directory: FileSystemDirectoryHandle, update: (statuses: ReadonlyMap<string, ExplorerFileStatus>) => void) => () => void;
|
|
64
|
+
type FolderViewProps = {
|
|
65
|
+
vm: object;
|
|
66
|
+
locale?: string;
|
|
67
|
+
marks?: FollowMarks;
|
|
68
|
+
fileStatuses?: FollowFileStatuses;
|
|
69
|
+
git?: FollowExplorerGit;
|
|
70
|
+
/** Opens a transient file tab in the host workspace. */
|
|
71
|
+
openFile?(request: FilePreviewRequest): boolean;
|
|
72
|
+
/** Reads the latest committed version of a file, when the host has access to a Git repository. */
|
|
73
|
+
readBaseline?: ReadFileBaseline;
|
|
74
|
+
};
|
|
75
|
+
export type { FileBaseline, FilePreviewRequest, ReadFileBaseline } from './file-preview.js';
|
|
76
|
+
/**
|
|
77
|
+
* Renders the explorer of the project folder open for `vm`, for a side panel of the host: its files with what each is
|
|
78
|
+
* for, and `marks` (such as the Git status) when given. It follows the folder as it opens, closes and saves; with no
|
|
79
|
+
* folder open it offers Open Project Folder…, and it renders nothing while no project folder is mounted for `vm`.
|
|
80
|
+
* Pass the same `marks` function across renders, or the marks are followed again.
|
|
81
|
+
*/
|
|
82
|
+
export declare function renderProjectFolderExplorer(createElement: (component: any, props: any, ...children: any[]) => any, { vm, locale, marks, fileStatuses, git, openFile, readBaseline }: FolderViewProps): any;
|