@kubohiroya/turbowarp-plus-editor-workbench 0.23.0 → 0.24.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 +51 -1
- package/README.md +51 -1
- package/dist/project-file-dialogs.d.ts +104 -4
- package/dist/project-file-dialogs.js +357 -6
- package/dist/project-file-menu.d.ts +16 -1
- package/dist/project-file-menu.js +14 -4
- package/dist/save-name.d.ts +33 -0
- package/dist/save-name.js +126 -0
- package/package.json +1 -1
- package/src/project-file-dialogs.ts +408 -7
- package/src/project-file-menu.css +55 -0
- package/src/project-file-menu.tsx +31 -6
- package/src/save-name.ts +130 -0
package/README.ja.md
CHANGED
|
@@ -121,7 +121,7 @@ turbowarp-plus-editor の `packages/editor-ui` と `packages/editor-backpack`
|
|
|
121
121
|
| --- | --- |
|
|
122
122
|
| `./project-info-menu` | 作品と設定のメニュー。作品名の欄と、ホストが渡す GUI の表示設定を含む |
|
|
123
123
|
| `./edit-menu` | 編集メニューのワークスペースの操作、復元、置換のショートカット |
|
|
124
|
-
| `./project-file-menu`・`./project-file-dialogs` |
|
|
124
|
+
| `./project-file-menu`・`./project-file-dialogs` | ファイルメニュー、新しいプロジェクトを作成…(メモリ上・フォルダ・GitHub の新しいリポジトリ)、プロジェクトのコピーを保存(現在の形式・埋め込み・フォルダ、GitHub の新しいリポジトリ)、保存用の名前、書き出しの表示、拡張の置き場所のフォーム |
|
|
125
125
|
| `./project-search` | 作品全体の検索と置換のボックス(検索そのものは `@kubohiroya/turbowarp-plus-editor-project-model` にある) |
|
|
126
126
|
| `./project-load-progress`・`./project-load-progress-view`・`./project-size-approval` | 読み込みの進み具合と、標準の上限を超える作品を開く前の確認 |
|
|
127
127
|
| `./stage-controls`・`./stage-controls-view` | 拡張が登録するステージの操作と、デバッガーと録画のボタンを含むメニューバーの表示 |
|
|
@@ -135,6 +135,56 @@ turbowarp-plus-editor の `packages/editor-ui` と `packages/editor-backpack`
|
|
|
135
135
|
|
|
136
136
|
これらは同じ作者が書いたもので、移すときに GPL-3.0 から MPL-2.0 にした。由来の監査は [turbowarp-plus-packages の移行計画](https://github.com/kubohiroya/turbowarp-plus-packages/blob/main/docs/editor-migration-plan.ja.md)の「由来の監査(7b)」にある。作品のメニューの Mark GitHub と Law のアイコンは GitHub Octicons(MIT)のもの。`NOTICE` を参照。
|
|
137
137
|
|
|
138
|
+
### ファイルメニュー:新しいプロジェクトを作成…・プロジェクトのコピーを保存…
|
|
139
|
+
|
|
140
|
+
ファイルメニューの先頭は「新しいプロジェクトを作成…」、保存の区切りには「プロジェクトのコピーを保存…」が並ぶ(コマンドの id は `save-as` のままなので、アイコンとホストはそのまま動く。未保存の印から開く保存の一覧も同じ表記)。ホストが `entries.createIn` を渡さないときは、先頭の項目は「新しいプロジェクトを作成」のままで、`entries.create` を直接呼ぶ。
|
|
141
|
+
|
|
142
|
+
**新しいプロジェクトを作成…** ホストが `entries.createIn` を渡すと、項目は `openNewProjectDialog(document, locale, options)` を開く。中身は `renderNewProjectForm(document, locale, options, close)` で、ホストが自分のダイアログに載せるときは `projectFileDialogTitle('new', locale)` を題名にする。作成先を選ぶ。
|
|
143
|
+
|
|
144
|
+
| 作成先 | 出す条件 | 要求 |
|
|
145
|
+
| --- | --- | --- |
|
|
146
|
+
| メモリ上の SB3(既定) | いつも | 今までどおり `entries.create` を呼ぶ(`create` が無いときは `createIn` に `{destination: 'memory'}`) |
|
|
147
|
+
| ブラウザー内のプロジェクトフォルダ | `newProject.browserFolders` | `{destination: 'browser', title, saveName}` |
|
|
148
|
+
| 手元のプロジェクトフォルダ | `newProject.deviceFolders` が `true`。`false` なら「フォルダを開く…」と同じ理由を添えて無効で出す | `{destination: 'device', title, saveName}` |
|
|
149
|
+
| Git のリモートリポジトリ | `newProject.github`(`connectForCreation`・`licenses`)と、作業用の写しの置き場所がある | `{destination: 'github', title, saveName, draft, workingCopy: 'browser' \| 'device'}` |
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
entries.createIn = (request: NewProjectRequest, signal: AbortSignal) => Promise<'created' | 'cancelled'>;
|
|
153
|
+
entries.newProject = {defaultTitle: 'Scratch の作品', browserFolders: true, deviceFolders: canPickFolders,
|
|
154
|
+
github: {connectForCreation, licenses}};
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
- フォルダとリポジトリでは、作品名(初期値は `newProject.defaultTitle`)と保存用の名前を決める。作品名が保存用の名前の規則に収まればそのまま使い、収まらなければダイアログの中で規則を案内し、`suggestSaveName(title)` を初期値にして保存用の名前を入力してもらう。
|
|
158
|
+
- GitHub では、コピーの保存と同じリポジトリの入力(作成先、リポジトリ名、概要、トピック、ライセンス、公開範囲)を使い、接続して確認の段を経たうえで、作業用の写しの置き場所(手元のフォルダは上と同じ条件)を選ぶ。リポジトリ名の初期値は保存用の名前で、要求の `saveName` はリポジトリ名(`draft.name`)になる。
|
|
159
|
+
- `createIn` は作品を開き終えたら `created` を返し、ダイアログが閉じる。`cancelled`(フォルダの選択を取り消したときなど)ならダイアログは開いたまま。Error で失敗すると、その message をダイアログに出す。`signal` はダイアログを閉じると中断される。
|
|
160
|
+
|
|
161
|
+
**保存用の名前。** 作品名をフォルダ名やリポジトリ名に使えないときの保存用の名前は、GitHub のリポジトリ名の規則に従う。半角英数字、`-`・`_`・`.`、100 文字まで。`.` と `..`、末尾の `.git` は使えない。
|
|
162
|
+
|
|
163
|
+
- `isValidSaveName(name)` は規則に合うかを返す(`.git` は大文字・小文字を区別しない)。
|
|
164
|
+
- `suggestSaveName(title)` は作品名から ASCII の候補を作る(アクセントを外し、小文字にし、ほかの文字は `-`)。使える文字が残らないとき(日本語だけの作品名など)は `''` を返す。
|
|
165
|
+
- `askSaveName({document, locale, title, current})` は規則を示すモーダルのダイアログで保存用の名前を尋ね、入力のたびに確かめる。OK で名前を、キャンセルで `null` を返す。
|
|
166
|
+
|
|
167
|
+
**保存先の無い作品の「プロジェクトを保存」。** 「プロジェクトを保存」(`save`、Ctrl/⌘+S)は、保存できる作品ならいつも使える。作品のファイルへの上書き(`storage.overwrite`)か、フォルダへの保存(`folder.save`)をし、どちらも無い作品(メモリ上の新しい作品など)では新しい `entries.saveNew` を呼ぶ。ホストはそこで同じ `renderSaveAsForm`(名前、SB3 かプロジェクトフォルダ、Git と GitHub)を `projectFileDialogTitle('save', locale)`(「プロジェクトを保存」)の題名で開き、その結果を**作品の保存先にする**。SB3 なら `saveProjectAs(..., {mode: 'save', unchanged})` が `storage.finish(handle, title, unchanged)` を呼び、ホストは今までどおりファイルのハンドルと作品名を設定して保存済みにする。フォルダや GitHub の新しいリポジトリなら、以前の「名前を変えて保存」と同じくホストが開いて結び付ける。`projectSaveShortcut(storage, folder, saveNew)` の第 3 引数にも同じものを渡す。ここに「コピーを保存」を渡すと、保存先の無い作品はいつまでも写しを作るだけになる。
|
|
168
|
+
|
|
169
|
+
**プロジェクトのコピーを保存…(ホストに影響する変更)。** 写しを書くだけで、今の作品はそのまま残る。作品名、ファイルのハンドル、フォルダ、未保存の変更は変わらない。既定の `mode: 'copy'` の `saveProjectAs` は `storage.finish` を呼ばず、書き終えたら `committed()` に続けて新しい任意の `storage.copied(handle, title)` を呼ぶ。ホストはここで保存中の表示を終えるだけにする。ダイアログの題名は `projectFileDialogTitle('save-as', locale)`(「プロジェクトのコピーを保存」)。
|
|
170
|
+
|
|
171
|
+
保存先になるかどうか:
|
|
172
|
+
|
|
173
|
+
| 経路 | 保存先 | 呼ばれるもの |
|
|
174
|
+
| --- | --- | --- |
|
|
175
|
+
| 「プロジェクトを保存」(保存先あり) | 今の保存先のまま | `storage.overwrite`・`folder.save` |
|
|
176
|
+
| 「プロジェクトを保存」(保存先なし、`entries.saveNew`) | 新しいファイル・フォルダ・リポジトリが保存先になる | `saveProjectAs({mode: 'save'})` → `storage.finish`。フォルダとリポジトリはホストが結び付ける |
|
|
177
|
+
| 「プロジェクトのコピーを保存…」(`entries.saveAs`) | 変わらない | `saveProjectAs()`(写し)→ `storage.copied`。ホストはフォルダもリポジトリも結び付けない |
|
|
178
|
+
|
|
179
|
+
今の「名前を変えて保存」を結線しているホストは、写しの経路で次をやめる。
|
|
180
|
+
|
|
181
|
+
1. `committed()` の中の `detachFolder()`(作品はプロジェクトフォルダに結び付いたまま)。
|
|
182
|
+
2. 写しの後にファイルのハンドルと作品名を設定すること(`storage.finish` の中の `onSetFileHandle(handle)` と `onSetProjectTitle(title)`。写しでは `finish` は呼ばれない)。代わりに `storage.copied` を用意し、保存の完了の通知はそこで出してよい。
|
|
183
|
+
3. 作品を保存済みにすること(`finishedSaving()`・`onProjectUnchanged()`)と、作品のプロパティの保存の受領(`commitMetadata()`)や組み込みデータの確定(`embed()`)を、作品そのものを保存したかのように確定すること。
|
|
184
|
+
4. フォルダへの写し(`createFolder`)や、コピーのダイアログから作った GitHub のリポジトリを、利用者が開くと選ばないのに開いたり結び付けたりすること。
|
|
185
|
+
|
|
186
|
+
そのうえで、以前の「名前を変えて保存」の動き(上の 1〜4 を含む)は `mode: 'save'` にして `entries.saveNew`(と `projectSaveShortcut` の第 3 引数)に結線する。
|
|
187
|
+
|
|
138
188
|
## 検証
|
|
139
189
|
|
|
140
190
|
`npm test` で配分・縦横比・設定の読み書きを、`npm run test:browser` で独立した試験用ホストを検証する。試験用ホストを手動で開くには、このディレクトリで `npm install` と `python3 -m http.server` を実行し、`/example/` を表示する。
|
package/README.md
CHANGED
|
@@ -123,7 +123,7 @@ These moved here from `packages/editor-ui` and `packages/editor-backpack` in tur
|
|
|
123
123
|
| --- | --- |
|
|
124
124
|
| `./project-info-menu` | The project and settings menu, with the project title field and the GUI's display settings the host passes in |
|
|
125
125
|
| `./edit-menu` | The Edit menu's workspace commands, restore and the replace shortcut |
|
|
126
|
-
| `./project-file-menu`, `./project-file-dialogs` | The File menu, Save
|
|
126
|
+
| `./project-file-menu`, `./project-file-dialogs` | The File menu, Create New Project… (in memory, a folder, or a new GitHub repository), Save a Copy of the Project (current, embedded or folder, and a new GitHub repository), save names, the export view and the extension storage form |
|
|
127
127
|
| `./project-search` | The project-wide search and replace box (the search itself is in `@kubohiroya/turbowarp-plus-editor-project-model`) |
|
|
128
128
|
| `./project-load-progress`, `./project-load-progress-view`, `./project-size-approval` | Loading progress, and asking before opening a project over the standard size limit |
|
|
129
129
|
| `./stage-controls`, `./stage-controls-view` | The stage controls that extensions register, and their view on the menu bar with the debugger and recorder buttons |
|
|
@@ -137,6 +137,56 @@ The debugger button comes from a GUI add-on. When handing it to `setDebuggerButt
|
|
|
137
137
|
|
|
138
138
|
These came from the same author and changed from GPL-3.0 to MPL-2.0 in the move. The provenance audit is in the "由来の監査(7b)" section of the [migration plan in turbowarp-plus-packages](https://github.com/kubohiroya/turbowarp-plus-packages/blob/main/docs/editor-migration-plan.ja.md). The Mark GitHub and Law icons in the project menu are from GitHub Octicons (MIT); see `NOTICE`.
|
|
139
139
|
|
|
140
|
+
### File menu: Create New Project… and Save a Copy of the Project…
|
|
141
|
+
|
|
142
|
+
The File menu starts with **Create New Project…** and its save section has **Save a Copy of the Project…** (the command id stays `save-as`, so its icon and the hosts keep working; the unsaved-changes popup uses the same label). Without `entries.createIn` the first item keeps the label **Create New Project** and calls `entries.create` directly.
|
|
143
|
+
|
|
144
|
+
**Create New Project…** When the host passes `entries.createIn`, the item opens `openNewProjectDialog(document, locale, options)`, a modal dialog with `renderNewProjectForm(document, locale, options, close)` (a host can show the form in its own dialog and title it with `projectFileDialogTitle('new', locale)`). The dialog chooses where to create the project:
|
|
145
|
+
|
|
146
|
+
| Choice | Offered when | Request |
|
|
147
|
+
| --- | --- | --- |
|
|
148
|
+
| In memory (SB3), the default | always | calls `entries.create`, as before (`{destination: 'memory'}` to `createIn` when there is no `create`) |
|
|
149
|
+
| Project folder in this browser | `newProject.browserFolders` | `{destination: 'browser', title, saveName}` |
|
|
150
|
+
| Project folder on this device | `newProject.deviceFolders` is `true`; with `false` it is shown disabled with the reason used for Open Folder… | `{destination: 'device', title, saveName}` |
|
|
151
|
+
| Git remote repository (GitHub) | `newProject.github` (`connectForCreation`, `licenses`) and a place for the working copy | `{destination: 'github', title, saveName, draft, workingCopy: 'browser' \| 'device'}` |
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
entries.createIn = (request: NewProjectRequest, signal: AbortSignal) => Promise<'created' | 'cancelled'>;
|
|
155
|
+
entries.newProject = {defaultTitle: 'Scratch Project', browserFolders: true, deviceFolders: canPickFolders,
|
|
156
|
+
github: {connectForCreation, licenses}};
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
- A folder or a repository takes the project title (prefilled with `newProject.defaultTitle`) and a save name. A title that is a valid save name is used as is; otherwise the dialog explains the rule inline and asks for a save name, starting from `suggestSaveName(title)`.
|
|
160
|
+
- For GitHub the form reuses the repository fields of Save a Copy (owner, repository name, description, topics, license, visibility), connects, shows the review step, and asks where to keep the working copy (the device folder follows the same rule as above). The repository name starts from the save name, and `saveName` in the request is the repository name (`draft.name`).
|
|
161
|
+
- `createIn` resolves `created` once the project is open, which closes the dialog, or `cancelled` (for example when the person cancels the folder picker), which keeps it open. A rejection shows the Error's message in the dialog. `signal` aborts when the dialog is dismissed.
|
|
162
|
+
|
|
163
|
+
**Save names.** The name a project is saved under where its title cannot be used, as a folder or a GitHub repository name, follows the GitHub repository name rule: letters, digits, `-`, `_` and `.`, up to 100 characters, not `.` or `..`, and not ending in `.git`.
|
|
164
|
+
|
|
165
|
+
- `isValidSaveName(name)` checks the rule (case-insensitively for `.git`).
|
|
166
|
+
- `suggestSaveName(title)` returns an ASCII slug of the title (accents removed, lower case, other characters as `-`), or `''` when nothing usable remains, as for a title only in Japanese.
|
|
167
|
+
- `askSaveName({document, locale, title, current})` asks for a save name in a modal dialog with the rule, validates as the person types, and resolves the name on OK or `null` on Cancel.
|
|
168
|
+
|
|
169
|
+
**Save Project with no save target.** Save Project (`save`, Ctrl/⌘+S) is enabled whenever the project can be saved. It overwrites the project's file (`storage.overwrite`) or saves into its folder (`folder.save`); a project with neither, such as a new project in memory, runs the new `entries.saveNew`. The host opens the same `renderSaveAsForm` there (name, SB3 or project folder, Git and GitHub), titled `projectFileDialogTitle('save', locale)` ("Save Project"), and the result **becomes the save target**: for an SB3, `saveProjectAs(..., {mode: 'save', unchanged})` calls `storage.finish(handle, title, unchanged)`, where the host sets the file handle and title and marks the project saved as before; for a folder or a new GitHub repository the host opens and attaches it, as the old Save As did. Pass the same action as the third argument of `projectSaveShortcut(storage, folder, saveNew)`; passing Save a Copy there would leave such a project copying forever.
|
|
170
|
+
|
|
171
|
+
**Save a Copy of the Project… (breaking for hosts).** Saving a copy writes a copy and leaves the project where it is: its title, file handle, folder and unsaved changes stay. `saveProjectAs` in its default `mode: 'copy'` never calls `storage.finish`; after writing it runs `committed()` and then the new optional `storage.copied(handle, title)`, where the host only ends its save indicator. Title the dialog with `projectFileDialogTitle('save-as', locale)` ("Save a Copy of the Project").
|
|
172
|
+
|
|
173
|
+
Which path attaches:
|
|
174
|
+
|
|
175
|
+
| Path | Becomes the save target | Hooks |
|
|
176
|
+
| --- | --- | --- |
|
|
177
|
+
| Save Project, with a target | stays the same target | `storage.overwrite` / `folder.save` |
|
|
178
|
+
| Save Project, no target (`entries.saveNew`) | yes: the new file, folder or repository | `saveProjectAs({mode: 'save'})` → `storage.finish`; the host attaches a folder or repository |
|
|
179
|
+
| Save a Copy of the Project… (`entries.saveAs`) | never | `saveProjectAs()` (copy) → `storage.copied`; the host does not attach a folder or repository |
|
|
180
|
+
|
|
181
|
+
A host that wired the old Save As must, for the copy path, stop:
|
|
182
|
+
|
|
183
|
+
1. calling `detachFolder()` in `committed()` (the project keeps its project folder);
|
|
184
|
+
2. setting the file handle and the project title after the copy (`onSetFileHandle(handle)` and `onSetProjectTitle(title)` in its `storage.finish`, which the copy no longer calls); implement `storage.copied` instead, which may show the save-success alert;
|
|
185
|
+
3. marking the project as saved (`finishedSaving()`/`onProjectUnchanged()`), and committing the project properties' deferred save receipt (`commitMetadata()`) or the embedded-payload commit (`embed()`) as if the project itself had been saved;
|
|
186
|
+
4. opening or attaching the new folder after a folder copy (`createFolder`), or after a new GitHub repository is set up from the copy dialog, unless the person chooses to open it.
|
|
187
|
+
|
|
188
|
+
and wire `entries.saveNew` (and the third argument of `projectSaveShortcut`) to the old Save As behaviour with `mode: 'save'`, keeping all of the above there.
|
|
189
|
+
|
|
140
190
|
## Verification
|
|
141
191
|
|
|
142
192
|
Run `npm test` to verify split sizing, aspect ratios, and settings persistence. Run `npm run test:browser` to test the standalone host. To open the test host manually, run `npm install` and `python3 -m http.server` in this directory, then open `/example/`.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CreationInteraction, GitHubCreationAccount, GitHubRepositoryDraft, RepositoryCreationControls, RepositoryCreationProgress } from '@kubohiroya/turbowarp-plus-editor-git/project-repository-creation';
|
|
2
|
+
export { askSaveName, isValidSaveName, suggestSaveName } from './save-name.js';
|
|
2
3
|
export type Action = () => void;
|
|
3
4
|
export type FolderActions = {
|
|
4
5
|
open: Action;
|
|
@@ -45,9 +46,27 @@ export interface ProjectFileStorage {
|
|
|
45
46
|
pick?: (filename: string) => Promise<FileSystemFileHandle>;
|
|
46
47
|
write(handle: FileSystemFileHandle, serialize: Serialize, current: () => boolean): Promise<void>;
|
|
47
48
|
download(filename: string, serialize: Serialize, current: () => boolean): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Called after a copy was written by {@link saveProjectAs} in the `copy` mode, with the file it was written to
|
|
51
|
+
* (`null` for a download) and the title stored in the copy. The host ends its save indicator here. It must not
|
|
52
|
+
* make the copy the current file, change the project title, or mark the project as saved: the project keeps its
|
|
53
|
+
* own file, folder and unsaved changes.
|
|
54
|
+
*/
|
|
55
|
+
copied?(handle: FileSystemFileHandle | null, title: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Called after {@link saveProjectAs} in the `save` mode (Save Project for a project with no save target yet):
|
|
58
|
+
* the written file becomes the project's file (`null` for a download), `title` its title, and `unchanged` says
|
|
59
|
+
* whether the project was not edited while saving, so the host can mark it saved. Never called for a copy.
|
|
60
|
+
*/
|
|
48
61
|
finish(handle: FileSystemFileHandle | null, title: string, unchanged: boolean): void;
|
|
49
62
|
fail(error: unknown): void;
|
|
50
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* The titles of the dialogs this package fills, by the File menu command that opens them: `save` is "Save Project"
|
|
66
|
+
* (the save form for a project with no save target yet), `save-as` is "Save a Copy of the Project" and `new` is
|
|
67
|
+
* "Create New Project".
|
|
68
|
+
*/
|
|
69
|
+
export declare function projectFileDialogTitle(command: 'save' | 'save-as' | 'new', locale: string): "新しいプロジェクトを作成" | "Create New Project" | "プロジェクトを保存" | "Save Project" | "プロジェクトのコピーを保存" | "Save a Copy of the Project";
|
|
51
70
|
/**
|
|
52
71
|
* Saving over the last file or into the project folder first collects edits held by other windows,
|
|
53
72
|
* as Save As does, so a save that does not move the focus to the editor misses nothing. A failed
|
|
@@ -57,10 +76,26 @@ export declare function collectBeforeSaving(storage: ProjectFileStorage, folder:
|
|
|
57
76
|
storage: ProjectFileStorage;
|
|
58
77
|
folder: FolderActions;
|
|
59
78
|
};
|
|
60
|
-
|
|
61
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Save Project and Ctrl/⌘+S: overwrite the project's file or save into its folder; with no save target yet, run
|
|
81
|
+
* `saveNew`, which opens the save form whose result becomes the target. Pass the save-to-a-new-place action here,
|
|
82
|
+
* never Save a Copy, or a project without a target would only ever be copied.
|
|
83
|
+
*/
|
|
84
|
+
export declare function projectSaveShortcut(storage: ProjectFileStorage, folder?: FolderActions, saveNew?: Action): void;
|
|
85
|
+
/**
|
|
86
|
+
* Saves the project as an SB3: picks the file (or downloads it), collects edits held by other windows, serializes
|
|
87
|
+
* it under the file's title and writes it, then runs `committed`.
|
|
88
|
+
*
|
|
89
|
+
* - `mode: 'copy'` (the default, Save a Copy of the Project): the project stays as it was; its file, folder, title
|
|
90
|
+
* and unsaved state do not change. `storage.copied` runs last.
|
|
91
|
+
* - `mode: 'save'` (Save Project with no save target yet): the file becomes the project's save target through
|
|
92
|
+
* `storage.finish(handle, title, unchanged())`.
|
|
93
|
+
*/
|
|
94
|
+
export declare function saveProjectAs(storage: ProjectFileStorage, name: string, { current, unchanged, serialize, committed, collect, mode }: {
|
|
62
95
|
current(): boolean;
|
|
63
|
-
|
|
96
|
+
/** Whether the project was not edited while saving; used by the `save` mode only. */
|
|
97
|
+
unchanged?(): boolean;
|
|
98
|
+
mode?: 'copy' | 'save';
|
|
64
99
|
serialize<T>(title: string, run: () => T): T;
|
|
65
100
|
committed(): void;
|
|
66
101
|
collect?(): Promise<void>;
|
|
@@ -76,4 +111,69 @@ export declare function renderExtensionsForm(document: Document, locale: string,
|
|
|
76
111
|
}[]>;
|
|
77
112
|
change(changes: Map<string, ExtensionStorage>): Promise<void>;
|
|
78
113
|
}): HTMLFormElement;
|
|
79
|
-
|
|
114
|
+
/** Where Create New Project… puts the new project. */
|
|
115
|
+
export type NewProjectDestination = 'memory' | 'browser' | 'device' | 'github';
|
|
116
|
+
/**
|
|
117
|
+
* What the new project dialog asks the host to create. `title` is the project title; `saveName` is the name of the
|
|
118
|
+
* folder (and, for GitHub, of the repository: it equals `draft.name`), always a valid save name
|
|
119
|
+
* ({@link isValidSaveName}). For GitHub, `workingCopy` says where the working copy is kept.
|
|
120
|
+
*/
|
|
121
|
+
export type NewProjectRequest = {
|
|
122
|
+
destination: 'memory';
|
|
123
|
+
} | {
|
|
124
|
+
destination: 'browser' | 'device';
|
|
125
|
+
title: string;
|
|
126
|
+
saveName: string;
|
|
127
|
+
} | {
|
|
128
|
+
destination: 'github';
|
|
129
|
+
title: string;
|
|
130
|
+
saveName: string;
|
|
131
|
+
draft: GitHubRepositoryDraft;
|
|
132
|
+
workingCopy: 'browser' | 'device';
|
|
133
|
+
};
|
|
134
|
+
/** `created` closes the dialog; `cancelled` (the person cancelled a picker, say) keeps it open with its entries. */
|
|
135
|
+
export type NewProjectResult = 'created' | 'cancelled';
|
|
136
|
+
export interface NewProjectGitHub {
|
|
137
|
+
connectForCreation(interaction: CreationInteraction): Promise<GitHubCreationAccount | null>;
|
|
138
|
+
licenses?: readonly {
|
|
139
|
+
id: string;
|
|
140
|
+
label: string;
|
|
141
|
+
}[];
|
|
142
|
+
}
|
|
143
|
+
/** What the host offers in the new project dialog. Only the in-memory project is always offered. */
|
|
144
|
+
export interface NewProjectChoices {
|
|
145
|
+
/** The localized title of a new project, the initial value of the title field. */
|
|
146
|
+
defaultTitle?: string;
|
|
147
|
+
/** Offers a project folder kept in the browser (OPFS). */
|
|
148
|
+
browserFolders?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Offers a project folder on the device: `true` offers it, `false` shows it disabled with the reason (Safari,
|
|
151
|
+
* Firefox), and leaving it out hides it.
|
|
152
|
+
*/
|
|
153
|
+
deviceFolders?: boolean;
|
|
154
|
+
/** Offers a new GitHub repository, with its working copy in the browser or on the device. */
|
|
155
|
+
github?: NewProjectGitHub;
|
|
156
|
+
}
|
|
157
|
+
export interface NewProjectFormOptions extends NewProjectChoices {
|
|
158
|
+
/**
|
|
159
|
+
* Creates the default project in memory, as Create New Project always did. Without it, the in-memory choice
|
|
160
|
+
* calls `createIn({destination: 'memory'})`.
|
|
161
|
+
*/
|
|
162
|
+
create?: Action;
|
|
163
|
+
/**
|
|
164
|
+
* Creates the project. Resolves `created` once the new project is open, or `cancelled` to keep the dialog open;
|
|
165
|
+
* rejects with an Error whose message the dialog shows. `signal` aborts when the dialog is dismissed.
|
|
166
|
+
*/
|
|
167
|
+
createIn(request: NewProjectRequest, signal: AbortSignal): Promise<NewProjectResult>;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The Create New Project… form. The in-memory project is selected first, so Create alone does what Create New
|
|
171
|
+
* Project always did. A folder or a GitHub repository also takes a title, and a save name when the title cannot be
|
|
172
|
+
* used as one. `close` receives `created`, or `cancelled` when the person dismissed the form.
|
|
173
|
+
*/
|
|
174
|
+
export declare function renderNewProjectForm(document: Document, locale: string, options: NewProjectFormOptions, close: (result: NewProjectResult) => void): HTMLFormElement;
|
|
175
|
+
/**
|
|
176
|
+
* Shows {@link renderNewProjectForm} in a modal dialog and resolves `created` or `cancelled` when it closes.
|
|
177
|
+
* Escape cancels it. Without a document body it resolves `cancelled`.
|
|
178
|
+
*/
|
|
179
|
+
export declare function openNewProjectDialog(document: Document, locale: string, options: NewProjectFormOptions): Promise<NewProjectResult>;
|