feat: make watch access model (#2067)

<img width="2087" height="1144" alt="0c29317922c3c829deb7f364b22ccaee"
src="https://github.com/user-attachments/assets/cfb8143e-21c6-45c8-9492-a4237473c0f0"
/>
This commit is contained in:
Myriad-Dreamin 2025-08-26 23:54:41 +08:00 committed by GitHub
parent 2fc5d919e9
commit 6573ed917b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 447 additions and 128 deletions

View file

@ -5,7 +5,7 @@ use std::collections::HashSet;
use std::path::Path;
use std::sync::{Arc, OnceLock};
use ecow::{EcoVec, eco_vec};
use ecow::{EcoString, EcoVec, eco_vec};
use tinymist_std::error::prelude::Result;
use tinymist_std::{ImmutPath, typst::TypstDocument};
use tinymist_task::ExportTarget;
@ -19,6 +19,7 @@ use tinymist_world::{
WorldComputeGraph, WorldDeps,
};
use tokio::sync::mpsc;
use typst::diag::FileError;
/// A compiled artifact.
pub struct CompiledArtifact<F: CompilerFeat> {
@ -317,6 +318,10 @@ impl<F: CompilerFeat + Send + Sync + 'static, Ext: 'static> Default for CompileS
}
}
const FILE_MISSING_ERROR_MSG: EcoString = EcoString::inline("t-file-missing");
/// The file missing error constant.
pub const FILE_MISSING_ERROR: FileError = FileError::Other(Some(FILE_MISSING_ERROR_MSG));
/// The synchronous compiler that runs on one project or multiple projects.
pub struct ProjectCompiler<F: CompilerFeat, Ext> {
/// The compilation handle.
@ -860,9 +865,15 @@ impl<F: CompilerFeat, Ext: 'static> ProjectInsState<F, Ext> {
// todo: we need to check revision for really concurrent compilation
log_compile_report(&rep);
if compiled
.diagnostics()
.any(|d| d.message == FILE_MISSING_ERROR_MSG)
{
return compiled;
}
h.status(revision, rep);
h.notify_compile(&compiled);
compiled
}
}