@influxdata/flux-lsp-node
Advanced tools
Comparing version 0.6.12 to 0.7.0
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* Parse flux into an AST representation. The AST will be generated regardless | ||
* of valid flux. As such, no error handling is needed. | ||
* @param {string} script | ||
* @returns {any} | ||
* Initialize logging - this requires the "console_log" feature to function, | ||
* as this library adds 180k to the wasm binary being shipped. | ||
*/ | ||
export function parse(script: string): any; | ||
export function initLog(): void; | ||
/** | ||
* Format a flux script from AST. | ||
* | ||
* In the event that the flux is invalid syntax, an Err will be returned, | ||
* which will translate into a JavaScript exception being thrown. | ||
* @param {any} js_file | ||
* @returns {string} | ||
* Lsp is the core lsp server interface. | ||
*/ | ||
export function format_from_js_file(js_file: any): string; | ||
export class Lsp { | ||
free(): void; | ||
/** | ||
*/ | ||
export class Server { | ||
free(): void; | ||
constructor(); | ||
/** | ||
* @param {boolean} disable_folding | ||
* @param {boolean} _support_multiple_files | ||
* Attach a message handler to server messages. | ||
* @param {Function} func | ||
*/ | ||
constructor(disable_folding: boolean, _support_multiple_files: boolean); | ||
onMessage(func: Function): void; | ||
/** | ||
* Send a message to the server. | ||
* @param {string} msg | ||
* @returns {Promise<any>} | ||
*/ | ||
process(msg: string): Promise<any>; | ||
send(msg: string): Promise<any>; | ||
/** | ||
* @param {Function} _f | ||
* Run the server. | ||
* | ||
* Note: this will run for the lifetime of the server. It should not be | ||
* `await`ed. However, as it returns a Promise, it's a good idea to attach | ||
* handlers for completion and error. If the promise ever resolves, the server | ||
* is no longer running, which may serve as a hint that attention is needed. | ||
* @returns {Promise<any>} | ||
*/ | ||
register_buckets_callback(_f: Function): void; | ||
/** | ||
* @param {Function} _f | ||
*/ | ||
register_measurements_callback(_f: Function): void; | ||
/** | ||
* @param {Function} _f | ||
*/ | ||
register_tag_keys_callback(_f: Function): void; | ||
/** | ||
* @param {Function} _f | ||
*/ | ||
register_tag_values_callback(_f: Function): void; | ||
run(): Promise<any>; | ||
} | ||
/** | ||
*/ | ||
export class ServerResponse { | ||
free(): void; | ||
/** | ||
* @returns {string | undefined} | ||
*/ | ||
get_message(): string | undefined; | ||
/** | ||
* @returns {string | undefined} | ||
*/ | ||
get_error(): string | undefined; | ||
} |
let imports = {}; | ||
imports['__wbindgen_placeholder__'] = module.exports; | ||
let wasm; | ||
const { TextDecoder, TextEncoder } = require(`util`); | ||
const { TextEncoder, TextDecoder } = require(`util`); | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
const heap = new Array(32).fill(undefined); | ||
cachedTextDecoder.decode(); | ||
heap.push(undefined, null, true, false); | ||
function getObject(idx) { return heap[idx]; } | ||
let WASM_VECTOR_LEN = 0; | ||
let cachegetUint8Memory0 = null; | ||
@@ -18,25 +22,2 @@ function getUint8Memory0() { | ||
function getStringFromWasm0(ptr, len) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
const heap = new Array(32).fill(undefined); | ||
heap.push(undefined, null, true, false); | ||
let heap_next = heap.length; | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function getObject(idx) { return heap[idx]; } | ||
let WASM_VECTOR_LEN = 0; | ||
let cachedTextEncoder = new TextEncoder('utf-8'); | ||
@@ -103,2 +84,21 @@ | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
function getStringFromWasm0(ptr, len) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
let heap_next = heap.length; | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function dropObject(idx) { | ||
@@ -116,2 +116,67 @@ if (idx < 36) return; | ||
function debugString(val) { | ||
// primitive types | ||
const type = typeof val; | ||
if (type == 'number' || type == 'boolean' || val == null) { | ||
return `${val}`; | ||
} | ||
if (type == 'string') { | ||
return `"${val}"`; | ||
} | ||
if (type == 'symbol') { | ||
const description = val.description; | ||
if (description == null) { | ||
return 'Symbol'; | ||
} else { | ||
return `Symbol(${description})`; | ||
} | ||
} | ||
if (type == 'function') { | ||
const name = val.name; | ||
if (typeof name == 'string' && name.length > 0) { | ||
return `Function(${name})`; | ||
} else { | ||
return 'Function'; | ||
} | ||
} | ||
// objects | ||
if (Array.isArray(val)) { | ||
const length = val.length; | ||
let debug = '['; | ||
if (length > 0) { | ||
debug += debugString(val[0]); | ||
} | ||
for(let i = 1; i < length; i++) { | ||
debug += ', ' + debugString(val[i]); | ||
} | ||
debug += ']'; | ||
return debug; | ||
} | ||
// Test for built-in | ||
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); | ||
let className; | ||
if (builtInMatches.length > 1) { | ||
className = builtInMatches[1]; | ||
} else { | ||
// Failed to match the standard '[object ClassName]' | ||
return toString.call(val); | ||
} | ||
if (className == 'Object') { | ||
// we're a user defined class or Object | ||
// JSON.stringify avoids problems with cycles, and is generally much | ||
// easier than looping through ownProperties of `val`. | ||
try { | ||
return 'Object(' + JSON.stringify(val) + ')'; | ||
} catch (_) { | ||
return 'Object'; | ||
} | ||
} | ||
// errors | ||
if (val instanceof Error) { | ||
return `${val.name}: ${val.message}\n${val.stack}`; | ||
} | ||
// TODO we could test for more things here, like `Set`s and `Map`s. | ||
return className; | ||
} | ||
function makeMutClosure(arg0, arg1, dtor, f) { | ||
@@ -141,3 +206,3 @@ const state = { a: arg0, b: arg1, cnt: 1, dtor }; | ||
} | ||
function __wbg_adapter_18(arg0, arg1, arg2) { | ||
function __wbg_adapter_16(arg0, arg1, arg2) { | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h6262b9cc0248558d(arg0, arg1, addHeapObject(arg2)); | ||
@@ -147,35 +212,9 @@ } | ||
/** | ||
* Parse flux into an AST representation. The AST will be generated regardless | ||
* of valid flux. As such, no error handling is needed. | ||
* @param {string} script | ||
* @returns {any} | ||
* Initialize logging - this requires the "console_log" feature to function, | ||
* as this library adds 180k to the wasm binary being shipped. | ||
*/ | ||
module.exports.parse = function(script) { | ||
var ptr0 = passStringToWasm0(script, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.parse(ptr0, len0); | ||
return takeObject(ret); | ||
module.exports.initLog = function() { | ||
wasm.initLog(); | ||
}; | ||
/** | ||
* Format a flux script from AST. | ||
* | ||
* In the event that the flux is invalid syntax, an Err will be returned, | ||
* which will translate into a JavaScript exception being thrown. | ||
* @param {any} js_file | ||
* @returns {string} | ||
*/ | ||
module.exports.format_from_js_file = function(js_file) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.format_from_js_file(retptr, addHeapObject(js_file)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
return getStringFromWasm0(r0, r1); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(r0, r1); | ||
} | ||
}; | ||
function handleError(f, args) { | ||
@@ -188,3 +227,3 @@ try { | ||
} | ||
function __wbg_adapter_41(arg0, arg1, arg2, arg3) { | ||
function __wbg_adapter_32(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h061d51273edd4f83(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
@@ -194,7 +233,8 @@ } | ||
/** | ||
* Lsp is the core lsp server interface. | ||
*/ | ||
class Server { | ||
class Lsp { | ||
static __wrap(ptr) { | ||
const obj = Object.create(Server.prototype); | ||
const obj = Object.create(Lsp.prototype); | ||
obj.ptr = ptr; | ||
@@ -214,116 +254,45 @@ | ||
const ptr = this.__destroy_into_raw(); | ||
wasm.__wbg_server_free(ptr); | ||
wasm.__wbg_lsp_free(ptr); | ||
} | ||
/** | ||
* @param {boolean} disable_folding | ||
* @param {boolean} _support_multiple_files | ||
*/ | ||
constructor(disable_folding, _support_multiple_files) { | ||
var ret = wasm.server_new(disable_folding, _support_multiple_files); | ||
return Server.__wrap(ret); | ||
constructor() { | ||
var ret = wasm.lsp_new(); | ||
return Lsp.__wrap(ret); | ||
} | ||
/** | ||
* Attach a message handler to server messages. | ||
* @param {Function} func | ||
*/ | ||
onMessage(func) { | ||
wasm.lsp_onMessage(this.ptr, addHeapObject(func)); | ||
} | ||
/** | ||
* Send a message to the server. | ||
* @param {string} msg | ||
* @returns {Promise<any>} | ||
*/ | ||
process(msg) { | ||
send(msg) { | ||
var ptr0 = passStringToWasm0(msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.server_process(this.ptr, ptr0, len0); | ||
var ret = wasm.lsp_send(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
} | ||
/** | ||
* @param {Function} _f | ||
* Run the server. | ||
* | ||
* Note: this will run for the lifetime of the server. It should not be | ||
* `await`ed. However, as it returns a Promise, it's a good idea to attach | ||
* handlers for completion and error. If the promise ever resolves, the server | ||
* is no longer running, which may serve as a hint that attention is needed. | ||
* @returns {Promise<any>} | ||
*/ | ||
register_buckets_callback(_f) { | ||
wasm.server_register_buckets_callback(this.ptr, addHeapObject(_f)); | ||
} | ||
/** | ||
* @param {Function} _f | ||
*/ | ||
register_measurements_callback(_f) { | ||
wasm.server_register_measurements_callback(this.ptr, addHeapObject(_f)); | ||
} | ||
/** | ||
* @param {Function} _f | ||
*/ | ||
register_tag_keys_callback(_f) { | ||
wasm.server_register_tag_keys_callback(this.ptr, addHeapObject(_f)); | ||
} | ||
/** | ||
* @param {Function} _f | ||
*/ | ||
register_tag_values_callback(_f) { | ||
wasm.server_register_tag_values_callback(this.ptr, addHeapObject(_f)); | ||
} | ||
} | ||
module.exports.Server = Server; | ||
/** | ||
*/ | ||
class ServerResponse { | ||
static __wrap(ptr) { | ||
const obj = Object.create(ServerResponse.prototype); | ||
obj.ptr = ptr; | ||
return obj; | ||
} | ||
__destroy_into_raw() { | ||
const ptr = this.ptr; | ||
this.ptr = 0; | ||
return ptr; | ||
} | ||
free() { | ||
run() { | ||
const ptr = this.__destroy_into_raw(); | ||
wasm.__wbg_serverresponse_free(ptr); | ||
var ret = wasm.lsp_run(ptr); | ||
return takeObject(ret); | ||
} | ||
/** | ||
* @returns {string | undefined} | ||
*/ | ||
get_message() { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.serverresponse_get_message(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
let v0; | ||
if (r0 !== 0) { | ||
v0 = getStringFromWasm0(r0, r1).slice(); | ||
wasm.__wbindgen_free(r0, r1 * 1); | ||
} | ||
return v0; | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* @returns {string | undefined} | ||
*/ | ||
get_error() { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.serverresponse_get_error(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
let v0; | ||
if (r0 !== 0) { | ||
v0 = getStringFromWasm0(r0, r1).slice(); | ||
wasm.__wbindgen_free(r0, r1 * 1); | ||
} | ||
return v0; | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
} | ||
module.exports.ServerResponse = ServerResponse; | ||
module.exports.Lsp = Lsp; | ||
module.exports.__wbindgen_json_parse = function(arg0, arg1) { | ||
var ret = JSON.parse(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbindgen_json_serialize = function(arg0, arg1) { | ||
@@ -338,2 +307,7 @@ const obj = getObject(arg1); | ||
module.exports.__wbindgen_string_new = function(arg0, arg1) { | ||
var ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbindgen_object_drop_ref = function(arg0) { | ||
@@ -348,12 +322,2 @@ takeObject(arg0); | ||
module.exports.__wbg_serverresponse_new = function(arg0) { | ||
var ret = ServerResponse.__wrap(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbindgen_string_new = function(arg0, arg1) { | ||
var ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_new_693216e109162396 = function() { | ||
@@ -407,3 +371,3 @@ var ret = new Error(); | ||
try { | ||
return __wbg_adapter_41(a, state0.b, arg0, arg1); | ||
return __wbg_adapter_32(a, state0.b, arg0, arg1); | ||
} finally { | ||
@@ -435,2 +399,10 @@ state0.a = a; | ||
module.exports.__wbindgen_debug_string = function(arg0, arg1) { | ||
var ret = debugString(getObject(arg1)); | ||
var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len0; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr0; | ||
}; | ||
module.exports.__wbindgen_throw = function(arg0, arg1) { | ||
@@ -440,8 +412,4 @@ throw new Error(getStringFromWasm0(arg0, arg1)); | ||
module.exports.__wbindgen_rethrow = function(arg0) { | ||
throw takeObject(arg0); | ||
}; | ||
module.exports.__wbindgen_closure_wrapper8050 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 1148, __wbg_adapter_18); | ||
module.exports.__wbindgen_closure_wrapper8275 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 1171, __wbg_adapter_16); | ||
return addHeapObject(ret); | ||
@@ -448,0 +416,0 @@ }; |
@@ -7,3 +7,3 @@ { | ||
"description": "LSP support for the flux language", | ||
"version": "0.6.12", | ||
"version": "0.7.0", | ||
"license": "MIT", | ||
@@ -10,0 +10,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
3390840
0
392