@industry-theme/file-editing-panels 0.3.17 → 0.4.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/dist/{index-BqlTIhAc.js → index-BL8kpLmN.js} +430 -600
- package/dist/index-BL8kpLmN.js.map +1 -0
- package/dist/{index-D28fU6KZ.js → index-BTXt6i9h.js} +2 -2
- package/dist/{index-D28fU6KZ.js.map → index-BTXt6i9h.js.map} +1 -1
- package/dist/{index-CSkeyrcW.js → index-BWJlMHH_.js} +2 -2
- package/dist/{index-CSkeyrcW.js.map → index-BWJlMHH_.js.map} +1 -1
- package/dist/{index-CD19Cn2h.js → index-BXVw4ynU.js} +2 -2
- package/dist/{index-CD19Cn2h.js.map → index-BXVw4ynU.js.map} +1 -1
- package/dist/{index-BCtOA9-r.js → index-C0770yXr.js} +2 -2
- package/dist/{index-BCtOA9-r.js.map → index-C0770yXr.js.map} +1 -1
- package/dist/{index-D5fp2bAg.js → index-CFej-1G2.js} +2 -2
- package/dist/{index-D5fp2bAg.js.map → index-CFej-1G2.js.map} +1 -1
- package/dist/{index-Cf6YiFwd.js → index-CLv3Y9-j.js} +2 -2
- package/dist/{index-Cf6YiFwd.js.map → index-CLv3Y9-j.js.map} +1 -1
- package/dist/{index-CZdMxQb8.js → index-CWjV_DtT.js} +2 -2
- package/dist/{index-CZdMxQb8.js.map → index-CWjV_DtT.js.map} +1 -1
- package/dist/{index-E_IZ21fC.js → index-ChQ_GgQS.js} +2 -2
- package/dist/{index-E_IZ21fC.js.map → index-ChQ_GgQS.js.map} +1 -1
- package/dist/{index-ClYa3JTM.js → index-CyEpFs5g.js} +2 -2
- package/dist/{index-ClYa3JTM.js.map → index-CyEpFs5g.js.map} +1 -1
- package/dist/{index-D16Rwhyr.js → index-D4BXOVXb.js} +2 -2
- package/dist/{index-D16Rwhyr.js.map → index-D4BXOVXb.js.map} +1 -1
- package/dist/{index-Dm7woeyA.js → index-DEwRzW47.js} +2 -2
- package/dist/{index-Dm7woeyA.js.map → index-DEwRzW47.js.map} +1 -1
- package/dist/{index-CxIqSemk.js → index-DOj0XYCl.js} +2 -2
- package/dist/{index-CxIqSemk.js.map → index-DOj0XYCl.js.map} +1 -1
- package/dist/{index-CxTKXcps.js → index-DYwDbpPP.js} +2 -2
- package/dist/{index-CxTKXcps.js.map → index-DYwDbpPP.js.map} +1 -1
- package/dist/{index-eFPe8wLW.js → index-Dh1AHgs3.js} +2 -2
- package/dist/{index-eFPe8wLW.js.map → index-Dh1AHgs3.js.map} +1 -1
- package/dist/{index-BN_ut6cW.js → index-DrfdWFxB.js} +2 -2
- package/dist/{index-BN_ut6cW.js.map → index-DrfdWFxB.js.map} +1 -1
- package/dist/{index-DjnzAbZR.js → index-KC7gIhDr.js} +2 -2
- package/dist/{index-DjnzAbZR.js.map → index-KC7gIhDr.js.map} +1 -1
- package/dist/{index--tqMMVET.js → index-KPVqGXN9.js} +2 -2
- package/dist/{index--tqMMVET.js.map → index-KPVqGXN9.js.map} +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/mocks/panelContext.d.ts +7 -2
- package/dist/mocks/panelContext.d.ts.map +1 -1
- package/dist/panels/FileEditorPanel/FileEditorPanel.d.ts +2 -2
- package/dist/panels/FileEditorPanel/FileEditorPanel.d.ts.map +1 -1
- package/dist/panels/FileEditorPanel/FileEditorPanel.stories.d.ts.map +1 -1
- package/dist/panels/GitDiffPanel/GitDiffPanel.d.ts +2 -2
- package/dist/panels/GitDiffPanel/GitDiffPanel.d.ts.map +1 -1
- package/dist/panels/GitDiffPanel/GitDiffPanel.stories.d.ts.map +1 -1
- package/dist/panels/MDXEditorPanel/MDXEditorPanel.d.ts +2 -2
- package/dist/panels/MDXEditorPanel/MDXEditorPanel.d.ts.map +1 -1
- package/dist/panels/MDXEditorPanel/MDXEditorPanel.stories.d.ts.map +1 -1
- package/dist/panels/MDXEditorPanel/index.d.ts +1 -1
- package/dist/panels/MDXEditorPanel/index.d.ts.map +1 -1
- package/dist/panels.bundle.js +1 -1
- package/dist/types/index.d.ts +56 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +17 -17
- package/dist/index-BqlTIhAc.js.map +0 -1
|
@@ -227,12 +227,12 @@ const getLanguage = (path) => {
|
|
|
227
227
|
};
|
|
228
228
|
const FileEditorPanelContent = ({
|
|
229
229
|
context,
|
|
230
|
-
actions
|
|
230
|
+
actions,
|
|
231
231
|
events,
|
|
232
232
|
filePath: filePathProp,
|
|
233
233
|
showCloseButton = false
|
|
234
234
|
}) => {
|
|
235
|
-
var _a3, _b2
|
|
235
|
+
var _a3, _b2;
|
|
236
236
|
const { theme: theme2 } = useTheme();
|
|
237
237
|
const [filePath, setFilePath] = useState(null);
|
|
238
238
|
const [fileContent, setFileContent] = useState("");
|
|
@@ -245,11 +245,9 @@ const FileEditorPanelContent = ({
|
|
|
245
245
|
const latestFilePathRef = useRef(null);
|
|
246
246
|
const isSavingRef = useRef(false);
|
|
247
247
|
const isDirtyRef = useRef(false);
|
|
248
|
-
const
|
|
249
|
-
const
|
|
250
|
-
const
|
|
251
|
-
const preferencesSlice = context.getSlice("preferences");
|
|
252
|
-
const vimMode = ((_b2 = preferencesSlice == null ? void 0 : preferencesSlice.data) == null ? void 0 : _b2.vimMode) ?? false;
|
|
248
|
+
const isEditable = Boolean(actions.writeFile);
|
|
249
|
+
const { activeFile, preferences } = context;
|
|
250
|
+
const vimMode = ((_a3 = preferences == null ? void 0 : preferences.data) == null ? void 0 : _a3.vimMode) ?? false;
|
|
253
251
|
useEffect(() => {
|
|
254
252
|
isDirtyRef.current = isDirty;
|
|
255
253
|
}, [isDirty]);
|
|
@@ -268,10 +266,10 @@ const FileEditorPanelContent = ({
|
|
|
268
266
|
}, [filePathProp]);
|
|
269
267
|
useEffect(() => {
|
|
270
268
|
var _a4;
|
|
271
|
-
if (!filePathProp && ((_a4 =
|
|
272
|
-
setFilePath(
|
|
269
|
+
if (!filePathProp && ((_a4 = activeFile == null ? void 0 : activeFile.data) == null ? void 0 : _a4.path)) {
|
|
270
|
+
setFilePath(activeFile.data.path);
|
|
273
271
|
}
|
|
274
|
-
}, [filePathProp, (
|
|
272
|
+
}, [filePathProp, (_b2 = activeFile == null ? void 0 : activeFile.data) == null ? void 0 : _b2.path]);
|
|
275
273
|
useEffect(() => {
|
|
276
274
|
if (filePathProp) {
|
|
277
275
|
return void 0;
|
|
@@ -285,7 +283,7 @@ const FileEditorPanelContent = ({
|
|
|
285
283
|
return unsubscribe;
|
|
286
284
|
}, [events, filePathProp]);
|
|
287
285
|
const loadFile = useCallback(async () => {
|
|
288
|
-
if (!filePath
|
|
286
|
+
if (!filePath) {
|
|
289
287
|
latestFilePathRef.current = null;
|
|
290
288
|
setFileContent("");
|
|
291
289
|
setEditorContent("");
|
|
@@ -298,19 +296,15 @@ const FileEditorPanelContent = ({
|
|
|
298
296
|
setIsLoading(true);
|
|
299
297
|
setError(null);
|
|
300
298
|
try {
|
|
301
|
-
const content2 = await
|
|
299
|
+
const content2 = await actions.readFile(filePath);
|
|
302
300
|
if (latestFilePathRef.current !== filePath) {
|
|
303
301
|
return;
|
|
304
302
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
setIsDirty(false);
|
|
311
|
-
}
|
|
312
|
-
} else {
|
|
313
|
-
throw new Error("Failed to read file");
|
|
303
|
+
setFileContent(content2);
|
|
304
|
+
setSaveError(null);
|
|
305
|
+
if (!isDirtyRef.current) {
|
|
306
|
+
setEditorContent(content2);
|
|
307
|
+
setIsDirty(false);
|
|
314
308
|
}
|
|
315
309
|
} catch (err) {
|
|
316
310
|
console.error("Error loading file:", err);
|
|
@@ -323,7 +317,7 @@ const FileEditorPanelContent = ({
|
|
|
323
317
|
setIsLoading(false);
|
|
324
318
|
}
|
|
325
319
|
}
|
|
326
|
-
}, [filePath,
|
|
320
|
+
}, [filePath, actions]);
|
|
327
321
|
useEffect(() => {
|
|
328
322
|
loadFile();
|
|
329
323
|
}, [loadFile]);
|
|
@@ -340,7 +334,7 @@ const FileEditorPanelContent = ({
|
|
|
340
334
|
);
|
|
341
335
|
const handleEditorSave = useCallback(
|
|
342
336
|
async (value2) => {
|
|
343
|
-
if (!filePath || !
|
|
337
|
+
if (!filePath || !actions.writeFile) {
|
|
344
338
|
return;
|
|
345
339
|
}
|
|
346
340
|
const contentToSave = value2 ?? editorContent;
|
|
@@ -351,7 +345,7 @@ const FileEditorPanelContent = ({
|
|
|
351
345
|
setIsSaving(true);
|
|
352
346
|
setSaveError(null);
|
|
353
347
|
try {
|
|
354
|
-
await
|
|
348
|
+
await actions.writeFile(filePath, contentToSave);
|
|
355
349
|
if (latestFilePathRef.current === filePath) {
|
|
356
350
|
setFileContent(contentToSave);
|
|
357
351
|
setEditorContent(contentToSave);
|
|
@@ -376,7 +370,7 @@ const FileEditorPanelContent = ({
|
|
|
376
370
|
isSavingRef.current = false;
|
|
377
371
|
}
|
|
378
372
|
},
|
|
379
|
-
[editorContent, fileContent, filePath, isDirty,
|
|
373
|
+
[editorContent, fileContent, filePath, isDirty, actions, events]
|
|
380
374
|
);
|
|
381
375
|
const handleClose2 = useCallback(() => {
|
|
382
376
|
events.emit({
|
|
@@ -14444,7 +14438,7 @@ class LineDiff extends Diff$1 {
|
|
|
14444
14438
|
}
|
|
14445
14439
|
}
|
|
14446
14440
|
const lineDiff$1 = new LineDiff();
|
|
14447
|
-
function diffLines
|
|
14441
|
+
function diffLines(oldStr, newStr, options) {
|
|
14448
14442
|
return lineDiff$1.diff(oldStr, newStr, options);
|
|
14449
14443
|
}
|
|
14450
14444
|
function tokenize$1(value2, options) {
|
|
@@ -14470,7 +14464,7 @@ const INCLUDE_HEADERS = {
|
|
|
14470
14464
|
includeUnderline: true,
|
|
14471
14465
|
includeFileHeaders: true
|
|
14472
14466
|
};
|
|
14473
|
-
function structuredPatch
|
|
14467
|
+
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
14474
14468
|
let optionsObj;
|
|
14475
14469
|
{
|
|
14476
14470
|
optionsObj = {};
|
|
@@ -14483,10 +14477,10 @@ function structuredPatch$1(oldFileName, newFileName, oldStr, newStr, oldHeader,
|
|
|
14483
14477
|
throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
|
|
14484
14478
|
}
|
|
14485
14479
|
if (!optionsObj.callback) {
|
|
14486
|
-
return diffLinesResultToPatch(diffLines
|
|
14480
|
+
return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
|
|
14487
14481
|
} else {
|
|
14488
14482
|
const { callback } = optionsObj;
|
|
14489
|
-
diffLines
|
|
14483
|
+
diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff3) => {
|
|
14490
14484
|
const patch = diffLinesResultToPatch(diff3);
|
|
14491
14485
|
callback(patch);
|
|
14492
14486
|
} }));
|
|
@@ -14572,7 +14566,7 @@ function structuredPatch$1(oldFileName, newFileName, oldStr, newStr, oldHeader,
|
|
|
14572
14566
|
};
|
|
14573
14567
|
}
|
|
14574
14568
|
}
|
|
14575
|
-
function formatPatch
|
|
14569
|
+
function formatPatch(patch, headerOptions) {
|
|
14576
14570
|
if (!headerOptions) {
|
|
14577
14571
|
headerOptions = INCLUDE_HEADERS;
|
|
14578
14572
|
}
|
|
@@ -14580,7 +14574,7 @@ function formatPatch$1(patch, headerOptions) {
|
|
|
14580
14574
|
if (patch.length > 1 && !headerOptions.includeFileHeaders) {
|
|
14581
14575
|
throw new Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");
|
|
14582
14576
|
}
|
|
14583
|
-
return patch.map((p2) => formatPatch
|
|
14577
|
+
return patch.map((p2) => formatPatch(p2, headerOptions)).join("\n");
|
|
14584
14578
|
}
|
|
14585
14579
|
const ret = [];
|
|
14586
14580
|
if (headerOptions.includeIndex && patch.oldFileName == patch.newFileName) {
|
|
@@ -14608,15 +14602,18 @@ function formatPatch$1(patch, headerOptions) {
|
|
|
14608
14602
|
}
|
|
14609
14603
|
return ret.join("\n") + "\n";
|
|
14610
14604
|
}
|
|
14611
|
-
function createTwoFilesPatch
|
|
14605
|
+
function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
14612
14606
|
{
|
|
14613
|
-
const patchObj = structuredPatch
|
|
14607
|
+
const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader);
|
|
14614
14608
|
if (!patchObj) {
|
|
14615
14609
|
return;
|
|
14616
14610
|
}
|
|
14617
|
-
return formatPatch
|
|
14611
|
+
return formatPatch(patchObj, void 0);
|
|
14618
14612
|
}
|
|
14619
14613
|
}
|
|
14614
|
+
function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
14615
|
+
return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader);
|
|
14616
|
+
}
|
|
14620
14617
|
function splitLines(text2) {
|
|
14621
14618
|
const hasTrailingNl = text2.endsWith("\n");
|
|
14622
14619
|
const result = text2.split("\n").map((line) => line + "\n");
|
|
@@ -16958,7 +16955,7 @@ function createContentGroup(type2) {
|
|
|
16958
16955
|
}
|
|
16959
16956
|
function parseDiffFromFile(oldFile, newFile, options) {
|
|
16960
16957
|
var _a3;
|
|
16961
|
-
const fileData = (_a3 = parsePatchFiles(createTwoFilesPatch
|
|
16958
|
+
const fileData = (_a3 = parsePatchFiles(createTwoFilesPatch(oldFile.name, newFile.name, oldFile.contents, newFile.contents, oldFile.header, newFile.header))[0]) == null ? void 0 : _a3.files[0];
|
|
16962
16959
|
if (fileData == null) throw new Error("parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?");
|
|
16963
16960
|
fileData.oldLines = oldFile.contents.split(SPLIT_WITH_NEWLINES);
|
|
16964
16961
|
fileData.newLines = newFile.contents.split(SPLIT_WITH_NEWLINES);
|
|
@@ -17412,505 +17409,6 @@ function FileDiff({ fileDiff, options, lineAnnotations, selectedLines: selectedL
|
|
|
17412
17409
|
}), prerenderedHTML)
|
|
17413
17410
|
});
|
|
17414
17411
|
}
|
|
17415
|
-
function Diff2() {
|
|
17416
|
-
}
|
|
17417
|
-
Diff2.prototype = {
|
|
17418
|
-
diff: function diff(oldString, newString) {
|
|
17419
|
-
var _options$timeout;
|
|
17420
|
-
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
17421
|
-
var callback = options.callback;
|
|
17422
|
-
if (typeof options === "function") {
|
|
17423
|
-
callback = options;
|
|
17424
|
-
options = {};
|
|
17425
|
-
}
|
|
17426
|
-
this.options = options;
|
|
17427
|
-
var self2 = this;
|
|
17428
|
-
function done(value2) {
|
|
17429
|
-
if (callback) {
|
|
17430
|
-
setTimeout(function() {
|
|
17431
|
-
callback(void 0, value2);
|
|
17432
|
-
}, 0);
|
|
17433
|
-
return true;
|
|
17434
|
-
} else {
|
|
17435
|
-
return value2;
|
|
17436
|
-
}
|
|
17437
|
-
}
|
|
17438
|
-
oldString = this.castInput(oldString);
|
|
17439
|
-
newString = this.castInput(newString);
|
|
17440
|
-
oldString = this.removeEmpty(this.tokenize(oldString));
|
|
17441
|
-
newString = this.removeEmpty(this.tokenize(newString));
|
|
17442
|
-
var newLen = newString.length, oldLen = oldString.length;
|
|
17443
|
-
var editLength = 1;
|
|
17444
|
-
var maxEditLength = newLen + oldLen;
|
|
17445
|
-
if (options.maxEditLength) {
|
|
17446
|
-
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
17447
|
-
}
|
|
17448
|
-
var maxExecutionTime = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : Infinity;
|
|
17449
|
-
var abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
17450
|
-
var bestPath = [{
|
|
17451
|
-
oldPos: -1,
|
|
17452
|
-
lastComponent: void 0
|
|
17453
|
-
}];
|
|
17454
|
-
var newPos = this.extractCommon(bestPath[0], newString, oldString, 0);
|
|
17455
|
-
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
17456
|
-
return done([{
|
|
17457
|
-
value: this.join(newString),
|
|
17458
|
-
count: newString.length
|
|
17459
|
-
}]);
|
|
17460
|
-
}
|
|
17461
|
-
var minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
17462
|
-
function execEditLength() {
|
|
17463
|
-
for (var diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
17464
|
-
var basePath = void 0;
|
|
17465
|
-
var removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
17466
|
-
if (removePath) {
|
|
17467
|
-
bestPath[diagonalPath - 1] = void 0;
|
|
17468
|
-
}
|
|
17469
|
-
var canAdd = false;
|
|
17470
|
-
if (addPath) {
|
|
17471
|
-
var addPathNewPos = addPath.oldPos - diagonalPath;
|
|
17472
|
-
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
17473
|
-
}
|
|
17474
|
-
var canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
17475
|
-
if (!canAdd && !canRemove) {
|
|
17476
|
-
bestPath[diagonalPath] = void 0;
|
|
17477
|
-
continue;
|
|
17478
|
-
}
|
|
17479
|
-
if (!canRemove || canAdd && removePath.oldPos + 1 < addPath.oldPos) {
|
|
17480
|
-
basePath = self2.addToPath(addPath, true, void 0, 0);
|
|
17481
|
-
} else {
|
|
17482
|
-
basePath = self2.addToPath(removePath, void 0, true, 1);
|
|
17483
|
-
}
|
|
17484
|
-
newPos = self2.extractCommon(basePath, newString, oldString, diagonalPath);
|
|
17485
|
-
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
17486
|
-
return done(buildValues(self2, basePath.lastComponent, newString, oldString, self2.useLongestToken));
|
|
17487
|
-
} else {
|
|
17488
|
-
bestPath[diagonalPath] = basePath;
|
|
17489
|
-
if (basePath.oldPos + 1 >= oldLen) {
|
|
17490
|
-
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
17491
|
-
}
|
|
17492
|
-
if (newPos + 1 >= newLen) {
|
|
17493
|
-
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
17494
|
-
}
|
|
17495
|
-
}
|
|
17496
|
-
}
|
|
17497
|
-
editLength++;
|
|
17498
|
-
}
|
|
17499
|
-
if (callback) {
|
|
17500
|
-
(function exec() {
|
|
17501
|
-
setTimeout(function() {
|
|
17502
|
-
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
17503
|
-
return callback();
|
|
17504
|
-
}
|
|
17505
|
-
if (!execEditLength()) {
|
|
17506
|
-
exec();
|
|
17507
|
-
}
|
|
17508
|
-
}, 0);
|
|
17509
|
-
})();
|
|
17510
|
-
} else {
|
|
17511
|
-
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
17512
|
-
var ret = execEditLength();
|
|
17513
|
-
if (ret) {
|
|
17514
|
-
return ret;
|
|
17515
|
-
}
|
|
17516
|
-
}
|
|
17517
|
-
}
|
|
17518
|
-
},
|
|
17519
|
-
addToPath: function addToPath(path, added, removed, oldPosInc) {
|
|
17520
|
-
var last = path.lastComponent;
|
|
17521
|
-
if (last && last.added === added && last.removed === removed) {
|
|
17522
|
-
return {
|
|
17523
|
-
oldPos: path.oldPos + oldPosInc,
|
|
17524
|
-
lastComponent: {
|
|
17525
|
-
count: last.count + 1,
|
|
17526
|
-
added,
|
|
17527
|
-
removed,
|
|
17528
|
-
previousComponent: last.previousComponent
|
|
17529
|
-
}
|
|
17530
|
-
};
|
|
17531
|
-
} else {
|
|
17532
|
-
return {
|
|
17533
|
-
oldPos: path.oldPos + oldPosInc,
|
|
17534
|
-
lastComponent: {
|
|
17535
|
-
count: 1,
|
|
17536
|
-
added,
|
|
17537
|
-
removed,
|
|
17538
|
-
previousComponent: last
|
|
17539
|
-
}
|
|
17540
|
-
};
|
|
17541
|
-
}
|
|
17542
|
-
},
|
|
17543
|
-
extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
|
|
17544
|
-
var newLen = newString.length, oldLen = oldString.length, oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
17545
|
-
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
|
|
17546
|
-
newPos++;
|
|
17547
|
-
oldPos++;
|
|
17548
|
-
commonCount++;
|
|
17549
|
-
}
|
|
17550
|
-
if (commonCount) {
|
|
17551
|
-
basePath.lastComponent = {
|
|
17552
|
-
count: commonCount,
|
|
17553
|
-
previousComponent: basePath.lastComponent
|
|
17554
|
-
};
|
|
17555
|
-
}
|
|
17556
|
-
basePath.oldPos = oldPos;
|
|
17557
|
-
return newPos;
|
|
17558
|
-
},
|
|
17559
|
-
equals: function equals(left, right) {
|
|
17560
|
-
if (this.options.comparator) {
|
|
17561
|
-
return this.options.comparator(left, right);
|
|
17562
|
-
} else {
|
|
17563
|
-
return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
17564
|
-
}
|
|
17565
|
-
},
|
|
17566
|
-
removeEmpty: function removeEmpty(array) {
|
|
17567
|
-
var ret = [];
|
|
17568
|
-
for (var i2 = 0; i2 < array.length; i2++) {
|
|
17569
|
-
if (array[i2]) {
|
|
17570
|
-
ret.push(array[i2]);
|
|
17571
|
-
}
|
|
17572
|
-
}
|
|
17573
|
-
return ret;
|
|
17574
|
-
},
|
|
17575
|
-
castInput: function castInput(value2) {
|
|
17576
|
-
return value2;
|
|
17577
|
-
},
|
|
17578
|
-
tokenize: function tokenize(value2) {
|
|
17579
|
-
return value2.split("");
|
|
17580
|
-
},
|
|
17581
|
-
join: function join(chars) {
|
|
17582
|
-
return chars.join("");
|
|
17583
|
-
}
|
|
17584
|
-
};
|
|
17585
|
-
function buildValues(diff3, lastComponent, newString, oldString, useLongestToken) {
|
|
17586
|
-
var components = [];
|
|
17587
|
-
var nextComponent;
|
|
17588
|
-
while (lastComponent) {
|
|
17589
|
-
components.push(lastComponent);
|
|
17590
|
-
nextComponent = lastComponent.previousComponent;
|
|
17591
|
-
delete lastComponent.previousComponent;
|
|
17592
|
-
lastComponent = nextComponent;
|
|
17593
|
-
}
|
|
17594
|
-
components.reverse();
|
|
17595
|
-
var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0;
|
|
17596
|
-
for (; componentPos < componentLen; componentPos++) {
|
|
17597
|
-
var component = components[componentPos];
|
|
17598
|
-
if (!component.removed) {
|
|
17599
|
-
if (!component.added && useLongestToken) {
|
|
17600
|
-
var value2 = newString.slice(newPos, newPos + component.count);
|
|
17601
|
-
value2 = value2.map(function(value3, i2) {
|
|
17602
|
-
var oldValue = oldString[oldPos + i2];
|
|
17603
|
-
return oldValue.length > value3.length ? oldValue : value3;
|
|
17604
|
-
});
|
|
17605
|
-
component.value = diff3.join(value2);
|
|
17606
|
-
} else {
|
|
17607
|
-
component.value = diff3.join(newString.slice(newPos, newPos + component.count));
|
|
17608
|
-
}
|
|
17609
|
-
newPos += component.count;
|
|
17610
|
-
if (!component.added) {
|
|
17611
|
-
oldPos += component.count;
|
|
17612
|
-
}
|
|
17613
|
-
} else {
|
|
17614
|
-
component.value = diff3.join(oldString.slice(oldPos, oldPos + component.count));
|
|
17615
|
-
oldPos += component.count;
|
|
17616
|
-
if (componentPos && components[componentPos - 1].added) {
|
|
17617
|
-
var tmp = components[componentPos - 1];
|
|
17618
|
-
components[componentPos - 1] = components[componentPos];
|
|
17619
|
-
components[componentPos] = tmp;
|
|
17620
|
-
}
|
|
17621
|
-
}
|
|
17622
|
-
}
|
|
17623
|
-
var finalComponent = components[componentLen - 1];
|
|
17624
|
-
if (componentLen > 1 && typeof finalComponent.value === "string" && (finalComponent.added || finalComponent.removed) && diff3.equals("", finalComponent.value)) {
|
|
17625
|
-
components[componentLen - 2].value += finalComponent.value;
|
|
17626
|
-
components.pop();
|
|
17627
|
-
}
|
|
17628
|
-
return components;
|
|
17629
|
-
}
|
|
17630
|
-
var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
|
|
17631
|
-
var reWhitespace = /\S/;
|
|
17632
|
-
var wordDiff = new Diff2();
|
|
17633
|
-
wordDiff.equals = function(left, right) {
|
|
17634
|
-
if (this.options.ignoreCase) {
|
|
17635
|
-
left = left.toLowerCase();
|
|
17636
|
-
right = right.toLowerCase();
|
|
17637
|
-
}
|
|
17638
|
-
return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
|
|
17639
|
-
};
|
|
17640
|
-
wordDiff.tokenize = function(value2) {
|
|
17641
|
-
var tokens = value2.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/);
|
|
17642
|
-
for (var i2 = 0; i2 < tokens.length - 1; i2++) {
|
|
17643
|
-
if (!tokens[i2 + 1] && tokens[i2 + 2] && extendedWordChars.test(tokens[i2]) && extendedWordChars.test(tokens[i2 + 2])) {
|
|
17644
|
-
tokens[i2] += tokens[i2 + 2];
|
|
17645
|
-
tokens.splice(i2 + 1, 2);
|
|
17646
|
-
i2--;
|
|
17647
|
-
}
|
|
17648
|
-
}
|
|
17649
|
-
return tokens;
|
|
17650
|
-
};
|
|
17651
|
-
var lineDiff = new Diff2();
|
|
17652
|
-
lineDiff.tokenize = function(value2) {
|
|
17653
|
-
if (this.options.stripTrailingCr) {
|
|
17654
|
-
value2 = value2.replace(/\r\n/g, "\n");
|
|
17655
|
-
}
|
|
17656
|
-
var retLines = [], linesAndNewlines = value2.split(/(\n|\r\n)/);
|
|
17657
|
-
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
17658
|
-
linesAndNewlines.pop();
|
|
17659
|
-
}
|
|
17660
|
-
for (var i2 = 0; i2 < linesAndNewlines.length; i2++) {
|
|
17661
|
-
var line = linesAndNewlines[i2];
|
|
17662
|
-
if (i2 % 2 && !this.options.newlineIsToken) {
|
|
17663
|
-
retLines[retLines.length - 1] += line;
|
|
17664
|
-
} else {
|
|
17665
|
-
if (this.options.ignoreWhitespace) {
|
|
17666
|
-
line = line.trim();
|
|
17667
|
-
}
|
|
17668
|
-
retLines.push(line);
|
|
17669
|
-
}
|
|
17670
|
-
}
|
|
17671
|
-
return retLines;
|
|
17672
|
-
};
|
|
17673
|
-
function diffLines(oldStr, newStr, callback) {
|
|
17674
|
-
return lineDiff.diff(oldStr, newStr, callback);
|
|
17675
|
-
}
|
|
17676
|
-
var sentenceDiff = new Diff2();
|
|
17677
|
-
sentenceDiff.tokenize = function(value2) {
|
|
17678
|
-
return value2.split(/(\S.+?[.!?])(?=\s+|$)/);
|
|
17679
|
-
};
|
|
17680
|
-
var cssDiff = new Diff2();
|
|
17681
|
-
cssDiff.tokenize = function(value2) {
|
|
17682
|
-
return value2.split(/([{}:;,]|\s+)/);
|
|
17683
|
-
};
|
|
17684
|
-
function _typeof(obj) {
|
|
17685
|
-
"@babel/helpers - typeof";
|
|
17686
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
17687
|
-
_typeof = function(obj2) {
|
|
17688
|
-
return typeof obj2;
|
|
17689
|
-
};
|
|
17690
|
-
} else {
|
|
17691
|
-
_typeof = function(obj2) {
|
|
17692
|
-
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
17693
|
-
};
|
|
17694
|
-
}
|
|
17695
|
-
return _typeof(obj);
|
|
17696
|
-
}
|
|
17697
|
-
function _toConsumableArray(arr) {
|
|
17698
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
17699
|
-
}
|
|
17700
|
-
function _arrayWithoutHoles(arr) {
|
|
17701
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
17702
|
-
}
|
|
17703
|
-
function _iterableToArray(iter) {
|
|
17704
|
-
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
|
17705
|
-
}
|
|
17706
|
-
function _unsupportedIterableToArray(o2, minLen) {
|
|
17707
|
-
if (!o2) return;
|
|
17708
|
-
if (typeof o2 === "string") return _arrayLikeToArray(o2, minLen);
|
|
17709
|
-
var n2 = Object.prototype.toString.call(o2).slice(8, -1);
|
|
17710
|
-
if (n2 === "Object" && o2.constructor) n2 = o2.constructor.name;
|
|
17711
|
-
if (n2 === "Map" || n2 === "Set") return Array.from(o2);
|
|
17712
|
-
if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray(o2, minLen);
|
|
17713
|
-
}
|
|
17714
|
-
function _arrayLikeToArray(arr, len) {
|
|
17715
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
17716
|
-
for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++) arr2[i2] = arr[i2];
|
|
17717
|
-
return arr2;
|
|
17718
|
-
}
|
|
17719
|
-
function _nonIterableSpread() {
|
|
17720
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
17721
|
-
}
|
|
17722
|
-
var objectPrototypeToString = Object.prototype.toString;
|
|
17723
|
-
var jsonDiff = new Diff2();
|
|
17724
|
-
jsonDiff.useLongestToken = true;
|
|
17725
|
-
jsonDiff.tokenize = lineDiff.tokenize;
|
|
17726
|
-
jsonDiff.castInput = function(value2) {
|
|
17727
|
-
var _this$options = this.options, undefinedReplacement = _this$options.undefinedReplacement, _this$options$stringi = _this$options.stringifyReplacer, stringifyReplacer = _this$options$stringi === void 0 ? function(k3, v2) {
|
|
17728
|
-
return typeof v2 === "undefined" ? undefinedReplacement : v2;
|
|
17729
|
-
} : _this$options$stringi;
|
|
17730
|
-
return typeof value2 === "string" ? value2 : JSON.stringify(canonicalize(value2, null, null, stringifyReplacer), stringifyReplacer, " ");
|
|
17731
|
-
};
|
|
17732
|
-
jsonDiff.equals = function(left, right) {
|
|
17733
|
-
return Diff2.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"));
|
|
17734
|
-
};
|
|
17735
|
-
function canonicalize(obj, stack, replacementStack, replacer, key2) {
|
|
17736
|
-
stack = stack || [];
|
|
17737
|
-
replacementStack = replacementStack || [];
|
|
17738
|
-
if (replacer) {
|
|
17739
|
-
obj = replacer(key2, obj);
|
|
17740
|
-
}
|
|
17741
|
-
var i2;
|
|
17742
|
-
for (i2 = 0; i2 < stack.length; i2 += 1) {
|
|
17743
|
-
if (stack[i2] === obj) {
|
|
17744
|
-
return replacementStack[i2];
|
|
17745
|
-
}
|
|
17746
|
-
}
|
|
17747
|
-
var canonicalizedObj;
|
|
17748
|
-
if ("[object Array]" === objectPrototypeToString.call(obj)) {
|
|
17749
|
-
stack.push(obj);
|
|
17750
|
-
canonicalizedObj = new Array(obj.length);
|
|
17751
|
-
replacementStack.push(canonicalizedObj);
|
|
17752
|
-
for (i2 = 0; i2 < obj.length; i2 += 1) {
|
|
17753
|
-
canonicalizedObj[i2] = canonicalize(obj[i2], stack, replacementStack, replacer, key2);
|
|
17754
|
-
}
|
|
17755
|
-
stack.pop();
|
|
17756
|
-
replacementStack.pop();
|
|
17757
|
-
return canonicalizedObj;
|
|
17758
|
-
}
|
|
17759
|
-
if (obj && obj.toJSON) {
|
|
17760
|
-
obj = obj.toJSON();
|
|
17761
|
-
}
|
|
17762
|
-
if (_typeof(obj) === "object" && obj !== null) {
|
|
17763
|
-
stack.push(obj);
|
|
17764
|
-
canonicalizedObj = {};
|
|
17765
|
-
replacementStack.push(canonicalizedObj);
|
|
17766
|
-
var sortedKeys = [], _key;
|
|
17767
|
-
for (_key in obj) {
|
|
17768
|
-
if (obj.hasOwnProperty(_key)) {
|
|
17769
|
-
sortedKeys.push(_key);
|
|
17770
|
-
}
|
|
17771
|
-
}
|
|
17772
|
-
sortedKeys.sort();
|
|
17773
|
-
for (i2 = 0; i2 < sortedKeys.length; i2 += 1) {
|
|
17774
|
-
_key = sortedKeys[i2];
|
|
17775
|
-
canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
|
|
17776
|
-
}
|
|
17777
|
-
stack.pop();
|
|
17778
|
-
replacementStack.pop();
|
|
17779
|
-
} else {
|
|
17780
|
-
canonicalizedObj = obj;
|
|
17781
|
-
}
|
|
17782
|
-
return canonicalizedObj;
|
|
17783
|
-
}
|
|
17784
|
-
var arrayDiff = new Diff2();
|
|
17785
|
-
arrayDiff.tokenize = function(value2) {
|
|
17786
|
-
return value2.slice();
|
|
17787
|
-
};
|
|
17788
|
-
arrayDiff.join = arrayDiff.removeEmpty = function(value2) {
|
|
17789
|
-
return value2;
|
|
17790
|
-
};
|
|
17791
|
-
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
17792
|
-
if (!options) {
|
|
17793
|
-
options = {};
|
|
17794
|
-
}
|
|
17795
|
-
if (typeof options.context === "undefined") {
|
|
17796
|
-
options.context = 4;
|
|
17797
|
-
}
|
|
17798
|
-
var diff3 = diffLines(oldStr, newStr, options);
|
|
17799
|
-
if (!diff3) {
|
|
17800
|
-
return;
|
|
17801
|
-
}
|
|
17802
|
-
diff3.push({
|
|
17803
|
-
value: "",
|
|
17804
|
-
lines: []
|
|
17805
|
-
});
|
|
17806
|
-
function contextLines(lines) {
|
|
17807
|
-
return lines.map(function(entry) {
|
|
17808
|
-
return " " + entry;
|
|
17809
|
-
});
|
|
17810
|
-
}
|
|
17811
|
-
var hunks = [];
|
|
17812
|
-
var oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
|
|
17813
|
-
var _loop = function _loop2(i3) {
|
|
17814
|
-
var current = diff3[i3], lines = current.lines || current.value.replace(/\n$/, "").split("\n");
|
|
17815
|
-
current.lines = lines;
|
|
17816
|
-
if (current.added || current.removed) {
|
|
17817
|
-
var _curRange;
|
|
17818
|
-
if (!oldRangeStart) {
|
|
17819
|
-
var prev = diff3[i3 - 1];
|
|
17820
|
-
oldRangeStart = oldLine;
|
|
17821
|
-
newRangeStart = newLine;
|
|
17822
|
-
if (prev) {
|
|
17823
|
-
curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
|
|
17824
|
-
oldRangeStart -= curRange.length;
|
|
17825
|
-
newRangeStart -= curRange.length;
|
|
17826
|
-
}
|
|
17827
|
-
}
|
|
17828
|
-
(_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function(entry) {
|
|
17829
|
-
return (current.added ? "+" : "-") + entry;
|
|
17830
|
-
})));
|
|
17831
|
-
if (current.added) {
|
|
17832
|
-
newLine += lines.length;
|
|
17833
|
-
} else {
|
|
17834
|
-
oldLine += lines.length;
|
|
17835
|
-
}
|
|
17836
|
-
} else {
|
|
17837
|
-
if (oldRangeStart) {
|
|
17838
|
-
if (lines.length <= options.context * 2 && i3 < diff3.length - 2) {
|
|
17839
|
-
var _curRange2;
|
|
17840
|
-
(_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines)));
|
|
17841
|
-
} else {
|
|
17842
|
-
var _curRange3;
|
|
17843
|
-
var contextSize = Math.min(lines.length, options.context);
|
|
17844
|
-
(_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize))));
|
|
17845
|
-
var hunk = {
|
|
17846
|
-
oldStart: oldRangeStart,
|
|
17847
|
-
oldLines: oldLine - oldRangeStart + contextSize,
|
|
17848
|
-
newStart: newRangeStart,
|
|
17849
|
-
newLines: newLine - newRangeStart + contextSize,
|
|
17850
|
-
lines: curRange
|
|
17851
|
-
};
|
|
17852
|
-
if (i3 >= diff3.length - 2 && lines.length <= options.context) {
|
|
17853
|
-
var oldEOFNewline = /\n$/.test(oldStr);
|
|
17854
|
-
var newEOFNewline = /\n$/.test(newStr);
|
|
17855
|
-
var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
|
|
17856
|
-
if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) {
|
|
17857
|
-
curRange.splice(hunk.oldLines, 0, "\");
|
|
17858
|
-
}
|
|
17859
|
-
if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
|
|
17860
|
-
curRange.push("\");
|
|
17861
|
-
}
|
|
17862
|
-
}
|
|
17863
|
-
hunks.push(hunk);
|
|
17864
|
-
oldRangeStart = 0;
|
|
17865
|
-
newRangeStart = 0;
|
|
17866
|
-
curRange = [];
|
|
17867
|
-
}
|
|
17868
|
-
}
|
|
17869
|
-
oldLine += lines.length;
|
|
17870
|
-
newLine += lines.length;
|
|
17871
|
-
}
|
|
17872
|
-
};
|
|
17873
|
-
for (var i2 = 0; i2 < diff3.length; i2++) {
|
|
17874
|
-
_loop(i2);
|
|
17875
|
-
}
|
|
17876
|
-
return {
|
|
17877
|
-
oldFileName,
|
|
17878
|
-
newFileName,
|
|
17879
|
-
oldHeader,
|
|
17880
|
-
newHeader,
|
|
17881
|
-
hunks
|
|
17882
|
-
};
|
|
17883
|
-
}
|
|
17884
|
-
function formatPatch(diff3) {
|
|
17885
|
-
if (Array.isArray(diff3)) {
|
|
17886
|
-
return diff3.map(formatPatch).join("\n");
|
|
17887
|
-
}
|
|
17888
|
-
var ret = [];
|
|
17889
|
-
if (diff3.oldFileName == diff3.newFileName) {
|
|
17890
|
-
ret.push("Index: " + diff3.oldFileName);
|
|
17891
|
-
}
|
|
17892
|
-
ret.push("===================================================================");
|
|
17893
|
-
ret.push("--- " + diff3.oldFileName + (typeof diff3.oldHeader === "undefined" ? "" : " " + diff3.oldHeader));
|
|
17894
|
-
ret.push("+++ " + diff3.newFileName + (typeof diff3.newHeader === "undefined" ? "" : " " + diff3.newHeader));
|
|
17895
|
-
for (var i2 = 0; i2 < diff3.hunks.length; i2++) {
|
|
17896
|
-
var hunk = diff3.hunks[i2];
|
|
17897
|
-
if (hunk.oldLines === 0) {
|
|
17898
|
-
hunk.oldStart -= 1;
|
|
17899
|
-
}
|
|
17900
|
-
if (hunk.newLines === 0) {
|
|
17901
|
-
hunk.newStart -= 1;
|
|
17902
|
-
}
|
|
17903
|
-
ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
|
|
17904
|
-
ret.push.apply(ret, hunk.lines);
|
|
17905
|
-
}
|
|
17906
|
-
return ret.join("\n") + "\n";
|
|
17907
|
-
}
|
|
17908
|
-
function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
17909
|
-
return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options));
|
|
17910
|
-
}
|
|
17911
|
-
function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
17912
|
-
return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
|
|
17913
|
-
}
|
|
17914
17412
|
const statusMeta = {
|
|
17915
17413
|
staged: {
|
|
17916
17414
|
label: "Staged change",
|
|
@@ -18009,14 +17507,13 @@ function createFileDiffMetadata(filePath, originalContent, modifiedContent, stat
|
|
|
18009
17507
|
return parsed[0].files[0];
|
|
18010
17508
|
}
|
|
18011
17509
|
const GitDiffPanelContent = ({
|
|
18012
|
-
context,
|
|
18013
|
-
actions
|
|
17510
|
+
context: _context,
|
|
17511
|
+
actions,
|
|
18014
17512
|
events,
|
|
18015
17513
|
filePath: filePathProp,
|
|
18016
17514
|
gitStatus: gitStatusProp,
|
|
18017
17515
|
showCloseButton = false
|
|
18018
17516
|
}) => {
|
|
18019
|
-
var _a3;
|
|
18020
17517
|
const { theme: theme2 } = useTheme();
|
|
18021
17518
|
const [filePath, setFilePath] = useState(null);
|
|
18022
17519
|
const [status, setStatus2] = useState("unstaged");
|
|
@@ -18027,7 +17524,6 @@ const GitDiffPanelContent = ({
|
|
|
18027
17524
|
const [diffStyle, setDiffStyle] = useState("unified");
|
|
18028
17525
|
const [contentProvidedExternally, setContentProvidedExternally] = useState(false);
|
|
18029
17526
|
useMemo(() => languageFromPath(filePath), [filePath]);
|
|
18030
|
-
const fileSystem = (_a3 = context.adapters) == null ? void 0 : _a3.fileSystem;
|
|
18031
17527
|
useEffect(() => {
|
|
18032
17528
|
if (filePathProp) {
|
|
18033
17529
|
console.log("[GitDiffPanel] Using prop-controlled file path:", filePathProp);
|
|
@@ -18070,30 +17566,21 @@ const GitDiffPanelContent = ({
|
|
|
18070
17566
|
if (contentProvidedExternally) {
|
|
18071
17567
|
return;
|
|
18072
17568
|
}
|
|
18073
|
-
if (!(fileSystem == null ? void 0 : fileSystem.readFile)) {
|
|
18074
|
-
return;
|
|
18075
|
-
}
|
|
18076
17569
|
setIsLoading(true);
|
|
18077
17570
|
setError(null);
|
|
18078
17571
|
try {
|
|
18079
|
-
const modified = await
|
|
17572
|
+
const modified = await actions.readFile(filePath);
|
|
18080
17573
|
if (!isActive) return;
|
|
18081
|
-
setModifiedContent(modified
|
|
17574
|
+
setModifiedContent(modified);
|
|
18082
17575
|
if (status === "untracked") {
|
|
18083
17576
|
setOriginalContent("");
|
|
18084
17577
|
} else {
|
|
18085
|
-
|
|
18086
|
-
|
|
18087
|
-
|
|
18088
|
-
|
|
18089
|
-
|
|
18090
|
-
|
|
18091
|
-
} catch (gitError) {
|
|
18092
|
-
console.warn("[GitDiffPanel] Failed to get file from git, using empty original:", gitError);
|
|
18093
|
-
setOriginalContent("");
|
|
18094
|
-
}
|
|
18095
|
-
} else {
|
|
18096
|
-
console.warn("[GitDiffPanel] getFileContentAtRevision not available in fileSystem adapter");
|
|
17578
|
+
try {
|
|
17579
|
+
const original = await actions.getFileContentAtRevision(filePath, "HEAD");
|
|
17580
|
+
if (!isActive) return;
|
|
17581
|
+
setOriginalContent(original);
|
|
17582
|
+
} catch (gitError) {
|
|
17583
|
+
console.warn("[GitDiffPanel] Failed to get file from git, using empty original:", gitError);
|
|
18097
17584
|
setOriginalContent("");
|
|
18098
17585
|
}
|
|
18099
17586
|
}
|
|
@@ -18115,7 +17602,7 @@ const GitDiffPanelContent = ({
|
|
|
18115
17602
|
return () => {
|
|
18116
17603
|
isActive = false;
|
|
18117
17604
|
};
|
|
18118
|
-
}, [filePath, status,
|
|
17605
|
+
}, [filePath, status, actions, contentProvidedExternally]);
|
|
18119
17606
|
const handleClose2 = () => {
|
|
18120
17607
|
events.emit({
|
|
18121
17608
|
type: "git:diff:close",
|
|
@@ -26166,6 +25653,354 @@ function init(open, close2) {
|
|
|
26166
25653
|
return txt === void 0 ? chain([open], [blk]) : $$2.enabled ? run([blk], txt + "") : txt + "";
|
|
26167
25654
|
};
|
|
26168
25655
|
}
|
|
25656
|
+
function Diff2() {
|
|
25657
|
+
}
|
|
25658
|
+
Diff2.prototype = {
|
|
25659
|
+
diff: function diff(oldString, newString) {
|
|
25660
|
+
var _options$timeout;
|
|
25661
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
25662
|
+
var callback = options.callback;
|
|
25663
|
+
if (typeof options === "function") {
|
|
25664
|
+
callback = options;
|
|
25665
|
+
options = {};
|
|
25666
|
+
}
|
|
25667
|
+
this.options = options;
|
|
25668
|
+
var self2 = this;
|
|
25669
|
+
function done(value2) {
|
|
25670
|
+
if (callback) {
|
|
25671
|
+
setTimeout(function() {
|
|
25672
|
+
callback(void 0, value2);
|
|
25673
|
+
}, 0);
|
|
25674
|
+
return true;
|
|
25675
|
+
} else {
|
|
25676
|
+
return value2;
|
|
25677
|
+
}
|
|
25678
|
+
}
|
|
25679
|
+
oldString = this.castInput(oldString);
|
|
25680
|
+
newString = this.castInput(newString);
|
|
25681
|
+
oldString = this.removeEmpty(this.tokenize(oldString));
|
|
25682
|
+
newString = this.removeEmpty(this.tokenize(newString));
|
|
25683
|
+
var newLen = newString.length, oldLen = oldString.length;
|
|
25684
|
+
var editLength = 1;
|
|
25685
|
+
var maxEditLength = newLen + oldLen;
|
|
25686
|
+
if (options.maxEditLength) {
|
|
25687
|
+
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
25688
|
+
}
|
|
25689
|
+
var maxExecutionTime = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : Infinity;
|
|
25690
|
+
var abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
25691
|
+
var bestPath = [{
|
|
25692
|
+
oldPos: -1,
|
|
25693
|
+
lastComponent: void 0
|
|
25694
|
+
}];
|
|
25695
|
+
var newPos = this.extractCommon(bestPath[0], newString, oldString, 0);
|
|
25696
|
+
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
25697
|
+
return done([{
|
|
25698
|
+
value: this.join(newString),
|
|
25699
|
+
count: newString.length
|
|
25700
|
+
}]);
|
|
25701
|
+
}
|
|
25702
|
+
var minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
25703
|
+
function execEditLength() {
|
|
25704
|
+
for (var diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
25705
|
+
var basePath = void 0;
|
|
25706
|
+
var removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
25707
|
+
if (removePath) {
|
|
25708
|
+
bestPath[diagonalPath - 1] = void 0;
|
|
25709
|
+
}
|
|
25710
|
+
var canAdd = false;
|
|
25711
|
+
if (addPath) {
|
|
25712
|
+
var addPathNewPos = addPath.oldPos - diagonalPath;
|
|
25713
|
+
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
25714
|
+
}
|
|
25715
|
+
var canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
25716
|
+
if (!canAdd && !canRemove) {
|
|
25717
|
+
bestPath[diagonalPath] = void 0;
|
|
25718
|
+
continue;
|
|
25719
|
+
}
|
|
25720
|
+
if (!canRemove || canAdd && removePath.oldPos + 1 < addPath.oldPos) {
|
|
25721
|
+
basePath = self2.addToPath(addPath, true, void 0, 0);
|
|
25722
|
+
} else {
|
|
25723
|
+
basePath = self2.addToPath(removePath, void 0, true, 1);
|
|
25724
|
+
}
|
|
25725
|
+
newPos = self2.extractCommon(basePath, newString, oldString, diagonalPath);
|
|
25726
|
+
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
25727
|
+
return done(buildValues(self2, basePath.lastComponent, newString, oldString, self2.useLongestToken));
|
|
25728
|
+
} else {
|
|
25729
|
+
bestPath[diagonalPath] = basePath;
|
|
25730
|
+
if (basePath.oldPos + 1 >= oldLen) {
|
|
25731
|
+
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
25732
|
+
}
|
|
25733
|
+
if (newPos + 1 >= newLen) {
|
|
25734
|
+
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
25735
|
+
}
|
|
25736
|
+
}
|
|
25737
|
+
}
|
|
25738
|
+
editLength++;
|
|
25739
|
+
}
|
|
25740
|
+
if (callback) {
|
|
25741
|
+
(function exec() {
|
|
25742
|
+
setTimeout(function() {
|
|
25743
|
+
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
25744
|
+
return callback();
|
|
25745
|
+
}
|
|
25746
|
+
if (!execEditLength()) {
|
|
25747
|
+
exec();
|
|
25748
|
+
}
|
|
25749
|
+
}, 0);
|
|
25750
|
+
})();
|
|
25751
|
+
} else {
|
|
25752
|
+
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
25753
|
+
var ret = execEditLength();
|
|
25754
|
+
if (ret) {
|
|
25755
|
+
return ret;
|
|
25756
|
+
}
|
|
25757
|
+
}
|
|
25758
|
+
}
|
|
25759
|
+
},
|
|
25760
|
+
addToPath: function addToPath(path, added, removed, oldPosInc) {
|
|
25761
|
+
var last = path.lastComponent;
|
|
25762
|
+
if (last && last.added === added && last.removed === removed) {
|
|
25763
|
+
return {
|
|
25764
|
+
oldPos: path.oldPos + oldPosInc,
|
|
25765
|
+
lastComponent: {
|
|
25766
|
+
count: last.count + 1,
|
|
25767
|
+
added,
|
|
25768
|
+
removed,
|
|
25769
|
+
previousComponent: last.previousComponent
|
|
25770
|
+
}
|
|
25771
|
+
};
|
|
25772
|
+
} else {
|
|
25773
|
+
return {
|
|
25774
|
+
oldPos: path.oldPos + oldPosInc,
|
|
25775
|
+
lastComponent: {
|
|
25776
|
+
count: 1,
|
|
25777
|
+
added,
|
|
25778
|
+
removed,
|
|
25779
|
+
previousComponent: last
|
|
25780
|
+
}
|
|
25781
|
+
};
|
|
25782
|
+
}
|
|
25783
|
+
},
|
|
25784
|
+
extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
|
|
25785
|
+
var newLen = newString.length, oldLen = oldString.length, oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
25786
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
|
|
25787
|
+
newPos++;
|
|
25788
|
+
oldPos++;
|
|
25789
|
+
commonCount++;
|
|
25790
|
+
}
|
|
25791
|
+
if (commonCount) {
|
|
25792
|
+
basePath.lastComponent = {
|
|
25793
|
+
count: commonCount,
|
|
25794
|
+
previousComponent: basePath.lastComponent
|
|
25795
|
+
};
|
|
25796
|
+
}
|
|
25797
|
+
basePath.oldPos = oldPos;
|
|
25798
|
+
return newPos;
|
|
25799
|
+
},
|
|
25800
|
+
equals: function equals(left, right) {
|
|
25801
|
+
if (this.options.comparator) {
|
|
25802
|
+
return this.options.comparator(left, right);
|
|
25803
|
+
} else {
|
|
25804
|
+
return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
25805
|
+
}
|
|
25806
|
+
},
|
|
25807
|
+
removeEmpty: function removeEmpty(array) {
|
|
25808
|
+
var ret = [];
|
|
25809
|
+
for (var i2 = 0; i2 < array.length; i2++) {
|
|
25810
|
+
if (array[i2]) {
|
|
25811
|
+
ret.push(array[i2]);
|
|
25812
|
+
}
|
|
25813
|
+
}
|
|
25814
|
+
return ret;
|
|
25815
|
+
},
|
|
25816
|
+
castInput: function castInput(value2) {
|
|
25817
|
+
return value2;
|
|
25818
|
+
},
|
|
25819
|
+
tokenize: function tokenize(value2) {
|
|
25820
|
+
return value2.split("");
|
|
25821
|
+
},
|
|
25822
|
+
join: function join(chars) {
|
|
25823
|
+
return chars.join("");
|
|
25824
|
+
}
|
|
25825
|
+
};
|
|
25826
|
+
function buildValues(diff3, lastComponent, newString, oldString, useLongestToken) {
|
|
25827
|
+
var components = [];
|
|
25828
|
+
var nextComponent;
|
|
25829
|
+
while (lastComponent) {
|
|
25830
|
+
components.push(lastComponent);
|
|
25831
|
+
nextComponent = lastComponent.previousComponent;
|
|
25832
|
+
delete lastComponent.previousComponent;
|
|
25833
|
+
lastComponent = nextComponent;
|
|
25834
|
+
}
|
|
25835
|
+
components.reverse();
|
|
25836
|
+
var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0;
|
|
25837
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
25838
|
+
var component = components[componentPos];
|
|
25839
|
+
if (!component.removed) {
|
|
25840
|
+
if (!component.added && useLongestToken) {
|
|
25841
|
+
var value2 = newString.slice(newPos, newPos + component.count);
|
|
25842
|
+
value2 = value2.map(function(value3, i2) {
|
|
25843
|
+
var oldValue = oldString[oldPos + i2];
|
|
25844
|
+
return oldValue.length > value3.length ? oldValue : value3;
|
|
25845
|
+
});
|
|
25846
|
+
component.value = diff3.join(value2);
|
|
25847
|
+
} else {
|
|
25848
|
+
component.value = diff3.join(newString.slice(newPos, newPos + component.count));
|
|
25849
|
+
}
|
|
25850
|
+
newPos += component.count;
|
|
25851
|
+
if (!component.added) {
|
|
25852
|
+
oldPos += component.count;
|
|
25853
|
+
}
|
|
25854
|
+
} else {
|
|
25855
|
+
component.value = diff3.join(oldString.slice(oldPos, oldPos + component.count));
|
|
25856
|
+
oldPos += component.count;
|
|
25857
|
+
if (componentPos && components[componentPos - 1].added) {
|
|
25858
|
+
var tmp = components[componentPos - 1];
|
|
25859
|
+
components[componentPos - 1] = components[componentPos];
|
|
25860
|
+
components[componentPos] = tmp;
|
|
25861
|
+
}
|
|
25862
|
+
}
|
|
25863
|
+
}
|
|
25864
|
+
var finalComponent = components[componentLen - 1];
|
|
25865
|
+
if (componentLen > 1 && typeof finalComponent.value === "string" && (finalComponent.added || finalComponent.removed) && diff3.equals("", finalComponent.value)) {
|
|
25866
|
+
components[componentLen - 2].value += finalComponent.value;
|
|
25867
|
+
components.pop();
|
|
25868
|
+
}
|
|
25869
|
+
return components;
|
|
25870
|
+
}
|
|
25871
|
+
var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
|
|
25872
|
+
var reWhitespace = /\S/;
|
|
25873
|
+
var wordDiff = new Diff2();
|
|
25874
|
+
wordDiff.equals = function(left, right) {
|
|
25875
|
+
if (this.options.ignoreCase) {
|
|
25876
|
+
left = left.toLowerCase();
|
|
25877
|
+
right = right.toLowerCase();
|
|
25878
|
+
}
|
|
25879
|
+
return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
|
|
25880
|
+
};
|
|
25881
|
+
wordDiff.tokenize = function(value2) {
|
|
25882
|
+
var tokens = value2.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/);
|
|
25883
|
+
for (var i2 = 0; i2 < tokens.length - 1; i2++) {
|
|
25884
|
+
if (!tokens[i2 + 1] && tokens[i2 + 2] && extendedWordChars.test(tokens[i2]) && extendedWordChars.test(tokens[i2 + 2])) {
|
|
25885
|
+
tokens[i2] += tokens[i2 + 2];
|
|
25886
|
+
tokens.splice(i2 + 1, 2);
|
|
25887
|
+
i2--;
|
|
25888
|
+
}
|
|
25889
|
+
}
|
|
25890
|
+
return tokens;
|
|
25891
|
+
};
|
|
25892
|
+
var lineDiff = new Diff2();
|
|
25893
|
+
lineDiff.tokenize = function(value2) {
|
|
25894
|
+
if (this.options.stripTrailingCr) {
|
|
25895
|
+
value2 = value2.replace(/\r\n/g, "\n");
|
|
25896
|
+
}
|
|
25897
|
+
var retLines = [], linesAndNewlines = value2.split(/(\n|\r\n)/);
|
|
25898
|
+
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
25899
|
+
linesAndNewlines.pop();
|
|
25900
|
+
}
|
|
25901
|
+
for (var i2 = 0; i2 < linesAndNewlines.length; i2++) {
|
|
25902
|
+
var line = linesAndNewlines[i2];
|
|
25903
|
+
if (i2 % 2 && !this.options.newlineIsToken) {
|
|
25904
|
+
retLines[retLines.length - 1] += line;
|
|
25905
|
+
} else {
|
|
25906
|
+
if (this.options.ignoreWhitespace) {
|
|
25907
|
+
line = line.trim();
|
|
25908
|
+
}
|
|
25909
|
+
retLines.push(line);
|
|
25910
|
+
}
|
|
25911
|
+
}
|
|
25912
|
+
return retLines;
|
|
25913
|
+
};
|
|
25914
|
+
var sentenceDiff = new Diff2();
|
|
25915
|
+
sentenceDiff.tokenize = function(value2) {
|
|
25916
|
+
return value2.split(/(\S.+?[.!?])(?=\s+|$)/);
|
|
25917
|
+
};
|
|
25918
|
+
var cssDiff = new Diff2();
|
|
25919
|
+
cssDiff.tokenize = function(value2) {
|
|
25920
|
+
return value2.split(/([{}:;,]|\s+)/);
|
|
25921
|
+
};
|
|
25922
|
+
function _typeof(obj) {
|
|
25923
|
+
"@babel/helpers - typeof";
|
|
25924
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
25925
|
+
_typeof = function(obj2) {
|
|
25926
|
+
return typeof obj2;
|
|
25927
|
+
};
|
|
25928
|
+
} else {
|
|
25929
|
+
_typeof = function(obj2) {
|
|
25930
|
+
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
25931
|
+
};
|
|
25932
|
+
}
|
|
25933
|
+
return _typeof(obj);
|
|
25934
|
+
}
|
|
25935
|
+
var objectPrototypeToString = Object.prototype.toString;
|
|
25936
|
+
var jsonDiff = new Diff2();
|
|
25937
|
+
jsonDiff.useLongestToken = true;
|
|
25938
|
+
jsonDiff.tokenize = lineDiff.tokenize;
|
|
25939
|
+
jsonDiff.castInput = function(value2) {
|
|
25940
|
+
var _this$options = this.options, undefinedReplacement = _this$options.undefinedReplacement, _this$options$stringi = _this$options.stringifyReplacer, stringifyReplacer = _this$options$stringi === void 0 ? function(k3, v2) {
|
|
25941
|
+
return typeof v2 === "undefined" ? undefinedReplacement : v2;
|
|
25942
|
+
} : _this$options$stringi;
|
|
25943
|
+
return typeof value2 === "string" ? value2 : JSON.stringify(canonicalize(value2, null, null, stringifyReplacer), stringifyReplacer, " ");
|
|
25944
|
+
};
|
|
25945
|
+
jsonDiff.equals = function(left, right) {
|
|
25946
|
+
return Diff2.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"));
|
|
25947
|
+
};
|
|
25948
|
+
function canonicalize(obj, stack, replacementStack, replacer, key2) {
|
|
25949
|
+
stack = stack || [];
|
|
25950
|
+
replacementStack = replacementStack || [];
|
|
25951
|
+
if (replacer) {
|
|
25952
|
+
obj = replacer(key2, obj);
|
|
25953
|
+
}
|
|
25954
|
+
var i2;
|
|
25955
|
+
for (i2 = 0; i2 < stack.length; i2 += 1) {
|
|
25956
|
+
if (stack[i2] === obj) {
|
|
25957
|
+
return replacementStack[i2];
|
|
25958
|
+
}
|
|
25959
|
+
}
|
|
25960
|
+
var canonicalizedObj;
|
|
25961
|
+
if ("[object Array]" === objectPrototypeToString.call(obj)) {
|
|
25962
|
+
stack.push(obj);
|
|
25963
|
+
canonicalizedObj = new Array(obj.length);
|
|
25964
|
+
replacementStack.push(canonicalizedObj);
|
|
25965
|
+
for (i2 = 0; i2 < obj.length; i2 += 1) {
|
|
25966
|
+
canonicalizedObj[i2] = canonicalize(obj[i2], stack, replacementStack, replacer, key2);
|
|
25967
|
+
}
|
|
25968
|
+
stack.pop();
|
|
25969
|
+
replacementStack.pop();
|
|
25970
|
+
return canonicalizedObj;
|
|
25971
|
+
}
|
|
25972
|
+
if (obj && obj.toJSON) {
|
|
25973
|
+
obj = obj.toJSON();
|
|
25974
|
+
}
|
|
25975
|
+
if (_typeof(obj) === "object" && obj !== null) {
|
|
25976
|
+
stack.push(obj);
|
|
25977
|
+
canonicalizedObj = {};
|
|
25978
|
+
replacementStack.push(canonicalizedObj);
|
|
25979
|
+
var sortedKeys = [], _key;
|
|
25980
|
+
for (_key in obj) {
|
|
25981
|
+
if (obj.hasOwnProperty(_key)) {
|
|
25982
|
+
sortedKeys.push(_key);
|
|
25983
|
+
}
|
|
25984
|
+
}
|
|
25985
|
+
sortedKeys.sort();
|
|
25986
|
+
for (i2 = 0; i2 < sortedKeys.length; i2 += 1) {
|
|
25987
|
+
_key = sortedKeys[i2];
|
|
25988
|
+
canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
|
|
25989
|
+
}
|
|
25990
|
+
stack.pop();
|
|
25991
|
+
replacementStack.pop();
|
|
25992
|
+
} else {
|
|
25993
|
+
canonicalizedObj = obj;
|
|
25994
|
+
}
|
|
25995
|
+
return canonicalizedObj;
|
|
25996
|
+
}
|
|
25997
|
+
var arrayDiff = new Diff2();
|
|
25998
|
+
arrayDiff.tokenize = function(value2) {
|
|
25999
|
+
return value2.slice();
|
|
26000
|
+
};
|
|
26001
|
+
arrayDiff.join = arrayDiff.removeEmpty = function(value2) {
|
|
26002
|
+
return value2;
|
|
26003
|
+
};
|
|
26169
26004
|
({
|
|
26170
26005
|
"--": $$2.red,
|
|
26171
26006
|
"··": $$2.grey,
|
|
@@ -79332,7 +79167,7 @@ function legacy(parser2) {
|
|
|
79332
79167
|
return new LanguageSupport(StreamLanguage.define(parser2));
|
|
79333
79168
|
}
|
|
79334
79169
|
function sql(dialectName) {
|
|
79335
|
-
return import("./index-
|
|
79170
|
+
return import("./index-Dh1AHgs3.js").then((m3) => m3.sql({ dialect: m3[dialectName] }));
|
|
79336
79171
|
}
|
|
79337
79172
|
const languages = [
|
|
79338
79173
|
// New-style language modes
|
|
@@ -79340,7 +79175,7 @@ const languages = [
|
|
|
79340
79175
|
name: "C",
|
|
79341
79176
|
extensions: ["c", "h", "ino"],
|
|
79342
79177
|
load() {
|
|
79343
|
-
return import("./index-
|
|
79178
|
+
return import("./index-DEwRzW47.js").then((m3) => m3.cpp());
|
|
79344
79179
|
}
|
|
79345
79180
|
}),
|
|
79346
79181
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -79348,7 +79183,7 @@ const languages = [
|
|
|
79348
79183
|
alias: ["cpp"],
|
|
79349
79184
|
extensions: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"],
|
|
79350
79185
|
load() {
|
|
79351
|
-
return import("./index-
|
|
79186
|
+
return import("./index-DEwRzW47.js").then((m3) => m3.cpp());
|
|
79352
79187
|
}
|
|
79353
79188
|
}),
|
|
79354
79189
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -79370,7 +79205,7 @@ const languages = [
|
|
|
79370
79205
|
name: "Go",
|
|
79371
79206
|
extensions: ["go"],
|
|
79372
79207
|
load() {
|
|
79373
|
-
return import("./index-
|
|
79208
|
+
return import("./index-CLv3Y9-j.js").then((m3) => m3.go());
|
|
79374
79209
|
}
|
|
79375
79210
|
}),
|
|
79376
79211
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -79385,7 +79220,7 @@ const languages = [
|
|
|
79385
79220
|
name: "Java",
|
|
79386
79221
|
extensions: ["java"],
|
|
79387
79222
|
load() {
|
|
79388
|
-
return import("./index-
|
|
79223
|
+
return import("./index-BXVw4ynU.js").then((m3) => m3.java());
|
|
79389
79224
|
}
|
|
79390
79225
|
}),
|
|
79391
79226
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -79400,7 +79235,7 @@ const languages = [
|
|
|
79400
79235
|
name: "Jinja",
|
|
79401
79236
|
extensions: ["j2", "jinja", "jinja2"],
|
|
79402
79237
|
load() {
|
|
79403
|
-
return import("./index-
|
|
79238
|
+
return import("./index-CFej-1G2.js").then((m3) => m3.jinja());
|
|
79404
79239
|
}
|
|
79405
79240
|
}),
|
|
79406
79241
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -79408,7 +79243,7 @@ const languages = [
|
|
|
79408
79243
|
alias: ["json5"],
|
|
79409
79244
|
extensions: ["json", "map"],
|
|
79410
79245
|
load() {
|
|
79411
|
-
return import("./index-
|
|
79246
|
+
return import("./index-C0770yXr.js").then((m3) => m3.json());
|
|
79412
79247
|
}
|
|
79413
79248
|
}),
|
|
79414
79249
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -79422,14 +79257,14 @@ const languages = [
|
|
|
79422
79257
|
name: "LESS",
|
|
79423
79258
|
extensions: ["less"],
|
|
79424
79259
|
load() {
|
|
79425
|
-
return import("./index-
|
|
79260
|
+
return import("./index-BTXt6i9h.js").then((m3) => m3.less());
|
|
79426
79261
|
}
|
|
79427
79262
|
}),
|
|
79428
79263
|
/* @__PURE__ */ LanguageDescription.of({
|
|
79429
79264
|
name: "Liquid",
|
|
79430
79265
|
extensions: ["liquid"],
|
|
79431
79266
|
load() {
|
|
79432
|
-
return import("./index-
|
|
79267
|
+
return import("./index-BWJlMHH_.js").then((m3) => m3.liquid());
|
|
79433
79268
|
}
|
|
79434
79269
|
}),
|
|
79435
79270
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -79461,7 +79296,7 @@ const languages = [
|
|
|
79461
79296
|
name: "PHP",
|
|
79462
79297
|
extensions: ["php", "php3", "php4", "php5", "php7", "phtml"],
|
|
79463
79298
|
load() {
|
|
79464
|
-
return import("./index-
|
|
79299
|
+
return import("./index-DYwDbpPP.js").then((m3) => m3.php());
|
|
79465
79300
|
}
|
|
79466
79301
|
}),
|
|
79467
79302
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -79482,28 +79317,28 @@ const languages = [
|
|
|
79482
79317
|
extensions: ["BUILD", "bzl", "py", "pyw"],
|
|
79483
79318
|
filename: /^(BUCK|BUILD)$/,
|
|
79484
79319
|
load() {
|
|
79485
|
-
return import("./index
|
|
79320
|
+
return import("./index-KPVqGXN9.js").then((m3) => m3.python());
|
|
79486
79321
|
}
|
|
79487
79322
|
}),
|
|
79488
79323
|
/* @__PURE__ */ LanguageDescription.of({
|
|
79489
79324
|
name: "Rust",
|
|
79490
79325
|
extensions: ["rs"],
|
|
79491
79326
|
load() {
|
|
79492
|
-
return import("./index-
|
|
79327
|
+
return import("./index-DrfdWFxB.js").then((m3) => m3.rust());
|
|
79493
79328
|
}
|
|
79494
79329
|
}),
|
|
79495
79330
|
/* @__PURE__ */ LanguageDescription.of({
|
|
79496
79331
|
name: "Sass",
|
|
79497
79332
|
extensions: ["sass"],
|
|
79498
79333
|
load() {
|
|
79499
|
-
return import("./index-
|
|
79334
|
+
return import("./index-CWjV_DtT.js").then((m3) => m3.sass({ indented: true }));
|
|
79500
79335
|
}
|
|
79501
79336
|
}),
|
|
79502
79337
|
/* @__PURE__ */ LanguageDescription.of({
|
|
79503
79338
|
name: "SCSS",
|
|
79504
79339
|
extensions: ["scss"],
|
|
79505
79340
|
load() {
|
|
79506
|
-
return import("./index-
|
|
79341
|
+
return import("./index-CWjV_DtT.js").then((m3) => m3.sass());
|
|
79507
79342
|
}
|
|
79508
79343
|
}),
|
|
79509
79344
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -79538,7 +79373,7 @@ const languages = [
|
|
|
79538
79373
|
name: "WebAssembly",
|
|
79539
79374
|
extensions: ["wat", "wast"],
|
|
79540
79375
|
load() {
|
|
79541
|
-
return import("./index-
|
|
79376
|
+
return import("./index-KC7gIhDr.js").then((m3) => m3.wast());
|
|
79542
79377
|
}
|
|
79543
79378
|
}),
|
|
79544
79379
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -79546,7 +79381,7 @@ const languages = [
|
|
|
79546
79381
|
alias: ["rss", "wsdl", "xsd"],
|
|
79547
79382
|
extensions: ["xml", "xsl", "xsd", "svg"],
|
|
79548
79383
|
load() {
|
|
79549
|
-
return import("./index-
|
|
79384
|
+
return import("./index-ChQ_GgQS.js").then((m3) => m3.xml());
|
|
79550
79385
|
}
|
|
79551
79386
|
}),
|
|
79552
79387
|
/* @__PURE__ */ LanguageDescription.of({
|
|
@@ -79554,7 +79389,7 @@ const languages = [
|
|
|
79554
79389
|
alias: ["yml"],
|
|
79555
79390
|
extensions: ["yaml", "yml"],
|
|
79556
79391
|
load() {
|
|
79557
|
-
return import("./index-
|
|
79392
|
+
return import("./index-D4BXOVXb.js").then((m3) => m3.yaml());
|
|
79558
79393
|
}
|
|
79559
79394
|
}),
|
|
79560
79395
|
// Legacy modes ported from CodeMirror 5
|
|
@@ -80343,13 +80178,13 @@ const languages = [
|
|
|
80343
80178
|
name: "Vue",
|
|
80344
80179
|
extensions: ["vue"],
|
|
80345
80180
|
load() {
|
|
80346
|
-
return import("./index-
|
|
80181
|
+
return import("./index-DOj0XYCl.js").then((m3) => m3.vue());
|
|
80347
80182
|
}
|
|
80348
80183
|
}),
|
|
80349
80184
|
/* @__PURE__ */ LanguageDescription.of({
|
|
80350
80185
|
name: "Angular Template",
|
|
80351
80186
|
load() {
|
|
80352
|
-
return import("./index-
|
|
80187
|
+
return import("./index-CyEpFs5g.js").then((m3) => m3.angular());
|
|
80353
80188
|
}
|
|
80354
80189
|
})
|
|
80355
80190
|
];
|
|
@@ -92567,14 +92402,14 @@ const basicDark = [
|
|
|
92567
92402
|
];
|
|
92568
92403
|
const MDXEditorPanelContent = ({
|
|
92569
92404
|
context,
|
|
92570
|
-
actions
|
|
92405
|
+
actions,
|
|
92571
92406
|
events,
|
|
92572
92407
|
filePath: filePathProp,
|
|
92573
92408
|
showCloseButton = true,
|
|
92574
92409
|
gitStatus: gitStatusProp,
|
|
92575
92410
|
isDirty: isDirtyProp
|
|
92576
92411
|
}) => {
|
|
92577
|
-
var _a3
|
|
92412
|
+
var _a3;
|
|
92578
92413
|
const { theme: theme2 } = useTheme();
|
|
92579
92414
|
const [filePath, setFilePath] = useState(null);
|
|
92580
92415
|
const [markdown2, setMarkdown] = useState("");
|
|
@@ -92586,9 +92421,8 @@ const MDXEditorPanelContent = ({
|
|
|
92586
92421
|
const [internalGitStatus, setInternalGitStatus] = useState(null);
|
|
92587
92422
|
const _isDirty = isDirtyProp !== void 0 ? isDirtyProp : internalIsDirty;
|
|
92588
92423
|
const gitStatus = gitStatusProp !== void 0 ? gitStatusProp : internalGitStatus;
|
|
92589
|
-
const
|
|
92590
|
-
const
|
|
92591
|
-
const activeFileSlice = context.getSlice("active-file");
|
|
92424
|
+
const isEditable = Boolean(actions.writeFile);
|
|
92425
|
+
const { activeFile } = context;
|
|
92592
92426
|
const plugins = useMemo(
|
|
92593
92427
|
() => [
|
|
92594
92428
|
headingsPlugin(),
|
|
@@ -92682,12 +92516,12 @@ const MDXEditorPanelContent = ({
|
|
|
92682
92516
|
useEffect(() => {
|
|
92683
92517
|
var _a4;
|
|
92684
92518
|
if (!filePathProp) {
|
|
92685
|
-
const path = (_a4 =
|
|
92519
|
+
const path = (_a4 = activeFile == null ? void 0 : activeFile.data) == null ? void 0 : _a4.path;
|
|
92686
92520
|
if (path && (path.endsWith(".md") || path.endsWith(".mdx"))) {
|
|
92687
92521
|
setFilePath(path);
|
|
92688
92522
|
}
|
|
92689
92523
|
}
|
|
92690
|
-
}, [filePathProp, (
|
|
92524
|
+
}, [filePathProp, (_a3 = activeFile == null ? void 0 : activeFile.data) == null ? void 0 : _a3.path]);
|
|
92691
92525
|
useEffect(() => {
|
|
92692
92526
|
if (filePathProp) {
|
|
92693
92527
|
return void 0;
|
|
@@ -92726,9 +92560,9 @@ const MDXEditorPanelContent = ({
|
|
|
92726
92560
|
const handleSave = useCallback(
|
|
92727
92561
|
async (content2) => {
|
|
92728
92562
|
const contentToSave = content2 || markdown2;
|
|
92729
|
-
if (filePath &&
|
|
92563
|
+
if (filePath && actions.writeFile) {
|
|
92730
92564
|
try {
|
|
92731
|
-
await
|
|
92565
|
+
await actions.writeFile(filePath, contentToSave);
|
|
92732
92566
|
if (isDirtyProp === void 0) {
|
|
92733
92567
|
setInternalIsDirty(false);
|
|
92734
92568
|
}
|
|
@@ -92746,26 +92580,22 @@ const MDXEditorPanelContent = ({
|
|
|
92746
92580
|
}
|
|
92747
92581
|
}
|
|
92748
92582
|
},
|
|
92749
|
-
[markdown2, filePath,
|
|
92583
|
+
[markdown2, filePath, actions, events, gitStatus, isDirtyProp, gitStatusProp]
|
|
92750
92584
|
);
|
|
92751
92585
|
useEffect(() => {
|
|
92752
92586
|
const loadFileContent = async () => {
|
|
92753
|
-
if (!filePath
|
|
92587
|
+
if (!filePath) {
|
|
92754
92588
|
setMarkdown("");
|
|
92755
92589
|
return;
|
|
92756
92590
|
}
|
|
92757
92591
|
setIsLoading(true);
|
|
92758
92592
|
setLoadError(null);
|
|
92759
92593
|
try {
|
|
92760
|
-
const content2 = await
|
|
92761
|
-
|
|
92762
|
-
|
|
92763
|
-
|
|
92764
|
-
|
|
92765
|
-
setInternalIsDirty(false);
|
|
92766
|
-
}
|
|
92767
|
-
} else {
|
|
92768
|
-
throw new Error("Failed to read file");
|
|
92594
|
+
const content2 = await actions.readFile(filePath);
|
|
92595
|
+
setMarkdown(content2);
|
|
92596
|
+
setParseError(null);
|
|
92597
|
+
if (isDirtyProp === void 0) {
|
|
92598
|
+
setInternalIsDirty(false);
|
|
92769
92599
|
}
|
|
92770
92600
|
} catch (error) {
|
|
92771
92601
|
console.error("Error loading file:", error);
|
|
@@ -92777,7 +92607,7 @@ const MDXEditorPanelContent = ({
|
|
|
92777
92607
|
}
|
|
92778
92608
|
};
|
|
92779
92609
|
loadFileContent();
|
|
92780
|
-
}, [filePath,
|
|
92610
|
+
}, [filePath, actions, isDirtyProp]);
|
|
92781
92611
|
useEffect(() => {
|
|
92782
92612
|
if (!isEditable) return;
|
|
92783
92613
|
const handleKeyDown = (e2) => {
|
|
@@ -93110,7 +92940,7 @@ const panels = [
|
|
|
93110
92940
|
version: "0.1.0",
|
|
93111
92941
|
author: "Industry Theme",
|
|
93112
92942
|
description: "Monaco-based code editor with syntax highlighting",
|
|
93113
|
-
slices: ["
|
|
92943
|
+
slices: ["activeFile"],
|
|
93114
92944
|
tools: [fileEditingPanelTools[0]]
|
|
93115
92945
|
// openFileTool
|
|
93116
92946
|
},
|
|
@@ -93134,7 +92964,7 @@ const panels = [
|
|
|
93134
92964
|
version: "0.1.0",
|
|
93135
92965
|
author: "Industry Theme",
|
|
93136
92966
|
description: "Side-by-side git diff viewer",
|
|
93137
|
-
slices: [
|
|
92967
|
+
slices: [],
|
|
93138
92968
|
tools: [fileEditingPanelTools[1]]
|
|
93139
92969
|
// viewDiffTool
|
|
93140
92970
|
},
|
|
@@ -93158,7 +92988,7 @@ const panels = [
|
|
|
93158
92988
|
version: "0.1.0",
|
|
93159
92989
|
author: "Industry Theme",
|
|
93160
92990
|
description: "Rich markdown/MDX editor with live preview",
|
|
93161
|
-
slices: ["
|
|
92991
|
+
slices: ["activeFile"],
|
|
93162
92992
|
tools: [fileEditingPanelTools[2]]
|
|
93163
92993
|
// openMarkdownTool
|
|
93164
92994
|
},
|
|
@@ -93224,4 +93054,4 @@ export {
|
|
|
93224
93054
|
onPackageUnload as y,
|
|
93225
93055
|
fileEditingPanelTools as z
|
|
93226
93056
|
};
|
|
93227
|
-
//# sourceMappingURL=index-
|
|
93057
|
+
//# sourceMappingURL=index-BL8kpLmN.js.map
|