mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 00:02:03 +00:00
e2feba391c
* feat(rust): add resource types * write tests * copy from go-resources * implement frontend for rust * update * update cli * update tests * update Signed-off-by: pyranota <pyra@duck.com> * fix package-lock * fix ci * update parser Signed-off-by: pyranota <pyra@duck.com> * Update frontend/src/lib/components/Editor.svelte Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --------- Signed-off-by: pyranota <pyra@duck.com> Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
108 lines
2.8 KiB
JavaScript
108 lines
2.8 KiB
JavaScript
|
|
|
|
let WASM_VECTOR_LEN = 0;
|
|
|
|
let cachedUint8ArrayMemory0 = null;
|
|
|
|
function getUint8ArrayMemory0() {
|
|
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
}
|
|
return cachedUint8ArrayMemory0;
|
|
}
|
|
|
|
const cachedTextEncoder = new TextEncoder();
|
|
|
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
|
|
if (realloc === undefined) {
|
|
const buf = cachedTextEncoder.encode(arg);
|
|
const ptr = malloc(buf.length, 1) >>> 0;
|
|
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
WASM_VECTOR_LEN = buf.length;
|
|
return ptr;
|
|
}
|
|
|
|
let len = arg.length;
|
|
let ptr = malloc(len, 1) >>> 0;
|
|
|
|
const mem = getUint8ArrayMemory0();
|
|
|
|
let offset = 0;
|
|
|
|
for (; offset < len; offset++) {
|
|
const code = arg.charCodeAt(offset);
|
|
if (code > 0x7F) break;
|
|
mem[ptr + offset] = code;
|
|
}
|
|
|
|
if (offset !== len) {
|
|
if (offset !== 0) {
|
|
arg = arg.slice(offset);
|
|
}
|
|
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
|
|
offset += ret.written;
|
|
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
}
|
|
|
|
WASM_VECTOR_LEN = offset;
|
|
return ptr;
|
|
}
|
|
|
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
|
|
cachedTextDecoder.decode();
|
|
|
|
function decodeText(ptr, len) {
|
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
}
|
|
|
|
function getStringFromWasm0(ptr, len) {
|
|
ptr = ptr >>> 0;
|
|
return decodeText(ptr, len);
|
|
}
|
|
/**
|
|
* @param {string} code
|
|
* @returns {string}
|
|
*/
|
|
export function parse_rust(code) {
|
|
let deferred2_0;
|
|
let deferred2_1;
|
|
try {
|
|
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.parse_rust(ptr0, len0);
|
|
deferred2_0 = ret[0];
|
|
deferred2_1 = ret[1];
|
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
}
|
|
}
|
|
|
|
const imports = {
|
|
__wbindgen_placeholder__: {
|
|
__wbindgen_init_externref_table: function() {
|
|
const table = wasm.__wbindgen_export_0;
|
|
const offset = table.grow(4);
|
|
table.set(0, undefined);
|
|
table.set(offset + 0, undefined);
|
|
table.set(offset + 1, null);
|
|
table.set(offset + 2, true);
|
|
table.set(offset + 3, false);
|
|
;
|
|
},
|
|
},
|
|
|
|
};
|
|
|
|
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();
|
|
|