feat: add dependency
This commit is contained in:
30
javascript-engine/external/boa/boa_icu_provider/Cargo.toml
vendored
Normal file
30
javascript-engine/external/boa/boa_icu_provider/Cargo.toml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
[package]
|
||||
name = "boa_icu_provider"
|
||||
description = "ICU4X data provider for the Boa JavaScript engine."
|
||||
keywords = ["javascript", "cldr", "unicode"]
|
||||
categories = ["internationalization"]
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
rust-version.workspace = true
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
icu_provider = { version = "1.0.1", features = ["serde", "sync"] }
|
||||
icu_provider_blob = "1.0.0"
|
||||
icu_provider_adapters = { version = "1.0.0", features = ["serde"]}
|
||||
icu_datagen = { version = "1.0.2", optional = true }
|
||||
log = { version = "0.4.17", optional = true }
|
||||
simple_logger = { version = "4.0.0", optional = true }
|
||||
once_cell = "1.17.0"
|
||||
|
||||
[features]
|
||||
bin = ["dep:icu_datagen", "dep:simple_logger", "dep:log"]
|
||||
|
||||
[[bin]]
|
||||
name = "boa-datagen"
|
||||
path = "src/bin/datagen.rs"
|
||||
required-features = ["bin"]
|
||||
12
javascript-engine/external/boa/boa_icu_provider/README.md
vendored
Normal file
12
javascript-engine/external/boa/boa_icu_provider/README.md
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# boa_icu_provider
|
||||
|
||||
`boa_icu_provider` generates and defines the [ICU4X](https://github.com/unicode-org/icu4x) data provider
|
||||
used in the Boa engine to enable internationalization functionality.
|
||||
|
||||
## Datagen
|
||||
|
||||
To regenerate the data:
|
||||
|
||||
```bash
|
||||
$ cargo run --bin boa-datagen --features bin
|
||||
```
|
||||
BIN
javascript-engine/external/boa/boa_icu_provider/data/icudata.postcard
vendored
Normal file
BIN
javascript-engine/external/boa/boa_icu_provider/data/icudata.postcard
vendored
Normal file
Binary file not shown.
21
javascript-engine/external/boa/boa_icu_provider/src/bin/datagen.rs
vendored
Normal file
21
javascript-engine/external/boa/boa_icu_provider/src/bin/datagen.rs
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
use std::{error::Error, fs::File};
|
||||
|
||||
use boa_icu_provider::data_root;
|
||||
use icu_datagen::{all_keys, datagen, CldrLocaleSubset, Out, SourceData};
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
simple_logger::SimpleLogger::new()
|
||||
.env()
|
||||
.with_level(log::LevelFilter::Info)
|
||||
.init()?;
|
||||
|
||||
let source_data = SourceData::default()
|
||||
.with_cldr_latest(CldrLocaleSubset::Modern)?
|
||||
.with_icuexport_latest()?;
|
||||
|
||||
let blob_out = Out::Blob(Box::new(File::create(
|
||||
data_root().join("icudata.postcard"),
|
||||
)?));
|
||||
|
||||
datagen(None, &all_keys(), &source_data, [blob_out].into()).map_err(Into::into)
|
||||
}
|
||||
94
javascript-engine/external/boa/boa_icu_provider/src/lib.rs
vendored
Normal file
94
javascript-engine/external/boa/boa_icu_provider/src/lib.rs
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
//! Boa's **`boa_icu_provider`** exports the default data provider used by its `Intl` implementation.
|
||||
//!
|
||||
//! # Crate Overview
|
||||
//! This crate exports the function [`buffer`], which contains an extensive dataset of locale data to
|
||||
//! enable `Intl` functionality in the engine. The set of locales included is precisely the ["modern"]
|
||||
//! subset of locales in the [Unicode Common Locale Data Repository][cldr].
|
||||
//!
|
||||
//! If you need to support the full set of locales, you can check out the [ICU4X guide] about
|
||||
//! generating custom data providers. Boa supports plugging both [`BufferProvider`]s or [`AnyProvider`]s
|
||||
//! generated by the tool.
|
||||
//!
|
||||
//! ["modern"]: https://github.com/unicode-org/cldr-json/tree/main/cldr-json/cldr-localenames-modern/main
|
||||
//! [cldr]: https://github.com/unicode-org/
|
||||
//! [ICU4X guide]: https://github.com/unicode-org/icu4x/blob/main/docs/tutorials/data_management.md
|
||||
//! [`BufferProvider`]: icu_provider::BufferProvider
|
||||
//! [`AnyProvider`]: icu_provider::AnyProvider
|
||||
|
||||
#![deny(
|
||||
// rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html
|
||||
warnings,
|
||||
future_incompatible,
|
||||
let_underscore,
|
||||
nonstandard_style,
|
||||
rust_2018_compatibility,
|
||||
rust_2018_idioms,
|
||||
rust_2021_compatibility,
|
||||
unused,
|
||||
|
||||
// rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html
|
||||
macro_use_extern_crate,
|
||||
meta_variable_misuse,
|
||||
missing_abi,
|
||||
missing_copy_implementations,
|
||||
missing_debug_implementations,
|
||||
non_ascii_idents,
|
||||
noop_method_call,
|
||||
single_use_lifetimes,
|
||||
trivial_casts,
|
||||
trivial_numeric_casts,
|
||||
unreachable_pub,
|
||||
unsafe_op_in_unsafe_fn,
|
||||
unused_import_braces,
|
||||
unused_lifetimes,
|
||||
unused_qualifications,
|
||||
unused_tuple_struct_fields,
|
||||
variant_size_differences,
|
||||
|
||||
// rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html
|
||||
rustdoc::broken_intra_doc_links,
|
||||
rustdoc::private_intra_doc_links,
|
||||
rustdoc::missing_crate_level_docs,
|
||||
rustdoc::private_doc_tests,
|
||||
rustdoc::invalid_codeblock_attributes,
|
||||
rustdoc::invalid_rust_codeblocks,
|
||||
rustdoc::bare_urls,
|
||||
|
||||
// clippy categories https://doc.rust-lang.org/clippy/
|
||||
clippy::all,
|
||||
clippy::correctness,
|
||||
clippy::suspicious,
|
||||
clippy::style,
|
||||
clippy::complexity,
|
||||
clippy::perf,
|
||||
clippy::pedantic,
|
||||
clippy::nursery,
|
||||
)]
|
||||
|
||||
/// Gets the path to the directory where the generated data is stored.
|
||||
#[must_use]
|
||||
#[doc(hidden)]
|
||||
pub fn data_root() -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(std::env!("CARGO_MANIFEST_DIR")).join("data")
|
||||
}
|
||||
|
||||
use icu_provider::BufferProvider;
|
||||
use icu_provider_adapters::fallback::LocaleFallbackProvider;
|
||||
use icu_provider_blob::BlobDataProvider;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
/// Gets a data provider that is stored as a [`BufferProvider`]
|
||||
#[must_use]
|
||||
pub fn buffer() -> &'static impl BufferProvider {
|
||||
static PROVIDER: Lazy<LocaleFallbackProvider<BlobDataProvider>> = Lazy::new(|| {
|
||||
let blob = BlobDataProvider::try_new_from_static_blob(include_bytes!(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/data/icudata.postcard"
|
||||
)))
|
||||
.expect("The statically compiled data file should be valid.");
|
||||
LocaleFallbackProvider::try_new_with_buffer_provider(blob)
|
||||
.expect("The statically compiled data file should be valid.")
|
||||
});
|
||||
|
||||
&*PROVIDER
|
||||
}
|
||||
Reference in New Issue
Block a user