diff --git a/backend/parsers/windmill-parser-ts/src/lib.rs b/backend/parsers/windmill-parser-ts/src/lib.rs index 92e81fd5bd..c156d915aa 100644 --- a/backend/parsers/windmill-parser-ts/src/lib.rs +++ b/backend/parsers/windmill-parser-ts/src/lib.rs @@ -402,10 +402,8 @@ fn tstype_to_typ(ts_type: &TsType) -> (Typ, bool) { (tstype_to_typ(&types[other_p]).0, true) } else { if types.len() > 1 { - let one_of_values: Vec = types - .into_iter() - .map_while(parse_one_of_type) - .collect(); + let one_of_values: Vec = + types.into_iter().map_while(parse_one_of_type).collect(); if one_of_values.len() == types.len() { return (Typ::OneOf(one_of_values), false); @@ -480,31 +478,55 @@ fn parse_one_of_type(x: &Box) -> Option { } _ => None, } - } +} fn one_of_label(members: &Vec) -> Option { members.iter().find_map(|y| { - let TsTypeElement::TsPropertySignature(TsPropertySignature { key, type_ann, .. }) = y else { return None; }; - - let Expr::Ident(Ident { sym, .. }) = &**key else { return None; }; - if sym != "label" { return None; } - - let Some(type_ann) = type_ann.as_ref() else { return None; }; - let TsType::TsLitType(TsLitType { lit: TsLit::Str(Str { value, .. }), .. }) = &*type_ann.type_ann else { return None; }; - + let TsTypeElement::TsPropertySignature(TsPropertySignature { key, type_ann, .. }) = y + else { + return None; + }; + + let Expr::Ident(Ident { sym, .. }) = &**key else { + return None; + }; + if sym != "label" { + return None; + } + + let Some(type_ann) = type_ann.as_ref() else { + return None; + }; + let TsType::TsLitType(TsLitType { lit: TsLit::Str(Str { value, .. }), .. }) = + &*type_ann.type_ann + else { + return None; + }; + Some(value.to_string()) }) } fn one_of_properties(members: &Vec) -> Vec { - members.iter().filter_map(|x| { - let TsTypeElement::TsPropertySignature(TsPropertySignature { key, type_ann, .. }) = x else { return None; }; - - let Expr::Ident(Ident { sym, .. }) = *key.to_owned() else { return None; }; - let typ = type_ann.as_ref().map(|typ| Box::new(tstype_to_typ(&*typ.type_ann).0)).unwrap_or(Box::new(Typ::Unknown)); - - Some(ObjectProperty { key: sym.to_string(), typ }) - }).collect() + members + .iter() + .filter_map(|x| { + let TsTypeElement::TsPropertySignature(TsPropertySignature { key, type_ann, .. }) = x + else { + return None; + }; + + let Expr::Ident(Ident { sym, .. }) = *key.to_owned() else { + return None; + }; + let typ = type_ann + .as_ref() + .map(|typ| Box::new(tstype_to_typ(&*typ.type_ann).0)) + .unwrap_or(Box::new(Typ::Unknown)); + + Some(ObjectProperty { key: sym.to_string(), typ }) + }) + .collect() } fn find_undefined(types: &Vec>) -> Option { diff --git a/backend/parsers/windmill-parser-wasm/pkg/package.json b/backend/parsers/windmill-parser-wasm/pkg/package.json index 19fe08828b..9c7c686a2d 100644 --- a/backend/parsers/windmill-parser-wasm/pkg/package.json +++ b/backend/parsers/windmill-parser-wasm/pkg/package.json @@ -3,7 +3,7 @@ "collaborators": [ "Ruben Fiszel " ], - "version": "1.355.4", + "version": "1.364.3", "files": [ "windmill_parser_wasm_bg.wasm", "windmill_parser_wasm.js", diff --git a/backend/parsers/windmill-parser-wasm/pkg/windmill_parser_wasm.js b/backend/parsers/windmill-parser-wasm/pkg/windmill_parser_wasm.js index 4778f33186..adcb22c539 100644 --- a/backend/parsers/windmill-parser-wasm/pkg/windmill_parser_wasm.js +++ b/backend/parsers/windmill-parser-wasm/pkg/windmill_parser_wasm.js @@ -6,6 +6,20 @@ heap.push(undefined, null, true, false); function getObject(idx) { return heap[idx]; } +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + let WASM_VECTOR_LEN = 0; let cachedUint8Memory0 = null; @@ -84,27 +98,13 @@ function getInt32Memory0() { return cachedInt32Memory0; } -let heap_next = heap.length; +let cachedFloat64Memory0 = null; -function dropObject(idx) { - if (idx < 132) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; -} - -const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); - -if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; - -function getStringFromWasm0(ptr, len) { - ptr = ptr >>> 0; - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; } function addHeapObject(obj) { @@ -116,13 +116,13 @@ function addHeapObject(obj) { return idx; } -let cachedFloat64Memory0 = null; +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); -function getFloat64Memory0() { - if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { - cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); - } - return cachedFloat64Memory0; +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); } let cachedBigInt64Memory0 = null; @@ -585,6 +585,9 @@ async function __wbg_load(module, imports) { function __wbg_get_imports() { const imports = {}; imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; imports.wbg.__wbindgen_string_get = function(arg0, arg1) { const obj = getObject(arg1); const ret = typeof(obj) === 'string' ? obj : undefined; @@ -593,13 +596,6 @@ function __wbg_get_imports() { getInt32Memory0()[arg0 / 4 + 1] = len1; getInt32Memory0()[arg0 / 4 + 0] = ptr1; }; - imports.wbg.__wbindgen_object_drop_ref = function(arg0) { - takeObject(arg0); - }; - imports.wbg.__wbindgen_error_new = function(arg0, arg1) { - const ret = new Error(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); - }; imports.wbg.__wbindgen_boolean_get = function(arg0) { const v = getObject(arg0); const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; @@ -636,7 +632,11 @@ function __wbg_get_imports() { const ret = BigInt.asUintN(64, arg0); return addHeapObject(ret); }; - imports.wbg.__wbg_eval_64ce1594989e82f8 = function(arg0, arg1) { + imports.wbg.__wbindgen_error_new = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_eval_2ea6d5f9a10f336a = function(arg0, arg1) { const ret = eval(getStringFromWasm0(arg0, arg1)); return addHeapObject(ret); }; diff --git a/backend/parsers/windmill-parser-wasm/pkg/windmill_parser_wasm_bg.wasm b/backend/parsers/windmill-parser-wasm/pkg/windmill_parser_wasm_bg.wasm index bfe332feeb..8daf94f457 100644 Binary files a/backend/parsers/windmill-parser-wasm/pkg/windmill_parser_wasm_bg.wasm and b/backend/parsers/windmill-parser-wasm/pkg/windmill_parser_wasm_bg.wasm differ diff --git a/frontend/package-lock.json b/frontend/package-lock.json index c4b4ef205b..21f4c2e1dd 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -52,7 +52,7 @@ "vscode-languageclient": "~9.0.1", "vscode-uri": "~3.0.8", "vscode-ws-jsonrpc": "~3.1.0", - "windmill-parser-wasm": "^1.355.4", + "windmill-parser-wasm": "^1.364.3", "windmill-sql-datatype-parser-wasm": "^1.318.0", "y-monaco": "^0.1.4", "y-websocket": "^1.5.0", @@ -10261,9 +10261,9 @@ } }, "node_modules/windmill-parser-wasm": { - "version": "1.355.4", - "resolved": "https://registry.npmjs.org/windmill-parser-wasm/-/windmill-parser-wasm-1.355.4.tgz", - "integrity": "sha512-7Usvb55qAULgGg5ULoMm4iWviAl0fQMNxoDQXx4lrPASpXSSV0BS9anP2jF/gse5HQ1usKj63TNtCFYedMThHg==" + "version": "1.364.3", + "resolved": "https://registry.npmjs.org/windmill-parser-wasm/-/windmill-parser-wasm-1.364.3.tgz", + "integrity": "sha512-P/t7uwyUfi7EjMveE7M5swj2FXlMq36kTb79rN7rsW8a2KMxgR1zs+sP0DBmBoAHMVywyjewF8/6i/8WP9+7Iw==" }, "node_modules/windmill-sql-datatype-parser-wasm": { "version": "1.318.0", diff --git a/frontend/package.json b/frontend/package.json index aecc3d405c..cef9e1e98f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -132,7 +132,7 @@ "vscode-languageclient": "~9.0.1", "vscode-uri": "~3.0.8", "vscode-ws-jsonrpc": "~3.1.0", - "windmill-parser-wasm": "^1.355.4", + "windmill-parser-wasm": "^1.364.3", "windmill-sql-datatype-parser-wasm": "^1.318.0", "y-monaco": "^0.1.4", "y-websocket": "^1.5.0", diff --git a/frontend/src/lib/script_helpers.ts b/frontend/src/lib/script_helpers.ts index 540b3c8871..23ee85226a 100644 --- a/frontend/src/lib/script_helpers.ts +++ b/frontend/src/lib/script_helpers.ts @@ -70,6 +70,13 @@ export async function main( //d: wmill.S3Object, // for large files backed by S3 (https://www.windmill.dev/docs/core_concepts/persistent_storage/large_data_files) e = "inferred type string from default arg", f = { nested: "object" }, + g: { + label: "Variant 1", + foo: string + } | { + label: "Variant 2", + bar: number + } ) { // let x = await wmill.getVariable('u/user/foo') return { foo: a };