@onflow/cadence-language-server
Advanced tools
Comparing version 0.16.0 to 0.17.0
@@ -44,3 +44,3 @@ export const go: Go; | ||
_inst: WebAssembly.Instance | undefined; | ||
_values: (number | boolean | Go | typeof global | null)[] | undefined; | ||
_values: (number | boolean | (NodeJS.Global & typeof globalThis) | Go | null)[] | undefined; | ||
_goRefCounts: any[] | undefined; | ||
@@ -52,84 +52,2 @@ _ids: any; | ||
} | ||
declare namespace global { | ||
namespace fs { | ||
namespace constants { | ||
const O_WRONLY: number; | ||
const O_RDWR: number; | ||
const O_CREAT: number; | ||
const O_TRUNC: number; | ||
const O_APPEND: number; | ||
const O_EXCL: number; | ||
} | ||
function writeSync(fd: any, buf: any): any; | ||
function writeSync(fd: any, buf: any): any; | ||
function write(fd: any, buf: any, offset: any, length: any, position: any, callback: any): void; | ||
function write(fd: any, buf: any, offset: any, length: any, position: any, callback: any): void; | ||
function chmod(path: any, mode: any, callback: any): void; | ||
function chmod(path: any, mode: any, callback: any): void; | ||
function chown(path: any, uid: any, gid: any, callback: any): void; | ||
function chown(path: any, uid: any, gid: any, callback: any): void; | ||
function close(fd: any, callback: any): void; | ||
function close(fd: any, callback: any): void; | ||
function fchmod(fd: any, mode: any, callback: any): void; | ||
function fchmod(fd: any, mode: any, callback: any): void; | ||
function fchown(fd: any, uid: any, gid: any, callback: any): void; | ||
function fchown(fd: any, uid: any, gid: any, callback: any): void; | ||
function fstat(fd: any, callback: any): void; | ||
function fstat(fd: any, callback: any): void; | ||
function fsync(fd: any, callback: any): void; | ||
function fsync(fd: any, callback: any): void; | ||
function ftruncate(fd: any, length: any, callback: any): void; | ||
function ftruncate(fd: any, length: any, callback: any): void; | ||
function lchown(path: any, uid: any, gid: any, callback: any): void; | ||
function lchown(path: any, uid: any, gid: any, callback: any): void; | ||
function link(path: any, link: any, callback: any): void; | ||
function link(path: any, link: any, callback: any): void; | ||
function lstat(path: any, callback: any): void; | ||
function lstat(path: any, callback: any): void; | ||
function mkdir(path: any, perm: any, callback: any): void; | ||
function mkdir(path: any, perm: any, callback: any): void; | ||
function open(path: any, flags: any, mode: any, callback: any): void; | ||
function open(path: any, flags: any, mode: any, callback: any): void; | ||
function read(fd: any, buffer: any, offset: any, length: any, position: any, callback: any): void; | ||
function read(fd: any, buffer: any, offset: any, length: any, position: any, callback: any): void; | ||
function readdir(path: any, callback: any): void; | ||
function readdir(path: any, callback: any): void; | ||
function readlink(path: any, callback: any): void; | ||
function readlink(path: any, callback: any): void; | ||
function rename(from: any, to: any, callback: any): void; | ||
function rename(from: any, to: any, callback: any): void; | ||
function rmdir(path: any, callback: any): void; | ||
function rmdir(path: any, callback: any): void; | ||
function stat(path: any, callback: any): void; | ||
function stat(path: any, callback: any): void; | ||
function symlink(path: any, link: any, callback: any): void; | ||
function symlink(path: any, link: any, callback: any): void; | ||
function truncate(path: any, length: any, callback: any): void; | ||
function truncate(path: any, length: any, callback: any): void; | ||
function unlink(path: any, callback: any): void; | ||
function unlink(path: any, callback: any): void; | ||
function utimes(path: any, atime: any, mtime: any, callback: any): void; | ||
function utimes(path: any, atime: any, mtime: any, callback: any): void; | ||
} | ||
namespace process { | ||
function getuid(): number; | ||
function getuid(): number; | ||
function getgid(): number; | ||
function getgid(): number; | ||
function geteuid(): number; | ||
function geteuid(): number; | ||
function getegid(): number; | ||
function getegid(): number; | ||
function getgroups(): never; | ||
function getgroups(): never; | ||
const pid: number; | ||
const ppid: number; | ||
function umask(): never; | ||
function umask(): never; | ||
function cwd(): never; | ||
function cwd(): never; | ||
function chdir(): never; | ||
function chdir(): never; | ||
} | ||
} | ||
export {}; |
@@ -9,7 +9,2 @@ import { Message } from "vscode-jsonrpc/lib/messages"; | ||
} | ||
declare global { | ||
interface Window { | ||
[key: string]: any; | ||
} | ||
} | ||
export declare class CadenceLanguageServer { | ||
@@ -23,3 +18,3 @@ private static functionNamePrefix; | ||
private isClientClosed; | ||
static create(binaryLocation: string, callbacks: Callbacks): Promise<CadenceLanguageServer>; | ||
static create(binaryLocation: string | BufferSource, callbacks: Callbacks): Promise<CadenceLanguageServer>; | ||
private static ensureLoaded; | ||
@@ -26,0 +21,0 @@ private static load; |
@@ -28,2 +28,3 @@ /* | ||
import { go } from './go.js'; | ||
const env = typeof global !== 'undefined' ? global : window; | ||
export class CadenceLanguageServer { | ||
@@ -36,4 +37,4 @@ constructor(callbacks) { | ||
// from the JS environment into the WebAssembly environment | ||
this.id = window[CadenceLanguageServer.functionName('start')](); | ||
window[this.functionName('toClient')] = (message) => { | ||
this.id = env[CadenceLanguageServer.functionName('start')](); | ||
env[this.functionName('toClient')] = (message) => { | ||
if (!callbacks.toClient) { | ||
@@ -44,3 +45,3 @@ return; | ||
}; | ||
window[this.functionName('getAddressCode')] = (address) => { | ||
env[this.functionName('getAddressCode')] = (address) => { | ||
if (!callbacks.getAddressCode) { | ||
@@ -51,3 +52,3 @@ return undefined; | ||
}; | ||
window[this.functionName('onServerClose')] = () => { | ||
env[this.functionName('onServerClose')] = () => { | ||
if (!callbacks.onServerClose) { | ||
@@ -59,3 +60,3 @@ return; | ||
callbacks.toServer = (error, message) => { | ||
window[this.functionName('toServer')](error, JSON.stringify(message)); | ||
env[this.functionName('toServer')](error, JSON.stringify(message)); | ||
}; | ||
@@ -67,3 +68,3 @@ callbacks.onClientClose = () => { | ||
this.isClientClosed = true; | ||
window[this.functionName('onClientClose')](); | ||
env[this.functionName('onClientClose')](); | ||
}; | ||
@@ -83,3 +84,3 @@ } | ||
} | ||
static ensureLoaded(binaryLocation) { | ||
static ensureLoaded(urlOrBinary) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -90,10 +91,16 @@ if (this.loaded) { | ||
this.setWriteSync(); | ||
yield this.load(binaryLocation); | ||
yield this.load(urlOrBinary); | ||
this.loaded = true; | ||
}); | ||
} | ||
static load(binaryLocation) { | ||
static load(urlOrBinary) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const binary = fetch(binaryLocation); | ||
const instantiatedSource = yield WebAssembly.instantiateStreaming(binary, go.importObject); | ||
let instantiatedSource; | ||
if (typeof urlOrBinary === 'string') { | ||
const binaryRequest = fetch(urlOrBinary); | ||
instantiatedSource = (yield WebAssembly.instantiateStreaming(binaryRequest, go.importObject)); | ||
} | ||
else { | ||
instantiatedSource = yield WebAssembly.instantiate(urlOrBinary, go.importObject); | ||
} | ||
// NOTE: don't await the promise, just ignore it, as it is only resolved when the program exists | ||
@@ -118,3 +125,3 @@ go.run(instantiatedSource.instance).then(() => { }); | ||
// then log the output in the console | ||
window['fs'].writeSync = function (fileDescriptor, buf) { | ||
env['fs'].writeSync = function (fileDescriptor, buf) { | ||
// Get the currently buffered output for the given file descriptor, | ||
@@ -121,0 +128,0 @@ // or initialize it, if there is no buffered output yet. |
{ | ||
"name": "@onflow/cadence-language-server", | ||
"version": "0.16.0", | ||
"version": "0.17.0", | ||
"description": "The Cadence Language Server", | ||
@@ -12,6 +12,11 @@ "homepage": "https://github.com/onflow/cadence", | ||
"scripts": { | ||
"build": "tsc" | ||
"build": "tsc", | ||
"test": "jest" | ||
}, | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
"@types/jest": "^26.0.14", | ||
"jest": "^26.5.3", | ||
"node-fetch": "^2.6.1", | ||
"ts-jest": "^26.4.1", | ||
"typescript": "^4.0.2" | ||
@@ -18,0 +23,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
14379659
5
699