difftreelog
feat wire jrsonnet-web for experimental features
in: master
11 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2695,6 +2695,7 @@
"jrsonnet-stdlib",
"jrsonnet-types",
"js-sys",
+ "num-bigint",
"rustc-hash 2.1.2",
"url",
"wasm-bindgen",
bindings/jrsonnet-web/Cargo.tomldiffbeforeafterboth--- a/bindings/jrsonnet-web/Cargo.toml
+++ b/bindings/jrsonnet-web/Cargo.toml
@@ -9,6 +9,19 @@
repository.workspace = true
version.workspace = true
+[features]
+experimental = ["exp-preserve-order", "exp-bigint"]
+exp-preserve-order = [
+ "jrsonnet-evaluator/exp-preserve-order",
+ "jrsonnet-stdlib/exp-preserve-order",
+]
+exp-bigint = [
+ "dep:num-bigint",
+ "jrsonnet-evaluator/exp-bigint",
+ "jrsonnet-stdlib/exp-bigint",
+ "jrsonnet-types/exp-bigint",
+]
+
[dependencies]
console_error_panic_hook.workspace = true
getrandom = { workspace = true, features = ["wasm_js"] }
@@ -19,6 +32,7 @@
jrsonnet-stdlib.workspace = true
jrsonnet-types.workspace = true
js-sys.workspace = true
+num-bigint = { workspace = true, optional = true }
rustc-hash.workspace = true
url.workspace = true
wasm-bindgen.workspace = true
bindings/jrsonnet-web/src/lib.rsdiffbeforeafterboth31 Arr,31 Arr,32 Obj,32 Obj,33 Func,33 Func,34 BigInt,34}35}353636thread_local! {37thread_local! {132 ValType::Arr => Self::Arr,133 ValType::Arr => Self::Arr,133 ValType::Obj => Self::Obj,134 ValType::Obj => Self::Obj,134 ValType::Func => Self::Func,135 ValType::Func => Self::Func,136 #[cfg(feature = "exp-bigint")]137 ValType::BigInt => Self::BigInt,135 }138 }136 }139 }137}140}182 pub fn string(s: String) -> Self {185 pub fn string(s: String) -> Self {183 Self::new(Val::string(s))186 Self::new(Val::string(s))184 }187 }188 pub fn bigint(value: js_sys::BigInt) -> Result<Self, JsError> {189 #[cfg(feature = "exp-bigint")]190 {191 let s: String = value192 .to_string(10)193 .map_err(|_| JsError::new("invalid bigint"))?194 .into();195 let bi = s196 .parse::<num_bigint::BigInt>()197 .map_err(|e| JsError::new(&format!("failed to parse bigint: {e}")))?;198 Ok(Self::new(Val::BigInt(Box::new(bi))))199 }200 #[cfg(not(feature = "exp-bigint"))]201 {202 let _ = value;203 Err(JsError::new(204 "bigint support is not enabled in this build (exp-bigint feature)",205 ))206 }207 }185 pub fn arr(items: Vec<WasmVal>) -> Self {208 pub fn arr(items: Vec<WasmVal>) -> Self {186 Self::new(Val::arr(209 Self::new(Val::arr(187 items.into_iter().map(|v| v.val).collect::<Vec<_>>(),210 items.into_iter().map(|v| v.val).collect::<Vec<_>>(),212 pub fn as_num(&self) -> Option<f64> {235 pub fn as_num(&self) -> Option<f64> {213 self.val.as_num()236 self.val.as_num()214 }237 }238 #[wasm_bindgen(js_name = asBigint)]239 pub fn as_bigint(&self) -> Result<Option<js_sys::BigInt>, JsError> {240 #[cfg(feature = "exp-bigint")]241 {242 let Some(bi) = self.val.as_bigint() else {243 return Ok(None);244 };245 let big = js_sys::BigInt::new(&JsValue::from_str(&bi.to_string()))246 .map_err(|e| JsError::new(&format!("{e:?}")))?;247 Ok(Some(big))248 }249 #[cfg(not(feature = "exp-bigint"))]250 {251 Err(JsError::new(252 "bigint support is not enabled in this build (exp-bigint feature)",253 ))254 }255 }215 #[wasm_bindgen(js_name = asString)]256 #[wasm_bindgen(js_name = asString)]216 pub fn as_string(&self) -> Option<String> {257 pub fn as_string(&self) -> Option<String> {217 self.val.as_str().map(|s| s.to_string())258 self.val.as_str().map(|s| s.to_string())260 #[wasm_bindgen(js_name = manifestJson)]301 #[wasm_bindgen(js_name = manifestJson)]261 pub fn manifest_json(&self, indent: u32) -> Result<String, JsValue> {302 pub fn manifest_json(&self, indent: u32) -> Result<String, JsValue> {262 self.manifest_with(JsonFormat::cli(indent as usize))303 self.manifest_with(JsonFormat::cli(304 indent as usize,305 #[cfg(feature = "exp-preserve-order")]306 false,307 ))263 }308 }264 #[wasm_bindgen(js_name = manifestToString)]309 #[wasm_bindgen(js_name = manifestToString)]273 pub fn manifest_yaml(&self, indent: u32, quote_keys: bool) -> Result<String, JsValue> {318 pub fn manifest_yaml(&self, indent: u32, quote_keys: bool) -> Result<String, JsValue> {274 self.manifest_with(YamlFormat::std_to_yaml(indent != 0, quote_keys))319 self.manifest_with(YamlFormat::std_to_yaml(320 indent != 0,321 quote_keys,322 #[cfg(feature = "exp-preserve-order")]323 false,324 ))275 }325 }276 #[wasm_bindgen(js_name = manifestYamlStream)]326 #[wasm_bindgen(js_name = manifestYamlStream)]283 self.manifest_with(YamlStreamFormat::std_yaml_stream(333 self.manifest_with(YamlStreamFormat::std_yaml_stream(284 YamlFormat::std_to_yaml(indent != 0, quote_keys),334 YamlFormat::std_to_yaml(335 indent != 0,336 quote_keys,337 #[cfg(feature = "exp-preserve-order")]338 false,339 ),285 c_document_end,340 c_document_end,286 ))341 ))292 #[wasm_bindgen(js_name = manifestToml)]347 #[wasm_bindgen(js_name = manifestToml)]293 pub fn manifest_toml(&self, indent: u32) -> Result<String, JsValue> {348 pub fn manifest_toml(&self, indent: u32) -> Result<String, JsValue> {294 self.manifest_with(TomlFormat::std_to_toml(" ".repeat(indent as usize)))349 self.manifest_with(TomlFormat::std_to_toml(350 " ".repeat(indent as usize),351 #[cfg(feature = "exp-preserve-order")]352 false,353 ))295 }354 }296 #[wasm_bindgen(js_name = manifestIni)]355 #[wasm_bindgen(js_name = manifestIni)]297 pub fn manifest_ini(&self) -> Result<String, JsValue> {356 pub fn manifest_ini(&self) -> Result<String, JsValue> {298 self.manifest_with(IniFormat::std())357 self.manifest_with(IniFormat::std(358 #[cfg(feature = "exp-preserve-order")]359 false,360 ))299 }361 }300}362}341 pub fn keys(&self) -> Vec<String> {403 pub fn keys(&self) -> Vec<String> {342 self.obj404 self.obj343 .fields()405 .fields(406 #[cfg(feature = "exp-preserve-order")]407 false,408 )344 .into_iter()409 .into_iter()345 .map(|s| s.to_string())410 .map(|s| s.to_string())crates/jrsonnet-cli/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-cli/Cargo.toml
+++ b/crates/jrsonnet-cli/Cargo.toml
@@ -13,6 +13,12 @@
workspace = true
[features]
+experimental = [
+ "exp-preserve-order",
+ "exp-bigint",
+ "exp-null-coaelse",
+ "exp-regex",
+]
exp-preserve-order = [
"jrsonnet-evaluator/exp-preserve-order",
"jrsonnet-stdlib/exp-preserve-order",
crates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-evaluator/Cargo.toml
+++ b/crates/jrsonnet-evaluator/Cargo.toml
@@ -26,6 +26,13 @@
# Use PEG parser
peg-parser = ["dep:jrsonnet-peg-parser"]
+experimental = [
+ "exp-preserve-order",
+ "exp-destruct",
+ "exp-object-iteration",
+ "exp-bigint",
+ "exp-null-coaelse",
+]
# Allows to preserve field order in objects
exp-preserve-order = []
# Implements field destructuring
crates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -42,7 +42,9 @@
use jrsonnet_gcmodule::{Cc, Trace, cc_dyn};
pub use jrsonnet_interner::{IBytes, IStr};
use jrsonnet_ir::Expr;
-pub use jrsonnet_ir::{NumValue, Source, SourcePath, SourceUrl, SourceVirtual, Span};
+pub use jrsonnet_ir::{
+ NumValue, Source, SourceDefaultIgnoreJpath, SourcePath, SourceUrl, SourceVirtual, Span,
+};
#[doc(hidden)]
pub use jrsonnet_macros;
crates/jrsonnet-ir-parser/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-ir-parser/Cargo.toml
+++ b/crates/jrsonnet-ir-parser/Cargo.toml
@@ -10,6 +10,8 @@
version.workspace = true
[features]
+default = []
+experimental = ["exp-null-coaelse", "exp-destruct"]
exp-null-coaelse = ["jrsonnet-ir/exp-null-coaelse"]
exp-destruct = ["jrsonnet-ir/exp-destruct"]
crates/jrsonnet-ir/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-ir/Cargo.toml
+++ b/crates/jrsonnet-ir/Cargo.toml
@@ -12,6 +12,7 @@
[features]
default = []
+experimental = ["exp-destruct", "exp-null-coaelse"]
exp-destruct = []
exp-null-coaelse = []
crates/jrsonnet-peg-parser/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-peg-parser/Cargo.toml
+++ b/crates/jrsonnet-peg-parser/Cargo.toml
@@ -22,5 +22,6 @@
[features]
default = []
+experimental = ["exp-destruct", "exp-null-coaelse"]
exp-destruct = ["jrsonnet-ir/exp-destruct"]
exp-null-coaelse = ["jrsonnet-ir/exp-null-coaelse"]
crates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-stdlib/Cargo.toml
+++ b/crates/jrsonnet-stdlib/Cargo.toml
@@ -13,6 +13,12 @@
workspace = true
[features]
+experimental = [
+ "exp-preserve-order",
+ "exp-bigint",
+ "exp-null-coaelse",
+ "exp-regex",
+]
# Add order preservation flag to some functions
exp-preserve-order = ["jrsonnet-evaluator/exp-preserve-order"]
# Bigint type
crates/jrsonnet-types/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-types/Cargo.toml
+++ b/crates/jrsonnet-types/Cargo.toml
@@ -18,4 +18,5 @@
peg.workspace = true
[features]
+experimental = ["exp-bigint"]
exp-bigint = []