chore(parsers): publish bash parser with CRLF handling (#6905)

This commit is contained in:
hugocasa
2025-10-23 10:33:41 +02:00
committed by GitHub
parent 8bee6ca41e
commit 4b26def0cd
5 changed files with 20 additions and 34 deletions
@@ -4,9 +4,9 @@ use anyhow::anyhow;
use lazy_static::lazy_static;
#[cfg(not(target_arch = "wasm32"))]
use regex::Regex;
use regex::{Match, Regex};
#[cfg(target_arch = "wasm32")]
use regex_lite::Regex;
use regex_lite::{Match, Regex};
use serde_json::json;
@@ -548,7 +548,7 @@ fn parse_pg_file(code: &str) -> anyhow::Result<Option<Vec<Arg>>> {
// The regex doesn't parse types with space such as "character varying"
// So we look for them manually and replace them with their shorter counterpart
fn transform_types_with_spaces<'a>(cap: &regex::Match<'a>, code: &str) -> &'a str {
fn transform_types_with_spaces<'a>(cap: &Match<'a>, code: &str) -> &'a str {
lazy_static! {
static ref TYPES: [(&'static str, &'static str); 6] = [
("character varying", "varchar"),
+12 -26
View File
@@ -11,11 +11,7 @@ function getUint8ArrayMemory0() {
return cachedUint8ArrayMemory0;
}
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
const encodeString = function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
};
const cachedTextEncoder = new TextEncoder();
function passStringToWasm0(arg, malloc, realloc) {
@@ -46,7 +42,7 @@ function passStringToWasm0(arg, malloc, realloc) {
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
const ret = cachedTextEncoder.encodeInto(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
@@ -56,13 +52,17 @@ function passStringToWasm0(arg, malloc, realloc) {
return ptr;
}
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
cachedTextDecoder.decode();
function decodeText(ptr, len) {
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
return decodeText(ptr, len);
}
/**
* @param {string} code
@@ -305,23 +305,9 @@ const imports = {
};
const wasm_url = new URL('windmill_parser_wasm_bg.wasm', import.meta.url);
let wasmCode = '';
switch (wasm_url.protocol) {
case 'file:':
wasmCode = await Deno.readFile(wasm_url);
break
case 'https:':
case 'http:':
wasmCode = await (await fetch(wasm_url)).arrayBuffer();
break
default:
throw new Error(`Unsupported protocol: ${wasm_url.protocol}`);
}
const wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance;
const wasm = wasmInstance.exports;
export const __wasm = wasm;
const wasmUrl = new URL('windmill_parser_wasm_bg.wasm', import.meta.url);
const wasm = (await WebAssembly.instantiateStreaming(fetch(wasmUrl), imports)).instance.exports;
export { wasm as __wasm };
wasm.__wbindgen_start();
Binary file not shown.
+4 -4
View File
@@ -79,7 +79,7 @@
"windmill-parser-wasm-nu": "1.510.1",
"windmill-parser-wasm-php": "1.510.1",
"windmill-parser-wasm-py": "1.538.0",
"windmill-parser-wasm-regex": "1.552.1",
"windmill-parser-wasm-regex": "1.565.0",
"windmill-parser-wasm-ruby": "1.526.1",
"windmill-parser-wasm-rust": "1.558.1",
"windmill-parser-wasm-ts": "1.538.0",
@@ -13759,9 +13759,9 @@
"integrity": "sha512-s+bdIgT/fA5em3zYUwF8D14uA/dZh7iu0krZYZQqZUO7txN37hwSCVfovbMkIwm4zPbsJ50mU8DRLt7UpAPZIw=="
},
"node_modules/windmill-parser-wasm-regex": {
"version": "1.552.1",
"resolved": "https://registry.npmjs.org/windmill-parser-wasm-regex/-/windmill-parser-wasm-regex-1.552.1.tgz",
"integrity": "sha512-TIt3+aR1hrUKuMbLAecT0c3Wdcg6w46Jm0EweMZfeqGX7lDp7SK8Ak1vwmzgBiZMJaM98RNAgyTCZHJiUoAeMA=="
"version": "1.565.0",
"resolved": "https://registry.npmjs.org/windmill-parser-wasm-regex/-/windmill-parser-wasm-regex-1.565.0.tgz",
"integrity": "sha512-fcAy7SkyrCML6YgnsQ5H3utpJFxLqWssGmY+hJAibdQtAYNRASsSQZl87A46nIFO8TpKKiWioTSxZDl/9Ovtrw=="
},
"node_modules/windmill-parser-wasm-ruby": {
"version": "1.526.1",
+1 -1
View File
@@ -144,7 +144,7 @@
"windmill-parser-wasm-nu": "1.510.1",
"windmill-parser-wasm-php": "1.510.1",
"windmill-parser-wasm-py": "1.538.0",
"windmill-parser-wasm-regex": "1.552.1",
"windmill-parser-wasm-regex": "1.565.0",
"windmill-parser-wasm-ruby": "1.526.1",
"windmill-parser-wasm-rust": "1.558.1",
"windmill-parser-wasm-ts": "1.538.0",