Compare commits
7 commits
dependabot
...
master
Author | SHA1 | Date | |
---|---|---|---|
9d7852c4f9 | |||
71292fea36 | |||
447894d23f | |||
abf568b117 | |||
00b46a278a | |||
2ebd47dbea | |||
e255c57f39 |
10
.github/dependabot.yml
vendored
10
.github/dependabot.yml
vendored
|
@ -1,16 +1,8 @@
|
||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
- package-ecosystem: cargo
|
- package-ecosystem: cargo
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: weekly
|
interval: weekly
|
||||||
time: "09:00"
|
time: "09:00"
|
||||||
open-pull-requests-limit: 10
|
open-pull-requests-limit: 10
|
||||||
ignore:
|
|
||||||
- dependency-name: pretty_assertions
|
|
||||||
versions:
|
|
||||||
- 0.7.1
|
|
||||||
- dependency-name: nom
|
|
||||||
versions:
|
|
||||||
- 6.1.0
|
|
||||||
- 6.1.1
|
|
||||||
|
|
10
.github/workflows/rust.yml
vendored
10
.github/workflows/rust.yml
vendored
|
@ -1,17 +1,13 @@
|
||||||
name: Rust
|
name: Rust
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
format:
|
format:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Run rustfmt
|
- name: Run rustfmt
|
||||||
run: cargo fmt -- --check
|
run: cargo fmt -- --check
|
||||||
|
@ -20,7 +16,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
- name: Install Rust toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
|
|
34
.github/workflows/wasm.yml
vendored
Normal file
34
.github/workflows/wasm.yml
vendored
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
name: Wasm
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: wasm
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: "14"
|
||||||
|
|
||||||
|
- name: Install
|
||||||
|
run: |
|
||||||
|
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
||||||
|
yarn
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
wasm-pack build --target web --out-dir wasm/pkg -- --features wasm
|
||||||
|
yarn build
|
||||||
|
|
||||||
|
- name: Deploy to gh pages
|
||||||
|
uses: JamesIves/github-pages-deploy-action@4.1.5
|
||||||
|
with:
|
||||||
|
branch: gh-pages
|
||||||
|
folder: wasm/lib
|
44
Cargo.toml
44
Cargo.toml
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "orgize"
|
name = "orgize"
|
||||||
version = "0.8.4"
|
version = "0.9.0"
|
||||||
authors = ["PoiScript <poiscript@gmail.com>"]
|
authors = ["PoiScript <poiscript@gmail.com>"]
|
||||||
description = "A Rust library for parsing orgmode files."
|
description = "A Rust library for parsing orgmode files."
|
||||||
repository = "https://github.com/PoiScript/orgize"
|
repository = "https://github.com/PoiScript/orgize"
|
||||||
|
@ -8,6 +8,7 @@ readme = "README.md"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
keywords = ["orgmode", "emacs", "parser"]
|
keywords = ["orgmode", "emacs", "parser"]
|
||||||
|
exclude = ["/wasm", "/.github"]
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
@ -15,25 +16,36 @@ all-features = true
|
||||||
[badges]
|
[badges]
|
||||||
travis-ci = { repository = "PoiScript/orgize" }
|
travis-ci = { repository = "PoiScript/orgize" }
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
# Tell `rustc` to optimize for small code size.
|
||||||
|
opt-level = "s"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["ser"]
|
default = ["ser"]
|
||||||
|
wasm = ["serde-wasm-bindgen", "wasm-bindgen", "wee_alloc"]
|
||||||
ser = ["serde", "serde_indextree", "indexmap/serde-1"]
|
ser = ["serde", "serde_indextree", "indexmap/serde-1"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bytecount = "0.6.0"
|
bytecount = "0.6"
|
||||||
chrono = { version = "0.4.11", optional = true }
|
chrono = { version = "0.4", optional = true }
|
||||||
indextree = "4.0.0"
|
indextree = "4.3"
|
||||||
jetscii = "0.4.4"
|
jetscii = "0.5"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4"
|
||||||
memchr = "2.3.3"
|
memchr = "2.4"
|
||||||
# we don't need to parse any float number, so lexical crate is redundant
|
nom = { version = "7.0", default-features = false, features = ["std"] }
|
||||||
nom = { version = "5.1.1", default-features = false, features = ["std"] }
|
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||||
serde = { version = "1.0.106", optional = true, features = ["derive"] }
|
serde_indextree = { version = "0.2", optional = true }
|
||||||
serde_indextree = { version = "0.2.0", optional = true }
|
syntect = { version = "4.6", optional = true }
|
||||||
syntect = { version = "4.1.0", optional = true }
|
indexmap = { version = "1.7", features = ["serde-1"], optional = true }
|
||||||
indexmap = { version = "1.3.2", features = ["serde-1"], optional = true}
|
# wasm stuff
|
||||||
|
serde-wasm-bindgen = { version = "0.3", optional = true }
|
||||||
|
wasm-bindgen = { version = "0.2", optional = true }
|
||||||
|
wee_alloc = { version = "0.4", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_assertions = "0.6.1"
|
pretty_assertions = "1.0"
|
||||||
serde_json = "1.0.51"
|
serde_json = "1.0"
|
||||||
slugify = "0.1.0"
|
slugify = "0.1"
|
||||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2019-2020 Alex Lin (poi)
|
Copyright (c) 2019-2021 Alex Lin (poi)
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -50,7 +50,7 @@ pub use self::{
|
||||||
table::{Table, TableCell, TableRow},
|
table::{Table, TableCell, TableRow},
|
||||||
target::Target,
|
target::Target,
|
||||||
timestamp::{Datetime, Timestamp},
|
timestamp::{Datetime, Timestamp},
|
||||||
title::Title,
|
title::{PropertiesMap, Title},
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
//! Headline Title
|
//! Headline Title
|
||||||
|
|
||||||
#[cfg(not(feature = "indexmap"))]
|
use std::collections::HashMap;
|
||||||
pub type PropertiesMap<K, V> = std::collections::HashMap<K, V>;
|
use std::{borrow::Cow, iter::FromIterator};
|
||||||
|
|
||||||
#[cfg(feature = "indexmap")]
|
|
||||||
pub type PropertiesMap<K, V> = indexmap::IndexMap<K, V>;
|
|
||||||
|
|
||||||
use std::borrow::Cow;
|
|
||||||
|
|
||||||
use memchr::memrchr2;
|
use memchr::memrchr2;
|
||||||
use nom::{
|
use nom::{
|
||||||
|
@ -52,7 +47,7 @@ pub struct Title<'a> {
|
||||||
feature = "ser",
|
feature = "ser",
|
||||||
serde(skip_serializing_if = "PropertiesMap::is_empty")
|
serde(skip_serializing_if = "PropertiesMap::is_empty")
|
||||||
)]
|
)]
|
||||||
pub properties: PropertiesMap<Cow<'a, str>, Cow<'a, str>>,
|
pub properties: PropertiesMap<'a>,
|
||||||
/// Numbers of blank lines between last title's line and next non-blank line
|
/// Numbers of blank lines between last title's line and next non-blank line
|
||||||
/// or buffer's end
|
/// or buffer's end
|
||||||
pub post_blank: usize,
|
pub post_blank: usize,
|
||||||
|
@ -107,11 +102,7 @@ impl Title<'_> {
|
||||||
keyword: self.keyword.map(Into::into).map(Cow::Owned),
|
keyword: self.keyword.map(Into::into).map(Cow::Owned),
|
||||||
raw: self.raw.into_owned().into(),
|
raw: self.raw.into_owned().into(),
|
||||||
planning: self.planning.map(|p| Box::new(p.into_owned())),
|
planning: self.planning.map(|p| Box::new(p.into_owned())),
|
||||||
properties: self
|
properties: self.properties.into_owned(),
|
||||||
.properties
|
|
||||||
.into_iter()
|
|
||||||
.map(|(k, v)| (k.into_owned().into(), v.into_owned().into()))
|
|
||||||
.collect(),
|
|
||||||
post_blank: self.post_blank,
|
post_blank: self.post_blank,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,6 +123,60 @@ impl Default for Title<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Properties
|
||||||
|
#[derive(Default, Debug, Clone)]
|
||||||
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
|
pub struct PropertiesMap<'a> {
|
||||||
|
pub pairs: Vec<(Cow<'a, str>, Cow<'a, str>)>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> PropertiesMap<'a> {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
PropertiesMap { pairs: Vec::new() }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.pairs.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn iter(&self) -> impl Iterator<Item = &(Cow<'a, str>, Cow<'a, str>)> {
|
||||||
|
self.pairs.iter()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut (Cow<'a, str>, Cow<'a, str>)> {
|
||||||
|
self.pairs.iter_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn into_iter(self) -> impl Iterator<Item = (Cow<'a, str>, Cow<'a, str>)> {
|
||||||
|
self.pairs.into_iter()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn into_hash_map(self) -> HashMap<Cow<'a, str>, Cow<'a, str>> {
|
||||||
|
self.pairs.into_iter().collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "indexmap")]
|
||||||
|
pub fn into_index_map(self) -> indexmap::IndexMap<Cow<'a, str>, Cow<'a, str>> {
|
||||||
|
self.pairs.into_iter().collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn into_owned(self) -> PropertiesMap<'static> {
|
||||||
|
self.pairs
|
||||||
|
.into_iter()
|
||||||
|
.map(|(k, v)| (k.into_owned().into(), v.into_owned().into()))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> FromIterator<(Cow<'a, str>, Cow<'a, str>)> for PropertiesMap<'a> {
|
||||||
|
fn from_iter<T: IntoIterator<Item = (Cow<'a, str>, Cow<'a, str>)>>(iter: T) -> Self {
|
||||||
|
let mut map = PropertiesMap::new();
|
||||||
|
map.pairs.extend(iter);
|
||||||
|
map
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn white_spaces_or_eol(input: &str) -> IResult<&str, &str, ()> {
|
fn white_spaces_or_eol(input: &str) -> IResult<&str, &str, ()> {
|
||||||
alt((space1, line_ending))(input)
|
alt((space1, line_ending))(input)
|
||||||
}
|
}
|
||||||
|
@ -212,18 +257,16 @@ fn is_tag_line(input: &str) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn parse_properties_drawer(
|
fn parse_properties_drawer(input: &str) -> IResult<&str, PropertiesMap<'_>, ()> {
|
||||||
input: &str,
|
|
||||||
) -> IResult<&str, PropertiesMap<Cow<'_, str>, Cow<'_, str>>, ()> {
|
|
||||||
let (input, (drawer, content)) = parse_drawer_without_blank(input.trim_start())?;
|
let (input, (drawer, content)) = parse_drawer_without_blank(input.trim_start())?;
|
||||||
if drawer.name != "PROPERTIES" {
|
if drawer.name != "PROPERTIES" {
|
||||||
return Err(Err::Error(make_error(input, ErrorKind::Tag)));
|
return Err(Err::Error(make_error(input, ErrorKind::Tag)));
|
||||||
}
|
}
|
||||||
let (_, map) = fold_many0(
|
let (_, map) = fold_many0(
|
||||||
parse_node_property,
|
parse_node_property,
|
||||||
PropertiesMap::new(),
|
PropertiesMap::new,
|
||||||
|mut acc: PropertiesMap<_, _>, (name, value)| {
|
|mut acc: PropertiesMap, (name, value)| {
|
||||||
acc.insert(name.into(), value.into());
|
acc.pairs.push((name.into(), value.into()));
|
||||||
acc
|
acc
|
||||||
},
|
},
|
||||||
)(content)?;
|
)(content)?;
|
||||||
|
@ -461,20 +504,21 @@ fn parse_properties_drawer_() {
|
||||||
"",
|
"",
|
||||||
vec![("CUSTOM_ID".into(), "id".into())]
|
vec![("CUSTOM_ID".into(), "id".into())]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect::<PropertiesMap<_, _>>()
|
.collect::<PropertiesMap>()
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg(feature = "indexmap")]
|
||||||
fn preserve_properties_drawer_order() {
|
fn preserve_properties_drawer_order() {
|
||||||
let mut properties = Vec::default();
|
let mut vec = Vec::default();
|
||||||
// Use a large number of properties to reduce false pass rate, since HashMap
|
// Use a large number of properties to reduce false pass rate, since HashMap
|
||||||
// is non-deterministic. There are roughly 10^18 possible derangements of this sequence.
|
// is non-deterministic. There are roughly 10^18 possible derangements of this sequence.
|
||||||
for i in 0..20 {
|
for i in 0..20 {
|
||||||
// Avoid alphabetic or numeric order.
|
// Avoid alphabetic or numeric order.
|
||||||
let j = (i + 7) % 20;
|
let j = (i + 7) % 20;
|
||||||
properties.push((
|
vec.push((
|
||||||
Cow::Owned(format!(
|
Cow::Owned(format!(
|
||||||
"{}{}",
|
"{}{}",
|
||||||
if i % 3 == 0 {
|
if i % 3 == 0 {
|
||||||
|
@ -491,20 +535,17 @@ fn preserve_properties_drawer_order() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut s = String::default();
|
let mut s = String::default();
|
||||||
for (k, v) in &properties {
|
|
||||||
|
for (k, v) in &vec {
|
||||||
s += &format!(" :{}: {}\n", k, v);
|
s += &format!(" :{}: {}\n", k, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
let drawer = format!(" :PROPERTIES:\n{}:END:\n", &s);
|
let drawer = format!(" :PROPERTIES:\n{}:END:\n", &s);
|
||||||
let mut parsed: Vec<(_, _)> = parse_properties_drawer(&drawer)
|
|
||||||
.unwrap()
|
|
||||||
.1
|
|
||||||
.into_iter()
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
#[cfg(not(feature = "indexmap"))]
|
let map = parse_properties_drawer(&drawer).unwrap().1.into_index_map();
|
||||||
parsed.sort();
|
|
||||||
#[cfg(not(feature = "indexmap"))]
|
|
||||||
properties.sort();
|
|
||||||
|
|
||||||
assert_eq!(parsed, properties);
|
// indexmap should be in the same order as vector
|
||||||
|
for (left, right) in vec.iter().zip(map) {
|
||||||
|
assert_eq!(left, &right);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,7 @@ impl OrgHandler<Error> for DefaultOrgHandler {
|
||||||
}
|
}
|
||||||
if !title.properties.is_empty() {
|
if !title.properties.is_empty() {
|
||||||
writeln!(&mut w, ":PROPERTIES:")?;
|
writeln!(&mut w, ":PROPERTIES:")?;
|
||||||
for (key, value) in &title.properties {
|
for (key, value) in title.properties.iter() {
|
||||||
writeln!(&mut w, ":{}: {}", key, value)?;
|
writeln!(&mut w, ":{}: {}", key, value)?;
|
||||||
}
|
}
|
||||||
writeln!(&mut w, ":END:")?;
|
writeln!(&mut w, ":END:")?;
|
||||||
|
|
|
@ -240,3 +240,6 @@ pub use elements::Element;
|
||||||
pub use headline::{Document, Headline};
|
pub use headline::{Document, Headline};
|
||||||
pub use org::{Event, Org};
|
pub use org::{Event, Org};
|
||||||
pub use validate::ValidationError;
|
pub use validate::ValidationError;
|
||||||
|
|
||||||
|
#[cfg(feature = "wasm")]
|
||||||
|
mod wasm;
|
||||||
|
|
|
@ -83,11 +83,7 @@ impl Org<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
for child in children {
|
for child in children {
|
||||||
expect_element!(
|
expect_element!(child, "Headline", Element::Headline { .. });
|
||||||
child,
|
|
||||||
"Headline",
|
|
||||||
Element::Headline { .. }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Element::Headline { .. } => {
|
Element::Headline { .. } => {
|
||||||
|
@ -107,11 +103,7 @@ impl Org<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
for child in children {
|
for child in children {
|
||||||
expect_element!(
|
expect_element!(child, "Headline", Element::Headline { .. });
|
||||||
child,
|
|
||||||
"Headline",
|
|
||||||
Element::Headline { .. }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Element::Title(title) => {
|
Element::Title(title) => {
|
||||||
|
|
189
src/wasm/mod.rs
Normal file
189
src/wasm/mod.rs
Normal file
|
@ -0,0 +1,189 @@
|
||||||
|
#[global_allocator]
|
||||||
|
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
||||||
|
|
||||||
|
use serde::Serialize;
|
||||||
|
use serde_wasm_bindgen::Serializer;
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
use crate::{Element, Event};
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub struct Org(crate::Org<'static>);
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
impl Org {
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn parse(input: String) -> Self {
|
||||||
|
Org(crate::Org::parse_string(input))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen(js_name = toJson)]
|
||||||
|
pub fn to_json(&self) -> JsValue {
|
||||||
|
to_value(&self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
extern "C" {
|
||||||
|
#[wasm_bindgen(skip_typescript)]
|
||||||
|
pub type Handler;
|
||||||
|
|
||||||
|
#[wasm_bindgen(method)]
|
||||||
|
pub fn text(this: &Handler, text: JsValue);
|
||||||
|
#[wasm_bindgen(method)]
|
||||||
|
pub fn code(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method)]
|
||||||
|
pub fn cookie(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method)]
|
||||||
|
pub fn rule(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = exampleBlock)]
|
||||||
|
pub fn example_block(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = exportBlock)]
|
||||||
|
pub fn export_block(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = sourceBlock)]
|
||||||
|
pub fn source_block(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = inlineSrc)]
|
||||||
|
pub fn inline_src(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method)]
|
||||||
|
pub fn link(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method)]
|
||||||
|
pub fn snippet(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method)]
|
||||||
|
pub fn timestamp(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method)]
|
||||||
|
pub fn verbatim(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method)]
|
||||||
|
pub fn fixedWidth(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method)]
|
||||||
|
pub fn keyword(this: &Handler, item: JsValue);
|
||||||
|
|
||||||
|
#[wasm_bindgen(method, js_name = listStart)]
|
||||||
|
pub fn list_start(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = listEnd)]
|
||||||
|
pub fn list_end(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = tableStart)]
|
||||||
|
pub fn table_start(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = tableEnd)]
|
||||||
|
pub fn table_end(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = tableRowStart)]
|
||||||
|
pub fn table_row_start(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = tableRowEnd)]
|
||||||
|
pub fn table_row_end(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = tableCellStart)]
|
||||||
|
pub fn table_cell_start(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = tableCellEnd)]
|
||||||
|
pub fn table_cell_end(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = titleStart)]
|
||||||
|
pub fn title_start(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = titleEnd)]
|
||||||
|
pub fn title_end(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = boldStart)]
|
||||||
|
pub fn bold_start(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = boldEnd)]
|
||||||
|
pub fn bold_end(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = centerBlockStart)]
|
||||||
|
pub fn center_block_start(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = centerBlockEnd)]
|
||||||
|
pub fn center_block_end(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = documentStart)]
|
||||||
|
pub fn document_start(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = documentEnd)]
|
||||||
|
pub fn document_end(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = italicStart)]
|
||||||
|
pub fn italic_start(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = italicEnd)]
|
||||||
|
pub fn italic_end(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = listItemStart)]
|
||||||
|
pub fn list_item_start(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = listItemEnd)]
|
||||||
|
pub fn list_item_end(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = paragraphStart)]
|
||||||
|
pub fn paragraph_start(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = paragraphEnd)]
|
||||||
|
pub fn paragraph_end(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = quoteBlockStart)]
|
||||||
|
pub fn quote_block_start(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = quoteBlockEnd)]
|
||||||
|
pub fn quote_block_end(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = sectionStart)]
|
||||||
|
pub fn section_start(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = sectionEnd)]
|
||||||
|
pub fn section_end(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = strikeStart)]
|
||||||
|
pub fn strike_start(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = strikeEnd)]
|
||||||
|
pub fn strike_end(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = underlineStart)]
|
||||||
|
pub fn underline_start(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = underlineEnd)]
|
||||||
|
pub fn underline_end(this: &Handler);
|
||||||
|
#[wasm_bindgen(method, js_name = verseBlockStart)]
|
||||||
|
pub fn verse_block_start(this: &Handler, item: JsValue);
|
||||||
|
#[wasm_bindgen(method, js_name = verseBlockEnd)]
|
||||||
|
pub fn verse_block_end(this: &Handler, item: JsValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn handle(org: &Org, handler: Handler) {
|
||||||
|
for event in org.0.iter() {
|
||||||
|
use Element::*;
|
||||||
|
|
||||||
|
match event {
|
||||||
|
Event::Start(Text { value }) => handler.text(JsValue::from_str(value)),
|
||||||
|
Event::Start(ExampleBlock(block)) => handler.example_block(to_value(block)),
|
||||||
|
Event::Start(ExportBlock(block)) => handler.export_block(to_value(block)),
|
||||||
|
Event::Start(SourceBlock(block)) => handler.source_block(to_value(block)),
|
||||||
|
Event::Start(InlineSrc(src)) => handler.inline_src(to_value(src)),
|
||||||
|
Event::Start(Code { value }) => handler.code(JsValue::from_str(value)),
|
||||||
|
Event::Start(Link(link)) => handler.link(to_value(link)),
|
||||||
|
Event::Start(Snippet(snippet)) => handler.snippet(to_value(snippet)),
|
||||||
|
Event::Start(Timestamp(timestamp)) => handler.timestamp(to_value(timestamp)),
|
||||||
|
Event::Start(Verbatim { value }) => handler.verbatim(JsValue::from_str(value)),
|
||||||
|
Event::Start(FixedWidth(fixed_width)) => handler.fixedWidth(to_value(fixed_width)),
|
||||||
|
Event::Start(Rule(_)) => handler.rule(),
|
||||||
|
Event::Start(Cookie(cookie)) => handler.cookie(to_value(cookie)),
|
||||||
|
Event::Start(Keyword(keyword)) => handler.keyword(to_value(keyword)),
|
||||||
|
|
||||||
|
Event::Start(Table(table)) => handler.table_start(to_value(table)),
|
||||||
|
Event::End(Table(table)) => handler.table_start(to_value(table)),
|
||||||
|
Event::Start(TableRow(row)) => handler.table_row_start(to_value(row)),
|
||||||
|
Event::End(TableRow(row)) => handler.table_row_start(to_value(row)),
|
||||||
|
Event::Start(TableCell(cell)) => handler.table_cell_start(to_value(cell)),
|
||||||
|
Event::End(TableCell(cell)) => handler.table_cell_start(to_value(cell)),
|
||||||
|
Event::Start(Title(title)) => handler.title_start(to_value(title)),
|
||||||
|
Event::End(Title(title)) => handler.title_end(to_value(title)),
|
||||||
|
Event::Start(QuoteBlock(block)) => handler.quote_block_start(to_value(block)),
|
||||||
|
Event::End(QuoteBlock(block)) => handler.quote_block_end(to_value(block)),
|
||||||
|
Event::Start(CenterBlock(block)) => handler.center_block_start(to_value(block)),
|
||||||
|
Event::End(CenterBlock(block)) => handler.center_block_end(to_value(block)),
|
||||||
|
Event::Start(VerseBlock(block)) => handler.verse_block_start(to_value(block)),
|
||||||
|
Event::End(VerseBlock(block)) => handler.verse_block_end(to_value(block)),
|
||||||
|
Event::Start(Bold) => handler.bold_start(),
|
||||||
|
Event::End(Bold) => handler.bold_end(),
|
||||||
|
Event::Start(Document { .. }) => handler.document_start(),
|
||||||
|
Event::End(Document { .. }) => handler.document_end(),
|
||||||
|
Event::Start(List(list)) => handler.list_start(to_value(list)),
|
||||||
|
Event::End(List(list)) => handler.list_end(to_value(list)),
|
||||||
|
Event::Start(Italic) => handler.italic_start(),
|
||||||
|
Event::End(Italic) => handler.italic_end(),
|
||||||
|
Event::Start(ListItem(_)) => handler.list_item_start(),
|
||||||
|
Event::End(ListItem(_)) => handler.list_item_end(),
|
||||||
|
Event::Start(Paragraph { .. }) => handler.paragraph_start(),
|
||||||
|
Event::End(Paragraph { .. }) => handler.paragraph_end(),
|
||||||
|
Event::Start(Section) => handler.section_start(),
|
||||||
|
Event::End(Section) => handler.section_end(),
|
||||||
|
Event::Start(Strike) => handler.strike_start(),
|
||||||
|
Event::End(Strike) => handler.strike_end(),
|
||||||
|
Event::Start(Underline) => handler.underline_start(),
|
||||||
|
Event::End(Underline) => handler.underline_end(),
|
||||||
|
|
||||||
|
_ => continue,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn to_value<T: Serialize + ?Sized>(value: &T) -> JsValue {
|
||||||
|
value
|
||||||
|
.serialize(&Serializer::new().serialize_maps_as_objects(true))
|
||||||
|
.unwrap()
|
||||||
|
}
|
6
wasm/.gitignore
vendored
Normal file
6
wasm/.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
/lib
|
||||||
|
/node_modules
|
||||||
|
/out-tsc
|
||||||
|
/package
|
||||||
|
/pkg
|
||||||
|
*.tgz
|
41
wasm/README.md
Normal file
41
wasm/README.md
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
# orgize
|
||||||
|
|
||||||
|
![npm](https://img.shields.io/npm/v/orgize)
|
||||||
|
|
||||||
|
## Quick start
|
||||||
|
|
||||||
|
Install the package:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install orgize
|
||||||
|
yarn add orgize
|
||||||
|
```
|
||||||
|
|
||||||
|
Load the wasm module and init:
|
||||||
|
|
||||||
|
### Browser
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { init, renderHtml } from "orgize";
|
||||||
|
|
||||||
|
init().then(() => {
|
||||||
|
console.log(renderHtml("* Hello, /world/!"));
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Node.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { init, renderHtml } = require("orgize");
|
||||||
|
const { readFile } = require("fs/promises");
|
||||||
|
|
||||||
|
readFile(require.resolve("orgize/lib/orgize_bg.wasm"))
|
||||||
|
.then((bytes) => init(new WebAssembly.Module(bytes)))
|
||||||
|
.then(() => {
|
||||||
|
console.log(renderHtml("* Hello, /world/!"));
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT
|
71
wasm/index.html
Normal file
71
wasm/index.html
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Orgize wasm demo</title>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<script defer src="https://unpkg.com/alpinejs@3/dist/cdn.min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.0/beautify-html.js"></script>
|
||||||
|
|
||||||
|
<script src="./orgize.umd.js"></script>
|
||||||
|
<style>
|
||||||
|
h3 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body > * {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body
|
||||||
|
x-data="{ loaded: false, org: '* Hello, /world/!', type: 'json' }"
|
||||||
|
x-init="orgize.init('./orgize_bg.wasm').then(() => loaded = true)"
|
||||||
|
>
|
||||||
|
<h2>Orgize wasm demo</h2>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<a href="https://github.com/PoiScript/orgize">GitHub</a>
|
||||||
|
<a href="https://www.npmjs.com/package/orgize">NPM</a>
|
||||||
|
<a href="https://crates.io/crates/orgize">crates.io</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>Input:</div>
|
||||||
|
|
||||||
|
<textarea
|
||||||
|
x-model="org"
|
||||||
|
style="width: 100%; height: 100px; margin-bottom: 16px"
|
||||||
|
></textarea>
|
||||||
|
|
||||||
|
<div>Type:</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button @click="type = 'json'">JSON</button>
|
||||||
|
<button @click="type = 'html'">HTML</button>
|
||||||
|
<button @click="type = 'html-rendered'">HTML (Rendered)</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>Output:</div>
|
||||||
|
|
||||||
|
<noscript>
|
||||||
|
<p style="color: red">JavaScript is required.</p>
|
||||||
|
</noscript>
|
||||||
|
|
||||||
|
<pre
|
||||||
|
x-show="type === 'json'"
|
||||||
|
x-transition
|
||||||
|
x-text="loaded ? JSON.stringify(orgize.Org.parse(org).toJson(), null, 2) : 'Loading...'"
|
||||||
|
></pre>
|
||||||
|
<pre
|
||||||
|
x-show="type === 'html'"
|
||||||
|
x-transition
|
||||||
|
x-text="loaded ? html_beautify(orgize.renderHtml(org), { indent_size: 2 }) : 'Loading...'"
|
||||||
|
></pre>
|
||||||
|
<div
|
||||||
|
x-show="type === 'html-rendered'"
|
||||||
|
x-transition
|
||||||
|
x-html="loaded ? orgize.renderHtml(org) : 'Loading...'"
|
||||||
|
></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
27
wasm/package.json
Normal file
27
wasm/package.json
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"name": "orgize",
|
||||||
|
"version": "0.0.3",
|
||||||
|
"license": "MIT",
|
||||||
|
"author": "PoiScript <poiscript@gmail.com>",
|
||||||
|
"main": "lib/orgize.umd.js",
|
||||||
|
"module": "lib/orgize.es.js",
|
||||||
|
"typings": "lib/orgize.d.ts",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/PoiScript/orgize"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"prebuild": "rm -rf out-tsc/ lib/",
|
||||||
|
"build": "tsc && rollup -c rollup.js && cp pkg/orgize_bg.wasm lib/"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"rollup": "^2.56.3",
|
||||||
|
"rollup-plugin-copy": "^3.4.0",
|
||||||
|
"rollup-plugin-dts": "^4.0.0",
|
||||||
|
"typescript": "^4.4.2"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib",
|
||||||
|
"README.md"
|
||||||
|
]
|
||||||
|
}
|
31
wasm/rollup.js
Normal file
31
wasm/rollup.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
import dts from "rollup-plugin-dts";
|
||||||
|
import copy from "rollup-plugin-copy";
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
input: "./out-tsc/index.d.ts",
|
||||||
|
output: {
|
||||||
|
file: "./lib/orgize.d.ts",
|
||||||
|
},
|
||||||
|
plugins: [dts()],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: "./out-tsc/index.js",
|
||||||
|
output: [
|
||||||
|
{
|
||||||
|
file: "./lib/orgize.es.js",
|
||||||
|
format: "es",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "orgize",
|
||||||
|
file: "./lib/orgize.umd.js",
|
||||||
|
format: "umd",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
copy({
|
||||||
|
targets: [{ src: "index.html", dest: "lib" }],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
102
wasm/src/handler.ts
Normal file
102
wasm/src/handler.ts
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
export class Handler {
|
||||||
|
text(_text: string) {}
|
||||||
|
code(_item: string) {}
|
||||||
|
cookie(_item: Cookie) {}
|
||||||
|
rule() {}
|
||||||
|
exampleBlock(_item: Block) {}
|
||||||
|
exportBlock(_item: Block) {}
|
||||||
|
sourceBlock(_item: SourceBlock) {}
|
||||||
|
inlineSrc(_item: InlineSrc) {}
|
||||||
|
link(_item: Link) {}
|
||||||
|
snippet(_item: Snippet) {}
|
||||||
|
timestamp(_item: any) {}
|
||||||
|
verbatim(_item: string) {}
|
||||||
|
fixedWidth(_item: FixedWidth) {}
|
||||||
|
listStart(_item: List) {}
|
||||||
|
listEnd(_item: List) {}
|
||||||
|
tableStart(_item: any) {}
|
||||||
|
tableEnd(_item: any) {}
|
||||||
|
tableRowStart(_item: any) {}
|
||||||
|
tableRowEnd(_item: any) {}
|
||||||
|
tableCellStart(_item: any) {}
|
||||||
|
tableCellEnd(_item: any) {}
|
||||||
|
titleStart(_item: Title) {}
|
||||||
|
titleEnd(_item: Title) {}
|
||||||
|
boldStart() {}
|
||||||
|
boldEnd() {}
|
||||||
|
centerBlockStart(_item: any) {}
|
||||||
|
centerBlockEnd(_item: any) {}
|
||||||
|
documentStart() {}
|
||||||
|
documentEnd() {}
|
||||||
|
italicStart() {}
|
||||||
|
italicEnd() {}
|
||||||
|
listItemStart() {}
|
||||||
|
listItemEnd() {}
|
||||||
|
paragraphStart() {}
|
||||||
|
paragraphEnd() {}
|
||||||
|
quoteBlockStart(_item: any) {}
|
||||||
|
quoteBlockEnd(_item: any) {}
|
||||||
|
sectionStart() {}
|
||||||
|
sectionEnd() {}
|
||||||
|
strikeStart() {}
|
||||||
|
strikeEnd() {}
|
||||||
|
underlineStart() {}
|
||||||
|
underlineEnd() {}
|
||||||
|
verseBlockStart(_item: any) {}
|
||||||
|
verseBlockEnd(_item: any) {}
|
||||||
|
keyword(_item: Keyword) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Title = {
|
||||||
|
level: number;
|
||||||
|
priority?: string;
|
||||||
|
tags?: string[];
|
||||||
|
keyword?: string;
|
||||||
|
raw: string;
|
||||||
|
properties?: { [key: string]: string };
|
||||||
|
post_blank: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type List = {
|
||||||
|
ordered: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Block = {
|
||||||
|
contents: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type InlineSrc = {
|
||||||
|
lang: string;
|
||||||
|
body: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Link = {
|
||||||
|
path: string;
|
||||||
|
desc?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type FixedWidth = {
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Cookie = {
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SourceBlock = {
|
||||||
|
contents: string;
|
||||||
|
language: string;
|
||||||
|
arguments: string;
|
||||||
|
post_blank: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Keyword = {
|
||||||
|
key: string;
|
||||||
|
optional?: string;
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Snippet = {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
};
|
160
wasm/src/html.ts
Normal file
160
wasm/src/html.ts
Normal file
|
@ -0,0 +1,160 @@
|
||||||
|
import {
|
||||||
|
Block,
|
||||||
|
Cookie,
|
||||||
|
FixedWidth,
|
||||||
|
Handler,
|
||||||
|
InlineSrc,
|
||||||
|
Link,
|
||||||
|
List,
|
||||||
|
Snippet,
|
||||||
|
Title,
|
||||||
|
} from "./handler";
|
||||||
|
|
||||||
|
const tags: { [tag: string]: string } = {
|
||||||
|
"&": "&",
|
||||||
|
"<": "<",
|
||||||
|
">": ">",
|
||||||
|
'"': """,
|
||||||
|
"'": "'",
|
||||||
|
};
|
||||||
|
|
||||||
|
const replaceTags = (tag: string): string => tags[tag];
|
||||||
|
|
||||||
|
export const escapeHtml = (str: string): string =>
|
||||||
|
str.replace(/[&<>"']/g, replaceTags);
|
||||||
|
|
||||||
|
export class HtmlHandler extends Handler {
|
||||||
|
result: string;
|
||||||
|
|
||||||
|
constructor(result: string = "") {
|
||||||
|
super();
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static escape(): string {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
quoteBlockStart() {
|
||||||
|
this.result += "<blockquote>";
|
||||||
|
}
|
||||||
|
quoteBlockEnd() {
|
||||||
|
this.result += "</blockquote>";
|
||||||
|
}
|
||||||
|
centerBlockStart() {
|
||||||
|
this.result += '<div class="center">';
|
||||||
|
}
|
||||||
|
centerBlockEnd() {
|
||||||
|
this.result += "</div>";
|
||||||
|
}
|
||||||
|
verseBlockStart() {
|
||||||
|
this.result += '<p class="verse">';
|
||||||
|
}
|
||||||
|
verseBlockEnd() {
|
||||||
|
this.result += "</p>";
|
||||||
|
}
|
||||||
|
boldStart() {
|
||||||
|
this.result += "<b>";
|
||||||
|
}
|
||||||
|
boldEnd() {
|
||||||
|
this.result += "</b>";
|
||||||
|
}
|
||||||
|
documentStart() {
|
||||||
|
this.result += "<main>";
|
||||||
|
}
|
||||||
|
documentEnd() {
|
||||||
|
this.result += "</main>";
|
||||||
|
}
|
||||||
|
|
||||||
|
listStart(list: List) {
|
||||||
|
this.result += `<${list.ordered ? "o" : "u"}l>`;
|
||||||
|
}
|
||||||
|
listEnd(list: List) {
|
||||||
|
this.result += `</${list.ordered ? "o" : "u"}l>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
italicStart() {
|
||||||
|
this.result += "<i>";
|
||||||
|
}
|
||||||
|
italicEnd() {
|
||||||
|
this.result += "</i>";
|
||||||
|
}
|
||||||
|
listItemStart() {
|
||||||
|
this.result += "<li>";
|
||||||
|
}
|
||||||
|
listItemEnd() {
|
||||||
|
this.result += "</li>";
|
||||||
|
}
|
||||||
|
paragraphStart() {
|
||||||
|
this.result += "<p>";
|
||||||
|
}
|
||||||
|
paragraphEnd() {
|
||||||
|
this.result += "</p>";
|
||||||
|
}
|
||||||
|
sectionStart() {
|
||||||
|
this.result += "<section>";
|
||||||
|
}
|
||||||
|
sectionEnd() {
|
||||||
|
this.result += "</section>";
|
||||||
|
}
|
||||||
|
strikeStart() {
|
||||||
|
this.result += "<s>";
|
||||||
|
}
|
||||||
|
strikeEnd() {
|
||||||
|
this.result += "</s>";
|
||||||
|
}
|
||||||
|
underlineStart() {
|
||||||
|
this.result += "<u>";
|
||||||
|
}
|
||||||
|
underlineEnd() {
|
||||||
|
this.result += "</u>";
|
||||||
|
}
|
||||||
|
|
||||||
|
exampleBlock(block: Block) {
|
||||||
|
this.result += `<pre class="example">${escapeHtml(block.contents)}</pre>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceBlock(block: Block) {
|
||||||
|
this.result += `<pre class="example">${escapeHtml(block.contents)}</pre>`;
|
||||||
|
}
|
||||||
|
inlineSrc(src: InlineSrc) {
|
||||||
|
this.result += `<code class="src src-${src.lang}">${escapeHtml(
|
||||||
|
src.body
|
||||||
|
)}</code>`;
|
||||||
|
}
|
||||||
|
code(value: string) {
|
||||||
|
this.result += `<code>${escapeHtml(value)}</code>`;
|
||||||
|
}
|
||||||
|
link(link: Link) {
|
||||||
|
this.result += `<a href="${link.path}">${escapeHtml(
|
||||||
|
link.desc || link.path
|
||||||
|
)}</a>`;
|
||||||
|
}
|
||||||
|
snippet(snippet: Snippet) {
|
||||||
|
if (snippet.name.toLowerCase() === "html") {
|
||||||
|
this.result += snippet.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text(value: string) {
|
||||||
|
this.result += escapeHtml(value);
|
||||||
|
}
|
||||||
|
verbatim(value: string) {
|
||||||
|
this.result += `<code>${escapeHtml(value)}</code>`;
|
||||||
|
}
|
||||||
|
fixedWidth(item: FixedWidth) {
|
||||||
|
this.result += `<pre class="example">${escapeHtml(item.value)}</pre>`;
|
||||||
|
}
|
||||||
|
rule() {
|
||||||
|
this.result += "<hr>";
|
||||||
|
}
|
||||||
|
cookie(cookie: Cookie) {
|
||||||
|
this.result += `<code>${escapeHtml(cookie.value)}</code>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
titleStart(title: Title) {
|
||||||
|
this.result += `<h${Math.min(title.level, 6)}>`;
|
||||||
|
}
|
||||||
|
titleEnd(title: Title) {
|
||||||
|
this.result += `</h${Math.min(title.level, 6)}>`;
|
||||||
|
}
|
||||||
|
}
|
34
wasm/src/index.ts
Normal file
34
wasm/src/index.ts
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import init, {
|
||||||
|
handle as internalHandle,
|
||||||
|
InitInput,
|
||||||
|
InitOutput,
|
||||||
|
Org,
|
||||||
|
} from "../pkg/orgize";
|
||||||
|
import { Handler } from "./handler";
|
||||||
|
import { HtmlHandler } from "./html";
|
||||||
|
import { CollectKeywords } from "./keyword";
|
||||||
|
|
||||||
|
export const handle = (org: Org | string, handler: Handler) => {
|
||||||
|
if (typeof org === "string") {
|
||||||
|
org = Org.parse(org);
|
||||||
|
}
|
||||||
|
internalHandle(org, handler);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const renderHtml = (
|
||||||
|
org: Org | string,
|
||||||
|
handler: HtmlHandler = new HtmlHandler()
|
||||||
|
): string => {
|
||||||
|
handle(org, handler);
|
||||||
|
return handler.result;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const keywords = (org: Org | string): { [key: string]: string[] } => {
|
||||||
|
const handler = new CollectKeywords();
|
||||||
|
handle(org, handler);
|
||||||
|
return handler.keywords;
|
||||||
|
};
|
||||||
|
|
||||||
|
export * from "./handler";
|
||||||
|
export * from "./html";
|
||||||
|
export { Org, init, InitInput, InitOutput };
|
10
wasm/src/keyword.ts
Normal file
10
wasm/src/keyword.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import { Handler, Keyword } from "./handler";
|
||||||
|
|
||||||
|
export class CollectKeywords extends Handler {
|
||||||
|
keywords: { [key: string]: string[] } = {};
|
||||||
|
|
||||||
|
keyword(keyword: Keyword) {
|
||||||
|
this.keywords[keyword.key] = this.keywords[keyword.key] || [];
|
||||||
|
this.keywords[keyword.key].push(keyword.value);
|
||||||
|
}
|
||||||
|
}
|
82
wasm/tests/html.js
Normal file
82
wasm/tests/html.js
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
const { readFile } = require("fs/promises");
|
||||||
|
const { resolve } = require("path");
|
||||||
|
const { strictEqual } = require("assert");
|
||||||
|
|
||||||
|
const { init, renderHtml } = require("../lib/orgize.umd");
|
||||||
|
|
||||||
|
const assert = (org, html) => strictEqual(renderHtml(org), html);
|
||||||
|
|
||||||
|
readFile(resolve(__dirname, "../lib/orgize_bg.wasm"))
|
||||||
|
.then((bytes) => new WebAssembly.Module(bytes))
|
||||||
|
.then((module) => init(module))
|
||||||
|
.then(() => {
|
||||||
|
assert(
|
||||||
|
"*bold*, /italic/,\n_underlined_, =verbatim= and ~code~",
|
||||||
|
"<main><section><p><b>bold</b>, <i>italic</i>,\n<u>underlined</u>, " +
|
||||||
|
"<code>verbatim</code> and <code>code</code></p></section></main>"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(
|
||||||
|
"Visit[[http://example.com][link1]]or[[http://example.com][link1]].",
|
||||||
|
`<main><section><p>Visit<a href="http://example.com">link1</a>or<a href="http://example.com">link1</a>.</p></section></main>`
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(
|
||||||
|
`
|
||||||
|
* title 1
|
||||||
|
section 1
|
||||||
|
** title 2
|
||||||
|
section 2
|
||||||
|
* title 3
|
||||||
|
section 3
|
||||||
|
* title 4
|
||||||
|
section 4
|
||||||
|
`,
|
||||||
|
"<main><h1>title 1</h1><section><p>section 1</p></section>" +
|
||||||
|
"<h2>title 2</h2><section><p>section 2</p></section>" +
|
||||||
|
"<h1>title 3</h1><section><p>section 3</p></section>" +
|
||||||
|
"<h1>title 4</h1><section><p>section 4</p></section></main>"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(
|
||||||
|
`
|
||||||
|
+ 1
|
||||||
|
|
||||||
|
+ 2
|
||||||
|
|
||||||
|
- 3
|
||||||
|
|
||||||
|
- 4
|
||||||
|
|
||||||
|
+ 5
|
||||||
|
`,
|
||||||
|
"<main><section><ul>" +
|
||||||
|
"<li><p>1</p></li>" +
|
||||||
|
"<li><p>2</p><ul><li><p>3</p></li><li><p>4</p></li></ul></li>" +
|
||||||
|
"<li><p>5</p></li>" +
|
||||||
|
"</ul></section></main>"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(
|
||||||
|
"@@html:<del>@@delete this@@html:</del>@@",
|
||||||
|
"<main><section><p><del>delete this</del></p></section></main>"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(
|
||||||
|
`
|
||||||
|
* title
|
||||||
|
|
||||||
|
paragraph 1
|
||||||
|
|
||||||
|
paragraph 2
|
||||||
|
|
||||||
|
paragraph 3
|
||||||
|
|
||||||
|
paragraph 4
|
||||||
|
`,
|
||||||
|
"<main><h1>title</h1><section>" +
|
||||||
|
"<p>paragraph 1</p><p>paragraph 2</p>" +
|
||||||
|
"<p>paragraph 3</p><p>paragraph 4</p>" +
|
||||||
|
"</section></main>"
|
||||||
|
);
|
||||||
|
});
|
17
wasm/tests/keyword.js
Normal file
17
wasm/tests/keyword.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
const { readFile } = require("fs/promises");
|
||||||
|
const { resolve } = require("path");
|
||||||
|
const { deepStrictEqual } = require("assert");
|
||||||
|
|
||||||
|
const { init, keywords } = require("../lib/orgize.umd");
|
||||||
|
|
||||||
|
const assert = (org, kw) => deepStrictEqual(keywords(org), kw);
|
||||||
|
|
||||||
|
readFile(resolve(__dirname, "../lib/orgize_bg.wasm"))
|
||||||
|
.then((bytes) => new WebAssembly.Module(bytes))
|
||||||
|
.then((module) => init(module))
|
||||||
|
.then(() => {
|
||||||
|
assert("#+TITLE: orgize test cases\n#+FOO: bar", {
|
||||||
|
TITLE: ["orgize test cases"],
|
||||||
|
FOO: ["bar"],
|
||||||
|
});
|
||||||
|
});
|
12
wasm/tsconfig.json
Normal file
12
wasm/tsconfig.json
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ESNext",
|
||||||
|
"module": "ESNext",
|
||||||
|
"lib": ["ESNext", "WebWorker"],
|
||||||
|
"strict": true,
|
||||||
|
"outDir": "out-tsc",
|
||||||
|
"rootDir": "./src",
|
||||||
|
"declaration": true
|
||||||
|
},
|
||||||
|
"include": ["./src"]
|
||||||
|
}
|
416
wasm/yarn.lock
Normal file
416
wasm/yarn.lock
Normal file
|
@ -0,0 +1,416 @@
|
||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
"@babel/code-frame@^7.14.5":
|
||||||
|
version "7.14.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.14.5.tgz#23b08d740e83f49c5e59945fbf1b43e80bbf4edb"
|
||||||
|
integrity sha512-9pzDqyc6OLDaqe+zbACgFkb6fKMNG6CObKpnYXChRsvYGyEdc7CA2BaqeOM+vOtCS5ndmJicPJhKAwYRI6UfFw==
|
||||||
|
dependencies:
|
||||||
|
"@babel/highlight" "^7.14.5"
|
||||||
|
|
||||||
|
"@babel/helper-validator-identifier@^7.14.5":
|
||||||
|
version "7.14.9"
|
||||||
|
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.9.tgz#6654d171b2024f6d8ee151bf2509699919131d48"
|
||||||
|
integrity sha512-pQYxPY0UP6IHISRitNe8bsijHex4TWZXi2HwKVsjPiltzlhse2znVcm9Ace510VT1kxIHjGJCZZQBX2gJDbo0g==
|
||||||
|
|
||||||
|
"@babel/highlight@^7.14.5":
|
||||||
|
version "7.14.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.14.5.tgz#6861a52f03966405001f6aa534a01a24d99e8cd9"
|
||||||
|
integrity sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg==
|
||||||
|
dependencies:
|
||||||
|
"@babel/helper-validator-identifier" "^7.14.5"
|
||||||
|
chalk "^2.0.0"
|
||||||
|
js-tokens "^4.0.0"
|
||||||
|
|
||||||
|
"@nodelib/fs.scandir@2.1.5":
|
||||||
|
version "2.1.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
|
||||||
|
integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==
|
||||||
|
dependencies:
|
||||||
|
"@nodelib/fs.stat" "2.0.5"
|
||||||
|
run-parallel "^1.1.9"
|
||||||
|
|
||||||
|
"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2":
|
||||||
|
version "2.0.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b"
|
||||||
|
integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==
|
||||||
|
|
||||||
|
"@nodelib/fs.walk@^1.2.3":
|
||||||
|
version "1.2.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a"
|
||||||
|
integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==
|
||||||
|
dependencies:
|
||||||
|
"@nodelib/fs.scandir" "2.1.5"
|
||||||
|
fastq "^1.6.0"
|
||||||
|
|
||||||
|
"@types/fs-extra@^8.0.1":
|
||||||
|
version "8.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-8.1.2.tgz#7125cc2e4bdd9bd2fc83005ffdb1d0ba00cca61f"
|
||||||
|
integrity sha512-SvSrYXfWSc7R4eqnOzbQF4TZmfpNSM9FrSWLU3EUnWBuyZqNBOrv1B1JA3byUDPUl9z4Ab3jeZG2eDdySlgNMg==
|
||||||
|
dependencies:
|
||||||
|
"@types/node" "*"
|
||||||
|
|
||||||
|
"@types/glob@^7.1.1":
|
||||||
|
version "7.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"
|
||||||
|
integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==
|
||||||
|
dependencies:
|
||||||
|
"@types/minimatch" "*"
|
||||||
|
"@types/node" "*"
|
||||||
|
|
||||||
|
"@types/minimatch@*":
|
||||||
|
version "3.0.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40"
|
||||||
|
integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==
|
||||||
|
|
||||||
|
"@types/node@*":
|
||||||
|
version "16.11.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.6.tgz#6bef7a2a0ad684cf6e90fcfe31cecabd9ce0a3ae"
|
||||||
|
integrity sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==
|
||||||
|
|
||||||
|
ansi-styles@^3.2.1:
|
||||||
|
version "3.2.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
|
||||||
|
integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==
|
||||||
|
dependencies:
|
||||||
|
color-convert "^1.9.0"
|
||||||
|
|
||||||
|
array-union@^2.1.0:
|
||||||
|
version "2.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d"
|
||||||
|
integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==
|
||||||
|
|
||||||
|
balanced-match@^1.0.0:
|
||||||
|
version "1.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
|
||||||
|
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
|
||||||
|
|
||||||
|
brace-expansion@^1.1.7:
|
||||||
|
version "1.1.11"
|
||||||
|
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
|
||||||
|
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
|
||||||
|
dependencies:
|
||||||
|
balanced-match "^1.0.0"
|
||||||
|
concat-map "0.0.1"
|
||||||
|
|
||||||
|
braces@^3.0.1:
|
||||||
|
version "3.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
|
||||||
|
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
|
||||||
|
dependencies:
|
||||||
|
fill-range "^7.0.1"
|
||||||
|
|
||||||
|
chalk@^2.0.0:
|
||||||
|
version "2.4.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
|
||||||
|
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
|
||||||
|
dependencies:
|
||||||
|
ansi-styles "^3.2.1"
|
||||||
|
escape-string-regexp "^1.0.5"
|
||||||
|
supports-color "^5.3.0"
|
||||||
|
|
||||||
|
color-convert@^1.9.0:
|
||||||
|
version "1.9.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
|
||||||
|
integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==
|
||||||
|
dependencies:
|
||||||
|
color-name "1.1.3"
|
||||||
|
|
||||||
|
color-name@1.1.3:
|
||||||
|
version "1.1.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
|
||||||
|
integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=
|
||||||
|
|
||||||
|
colorette@^1.1.0:
|
||||||
|
version "1.4.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.4.0.tgz#5190fbb87276259a86ad700bff2c6d6faa3fca40"
|
||||||
|
integrity sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==
|
||||||
|
|
||||||
|
concat-map@0.0.1:
|
||||||
|
version "0.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||||
|
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
|
||||||
|
|
||||||
|
dir-glob@^3.0.1:
|
||||||
|
version "3.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f"
|
||||||
|
integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==
|
||||||
|
dependencies:
|
||||||
|
path-type "^4.0.0"
|
||||||
|
|
||||||
|
escape-string-regexp@^1.0.5:
|
||||||
|
version "1.0.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
|
||||||
|
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
|
||||||
|
|
||||||
|
fast-glob@^3.0.3:
|
||||||
|
version "3.2.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.7.tgz#fd6cb7a2d7e9aa7a7846111e85a196d6b2f766a1"
|
||||||
|
integrity sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==
|
||||||
|
dependencies:
|
||||||
|
"@nodelib/fs.stat" "^2.0.2"
|
||||||
|
"@nodelib/fs.walk" "^1.2.3"
|
||||||
|
glob-parent "^5.1.2"
|
||||||
|
merge2 "^1.3.0"
|
||||||
|
micromatch "^4.0.4"
|
||||||
|
|
||||||
|
fastq@^1.6.0:
|
||||||
|
version "1.13.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c"
|
||||||
|
integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==
|
||||||
|
dependencies:
|
||||||
|
reusify "^1.0.4"
|
||||||
|
|
||||||
|
fill-range@^7.0.1:
|
||||||
|
version "7.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
|
||||||
|
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
|
||||||
|
dependencies:
|
||||||
|
to-regex-range "^5.0.1"
|
||||||
|
|
||||||
|
fs-extra@^8.1.0:
|
||||||
|
version "8.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
|
||||||
|
integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
|
||||||
|
dependencies:
|
||||||
|
graceful-fs "^4.2.0"
|
||||||
|
jsonfile "^4.0.0"
|
||||||
|
universalify "^0.1.0"
|
||||||
|
|
||||||
|
fs.realpath@^1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
|
||||||
|
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
|
||||||
|
|
||||||
|
fsevents@~2.3.2:
|
||||||
|
version "2.3.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
|
||||||
|
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
|
||||||
|
|
||||||
|
glob-parent@^5.1.2:
|
||||||
|
version "5.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
|
||||||
|
integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==
|
||||||
|
dependencies:
|
||||||
|
is-glob "^4.0.1"
|
||||||
|
|
||||||
|
glob@^7.1.3:
|
||||||
|
version "7.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023"
|
||||||
|
integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==
|
||||||
|
dependencies:
|
||||||
|
fs.realpath "^1.0.0"
|
||||||
|
inflight "^1.0.4"
|
||||||
|
inherits "2"
|
||||||
|
minimatch "^3.0.4"
|
||||||
|
once "^1.3.0"
|
||||||
|
path-is-absolute "^1.0.0"
|
||||||
|
|
||||||
|
globby@10.0.1:
|
||||||
|
version "10.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.1.tgz#4782c34cb75dd683351335c5829cc3420e606b22"
|
||||||
|
integrity sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A==
|
||||||
|
dependencies:
|
||||||
|
"@types/glob" "^7.1.1"
|
||||||
|
array-union "^2.1.0"
|
||||||
|
dir-glob "^3.0.1"
|
||||||
|
fast-glob "^3.0.3"
|
||||||
|
glob "^7.1.3"
|
||||||
|
ignore "^5.1.1"
|
||||||
|
merge2 "^1.2.3"
|
||||||
|
slash "^3.0.0"
|
||||||
|
|
||||||
|
graceful-fs@^4.1.6, graceful-fs@^4.2.0:
|
||||||
|
version "4.2.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.8.tgz#e412b8d33f5e006593cbd3cee6df9f2cebbe802a"
|
||||||
|
integrity sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==
|
||||||
|
|
||||||
|
has-flag@^3.0.0:
|
||||||
|
version "3.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
|
||||||
|
integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0=
|
||||||
|
|
||||||
|
ignore@^5.1.1:
|
||||||
|
version "5.1.9"
|
||||||
|
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.9.tgz#9ec1a5cbe8e1446ec60d4420060d43aa6e7382fb"
|
||||||
|
integrity sha512-2zeMQpbKz5dhZ9IwL0gbxSW5w0NK/MSAMtNuhgIHEPmaU3vPdKPL0UdvUCXs5SS4JAwsBxysK5sFMW8ocFiVjQ==
|
||||||
|
|
||||||
|
inflight@^1.0.4:
|
||||||
|
version "1.0.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
|
||||||
|
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
|
||||||
|
dependencies:
|
||||||
|
once "^1.3.0"
|
||||||
|
wrappy "1"
|
||||||
|
|
||||||
|
inherits@2:
|
||||||
|
version "2.0.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
|
||||||
|
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
|
||||||
|
|
||||||
|
is-extglob@^2.1.1:
|
||||||
|
version "2.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
|
||||||
|
integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=
|
||||||
|
|
||||||
|
is-glob@^4.0.1:
|
||||||
|
version "4.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084"
|
||||||
|
integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==
|
||||||
|
dependencies:
|
||||||
|
is-extglob "^2.1.1"
|
||||||
|
|
||||||
|
is-number@^7.0.0:
|
||||||
|
version "7.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
|
||||||
|
integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==
|
||||||
|
|
||||||
|
is-plain-object@^3.0.0:
|
||||||
|
version "3.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-3.0.1.tgz#662d92d24c0aa4302407b0d45d21f2251c85f85b"
|
||||||
|
integrity sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g==
|
||||||
|
|
||||||
|
js-tokens@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
|
||||||
|
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
|
||||||
|
|
||||||
|
jsonfile@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
|
||||||
|
integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
|
||||||
|
optionalDependencies:
|
||||||
|
graceful-fs "^4.1.6"
|
||||||
|
|
||||||
|
magic-string@^0.25.7:
|
||||||
|
version "0.25.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051"
|
||||||
|
integrity sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==
|
||||||
|
dependencies:
|
||||||
|
sourcemap-codec "^1.4.4"
|
||||||
|
|
||||||
|
merge2@^1.2.3, merge2@^1.3.0:
|
||||||
|
version "1.4.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
|
||||||
|
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
|
||||||
|
|
||||||
|
micromatch@^4.0.4:
|
||||||
|
version "4.0.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.4.tgz#896d519dfe9db25fce94ceb7a500919bf881ebf9"
|
||||||
|
integrity sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==
|
||||||
|
dependencies:
|
||||||
|
braces "^3.0.1"
|
||||||
|
picomatch "^2.2.3"
|
||||||
|
|
||||||
|
minimatch@^3.0.4:
|
||||||
|
version "3.0.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
|
||||||
|
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
|
||||||
|
dependencies:
|
||||||
|
brace-expansion "^1.1.7"
|
||||||
|
|
||||||
|
once@^1.3.0:
|
||||||
|
version "1.4.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
|
||||||
|
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
|
||||||
|
dependencies:
|
||||||
|
wrappy "1"
|
||||||
|
|
||||||
|
path-is-absolute@^1.0.0:
|
||||||
|
version "1.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
|
||||||
|
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
|
||||||
|
|
||||||
|
path-type@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
|
||||||
|
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
|
||||||
|
|
||||||
|
picomatch@^2.2.3:
|
||||||
|
version "2.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.0.tgz#f1f061de8f6a4bf022892e2d128234fb98302972"
|
||||||
|
integrity sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==
|
||||||
|
|
||||||
|
queue-microtask@^1.2.2:
|
||||||
|
version "1.2.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
|
||||||
|
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==
|
||||||
|
|
||||||
|
reusify@^1.0.4:
|
||||||
|
version "1.0.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"
|
||||||
|
integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==
|
||||||
|
|
||||||
|
rollup-plugin-copy@^3.4.0:
|
||||||
|
version "3.4.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/rollup-plugin-copy/-/rollup-plugin-copy-3.4.0.tgz#f1228a3ffb66ffad8606e2f3fb7ff23141ed3286"
|
||||||
|
integrity sha512-rGUmYYsYsceRJRqLVlE9FivJMxJ7X6jDlP79fmFkL8sJs7VVMSVyA2yfyL+PGyO/vJs4A87hwhgVfz61njI+uQ==
|
||||||
|
dependencies:
|
||||||
|
"@types/fs-extra" "^8.0.1"
|
||||||
|
colorette "^1.1.0"
|
||||||
|
fs-extra "^8.1.0"
|
||||||
|
globby "10.0.1"
|
||||||
|
is-plain-object "^3.0.0"
|
||||||
|
|
||||||
|
rollup-plugin-dts@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/rollup-plugin-dts/-/rollup-plugin-dts-4.0.0.tgz#7645280183b7624e77375a548a11297f9916f6d8"
|
||||||
|
integrity sha512-tgUC8CxVgtlLDVloUEA9uACVaxjJHuYxlDSTp1LdCexA0bJx+RuMi45RjdLG9RTCgZlV5YBh3O7P2u6dS1KlnA==
|
||||||
|
dependencies:
|
||||||
|
magic-string "^0.25.7"
|
||||||
|
optionalDependencies:
|
||||||
|
"@babel/code-frame" "^7.14.5"
|
||||||
|
|
||||||
|
rollup@^2.56.3:
|
||||||
|
version "2.56.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.56.3.tgz#b63edadd9851b0d618a6d0e6af8201955a77aeff"
|
||||||
|
integrity sha512-Au92NuznFklgQCUcV96iXlxUbHuB1vQMaH76DHl5M11TotjOHwqk9CwcrT78+Tnv4FN9uTBxq6p4EJoYkpyekg==
|
||||||
|
optionalDependencies:
|
||||||
|
fsevents "~2.3.2"
|
||||||
|
|
||||||
|
run-parallel@^1.1.9:
|
||||||
|
version "1.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee"
|
||||||
|
integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==
|
||||||
|
dependencies:
|
||||||
|
queue-microtask "^1.2.2"
|
||||||
|
|
||||||
|
slash@^3.0.0:
|
||||||
|
version "3.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
|
||||||
|
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==
|
||||||
|
|
||||||
|
sourcemap-codec@^1.4.4:
|
||||||
|
version "1.4.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4"
|
||||||
|
integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==
|
||||||
|
|
||||||
|
supports-color@^5.3.0:
|
||||||
|
version "5.5.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
|
||||||
|
integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==
|
||||||
|
dependencies:
|
||||||
|
has-flag "^3.0.0"
|
||||||
|
|
||||||
|
to-regex-range@^5.0.1:
|
||||||
|
version "5.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4"
|
||||||
|
integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==
|
||||||
|
dependencies:
|
||||||
|
is-number "^7.0.0"
|
||||||
|
|
||||||
|
typescript@^4.4.2:
|
||||||
|
version "4.4.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86"
|
||||||
|
integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==
|
||||||
|
|
||||||
|
universalify@^0.1.0:
|
||||||
|
version "0.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
|
||||||
|
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
|
||||||
|
|
||||||
|
wrappy@1:
|
||||||
|
version "1.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
|
||||||
|
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
|
Loading…
Reference in a new issue