Skip to content

Commit

Permalink
archive
Browse files Browse the repository at this point in the history
  • Loading branch information
Myriad-Dreamin committed Dec 11, 2024
1 parent 5ab151e commit d604db6
Show file tree
Hide file tree
Showing 42 changed files with 490 additions and 145 deletions.
10 changes: 5 additions & 5 deletions benches/lowering/src/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::{Arc, Mutex};

use divan::Bencher;
use reflexo_typst::{
CompileDriver as CompileDriverT, Compiler, PureCompiler, ShadowApiExt, TypstDocument,
CompileDriver as CompileDriverT, Compiler, PureCompiler, ShadowApiExt, TypstPagedDocument,
TypstSystemWorld,
};
use reflexo_typst2vec::pass::{IncrTypst2VecPass, Typst2VecPass};
Expand All @@ -21,10 +21,10 @@ static TEST_COMPILER: CompileDriver = LazyLock::new(|| {

const TEST_FILE: &str = include_str!("../../../fuzzers/corpora/math/undergradmath.typ");

static TEST_DOC: LazyLock<Arc<TypstDocument>> =
static TEST_DOC: LazyLock<Arc<TypstPagedDocument>> =
LazyLock::new(|| compile(&TEST_COMPILER, TEST_FILE));

fn compile(driver: &CompileDriver, src: &str) -> Arc<TypstDocument> {
fn compile(driver: &CompileDriver, src: &str) -> Arc<TypstPagedDocument> {
let mut driver = driver.lock().unwrap();
let e = driver.entry_file().to_owned().unwrap();
driver
Expand All @@ -45,12 +45,12 @@ fn main() {
divan::main();
}

fn lower_impl(doc: &TypstDocument) {
fn lower_impl(doc: &TypstPagedDocument) {
let pass = Typst2VecPass::default();
let _ = pass.doc(&doc.introspector, doc);
}

fn lower_incr_impl<'a>(docs: impl Iterator<Item = &'a Arc<TypstDocument>>) {
fn lower_incr_impl<'a>(docs: impl Iterator<Item = &'a Arc<TypstPagedDocument>>) {
let mut pass = IncrTypst2VecPass::default();
for doc in docs {
pass.increment_lifetime();
Expand Down
4 changes: 2 additions & 2 deletions cli/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::sync::Arc;
use reflexo_typst::config::entry::{EntryOpts, MEMORY_MAIN_ENTRY};
use reflexo_typst::config::CompileOpts;
use reflexo_typst::features::{FeatureSet, DIAG_FMT_FEATURE};
use reflexo_typst::TypstDocument;
use reflexo_typst::TypstPagedDocument;
use reflexo_typst::{exporter_builtins::GroupExporter, path::PathClean};
use reflexo_typst::{
CompilationHandle, CompileActor, CompileDriver, CompileExporter, CompileServerOpts,
Expand Down Expand Up @@ -113,7 +113,7 @@ pub fn create_driver(args: CompileOnceArgs) -> CompileDriver<PureCompiler<TypstS
CompileDriver::new(std::marker::PhantomData, world)
}

pub fn compile_export(args: CompileArgs, exporter: GroupExporter<TypstDocument>) -> ! {
pub fn compile_export(args: CompileArgs, exporter: GroupExporter<TypstPagedDocument>) -> ! {
let is_stdin = args.compile.entry == "-";
let (intr_tx, intr_rx) = mpsc::unbounded_channel();

Expand Down
6 changes: 3 additions & 3 deletions cli/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use reflexo_typst::exporter_builtins::{FsPathExporter, GroupExporter};
use reflexo_typst::program_meta::REPORT_BUG_MESSAGE;
use reflexo_typst::svg::DefaultExportFeature;
use reflexo_typst::TypstDatetime;
use reflexo_typst::TypstDocument;
use reflexo_typst::TypstPagedDocument;

use crate::{utils::current_dir, CompileArgs, ExportArgs};

type GroupDocExporter = GroupExporter<TypstDocument>;
type GroupDocExporter = GroupExporter<TypstPagedDocument>;

/// builtin formats should be enabled by default, and non-builtin formats should
/// be
Expand Down Expand Up @@ -116,7 +116,7 @@ fn prepare_exporters_impl(
}
return GroupExporter::new(doc);

type Doc = TypstDocument;
type Doc = TypstPagedDocument;

type WithAst = reflexo_typst::AstExporter;
type WithPdf = reflexo_typst::PdfDocExporter;
Expand Down
6 changes: 3 additions & 3 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use reflexo_typst::error::prelude::*;
use reflexo_typst::exporter_builtins::GroupExporter;
use reflexo_typst::exporter_utils::map_err;
use reflexo_typst::path::{unix_slash, PathClean};
use reflexo_typst::TypstDocument;
use reflexo_typst::TypstPagedDocument;
use reflexo_typst::TypstSystemUniverse;
use typst::{text::FontVariant, World};
use typst_assets::fonts;
Expand Down Expand Up @@ -111,10 +111,10 @@ pub fn query(args: QueryArgs) -> ! {
use typst_ts_cli::query::format;
let compile_args = args.compile.clone();

let mut exporter = GroupExporter::<TypstDocument>::new(vec![]);
let mut exporter = GroupExporter::<TypstPagedDocument>::new(vec![]);

exporter.push_front(Box::new(
move |world: &dyn World, output: Arc<TypstDocument>| {
move |world: &dyn World, output: Arc<TypstPagedDocument>| {
if args.selector == "document_title" {
let title = output
.info
Expand Down
7 changes: 5 additions & 2 deletions crates/conversion/typst2vec/src/incr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl IncrDocServer {
}

/// Pack the delta into a binary blob.
pub fn pack_delta(&mut self, output: Arc<TypstDocument>) -> Vec<u8> {
pub fn pack_delta(&mut self, output: TypstDocument) -> Vec<u8> {
self.typst2vec.spans.reset();

// Increment the lifetime of all items to touch.
Expand All @@ -43,7 +43,10 @@ impl IncrDocServer {
let gc_items = self.typst2vec.gc(5 * 2);

// run typst2vec pass
let pages = self.typst2vec.doc(&output.introspector, &output);
let pages = match output {
TypstDocument::Html(output) => self.typst2vec.html(&output.introspector, &output),
TypstDocument::Paged(output) => self.typst2vec.doc(&output.introspector, &output),
};

// let new_items = builder.new_items.get_mut().len();
// let new_fonts = builder.glyphs.new_fonts.get_mut().len();
Expand Down
Loading

0 comments on commit d604db6

Please sign in to comment.