From 9035cddaad3853b9eccda122f9950f6a011fd578 Mon Sep 17 00:00:00 2001 From: Myriad-Dreamin Date: Sat, 28 Dec 2024 17:30:02 +0800 Subject: [PATCH] fix: typos --- .../typst2vec/src/pass/typst2vec.rs | 4 +- crates/conversion/vec2dom/src/incr.rs | 4 +- crates/conversion/vec2dom/src/svg_backend.rs | 4 +- .../conversion/vec2svg/src/backend/escape.rs | 2 +- crates/conversion/vec2svg/src/backend/mod.rs | 2 +- crates/conversion/vec2svg/src/backend/text.rs | 4 +- .../vec2svg/src/frontend/context.rs | 2 +- crates/reflexo-typst/src/exporter.rs | 8 +- crates/reflexo-vfs/src/notify.rs | 2 +- crates/reflexo-world/src/entry.rs | 2 +- crates/reflexo-world/src/source.rs | 6 +- crates/reflexo/src/escape.rs | 2 +- crates/reflexo/src/vector/incr.rs | 8 +- crates/reflexo/src/vector/ir/color.rs | 2 +- crates/reflexo/src/vector/ir/text.rs | 6 +- docs/cookery/direction/responsive.typ | 6 +- docs/cookery/guide/all-in-one.typ | 8 +- docs/cookery/guide/compiler/service.typ | 2 +- docs/cookery/guide/compiler/ts-cli.typ | 2 +- docs/cookery/guide/renderer/angular.typ | 2 +- docs/cookery/guide/renderer/ts-lib.typ | 2 +- docs/proposals/6-artifact-streaming.typ | 52 +++---- docs/proposals/bytefield.typ | 137 +++++++++++------- packages/renderer/src/worker.rs | 6 +- packages/typst.ts/src/init.mts | 6 +- packages/typst.ts/src/render/canvas/view.mts | 16 +- packages/typst.ts/src/render/svg/patch.mts | 6 +- packages/typst.ts/src/renderer.mts | 6 +- scripts/preview_server.py | 4 +- server/dev/src/lib.rs | 2 +- server/dev/src/main.rs | 2 +- tests/std/src/main.rs | 8 +- 32 files changed, 182 insertions(+), 143 deletions(-) diff --git a/crates/conversion/typst2vec/src/pass/typst2vec.rs b/crates/conversion/typst2vec/src/pass/typst2vec.rs index 5d36484fa..7d40520bc 100644 --- a/crates/conversion/typst2vec/src/pass/typst2vec.rs +++ b/crates/conversion/typst2vec/src/pass/typst2vec.rs @@ -926,7 +926,7 @@ impl Typst2VecPassImpl { format!("@{}", fingerprint.as_svg_id("p")).into() } Paint::Gradient(g) => { - let fingerprint = self.graident(g, mk_transform(g.relative(), true)); + let fingerprint = self.gradient(g, mk_transform(g.relative(), true)); format!("@{}", fingerprint.as_svg_id("g")).into() } } @@ -961,7 +961,7 @@ impl Typst2VecPassImpl { } } - fn graident(&self, g: &Gradient, transform: ir::Transform) -> Fingerprint { + fn gradient(&self, g: &Gradient, transform: ir::Transform) -> Fingerprint { let mut stops = Vec::with_capacity(g.stops_ref().len()); for (c, step) in g.stops_ref() { let [r, g, b, a] = c.to_rgb().to_vec4_u8(); diff --git a/crates/conversion/vec2dom/src/incr.rs b/crates/conversion/vec2dom/src/incr.rs index 26e6c0b3d..7c5341395 100644 --- a/crates/conversion/vec2dom/src/incr.rs +++ b/crates/conversion/vec2dom/src/incr.rs @@ -161,7 +161,7 @@ impl IncrDomDocClient { } STAGE_PREPARE_CANVAS => { if let Some(elem) = page.prepare_canvas(&mut ctx)? { - // explicit drop ctx to avoid async promise cature these variables + // explicit drop ctx to avoid async promise capture these variables drop(ctx); #[cfg(feature = "debug_repaint_canvas")] web_sys::console::log_1(&format!("canvas state prepare: {page_num}").into()); @@ -183,7 +183,7 @@ impl IncrDomDocClient { } } STAGE_CANVAS => { - // explicit drop ctx to avoid async promise cature these variables + // explicit drop ctx to avoid async promise capture these variables drop(ctx); let ppp = self.canvas_backend.pixel_per_pt; let page = &mut self.doc_view[page_num as usize]; diff --git a/crates/conversion/vec2dom/src/svg_backend.rs b/crates/conversion/vec2dom/src/svg_backend.rs index e0057b646..71b0327f5 100644 --- a/crates/conversion/vec2dom/src/svg_backend.rs +++ b/crates/conversion/vec2dom/src/svg_backend.rs @@ -266,9 +266,9 @@ pub static FETCH_BBOX_TIMES: std::sync::atomic::AtomicUsize = static BBOX_SANITIZER: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); impl TypstElem { - /// Repaint svg API will retrun a new viewport if it is updated. + /// Repaint svg API will return a new viewport if it is updated. /// - /// The idea is that: the element visible before will be overrided by the + /// The idea is that: the element visible before will be overridden by the /// latter ones, so we should update the viewport to the union of all /// previous ones and repaint the latter elements accordingly. fn repaint_svg( diff --git a/crates/conversion/vec2svg/src/backend/escape.rs b/crates/conversion/vec2svg/src/backend/escape.rs index d77430a45..69f502f05 100644 --- a/crates/conversion/vec2svg/src/backend/escape.rs +++ b/crates/conversion/vec2svg/src/backend/escape.rs @@ -33,7 +33,7 @@ impl fmt::Display for Escaped<'_, E> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut total_remaining = self.to_escape; - // find the next occurence + // find the next occurrence while let Some(n) = total_remaining.bytes().position(E::byte_needs_escaping) { let (start, remaining) = total_remaining.split_at(n); diff --git a/crates/conversion/vec2svg/src/backend/mod.rs b/crates/conversion/vec2svg/src/backend/mod.rs index 364290281..265712d85 100644 --- a/crates/conversion/vec2svg/src/backend/mod.rs +++ b/crates/conversion/vec2svg/src/backend/mod.rs @@ -158,7 +158,7 @@ impl SvgTextBuilder { upem: Scalar, ) { // upem is the unit per em defined in the font. - // ppem is calcuated by the font size. + // ppem is calculated by the font size. // > ppem = text_size / upem let upem = upem.0; diff --git a/crates/conversion/vec2svg/src/backend/text.rs b/crates/conversion/vec2svg/src/backend/text.rs index 4ad792f6e..01a0cc778 100644 --- a/crates/conversion/vec2svg/src/backend/text.rs +++ b/crates/conversion/vec2svg/src/backend/text.rs @@ -1,4 +1,4 @@ -// #[cfg(feature = "aggresive-browser-optimization")] +// #[cfg(feature = "aggressive-browser-optimization")] // fn f() {} -// #[cfg(not(feature = "aggresive-browser-optimization"))] +// #[cfg(not(feature = "aggressive-browser-optimization"))] // fn f() {} diff --git a/crates/conversion/vec2svg/src/frontend/context.rs b/crates/conversion/vec2svg/src/frontend/context.rs index 06df1016a..6440cf4f2 100644 --- a/crates/conversion/vec2svg/src/frontend/context.rs +++ b/crates/conversion/vec2svg/src/frontend/context.rs @@ -48,7 +48,7 @@ pub struct RenderContext<'m, 't, Feat: ExportFeature> { /// Stores the style definitions used in the document. pub(crate) _style_defs: &'t mut StyleDefMap, - /// Stores the graidents used in the document. + /// Stores the gradients used in the document. pub(crate) gradients: &'t mut PaintFillMap, /// Stores the patterns used in the document. pub(crate) patterns: &'t mut PaintFillMap, diff --git a/crates/reflexo-typst/src/exporter.rs b/crates/reflexo-typst/src/exporter.rs index 28986ab83..b3b861f6b 100644 --- a/crates/reflexo-typst/src/exporter.rs +++ b/crates/reflexo-typst/src/exporter.rs @@ -18,7 +18,7 @@ pub mod text; pub type DynExporter = Box + Send + Sync>; pub trait Transformer { - /// Export the given input with given world. the writable world is hiden by + /// Export the given input with given world. the writable world is hidden by /// trait itself. fn export(&self, world: &dyn World, output: Input) -> SourceResult; } @@ -34,7 +34,7 @@ where } pub trait Exporter { - /// Export the given input with given world. the writable world is hiden by + /// Export the given input with given world. the writable world is hidden by /// trait itself. fn export(&self, world: &dyn World, output: Arc) -> SourceResult; } @@ -68,7 +68,7 @@ pub type DynGenericExporter = pub trait GenericTransformer { type W; - /// Export the given input with given world. the writable world is hiden by + /// Export the given input with given world. the writable world is hidden by /// trait itself. fn export(&self, world: &Self::W, output: Input) -> SourceResult; } @@ -76,7 +76,7 @@ pub trait GenericTransformer { pub trait GenericExporter { type W; - /// Export the given input with given world. the writable world is hiden by + /// Export the given input with given world. the writable world is hidden by /// trait itself. fn export(&self, world: &Self::W, output: Arc) -> SourceResult; } diff --git a/crates/reflexo-vfs/src/notify.rs b/crates/reflexo-vfs/src/notify.rs index b6809eaa8..f652f9f8f 100644 --- a/crates/reflexo-vfs/src/notify.rs +++ b/crates/reflexo-vfs/src/notify.rs @@ -61,7 +61,7 @@ impl FileSnapshot { } } -/// Convenent function to create a [`FileSnapshot`] from tuple +/// Convenient function to create a [`FileSnapshot`] from tuple impl From> for FileSnapshot { fn from(result: FileResult<(crate::Time, Bytes)>) -> Self { Self( diff --git a/crates/reflexo-world/src/entry.rs b/crates/reflexo-world/src/entry.rs index 6cb30ac5f..9978f19de 100644 --- a/crates/reflexo-world/src/entry.rs +++ b/crates/reflexo-world/src/entry.rs @@ -28,7 +28,7 @@ pub trait EntryManager: EntryReader { #[derive(Debug, Clone, Hash, PartialEq, Eq, Default)] pub struct EntryState { - /// The differents is that: if the entry is rooted, the workspace root is + /// The differences is that: if the entry is rooted, the workspace root is /// the parent of the entry file and cannot be used by workspace functions /// like [`EntryState::try_select_path_in_workspace`]. rooted: bool, diff --git a/crates/reflexo-world/src/source.rs b/crates/reflexo-world/src/source.rs index a3afc7c79..12db16ea8 100644 --- a/crates/reflexo-world/src/source.rs +++ b/crates/reflexo-world/src/source.rs @@ -48,9 +48,9 @@ impl Default for SharedState { impl SharedState { fn gc(&mut self) { - let commited = self.committed_revision.unwrap_or(0); + let committed = self.committed_revision.unwrap_or(0); self.cache_entries - .retain(|_, v| commited.saturating_sub(v.last_accessed_rev().get()) <= 30); + .retain(|_, v| committed.saturating_sub(v.last_accessed_rev().get()) <= 30); } } @@ -86,7 +86,7 @@ impl SourceState { // todo: utilize the committed revision is not zero if state .committed_revision - .map_or(false, |commited| commited >= self.revision.get()) + .map_or(false, |committed| committed >= self.revision.get()) { return; } diff --git a/crates/reflexo/src/escape.rs b/crates/reflexo/src/escape.rs index c67c9e453..0f5660a0a 100644 --- a/crates/reflexo/src/escape.rs +++ b/crates/reflexo/src/escape.rs @@ -33,7 +33,7 @@ impl fmt::Display for Escaped<'_, E> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut total_remaining = self.to_escape; - // find the next occurence + // find the next occurrence while let Some(n) = total_remaining.bytes().position(E::byte_needs_escaping) { let (start, remaining) = total_remaining.split_at(n); diff --git a/crates/reflexo/src/vector/incr.rs b/crates/reflexo/src/vector/incr.rs index 7c6c2a1f5..9df1e6809 100644 --- a/crates/reflexo/src/vector/incr.rs +++ b/crates/reflexo/src/vector/incr.rs @@ -17,7 +17,7 @@ pub struct IncrDocClient { /// Optional source mapping data. pub source_mapping_data: Vec, /// Optional page source mapping references. - pub page_source_mappping: LayoutSourceMapping, + pub page_source_mapping: LayoutSourceMapping, } impl IncrDocClient { @@ -33,7 +33,7 @@ impl IncrDocClient { self.source_mapping_data = data; } ModuleMetadata::PageSourceMapping(data) => { - self.page_source_mappping = data.take(); + self.page_source_mapping = data.take(); } _ => {} } @@ -101,14 +101,14 @@ impl<'a> IncrDocClientKern<'a> { const SOURCE_MAPPING_TYPE_SHAPE: u32 = 3; const SOURCE_MAPPING_TYPE_PAGE: u32 = 4; - if self.0.page_source_mappping.is_empty() { + if self.0.page_source_mapping.is_empty() { return Ok(None); } let mut index_item: Option<&SourceMappingNode> = None; let source_mapping = self.0.source_mapping_data.as_slice(); - let page_sources = self.0.page_source_mappping[0] + let page_sources = self.0.page_source_mapping[0] .source_mapping(&self.0.doc.module) .unwrap(); let page_sources = page_sources.source_mapping(); diff --git a/crates/reflexo/src/vector/ir/color.rs b/crates/reflexo/src/vector/ir/color.rs index 5d9d2e5fe..27383034b 100644 --- a/crates/reflexo/src/vector/ir/color.rs +++ b/crates/reflexo/src/vector/ir/color.rs @@ -108,7 +108,7 @@ pub struct GradientItem { pub styles: Vec, } -/// Kind of graidents for [`GradientItem`]. +/// Kind of gradients for [`GradientItem`]. #[derive(Debug, Clone, Hash, PartialEq, Eq)] #[cfg_attr(feature = "rkyv", derive(Archive, rDeser, rSer))] #[cfg_attr(feature = "rkyv-validation", archive(check_bytes))] diff --git a/crates/reflexo/src/vector/ir/text.rs b/crates/reflexo/src/vector/ir/text.rs index 08582eea8..f6cbfdc7c 100644 --- a/crates/reflexo/src/vector/ir/text.rs +++ b/crates/reflexo/src/vector/ir/text.rs @@ -91,12 +91,12 @@ pub struct TextShape { } impl TextShape { - /// ppem is calcuated by the font size. + /// ppem is calculated by the font size. pub fn ppem(&self, upem: f32) -> Scalar { Scalar(self.size.0 / upem) } - /// inv_ppem is calcuated by the font size. + /// inv_ppem is calculated by the font size. pub fn inv_ppem(&self, upem: f32) -> Scalar { Scalar(upem / self.size.0) } @@ -171,7 +171,7 @@ impl TextItem { #[cfg_attr(feature = "rkyv-validation", archive(check_bytes))] pub struct TextItemContent { /// The plain utf-8 content of the text item. - /// Note: witout XML escaping. + /// Note: without XML escaping. pub content: ImmutStr, /// The glyphs in the text. /// (offset, advance, glyph): ([`Abs`], [`Abs`], [`FlatGlyphItem`]) diff --git a/docs/cookery/direction/responsive.typ b/docs/cookery/direction/responsive.typ index 8b89d837f..3af151bd3 100644 --- a/docs/cookery/direction/responsive.typ +++ b/docs/cookery/direction/responsive.typ @@ -25,7 +25,7 @@ in social media. Though it is not implemented, HTML elements is considered for r == Prepare Artifacts: Precompiler Part -As an example, #link("https://github.com/Myriad-Dreamin/typst.ts/blob/main/projects/hexo-renderer-typst/lib/compiler.cjs")[hexo-renderer-typst] utilizes #cross-link("/guide/all-in-one-node.typ")[All-in-one Library for Node.js] to build its functions. First, it creates a dyn layout compiler for precompiling docuemnts: +As an example, #link("https://github.com/Myriad-Dreamin/typst.ts/blob/main/projects/hexo-renderer-typst/lib/compiler.cjs")[hexo-renderer-typst] utilizes #cross-link("/guide/all-in-one-node.typ")[All-in-one Library for Node.js] to build its functions. First, it creates a dyn layout compiler for precompiling documents: ```js this.dyn = DynLayoutCompiler.fromBoxed(NodeCompiler.create(compileArgs).intoBoxed()); @@ -41,7 +41,7 @@ return this.dyn.vector({ mainFilePath: path }); === `x-page-width` (stable) -Retreiving the sys arguments specified by the dynamic layout compiler: +Retrieving the sys arguments specified by the dynamic layout compiler: ```typ /// It is in default A4 paper size (21cm) @@ -63,7 +63,7 @@ Templating Example: *Note: Official typst may introduce their owned method to specify target, therefore this feature may move to the native approach in future.* -Retreiving the sys arguments specified by SSG Tools: +Retrieving the sys arguments specified by SSG Tools: ```typ /// The default target is _pdf_. diff --git a/docs/cookery/guide/all-in-one.typ b/docs/cookery/guide/all-in-one.typ index 223d810bd..2baba9a3e 100644 --- a/docs/cookery/guide/all-in-one.typ +++ b/docs/cookery/guide/all-in-one.typ @@ -28,7 +28,7 @@ console.log((await $typst.svg({ // :-> 7317 ``` -However, it is less flexible and stable than the underlying interfaces, the `TypstCompiler` and `TypstRenderer`. If you've become more familar with typst.ts, we recommend you rewrite your library with underlying interfaces according to example usage shown by the #snippet-lib library. +However, it is less flexible and stable than the underlying interfaces, the `TypstCompiler` and `TypstRenderer`. If you've become more familiar with typst.ts, we recommend you rewrite your library with underlying interfaces according to example usage shown by the #snippet-lib library. Note: If your script targets to *CommonJS*, you should import it in *CommonJS* path instead of In *ES Module* path: @@ -90,7 +90,7 @@ Ideally, you don't have to specify any options. But if necessary, the extra init ```ts // Example: cache default fonts to file system -$typst.setCompilerInitOptions(await cachedFontInitOptoins()); +$typst.setCompilerInitOptions(await cachedFontInitOptions()); // specify init options to renderer $typst.setRendererInitOptions(rendererInitOptions); @@ -126,7 +126,7 @@ $typst.use( Fetch package from remote registry: ```js -const acessModel = cm.FetchAccessModel() or +const accessModel = cm.FetchAccessModel() or cm.MemoryAccessModel() or others; $typst.use( TypstSnippet.fetchPackageRegistry(fetchBackend), @@ -141,7 +141,7 @@ See #link(snippet-source)[comments on source] for more details. See #link("https://github.com/Myriad-Dreamin/typst.ts/blob/main/packages/typst.ts/examples/all-in-one.html")[Preview by all-in-one Library] by a single included file (`all-in-one.bundle.js`). -See #link("https://github.com/Myriad-Dreamin/typst.ts/blob/main/packages/typst.ts/examples/all-in-one-lite.html")[Preview by all-in-one-lite Library] by the more pratical single included file (`all-in-one-lite.bundle.js`), which needs configure your frontend to have access to wasm module files: +See #link("https://github.com/Myriad-Dreamin/typst.ts/blob/main/packages/typst.ts/examples/all-in-one-lite.html")[Preview by all-in-one-lite Library] by the more practical single included file (`all-in-one-lite.bundle.js`), which needs configure your frontend to have access to wasm module files: ```js $typst.setCompilerInitOptions({ diff --git a/docs/cookery/guide/compiler/service.typ b/docs/cookery/guide/compiler/service.typ index 08a5c19a8..4364a3a83 100644 --- a/docs/cookery/guide/compiler/service.typ +++ b/docs/cookery/guide/compiler/service.typ @@ -51,7 +51,7 @@ std::marker::PhantomData.compile( Note: The ```rs struct CompileExporter``` derives #compiler-trait. #linebreak() ] -Retrieve an exporter instance that is executed on each sucessful compilation (more useful for incremental compilation). +Retrieve an exporter instance that is executed on each successful compilation (more useful for incremental compilation). ```ts let driver = CompileExporter::default() diff --git a/docs/cookery/guide/compiler/ts-cli.typ b/docs/cookery/guide/compiler/ts-cli.typ index 59fe0f289..72fb267a7 100644 --- a/docs/cookery/guide/compiler/ts-cli.typ +++ b/docs/cookery/guide/compiler/ts-cli.typ @@ -100,7 +100,7 @@ typst-ts-cli compile ... -o dist === `--trace` option -Comma seperated options to trace execution of typst compiler when compiling documents: +Comma separated options to trace execution of typst compiler when compiling documents: ```bash # trace events at warning level diff --git a/docs/cookery/guide/renderer/angular.typ b/docs/cookery/guide/renderer/angular.typ index 8898fde5f..90658c57f 100644 --- a/docs/cookery/guide/renderer/angular.typ +++ b/docs/cookery/guide/renderer/angular.typ @@ -55,7 +55,7 @@ Render the document with artifact from precompiler. === Set renderer initialization option for `typst-document` -Retrieve a #term.init-option for initializating the renderer for `typst-document` +Retrieve a #term.init-option for initializing the renderer for `typst-document` ```ts typst-document.setWasmModuleInitOptions({ diff --git a/docs/cookery/guide/renderer/ts-lib.typ b/docs/cookery/guide/renderer/ts-lib.typ index 6a51e862e..a76e6e194 100644 --- a/docs/cookery/guide/renderer/ts-lib.typ +++ b/docs/cookery/guide/renderer/ts-lib.typ @@ -88,6 +88,6 @@ See the sample application #link("https://github.com/Myriad-Dreamin/typst.ts/blo == Use `RenderSession` APIs -Full exmaple: #link("https://github.com/Enter-tainer/typst-preview/tree/110c031d21e74f747f78fbf78934140d23fec267/addons/frontend")[typst-preview-frontend] +Full example: #link("https://github.com/Enter-tainer/typst-preview/tree/110c031d21e74f747f78fbf78934140d23fec267/addons/frontend")[typst-preview-frontend] See #renderer-lib for more details. diff --git a/docs/proposals/6-artifact-streaming.typ b/docs/proposals/6-artifact-streaming.typ index 157792915..4e7d1b2ec 100644 --- a/docs/proposals/6-artifact-streaming.typ +++ b/docs/proposals/6-artifact-streaming.typ @@ -14,7 +14,7 @@ The Compiler and Renderer always keep a consistent state regarding to the artifa The artifact is considered to break into following three parts, which are transferred by different strategies. -- Full content: A subset of artifact data which does not affect the performance a lot is transferred by full content strategy, such as the source mappping. +- Full content: A subset of artifact data which does not affect the performance a lot is transferred by full content strategy, such as the source mapping. - Tree patching: A subset of the artifact which is in tree shape is transferred by tree patching strategy, such as the `typst::doc::Frame` (`SvgItem`). @@ -26,7 +26,7 @@ When there is no server available, a (Pre) Compiler can still calculate the diff - frame difference between different themes but over a same document will be preprocess using #link()[tree pathcing]. -- document related font data could be shooted once when user first open the document, but the client could also preload font data by a determinsitic #link()[range partition] for most likely accessed document. +- document related font data could be shooted once when user first open the document, but the client could also preload font data by a deterministic #link()[range partition] for most likely accessed document. == Possible implementation @@ -34,42 +34,42 @@ A server that holds *entire current artifact data*, and also state of incrementa ```rust /// maintains the state of the incremental compiling at server side -#[derive(Default)] -pub struct IncrSvgDocServer { - /// Whether to attach debug info to the output. - should_attach_debug_info: bool, +#[derive(Default)] +pub struct IncrSvgDocServer { + /// Whether to attach debug info to the output. + should_attach_debug_info: bool, - /// Expected exact state of the current Compiler. - /// Initially it is None meaning no completed compilation. - doc_view: Option, + /// Expected exact state of the current Compiler. + /// Initially it is None meaning no completed compilation. + doc_view: Option, - /// Maintaining document build status - module_builder: IncrModuleBuilder, + /// Maintaining document build status + module_builder: IncrModuleBuilder, - /// Optional page source mapping references. - page_source_mapping: Vec, -} + /// Optional page source mapping references. + page_source_mapping: Vec, +} ``` A client that holds *entire current artifact data*, and also state of typst document in DOM (UI State). ```rust -/// maintains the state of the incremental rendering at client side -#[derive(Default)] -pub struct IncrSvgDocClient { - /// Full information of the current document from server. +/// maintains the state of the incremental rendering at client side +#[derive(Default)] +pub struct IncrSvgDocClient { + /// Full information of the current document from server. pub doc_view: SvgDocument, - /// Optional page source mapping references. - pub page_source_mappping: Vec, + /// Optional page source mapping references. + pub page_source_mapping: Vec, - /// Expected exact state of the current DOM. - /// Initially it is None meaning no any page is rendered. + /// Expected exact state of the current DOM. + /// Initially it is None meaning no any page is rendered. pub dom_doc_view: Option, - /// Glyphs that has already committed to the DOM. - pub dom_glyph_status: GlyphStatus, -} + /// Glyphs that has already committed to the DOM. + pub dom_glyph_status: GlyphStatus, +} ``` The server and client will communicate with each other by sending the differences between the current artifact and the expected artifact. The differences are in the form of `ArtifactDiff` which is defined as following: @@ -110,4 +110,4 @@ pub async fn main() { cli.await.unwrap(); } -``` \ No newline at end of file +``` diff --git a/docs/proposals/bytefield.typ b/docs/proposals/bytefield.typ index bc565b37a..71e422b46 100644 --- a/docs/proposals/bytefield.typ +++ b/docs/proposals/bytefield.typ @@ -1,3 +1,4 @@ + // Bytefield - generate protocol headers and more // Feel free to contribute with any features you think are missing. // Still a WIP - alpha stage and a bit hacky at the moment @@ -6,10 +7,10 @@ #set text(font: "IBM Plex Mono") #let bfcell( - len, // lenght of the fields in bits - content, + len, // length of the fields in bits + content, fill: none, // color to fill the field - height: auto // height of the field + height: auto, // height of the field ) = cellx(colspan: len, fill: fill, inset: 0pt)[#box(height: height, width: 100%, stroke: 1pt + black)[#content]] @@ -20,9 +21,9 @@ // calculate cells for (idx, field) in fields.pos().enumerate() { - let (size, content, fill, ..) = field; - let remaining_cols = bits - col_count; - col_count = calc.rem(col_count + size, bits); + let (size, content, fill, ..) = field + let remaining_cols = bits - col_count + col_count = calc.rem(col_count + size, bits) // if no size was specified if size == none { size = remaining_cols @@ -30,26 +31,25 @@ } if size > bits and remaining_cols == bits and calc.rem(size, bits) == 0 { content = content + " (" + str(size) + " Bit)" - cells.push(bfcell(int(bits),fill:fill, height: rowheight * size/bits)[#content]) + cells.push(bfcell(int(bits), fill: fill, height: rowheight * size / bits)[#content]) size = 0 } while size > 0 { - let width = calc.min(size, remaining_cols); + let width = calc.min(size, remaining_cols) size -= remaining_cols remaining_cols = bits - cells.push(bfcell(int(width),fill:fill, height: rowheight,)[#content]) + cells.push(bfcell(int(width), fill: fill, height: rowheight)[#content]) } - } - bitheader = if bitheader == auto { - range(bits).map(i => if calc.rem(i,8) == 0 or i == (bits - 1) { text(9pt)[#i] } else { none }) + bitheader = if bitheader == auto { + range(bits).map(i => if calc.rem(i, 8) == 0 or i == (bits - 1) { text(9pt)[#i] } else { none }) } else if bitheader != none { assert(type(bitheader) == "array", message: "header must be an array or none") - range(bits).map(i => if i in bitheader { text(9pt)[#i] } else {none}) + range(bits).map(i => if i in bitheader { text(9pt)[#i] } else { none }) } - + box(width: 100%)[ //#show grid: set block(below: 0pt) #gridx( @@ -65,10 +65,10 @@ // Low level API #let bitbox(length_in_bits, content, fill: none) = ( type: "bitbox", - size: length_in_bits, // length of the field + size: length_in_bits, // length of the field fill: fill, content: content, - var: false, + var: false, show_size: false, ) @@ -80,42 +80,62 @@ #let padding(..args) = bitbox(none, ..args) // Rotating text for flags -#let flagtext(text) = align(end,pad(-3pt,rotate(270deg,text))) +#let flagtext(text) = align(end, pad(-3pt, rotate(270deg, text))) // Common network protocols #let ipv4 = bytefield( - bits(4)[Version], bits(4)[TTL], bytes(1)[TOS], bytes(2)[Total Length], - bytes(2)[Identification], bits(3)[Flags], bits(13)[Fragment Offset], - bytes(1)[TTL], bytes(1)[Protocol], bytes(2)[Header Checksum], + bits(4)[Version], + bits(4)[TTL], + bytes(1)[TOS], + bytes(2)[Total Length], + bytes(2)[Identification], + bits(3)[Flags], + bits(13)[Fragment Offset], + bytes(1)[TTL], + bytes(1)[Protocol], + bytes(2)[Header Checksum], bytes(4)[Source Address], bytes(4)[Destination Address], - bytes(3)[Options], bytes(1)[Padding] + bytes(3)[Options], + bytes(1)[Padding], ) #let ipv6 = bytefield( - bits(4)[Version], bytes(1)[Traffic Class], bits(20)[Flowlabel], - bytes(2)[Payload Length], bytes(1)[Next Header], bytes(1)[Hop Limit], - bytes(128/8)[Source Address], - bytes(128/8)[Destination Address], + bits(4)[Version], + bytes(1)[Traffic Class], + bits(20)[Flowlabel], + bytes(2)[Payload Length], + bytes(1)[Next Header], + bytes(1)[Hop Limit], + bytes(128 / 8)[Source Address], + bytes(128 / 8)[Destination Address], ) #let icmp = bytefield( - header: (0,8,16,31), - byte[Type], byte[Code], bytes(2)[Checksum], - bytes(2)[Identifier], bytes(2)[Sequence Number], - padding[Optional Data ] + header: (0, 8, 16, 31), + byte[Type], + byte[Code], + bytes(2)[Checksum], + bytes(2)[Identifier], + bytes(2)[Sequence Number], + padding[Optional Data ], ) #let icmpv6 = bytefield( - header: (0,8,16,31), - byte[Type], byte[Code], bytes(2)[Checksum], - padding[Internet Header + 64 bits of Original Data Datagram ] + header: (0, 8, 16, 31), + byte[Type], + byte[Code], + bytes(2)[Checksum], + padding[Internet Header + 64 bits of Original Data Datagram ], ) #let dns = bytefield( - bytes(2)[Identification], bytes(2)[Flags], - bytes(2)[Number of Questions], bytes(2)[Number of answer RRs], - bytes(2)[Number of authority RRs], bytes(2)[Number of additional RRs], + bytes(2)[Identification], + bytes(2)[Flags], + bytes(2)[Number of Questions], + bytes(2)[Number of answer RRs], + bytes(2)[Number of authority RRs], + bytes(2)[Number of additional RRs], bytes(8)[Questions], bytes(8)[Answers (variable number of resource records) ], bytes(8)[Authority (variable number of resource records) ], @@ -123,30 +143,49 @@ ) #let tcp = bytefield( - bytes(2)[Source Port], bytes(2)[ Destinatino Port], + bytes(2)[Source Port], + bytes(2)[ Destination Port], bytes(4)[Sequence Number], bytes(4)[Acknowledgment Number], - bits(4)[Data Offset],bits(6)[Reserved], bits(6)[Flags], bytes(2)[Window], - bytes(2)[Checksum], bytes(2)[Urgent Pointer], - bytes(3)[Options], byte[Padding], - padding[...DATA...] + bits(4)[Data Offset], + bits(6)[Reserved], + bits(6)[Flags], + bytes(2)[Window], + bytes(2)[Checksum], + bytes(2)[Urgent Pointer], + bytes(3)[Options], + byte[Padding], + padding[...DATA...], ) #let tcp_detailed = bytefield( - bytes(2)[Source Port], bytes(2)[ Destinatino Port], + bytes(2)[Source Port], + bytes(2)[ Destination Port], bytes(4)[Sequence Number], bytes(4)[Acknowledgment Number], - bits(4)[Data Offset],bits(6)[Reserved], bit[#flagtext("URG")], bit[#flagtext("ACK")], bit[#flagtext("PSH")], bit[#flagtext("RST")], bit[#flagtext("SYN")], bit[#flagtext("FIN")], bytes(2)[Window], - bytes(2)[Checksum], bytes(2)[Urgent Pointer], - bytes(3)[Options], byte[Padding], - padding[...DATA...] + bits(4)[Data Offset], + bits(6)[Reserved], + bit[#flagtext("URG")], + bit[#flagtext("ACK")], + bit[#flagtext("PSH")], + bit[#flagtext("RST")], + bit[#flagtext("SYN")], + bit[#flagtext("FIN")], + bytes(2)[Window], + bytes(2)[Checksum], + bytes(2)[Urgent Pointer], + bytes(3)[Options], + byte[Padding], + padding[...DATA...], ) #let udp = bytefield( - bitheader: (0,16,31), - bytes(2)[Source Port], bytes(2)[ Destinatino Port], - bytes(2)[Length], bytes(2)[Checksum], - padding[...DATA...] + bitheader: (0, 16, 31), + bytes(2)[Source Port], + bytes(2)[ Destination Port], + bytes(2)[Length], + bytes(2)[Checksum], + padding[...DATA...], ) diff --git a/packages/renderer/src/worker.rs b/packages/renderer/src/worker.rs index d69b9d734..14286f06e 100644 --- a/packages/renderer/src/worker.rs +++ b/packages/renderer/src/worker.rs @@ -459,7 +459,7 @@ pub struct WorkerBridge { pub(crate) sessions: HashMap>>, pub(crate) canvases: HashMap>, pub(crate) previous_promise: Option, - pub(crate) sesions: i32, + pub(crate) sessions: i32, } #[wasm_bindgen] @@ -480,8 +480,8 @@ impl WorkerBridge { let res = match x { Request::CreateSession(opts) => { let session = self.plugin.create_session(opts).unwrap(); - let idx = self.sesions; - self.sesions += 1; + let idx = self.sessions; + self.sessions += 1; #[allow(clippy::arc_with_non_send_sync)] self.sessions.insert(idx, Arc::new(Mutex::new(session))); Ok(JsValue::from_f64(idx as f64)) diff --git a/packages/typst.ts/src/init.mts b/packages/typst.ts/src/init.mts index 39c806a9b..e4df4dbfe 100644 --- a/packages/typst.ts/src/init.mts +++ b/packages/typst.ts/src/init.mts @@ -44,7 +44,7 @@ async function addPartialFonts({ builder, hooks }: InitContext): Promise { const postscriptName = font.postscriptName; @@ -61,7 +61,7 @@ async function addPartialFonts({ builder, hooks }: InitContext): Promise({ builder, hooks }: InitContext): Promise { console.log(this, font, idx); if (readyBuffer) { diff --git a/packages/typst.ts/src/render/canvas/view.mts b/packages/typst.ts/src/render/canvas/view.mts index 48ce75468..0aa25faee 100644 --- a/packages/typst.ts/src/render/canvas/view.mts +++ b/packages/typst.ts/src/render/canvas/view.mts @@ -64,17 +64,17 @@ export class RenderView { /// on width change const containerWidth = container.offsetWidth; - const orignalScale = containerWidth / pageAst.width; + const originalScale = containerWidth / pageAst.width; textLayerParent.style.width = `${containerWidth}px`; - textLayerParent.style.height = `${pageAst.height * orignalScale}px`; + textLayerParent.style.height = `${pageAst.height * originalScale}px`; // --data-text-width - textLayerParent.style.setProperty('--data-text-width', `${orignalScale}px`); - textLayerParent.style.setProperty('--data-text-height', `${orignalScale}px`); + textLayerParent.style.setProperty('--data-text-width', `${originalScale}px`); + textLayerParent.style.setProperty('--data-text-height', `${originalScale}px`); // textLayerParent.style.position = 'absolute'; commonDiv.classList.add('typst-page'); commonDiv.classList.add('canvas'); commonDiv.style.width = `${containerWidth}px`; - commonDiv.style.height = `${height * orignalScale}px`; + commonDiv.style.height = `${height * originalScale}px`; commonDiv.style.position = 'relative'; // textLayerParent.style.zIndex = '1'; @@ -113,11 +113,11 @@ export class RenderView { /// on width change const containerWidth = this.container.offsetWidth; - const orignalScale = containerWidth / width; + const originalScale = containerWidth / width; textLayerParent.style.width = `${containerWidth}px`; - textLayerParent.style.height = `${height * orignalScale}px`; + textLayerParent.style.height = `${height * originalScale}px`; commonDiv.style.width = `${containerWidth}px`; - commonDiv.style.height = `${height * orignalScale}px`; + commonDiv.style.height = `${height * originalScale}px`; // compute scaling factor according to the paper size const currentScale = this.container.offsetWidth / width; diff --git a/packages/typst.ts/src/render/svg/patch.mts b/packages/typst.ts/src/render/svg/patch.mts index ad53e74d9..458ab924a 100644 --- a/packages/typst.ts/src/render/svg/patch.mts +++ b/packages/typst.ts/src/render/svg/patch.mts @@ -450,15 +450,15 @@ function reuseOrPatchElem(prev: SVGGElement, next: SVGGElement) { return false /* reused */; function replaceNonSVGElements(prev: Element, next: Element) { - const removedIndecies: number[] = []; + const removedIndices: number[] = []; for (let i = 0; i < prev.children.length; i++) { const prevChild = prev.children[i]; if (!isGElem(prevChild)) { - removedIndecies.push(i); + removedIndices.push(i); } } - for (const index of removedIndecies.reverse()) { + for (const index of removedIndices.reverse()) { prev.children[index].remove(); } diff --git a/packages/typst.ts/src/renderer.mts b/packages/typst.ts/src/renderer.mts index af43b4ffc..534a0e350 100644 --- a/packages/typst.ts/src/renderer.mts +++ b/packages/typst.ts/src/renderer.mts @@ -373,7 +373,7 @@ export interface TypstRenderer extends TypstSvgRenderer { resetSession(session: RenderSession): void; /** - * Retreive page information of current selected document + * Retrieve page information of current selected document */ retrievePagesInfoFromSession(session: RenderSession): PageInfo[]; @@ -475,7 +475,7 @@ export interface TypstRenderer extends TypstSvgRenderer { manipulateData(opts: RenderInSessionOptions): void; /** - * Run a function with a session, and the sesssion is only available during + * Run a function with a session, and the session is only available during * the function call. * * the lifetime of session is quite bug-prone, so we current does not make it @@ -861,7 +861,7 @@ export class TypstRendererDriver { ); const t2 = performance.now(); - console.log(`layer used: retieve = ${(t2 - t).toFixed(1)}ms`); + console.log(`layer used: retrieve = ${(t2 - t).toFixed(1)}ms`); await doRenderDisplayLayer(pageView.canvasList, () => pageView.resetLayout()); this.renderTextLayer(pageView.textLayerList, renderPageResults); diff --git a/scripts/preview_server.py b/scripts/preview_server.py index 4a18347ab..af37ebd53 100644 --- a/scripts/preview_server.py +++ b/scripts/preview_server.py @@ -5,7 +5,7 @@ import re def server_main(): - class FrontEndHanlder(http.server.SimpleHTTPRequestHandler): + class FrontEndHandler(http.server.SimpleHTTPRequestHandler): def __init__(self, *args, **kwargs): kwargs['directory'] = '.' @@ -37,7 +37,7 @@ def do_GET(self) -> None: super().do_GET() - http.server.ThreadingHTTPServer(('127.0.0.1', 20812), FrontEndHanlder).serve_forever() + http.server.ThreadingHTTPServer(('127.0.0.1', 20812), FrontEndHandler).serve_forever() if __name__ == '__main__': diff --git a/server/dev/src/lib.rs b/server/dev/src/lib.rs index 5007350ba..f1b8bb2e2 100644 --- a/server/dev/src/lib.rs +++ b/server/dev/src/lib.rs @@ -64,7 +64,7 @@ pub enum CompileSubCommands { pub struct CompileCorpusArgs { /// The name of Corpus. #[clap(long = "cat", value_name = "CAT", value_delimiter = ',', action = ArgAction::Append)] - pub catergories: Vec, + pub categories: Vec, /// Output formats. #[clap(long)] diff --git a/server/dev/src/main.rs b/server/dev/src/main.rs index 14d05e4bc..d204352b6 100644 --- a/server/dev/src/main.rs +++ b/server/dev/src/main.rs @@ -101,7 +101,7 @@ fn compile_corpus(args: CompileCorpusArgs) { // get all corpus in workspace_path - for cat in args.catergories.clone() { + for cat in args.categories.clone() { info!("compile corpus in {cat}..."); let cat_dir = corpus_path.join(&cat); diff --git a/tests/std/src/main.rs b/tests/std/src/main.rs index 12e5ff2b7..7a413e6ab 100644 --- a/tests/std/src/main.rs +++ b/tests/std/src/main.rs @@ -9,10 +9,10 @@ static PRESET_HEADER: &str = r#" "#; fn main() -> anyhow::Result<()> { - let mainfest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); - let test_dir = &mainfest_dir.join("../../../typst/tests/typ"); - let rewrite_dir = mainfest_dir.join("../../fuzzers/corpora"); - let std_artifact_path = mainfest_dir.join("../../tests/common/src/std_artifact.rs"); + let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); + let test_dir = &manifest_dir.join("../../../typst/tests/typ"); + let rewrite_dir = manifest_dir.join("../../fuzzers/corpora"); + let std_artifact_path = manifest_dir.join("../../tests/common/src/std_artifact.rs"); let mut test_files = WalkDir::new(test_dir) .into_iter()