Skip to content

Commit

Permalink
feat(compose): add separate instance for compose
Browse files Browse the repository at this point in the history
  • Loading branch information
zoobestik committed May 21, 2024
1 parent 29fb98f commit da3f82d
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import {getConfigFromElement, getCurrentScript} from './utils';
import {TargetPlatforms} from "./utils/platforms";
import { getConfigFromElement, getCurrentScript } from './utils';
import { TargetPlatforms } from './utils/platforms';

const currentScript = getCurrentScript();

export const RUNTIME_CONFIG = {...getConfigFromElement(currentScript)};
export const RUNTIME_CONFIG = { ...getConfigFromElement(currentScript) };

/**
* API Paths
*
* @type {{COMPILE: string, COMPLETE: string, VERSIONS: string, JQUERY: string, KOTLIN_JS: string}}
*/
export const API_URLS = {
server: RUNTIME_CONFIG.server || __WEBDEMO_URL__,
server: (RUNTIME_CONFIG.server || __WEBDEMO_URL__).replace(/\/$/, ''),
composeServer: (
'https://compose.sandbox.intellij.net' || __WEBDEMO_URL__
).replace(/\/$/, ''),

COMPILE(platform, version) {
let url;

Expand All @@ -32,7 +36,7 @@ export const API_URLS = {
url = `${this.server}/api/${version}/compiler/translate?ir=true&compiler=wasm`;
break;
case TargetPlatforms.COMPOSE_WASM:
url = `${this.server}/api/${version}/${TargetPlatforms.COMPOSE_WASM.id}/compiler/translate?compiler=compose-wasm`;
url = `${this.composeServer}/api/compiler/translate?compiler=${TargetPlatforms.COMPOSE_WASM.id}`;
break;
case TargetPlatforms.JUNIT:
url = `${this.server}/api/${version}/compiler/test`;
Expand All @@ -41,7 +45,7 @@ export const API_URLS = {
url = `${this.server}/api/${version}/${TargetPlatforms.SWIFT_EXPORT.id}/compiler/translate?compiler=swift-export`;
break;
default:
console.warn(`Unknown ${platform.id} , used by default JVM`)
console.warn(`Unknown ${platform.id} , used by default JVM`);
url = `${this.server}/api/${version}/compiler/run`;
break;
}
Expand All @@ -58,18 +62,18 @@ export const API_URLS = {
get VERSIONS() {
return `${this.server}/versions`;
},
SKIKO_MJS(version) {
return `${this.server}/api/${version}/${TargetPlatforms.COMPOSE_WASM.id}/resource/skiko.mjs`;
SKIKO_MJS() {
return `${this.composeServer}/api/resource/skiko.mjs`;
},
SKIKO_WASM(version) {
return `${this.server}/api/${version}/${TargetPlatforms.COMPOSE_WASM.id}/resource/skiko.wasm`;
SKIKO_WASM() {
return `${this.composeServer}/api/resource/skiko.wasm`;
},
get JQUERY() {
return `https://cdn.jsdelivr.net/npm/jquery@1/dist/jquery.min.js`;
},
get KOTLIN_JS() {
return `https://cdn.jsdelivr.net/npm/kotlin@`;
}
},
};

/**
Expand All @@ -82,5 +86,5 @@ export default {
* Will be calculated according to user defined `data-min-compiler-version`
* attribute and WebDemo API response
*/
compilerVersion: undefined
}
compilerVersion: undefined,
};

0 comments on commit da3f82d

Please sign in to comment.