mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 14:40:17 +00:00
feat(aqua-api): Use scala.js link instead of opt (#891)
* Add link settings * fix * Rename to api-dist-js * Correct import * Update CI --------- Co-authored-by: Artsiom Shamsutdzinau <shamsartem@gmail.com>
This commit is contained in:
parent
6be2a3d5da
commit
3f916c78ab
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
@ -41,7 +41,7 @@ jobs:
|
|||||||
apps: sbt
|
apps: sbt
|
||||||
|
|
||||||
- name: scala-js build
|
- name: scala-js build
|
||||||
run: sbt ";language-server-apiJS/fullOptJS;aqua-apiJS/fullOptJS"
|
run: sbt ";language-server-apiJS/fullOptJS;aqua-apiJS/fullLinkJS"
|
||||||
|
|
||||||
- name: Import secrets
|
- name: Import secrets
|
||||||
uses: hashicorp/vault-action@v2.7.3
|
uses: hashicorp/vault-action@v2.7.3
|
||||||
|
2
.github/workflows/snapshot.yml
vendored
2
.github/workflows/snapshot.yml
vendored
@ -51,7 +51,7 @@ jobs:
|
|||||||
- name: scala-js build
|
- name: scala-js build
|
||||||
env:
|
env:
|
||||||
SNAPSHOT: ${{ steps.version.outputs.id }}
|
SNAPSHOT: ${{ steps.version.outputs.id }}
|
||||||
run: sbt ";language-server-apiJS/fastOptJS;aqua-apiJS/fastOptJS"
|
run: sbt ";language-server-apiJS/fastOptJS;aqua-apiJS/fastLinkJS"
|
||||||
|
|
||||||
- name: Import secrets
|
- name: Import secrets
|
||||||
uses: hashicorp/vault-action@v2.7.3
|
uses: hashicorp/vault-action@v2.7.3
|
||||||
|
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -82,7 +82,7 @@ jobs:
|
|||||||
apps: sbt
|
apps: sbt
|
||||||
|
|
||||||
- name: aqua-api build
|
- name: aqua-api build
|
||||||
run: sbt "aqua-apiJS/fastOptJS"
|
run: sbt "aqua-apiJS/fastLinkJS"
|
||||||
|
|
||||||
- name: Setup pnpm
|
- name: Setup pnpm
|
||||||
uses: pnpm/action-setup@v2.4.0
|
uses: pnpm/action-setup@v2.4.0
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -9,9 +9,8 @@ project/target
|
|||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
cli/cli-npm/aqua.j*
|
|
||||||
language-server/language-server-npm/aqua-lsp-api.j*
|
language-server/language-server-npm/aqua-lsp-api.j*
|
||||||
api/api-npm/aqua-api.j*
|
api/api-npm/api-dist-js
|
||||||
|
|
||||||
integration-tests/src/compiled/*
|
integration-tests/src/compiled/*
|
||||||
|
|
||||||
|
69
api/api-npm/aqua-api.d.ts
vendored
69
api/api-npm/aqua-api.d.ts
vendored
@ -1,69 +0,0 @@
|
|||||||
import type { FunctionCallDef, ServiceDef } from "@fluencelabs/interfaces";
|
|
||||||
|
|
||||||
export class AquaConfig {
|
|
||||||
constructor(
|
|
||||||
logLevel?: string,
|
|
||||||
constants?: string[],
|
|
||||||
noXor?: boolean,
|
|
||||||
noRelay?: boolean,
|
|
||||||
targetType?: string,
|
|
||||||
tracing?: boolean,
|
|
||||||
);
|
|
||||||
|
|
||||||
logLevel?: string;
|
|
||||||
constants?: string[];
|
|
||||||
noXor?: boolean;
|
|
||||||
noRelay?: boolean;
|
|
||||||
targetType?: string;
|
|
||||||
tracing?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class AquaFunction {
|
|
||||||
funcDef: FunctionCallDef;
|
|
||||||
script: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class GeneratedSource {
|
|
||||||
name: string;
|
|
||||||
tsSource?: string;
|
|
||||||
jsSource?: string;
|
|
||||||
tsTypes?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CompilationResult {
|
|
||||||
services: Record<string, ServiceDef>;
|
|
||||||
functions: Record<string, AquaFunction>;
|
|
||||||
functionCall?: AquaFunction;
|
|
||||||
errors: string[];
|
|
||||||
generatedSources: GeneratedSource[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Input {
|
|
||||||
constructor(input: string);
|
|
||||||
|
|
||||||
input: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Path {
|
|
||||||
constructor(path: string);
|
|
||||||
|
|
||||||
path: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Call {
|
|
||||||
constructor(functionCall: string, arguments: any, input: Input | Path);
|
|
||||||
|
|
||||||
functionCall: string;
|
|
||||||
arguments: any;
|
|
||||||
input: Input | Path;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Compiler {
|
|
||||||
compile(
|
|
||||||
input: Input | Path | Call,
|
|
||||||
imports: string[],
|
|
||||||
config?: AquaConfig,
|
|
||||||
): Promise<CompilationResult>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export var Aqua: Compiler;
|
|
46
api/api-npm/index.d.ts
vendored
46
api/api-npm/index.d.ts
vendored
@ -1,4 +1,24 @@
|
|||||||
import { type CompilationResult } from "./aqua-api.js";
|
import { ServiceDef, FunctionCallDef } from "@fluencelabs/interfaces";
|
||||||
|
|
||||||
|
class AquaFunction {
|
||||||
|
funcDef: FunctionCallDef;
|
||||||
|
script: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
class GeneratedSource {
|
||||||
|
name: string;
|
||||||
|
tsSource?: string;
|
||||||
|
jsSource?: string;
|
||||||
|
tsTypes?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
class CompilationResult {
|
||||||
|
services: Record<string, ServiceDef>;
|
||||||
|
functions: Record<string, AquaFunction>;
|
||||||
|
functionCall?: AquaFunction;
|
||||||
|
errors: string[];
|
||||||
|
generatedSources: GeneratedSource[];
|
||||||
|
}
|
||||||
|
|
||||||
/** Common arguments for all compile functions */
|
/** Common arguments for all compile functions */
|
||||||
type CommonArgs = {
|
type CommonArgs = {
|
||||||
@ -21,30 +41,38 @@ type CommonArgs = {
|
|||||||
type CodeString = {
|
type CodeString = {
|
||||||
/** Aqua code to be compiled */
|
/** Aqua code to be compiled */
|
||||||
code: string;
|
code: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
/** Compile aqua code from a string */
|
/** Compile aqua code from a string */
|
||||||
export declare function compileFromString(args: CommonArgs & CodeString): Promise<Omit<CompilationResult, 'funcCall'>>
|
export declare function compileFromString(
|
||||||
|
args: CommonArgs & CodeString,
|
||||||
|
): Promise<Omit<CompilationResult, "funcCall">>;
|
||||||
|
|
||||||
type FilePath = {
|
type FilePath = {
|
||||||
/** Path to the aqua file to be compiled */
|
/** Path to the aqua file to be compiled */
|
||||||
filePath: string;
|
filePath: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
/** Compile aqua code from a file */
|
/** Compile aqua code from a file */
|
||||||
export declare function compileFromPath(args: CommonArgs & FilePath): Promise<Omit<CompilationResult, 'funcCall'>>
|
export declare function compileFromPath(
|
||||||
|
args: CommonArgs & FilePath,
|
||||||
|
): Promise<Omit<CompilationResult, "funcCall">>;
|
||||||
|
|
||||||
type FuncCall = {
|
type FuncCall = {
|
||||||
/** Function call you want to compile. Example: someFunc("someArg") */
|
/** Function call you want to compile. Example: someFunc("someArg") */
|
||||||
funcCall: string;
|
funcCall: string;
|
||||||
/** Args to be passed to the function (record with keys named as args you want to pass to the function) Example: { someArg: 1 } */
|
/** Args to be passed to the function (record with keys named as args you want to pass to the function) Example: { someArg: 1 } */
|
||||||
data?: Record<string, unknown> | undefined;
|
data?: Record<string, unknown> | undefined;
|
||||||
}
|
};
|
||||||
|
|
||||||
/** Compile aqua function call from a string */
|
/** Compile aqua function call from a string */
|
||||||
export declare function compileAquaCallFromString(args: CommonArgs & CodeString & FuncCall): Promise<Required<CompilationResult>>
|
export declare function compileAquaCallFromString(
|
||||||
|
args: CommonArgs & CodeString & FuncCall,
|
||||||
|
): Promise<Required<CompilationResult>>;
|
||||||
|
|
||||||
/** Compile aqua function call from a file */
|
/** Compile aqua function call from a file */
|
||||||
export declare function compileAquaCallFromPath(args: CommonArgs & FilePath & FuncCall): Promise<Required<CompilationResult>>
|
export declare function compileAquaCallFromPath(
|
||||||
|
args: CommonArgs & FilePath & FuncCall,
|
||||||
|
): Promise<Required<CompilationResult>>;
|
||||||
|
|
||||||
export {}
|
export {};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
// @ts-check
|
import { AquaConfig, Aqua, Call, Input, Path } from "./api-dist-js/main.js";
|
||||||
import { AquaConfig, Aqua, Call, Input, Path } from "./aqua-api.js";
|
|
||||||
|
|
||||||
function getConfig({
|
function getConfig({
|
||||||
constants = [],
|
constants = [],
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
"index.js",
|
||||||
"index.d.ts",
|
"index.d.ts",
|
||||||
"aqua-api.js",
|
"api-dist-js/main.js",
|
||||||
"aqua-api.d.ts",
|
|
||||||
"meta-utils.js"
|
"meta-utils.js"
|
||||||
],
|
],
|
||||||
"prettier": {},
|
"prettier": {},
|
||||||
|
@ -74,6 +74,7 @@ lazy val `language-server-api` = crossProject(JSPlatform, JVMPlatform)
|
|||||||
|
|
||||||
lazy val `language-server-apiJS` = `language-server-api`.js
|
lazy val `language-server-apiJS` = `language-server-api`.js
|
||||||
.settings(
|
.settings(
|
||||||
|
// TODO: move to fast/fullLinkJS here
|
||||||
Compile / fastOptJS / artifactPath := baseDirectory.value / "../../language-server-npm" / "aqua-lsp-api.js",
|
Compile / fastOptJS / artifactPath := baseDirectory.value / "../../language-server-npm" / "aqua-lsp-api.js",
|
||||||
Compile / fullOptJS / artifactPath := baseDirectory.value / "../../language-server-npm" / "aqua-lsp-api.js",
|
Compile / fullOptJS / artifactPath := baseDirectory.value / "../../language-server-npm" / "aqua-lsp-api.js",
|
||||||
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)),
|
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)),
|
||||||
@ -103,8 +104,8 @@ lazy val `aqua-api` = crossProject(JSPlatform, JVMPlatform)
|
|||||||
|
|
||||||
lazy val `aqua-apiJS` = `aqua-api`.js
|
lazy val `aqua-apiJS` = `aqua-api`.js
|
||||||
.settings(
|
.settings(
|
||||||
Compile / fastOptJS / artifactPath := baseDirectory.value / "../../api-npm" / "aqua-api.js",
|
Compile / fastLinkJS / scalaJSLinkerOutputDirectory := baseDirectory.value / "../../api-npm/api-dist-js",
|
||||||
Compile / fullOptJS / artifactPath := baseDirectory.value / "../../api-npm" / "aqua-api.js",
|
Compile / fullLinkJS / scalaJSLinkerOutputDirectory := baseDirectory.value / "../../api-npm/api-dist-js",
|
||||||
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.ESModule)),
|
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.ESModule)),
|
||||||
scalaJSUseMainModuleInitializer := true,
|
scalaJSUseMainModuleInitializer := true,
|
||||||
Test / test := {}
|
Test / test := {}
|
||||||
|
@ -7,8 +7,9 @@ object Meta {
|
|||||||
|
|
||||||
// get `import`.meta.url info from javascript
|
// get `import`.meta.url info from javascript
|
||||||
// it is needed for `createRequire` function
|
// it is needed for `createRequire` function
|
||||||
|
// TODO: Investigate if it is really needed
|
||||||
@js.native
|
@js.native
|
||||||
@JSImport("./meta-utils.js", "metaUrl")
|
@JSImport("../meta-utils.js", "metaUrl")
|
||||||
val metaUrl: String = js.native
|
val metaUrl: String = js.native
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user