forked from 1b-agent/opencadstudio-upstream
web: XREFs, data links & extraction, ARCHIVE transmittals, worker-side saves
The last four big web-vs-desktop gaps.
XREFs: XATTACH reads the picked drawing's bytes and registers them
name-keyed (the image/PDF-underlay pattern), pre-parses on the web
worker, and the commit merge produces the same xref block flow as
native. Opened drawings resolve xrefs from the registry (trailing-name
match) before cache build; unresolved references produce ONE warning
listing the names and the fix — drop the referenced files on the page
(drops and picker opens now register their bytes) and reopen or
XRELOAD. XRELOAD works off the registry on unsaved drawings too.
Data Link & Extraction: spreadsheet links read picked xlsx/csv bytes
(calamine from slices / CSV from string) through a session registry,
so preview, refresh, and table-insert work on web; extraction takes
external drawings via a multi-file picker parsed on the worker, and
outputs CSV/TXT/.dxex via download_bytes. The disabled 'Add folder'
button explains why.
ARCHIVE/ETRANSMIT: assembles the drawing plus registered images, PDF
underlays, and session plot tables into a ZIP delivered as
{stem}_transmit.zip; skipped dependencies are reported by name.
Save/autosave off the UI thread: the parse worker gains a serialize
action (protocol v5) — the document is prepared once on the main
thread (clone, styles, dimension bake), then the DWG/DXF writer pass,
the dominant cost, runs on the worker; any worker failure falls back
to inline serialization with the identical shared implementation.
The save path also clears the dirty flag only when the tab didn't
change mid-write, and the runtime-fields sidecar now carries
graphic_data, fixing a pre-existing loss of raw DWG round-trip bytes
on web-opened documents.
(cherry picked from commit 2e100634)
Ported onto main (#1717 review): the new ocs_save crate builds on the
pinned codec; the hand-written ZIP writer is replaced by the zip crate
already in the tree; ARCHIVE packs registered xref bytes too and
serializes document_for_save() like a web Save; the web save prepares
document_for_save() (prepare_document_for_save now takes the copy by
value, so no second clone); the wasm resolve_path consults the xref
registry, so every reference lookup — not just resolve — finds dropped
files; XRELOAD keeps main's undo, unload and stale-baseline handling;
native data extraction streams the source drawings one at a time.
This commit is contained in:
1 parent
9cd898a17a
commit
61c32c7f74
43 files changed
+2187
-336
No files matched your search
@@ -1612,9 +1612,20 @@ impl OpenCADStudio {
|
||||
"XRELOAD" => {
|
||||
// Reload all xrefs for the current drawing. Every direct key
|
||||
// leaves the session-unloaded set (reloaded content is live
|
||||
// again) with fresh stat baselines on the next refresh.
|
||||
if let Some(path) = &self.tabs[i].current_path.clone() {
|
||||
if let Some(base_dir) = path.parent() {
|
||||
// again) with fresh stat baselines on the next refresh. Web:
|
||||
// xrefs re-read from the in-session bytes registry, so an
|
||||
// unsaved drawing reloads too; native needs the drawing's own
|
||||
// folder for relative xref paths.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let base_dir: Option<std::path::PathBuf> = Some(std::path::PathBuf::new());
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let base_dir: Option<std::path::PathBuf> = self.tabs[i]
|
||||
.current_path
|
||||
.as_ref()
|
||||
.and_then(|path| path.parent().map(std::path::Path::to_path_buf));
|
||||
if let Some(base_dir) = base_dir {
|
||||
{
|
||||
let base_dir: &std::path::Path = &base_dir;
|
||||
let reload_keys: Vec<u64> = crate::io::xref::collect_entries_with_prev(
|
||||
&self.tabs[i].scene.document,
|
||||
base_dir,
|
||||
@@ -1631,7 +1642,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
let (infos, _dropped) = crate::io::xref::resolve_xrefs(
|
||||
&mut self.tabs[i].scene.document,
|
||||
base_dir,
|
||||
&base_dir,
|
||||
);
|
||||
// `resolve_xrefs` re-merges ALL references — refresh stat
|
||||
// baselines for every currently-Loaded entry so no row
|
||||
@@ -1652,8 +1663,17 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
for info in &infos {
|
||||
// Web: unresolved references surface once below,
|
||||
// with the drop hint, instead of a filesystem path
|
||||
// no browser can open.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
if info.status == crate::io::xref::XrefStatus::NotFound {
|
||||
continue;
|
||||
}
|
||||
self.report_xref_status(info);
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
self.warn_unresolved_xrefs(&infos);
|
||||
self.post_ref_op(i);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user