@tobos/cli 0.4.28 → 0.4.29
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.
|
@@ -55798,6 +55798,120 @@ function mediaTypeOf(name) {
|
|
|
55798
55798
|
return TYPES[extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
55799
55799
|
}
|
|
55800
55800
|
|
|
55801
|
+
// ../deck/src/merge.ts
|
|
55802
|
+
init_define_TOBOS_PRESENT_TYPES();
|
|
55803
|
+
init_define_TOBOS_SKILL();
|
|
55804
|
+
init_define_TOBOS_TOOLCHAIN();
|
|
55805
|
+
var MOST = 4e6;
|
|
55806
|
+
function mergeText(base, ours, theirs) {
|
|
55807
|
+
if (ours === theirs || theirs === base) return ours;
|
|
55808
|
+
if (ours === base) return theirs;
|
|
55809
|
+
const [b, o, t] = [base, ours, theirs].map(split);
|
|
55810
|
+
let changes;
|
|
55811
|
+
try {
|
|
55812
|
+
changes = [hunksOf(b, o), hunksOf(b, t)];
|
|
55813
|
+
} catch (error) {
|
|
55814
|
+
if (error instanceof TooLarge) return void 0;
|
|
55815
|
+
throw error;
|
|
55816
|
+
}
|
|
55817
|
+
const hunks = [
|
|
55818
|
+
...changes[0].map((h) => ({ ...h, side: 0 })),
|
|
55819
|
+
...changes[1].map((h) => ({ ...h, side: 1 }))
|
|
55820
|
+
].sort((x, y) => x.from - y.from || x.to - y.to);
|
|
55821
|
+
const merged = [];
|
|
55822
|
+
let at2 = 0;
|
|
55823
|
+
for (let i2 = 0; i2 < hunks.length; ) {
|
|
55824
|
+
const group = [hunks[i2]];
|
|
55825
|
+
let to = hunks[i2].to;
|
|
55826
|
+
for (i2++; i2 < hunks.length && overlaps(hunks[i2], group.at(-1).from, to); i2++) {
|
|
55827
|
+
group.push(hunks[i2]);
|
|
55828
|
+
to = Math.max(to, hunks[i2].to);
|
|
55829
|
+
}
|
|
55830
|
+
const from = group[0].from;
|
|
55831
|
+
const sides = new Set(group.map((h) => h.side));
|
|
55832
|
+
let lines2;
|
|
55833
|
+
if (sides.size === 1) lines2 = applied(b, group, from, to);
|
|
55834
|
+
else {
|
|
55835
|
+
const mine = applied(
|
|
55836
|
+
b,
|
|
55837
|
+
group.filter((h) => h.side === 0),
|
|
55838
|
+
from,
|
|
55839
|
+
to
|
|
55840
|
+
);
|
|
55841
|
+
const yours = applied(
|
|
55842
|
+
b,
|
|
55843
|
+
group.filter((h) => h.side === 1),
|
|
55844
|
+
from,
|
|
55845
|
+
to
|
|
55846
|
+
);
|
|
55847
|
+
if (mine.join("") !== yours.join("")) return void 0;
|
|
55848
|
+
lines2 = mine;
|
|
55849
|
+
}
|
|
55850
|
+
merged.push(...b.slice(at2, from), ...lines2);
|
|
55851
|
+
at2 = to;
|
|
55852
|
+
}
|
|
55853
|
+
merged.push(...b.slice(at2));
|
|
55854
|
+
return merged.join("");
|
|
55855
|
+
}
|
|
55856
|
+
function overlaps(hunk, from, to) {
|
|
55857
|
+
return hunk.from < to || hunk.from === from || hunk.from === to && (hunk.to === to || from === to);
|
|
55858
|
+
}
|
|
55859
|
+
function applied(base, hunks, from, to) {
|
|
55860
|
+
const out = [];
|
|
55861
|
+
let at2 = from;
|
|
55862
|
+
for (const hunk of hunks) {
|
|
55863
|
+
out.push(...base.slice(at2, hunk.from), ...hunk.lines);
|
|
55864
|
+
at2 = hunk.to;
|
|
55865
|
+
}
|
|
55866
|
+
out.push(...base.slice(at2, to));
|
|
55867
|
+
return out;
|
|
55868
|
+
}
|
|
55869
|
+
function split(text3) {
|
|
55870
|
+
return text3.match(/[^\n]*\n|[^\n]+$/g) ?? [];
|
|
55871
|
+
}
|
|
55872
|
+
function hunksOf(all, other) {
|
|
55873
|
+
let start = 0;
|
|
55874
|
+
while (start < all.length && start < other.length && all[start] === other[start]) start++;
|
|
55875
|
+
let end = 0;
|
|
55876
|
+
while (end < all.length - start && end < other.length - start && all[all.length - 1 - end] === other[other.length - 1 - end])
|
|
55877
|
+
end++;
|
|
55878
|
+
const a = all.slice(start, all.length - end);
|
|
55879
|
+
const b = other.slice(start, other.length - end);
|
|
55880
|
+
if ((a.length + 1) * (b.length + 1) > MOST) throw new TooLarge();
|
|
55881
|
+
return middleHunks(a, b).map((h) => ({ ...h, from: h.from + start, to: h.to + start }));
|
|
55882
|
+
}
|
|
55883
|
+
var TooLarge = class extends Error {
|
|
55884
|
+
};
|
|
55885
|
+
function middleHunks(a, b) {
|
|
55886
|
+
const width = b.length + 1;
|
|
55887
|
+
const tail = new Int32Array((a.length + 1) * width);
|
|
55888
|
+
for (let i3 = a.length - 1; i3 >= 0; i3--)
|
|
55889
|
+
for (let j2 = b.length - 1; j2 >= 0; j2--)
|
|
55890
|
+
tail[i3 * width + j2] = a[i3] === b[j2] ? tail[(i3 + 1) * width + j2 + 1] + 1 : Math.max(tail[(i3 + 1) * width + j2], tail[i3 * width + j2 + 1]);
|
|
55891
|
+
const hunks = [];
|
|
55892
|
+
let [i2, j] = [0, 0];
|
|
55893
|
+
let open2;
|
|
55894
|
+
const close2 = () => {
|
|
55895
|
+
if (open2) hunks.push(open2);
|
|
55896
|
+
open2 = void 0;
|
|
55897
|
+
};
|
|
55898
|
+
while (i2 < a.length || j < b.length) {
|
|
55899
|
+
if (i2 < a.length && j < b.length && a[i2] === b[j]) {
|
|
55900
|
+
close2();
|
|
55901
|
+
i2++;
|
|
55902
|
+
j++;
|
|
55903
|
+
} else if (j < b.length && (i2 === a.length || tail[i2 * width + j + 1] >= tail[(i2 + 1) * width + j])) {
|
|
55904
|
+
open2 ??= { from: i2, to: i2, lines: [] };
|
|
55905
|
+
open2.lines.push(b[j++]);
|
|
55906
|
+
} else {
|
|
55907
|
+
open2 ??= { from: i2, to: i2, lines: [] };
|
|
55908
|
+
open2.to = ++i2;
|
|
55909
|
+
}
|
|
55910
|
+
}
|
|
55911
|
+
close2();
|
|
55912
|
+
return hunks;
|
|
55913
|
+
}
|
|
55914
|
+
|
|
55801
55915
|
export {
|
|
55802
55916
|
formatProblems,
|
|
55803
55917
|
TEXT_MAX,
|
|
@@ -55818,5 +55932,6 @@ export {
|
|
|
55818
55932
|
KEPT_MEDIA_DAYS,
|
|
55819
55933
|
buildDeck,
|
|
55820
55934
|
masterOf,
|
|
55821
|
-
mediaTypeOf
|
|
55935
|
+
mediaTypeOf,
|
|
55936
|
+
mergeText
|
|
55822
55937
|
};
|
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
formatMediaJson,
|
|
6
6
|
formatProblems,
|
|
7
7
|
mediaTypeOf
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TQNXR6KB.js";
|
|
9
9
|
import {
|
|
10
10
|
ASK_THE_PERSON,
|
|
11
11
|
CliError,
|
|
@@ -89,7 +89,7 @@ function settings() {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// src/api.ts
|
|
92
|
-
var VERSION = true ? "0.4.
|
|
92
|
+
var VERSION = true ? "0.4.29" : "dev";
|
|
93
93
|
function newer(a, b) {
|
|
94
94
|
const parse = (v) => /^\d+\.\d+\.\d+/.test(v) ? v.split(".").map((n) => parseInt(n)) : null;
|
|
95
95
|
const x = parse(a);
|
|
@@ -112,7 +112,7 @@ async function api(path, options = {}) {
|
|
|
112
112
|
}
|
|
113
113
|
function failure(response, data, prefix = "") {
|
|
114
114
|
const { error, message, ...extra } = data;
|
|
115
|
-
const said = prefix + (
|
|
115
|
+
const said = prefix + (message ?? error ?? `${response.status} ${response.statusText}`);
|
|
116
116
|
const limit = response.status === 402 || response.status === 423;
|
|
117
117
|
return new CliError(
|
|
118
118
|
limit ? `${said}
|
|
@@ -760,7 +760,7 @@ async function pushedFiles(root) {
|
|
|
760
760
|
}
|
|
761
761
|
}
|
|
762
762
|
async function runCheck(dir2) {
|
|
763
|
-
const { buildDeck } = await import("./src-
|
|
763
|
+
const { buildDeck } = await import("./src-K2VVILG5.js");
|
|
764
764
|
const started = performance.now();
|
|
765
765
|
const files = await pushedFiles(dir2.root);
|
|
766
766
|
const result = await buildDeck(directoryTree(dir2.root, files));
|
|
@@ -821,7 +821,7 @@ async function check(out, args) {
|
|
|
821
821
|
await syncMediaJson(deck.root);
|
|
822
822
|
const result = await runCheck(deck);
|
|
823
823
|
if (args.values.types) {
|
|
824
|
-
const { checkTypes } = await import("./types-
|
|
824
|
+
const { checkTypes } = await import("./types-BX3YXER7.js");
|
|
825
825
|
const sent = result.files && new Set(result.files);
|
|
826
826
|
result.problems.push(
|
|
827
827
|
...(await checkTypes(deck.root, (m) => out.note(m))).filter((p) => sent?.has(p.file) ?? true)
|
|
@@ -848,7 +848,7 @@ async function pushWorkingCopy(out, deck, message) {
|
|
|
848
848
|
const result = await runCheck(deck);
|
|
849
849
|
const { errors, warnings } = problemSummary(result.problems);
|
|
850
850
|
if (errors > 0) return { ok: false, errors, warnings, problems: result.problems };
|
|
851
|
-
const { mediaInUse } = await import("./src-
|
|
851
|
+
const { mediaInUse } = await import("./src-K2VVILG5.js");
|
|
852
852
|
const shown = result.manifest ? mediaInUse(result.manifest) : media;
|
|
853
853
|
for (const [name, entry] of Object.entries(shown)) {
|
|
854
854
|
const note = sizeNote(name, entry.size);
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
mediaInUse,
|
|
16
16
|
mediaTypeOf,
|
|
17
17
|
memoryTree,
|
|
18
|
+
mergeText,
|
|
18
19
|
openActivity,
|
|
19
20
|
parseDeckJson,
|
|
20
21
|
parseMediaJson,
|
|
@@ -22,7 +23,7 @@ import {
|
|
|
22
23
|
servesModule,
|
|
23
24
|
sha256,
|
|
24
25
|
sharedManifest
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-TQNXR6KB.js";
|
|
26
27
|
import "./chunk-3SEPIUUD.js";
|
|
27
28
|
export {
|
|
28
29
|
ID,
|
|
@@ -38,6 +39,7 @@ export {
|
|
|
38
39
|
mediaInUse,
|
|
39
40
|
mediaTypeOf,
|
|
40
41
|
memoryTree,
|
|
42
|
+
mergeText,
|
|
41
43
|
openActivity,
|
|
42
44
|
parseDeckJson,
|
|
43
45
|
parseMediaJson,
|