@kubohiroya/turbowarp-plus-editor-git 0.9.0 → 0.11.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.
@@ -0,0 +1,27 @@
1
+ import type { ProjectBlockLocator, ScratchBlockLocationWorkspace } from './block-diff-location.js';
2
+ /** The parts of a Scratch VM the locator reads to find a stage or sprite. */
3
+ export interface LocatorVM {
4
+ runtime: {
5
+ targets: readonly {
6
+ id: string;
7
+ isOriginal?: boolean;
8
+ isStage: boolean;
9
+ getName(): string;
10
+ }[];
11
+ };
12
+ editingTarget?: {
13
+ id: string;
14
+ } | null;
15
+ }
16
+ export interface EditorBlockLocatorOptions {
17
+ vm: LocatorVM;
18
+ /** Opens the code of one stage or sprite in the Editor, as project search does. */
19
+ openTargetCode(targetId: string): void | Promise<void>;
20
+ /** The Editor's code workspace as it is now, or `null` while none is shown. */
21
+ getWorkspace(): ScratchBlockLocationWorkspace | null | Promise<ScratchBlockLocationWorkspace | null>;
22
+ }
23
+ /**
24
+ * Finds the stage or sprite of a compared version in the open project, opens its code and waits for the block,
25
+ * then centers and outlines it. The caller decides which version matches the open project.
26
+ */
27
+ export declare function createEditorBlockLocator({ vm, openTargetCode, getWorkspace }: EditorBlockLocatorOptions): ProjectBlockLocator;
@@ -3,16 +3,18 @@ import type { FileChange, FileDiff } from './repository.js';
3
3
  import type { labelsFor } from './messages.js';
4
4
  import type { ProjectBlockRenderer } from './scratch-block-diff-renderer.js';
5
5
  import type { ProjectAssetLoader } from './project-assets.js';
6
+ import type { ProjectBlockLocator } from './block-diff-location.js';
6
7
  /** Project sources are the files the panel opens as projects. */
7
8
  export declare const isProjectSource: (path: string) => boolean;
8
9
  /**
9
10
  * Shows one changed file. Project sources are compared as blocks by default, with their text diff one switch away.
10
11
  */
11
- export declare function FileDiffView({ change, diff, labels, locale, renderBlock, loadAsset }: {
12
+ export declare function FileDiffView({ change, diff, labels, locale, renderBlock, loadAsset, locateBlock }: {
12
13
  change: FileChange;
13
14
  diff: FileDiff | null;
14
15
  labels: ReturnType<typeof labelsFor>;
15
16
  locale: string;
16
17
  renderBlock?: ProjectBlockRenderer;
17
18
  loadAsset?: ProjectAssetLoader;
19
+ locateBlock?: ProjectBlockLocator;
18
20
  }): React.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import type { GitConnectionSettings } from './connection-settings.js';
2
2
  import type { ProjectBlockRenderer } from './scratch-block-diff-renderer.js';
3
+ import type { ScratchBlockLocationWorkspace } from './block-diff-location.js';
4
+ export { createScratchBlocksDiffLocator } from './block-diff-location.js';
5
+ export { createEditorBlockLocator } from './editor-block-locator.js';
3
6
  export { createScratchBlocksDiffRenderer } from './scratch-block-diff-renderer.js';
4
7
  export type { ScratchBlockDiffRendererOptions, ScratchBlocksPort } from './scratch-block-diff-renderer.js';
5
8
  export { openRepository, createReadOnlyFs, GitPanelError } from './repository.js';
@@ -11,6 +14,28 @@ export interface GitHost {
11
14
  isProjectDirty(): boolean;
12
15
  isProjectRunning?(): boolean;
13
16
  subscribe?(listener: (event: 'loaded' | 'changed') => void): () => void;
17
+ /**
18
+ * Opens the panel as a tab of the host's layout, with the same shape as the layout package's DocumentPanelRequest.
19
+ * Returning `false` keeps the modal dialog.
20
+ */
21
+ openPanel?(request: GitPanelRequest): boolean;
22
+ /** Opens the code of one stage or sprite, so a diff can point at its block. Without it, no block is located. */
23
+ openTargetCode?(targetId: string): void | Promise<void>;
24
+ /** The Editor's code workspace as it is now. */
25
+ getWorkspace?(): ScratchBlockLocationWorkspace | null | Promise<ScratchBlockLocationWorkspace | null>;
26
+ }
27
+ export interface GitPanelRequest {
28
+ reference: {
29
+ providerId: string;
30
+ documentId: string;
31
+ };
32
+ filename: string;
33
+ title?: string;
34
+ transient?: boolean;
35
+ mount(element: HTMLElement, close: () => void): {
36
+ requestClose(): void;
37
+ dispose(): void;
38
+ };
14
39
  }
15
40
  export declare function mountGitPanel({ vm, document, host }: {
16
41
  vm: object;