@poe-platform/safe-bash 0.1.814 → 0.1.815
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/mp4-ast/index.d.ts +1 -0
- package/dist/mp4-ast/mp4-fragment-source.d.ts +35 -0
- package/dist/mp4-ast/mp4-sample-source.d.ts +5 -2
- package/dist/mp4-ast/types.d.ts +11 -0
- package/dist/pdf-ast/cos/object-reader.d.ts +3 -2
- package/dist/pdf-ast/edit/forms.d.ts +1 -0
- package/dist/pdf-ast/edit/retained-form-data.d.ts +9 -0
- package/dist/pdf-ast/index.d.ts +1 -0
- package/dist/pdf-ast/index.js +476 -55
- package/dist/safe-bash/command-chunks/{biff-KRHJ63K3-VQPJCVIL.js → biff-A7XPBWAK-DCLG5QKF.js} +1775 -1667
- package/dist/safe-bash/command-chunks/{chunk-AVGXFWEB.js → chunk-44F5TOHZ.js} +179 -58
- package/dist/safe-bash/command-chunks/{chunk-PIVH35EQ.js → chunk-6CDDKNNA.js} +1 -0
- package/dist/safe-bash/command-chunks/{chunk-K4XNUJVJ.js → chunk-6EINUY5G.js} +149 -165
- package/dist/safe-bash/command-chunks/{chunk-5BIQWWLB.js → chunk-CFMJXJS5.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3JM7E42I.js → chunk-GPGLTWNR.js} +106 -32
- package/dist/safe-bash/command-chunks/{chunk-2ETEJOYX.js → chunk-HQ2UN2L2.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-CK2WFJZN.js → chunk-KASXIRKD.js} +12 -14
- package/dist/safe-bash/command-chunks/chunk-KHUT7BB5.js +65 -0
- package/dist/safe-bash/command-chunks/{chunk-LAPOMHGY.js → chunk-NEYITAAO.js} +114 -97
- package/dist/safe-bash/command-chunks/{chunk-FF7UGJWS.js → chunk-QDVDBN2N.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-SW37YCBW.js → chunk-U3C6IT2C.js} +44 -30
- package/dist/safe-bash/command-chunks/{chunk-G3TAX3CV.js → chunk-WAT2562G.js} +610 -539
- package/dist/safe-bash/command-chunks/{chunk-VT7UBPAE.js → chunk-YW2VYN4V.js} +23 -11
- package/dist/safe-bash/command-chunks/{chunk-GQGMQMIM.js → chunk-ZIGENXGC.js} +243 -1
- package/dist/safe-bash/command-chunks/{command-engine-7V6PZR7G.js → command-engine-M7S4QIXV.js} +12 -4
- package/dist/safe-bash/command-chunks/{engine-UYJENSWK-VSCGKSQV.js → engine-YUYZJIB4-NZUDFEHL.js} +1 -1
- package/dist/safe-bash-command-ffmpeg/index.js +1 -1
- package/dist/safe-bash-command-ffprobe/index.js +2 -2
- package/dist/safe-bash-command-ffprobe/media.d.ts +8 -2
- package/dist/safe-bash-command-ffprobe/media.js +4 -2
- package/dist/safe-bash-command-pandoc/command.js +3 -3
- package/dist/safe-bash-command-pandoc/index.js +8 -8
- package/dist/safe-bash-command-patch/index.js +7 -6
- package/dist/safe-bash-command-patch/patch-formats.d.ts +6 -5
- package/dist/safe-bash-command-patch/patch-formats.js +3 -2
- package/dist/safe-bash-command-patch/patch-gnu-paths.d.ts +7 -7
- package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +1 -1
- package/dist/safe-bash-command-patch/patch-gnu-reject.js +3 -2
- package/dist/safe-bash-command-patch/patch-publication.js +3 -2
- package/dist/safe-bash-command-patch/patch-text.d.ts +13 -0
- package/dist/safe-bash-command-patch/patch.js +7 -6
- package/dist/safe-bash-command-patch/stored-patch.d.ts +29 -4
- package/dist/safe-bash-command-patch/stored-target.d.ts +2 -1
- package/dist/safe-bash-command-patch/unified.d.ts +18 -4
- package/dist/safe-bash-command-patch/unified.js +2 -1
- package/dist/safe-bash-command-pdftk/index.js +30 -20
- package/dist/safe-bash-command-pptx/engine.js +1 -1
- package/dist/safe-bash-command-ssconvert/index.js +2 -2
- package/dist/safe-bash-presentation-engine/index.js +1 -1
- package/dist/safe-bash-presentation-engine/notes.d.ts +1 -0
- package/dist/safe-bash-presentation-engine/notes.js +7 -1
- package/dist/safe-bash-presentation-engine/retained-notes.d.ts +27 -0
- package/dist/safe-bash-xml-engine/document.js +2 -2
- package/dist/safe-bash-xml-engine/index.js +2 -2
- package/dist/safe-bash-xml-engine/stored-document.js +1 -1
- package/dist/spreadsheet-format-xls/biff-properties-merge.js +40 -21
- package/dist/spreadsheet-format-xls/biff-property-values.d.ts +31 -0
- package/dist/spreadsheet-format-xls/biff-property-values.js +158 -0
- package/package.json +3 -2
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
g
|
|
3
3
|
} from "./chunk-Z7ESJVFP.js";
|
|
4
4
|
|
|
5
|
-
// packages/safe-bash-command-ssconvert/dist/chunks/chunk-
|
|
5
|
+
// packages/safe-bash-command-ssconvert/dist/chunks/chunk-HRRIWW7U.js
|
|
6
6
|
import { createEngine as vt } from "../../spreadsheet-engine/index.js";
|
|
7
7
|
import { SsconvertError as O } from "../../spreadsheet-engine/contracts.js";
|
|
8
8
|
import { decodeTextSource as ot } from "../../spreadsheet-engine/encoding/decode-source.js";
|
|
@@ -35,13 +35,13 @@ var te = { id: "Gnumeric_applix", services: [{ id: "applix", direction: "read",
|
|
|
35
35
|
var re = { id: "Gnumeric_dif", services: [{ id: "dif", direction: "read", read: async (e, t) => (await import("./dif-BXKPQOCO-4KB3RC6G.js")).readDif(e, t), description: "Data Interchange Format (*.dif)", extensions: ["dif"], probePriority: 1 }, { id: "dif", direction: "write", write: async (e, t, i) => (await import("./dif-BXKPQOCO-4KB3RC6G.js")).writeDif(e, t, i), description: "Data Interchange Format (*.dif)", extensions: ["dif"], formatLevel: "manual_remember", saveScope: "sheet", selectionSource: "view" }], source: "plugins/dif/plugin.xml.in" };
|
|
36
36
|
var Qe = ["xor", "rc4", ...[false, true].flatMap((e) => [40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128].map((t) => `rc4-cryptoapi-${t}${e ? "-properties" : ""}`))];
|
|
37
37
|
var ie = ["xor"];
|
|
38
|
-
var W = { id: "Gnumeric_Excel", source: "plugins/excel/plugin.xml.in", services: [{ id: "excel", direction: "read", readWorkbookSource: async (...e) => (await import("./biff-
|
|
39
|
-
yield* (await import("./biff-
|
|
40
|
-
}, labelRanges: true, exportOptionRules: { encryption: { kind: "enum", values: Qe } }, direction: "write", description: "MS Excel\u2122 97/2000/XP", extensions: ["xls"], mimeTypes: ["application/vnd.ms-excel"], formatLevel: "auto", defaultSaverPriority: 1 }, { id: "excel_biff7", write: async (...e) => (await import("./biff-
|
|
41
|
-
yield* (await import("./biff-
|
|
42
|
-
}, labelRanges: true, exportOptionRules: { encryption: { kind: "enum", values: ie } }, direction: "write", description: "MS Excel\u2122 5.0/95", extensions: ["xls"], mimeTypes: ["application/vnd.ms-excel"], formatLevel: "auto" }, { id: "excel_dsf", write: async (...e) => (await import("./biff-
|
|
43
|
-
yield* (await import("./biff-
|
|
44
|
-
}, labelRanges: true, exportOptionRules: { encryption: { kind: "enum", values: ie } }, direction: "write", description: "MS Excel\u2122 97/2000/XP & 5.0/95", extensions: ["xls"], mimeTypes: ["application/vnd.ms-excel"], formatLevel: "auto" }, { id: "excel_enc", direction: "read", read: async (...e) => (await import("./biff-
|
|
38
|
+
var W = { id: "Gnumeric_Excel", source: "plugins/excel/plugin.xml.in", services: [{ id: "excel", direction: "read", readWorkbookSource: async (...e) => (await import("./biff-A7XPBWAK-DCLG5QKF.js")).readBiffWorkbookSource(...e), readSource: async (...e) => (await import("./biff-A7XPBWAK-DCLG5QKF.js")).readBiff(...e), probeSource: async (...e) => (await import("./biff-A7XPBWAK-DCLG5QKF.js")).probeBiff(...e), read: async (...e) => (await import("./biff-A7XPBWAK-DCLG5QKF.js")).readBiff(...e), probeContent: async (...e) => (await import("./biff-A7XPBWAK-DCLG5QKF.js")).probeBiff(...e), description: "MS Excel\u2122 (*.xls)", extensions: ["xls", "xlw", "xlt"], mimeTypes: ["application/vnd.ms-excel", "application/excel", "application/msexcel", "application/x-excel", "application/x-ms-excel", "application/x-msexcel", "application/x-xls", "application/xls", "application/x-dos_ms_excel", "zz-application/zz-winassoc-xls"], probePriority: 100, contentProbe: true }, { id: "excel_biff8", write: async (...e) => (await import("./biff-A7XPBWAK-DCLG5QKF.js")).createBiffWriter(8)(...e), writeStream: async function* (...e) {
|
|
39
|
+
yield* (await import("./biff-A7XPBWAK-DCLG5QKF.js")).createBiffStreamWriter(8)(...e);
|
|
40
|
+
}, labelRanges: true, exportOptionRules: { encryption: { kind: "enum", values: Qe } }, direction: "write", description: "MS Excel\u2122 97/2000/XP", extensions: ["xls"], mimeTypes: ["application/vnd.ms-excel"], formatLevel: "auto", defaultSaverPriority: 1 }, { id: "excel_biff7", write: async (...e) => (await import("./biff-A7XPBWAK-DCLG5QKF.js")).createBiffWriter(7)(...e), writeStream: async function* (...e) {
|
|
41
|
+
yield* (await import("./biff-A7XPBWAK-DCLG5QKF.js")).createBiffStreamWriter(7)(...e);
|
|
42
|
+
}, labelRanges: true, exportOptionRules: { encryption: { kind: "enum", values: ie } }, direction: "write", description: "MS Excel\u2122 5.0/95", extensions: ["xls"], mimeTypes: ["application/vnd.ms-excel"], formatLevel: "auto" }, { id: "excel_dsf", write: async (...e) => (await import("./biff-A7XPBWAK-DCLG5QKF.js")).createBiffWriter("dsf")(...e), writeStream: async function* (...e) {
|
|
43
|
+
yield* (await import("./biff-A7XPBWAK-DCLG5QKF.js")).createBiffStreamWriter("dsf")(...e);
|
|
44
|
+
}, labelRanges: true, exportOptionRules: { encryption: { kind: "enum", values: ie } }, direction: "write", description: "MS Excel\u2122 97/2000/XP & 5.0/95", extensions: ["xls"], mimeTypes: ["application/vnd.ms-excel"], formatLevel: "auto" }, { id: "excel_enc", direction: "read", read: async (...e) => (await import("./biff-A7XPBWAK-DCLG5QKF.js")).readBiff(...e), description: "MS Excel\u2122 (*.xls) requiring encoding specification", extensions: [], probePriority: 200, encodingDependent: true }] };
|
|
45
45
|
var oe = { id: "Gnumeric_Excel", source: "plugins/excel/plugin.xml.in", services: [{ id: "xlsx", direction: "read", probeContent: async (e, t) => (await import("./xlsx-RE54MFCS-DI3F765V.js")).probeXlsx(e, t), probeSource: async (e, t) => (await import("./xlsx-RE54MFCS-DI3F765V.js")).probeXlsx(e, t), readWorkbookSource: async (e, t) => (await import("./xlsx-RE54MFCS-DI3F765V.js")).readXlsx(e, t, true), readSource: async (e, t) => (await import("./xlsx-RE54MFCS-DI3F765V.js")).readXlsx(e, t), read: async (e, t) => (await import("./xlsx-RE54MFCS-DI3F765V.js")).readXlsx(e, t), description: "ECMA 376 / Office Open XML [MS Excel\u2122 2007/2010] (*.xlsx)", extensions: ["xlsx", "xltx", "xlsb", "xlsm", "xltm"], mimeTypes: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"], probePriority: 100, contentProbe: true }, { id: "xlsx", direction: "write", sourceAxes: true, write: async (e, t, i) => (await import("./xlsx-RE54MFCS-DI3F765V.js")).createXlsxWriter("2006")(e, t, i), writeStream: async function* (e, t, i) {
|
|
46
46
|
yield* (await import("./xlsx-RE54MFCS-DI3F765V.js")).createXlsxStreamWriter("2006")(e, t, i);
|
|
47
47
|
}, writeWorkbookSource: async function* (e, t, i) {
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
patchTextBytes
|
|
3
|
+
} from "./chunk-KHUT7BB5.js";
|
|
4
|
+
|
|
1
5
|
// packages/safe-bash-command-patch/src/stored-target.ts
|
|
2
6
|
import { PagedStorage, PagedStorageCache } from "@poe-platform/safe-fs/storage";
|
|
3
7
|
import { IndexedDocument, closeDocumentResources } from "../../safe-bash-diff-engine/document.js";
|
|
4
8
|
import { ToolError, host } from "../../safe-bash-diff-engine/shared.js";
|
|
5
9
|
async function* targetBytes(line) {
|
|
6
|
-
if (typeof line
|
|
7
|
-
|
|
8
|
-
for (let offset = line.start; offset < line.end; offset += 16384)
|
|
9
|
-
yield await line.storage.read(offset, Math.min(16384, line.end - offset));
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const range = await line.document.line(line.index);
|
|
13
|
-
yield* line.document.range(range.start, range.end);
|
|
10
|
+
if (typeof line === "string" || "bytes" in line) {
|
|
11
|
+
yield* patchTextBytes(line);
|
|
14
12
|
return;
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
yield new TextEncoder().encode(line.slice(start, end));
|
|
21
|
-
start = end;
|
|
14
|
+
if ("storage" in line) {
|
|
15
|
+
for (let offset = line.start; offset < line.end; offset += 16384)
|
|
16
|
+
yield await line.storage.read(offset, Math.min(16384, line.end - offset));
|
|
17
|
+
return;
|
|
22
18
|
}
|
|
19
|
+
const range = await line.document.line(line.index);
|
|
20
|
+
yield* line.document.range(range.start, range.end);
|
|
23
21
|
}
|
|
24
22
|
async function* normalized(line, whitespace) {
|
|
25
23
|
if (!whitespace) {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// packages/safe-bash-command-patch/src/patch-text.ts
|
|
2
|
+
import { byteLength } from "../../safe-bash-io-engine/byte-encoding.js";
|
|
3
|
+
function textSize(text) {
|
|
4
|
+
return typeof text === "string" ? byteLength(text) : text.size;
|
|
5
|
+
}
|
|
6
|
+
function terminated(text) {
|
|
7
|
+
return typeof text === "string" ? text.endsWith("\n") : text.terminated;
|
|
8
|
+
}
|
|
9
|
+
async function* patchTextBytes(text) {
|
|
10
|
+
if (typeof text !== "string") {
|
|
11
|
+
yield* text.bytes;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
for (let start = 0; start < text.length; ) {
|
|
15
|
+
let end = Math.min(start + 4096, text.length);
|
|
16
|
+
const last = text.charCodeAt(end - 1);
|
|
17
|
+
if (end < text.length && last >= 55296 && last <= 56319) end--;
|
|
18
|
+
yield new TextEncoder().encode(text.slice(start, end));
|
|
19
|
+
start = end;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function materializeText(text) {
|
|
23
|
+
if (typeof text === "string") return text;
|
|
24
|
+
const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
25
|
+
let result = "";
|
|
26
|
+
for await (const bytes of text.bytes) result += decoder.decode(bytes, { stream: true });
|
|
27
|
+
return result + decoder.decode();
|
|
28
|
+
}
|
|
29
|
+
async function equalPatchText(left, right, budget) {
|
|
30
|
+
if (typeof left === "string" && typeof right === "string") return budget.equal(left, right);
|
|
31
|
+
if (textSize(left) !== textSize(right)) return false;
|
|
32
|
+
const a = patchTextBytes(left)[Symbol.asyncIterator](), b = patchTextBytes(right)[Symbol.asyncIterator]();
|
|
33
|
+
try {
|
|
34
|
+
let x = await a.next(), y = await b.next(), i = 0, j = 0;
|
|
35
|
+
while (!x.done && !y.done) {
|
|
36
|
+
const count = Math.min(x.value.length - i, y.value.length - j);
|
|
37
|
+
budget.step(count);
|
|
38
|
+
for (let at = 0; at < count; at++) if (x.value[i + at] !== y.value[j + at]) return false;
|
|
39
|
+
i += count;
|
|
40
|
+
j += count;
|
|
41
|
+
if (i === x.value.length) {
|
|
42
|
+
x = await a.next();
|
|
43
|
+
i = 0;
|
|
44
|
+
}
|
|
45
|
+
if (j === y.value.length) {
|
|
46
|
+
y = await b.next();
|
|
47
|
+
j = 0;
|
|
48
|
+
}
|
|
49
|
+
const pause = budget.checkpoint();
|
|
50
|
+
if (pause) await pause;
|
|
51
|
+
}
|
|
52
|
+
return !!x.done && !!y.done;
|
|
53
|
+
} finally {
|
|
54
|
+
await a.return?.();
|
|
55
|
+
await b.return?.();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
textSize,
|
|
61
|
+
terminated,
|
|
62
|
+
patchTextBytes,
|
|
63
|
+
materializeText,
|
|
64
|
+
equalPatchText
|
|
65
|
+
};
|
|
@@ -332830,6 +332830,49 @@ function* decodeH264Samples(samples, descriptions, width, height, timescale) {
|
|
|
332830
332830
|
if (decoded !== samples.length) throw new Error("H.264 stream did not decode every picture");
|
|
332831
332831
|
}
|
|
332832
332832
|
|
|
332833
|
+
// packages/mp4-ast/src/mp4-box-layout.ts
|
|
332834
|
+
var containers = /* @__PURE__ */ new Set([
|
|
332835
|
+
"moov",
|
|
332836
|
+
"trak",
|
|
332837
|
+
"edts",
|
|
332838
|
+
"mdia",
|
|
332839
|
+
"minf",
|
|
332840
|
+
"dinf",
|
|
332841
|
+
"stbl",
|
|
332842
|
+
"mvex",
|
|
332843
|
+
"moof",
|
|
332844
|
+
"traf",
|
|
332845
|
+
"mfra",
|
|
332846
|
+
"udta",
|
|
332847
|
+
"ilst",
|
|
332848
|
+
"sinf",
|
|
332849
|
+
"schi",
|
|
332850
|
+
"tref",
|
|
332851
|
+
"gmhd"
|
|
332852
|
+
]);
|
|
332853
|
+
function mp4BoxLayout(prefix, remaining) {
|
|
332854
|
+
if (prefix.length < 8) return void 0;
|
|
332855
|
+
const view = new DataView(prefix.buffer, prefix.byteOffset, prefix.length);
|
|
332856
|
+
let size = view.getUint32(0), headerSize = 8;
|
|
332857
|
+
const type = decodeFourCC(prefix, 4);
|
|
332858
|
+
if (size === 1) {
|
|
332859
|
+
if (prefix.length < 16) return void 0;
|
|
332860
|
+
size = view.getUint32(8) * 4294967296 + view.getUint32(12);
|
|
332861
|
+
headerSize = 16;
|
|
332862
|
+
} else if (size === 0) size = remaining;
|
|
332863
|
+
if (size < headerSize || size > remaining) {
|
|
332864
|
+
size = remaining;
|
|
332865
|
+
if (size < headerSize) return void 0;
|
|
332866
|
+
}
|
|
332867
|
+
if (type === "uuid" && headerSize + 16 <= size) return { type, size, headerSize: headerSize + 16, uuidOffset: headerSize };
|
|
332868
|
+
return { type, size, headerSize };
|
|
332869
|
+
}
|
|
332870
|
+
function mp4BoxChildrenOffset(type, payloadSize, metaChildType) {
|
|
332871
|
+
if (containers.has(type)) return 0;
|
|
332872
|
+
if (type !== "meta" || payloadSize < 12) return void 0;
|
|
332873
|
+
return metaChildType === "hdlr" || metaChildType === "ilst" || metaChildType === "keys" || metaChildType === "free" ? 4 : 0;
|
|
332874
|
+
}
|
|
332875
|
+
|
|
332833
332876
|
// packages/mp4-ast/src/mp4-sample-source.ts
|
|
332834
332877
|
function* mp4SampleTableSteps(size, tables, options = {}) {
|
|
332835
332878
|
function* read(table, offset, length) {
|
|
@@ -332907,47 +332950,53 @@ function* mp4SampleTableSteps(size, tables, options = {}) {
|
|
|
332907
332950
|
}
|
|
332908
332951
|
}
|
|
332909
332952
|
|
|
332910
|
-
// packages/mp4-ast/src/mp4-
|
|
332911
|
-
|
|
332912
|
-
|
|
332913
|
-
|
|
332914
|
-
|
|
332915
|
-
|
|
332916
|
-
|
|
332917
|
-
|
|
332918
|
-
|
|
332919
|
-
|
|
332920
|
-
|
|
332921
|
-
|
|
332922
|
-
|
|
332923
|
-
|
|
332924
|
-
"ilst",
|
|
332925
|
-
"sinf",
|
|
332926
|
-
"schi",
|
|
332927
|
-
"tref",
|
|
332928
|
-
"gmhd"
|
|
332929
|
-
]);
|
|
332930
|
-
function mp4BoxLayout(prefix, remaining) {
|
|
332931
|
-
if (prefix.length < 8) return void 0;
|
|
332932
|
-
const view = new DataView(prefix.buffer, prefix.byteOffset, prefix.length);
|
|
332933
|
-
let size = view.getUint32(0), headerSize = 8;
|
|
332934
|
-
const type = decodeFourCC(prefix, 4);
|
|
332935
|
-
if (size === 1) {
|
|
332936
|
-
if (prefix.length < 16) return void 0;
|
|
332937
|
-
size = view.getUint32(8) * 4294967296 + view.getUint32(12);
|
|
332938
|
-
headerSize = 16;
|
|
332939
|
-
} else if (size === 0) size = remaining;
|
|
332940
|
-
if (size < headerSize || size > remaining) {
|
|
332941
|
-
size = remaining;
|
|
332942
|
-
if (size < headerSize) return void 0;
|
|
332943
|
-
}
|
|
332944
|
-
if (type === "uuid" && headerSize + 16 <= size) return { type, size, headerSize: headerSize + 16, uuidOffset: headerSize };
|
|
332945
|
-
return { type, size, headerSize };
|
|
332953
|
+
// packages/mp4-ast/src/mp4-fragment-source.ts
|
|
332954
|
+
function mp4FragmentHeader(bytes, options) {
|
|
332955
|
+
if (bytes.length < 8) return;
|
|
332956
|
+
const reader = new BinaryReader(bytes);
|
|
332957
|
+
reader.readU8();
|
|
332958
|
+
const flags = reader.readU24BE(), trackId = reader.readU32BE();
|
|
332959
|
+
if (trackId !== options.trackId) return;
|
|
332960
|
+
return {
|
|
332961
|
+
baseDataOffset: flags & 1 ? reader.readU64BE() : options.moofOffset,
|
|
332962
|
+
defaultSampleDescriptionIndex: flags & 2 ? reader.readU32BE() : options.defaults.defaultSampleDescriptionIndex,
|
|
332963
|
+
defaultSampleDuration: flags & 8 ? reader.readU32BE() : options.defaults.defaultSampleDuration,
|
|
332964
|
+
defaultSampleSize: flags & 16 ? reader.readU32BE() : options.defaults.defaultSampleSize,
|
|
332965
|
+
defaultSampleFlags: flags & 32 ? reader.readU32BE() : options.defaults.defaultSampleFlags
|
|
332966
|
+
};
|
|
332946
332967
|
}
|
|
332947
|
-
function
|
|
332948
|
-
if (
|
|
332949
|
-
|
|
332950
|
-
|
|
332968
|
+
function mp4FragmentTime(bytes, fallback) {
|
|
332969
|
+
if (bytes.length < 8) return fallback;
|
|
332970
|
+
const reader = new BinaryReader(bytes), version = reader.readU8();
|
|
332971
|
+
reader.skip(3);
|
|
332972
|
+
return version === 1 ? reader.readU64BE() : reader.readU32BE();
|
|
332973
|
+
}
|
|
332974
|
+
function* mp4FragmentRunSteps(size, table, header, state, options) {
|
|
332975
|
+
if (table.payloadSize < 8) return state;
|
|
332976
|
+
function* read(offset, length) {
|
|
332977
|
+
if (offset >= table.payloadSize || !length) return new BinaryReader(new Uint8Array());
|
|
332978
|
+
return new BinaryReader(yield { kind: "read", table, offset: table.payloadOffset + offset, length: Math.min(length, table.payloadSize - offset) });
|
|
332979
|
+
}
|
|
332980
|
+
const reader = yield* read(0, 16), version = reader.readU8(), flags = reader.readU24BE(), count = reader.readU32BE();
|
|
332981
|
+
options.budget?.checkSamples(state.sampleCount + count);
|
|
332982
|
+
let cursor = header.baseDataOffset + (flags & 1 ? reader.readI32BE() : 0);
|
|
332983
|
+
const firstFlags = flags & 4 ? reader.readU32BE() : void 0, start = reader.offset;
|
|
332984
|
+
const width = [256, 512, 1024, 2048].reduce((n, bit) => n + (flags & bit ? 4 : 0), 0);
|
|
332985
|
+
let dts = state.dts;
|
|
332986
|
+
for (let i = 0; i < count; i++) {
|
|
332987
|
+
options.budget?.checkCpu();
|
|
332988
|
+
const row = yield* read(start + i * width, width);
|
|
332989
|
+
const duration = flags & 256 ? row.readU32BE() : header.defaultSampleDuration;
|
|
332990
|
+
const declaredSize = flags & 512 ? row.readU32BE() : header.defaultSampleSize;
|
|
332991
|
+
const sampleFlags = flags & 1024 ? row.readU32BE() : i === 0 && firstFlags !== void 0 ? firstFlags : header.defaultSampleFlags;
|
|
332992
|
+
const cts = flags & 2048 ? version === 1 ? row.readI32BE() : row.readU32BE() : 0;
|
|
332993
|
+
const offset = Math.max(0, Math.min(size, cursor));
|
|
332994
|
+
const isKeyframe = (sampleFlags >>> 24 & 3) === 2 || !(sampleFlags & 65536) && (i === 0 || options.type !== "video");
|
|
332995
|
+
yield { kind: "sample", sample: { offset, size: Math.max(0, Math.min(size - offset, declaredSize)), dts, pts: dts + cts, cts, duration, isKeyframe, sampleDescriptionIndex: header.defaultSampleDescriptionIndex } };
|
|
332996
|
+
dts += duration;
|
|
332997
|
+
cursor += declaredSize;
|
|
332998
|
+
}
|
|
332999
|
+
return { dts, sampleCount: state.sampleCount + count };
|
|
332951
333000
|
}
|
|
332952
333001
|
|
|
332953
333002
|
// packages/mp4-ast/src/work.ts
|
|
@@ -333461,64 +333510,32 @@ function parseMp4(bytes, options = {}) {
|
|
|
333461
333510
|
for (const traf of trafBoxes) {
|
|
333462
333511
|
const tfhd = findBox(traf.children, "tfhd");
|
|
333463
333512
|
if (!tfhd || tfhd.payload.byteLength < 8) continue;
|
|
333464
|
-
const
|
|
333465
|
-
|
|
333466
|
-
|
|
333467
|
-
const trafTrackId = tfhdReader.readU32BE();
|
|
333468
|
-
if (trafTrackId !== trackId) continue;
|
|
333469
|
-
let baseDataOffset = moof.offset;
|
|
333470
|
-
let defaultSampleDescriptionIndex = trex.defaultSampleDescriptionIndex;
|
|
333471
|
-
let defaultSampleDuration = trex.defaultSampleDuration;
|
|
333472
|
-
let defaultSampleSize = trex.defaultSampleSize;
|
|
333473
|
-
let defaultSampleFlags = trex.defaultSampleFlags;
|
|
333474
|
-
if (tfhdFlags & 1) baseDataOffset = tfhdReader.readU64BE();
|
|
333475
|
-
if (tfhdFlags & 2) defaultSampleDescriptionIndex = tfhdReader.readU32BE();
|
|
333476
|
-
if (tfhdFlags & 8) defaultSampleDuration = tfhdReader.readU32BE();
|
|
333477
|
-
if (tfhdFlags & 16) defaultSampleSize = tfhdReader.readU32BE();
|
|
333478
|
-
if (tfhdFlags & 32) defaultSampleFlags = tfhdReader.readU32BE();
|
|
333513
|
+
const fragmentOptions = { trackId, moofOffset: moof.offset, defaults: trex, type, budget };
|
|
333514
|
+
const header = mp4FragmentHeader(tfhd.payload, fragmentOptions);
|
|
333515
|
+
if (!header) continue;
|
|
333479
333516
|
const tfdt = findBox(traf.children, "tfdt");
|
|
333480
|
-
if (tfdt
|
|
333481
|
-
|
|
333482
|
-
const
|
|
333483
|
-
|
|
333484
|
-
|
|
333485
|
-
|
|
333486
|
-
|
|
333487
|
-
|
|
333488
|
-
|
|
333489
|
-
|
|
333490
|
-
|
|
333491
|
-
|
|
333492
|
-
|
|
333493
|
-
|
|
333494
|
-
|
|
333495
|
-
|
|
333496
|
-
|
|
333497
|
-
|
|
333498
|
-
|
|
333499
|
-
|
|
333500
|
-
|
|
333501
|
-
|
|
333502
|
-
const size = trunFlags & 512 ? trunReader.readU32BE() : defaultSampleSize;
|
|
333503
|
-
const flags = trunFlags & 1024 ? trunReader.readU32BE() : s === 0 && firstSampleFlags !== void 0 ? firstSampleFlags : defaultSampleFlags;
|
|
333504
|
-
const cts = trunFlags & 2048 ? trunVersion === 1 ? trunReader.readI32BE() : trunReader.readU32BE() : 0;
|
|
333505
|
-
const isNonSync = (flags & 65536) !== 0;
|
|
333506
|
-
const sampleDependsOn = flags >>> 24 & 3;
|
|
333507
|
-
const isKeyframe = sampleDependsOn === 2 || !isNonSync && (s === 0 || type !== "video");
|
|
333508
|
-
const safeStart = Math.max(0, Math.min(bytes.byteLength, cursor));
|
|
333509
|
-
const safeEnd = Math.max(safeStart, Math.min(bytes.byteLength, safeStart + size));
|
|
333510
|
-
samples.push({
|
|
333511
|
-
data: bytes.subarray(safeStart, safeEnd),
|
|
333512
|
-
dts: runningDts,
|
|
333513
|
-
pts: runningDts + cts,
|
|
333514
|
-
cts,
|
|
333515
|
-
duration,
|
|
333516
|
-
size: safeEnd - safeStart,
|
|
333517
|
-
isKeyframe,
|
|
333518
|
-
sampleDescriptionIndex: defaultSampleDescriptionIndex
|
|
333519
|
-
});
|
|
333520
|
-
runningDts += duration;
|
|
333521
|
-
cursor += size;
|
|
333517
|
+
if (tfdt) runningDts = mp4FragmentTime(tfdt.payload, runningDts);
|
|
333518
|
+
for (const trun of findBoxes(traf.children, "trun")) {
|
|
333519
|
+
const steps2 = mp4FragmentRunSteps(
|
|
333520
|
+
bytes.byteLength,
|
|
333521
|
+
{ payloadOffset: trun.offset + trun.headerSize, payloadSize: trun.payload.byteLength },
|
|
333522
|
+
header,
|
|
333523
|
+
{ dts: runningDts, sampleCount: samples.length },
|
|
333524
|
+
fragmentOptions
|
|
333525
|
+
);
|
|
333526
|
+
let answer2;
|
|
333527
|
+
for (; ; ) {
|
|
333528
|
+
const next = steps2.next(answer2);
|
|
333529
|
+
if (next.done) {
|
|
333530
|
+
runningDts = next.value.dts;
|
|
333531
|
+
break;
|
|
333532
|
+
}
|
|
333533
|
+
const step = next.value;
|
|
333534
|
+
if (step.kind === "read") answer2 = bytes.subarray(step.offset, step.offset + step.length);
|
|
333535
|
+
else if (step.kind === "sample") {
|
|
333536
|
+
const { offset, ...sample } = step.sample;
|
|
333537
|
+
samples.push({ ...sample, data: bytes.subarray(offset, offset + sample.size) });
|
|
333538
|
+
}
|
|
333522
333539
|
}
|
|
333523
333540
|
}
|
|
333524
333541
|
}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseUnified,
|
|
3
3
|
parseUnifiedSection
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YW2VYN4V.js";
|
|
5
|
+
import {
|
|
6
|
+
equalPatchText,
|
|
7
|
+
materializeText,
|
|
8
|
+
terminated,
|
|
9
|
+
textSize
|
|
10
|
+
} from "./chunk-KHUT7BB5.js";
|
|
5
11
|
import {
|
|
6
12
|
decodeHeaderPath
|
|
7
13
|
} from "./chunk-AJEQUVDN.js";
|
|
8
14
|
|
|
9
15
|
// packages/safe-bash-command-patch/src/patch-formats.ts
|
|
10
16
|
import { ToolError, integer } from "../../safe-bash-diff-engine/shared.js";
|
|
11
|
-
import { byteLength } from "../../safe-bash-io-engine/byte-encoding.js";
|
|
12
17
|
var Reader = class {
|
|
13
18
|
constructor(input, budget, admit = true) {
|
|
14
19
|
this.budget = budget;
|
|
@@ -25,16 +30,19 @@ var Reader = class {
|
|
|
25
30
|
budget;
|
|
26
31
|
input;
|
|
27
32
|
index = 0;
|
|
28
|
-
peek() {
|
|
29
|
-
return this.input.read(this.index);
|
|
33
|
+
peek(prefix) {
|
|
34
|
+
return this.input.read(this.index, prefix);
|
|
35
|
+
}
|
|
36
|
+
async matches(text) {
|
|
37
|
+
return this.input.matches ? this.input.matches(this.index, text) : await this.peek() === text;
|
|
30
38
|
}
|
|
31
|
-
async take() {
|
|
39
|
+
async take(prefix) {
|
|
32
40
|
this.budget.step();
|
|
33
41
|
{
|
|
34
42
|
const c = this.budget.checkpoint();
|
|
35
43
|
if (c) await c;
|
|
36
44
|
}
|
|
37
|
-
const line = await this.input.read(this.index
|
|
45
|
+
const line = await this.input.read(this.index++, prefix);
|
|
38
46
|
if (line === void 0) throw new ToolError("truncated patch");
|
|
39
47
|
return line;
|
|
40
48
|
}
|
|
@@ -44,20 +52,22 @@ var Reader = class {
|
|
|
44
52
|
return result;
|
|
45
53
|
}
|
|
46
54
|
async content(prefix) {
|
|
47
|
-
const
|
|
55
|
+
const position = this.index;
|
|
56
|
+
const line = await this.take(this.input.body ? 2 : void 0);
|
|
48
57
|
if (line !== prefix && !(prefix === " " && line === "") && !line.startsWith(`${prefix} `) && !line.startsWith(`${prefix} `)) throw new ToolError("malformed patch body prefix");
|
|
49
|
-
|
|
50
|
-
`;
|
|
51
|
-
if (
|
|
58
|
+
const incomplete = await this.matches("\");
|
|
59
|
+
const text = this.input.body ? await this.input.body(position, 2, incomplete) : `${line.slice(2)}${incomplete ? "" : "\n"}`;
|
|
60
|
+
if (incomplete) {
|
|
52
61
|
await this.take();
|
|
53
|
-
if (text ===
|
|
54
|
-
text = text.slice(0, -1);
|
|
62
|
+
if (textSize(text) === 0) throw new ToolError("empty incomplete line is not a valid text line");
|
|
55
63
|
}
|
|
56
64
|
return text;
|
|
57
65
|
}
|
|
58
66
|
};
|
|
59
|
-
function encoded(line) {
|
|
60
|
-
|
|
67
|
+
function* encoded(line) {
|
|
68
|
+
yield line.kind;
|
|
69
|
+
yield line.text;
|
|
70
|
+
if (!terminated(line.text)) yield "\n\\n";
|
|
61
71
|
}
|
|
62
72
|
async function* normal(reader, target) {
|
|
63
73
|
const quoted = JSON.stringify(target ?? "/dev/null");
|
|
@@ -82,9 +92,9 @@ async function* normal(reader, target) {
|
|
|
82
92
|
const newCount = operation === "d" ? 0 : newLast - newStart + 1;
|
|
83
93
|
yield `@@ -${oldStart},${oldCount} +${newStart},${newCount} @@
|
|
84
94
|
`;
|
|
85
|
-
for (let index = 0; index < oldCount; index++) yield encoded({ kind: "-", text: await reader.content("<") });
|
|
95
|
+
for (let index = 0; index < oldCount; index++) yield* encoded({ kind: "-", text: await reader.content("<") });
|
|
86
96
|
if (operation === "c" && await reader.take() !== "---") throw new ToolError("missing normal change separator");
|
|
87
|
-
for (let index = 0; index < newCount; index++) yield encoded({ kind: "+", text: await reader.content(">") });
|
|
97
|
+
for (let index = 0; index < newCount; index++) yield* encoded({ kind: "+", text: await reader.content(">") });
|
|
88
98
|
}
|
|
89
99
|
}
|
|
90
100
|
async function contextRange(reader, old) {
|
|
@@ -100,19 +110,19 @@ async function contextSide(reader, old, range) {
|
|
|
100
110
|
const start = reader.index;
|
|
101
111
|
let length = 0, common = 0, changed = false, incomplete = false;
|
|
102
112
|
const count = range.start === 0 ? 0 : range.last - range.start + 1;
|
|
103
|
-
while (await reader.peek() !== void 0 && length < count) {
|
|
104
|
-
const kind = await reader.peek() === "" ? " " : (await reader.peek())[0];
|
|
113
|
+
while (await reader.peek(2) !== void 0 && length < count) {
|
|
114
|
+
const kind = await reader.peek(2) === "" ? " " : (await reader.peek(2))[0];
|
|
105
115
|
if (kind !== " " && kind !== "!" && kind !== (old ? "-" : "+")) break;
|
|
106
|
-
if (old && /^--- \d+(?:,\d+)? ----$/u.test(await reader.peek())) break;
|
|
116
|
+
if (old && (await reader.peek(2))?.startsWith("--") && /^--- \d+(?:,\d+)? ----$/u.test(await reader.peek())) break;
|
|
107
117
|
const text = await reader.content(kind);
|
|
108
|
-
incomplete = !text
|
|
118
|
+
incomplete = !terminated(text);
|
|
109
119
|
length++;
|
|
110
120
|
if (kind === " ") common++;
|
|
111
121
|
changed ||= kind === "!";
|
|
112
122
|
if (length > reader.budget.limits.maxLines) throw new ToolError("context body line limit exceeded");
|
|
113
123
|
}
|
|
114
124
|
if (!old && length === count && incomplete) {
|
|
115
|
-
while (await reader.
|
|
125
|
+
while (await reader.matches("\")) await reader.take();
|
|
116
126
|
}
|
|
117
127
|
return { start, records: length, length, common, changed };
|
|
118
128
|
}
|
|
@@ -120,7 +130,7 @@ async function* contextLines(reader, side) {
|
|
|
120
130
|
const replay = new Reader(reader.input, reader.budget, false);
|
|
121
131
|
replay.index = side.start;
|
|
122
132
|
for (let index = 0; index < side.records; index++) {
|
|
123
|
-
const prefix = await replay.peek();
|
|
133
|
+
const prefix = await replay.peek(1);
|
|
124
134
|
const kind = prefix === "" ? " " : prefix[0];
|
|
125
135
|
const text = await replay.content(kind);
|
|
126
136
|
if (!side.commonOnly || kind === " ") yield { kind, text };
|
|
@@ -177,7 +187,7 @@ async function* context(reader) {
|
|
|
177
187
|
let oldChanged = false, newChanged = false;
|
|
178
188
|
while (!oldLine.done && oldLine.value.kind !== " ") {
|
|
179
189
|
oldChanged ||= oldLine.value.kind === "!";
|
|
180
|
-
yield encoded({ kind: "-", text: oldLine.value.text });
|
|
190
|
+
yield* encoded({ kind: "-", text: oldLine.value.text });
|
|
181
191
|
reader.budget.step();
|
|
182
192
|
{
|
|
183
193
|
const c = reader.budget.checkpoint();
|
|
@@ -187,7 +197,7 @@ async function* context(reader) {
|
|
|
187
197
|
}
|
|
188
198
|
while (!newLine.done && newLine.value.kind !== " ") {
|
|
189
199
|
newChanged ||= newLine.value.kind === "!";
|
|
190
|
-
yield encoded({ kind: "+", text: newLine.value.text });
|
|
200
|
+
yield* encoded({ kind: "+", text: newLine.value.text });
|
|
191
201
|
reader.budget.step();
|
|
192
202
|
{
|
|
193
203
|
const c = reader.budget.checkpoint();
|
|
@@ -197,8 +207,8 @@ async function* context(reader) {
|
|
|
197
207
|
}
|
|
198
208
|
if (oldChanged !== newChanged) throw new ToolError("unpaired changed context group");
|
|
199
209
|
if (!oldLine.done || !newLine.done) {
|
|
200
|
-
if (oldLine.done || newLine.done || !
|
|
201
|
-
yield encoded({ kind: " ", text: oldLine.value.text });
|
|
210
|
+
if (oldLine.done || newLine.done || !await equalPatchText(oldLine.value.text, newLine.value.text, reader.budget)) throw new ToolError("context halves disagree");
|
|
211
|
+
yield* encoded({ kind: " ", text: oldLine.value.text });
|
|
202
212
|
oldLine = await oldIterator.next();
|
|
203
213
|
newLine = await newIterator.next();
|
|
204
214
|
}
|
|
@@ -215,11 +225,15 @@ async function* context(reader) {
|
|
|
215
225
|
async function parsePatch(text, budget, format, target, progress, convert) {
|
|
216
226
|
return parsePatchWith(text, budget, format, target, {
|
|
217
227
|
unified: (cursor) => parseUnifiedSection(cursor, budget),
|
|
218
|
-
converted:
|
|
228
|
+
converted: async (source) => {
|
|
229
|
+
const strings = { async *[Symbol.asyncIterator]() {
|
|
230
|
+
for await (const chunk of source) yield await materializeText(chunk);
|
|
231
|
+
} };
|
|
232
|
+
if (convert) return convert(strings);
|
|
219
233
|
const chunks = [];
|
|
220
|
-
for await (const chunk of
|
|
234
|
+
for await (const chunk of strings) chunks.push(chunk);
|
|
221
235
|
return parseUnified(chunks.join(""), budget);
|
|
222
|
-
}
|
|
236
|
+
}
|
|
223
237
|
}, progress);
|
|
224
238
|
}
|
|
225
239
|
async function parsePatchWith(text, budget, format, target, parsers, progress) {
|
|
@@ -258,7 +272,7 @@ async function parsePatchWith(text, budget, format, target, parsers, progress) {
|
|
|
258
272
|
const source = detected === "normal" ? normal(reader, target ?? indexPath) : context(reader);
|
|
259
273
|
const converted = { async *[Symbol.asyncIterator]() {
|
|
260
274
|
for await (const chunk of source) {
|
|
261
|
-
convertedBytes +=
|
|
275
|
+
convertedBytes += textSize(chunk);
|
|
262
276
|
yield chunk;
|
|
263
277
|
}
|
|
264
278
|
if (convertedBytes > budget.limits.maxInputBytes * 2 + 16384) throw new ToolError("converted patch byte limit exceeded");
|