@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.
Files changed (59) hide show
  1. package/dist/mp4-ast/index.d.ts +1 -0
  2. package/dist/mp4-ast/mp4-fragment-source.d.ts +35 -0
  3. package/dist/mp4-ast/mp4-sample-source.d.ts +5 -2
  4. package/dist/mp4-ast/types.d.ts +11 -0
  5. package/dist/pdf-ast/cos/object-reader.d.ts +3 -2
  6. package/dist/pdf-ast/edit/forms.d.ts +1 -0
  7. package/dist/pdf-ast/edit/retained-form-data.d.ts +9 -0
  8. package/dist/pdf-ast/index.d.ts +1 -0
  9. package/dist/pdf-ast/index.js +476 -55
  10. package/dist/safe-bash/command-chunks/{biff-KRHJ63K3-VQPJCVIL.js → biff-A7XPBWAK-DCLG5QKF.js} +1775 -1667
  11. package/dist/safe-bash/command-chunks/{chunk-AVGXFWEB.js → chunk-44F5TOHZ.js} +179 -58
  12. package/dist/safe-bash/command-chunks/{chunk-PIVH35EQ.js → chunk-6CDDKNNA.js} +1 -0
  13. package/dist/safe-bash/command-chunks/{chunk-K4XNUJVJ.js → chunk-6EINUY5G.js} +149 -165
  14. package/dist/safe-bash/command-chunks/{chunk-5BIQWWLB.js → chunk-CFMJXJS5.js} +1 -1
  15. package/dist/safe-bash/command-chunks/{chunk-3JM7E42I.js → chunk-GPGLTWNR.js} +106 -32
  16. package/dist/safe-bash/command-chunks/{chunk-2ETEJOYX.js → chunk-HQ2UN2L2.js} +8 -8
  17. package/dist/safe-bash/command-chunks/{chunk-CK2WFJZN.js → chunk-KASXIRKD.js} +12 -14
  18. package/dist/safe-bash/command-chunks/chunk-KHUT7BB5.js +65 -0
  19. package/dist/safe-bash/command-chunks/{chunk-LAPOMHGY.js → chunk-NEYITAAO.js} +114 -97
  20. package/dist/safe-bash/command-chunks/{chunk-FF7UGJWS.js → chunk-QDVDBN2N.js} +1 -1
  21. package/dist/safe-bash/command-chunks/{chunk-SW37YCBW.js → chunk-U3C6IT2C.js} +44 -30
  22. package/dist/safe-bash/command-chunks/{chunk-G3TAX3CV.js → chunk-WAT2562G.js} +610 -539
  23. package/dist/safe-bash/command-chunks/{chunk-VT7UBPAE.js → chunk-YW2VYN4V.js} +23 -11
  24. package/dist/safe-bash/command-chunks/{chunk-GQGMQMIM.js → chunk-ZIGENXGC.js} +243 -1
  25. package/dist/safe-bash/command-chunks/{command-engine-7V6PZR7G.js → command-engine-M7S4QIXV.js} +12 -4
  26. package/dist/safe-bash/command-chunks/{engine-UYJENSWK-VSCGKSQV.js → engine-YUYZJIB4-NZUDFEHL.js} +1 -1
  27. package/dist/safe-bash-command-ffmpeg/index.js +1 -1
  28. package/dist/safe-bash-command-ffprobe/index.js +2 -2
  29. package/dist/safe-bash-command-ffprobe/media.d.ts +8 -2
  30. package/dist/safe-bash-command-ffprobe/media.js +4 -2
  31. package/dist/safe-bash-command-pandoc/command.js +3 -3
  32. package/dist/safe-bash-command-pandoc/index.js +8 -8
  33. package/dist/safe-bash-command-patch/index.js +7 -6
  34. package/dist/safe-bash-command-patch/patch-formats.d.ts +6 -5
  35. package/dist/safe-bash-command-patch/patch-formats.js +3 -2
  36. package/dist/safe-bash-command-patch/patch-gnu-paths.d.ts +7 -7
  37. package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +1 -1
  38. package/dist/safe-bash-command-patch/patch-gnu-reject.js +3 -2
  39. package/dist/safe-bash-command-patch/patch-publication.js +3 -2
  40. package/dist/safe-bash-command-patch/patch-text.d.ts +13 -0
  41. package/dist/safe-bash-command-patch/patch.js +7 -6
  42. package/dist/safe-bash-command-patch/stored-patch.d.ts +29 -4
  43. package/dist/safe-bash-command-patch/stored-target.d.ts +2 -1
  44. package/dist/safe-bash-command-patch/unified.d.ts +18 -4
  45. package/dist/safe-bash-command-patch/unified.js +2 -1
  46. package/dist/safe-bash-command-pdftk/index.js +30 -20
  47. package/dist/safe-bash-command-pptx/engine.js +1 -1
  48. package/dist/safe-bash-command-ssconvert/index.js +2 -2
  49. package/dist/safe-bash-presentation-engine/index.js +1 -1
  50. package/dist/safe-bash-presentation-engine/notes.d.ts +1 -0
  51. package/dist/safe-bash-presentation-engine/notes.js +7 -1
  52. package/dist/safe-bash-presentation-engine/retained-notes.d.ts +27 -0
  53. package/dist/safe-bash-xml-engine/document.js +2 -2
  54. package/dist/safe-bash-xml-engine/index.js +2 -2
  55. package/dist/safe-bash-xml-engine/stored-document.js +1 -1
  56. package/dist/spreadsheet-format-xls/biff-properties-merge.js +40 -21
  57. package/dist/spreadsheet-format-xls/biff-property-values.d.ts +31 -0
  58. package/dist/spreadsheet-format-xls/biff-property-values.js +158 -0
  59. package/package.json +3 -2
@@ -1,3 +1,4 @@
1
+ import { BiffMutablePropertyValues } from './biff-property-values.js';
1
2
  import { createBiffPropertyNameEncoder } from "./biff-property-name.js";
2
3
  import { readBiffPropertyText } from "./biff-property-text.js";
3
4
  import { stageWideBiffProperty } from './biff-property-transcode.js';
@@ -5,7 +6,7 @@ import { stagePropertyBytes, propertyChunks } from './biff-property-bytes.js';
5
6
  import { SsconvertError } from "../spreadsheet-engine/contracts.js";
6
7
  import { Binary, invalidBiff } from "./biff-binary.js";
7
8
  import { biffPropertyFields, biffPropertyFormats, readBiffProperties } from "./biff-properties.js";
8
- import { propertyRange, readPropertySectionRanges, readPropertyValueRanges } from "./biff-property-range.js";
9
+ import { propertyRange, readPropertySectionRanges, withPropertyValueRanges } from "./biff-property-range.js";
9
10
  /** Rebuild offsets around original opaque spans. Never transcode their codepage. */
10
11
  export async function mergeBiffProperties(book, streams, handled, context, charge, allocate, staged) {
11
12
  const canonical = (name) => ["\u0005SummaryInformation", "\u0005DocumentSummaryInformation"].find(target => target.toUpperCase() === name.toUpperCase());
@@ -89,8 +90,16 @@ export async function mergeBiffProperties(book, streams, handled, context, charg
89
90
  const file = propertyRange(input, context), sections = [];
90
91
  for await (const section of readPropertySectionRanges(file, admit, charge, context)) {
91
92
  const bytes = file.slice(section.offset, section.end - section.offset);
92
- sections.push({ ...section, bytes, ...(biffPropertyFields.has(section.guid) || section.guid === biffPropertyFormats.custom ?
93
- { values: await readPropertyValueRanges(bytes, admit, charge, context) } : {}) });
93
+ let values;
94
+ if (biffPropertyFields.has(section.guid) || section.guid === biffPropertyFormats.custom) {
95
+ values = new BiffMutablePropertyValues(context, charge);
96
+ temporarySources.push(values);
97
+ await withPropertyValueRanges(bytes, admit, charge, context, async (source) => {
98
+ for await (const [id, value] of source.entries())
99
+ await values.set(id, value);
100
+ });
101
+ }
102
+ sections.push({ ...section, bytes, ...(values ? { values } : {}) });
94
103
  }
95
104
  return sections;
96
105
  };
@@ -122,10 +131,10 @@ export async function mergeBiffProperties(book, streams, handled, context, charg
122
131
  }
123
132
  };
124
133
  const dictionary = async function* (section, names = true) {
125
- const data = section.values?.get(0);
134
+ const data = await section.values?.get(0);
126
135
  if (!data)
127
136
  return;
128
- const cp = await section.values?.get(1)?.u16(4) ?? 1252, count = await data.u32(0);
137
+ const cp = await (await section.values?.get(1))?.u16(4) ?? 1252, count = await data.u32(0);
129
138
  data.check(4, count * 9);
130
139
  if (names) {
131
140
  charge(data.size);
@@ -171,7 +180,7 @@ export async function mergeBiffProperties(book, streams, handled, context, charg
171
180
  staged.reserve(plan.length);
172
181
  const source = await stagePropertyBytes(output, context);
173
182
  temporarySources.push(source);
174
- section.values.set(0, propertyRange(source, context));
183
+ await section.values.set(0, propertyRange(source, context));
175
184
  }
176
185
  else {
177
186
  const bytes = allocate(plan.length);
@@ -180,11 +189,11 @@ export async function mergeBiffProperties(book, streams, handled, context, charg
180
189
  bytes.set(part, at);
181
190
  at += part.length;
182
191
  }
183
- section.values.set(0, propertyRange(bytes, context));
192
+ await section.values.set(0, propertyRange(bytes, context));
184
193
  }
185
194
  };
186
195
  const remove = async (section, id) => {
187
- section.values.delete(id);
196
+ await section.values.delete(id);
188
197
  if (section.guid === biffPropertyFormats.custom) {
189
198
  let length = 4, count = 0;
190
199
  for await (const entry of dictionary(section))
@@ -198,13 +207,13 @@ export async function mergeBiffProperties(book, streams, handled, context, charg
198
207
  const take = async (property) => {
199
208
  charge(fresh.get(property.stream).length);
200
209
  const section = fresh.get(property.stream).find(section => section.offset === property.section);
201
- const value = section.values.get(property.id);
210
+ const value = (await section.values.get(property.id));
202
211
  await remove(section, property.id);
203
212
  pending.delete(property.key);
204
213
  return value;
205
214
  };
206
215
  const wide = async (source, section) => {
207
- if (await source.u32(0) !== 30 || (await section.values.get(1)?.u16(4) ?? 1252) === 65001)
216
+ if (await source.u32(0) !== 30 || (await (await section.values.get(1))?.u16(4) ?? 1252) === 65001)
208
217
  return source;
209
218
  if (staged) {
210
219
  const output = await stageWideBiffProperty(source, context, charge, staged.reserve);
@@ -265,7 +274,7 @@ export async function mergeBiffProperties(book, streams, handled, context, charg
265
274
  await take(replacement);
266
275
  }
267
276
  else if (replacement)
268
- section.values.set(id, await wide(await take(replacement), section));
277
+ await section.values.set(id, await wide(await take(replacement), section));
269
278
  }
270
279
  }
271
280
  const encodeName = createBiffPropertyNameEncoder(context, charge, accountText);
@@ -301,13 +310,13 @@ export async function mergeBiffProperties(book, streams, handled, context, charg
301
310
  await warn(property.key, "opaque name collision");
302
311
  continue;
303
312
  }
304
- const cp = await values.get(1)?.u16(4) ?? 1252, text = encodeName(property.key, cp);
313
+ const cp = await (await values.get(1))?.u16(4) ?? 1252, text = encodeName(property.key, cp);
305
314
  if (!text) {
306
315
  await warn(property.key, "name cannot be encoded in the original codepage");
307
316
  continue;
308
317
  }
309
318
  id = maximumId;
310
- for (const key of values.keys())
319
+ for await (const [key] of values.entries())
311
320
  id = Math.max(id, key);
312
321
  id++;
313
322
  if (id > 0xffffffff) {
@@ -342,11 +351,11 @@ export async function mergeBiffProperties(book, streams, handled, context, charg
342
351
  }
343
352
  await writeDictionary(target, { length: dictionaryLength + bytes.size, count: count + 1, append: bytes });
344
353
  }
345
- else if (values.has(id)) {
354
+ else if (await values.get(id)) {
346
355
  await warn(property.key, "opaque property ID collision");
347
356
  continue;
348
357
  }
349
- values.set(id, await wide(value, target));
358
+ await values.set(id, await wide(value, target));
350
359
  }
351
360
  const reserve = staged?.reserve ?? ((length) => {
352
361
  charge(length);
@@ -354,12 +363,12 @@ export async function mergeBiffProperties(book, streams, handled, context, charg
354
363
  throw new SsconvertError("resource-limit", "ssconvert BIFF property output bytes limit exceeded");
355
364
  return length;
356
365
  });
357
- const encodeSection = (section) => {
366
+ const encodeSection = async (section) => {
358
367
  if (!section.values)
359
368
  return { length: section.bytes.size, chunks: () => chunks(section.bytes) };
360
369
  const values = section.values;
361
370
  let length = 8 + values.size * 8;
362
- for (const value of values.values())
371
+ for await (const [, value] of values.entries())
363
372
  length += Math.ceil(value.size / 4) * 4;
364
373
  // Buffered output charges the section size here, as the old allocation did.
365
374
  reserve(length);
@@ -369,7 +378,7 @@ export async function mergeBiffProperties(book, streams, handled, context, charg
369
378
  view.setUint32(4, values.size, true);
370
379
  yield header;
371
380
  let at = 8 + values.size * 8;
372
- for (const [id, value] of values) {
381
+ for await (const [id, value] of values.entries()) {
373
382
  charge(value.size);
374
383
  const entry = new Uint8Array(8), view = new DataView(entry.buffer);
375
384
  view.setUint32(0, id, true);
@@ -377,7 +386,7 @@ export async function mergeBiffProperties(book, streams, handled, context, charg
377
386
  yield entry;
378
387
  at += Math.ceil(value.size / 4) * 4;
379
388
  }
380
- for (const value of values.values()) {
389
+ for await (const [, value] of values.entries()) {
381
390
  yield* chunks(value);
382
391
  const padding = (4 - value.size % 4) % 4;
383
392
  if (padding)
@@ -388,7 +397,14 @@ export async function mergeBiffProperties(book, streams, handled, context, charg
388
397
  for (const name of new Set([...streams.keys(), ...snapshots.keys()])) {
389
398
  for (const section of fresh.get(name) ?? [])
390
399
  charge(1 + section.values.size);
391
- const remaining = fresh.get(name)?.filter(section => [...section.values.keys()].some(id => id >= 2)) ?? [];
400
+ const remaining = [];
401
+ for (const section of fresh.get(name) ?? []) {
402
+ for await (const [id] of section.values.entries())
403
+ if (id >= 2) {
404
+ remaining.push(section);
405
+ break;
406
+ }
407
+ }
392
408
  if (!old.has(name) && remaining.some(section => section.guid === biffPropertyFormats.custom) &&
393
409
  !remaining.some(section => section.guid === biffPropertyFormats.document)) {
394
410
  const builtin = fresh.get(name)?.find(section => section.guid === biffPropertyFormats.document);
@@ -400,7 +416,10 @@ export async function mergeBiffProperties(book, streams, handled, context, charg
400
416
  streams.delete(name);
401
417
  continue;
402
418
  }
403
- const bodies = sections.map(encodeSection), length = 28 + sections.length * 20 + bodies.reduce((sum, body) => sum + body.length, 0);
419
+ const bodies = [];
420
+ for (const section of sections)
421
+ bodies.push(await encodeSection(section));
422
+ const length = 28 + sections.length * 20 + bodies.reduce((sum, body) => sum + body.length, 0);
404
423
  const originalHeader = await (snapshots.get(name)?.bytes ?? propertyRange(streams.get(name), context)).read(0, 28);
405
424
  const output = { length, async *chunks() {
406
425
  const header = new Uint8Array(originalHeader);
@@ -0,0 +1,31 @@
1
+ import { type CapabilityContext } from "../spreadsheet-engine/contracts.js";
2
+ import { BiffPropertyRange } from './biff-property-range.js';
3
+ /** Mutable insertion order with immutable payload snapshots. Deleted payloads remain
4
+ * readable until close, so values can be moved between independently edited sections. */
5
+ export declare class BiffMutablePropertyValues {
6
+ private readonly context;
7
+ private readonly charge;
8
+ private readonly storage;
9
+ private readonly index;
10
+ private readonly fallback;
11
+ private pending;
12
+ private closing;
13
+ private closed;
14
+ private initialized;
15
+ private first;
16
+ private last;
17
+ private count;
18
+ private readonly root;
19
+ constructor(context: CapabilityContext, charge: (amount: number) => void);
20
+ get size(): number;
21
+ private check;
22
+ private allocate;
23
+ private io;
24
+ private read;
25
+ private write;
26
+ get(id: number): Promise<BiffPropertyRange | undefined>;
27
+ set(id: number, value: BiffPropertyRange): Promise<void>;
28
+ delete(id: number): Promise<boolean>;
29
+ entries(): AsyncGenerator<readonly [number, BiffPropertyRange]>;
30
+ close(): Promise<void>;
31
+ }
@@ -0,0 +1,158 @@
1
+ import { IntegerTable } from "@poe-platform/safe-fs/storage";
2
+ import { SsconvertError } from "../spreadsheet-engine/contracts.js";
3
+ import { Binary, invalidBiff } from './biff-binary.js';
4
+ import { BiffPropertyRange } from './biff-property-range.js';
5
+ /** Mutable insertion order with immutable payload snapshots. Deleted payloads remain
6
+ * readable until close, so values can be moved between independently edited sections. */
7
+ export class BiffMutablePropertyValues {
8
+ context;
9
+ charge;
10
+ storage;
11
+ index;
12
+ fallback;
13
+ pending = Promise.resolve();
14
+ closing;
15
+ closed = false;
16
+ initialized = false;
17
+ first = 0;
18
+ last = 0;
19
+ count = 0;
20
+ root = { read: (at, count) => this.read(at, count), check: () => this.check() };
21
+ constructor(context, charge) {
22
+ this.context = context;
23
+ this.charge = charge;
24
+ this.storage = context.createWorkingStorage?.();
25
+ if (this.storage)
26
+ this.index = new IntegerTable({ allocate: length => this.allocate(length),
27
+ read: (at, length) => this.read(at, length), write: (at, bytes) => this.write(at, bytes) }, 64);
28
+ else
29
+ this.fallback = new Map();
30
+ context.own(() => this.close());
31
+ }
32
+ get size() { this.check(); return this.fallback?.size ?? this.count; }
33
+ check() {
34
+ this.context.signal.throwIfAborted();
35
+ if (this.closed)
36
+ throw new SsconvertError('invalid-request', 'BIFF mutable property values are closed');
37
+ }
38
+ allocate(length) { this.check(); return this.storage.allocate(length); }
39
+ io(action) {
40
+ const result = this.pending.then(async () => { this.check(); const value = await action(); this.check(); return value; });
41
+ this.pending = result.then(() => undefined, () => undefined);
42
+ return result;
43
+ }
44
+ read(at, length) {
45
+ return this.io(async () => {
46
+ const bytes = await this.storage.read(at, length);
47
+ if (bytes.length !== length)
48
+ invalidBiff('truncated mutable property values');
49
+ return new Uint8Array(bytes);
50
+ });
51
+ }
52
+ async write(at, bytes) {
53
+ const owned = new Uint8Array(bytes);
54
+ try {
55
+ await this.io(() => this.storage.write(at, owned));
56
+ }
57
+ finally {
58
+ owned.fill(0);
59
+ }
60
+ }
61
+ async get(id) {
62
+ this.check();
63
+ if (this.fallback)
64
+ return this.fallback.get(id);
65
+ const position = await this.index.get(BigInt(id));
66
+ this.check();
67
+ if (!position)
68
+ return undefined;
69
+ const record = new Binary(await this.read(Number(position), 32));
70
+ return new BiffPropertyRange(this.root, record.f64(8), record.f64(16));
71
+ }
72
+ async set(id, value) {
73
+ this.check();
74
+ if (this.fallback) {
75
+ this.fallback.set(id, value);
76
+ return;
77
+ }
78
+ this.charge(value.size);
79
+ if (!this.initialized) {
80
+ this.allocate(8);
81
+ this.initialized = true;
82
+ }
83
+ const existing = await this.index.get(BigInt(id));
84
+ this.check();
85
+ const data = this.allocate(value.size);
86
+ for (let at = 0; at < value.size;) {
87
+ const bytes = await value.read(at, Math.min(16384, value.size - at));
88
+ try {
89
+ await this.write(data + at, bytes);
90
+ at += bytes.length;
91
+ }
92
+ finally {
93
+ bytes.fill(0);
94
+ }
95
+ }
96
+ const record = new Uint8Array(32), view = new DataView(record.buffer);
97
+ view.setFloat64(8, data, true);
98
+ view.setFloat64(16, value.size, true);
99
+ view.setUint32(24, id, true);
100
+ view.setUint32(28, 1, true);
101
+ if (existing) {
102
+ await this.write(Number(existing) + 8, record.subarray(8, 24));
103
+ return;
104
+ }
105
+ const position = this.allocate(32);
106
+ await this.write(position, record);
107
+ if (this.last) {
108
+ view.setFloat64(0, position, true);
109
+ await this.write(this.last, record.subarray(0, 8));
110
+ }
111
+ else
112
+ this.first = position;
113
+ this.last = position;
114
+ await this.index.set(BigInt(id), BigInt(position));
115
+ this.check();
116
+ this.count++;
117
+ }
118
+ async delete(id) {
119
+ this.check();
120
+ if (this.fallback)
121
+ return this.fallback.delete(id);
122
+ const position = await this.index.get(BigInt(id));
123
+ this.check();
124
+ if (!position)
125
+ return false;
126
+ await this.write(Number(position) + 28, new Uint8Array(4));
127
+ await this.index.set(BigInt(id), 0n);
128
+ this.check();
129
+ this.count--;
130
+ return true;
131
+ }
132
+ async *entries() {
133
+ this.check();
134
+ if (this.fallback) {
135
+ for (const entry of this.fallback) {
136
+ this.check();
137
+ yield entry;
138
+ }
139
+ return;
140
+ }
141
+ let position = this.first;
142
+ while (position) {
143
+ const record = new Binary(await this.read(position, 32));
144
+ position = record.f64(0);
145
+ if (record.u32(28))
146
+ yield [record.u32(24), new BiffPropertyRange(this.root, record.f64(8), record.f64(16))];
147
+ }
148
+ this.check();
149
+ }
150
+ close() {
151
+ if (!this.closing) {
152
+ this.closed = true;
153
+ this.fallback?.clear();
154
+ this.closing = this.pending.then(async () => { await this.storage?.close(); });
155
+ }
156
+ return this.closing;
157
+ }
158
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-bash",
3
- "version": "0.1.814",
3
+ "version": "0.1.815",
4
4
  "description": "Extensible virtual shell with pluggable filesystems and streaming commands",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1407,7 +1407,7 @@
1407
1407
  "access": "public"
1408
1408
  },
1409
1409
  "dependencies": {
1410
- "@poe-platform/safe-fs": "0.1.814",
1410
+ "@poe-platform/safe-fs": "0.1.815",
1411
1411
  "pdf-lib": "1.17.1",
1412
1412
  "@types/node": "^25.2.2",
1413
1413
  "@formatjs/intl-numberformat": "9.4.0",
@@ -2845,6 +2845,7 @@
2845
2845
  "./dist/spreadsheet-format-xls/biff-property-range.js",
2846
2846
  "./dist/spreadsheet-format-xls/biff-property-text.js",
2847
2847
  "./dist/spreadsheet-format-xls/biff-property-transcode.js",
2848
+ "./dist/spreadsheet-format-xls/biff-property-values.js",
2848
2849
  "./dist/spreadsheet-format-xls/biff-range.js",
2849
2850
  "./dist/spreadsheet-format-xls/biff-record-storage.js",
2850
2851
  "./dist/spreadsheet-format-xls/biff-shared-strings.js",