git.delta.rocks / jrsonnet / refs/commits / 3e1d3979f00f

difftreelog

feat wire jrsonnet-web for experimental features

mqyzspnqYaroslav Bolyukin2026-05-06parent: #7324ad9.patch.diff
in: master

11 files changed

modifiedCargo.lockdiffbeforeafterboth
2695 "jrsonnet-stdlib",2695 "jrsonnet-stdlib",
2696 "jrsonnet-types",2696 "jrsonnet-types",
2697 "js-sys",2697 "js-sys",
2698 "num-bigint",
2698 "rustc-hash 2.1.2",2699 "rustc-hash 2.1.2",
2699 "url",2700 "url",
2700 "wasm-bindgen",2701 "wasm-bindgen",
modifiedbindings/jrsonnet-web/Cargo.tomldiffbeforeafterboth
9repository.workspace = true9repository.workspace = true
10version.workspace = true10version.workspace = true
11
12[features]
13experimental = ["exp-preserve-order", "exp-bigint"]
14exp-preserve-order = [
15 "jrsonnet-evaluator/exp-preserve-order",
16 "jrsonnet-stdlib/exp-preserve-order",
17]
18exp-bigint = [
19 "dep:num-bigint",
20 "jrsonnet-evaluator/exp-bigint",
21 "jrsonnet-stdlib/exp-bigint",
22 "jrsonnet-types/exp-bigint",
23]
1124
12[dependencies]25[dependencies]
13console_error_panic_hook.workspace = true26console_error_panic_hook.workspace = true
19jrsonnet-stdlib.workspace = true32jrsonnet-stdlib.workspace = true
20jrsonnet-types.workspace = true33jrsonnet-types.workspace = true
21js-sys.workspace = true34js-sys.workspace = true
35num-bigint = { workspace = true, optional = true }
22rustc-hash.workspace = true36rustc-hash.workspace = true
23url.workspace = true37url.workspace = true
24wasm-bindgen.workspace = true38wasm-bindgen.workspace = true
modifiedbindings/jrsonnet-web/src/lib.rsdiffbeforeafterboth
31 Arr,31 Arr,
32 Obj,32 Obj,
33 Func,33 Func,
34 BigInt,
34}35}
3536
36thread_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 = value
192 .to_string(10)
193 .map_err(|_| JsError::new("invalid bigint"))?
194 .into();
195 let bi = s
196 .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.obj
343 .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())
modifiedcrates/jrsonnet-cli/Cargo.tomldiffbeforeafterboth
13workspace = true13workspace = true
1414
15[features]15[features]
16experimental = [
17 "exp-preserve-order",
18 "exp-bigint",
19 "exp-null-coaelse",
20 "exp-regex",
21]
16exp-preserve-order = [22exp-preserve-order = [
17 "jrsonnet-evaluator/exp-preserve-order",23 "jrsonnet-evaluator/exp-preserve-order",
18 "jrsonnet-stdlib/exp-preserve-order",24 "jrsonnet-stdlib/exp-preserve-order",
modifiedcrates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth
26# Use PEG parser26# Use PEG parser
27peg-parser = ["dep:jrsonnet-peg-parser"]27peg-parser = ["dep:jrsonnet-peg-parser"]
2828
29experimental = [
30 "exp-preserve-order",
31 "exp-destruct",
32 "exp-object-iteration",
33 "exp-bigint",
34 "exp-null-coaelse",
35]
29# Allows to preserve field order in objects36# Allows to preserve field order in objects
30exp-preserve-order = []37exp-preserve-order = []
31# Implements field destructuring38# Implements field destructuring
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
43pub use jrsonnet_interner::{IBytes, IStr};43pub use jrsonnet_interner::{IBytes, IStr};
44use jrsonnet_ir::Expr;44use jrsonnet_ir::Expr;
45pub use jrsonnet_ir::{NumValue, Source, SourcePath, SourceUrl, SourceVirtual, Span};45pub use jrsonnet_ir::{
46 NumValue, Source, SourceDefaultIgnoreJpath, SourcePath, SourceUrl, SourceVirtual, Span,
47};
46#[doc(hidden)]48#[doc(hidden)]
47pub use jrsonnet_macros;49pub use jrsonnet_macros;
modifiedcrates/jrsonnet-ir-parser/Cargo.tomldiffbeforeafterboth
10version.workspace = true10version.workspace = true
1111
12[features]12[features]
13default = []
14experimental = ["exp-null-coaelse", "exp-destruct"]
13exp-null-coaelse = ["jrsonnet-ir/exp-null-coaelse"]15exp-null-coaelse = ["jrsonnet-ir/exp-null-coaelse"]
14exp-destruct = ["jrsonnet-ir/exp-destruct"]16exp-destruct = ["jrsonnet-ir/exp-destruct"]
1517
modifiedcrates/jrsonnet-ir/Cargo.tomldiffbeforeafterboth
1212
13[features]13[features]
14default = []14default = []
15experimental = ["exp-destruct", "exp-null-coaelse"]
15exp-destruct = []16exp-destruct = []
16exp-null-coaelse = []17exp-null-coaelse = []
1718
modifiedcrates/jrsonnet-peg-parser/Cargo.tomldiffbeforeafterboth
2222
23[features]23[features]
24default = []24default = []
25experimental = ["exp-destruct", "exp-null-coaelse"]
25exp-destruct = ["jrsonnet-ir/exp-destruct"]26exp-destruct = ["jrsonnet-ir/exp-destruct"]
26exp-null-coaelse = ["jrsonnet-ir/exp-null-coaelse"]27exp-null-coaelse = ["jrsonnet-ir/exp-null-coaelse"]
2728
modifiedcrates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth
13workspace = true13workspace = true
1414
15[features]15[features]
16experimental = [
17 "exp-preserve-order",
18 "exp-bigint",
19 "exp-null-coaelse",
20 "exp-regex",
21]
16# Add order preservation flag to some functions22# Add order preservation flag to some functions
17exp-preserve-order = ["jrsonnet-evaluator/exp-preserve-order"]23exp-preserve-order = ["jrsonnet-evaluator/exp-preserve-order"]
18# Bigint type24# Bigint type
modifiedcrates/jrsonnet-types/Cargo.tomldiffbeforeafterboth
18peg.workspace = true18peg.workspace = true
1919
20[features]20[features]
21experimental = ["exp-bigint"]
21exp-bigint = []22exp-bigint = []
2223