@@ -18,20 +18,12 @@ import 'codemirror/mode/swift/swift';
1818import merge from 'deepmerge' ;
1919import Set from 'es6-set/polyfill' ;
2020import defaultConfig , { API_URLS } from '../config' ;
21- import {
22- arrayFrom ,
23- escapeRegExp ,
24- getConfigFromElement ,
25- insertAfter , MARK_PLACEHOLDER_CLOSE , MARK_PLACEHOLDER_OPEN ,
26- READ_ONLY_TAG ,
27- replaceWhiteSpaces , SAMPLE_END , SAMPLE_START ,
28- THEMES
29- } from '../utils' ;
21+ import { arrayFrom , getConfigFromElement , insertAfter , READ_ONLY_TAG , replaceWhiteSpaces , THEMES } from '../utils' ;
3022import WebDemoApi from "../webdemo-api" ;
31- import TargetPlatform from '../target-platform'
3223import ExecutableFragment from './executable-fragment' ;
3324import { generateCrosslink } from '../lib/crosslink' ;
3425import '../styles.scss' ;
26+ import { getTargetById , isJsRelated , TargetPlatforms } from "../utils/platforms" ;
3527
3628const INITED_ATTRIBUTE_NAME = 'data-kotlin-playground-initialized' ;
3729const DEFAULT_INDENT = 4 ;
@@ -94,7 +86,7 @@ export default class ExecutableCode {
9486 const args = targetNode . hasAttribute ( ATTRIBUTES . ARGUMENTS ) ? targetNode . getAttribute ( ATTRIBUTES . ARGUMENTS ) : "" ;
9587 const hiddenDependencies = this . getHiddenDependencies ( targetNode ) ;
9688 const outputHeight = targetNode . getAttribute ( ATTRIBUTES . OUTPUT_HEIGHT ) || null ;
97- const targetPlatform = TargetPlatform . getById ( targetNode . getAttribute ( ATTRIBUTES . PLATFORM ) ) ;
89+ const targetPlatform = getTargetById ( targetNode . getAttribute ( ATTRIBUTES . PLATFORM ) ) ;
9890 const targetNodeStyle = targetNode . getAttribute ( ATTRIBUTES . STYLE ) ;
9991 const jsLibs = this . getJsLibraries ( targetNode , targetPlatform ) ;
10092 const isFoldedButton = targetNode . getAttribute ( ATTRIBUTES . FOLDED_BUTTON ) !== "false" ;
@@ -130,13 +122,8 @@ export default class ExecutableCode {
130122 )
131123 ) ;
132124
133- if ( ! isCrosslinkDisabled ) crosslink = generateCrosslink ( {
134- code : code
135- . replace ( new RegExp ( escapeRegExp ( MARK_PLACEHOLDER_OPEN ) , 'g' ) , "" )
136- . replace ( new RegExp ( escapeRegExp ( MARK_PLACEHOLDER_CLOSE ) , 'g' ) , "" )
137- . replace ( new RegExp ( escapeRegExp ( SAMPLE_START ) , 'g' ) , "" )
138- . replace ( new RegExp ( escapeRegExp ( SAMPLE_END ) , 'g' ) , "" ) ,
139-
125+ if ( ! isCrosslinkDisabled ) crosslink = generateCrosslink ( code , {
126+ code : code ,
140127 targetPlatform : targetPlatform . id ,
141128 // hiddenDependencies, // multi-file support needs
142129 compilerVersion : cfg . compilerVersion ,
@@ -209,8 +196,8 @@ export default class ExecutableCode {
209196 * @returns {Set } - set of additional libraries
210197 */
211198 getJsLibraries ( targetNode , platform ) {
212- if ( TargetPlatform . isJsRelated ( platform ) ) {
213- if ( platform === TargetPlatform . WASM ) {
199+ if ( isJsRelated ( platform ) ) {
200+ if ( platform === TargetPlatforms . WASM ) {
214201 return new Set ( )
215202 }
216203 const jsLibs = targetNode . getAttribute ( ATTRIBUTES . JS_LIBS ) ;
0 commit comments