@kubohiroya/turbowarp-plus-editor-workbench 0.28.0 → 0.28.1

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.
@@ -1,5 +1,7 @@
1
1
  /** Give the browser a frame before starting work that may block its main thread. */
2
- export declare function withWaitCursor<T>(documents: Iterable<Document>, run: () => T): Promise<Awaited<T>>;
2
+ export declare function withWaitCursor<T>(documents: Iterable<Document>, run: () => T, { releaseAfterPaint }?: {
3
+ releaseAfterPaint?: boolean;
4
+ }): Promise<Awaited<T>>;
3
5
  /** Temporarily restore the normal cursor while an operation needs an answer. */
4
6
  export declare function withoutWaitCursor<T>(document: Document | undefined, ask: () => T): Promise<Awaited<T>>;
5
7
  interface Target {
@@ -38,7 +38,7 @@ function afterPaint(document) {
38
38
  });
39
39
  }
40
40
  /** Give the browser a frame before starting work that may block its main thread. */
41
- export async function withWaitCursor(documents, run) {
41
+ export async function withWaitCursor(documents, run, { releaseAfterPaint = false } = {}) {
42
42
  const visible = [...new Set(documents)].filter(document => document?.head && document.defaultView && !document.defaultView.closed);
43
43
  const release = visible.map(holdCursor);
44
44
  try {
@@ -46,7 +46,13 @@ export async function withWaitCursor(documents, run) {
46
46
  return await run();
47
47
  }
48
48
  finally {
49
- release.forEach(done => done());
49
+ const finish = () => release.forEach(done => done());
50
+ // Resolving the project load lets the host mount its initial code view. Keep the already-painted
51
+ // wait cursor through that synchronous work without delaying the host's load continuation.
52
+ if (releaseAfterPaint)
53
+ void Promise.all(visible.map(afterPaint)).then(finish, finish);
54
+ else
55
+ finish();
50
56
  }
51
57
  }
52
58
  /** Temporarily restore the normal cursor while an operation needs an answer. */
@@ -30,7 +30,7 @@ export function createProjectTools({ installEditorExtensionHost, installProjectP
30
30
  const installProjectToolsHost = (vm, settings = {}, enabled = PROJECT_TOOLS_ENABLED) => {
31
31
  const diagnostics = createProjectDiagnostics();
32
32
  const document = settings.document || globalThis.document;
33
- const runProjectLoad = document ? (run) => withWaitCursor([document], run) : undefined;
33
+ const runProjectLoad = document ? (run) => withWaitCursor([document], run, { releaseAfterPaint: true }) : undefined;
34
34
  const host = installEditorExtensionHost(vm, { ...settings, showDiagnostics: false, runProjectLoad,
35
35
  projectArchives: editorProjectArchives,
36
36
  captureProjectProgress: () => captureProjectLoad(vm),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-plus-editor-workbench",
3
- "version": "0.28.0",
3
+ "version": "0.28.1",
4
4
  "description": "The TurboWarp Plus Editor workbench: layout, dockable sprite tabs, stage, debugger tab and file menu",
5
5
  "type": "module",
6
6
  "license": "MPL-2.0",
@@ -212,7 +212,7 @@
212
212
  "@turbowarp/jszip": "3.12.0",
213
213
  "@kubohiroya/turbowarp-extension-loader": "0.11.1",
214
214
  "@kubohiroya/turbowarp-plus-editor-project-folder": "0.20.1",
215
- "@kubohiroya/turbowarp-plus-editor-code-views": "0.22.0",
215
+ "@kubohiroya/turbowarp-plus-editor-code-views": "0.22.1",
216
216
  "@kubohiroya/turbowarp-extension-security-dialog": "0.9.0"
217
217
  },
218
218
  "repository": {
@@ -221,7 +221,7 @@
221
221
  },
222
222
  "dependencies": {
223
223
  "@kubohiroya/turbowarp-plus-editor-project-model": "0.2.0",
224
- "@kubohiroya/turbowarp-plus-editor-sprite-panes": "0.11.0",
224
+ "@kubohiroya/turbowarp-plus-editor-sprite-panes": "0.11.1",
225
225
  "@kubohiroya/turbowarp-script-transfer": "0.1.5",
226
226
  "dockview": "8.8.3"
227
227
  },
@@ -38,14 +38,19 @@ function afterPaint(document: Document) {
38
38
  }
39
39
 
40
40
  /** Give the browser a frame before starting work that may block its main thread. */
41
- export async function withWaitCursor<T>(documents: Iterable<Document>, run: () => T): Promise<Awaited<T>> {
41
+ export async function withWaitCursor<T>(documents: Iterable<Document>, run: () => T,
42
+ {releaseAfterPaint = false}: {releaseAfterPaint?: boolean} = {}): Promise<Awaited<T>> {
42
43
  const visible = [...new Set(documents)].filter(document => document?.head && document.defaultView && !document.defaultView.closed);
43
44
  const release = visible.map(holdCursor);
44
45
  try {
45
46
  await Promise.all(visible.map(afterPaint));
46
47
  return await run();
47
48
  } finally {
48
- release.forEach(done => done());
49
+ const finish = () => release.forEach(done => done());
50
+ // Resolving the project load lets the host mount its initial code view. Keep the already-painted
51
+ // wait cursor through that synchronous work without delaying the host's load continuation.
52
+ if (releaseAfterPaint) void Promise.all(visible.map(afterPaint)).then(finish, finish);
53
+ else finish();
49
54
  }
50
55
  }
51
56
 
@@ -51,7 +51,8 @@ export function createProjectTools({installEditorExtensionHost, installProjectPr
51
51
  const installProjectToolsHost = (vm, settings: Parameters<typeof installEditorExtensionHost>[1] & Parameters<typeof installProjectProperties>[1] = {}, enabled = PROJECT_TOOLS_ENABLED) => {
52
52
  const diagnostics = createProjectDiagnostics();
53
53
  const document = settings.document || globalThis.document;
54
- const runProjectLoad = document ? <T>(run: () => Promise<T>) => withWaitCursor([document], run) : undefined;
54
+ const runProjectLoad = document ? <T>(run: () => Promise<T>) =>
55
+ withWaitCursor([document], run, {releaseAfterPaint: true}) : undefined;
55
56
  const host = installEditorExtensionHost(vm, {...settings, showDiagnostics: false, runProjectLoad,
56
57
  projectArchives: editorProjectArchives,
57
58
  captureProjectProgress: () => captureProjectLoad(vm),