feat(domain): R4.2d attachment probe, import_pdf and SheetHandle.import_pdf on the wasm facade
locate_attachment (shared 16 MiB budget, JS-path steps in the TypeScript order, OD-3 cap hook off until measured), pdf::import, facade import_pdf with the PdfImportKind kinds (ts-rs exported). cargo: O7 144 inputs (locate, read, archive rows) and O8 51 cases equal to the R3 path, 3 OD-4 differences declared (lone surrogate in an overwritten duplicate value). Node through the shipped module: the same O8 outcomes, every reference PDF. Module 421.7 KB gzip (W1 budget 600 KB).
This commit is contained in:
1 parent
9850a8341a
commit
f8579bc19a
13 files changed
+813
-14
No files matched your search
@@ -61,6 +61,22 @@ pub fn call_with_sheet(sheet: &LoadedSheet, op: &str, input: &str) -> String {
|
||||
render(crate::ops::on_sheet(sheet, op, input).unwrap_or_else(|| Err(unknown(op))))
|
||||
}
|
||||
|
||||
/// Reads `bytes` as a Faunosteo PDF and imports its attachment onto the session's sheet
|
||||
/// (R4, plan §B.1.4): the envelope of `archive.import`, plus the reader's kinds
|
||||
/// `invalid_pdf`, `no_attachment`, `attachment_stripped` (`PdfImportKind`).
|
||||
#[cfg(feature = "pdf-read")]
|
||||
pub fn import_pdf(sheet: &LoadedSheet, bytes: &[u8]) -> String {
|
||||
use crate::pdf::import::{PdfImportFailure, PdfImportKind, import_pdf};
|
||||
use crate::pdf::read::probe::ProbeLimits;
|
||||
let outcome = import_pdf(sheet, bytes, ProbeLimits::PRODUCTION)
|
||||
.map_err(|failure| match failure {
|
||||
PdfImportFailure::Import(failure) => crate::ops::import_failure(failure),
|
||||
read => Failure::new(PdfImportKind::from(&read).as_str(), ""),
|
||||
})
|
||||
.and_then(|import| to_value(&import));
|
||||
render(outcome)
|
||||
}
|
||||
|
||||
fn unknown(op: &str) -> Failure {
|
||||
Failure::new("unknown_op", format!("no operation named {op}"))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user