Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement axios ( work in progress ) #363

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[workspace]
members = [
"JS/wasm/crates/apis",
"JS/wasm/crates/arakoo-core",
"JS/wasm/crates/cli",
"JS/wasm/crates/serve",
Expand All @@ -13,15 +12,20 @@ edition = "2021"
version = "0.0.1"

[workspace.dependencies]
wizer = "4.0.0"
wasmtime = "16"
wasmtime-wasi = "16"
wasi-common = "16"
wizer = "6.0.0"
wasmtime = { features = ["async"], version = "19" }
wasmtime-wasi = "19"
javy = { version = "2.1.0" }
anyhow = "1.0.79"
once_cell = "1.19.0"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_bytes = "0.11"
http = "1.1.0"
reqwest = { version = "0.12.4", features = [
"blocking","json"
] }

[profile.release]
lto = true
opt-level = 's'
Expand Down
35 changes: 23 additions & 12 deletions JS/jsonnet/src/jsonnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (!isArakoo) {
jsonnet_evaluate_snippet,
jsonnet_destroy,
jsonnet_make,
ext_string,
jsonnet_ext_string,
jsonnet_evaluate_file,
get_func,
set_func,
Expand All @@ -24,7 +24,7 @@ if (!isArakoo) {
}

extString(key, value) {
ext_string(this.vm, key, value);
jsonnet_ext_string(this.vm, key, value);
return this;
}

Expand Down Expand Up @@ -55,24 +55,35 @@ if (!isArakoo) {
};
} else {
Jsonnet = class Jsonnet {
constructor() {
this.vars = {};
constructor() {}

#getVm() {
if (!this.vm) {
this.vm = __jsonnet_make();
}
return this.vm;
}

evaluateSnippet(snippet) {
let vm = this.#getVm();
return __jsonnet_evaluate_snippet(vm, snippet);
}

extString(key, value) {
this.vars[key] = value;
let vm = this.#getVm();
__jsonnet_ext_string(vm, key, value);
return this;
}
evaluateSnippet(snippet) {
let vars = JSON.stringify(this.vars);
return __jsonnet_evaluate_snippet(vars, snippet);
}

evaluateFile(filename) {
let vars = JSON.stringify(this.vars);
return __jsonnet_evaluate_file(vars, filename);
let vm = this.#getVm();
return __jsonnet_evaluate_file(vm, filename);
}

destroy() {}
destroy() {
let vm = this.#getVm();
__jsonnet_destroy(vm);
}
};
}

Expand Down
56 changes: 28 additions & 28 deletions JS/jsonnet/src/jsonnet_wasm.d.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
/* tslint:disable */
/* eslint-disable */
/**
* @returns {number}
*/
* @returns {number}
*/
export function jsonnet_make(): number;
/**
* @param {number} vm
*/
* @param {number} vm
*/
export function jsonnet_destroy(vm: number): void;
/**
* @param {number} vm
* @param {string} filename
* @param {string} snippet
* @returns {string}
*/
* @param {number} vm
* @param {string} filename
* @param {string} snippet
* @returns {string}
*/
export function jsonnet_evaluate_snippet(vm: number, filename: string, snippet: string): string;
/**
* @param {number} vm
* @param {string} filename
* @returns {string}
*/
* @param {number} vm
* @param {string} filename
* @returns {string}
*/
export function jsonnet_evaluate_file(vm: number, filename: string): string;
/**
* @param {number} vm
* @param {string} key
* @param {string} value
*/
export function ext_string(vm: number, key: string, value: string): void;
* @param {number} vm
* @param {string} key
* @param {string} value
*/
export function jsonnet_ext_string(vm: number, key: string, value: string): void;
/**
* @param {string} name
* @returns {Function | undefined}
*/
* @param {string} name
* @returns {Function | undefined}
*/
export function get_func(name: string): Function | undefined;
/**
* @param {string} name
* @param {Function} func
*/
* @param {string} name
* @param {Function} func
*/
export function set_func(name: string, func: Function): void;
/**
* @param {number} vm
* @param {string} name
* @param {number} args_num
*/
* @param {number} vm
* @param {string} name
* @param {number} args_num
*/
export function register_native_callback(vm: number, name: string, args_num: number): void;
Loading
Loading