@onflow/cadence-language-server
Advanced tools
Comparing version 0.33.4 to 1.0.0-preview.11
221
dist/go.js
@@ -1,4 +0,2 @@ | ||
// Copyright 2018 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
// Adapted from https://github.com/golang/go/blob/go1.20.14/misc/wasm/wasm_exec.js | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -13,4 +11,5 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
const encoder = new TextEncoder("utf-8"); | ||
const decoder = new TextDecoder("utf-8"); | ||
// Copyright 2018 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
const enosys = () => { | ||
@@ -21,62 +20,145 @@ const err = new Error("not implemented"); | ||
}; | ||
// NOTE: required and used by the WASM binary | ||
let outputBuf = ""; | ||
global.fs = { | ||
constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, | ||
writeSync(fd, buf) { | ||
outputBuf += decoder.decode(buf); | ||
const nl = outputBuf.lastIndexOf("\n"); | ||
if (nl != -1) { | ||
console.log(outputBuf.substr(0, nl)); | ||
outputBuf = outputBuf.substr(nl + 1); | ||
} | ||
return buf.length; | ||
}, | ||
write(fd, buf, offset, length, position, callback) { | ||
if (offset !== 0 || length !== buf.length || position !== null) { | ||
if (!globalThis.fs) { | ||
let outputBuf = ""; | ||
globalThis.fs = { | ||
constants: { | ||
O_WRONLY: -1, | ||
O_RDWR: -1, | ||
O_CREAT: -1, | ||
O_TRUNC: -1, | ||
O_APPEND: -1, | ||
O_EXCL: -1, | ||
}, | ||
writeSync(fd, buf) { | ||
outputBuf += decoder.decode(buf); | ||
const nl = outputBuf.lastIndexOf("\n"); | ||
if (nl != -1) { | ||
console.log(outputBuf.substring(0, nl)); | ||
outputBuf = outputBuf.substring(nl + 1); | ||
} | ||
return buf.length; | ||
}, | ||
write(fd, buf, offset, length, position, callback) { | ||
if (offset !== 0 || length !== buf.length || position !== null) { | ||
callback(enosys()); | ||
return; | ||
} | ||
const n = this.writeSync(fd, buf); | ||
callback(null, n); | ||
}, | ||
chmod(path, mode, callback) { | ||
callback(enosys()); | ||
return; | ||
} | ||
const n = this.writeSync(fd, buf); | ||
callback(null, n); | ||
}, | ||
chmod(path, mode, callback) { callback(enosys()); }, | ||
chown(path, uid, gid, callback) { callback(enosys()); }, | ||
close(fd, callback) { callback(enosys()); }, | ||
fchmod(fd, mode, callback) { callback(enosys()); }, | ||
fchown(fd, uid, gid, callback) { callback(enosys()); }, | ||
fstat(fd, callback) { callback(enosys()); }, | ||
fsync(fd, callback) { callback(null); }, | ||
ftruncate(fd, length, callback) { callback(enosys()); }, | ||
lchown(path, uid, gid, callback) { callback(enosys()); }, | ||
link(path, link, callback) { callback(enosys()); }, | ||
lstat(path, callback) { callback(enosys()); }, | ||
mkdir(path, perm, callback) { callback(enosys()); }, | ||
open(path, flags, mode, callback) { callback(enosys()); }, | ||
read(fd, buffer, offset, length, position, callback) { callback(enosys()); }, | ||
readdir(path, callback) { callback(enosys()); }, | ||
readlink(path, callback) { callback(enosys()); }, | ||
rename(from, to, callback) { callback(enosys()); }, | ||
rmdir(path, callback) { callback(enosys()); }, | ||
stat(path, callback) { callback(enosys()); }, | ||
symlink(path, link, callback) { callback(enosys()); }, | ||
truncate(path, length, callback) { callback(enosys()); }, | ||
unlink(path, callback) { callback(enosys()); }, | ||
utimes(path, atime, mtime, callback) { callback(enosys()); }, | ||
}; | ||
// NOTE: required and used by the WASM binary | ||
if (!global.process) { | ||
global.process = { | ||
getuid() { return -1; }, | ||
getgid() { return -1; }, | ||
geteuid() { return -1; }, | ||
getegid() { return -1; }, | ||
getgroups() { throw enosys(); }, | ||
}, | ||
chown(path, uid, gid, callback) { | ||
callback(enosys()); | ||
}, | ||
close(fd, callback) { | ||
callback(enosys()); | ||
}, | ||
fchmod(fd, mode, callback) { | ||
callback(enosys()); | ||
}, | ||
fchown(fd, uid, gid, callback) { | ||
callback(enosys()); | ||
}, | ||
fstat(fd, callback) { | ||
callback(enosys()); | ||
}, | ||
fsync(fd, callback) { | ||
callback(null); | ||
}, | ||
ftruncate(fd, length, callback) { | ||
callback(enosys()); | ||
}, | ||
lchown(path, uid, gid, callback) { | ||
callback(enosys()); | ||
}, | ||
link(path, link, callback) { | ||
callback(enosys()); | ||
}, | ||
lstat(path, callback) { | ||
callback(enosys()); | ||
}, | ||
mkdir(path, perm, callback) { | ||
callback(enosys()); | ||
}, | ||
open(path, flags, mode, callback) { | ||
callback(enosys()); | ||
}, | ||
read(fd, buffer, offset, length, position, callback) { | ||
callback(enosys()); | ||
}, | ||
readdir(path, callback) { | ||
callback(enosys()); | ||
}, | ||
readlink(path, callback) { | ||
callback(enosys()); | ||
}, | ||
rename(from, to, callback) { | ||
callback(enosys()); | ||
}, | ||
rmdir(path, callback) { | ||
callback(enosys()); | ||
}, | ||
stat(path, callback) { | ||
callback(enosys()); | ||
}, | ||
symlink(path, link, callback) { | ||
callback(enosys()); | ||
}, | ||
truncate(path, length, callback) { | ||
callback(enosys()); | ||
}, | ||
unlink(path, callback) { | ||
callback(enosys()); | ||
}, | ||
utimes(path, atime, mtime, callback) { | ||
callback(enosys()); | ||
}, | ||
}; | ||
} | ||
if (!globalThis.process) { | ||
globalThis.process = { | ||
getuid() { | ||
return -1; | ||
}, | ||
getgid() { | ||
return -1; | ||
}, | ||
geteuid() { | ||
return -1; | ||
}, | ||
getegid() { | ||
return -1; | ||
}, | ||
getgroups() { | ||
throw enosys(); | ||
}, | ||
pid: -1, | ||
ppid: -1, | ||
umask() { throw enosys(); }, | ||
cwd() { throw enosys(); }, | ||
chdir() { throw enosys(); }, | ||
umask() { | ||
throw enosys(); | ||
}, | ||
cwd() { | ||
throw enosys(); | ||
}, | ||
chdir() { | ||
throw enosys(); | ||
}, | ||
}; | ||
} | ||
if (!globalThis.crypto) { | ||
throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)"); | ||
} | ||
if (!globalThis.performance) { | ||
throw new Error("globalThis.performance is not available, polyfill required (performance.now only)"); | ||
} | ||
if (!globalThis.TextEncoder) { | ||
throw new Error("globalThis.TextEncoder is not available, polyfill required"); | ||
} | ||
if (!globalThis.TextDecoder) { | ||
throw new Error("globalThis.TextDecoder is not available, polyfill required"); | ||
} | ||
const encoder = new TextEncoder("utf-8"); | ||
const decoder = new TextDecoder("utf-8"); | ||
class Go { | ||
@@ -118,3 +200,3 @@ constructor() { | ||
const storeValue = (addr, v) => { | ||
const nanHead = 0x7FF80000; | ||
const nanHead = 0x7ff80000; | ||
if (typeof v === "number" && v !== 0) { | ||
@@ -223,3 +305,3 @@ if (isNaN(v)) { | ||
sp >>>= 0; | ||
const msec = (new Date).getTime(); | ||
const msec = new Date().getTime(); | ||
setInt64(sp + 8, msec / 1000); | ||
@@ -241,3 +323,4 @@ this.mem.setInt32(sp + 16, (msec % 1000) * 1000000, true); | ||
} | ||
}, getInt64(sp + 8) + 1)); | ||
}, getInt64(sp + 8) + 1 // setTimeout has been seen to fire up to 1 millisecond early | ||
)); | ||
this.mem.setInt32(sp + 16, id, true); | ||
@@ -374,3 +457,3 @@ }, | ||
sp >>>= 0; | ||
this.mem.setUint8(sp + 24, (loadValue(sp + 8) instanceof loadValue(sp + 16)) ? 1 : 0); | ||
this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16) ? 1 : 0); | ||
}, | ||
@@ -405,6 +488,6 @@ // func copyBytesToGo(dst []byte, src ref) (int, bool) | ||
}, | ||
"debug": (value) => { | ||
debug: (value) => { | ||
console.log(value); | ||
}, | ||
} | ||
}, | ||
}; | ||
@@ -420,2 +503,3 @@ } | ||
this._values = [ | ||
// JS values that Go currently has references to, indexed by reference id | ||
NaN, | ||
@@ -426,3 +510,3 @@ 0, | ||
false, | ||
global, | ||
globalThis, | ||
this, | ||
@@ -432,2 +516,3 @@ ]; | ||
this._ids = new Map([ | ||
// mapping from JS values to reference ids | ||
[0, 1], | ||
@@ -437,3 +522,3 @@ [null, 2], | ||
[false, 4], | ||
[global, 5], | ||
[globalThis, 5], | ||
[this, 6], | ||
@@ -440,0 +525,0 @@ ]); |
{ | ||
"name": "@onflow/cadence-language-server", | ||
"version": "0.33.4", | ||
"version": "1.0.0-preview.11", | ||
"description": "The Cadence Language Server", | ||
@@ -12,3 +12,3 @@ "homepage": "https://github.com/onflow/cadence", | ||
"scripts": { | ||
"build": "tsc && cd ../../languageserver && GOARCH=wasm GOOS=js go build -o ../npm-packages/cadence-language-server/dist/cadence-language-server.wasm ./cmd/languageserver && cd ../npm-packages/cadence-language-server", | ||
"build": "tsc && cd ../../languageserver && GOARCH=wasm GOOS=js go build -o ../npm-packages/cadence-language-server/dist/cadence-language-server.wasm -tags no_cgo ./cmd/languageserver && cd ../npm-packages/cadence-language-server", | ||
"test": "jest" | ||
@@ -15,0 +15,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
45386753
800