// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. // @dart = 2.7 /// Templates used for the HTML visualization of source map information. library sourcemap.html.templates; import 'dart:io'; abstract class Configurations { Iterable get configs; Iterable get files; String getPath(String config, String file); } void outputMultiConfigs(Uri uri, Configurations configurations) { StringBuffer sb = new StringBuffer(); String defaultConfig = configurations.configs.first; String defaultFile = configurations.files.first; sb.write(''' '''); for (String config in configurations.configs) { for (String file in configurations.files) { String uri = configurations.getPath(config, file); sb.write('''
'''); } } sb.write('''
file: '''); for (String file in configurations.files) { sb.write('''

$file

'''); } sb.write(''' config: '''); for (String config in configurations.configs) { sb.write('''

$config

'''); } sb.write('''
'''); output(uri, sb.toString()); } /// Outputs JavaScript/Dart source mapping traces into [uri]. void outputJsDartTrace( Uri uri, String jsCodeHtml, String dartCodeHtml, String jsTraceHtml) { String html = '''
${jsCodeHtml}
${dartCodeHtml} ${jsTraceHtml} '''; String css = ''' .js-buffer { left:0%; width:50%; top:0%; height:50%; } .dart-buffer { right:0%; width:50%; top:0%; height:50%; } .js-trace-buffer { left:0%; width:100%; top:50%; height:50%; } '''; outputInTemplate(uri, html, css); } /// Outputs [html] with customized [css] in [uri]. void outputInTemplate(Uri uri, String html, String css) { output(uri, ''' $html '''); } /// Outputs [html] in [uri]. void output(Uri uri, String html) { File outputFile = new File.fromUri(uri); outputFile.writeAsStringSync(html); }