@kubohiroya/turbowarp-plus-editor-git 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 +22 -6
- package/README.md +9 -1
- package/dist/block-diff-preview.d.ts +18 -2
- package/dist/file-diff-view.d.ts +3 -1
- package/dist/index.js +359 -15
- package/dist/{libesm-OWRWzmu_.js → project-asset-paths-KV715791.js} +23 -1
- package/dist/project-asset-paths.d.ts +12 -0
- package/dist/project-assets.d.ts +23 -0
- package/dist/project-change-list.d.ts +81 -0
- package/dist/project-change-model.d.ts +73 -0
- package/dist/project-source-diff.d.ts +7 -1
- package/dist/project-source-diff.js +10 -7
- package/dist/project-source-review-model.d.ts +4 -1
- package/dist/project-source-review.d.ts +11 -2
- package/dist/{repository-DplMQiuo.js → repository-VBp-UNWc.js} +134 -3
- package/dist/repository.d.ts +34 -0
- package/dist/repository.js +1 -1
- package/dist/{scratch-block-diff-renderer-CLYoOIB2.js → scratch-block-diff-renderer-DZR8ep-T.js} +708 -90
- package/dist/scratch-block-diff-renderer.d.ts +69 -6
- package/dist/style.css +48 -2
- package/package.json +7 -2
- package/src/block-diff-preview.tsx +89 -8
- package/src/file-diff-view.tsx +4 -3
- package/src/github-pull-requests.ts +73 -6
- package/src/index.tsx +42 -12
- package/src/project-asset-paths.ts +33 -0
- package/src/project-assets.ts +78 -0
- package/src/project-change-list.tsx +210 -0
- package/src/project-change-model.ts +212 -0
- package/src/project-source-diff.css +31 -2
- package/src/project-source-diff.tsx +17 -7
- package/src/project-source-review-model.ts +4 -1
- package/src/project-source-review.tsx +67 -27
- package/src/repository.ts +107 -2
- package/src/scratch-block-diff-renderer.ts +129 -11
- package/src/style.css +17 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The largest asset a thumbnail reads. */
|
|
2
|
+
export declare const assetLimit: number;
|
|
3
|
+
/** The largest sb3-source.json read to find the assets directory. */
|
|
4
|
+
export declare const folderSettingsLimit: number;
|
|
5
|
+
/** Asset names are plain `<md5>.<ext>` file names; anything else could address a path outside the assets directory. */
|
|
6
|
+
export declare const isAssetName: (name: unknown) => name is string;
|
|
7
|
+
/**
|
|
8
|
+
* The assets directory named by one version of a project folder's `sb3-source.json`, as path segments relative to the
|
|
9
|
+
* folder. `assets` when that file or its `assetsDirectory` field is missing or unreadable. `null` when the field names
|
|
10
|
+
* anything other than a plain relative path inside the folder.
|
|
11
|
+
*/
|
|
12
|
+
export declare function assetsDirectoryParts(settings: string | null): string[] | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ProjectTarget } from './project-source-patch.js';
|
|
2
|
+
export type ProjectVersion = 'before' | 'after';
|
|
3
|
+
/**
|
|
4
|
+
* Reads one asset of one version of a project file by its `md5ext` name (for example `0123…cdef.svg`), from the
|
|
5
|
+
* assets directory of that project. Resolves `null` when that version has no readable file of that name.
|
|
6
|
+
*/
|
|
7
|
+
export type ProjectAssetLoader = (request: {
|
|
8
|
+
version: ProjectVersion;
|
|
9
|
+
md5ext: string;
|
|
10
|
+
signal: AbortSignal;
|
|
11
|
+
}) => Promise<Blob | null>;
|
|
12
|
+
/** The costume a sprite shows, or the backdrop the stage shows, when the project data names an image file for it. */
|
|
13
|
+
export declare function currentCostume(target: ProjectTarget): {
|
|
14
|
+
name: string;
|
|
15
|
+
md5ext: string;
|
|
16
|
+
type: string;
|
|
17
|
+
} | null;
|
|
18
|
+
/** The image type of an asset file name, or `undefined` for sounds and anything that is not an image. */
|
|
19
|
+
export declare function assetImageType(md5ext: string): string | undefined;
|
|
20
|
+
/** Loads one image asset of one version as an object URL, or `null` while it is unavailable or not an image. */
|
|
21
|
+
export declare function useAssetImage(md5ext: string | undefined, version: ProjectVersion, loadAsset?: ProjectAssetLoader): string | null;
|
|
22
|
+
/** Loads the current costume of one version of a target as an object URL for an image, or `null` while it is unavailable. */
|
|
23
|
+
export declare function useCostumeImage(target: ProjectTarget | undefined, version: ProjectVersion, loadAsset?: ProjectAssetLoader): string | null;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChangedFile, ProjectChangeList, ProjectElementChange, ProjectTargetChanges } from './project-change-model.js';
|
|
3
|
+
import type { ProjectAssetLoader } from './project-assets.js';
|
|
4
|
+
import type { ChangeGroup, FileChange, Repository, Snapshot } from './repository.js';
|
|
5
|
+
import type { ProjectBlockRenderer } from './scratch-block-diff-renderer.js';
|
|
6
|
+
declare const en: {
|
|
7
|
+
title: string;
|
|
8
|
+
stage: string;
|
|
9
|
+
code: (count: number) => string;
|
|
10
|
+
costumes: string;
|
|
11
|
+
backdrops: string;
|
|
12
|
+
sounds: string;
|
|
13
|
+
data: string;
|
|
14
|
+
settings: string;
|
|
15
|
+
project: string;
|
|
16
|
+
other: string;
|
|
17
|
+
added: string;
|
|
18
|
+
removed: string;
|
|
19
|
+
updated: string;
|
|
20
|
+
files: string;
|
|
21
|
+
before: string;
|
|
22
|
+
after: string;
|
|
23
|
+
absent: string;
|
|
24
|
+
loading: string;
|
|
25
|
+
unreadable: string;
|
|
26
|
+
fileList: string;
|
|
27
|
+
property: string;
|
|
28
|
+
format: string;
|
|
29
|
+
rate: string;
|
|
30
|
+
samples: string;
|
|
31
|
+
file: string;
|
|
32
|
+
noImage: string;
|
|
33
|
+
groups: Record<ChangeGroup, string>;
|
|
34
|
+
};
|
|
35
|
+
type Labels = typeof en;
|
|
36
|
+
export declare const projectChangeLabels: (locale: string) => Labels;
|
|
37
|
+
export interface ProjectChanges {
|
|
38
|
+
list: ProjectChangeList;
|
|
39
|
+
sources: {
|
|
40
|
+
before: string | null;
|
|
41
|
+
after: string | null;
|
|
42
|
+
};
|
|
43
|
+
loadAsset: ProjectAssetLoader;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Reads the selected project folder in the last commit and the working tree (or a commit and its parent) and arranges
|
|
47
|
+
* the changed files by stage, sprite and element. `undefined` while there is no project; `'loading'` and `'unreadable'`
|
|
48
|
+
* tell the panel to keep the list by file.
|
|
49
|
+
*/
|
|
50
|
+
export declare function useProjectChanges(repository: Repository | null, snapshot: Snapshot | null, project: string | null, commit: string | null, changes: readonly FileChange[]): ProjectChanges | 'loading' | 'unreadable' | undefined;
|
|
51
|
+
/** The change list arranged by the project's stage, sprites and elements, with files outside the project after them. */
|
|
52
|
+
export declare function ProjectChangeListView({ changes, selected, locale, busy, onSelect, onSelectFile, fileList, fileListOpen, setFileListOpen }: {
|
|
53
|
+
changes: ProjectChanges;
|
|
54
|
+
selected: string | null;
|
|
55
|
+
locale: string;
|
|
56
|
+
busy: boolean;
|
|
57
|
+
onSelect(key: string): void;
|
|
58
|
+
onSelectFile(file: ChangedFile): void;
|
|
59
|
+
fileList: React.ReactNode;
|
|
60
|
+
fileListOpen: boolean;
|
|
61
|
+
setFileListOpen(open: boolean): void;
|
|
62
|
+
}): React.JSX.Element;
|
|
63
|
+
export declare function findElement(list: ProjectChangeList, key: string | null): {
|
|
64
|
+
element: ProjectElementChange;
|
|
65
|
+
target: ProjectTargetChanges;
|
|
66
|
+
} | {
|
|
67
|
+
element: ProjectElementChange;
|
|
68
|
+
target: null;
|
|
69
|
+
} | null;
|
|
70
|
+
/** The details of one selected row: its code, pictures or values in both versions, and the files behind it. */
|
|
71
|
+
export declare function ProjectElementView({ changes, selection, locale, renderBlock, onSelectFile }: {
|
|
72
|
+
changes: ProjectChanges;
|
|
73
|
+
selection: {
|
|
74
|
+
element: ProjectElementChange;
|
|
75
|
+
target: ProjectTargetChanges | null;
|
|
76
|
+
};
|
|
77
|
+
locale: string;
|
|
78
|
+
renderBlock?: ProjectBlockRenderer;
|
|
79
|
+
onSelectFile(file: ChangedFile): void;
|
|
80
|
+
}): React.JSX.Element;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ChangeGroup } from './repository.js';
|
|
2
|
+
import type { ProjectSource, ProjectTarget } from './project-source-patch.js';
|
|
3
|
+
/** One changed file of the repository, with the Git group it was listed under. A path can appear in several groups. */
|
|
4
|
+
export interface ChangedFile {
|
|
5
|
+
path: string;
|
|
6
|
+
group: ChangeGroup;
|
|
7
|
+
}
|
|
8
|
+
export type ProjectElementKind = 'code' | 'costumes' | 'sounds' | 'data' | 'settings';
|
|
9
|
+
export type ProjectChangeStatus = 'added' | 'removed' | 'updated';
|
|
10
|
+
/** One row of the project-shaped change list: something a person recognizes in the Editor. */
|
|
11
|
+
export interface ProjectElementChange {
|
|
12
|
+
/** Stable within one list, for React keys and selection. */
|
|
13
|
+
key: string;
|
|
14
|
+
kind: ProjectElementKind;
|
|
15
|
+
status: ProjectChangeStatus;
|
|
16
|
+
/** Costume or sound name; absent for code, data and settings rows. */
|
|
17
|
+
name?: string;
|
|
18
|
+
/** The costume or sound entry in each version, for costume and sound rows. */
|
|
19
|
+
before?: Record<string, unknown>;
|
|
20
|
+
after?: Record<string, unknown>;
|
|
21
|
+
/** Asset file names (`md5ext`) of each version, for costume and sound rows. */
|
|
22
|
+
md5ext?: {
|
|
23
|
+
before?: string;
|
|
24
|
+
after?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Changed property keys, for data and settings rows (for example `variables`, `x`, `visible`), and for
|
|
28
|
+
* project-level rows (`monitors`, `extensions`, `meta`).
|
|
29
|
+
*/
|
|
30
|
+
properties?: string[];
|
|
31
|
+
/** Number of changed code items (as counted by the review comparison), for code rows. */
|
|
32
|
+
scripts?: number;
|
|
33
|
+
/** The changed repository files behind this row, so the details view can show them with their Git groups. */
|
|
34
|
+
files: ChangedFile[];
|
|
35
|
+
}
|
|
36
|
+
export interface ProjectTargetChanges {
|
|
37
|
+
key: string;
|
|
38
|
+
name: string;
|
|
39
|
+
isStage: boolean;
|
|
40
|
+
status: ProjectChangeStatus;
|
|
41
|
+
before?: ProjectTarget;
|
|
42
|
+
after?: ProjectTarget;
|
|
43
|
+
/** In the order code, costumes, sounds, data, settings; costumes and sounds in their order in the target. */
|
|
44
|
+
elements: ProjectElementChange[];
|
|
45
|
+
}
|
|
46
|
+
export interface ProjectChangeList {
|
|
47
|
+
/** The stage first, then sprites in project order; removed targets after the existing ones. */
|
|
48
|
+
targets: ProjectTargetChanges[];
|
|
49
|
+
/** Project-level changes outside the targets (monitors, extensions, meta and other top-level keys). */
|
|
50
|
+
project: ProjectElementChange[];
|
|
51
|
+
/** Changed files that belong to no element: sb3-source.json, embedded-extensions.json, unreferenced assets and the rest. */
|
|
52
|
+
other: ChangedFile[];
|
|
53
|
+
}
|
|
54
|
+
export interface OrganizeProjectChangesInput {
|
|
55
|
+
/** The project folder relative to the repository root, `''` for the root. */
|
|
56
|
+
folder: string;
|
|
57
|
+
/** The project data of each version, `null` where the version has no project file. */
|
|
58
|
+
before: ProjectSource | null;
|
|
59
|
+
after: ProjectSource | null;
|
|
60
|
+
/** The assets directory of each version, relative to the folder (from sb3-source.json; `assets` by default). */
|
|
61
|
+
assetsDirectory: {
|
|
62
|
+
before: string;
|
|
63
|
+
after: string;
|
|
64
|
+
};
|
|
65
|
+
/** Every changed file in the folder, from all Git groups. */
|
|
66
|
+
files: readonly ChangedFile[];
|
|
67
|
+
}
|
|
68
|
+
/** The Japanese or English name of a project or target property key; unknown keys are returned as they are. */
|
|
69
|
+
export declare function projectPropertyLabel(key: string, locale?: string): string;
|
|
70
|
+
/** The asset file name of a costume or sound entry: `md5ext`, or `assetId.dataFormat`; `''` when it has neither. */
|
|
71
|
+
export declare function assetFileName(entry: Record<string, unknown>): string;
|
|
72
|
+
/** Arranges the changed files of one project folder by stage, sprite and element. Pure; reads nothing. */
|
|
73
|
+
export declare function organizeProjectChanges(input: OrganizeProjectChangesInput): ProjectChangeList;
|
|
@@ -9,8 +9,14 @@ export { createScratchBlocksDiffLocator } from './block-diff-location.js';
|
|
|
9
9
|
export type { ProjectBlockLocation, ProjectBlockLocator, ScratchBlockLocationWorkspace } from './block-diff-location.js';
|
|
10
10
|
export type { BlockPart } from './project-source-patch.js';
|
|
11
11
|
export { createProjectSourceDiff } from './project-source-patch.js';
|
|
12
|
+
export { currentCostume } from './project-assets.js';
|
|
13
|
+
export { assetFileName, organizeProjectChanges, projectPropertyLabel } from './project-change-model.js';
|
|
14
|
+
export type { ChangedFile, OrganizeProjectChangesInput, ProjectChangeList, ProjectChangeStatus, ProjectElementChange, ProjectElementKind, ProjectTargetChanges } from './project-change-model.js';
|
|
15
|
+
export type { ProjectAssetLoader, ProjectVersion } from './project-assets.js';
|
|
12
16
|
export { createScratchBlocksDiffRenderer } from './scratch-block-diff-renderer.js';
|
|
13
|
-
export type { ProjectBlockRenderer, ScratchBlockDiffRendererOptions, ScratchBlocksPort } from './scratch-block-diff-renderer.js';
|
|
17
|
+
export type { BlockPreviewView, BlockPreviewViewport, ProjectBlockRenderer, ProjectBlockRendering, ScratchBlockDiffRendererOptions, ScratchBlocksPort } from './scratch-block-diff-renderer.js';
|
|
18
|
+
export { createPreviewSync } from './block-diff-preview.js';
|
|
19
|
+
export type { PreviewSync } from './block-diff-preview.js';
|
|
14
20
|
export interface ProjectSourceBlockDiffProps {
|
|
15
21
|
patch: string;
|
|
16
22
|
/** Supply the original JSON if the unified patch omits context. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as gitHubRepositoryFromOrigin, c as
|
|
1
|
+
import { _ as compareProjectBlocks, a as gitHubRepositoryFromOrigin, b as readProjectSourceDiff, c as projectPropertyLabel, d as BlockPreview, f as createPreviewSync, i as createGitHubPullRequests, l as ProjectSourceComparison, m as currentCostume, n as createScratchBlocksDiffLocator, o as assetFileName, p as usePreviewSync, s as organizeProjectChanges, t as createScratchBlocksDiffRenderer, u as ProjectSourceReview, v as createProjectSourceDiff } from "./scratch-block-diff-renderer-DZR8ep-T.js";
|
|
2
2
|
import { n as init_objectSpread2, t as _objectSpread2 } from "./objectSpread2-Dkd68nJH.js";
|
|
3
3
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
// src/project-source-diff.tsx
|
|
@@ -19,13 +19,13 @@ var en = {
|
|
|
19
19
|
properties: "Other block properties",
|
|
20
20
|
absent: "No block on this side",
|
|
21
21
|
omitted: (count) => `${count} unchanged blocks omitted from the change list`,
|
|
22
|
-
context: "Highlight in the surrounding
|
|
22
|
+
context: "Highlight in the surrounding code",
|
|
23
23
|
more: "Show more changes",
|
|
24
24
|
noChanges: "No block changes.",
|
|
25
25
|
locate: "Highlight in Editor",
|
|
26
26
|
locating: "Finding the block in the Editor…",
|
|
27
27
|
located: "Highlighted in the Editor.",
|
|
28
|
-
missingLocation: "This version or block is unavailable in the Editor. Open its surrounding
|
|
28
|
+
missingLocation: "This version or block is unavailable in the Editor. Open its surrounding code here.",
|
|
29
29
|
partLegend: "Orange outlines mark changed inputs and fields.",
|
|
30
30
|
otherChanges: "The project also has changes outside its block code.",
|
|
31
31
|
invalid: "This diff could not be read. Use a full-context project diff, or provide the original project.",
|
|
@@ -48,13 +48,13 @@ var ja = {
|
|
|
48
48
|
properties: "その他のブロック属性",
|
|
49
49
|
absent: "この側にはブロックがありません",
|
|
50
50
|
omitted: (count) => `変更のないブロック ${count} 個を一覧から省略`,
|
|
51
|
-
context: "
|
|
51
|
+
context: "元のコード内で強調",
|
|
52
52
|
more: "続きを表示",
|
|
53
53
|
noChanges: "ブロックの変更はありません。",
|
|
54
54
|
locate: "編集画面で強調",
|
|
55
55
|
locating: "編集画面でブロックを検索中…",
|
|
56
56
|
located: "編集画面で強調しました。",
|
|
57
|
-
missingLocation: "
|
|
57
|
+
missingLocation: "編集画面に該当する版またはブロックがありません。元のコードをここで展開できます。",
|
|
58
58
|
partLegend: "オレンジの枠は、変更された入力欄やフィールドです。",
|
|
59
59
|
otherChanges: "ブロックのコード以外にも作品の変更があります。",
|
|
60
60
|
invalid: "差分を読み込めません。全体の文脈を含む差分を使うか、変更前の作品を指定してください。",
|
|
@@ -75,6 +75,7 @@ var propertyLabels = /* @__PURE__ */ new Map([
|
|
|
75
75
|
function ChangeCard({ change, renderBlock, labels, onLocate, location }) {
|
|
76
76
|
var _change$after;
|
|
77
77
|
const [withContext, setWithContext] = useState(false);
|
|
78
|
+
const { sync, toggle } = usePreviewSync(labels === en ? "en" : "ja");
|
|
78
79
|
const notes = [...new Set(change.fields.map((field) => {
|
|
79
80
|
var _propertyLabels$get;
|
|
80
81
|
return labels[(_propertyLabels$get = propertyLabels.get(field)) !== null && _propertyLabels$get !== void 0 ? _propertyLabels$get : "properties"];
|
|
@@ -89,8 +90,10 @@ function ChangeCard({ change, renderBlock, labels, onLocate, location }) {
|
|
|
89
90
|
labels,
|
|
90
91
|
parts: change.parts,
|
|
91
92
|
onLocate: onLocate && (() => onLocate(version)),
|
|
93
|
+
version,
|
|
94
|
+
sync,
|
|
92
95
|
locationStatus: (location === null || location === void 0 ? void 0 : location.version) === version ? location.status : void 0
|
|
93
|
-
}))), /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("input", {
|
|
96
|
+
}))), toggle, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("input", {
|
|
94
97
|
type: "checkbox",
|
|
95
98
|
checked: withContext,
|
|
96
99
|
onChange: (event) => setWithContext(event.currentTarget.checked)
|
|
@@ -166,4 +169,4 @@ function ProjectSourceBlockDiff({ patch, beforeSource, renderBlock, locateBlock,
|
|
|
166
169
|
})
|
|
167
170
|
}, labels.more));
|
|
168
171
|
}
|
|
169
|
-
export { ProjectSourceBlockDiff, ProjectSourceComparison, ProjectSourceReview, createGitHubPullRequests, createProjectSourceDiff, createScratchBlocksDiffLocator, createScratchBlocksDiffRenderer, gitHubRepositoryFromOrigin };
|
|
172
|
+
export { ProjectSourceBlockDiff, ProjectSourceComparison, ProjectSourceReview, assetFileName, createGitHubPullRequests, createPreviewSync, createProjectSourceDiff, createScratchBlocksDiffLocator, createScratchBlocksDiffRenderer, currentCostume, gitHubRepositoryFromOrigin, organizeProjectChanges, projectPropertyLabel };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BlockSide, ProjectSource } from './project-source-patch.js';
|
|
1
|
+
import type { BlockSide, ProjectSource, ProjectTarget } from './project-source-patch.js';
|
|
2
2
|
import type { ScriptBlockMark } from './scratch-block-diff-renderer.js';
|
|
3
3
|
export interface ScriptReviewSide extends BlockSide {
|
|
4
4
|
marks: ScriptBlockMark[];
|
|
@@ -11,6 +11,9 @@ export interface ScriptReview {
|
|
|
11
11
|
export interface TargetReview {
|
|
12
12
|
name: string;
|
|
13
13
|
isStage: boolean;
|
|
14
|
+
/** The stage or sprite in each version, absent where it does not exist. */
|
|
15
|
+
before?: ProjectTarget;
|
|
16
|
+
after?: ProjectTarget;
|
|
14
17
|
scripts: ScriptReview[];
|
|
15
18
|
properties: string[];
|
|
16
19
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ProjectBlockRenderer } from './scratch-block-diff-renderer.js';
|
|
3
|
+
import type { ProjectAssetLoader } from './project-assets.js';
|
|
3
4
|
export type ProjectSourceReviewFile = {
|
|
4
5
|
path: string;
|
|
5
6
|
summary?: string;
|
|
@@ -8,6 +9,7 @@ export type ProjectSourceReviewFile = {
|
|
|
8
9
|
} & ({
|
|
9
10
|
patch: string;
|
|
10
11
|
beforeSource?: string;
|
|
12
|
+
loadAsset?: ProjectAssetLoader;
|
|
11
13
|
} | {
|
|
12
14
|
status: 'added' | 'removed' | 'updated';
|
|
13
15
|
});
|
|
@@ -28,7 +30,14 @@ export interface ProjectSourceComparisonProps {
|
|
|
28
30
|
locale?: string;
|
|
29
31
|
/** Shown after an explanation when either version cannot be read as a project. Without it, only an error is shown. */
|
|
30
32
|
fallback?: React.ReactNode;
|
|
33
|
+
/** Reads the images of both versions for thumbnails. Without it, stages and sprites are shown by name. */
|
|
34
|
+
loadAsset?: ProjectAssetLoader;
|
|
35
|
+
/** Shows only the code of this stage or sprite, without the overview and the changes outside the code. */
|
|
36
|
+
target?: {
|
|
37
|
+
isStage: boolean;
|
|
38
|
+
name: string;
|
|
39
|
+
};
|
|
31
40
|
}
|
|
32
|
-
/** Compares two versions of a project.source.json by stage, sprite and
|
|
33
|
-
export declare function ProjectSourceComparison({ before, after, renderBlock, locale, fallback }: ProjectSourceComparisonProps): React.JSX.Element;
|
|
41
|
+
/** Compares two versions of a project.source.json by stage, sprite and code, as the pull request review does. */
|
|
42
|
+
export declare function ProjectSourceComparison({ before, after, renderBlock, locale, fallback, loadAsset, target }: ProjectSourceComparisonProps): React.JSX.Element;
|
|
34
43
|
export declare function ProjectSourceReview({ title, description, verification, files, renderBlock, locale }: ProjectSourceReviewProps): React.JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as __toESM, n as init_objectSpread2, r as __commonJSMin, t as _objectSpread2 } from "./objectSpread2-Dkd68nJH.js";
|
|
2
|
-
import {
|
|
2
|
+
import { a as createTwoFilesPatch, i as isAssetName, n as assetsDirectoryParts, r as folderSettingsLimit, t as assetLimit } from "./project-asset-paths-KV715791.js";
|
|
3
3
|
import { a as _OverloadYield, i as _wrapAsyncGenerator, o as _asyncIterator, r as createGitSmartHttp, t as GitSmartHttpError } from "./smart-http-BmHEkE7K.js";
|
|
4
4
|
// node_modules/inherits/inherits_browser.js
|
|
5
5
|
var require_inherits_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -16795,6 +16795,7 @@ async function runRemoteOperation(root, operation, getSession, guard, signal) {
|
|
|
16795
16795
|
}
|
|
16796
16796
|
// src/repository.ts
|
|
16797
16797
|
init_objectSpread2();
|
|
16798
|
+
var projectSourceLimit = 16777216;
|
|
16798
16799
|
var emptyTree = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
|
|
16799
16800
|
var textLimit = 1048576;
|
|
16800
16801
|
var inScope = (path, scope) => !scope || path === scope || path.startsWith(scope + "/");
|
|
@@ -17055,7 +17056,8 @@ async function openRepository(root) {
|
|
|
17055
17056
|
after: (_b$oid = b === null || b === void 0 ? void 0 : b.oid) !== null && _b$oid !== void 0 ? _b$oid : null,
|
|
17056
17057
|
oldMode: (_a$mode = a === null || a === void 0 ? void 0 : a.mode) !== null && _a$mode !== void 0 ? _a$mode : null,
|
|
17057
17058
|
newMode: (_b$mode = b === null || b === void 0 ? void 0 : b.mode) !== null && _b$mode !== void 0 ? _b$mode : null,
|
|
17058
|
-
worktree: false
|
|
17059
|
+
worktree: false,
|
|
17060
|
+
commit: oid
|
|
17059
17061
|
});
|
|
17060
17062
|
}
|
|
17061
17063
|
await assertSnapshot(snapshot);
|
|
@@ -17127,6 +17129,121 @@ async function openRepository(root) {
|
|
|
17127
17129
|
text
|
|
17128
17130
|
});
|
|
17129
17131
|
};
|
|
17132
|
+
const sourceOf = async (snapshot, change, version) => {
|
|
17133
|
+
if (change[version] === null) return null;
|
|
17134
|
+
switch (change.group) {
|
|
17135
|
+
case "staged": return version === "after" ? { kind: "index" } : snapshot.head ? {
|
|
17136
|
+
kind: "tree",
|
|
17137
|
+
ref: snapshot.head
|
|
17138
|
+
} : null;
|
|
17139
|
+
case "unstaged": return version === "after" ? { kind: "worktree" } : { kind: "index" };
|
|
17140
|
+
case "untracked": return version === "after" ? { kind: "worktree" } : null;
|
|
17141
|
+
case "commit": {
|
|
17142
|
+
if (!change.commit) return null;
|
|
17143
|
+
if (version === "after") return {
|
|
17144
|
+
kind: "tree",
|
|
17145
|
+
ref: change.commit
|
|
17146
|
+
};
|
|
17147
|
+
const parent = (await readCommit(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
17148
|
+
cache,
|
|
17149
|
+
oid: change.commit
|
|
17150
|
+
}))).commit.parent[0];
|
|
17151
|
+
return parent ? {
|
|
17152
|
+
kind: "tree",
|
|
17153
|
+
ref: parent
|
|
17154
|
+
} : null;
|
|
17155
|
+
}
|
|
17156
|
+
}
|
|
17157
|
+
};
|
|
17158
|
+
/** Reads one regular file of one version, or `null` when it is missing or larger than the limit. */
|
|
17159
|
+
const readVersion = async (source, path, limit) => {
|
|
17160
|
+
if (source.kind === "worktree") {
|
|
17161
|
+
const stat = await fs.promises.stat("/" + path).catch(() => null);
|
|
17162
|
+
if (!(stat === null || stat === void 0 ? void 0 : stat.isFile()) || stat.size > limit) return null;
|
|
17163
|
+
const bytes = await readOptional(fs, "/" + path);
|
|
17164
|
+
return bytes && bytes.byteLength <= limit ? bytes : null;
|
|
17165
|
+
}
|
|
17166
|
+
const entry = (await entries(source.kind === "tree" ? source.ref : null, path)).get(path);
|
|
17167
|
+
if (!entry || entry.mode !== 33188 && entry.mode !== 33261) return null;
|
|
17168
|
+
const { blob } = await readBlob(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
17169
|
+
cache,
|
|
17170
|
+
oid: entry.oid
|
|
17171
|
+
}));
|
|
17172
|
+
return blob.byteLength <= limit ? blob : null;
|
|
17173
|
+
};
|
|
17174
|
+
const comparisonSource = async (snapshot, comparison, version) => {
|
|
17175
|
+
if (comparison.kind === "worktree") return version === "after" ? { kind: "worktree" } : snapshot.head ? {
|
|
17176
|
+
kind: "tree",
|
|
17177
|
+
ref: snapshot.head
|
|
17178
|
+
} : null;
|
|
17179
|
+
if (version === "after") return {
|
|
17180
|
+
kind: "tree",
|
|
17181
|
+
ref: comparison.commit
|
|
17182
|
+
};
|
|
17183
|
+
const parent = (await readCommit(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
17184
|
+
cache,
|
|
17185
|
+
oid: comparison.commit
|
|
17186
|
+
}))).commit.parent[0];
|
|
17187
|
+
return parent ? {
|
|
17188
|
+
kind: "tree",
|
|
17189
|
+
ref: parent
|
|
17190
|
+
} : null;
|
|
17191
|
+
};
|
|
17192
|
+
const readAsset = (snapshot, change, version, md5ext, signal) => readFolderAsset(snapshot, pathParts(change.path).slice(0, -1), () => sourceOf(snapshot, change, version), md5ext, signal);
|
|
17193
|
+
const readFolderAsset = async (snapshot, folder, resolve, md5ext, signal) => {
|
|
17194
|
+
if (signal.aborted) return null;
|
|
17195
|
+
fs.clearReads();
|
|
17196
|
+
await assertSnapshot(snapshot);
|
|
17197
|
+
const source = await resolve();
|
|
17198
|
+
if (!source) return null;
|
|
17199
|
+
const settings = await readVersion(source, [...folder, "sb3-source.json"].join("/"), folderSettingsLimit);
|
|
17200
|
+
const directory = assetsDirectoryParts(settings && new TextDecoder().decode(settings));
|
|
17201
|
+
if (!directory || signal.aborted) return null;
|
|
17202
|
+
const bytes = await readVersion(source, [
|
|
17203
|
+
...folder,
|
|
17204
|
+
...directory,
|
|
17205
|
+
md5ext
|
|
17206
|
+
].join("/"), assetLimit);
|
|
17207
|
+
await fs.checkReads();
|
|
17208
|
+
return bytes && !signal.aborted ? new Blob([bytes]) : null;
|
|
17209
|
+
};
|
|
17210
|
+
/** Reads the project file and the assets directory of both versions of a project folder. */
|
|
17211
|
+
const readProject = async (snapshot, folder, comparison) => {
|
|
17212
|
+
fs.clearReads();
|
|
17213
|
+
await assertSnapshot(snapshot);
|
|
17214
|
+
const parts = pathParts(folder);
|
|
17215
|
+
const read = async (version) => {
|
|
17216
|
+
const source = await comparisonSource(snapshot, comparison, version);
|
|
17217
|
+
if (!source) return {
|
|
17218
|
+
source: null,
|
|
17219
|
+
assetsDirectory: "assets"
|
|
17220
|
+
};
|
|
17221
|
+
const bytes = await readVersion(source, [...parts, "project.source.json"].join("/"), projectSourceLimit);
|
|
17222
|
+
const settings = await readVersion(source, [...parts, "sb3-source.json"].join("/"), folderSettingsLimit);
|
|
17223
|
+
const directory = assetsDirectoryParts(settings && new TextDecoder().decode(settings));
|
|
17224
|
+
let text = null;
|
|
17225
|
+
if (bytes) try {
|
|
17226
|
+
text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
17227
|
+
} catch (_unused4) {
|
|
17228
|
+
throw new GitPanelError("unsupported");
|
|
17229
|
+
}
|
|
17230
|
+
return {
|
|
17231
|
+
source: text,
|
|
17232
|
+
assetsDirectory: directory ? directory.join("/") : "assets"
|
|
17233
|
+
};
|
|
17234
|
+
};
|
|
17235
|
+
const before = await read("before"), after = await read("after");
|
|
17236
|
+
await assertSnapshot(snapshot);
|
|
17237
|
+
await fs.checkReads();
|
|
17238
|
+
return {
|
|
17239
|
+
before: before.source,
|
|
17240
|
+
after: after.source,
|
|
17241
|
+
assetsDirectory: {
|
|
17242
|
+
before: before.assetsDirectory,
|
|
17243
|
+
after: after.assetsDirectory
|
|
17244
|
+
}
|
|
17245
|
+
};
|
|
17246
|
+
};
|
|
17130
17247
|
const directoryAt = async (path) => {
|
|
17131
17248
|
let directory = root;
|
|
17132
17249
|
for (const part of pathParts(path)) directory = await directory.getDirectoryHandle(part);
|
|
@@ -17206,7 +17323,21 @@ async function openRepository(root) {
|
|
|
17206
17323
|
}),
|
|
17207
17324
|
read: (scope) => serial(() => read(scope)),
|
|
17208
17325
|
readDiff: (snapshot, change) => serial(() => readDiff(snapshot, change)),
|
|
17209
|
-
historyChanges: (snapshot, oid) => serial(() => historyChanges(snapshot, oid))
|
|
17326
|
+
historyChanges: (snapshot, oid) => serial(() => historyChanges(snapshot, oid)),
|
|
17327
|
+
/**
|
|
17328
|
+
* Reads the assets of both versions of a selected project file, for thumbnails. Staged changes compare HEAD with
|
|
17329
|
+
* the index, unstaged ones the index with the working tree, untracked ones nothing with the working tree, and
|
|
17330
|
+
* commit changes the first parent with the commit. Each version's sb3-source.json names its assets directory.
|
|
17331
|
+
* Reads never write, and resolve `null` for anything missing, invalid, larger than 10 MiB or changed since the snapshot.
|
|
17332
|
+
*/
|
|
17333
|
+
assetLoader: (snapshot, change) => ({ version, md5ext, signal }) => !isAssetName(md5ext) || signal.aborted ? Promise.resolve(null) : serial(() => readAsset(snapshot, change, version, md5ext, signal)).catch(() => null),
|
|
17334
|
+
/**
|
|
17335
|
+
* Reads the project file of a folder in both versions of a comparison, with each version's assets directory.
|
|
17336
|
+
* `null` stands for a version without the file. Throws `changed` when the repository changed since the snapshot.
|
|
17337
|
+
*/
|
|
17338
|
+
readProject: (snapshot, folder, comparison) => serial(() => readProject(snapshot, folder, comparison)),
|
|
17339
|
+
/** Reads the assets of a folder in both versions of a comparison, like `assetLoader`. */
|
|
17340
|
+
projectAssetLoader: (snapshot, folder, comparison) => ({ version, md5ext, signal }) => !isAssetName(md5ext) || signal.aborted ? Promise.resolve(null) : serial(() => readFolderAsset(snapshot, pathParts(folder), () => comparisonSource(snapshot, comparison, version), md5ext, signal)).catch(() => null)
|
|
17210
17341
|
};
|
|
17211
17342
|
}
|
|
17212
17343
|
export { GitPanelError as n, createReadOnlyFs as r, openRepository as t };
|
package/dist/repository.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GetRemoteSession, RemoteOperation } from './remote-operations.js';
|
|
2
|
+
import type { ProjectAssetLoader } from './project-assets.js';
|
|
2
3
|
export { createReadOnlyFs, GitPanelError } from './filesystem.js';
|
|
3
4
|
export type ChangeGroup = 'staged' | 'unstaged' | 'untracked' | 'commit';
|
|
4
5
|
export interface FileChange {
|
|
@@ -9,6 +10,8 @@ export interface FileChange {
|
|
|
9
10
|
worktree: boolean;
|
|
10
11
|
oldMode: number | null;
|
|
11
12
|
newMode: number | null;
|
|
13
|
+
/** For `commit` changes, the commit compared with its first parent. */
|
|
14
|
+
commit?: string;
|
|
12
15
|
}
|
|
13
16
|
export interface Commit {
|
|
14
17
|
oid: string;
|
|
@@ -16,6 +19,16 @@ export interface Commit {
|
|
|
16
19
|
author: string;
|
|
17
20
|
timestamp: number;
|
|
18
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Two versions of a project folder as a person sees them: the last commit and the working tree, so changes split
|
|
24
|
+
* across the index and the working tree read as one; or one commit and its first parent.
|
|
25
|
+
*/
|
|
26
|
+
export type ProjectComparison = {
|
|
27
|
+
kind: 'worktree';
|
|
28
|
+
} | {
|
|
29
|
+
kind: 'commit';
|
|
30
|
+
commit: string;
|
|
31
|
+
};
|
|
19
32
|
type Metadata = Map<string, Uint8Array | null>;
|
|
20
33
|
export interface Snapshot {
|
|
21
34
|
branch: string | undefined;
|
|
@@ -57,5 +70,26 @@ export declare function openRepository(root: FileSystemDirectoryHandle): Promise
|
|
|
57
70
|
read: (scope?: string) => Promise<Snapshot>;
|
|
58
71
|
readDiff: (snapshot: Snapshot, change: FileChange) => Promise<FileDiff>;
|
|
59
72
|
historyChanges: (snapshot: Snapshot, oid: string) => Promise<FileChange[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Reads the assets of both versions of a selected project file, for thumbnails. Staged changes compare HEAD with
|
|
75
|
+
* the index, unstaged ones the index with the working tree, untracked ones nothing with the working tree, and
|
|
76
|
+
* commit changes the first parent with the commit. Each version's sb3-source.json names its assets directory.
|
|
77
|
+
* Reads never write, and resolve `null` for anything missing, invalid, larger than 10 MiB or changed since the snapshot.
|
|
78
|
+
*/
|
|
79
|
+
assetLoader: (snapshot: Snapshot, change: FileChange) => ProjectAssetLoader;
|
|
80
|
+
/**
|
|
81
|
+
* Reads the project file of a folder in both versions of a comparison, with each version's assets directory.
|
|
82
|
+
* `null` stands for a version without the file. Throws `changed` when the repository changed since the snapshot.
|
|
83
|
+
*/
|
|
84
|
+
readProject: (snapshot: Snapshot, folder: string, comparison: ProjectComparison) => Promise<{
|
|
85
|
+
before: string | null;
|
|
86
|
+
after: string | null;
|
|
87
|
+
assetsDirectory: {
|
|
88
|
+
before: string;
|
|
89
|
+
after: string;
|
|
90
|
+
};
|
|
91
|
+
}>;
|
|
92
|
+
/** Reads the assets of a folder in both versions of a comparison, like `assetLoader`. */
|
|
93
|
+
projectAssetLoader: (snapshot: Snapshot, folder: string, comparison: ProjectComparison) => ProjectAssetLoader;
|
|
60
94
|
}>;
|
|
61
95
|
export type Repository = Awaited<ReturnType<typeof openRepository>>;
|
package/dist/repository.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as GitPanelError, r as createReadOnlyFs, t as openRepository } from "./repository-
|
|
1
|
+
export { n as GitPanelError, r as createReadOnlyFs, t as openRepository } from "./repository-VBp-UNWc.js";
|