@poe-platform/safe-bash 0.1.809 → 0.1.810

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.
Files changed (109) hide show
  1. package/dist/audio-ast/index.d.ts +1 -1
  2. package/dist/audio-ast/index.js +6 -0
  3. package/dist/audio-ast/wav-source.d.ts +7 -1
  4. package/dist/image-ast/index.js +1 -1
  5. package/dist/pdf-ast/cos/mutable-object-store.d.ts +3 -0
  6. package/dist/pdf-ast/cos/qpdf-json-document.d.ts +42 -0
  7. package/dist/pdf-ast/cos/qpdf-json-values.d.ts +7 -0
  8. package/dist/pdf-ast/index.d.ts +1 -0
  9. package/dist/pdf-ast/index.js +508 -37
  10. package/dist/pdf-ast/retained-document.d.ts +3 -1
  11. package/dist/safe-bash/chunks/{chunk-RQCK77SC.js → chunk-65TFMAZU.js} +2 -2
  12. package/dist/safe-bash/chunks/{chunk-SOFBGDXG.js → chunk-HHSOUC3Z.js} +32 -0
  13. package/dist/safe-bash/chunks/{chunk-WAZEELYB.js → chunk-ZA5FQ34E.js} +10 -5
  14. package/dist/safe-bash/command-chunks/biff-ORSHM4YX-QYPGRDAZ.js +4937 -0
  15. package/dist/safe-bash/command-chunks/{chunk-62ZAHKFS.js → chunk-2VCKUNDZ.js} +130 -14
  16. package/dist/safe-bash/command-chunks/{chunk-GLVD3JJG.js → chunk-BYZUOF6X.js} +2858 -2816
  17. package/dist/safe-bash/command-chunks/{chunk-6OKH4X67.js → chunk-CAXJ4RLF.js} +264 -1
  18. package/dist/safe-bash/command-chunks/{chunk-YJJBGN7U.js → chunk-CHR2OD2U.js} +9 -9
  19. package/dist/safe-bash/command-chunks/{chunk-D7XBUF76.js → chunk-D2ASPM7R.js} +109 -23
  20. package/dist/safe-bash/command-chunks/chunk-D5AYP2UM.js +816 -0
  21. package/dist/safe-bash/command-chunks/{chunk-WFDG3N5R.js → chunk-ECDEPKKW.js} +1 -1
  22. package/dist/safe-bash/command-chunks/{chunk-OQCJGUI6.js → chunk-HARUYHH7.js} +10 -10
  23. package/dist/safe-bash/command-chunks/{chunk-NVBUC644.js → chunk-HKGNBH7Z.js} +2 -2
  24. package/dist/safe-bash/command-chunks/chunk-MGBHGZEX.js +12 -0
  25. package/dist/safe-bash/command-chunks/{chunk-4557HE3J.js → chunk-PMWW7KSB.js} +161 -42
  26. package/dist/safe-bash/command-chunks/{chunk-JW3KIZU6.js → chunk-RUXY7GN5.js} +1 -1
  27. package/dist/safe-bash/command-chunks/{chunk-KELMIFVV.js → chunk-TI52LKLL.js} +1 -1
  28. package/dist/safe-bash/command-chunks/{chunk-JJQ72P3V.js → chunk-VCML4T5D.js} +1 -1
  29. package/dist/safe-bash/command-chunks/{chunk-5HGEXQVD.js → chunk-WC2OCF4H.js} +1 -1
  30. package/dist/safe-bash/command-chunks/chunk-WH3TIOTS.js +326 -0
  31. package/dist/safe-bash/command-chunks/{chunk-45FI2IPY.js → chunk-WQ6ABTJU.js} +3 -6
  32. package/dist/safe-bash/command-chunks/{chunk-NB7JO7FE.js → chunk-YTFWPJ3F.js} +1 -1
  33. package/dist/safe-bash/command-chunks/{chunk-GKYCV6BU.js → chunk-ZEPDT6I5.js} +482 -168
  34. package/dist/safe-bash/command-chunks/{command-engine-P5DFM4OU.js → command-engine-BEWABZ75.js} +10 -3
  35. package/dist/safe-bash/command-chunks/{engine-RU4OFLPO-CPLFYD67.js → engine-MEPOXIXT-WZMRHACG.js} +1 -1
  36. package/dist/safe-bash/command-chunks/pdf-LOZAXXS6-ERI57IAV.js +557 -0
  37. package/dist/safe-bash/commands/audio/index.browser.js +2 -14
  38. package/dist/safe-bash/commands/diff-patch/index.js +0 -2
  39. package/dist/safe-bash/commands/ffprobe/index.browser.js +2 -5
  40. package/dist/safe-bash/commands/pandoc/index.browser.js +3 -1
  41. package/dist/safe-bash/commands/text.js +10 -1
  42. package/dist/safe-bash/core.d.ts +2 -2
  43. package/dist/safe-bash/core.js +2 -2
  44. package/dist/safe-bash/full-core.browser.js +18 -22
  45. package/dist/safe-bash/lazy-optional.d.ts +9 -0
  46. package/dist/safe-bash/lazy-optional.js +24 -0
  47. package/dist/safe-bash/plugins/index.browser.js +5 -3
  48. package/dist/safe-bash/registry-entry.browser.js +1 -1
  49. package/dist/safe-bash-command-apply-patch/apply.js +2 -2
  50. package/dist/safe-bash-command-apply-patch/index.js +2 -2
  51. package/dist/safe-bash-command-apply-patch/parser.d.ts +20 -1
  52. package/dist/safe-bash-command-apply-patch/parser.js +1 -1
  53. package/dist/safe-bash-command-ffprobe/index.js +2 -1
  54. package/dist/safe-bash-command-ffprobe/media.js +2 -1
  55. package/dist/safe-bash-command-ffprobe/options.d.ts +15 -0
  56. package/dist/safe-bash-command-ffprobe/options.js +7 -0
  57. package/dist/safe-bash-command-media/index.js +2 -2
  58. package/dist/safe-bash-command-media/plugin.js +1 -1
  59. package/dist/safe-bash-command-media/remote.js +2 -2
  60. package/dist/safe-bash-command-pandoc/command.js +6 -6
  61. package/dist/safe-bash-command-pandoc/index.js +31 -31
  62. package/dist/safe-bash-command-patch/index.js +2 -2
  63. package/dist/safe-bash-command-patch/patch-publication.d.ts +2 -2
  64. package/dist/safe-bash-command-patch/patch-publication.js +1 -1
  65. package/dist/safe-bash-command-patch/patch.js +2 -2
  66. package/dist/safe-bash-command-pptx/engine.js +1 -1
  67. package/dist/safe-bash-command-ssconvert/index.js +2 -2
  68. package/dist/safe-bash-command-xmllint/index.js +137 -30
  69. package/dist/safe-bash-compression-engine/bounded-codec.js +2 -2
  70. package/dist/safe-bash-compression-engine/codec-loader.js +1 -1
  71. package/dist/safe-bash-compression-engine/files.js +5 -5
  72. package/dist/safe-bash-compression-engine/index.js +4 -4
  73. package/dist/safe-bash-compression-engine/operand.js +5 -5
  74. package/dist/safe-bash-compression-engine/stream.js +4 -4
  75. package/dist/safe-bash-compression-engine/zstd-decode.js +3 -3
  76. package/dist/safe-bash-media-engine/imagemagick.d.ts +2 -0
  77. package/dist/safe-bash-media-engine/index.js +162 -72
  78. package/dist/safe-bash-network-engine/body.d.ts +1 -0
  79. package/dist/safe-bash-network-engine/body.js +1 -1
  80. package/dist/safe-bash-network-engine/transfer.js +11 -3
  81. package/dist/safe-bash-presentation-engine/command-placeholder.js +4 -3
  82. package/dist/safe-bash-presentation-engine/index.d.ts +1 -1
  83. package/dist/safe-bash-presentation-engine/index.js +9 -4
  84. package/dist/safe-bash-presentation-engine/presentation-model.js +3 -2
  85. package/dist/safe-bash-presentation-engine/retained-text.js +3 -3
  86. package/dist/safe-bash-presentation-engine/retained-xml-parts.d.ts +26 -0
  87. package/dist/safe-bash-presentation-engine/xml-parts.d.ts +1 -0
  88. package/dist/safe-bash-presentation-engine/xml-parts.js +7 -1
  89. package/dist/safe-bash-xml-engine/document.js +1 -1
  90. package/dist/safe-bash-xml-engine/index.js +1 -1
  91. package/dist/spreadsheet-engine/rendering/print/tab-layout.d.ts +11 -0
  92. package/dist/spreadsheet-engine/rendering/print/tab-layout.js +15 -0
  93. package/dist/spreadsheet-engine/rendering/print/text-lines.d.ts +2 -2
  94. package/dist/spreadsheet-engine/rendering/print/text-lines.js +3 -3
  95. package/dist/spreadsheet-format-xls/biff-encrypted-properties.d.ts +4 -0
  96. package/dist/spreadsheet-format-xls/biff-encrypted-properties.js +137 -56
  97. package/dist/spreadsheet-format-xls/biff-encryption.d.ts +1 -1
  98. package/dist/spreadsheet-format-xls/biff-encryption.js +8 -3
  99. package/dist/spreadsheet-format-xls/biff-property-bytes.d.ts +1 -1
  100. package/dist/spreadsheet-format-xls/biff-property-bytes.js +2 -2
  101. package/dist/spreadsheet-format-xls/biff.js +11 -3
  102. package/package.json +3 -2
  103. package/dist/safe-bash/chunks/chunk-I2A5ZCPD.js +0 -17
  104. package/dist/safe-bash/chunks/chunk-PQTT2EZP.js +0 -8
  105. package/dist/safe-bash/command-chunks/biff-DS263V2K-2GP4GZT7.js +0 -4868
  106. package/dist/safe-bash/command-chunks/chunk-6ZFYWT3U.js +0 -581
  107. package/dist/safe-bash/command-chunks/chunk-S244SWDH.js +0 -153
  108. package/dist/safe-bash/command-chunks/pdf-T7AWYZGQ-KNAYJ7YF.js +0 -552
  109. /package/dist/safe-bash/command-chunks/{chunk-EMMSXKEJ.js → chunk-4Q4R3VZU.js} +0 -0
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-66QPYWEF.js";
8
8
  import {
9
9
  parseRecords
10
- } from "./chunk-OQCJGUI6.js";
10
+ } from "./chunk-HARUYHH7.js";
11
11
  import {
12
12
  FileFailure,
13
13
  PatchError,
@@ -24,6 +24,111 @@ import {
24
24
  writeBytes
25
25
  } from "../../safe-bash-contracts/index.js";
26
26
 
27
+ // packages/safe-bash-command-apply-patch/src/metadata.ts
28
+ import { PagedStorage } from "@poe-platform/safe-fs/storage";
29
+ var MetadataList = class {
30
+ constructor(storage, work, codec, head = 0, length = 0) {
31
+ this.storage = storage;
32
+ this.work = work;
33
+ this.codec = codec;
34
+ this.head = head;
35
+ this.length = length;
36
+ }
37
+ storage;
38
+ work;
39
+ codec;
40
+ head;
41
+ length;
42
+ tail = 0;
43
+ async push(value) {
44
+ this.work.step();
45
+ await this.work.checkpoint();
46
+ if (this.length && !this.tail) throw new Error("Cannot append to a retained patch collection");
47
+ const bytes = new Uint8Array(8 + this.codec.size);
48
+ this.codec.encode(new DataView(bytes.buffer, 8), value);
49
+ const address = this.storage.allocate(bytes.length);
50
+ await this.storage.write(address, bytes);
51
+ if (this.tail) {
52
+ const link = new Uint8Array(8);
53
+ new DataView(link.buffer).setFloat64(0, address, true);
54
+ await this.storage.write(this.tail, link);
55
+ } else this.head = address;
56
+ this.tail = address;
57
+ this.length++;
58
+ }
59
+ async *[Symbol.asyncIterator]() {
60
+ let address = this.head;
61
+ for (let index = 0; index < this.length; index++) {
62
+ this.work.step();
63
+ await this.work.checkpoint();
64
+ const bytes = await this.storage.read(address, 8 + this.codec.size);
65
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
66
+ address = view.getFloat64(0, true);
67
+ yield this.codec.decode(new DataView(bytes.buffer, bytes.byteOffset + 8, this.codec.size));
68
+ }
69
+ }
70
+ };
71
+ var PatchMetadata = class {
72
+ constructor(document, work) {
73
+ this.work = work;
74
+ this.storage = new PagedStorage(work.context, 8);
75
+ this.close = this.storage.close.bind(this.storage);
76
+ work.context.registerCleanup?.(this.close);
77
+ this.textCodec = {
78
+ size: 16,
79
+ encode(view, value) {
80
+ view.setFloat64(0, value.start, true);
81
+ view.setFloat64(8, value.end, true);
82
+ },
83
+ decode(view) {
84
+ return { document, start: view.getFloat64(0, true), end: view.getFloat64(8, true) };
85
+ }
86
+ };
87
+ this.lineCodec = {
88
+ size: 24,
89
+ encode: (view, value) => {
90
+ view.setUint8(0, value.kind.charCodeAt(0));
91
+ this.textCodec.encode(new DataView(view.buffer, view.byteOffset + 8, 16), value.text);
92
+ },
93
+ decode: (view) => ({
94
+ kind: String.fromCharCode(view.getUint8(0)),
95
+ text: this.textCodec.decode(new DataView(view.buffer, view.byteOffset + 8, 16))
96
+ })
97
+ };
98
+ this.hunkCodec = {
99
+ size: 40,
100
+ encode(view, value) {
101
+ if (!(value.anchors instanceof MetadataList) || !(value.lines instanceof MetadataList)) throw new Error("Patch metadata must share caller storage");
102
+ view.setFloat64(0, value.anchors.head, true);
103
+ view.setFloat64(8, value.anchors.length, true);
104
+ view.setFloat64(16, value.lines.head, true);
105
+ view.setFloat64(24, value.lines.length, true);
106
+ view.setUint8(32, Number(value.eof));
107
+ },
108
+ decode: (view) => ({
109
+ anchors: new MetadataList(this.storage, work, this.textCodec, view.getFloat64(0, true), view.getFloat64(8, true)),
110
+ lines: new MetadataList(this.storage, work, this.lineCodec, view.getFloat64(16, true), view.getFloat64(24, true)),
111
+ eof: !!view.getUint8(32)
112
+ })
113
+ };
114
+ }
115
+ work;
116
+ storage;
117
+ close;
118
+ textCodec;
119
+ lineCodec;
120
+ hunkCodec;
121
+ texts() {
122
+ return new MetadataList(this.storage, this.work, this.textCodec);
123
+ }
124
+ lines() {
125
+ return new MetadataList(this.storage, this.work, this.lineCodec);
126
+ }
127
+ hunks() {
128
+ return new MetadataList(this.storage, this.work, this.hunkCodec);
129
+ }
130
+ };
131
+
27
132
  // packages/safe-bash-command-apply-patch/src/stored-text.ts
28
133
  async function* textChunks(value) {
29
134
  const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
@@ -99,7 +204,7 @@ async function equalText(left, right, pass, work) {
99
204
  }
100
205
 
101
206
  // packages/safe-bash-command-apply-patch/src/stored-parser.ts
102
- async function parseDocument(document, work) {
207
+ async function parseDocument(document, work, metadata) {
103
208
  await work.utf8(work.cwd, work.limits.maxPathBytes, 2);
104
209
  if (!work.cwd.startsWith("/") || work.cwd.includes("\0")) throw new PatchError("cwd must be an absolute virtual path", 2);
105
210
  if (document.binary) throw new PatchError("NUL bytes are unsupported", 2);
@@ -124,7 +229,7 @@ async function parseDocument(document, work) {
124
229
  for await (const chunk of textChunks(value)) result += chunk;
125
230
  return result;
126
231
  } };
127
- } }, work);
232
+ } }, work, metadata);
128
233
  }
129
234
 
130
235
  // packages/safe-bash-command-apply-patch/src/stored-matcher.ts
@@ -146,8 +251,9 @@ async function find(document, pattern, start, eof, work) {
146
251
  for (let pass = 0; pass < 4; pass++) for (let candidate = first; candidate <= last; candidate++) {
147
252
  await work.charge(1);
148
253
  let equal = true;
149
- for (let offset = 0; offset < pattern.length; offset++) {
150
- if (!await matches(document, candidate + offset, pattern[offset], pass, work)) {
254
+ let offset = 0;
255
+ for await (const expected of pattern) {
256
+ if (!await matches(document, candidate + offset++, expected, pass, work)) {
151
257
  equal = false;
152
258
  break;
153
259
  }
@@ -158,7 +264,7 @@ async function find(document, pattern, start, eof, work) {
158
264
  }
159
265
  async function* records(file, original, work, ending) {
160
266
  if (file.kind === "add") {
161
- for (const value of file.added) {
267
+ for await (const value of file.added) {
162
268
  await work.charge(1);
163
269
  yield { start: 0, end: 0, ending: "\n", text: value };
164
270
  }
@@ -166,26 +272,33 @@ async function* records(file, original, work, ending) {
166
272
  }
167
273
  const old = original;
168
274
  let cursor = 0, emitted = 0;
169
- for (const hunk of file.hunks) {
275
+ for await (const hunk of file.hunks) {
170
276
  let anchorPosition;
171
- for (const anchor of hunk.anchors) {
277
+ for await (const anchor of hunk.anchors) {
172
278
  const position = await find(old, [anchor], cursor, false, work);
173
279
  if (position < 0) throw new PatchError(`context anchor not found: ${file.label}`);
174
280
  cursor = position + 1;
175
281
  anchorPosition = position;
176
282
  }
177
- const pattern = [];
178
- for (const line of hunk.lines) {
283
+ let patternLength = 0;
284
+ let first;
285
+ for await (const line of hunk.lines) {
179
286
  await work.charge(1);
180
- if (line.kind !== "+") pattern.push(line.text);
287
+ if (line.kind !== "+") {
288
+ patternLength++;
289
+ first ??= line.text;
290
+ }
181
291
  }
182
- const searchStart = anchorPosition !== void 0 && pattern.length && await matches(old, anchorPosition, pattern[0], 3, work) ? anchorPosition : cursor;
292
+ const pattern = { length: patternLength, async *[Symbol.asyncIterator]() {
293
+ for await (const line of hunk.lines) if (line.kind !== "+") yield line.text;
294
+ } };
295
+ const searchStart = anchorPosition !== void 0 && first !== void 0 && await matches(old, anchorPosition, first, 3, work) ? anchorPosition : cursor;
183
296
  const start = pattern.length ? await find(old, pattern, searchStart, hunk.eof, work) : hunk.eof ? old.length : cursor;
184
297
  if (start < 0) throw new PatchError(`expected context not found: ${file.label}`);
185
298
  if (start < emitted) throw new PatchError("overlapping update hunks");
186
299
  while (emitted < start) yield await record(old, emitted++);
187
300
  let matched = start;
188
- for (const line of hunk.lines) {
301
+ for await (const line of hunk.lines) {
189
302
  await work.charge(1);
190
303
  if (line.kind === " ") yield await record(old, matched++);
191
304
  else if (line.kind === "-") matched++;
@@ -547,7 +660,10 @@ var Invocation = class {
547
660
  let summary;
548
661
  try {
549
662
  try {
550
- const files = await parseDocument(await this.input(), work);
663
+ const input = await this.input();
664
+ const metadata = new PatchMetadata(input, work);
665
+ this.documents.add(metadata);
666
+ const files = await parseDocument(input, work, metadata);
551
667
  await this.confine(files);
552
668
  const plans = await this.prepare(files);
553
669
  const lines = ["Success. Updated the following files:\n"];