Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: third_party/WebKit/Source/devtools/scripts/extract_module/extract_module.js

Issue 2915883002: DevTools: prepare to unify Network and CPU throttling UI (Closed)
Patch Set: gs Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/package.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 'use strict'; 4 'use strict';
5 const fs = require('fs'); 5 const fs = require('fs');
6 const path = require('path'); 6 const path = require('path');
7 7
8 const utils = require('../utils'); 8 const utils = require('../utils');
9 9
10 const FRONTEND_PATH = path.resolve(__dirname, '..', '..', 'front_end'); 10 const FRONTEND_PATH = path.resolve(__dirname, '..', '..', 'front_end');
11 const BUILD_GN_PATH = path.resolve(__dirname, '..', '..', 'BUILD.gn'); 11 const BUILD_GN_PATH = path.resolve(__dirname, '..', '..', 'BUILD.gn');
12 const SPECIAL_CASE_NAMESPACES_PATH = path.resolve(__dirname, '..', 'special_case _namespaces.json'); 12 const SPECIAL_CASE_NAMESPACES_PATH = path.resolve(__dirname, '..', 'special_case _namespaces.json');
13 13
14 /*
15 * ==========================================
16 * START EDITING HERE - TRANSFORMATION INPUTS
17 * ==========================================
18 */
19
14 const APPLICATION_DESCRIPTORS = [ 20 const APPLICATION_DESCRIPTORS = [
15 'inspector.json', 21 'inspector.json',
16 'toolbox.json', 22 'toolbox.json',
17 'unit_test_runner.json', 23 'unit_test_runner.json',
18 'formatter_worker.json', 24 'formatter_worker.json',
19 'heap_snapshot_worker.json', 25 'heap_snapshot_worker.json',
20 'utility_shared_worker.json', 26 'utility_shared_worker.json',
21 ]; 27 ];
22 28
23 // Replace based on specified transformation 29 /*
30 * If the transformation removes all the files of a module:
31 * ['text_editor']
32 */
24 const MODULES_TO_REMOVE = []; 33 const MODULES_TO_REMOVE = [];
25 34
35 /**
36 * If moving to a new module:
37 * {file: 'common/Text.js', new: 'a_new_module'}
38 *
39 * If moving to an existing module:
40 * {file: 'ui/SomeFile.js', existing: 'common'}
41 */
26 const JS_FILES_MAPPING = [ 42 const JS_FILES_MAPPING = [
27 {file: 'common/Text.js', new: 'text_utils'}, 43 {file: 'mobile_throttling/NetworkPriorities.js', new: 'network_priorities'},
28 {file: 'common/TextUtils.js', new: 'text_utils'},
29 {file: 'common/TextRange.js', new: 'text_utils'},
30 ]; 44 ];
31 45
46 /**
47 * List all new modules here:
48 * mobile_throttling: {
49 * dependencies: ['sdk'],
50 * dependents: ['console'],
51 * applications: ['inspector.json'],
52 * autostart: false,
53 * }
54 */
32 const MODULE_MAPPING = { 55 const MODULE_MAPPING = {
33 text_utils: { 56 network_priorities: {
34 dependencies: [], 57 dependencies: ['protocol', 'common'],
35 dependents: ['common'], 58 dependents: ['network', 'timeline'],
36 applications: ['inspector.json'], 59 applications: ['inspector.json'],
37 autostart: true, // set to autostart because of extensions 60 autostart: false,
38 }, 61 },
39 }; 62 };
40 63
64 /**
65 * If an existing module will have a new dependency on an existing module:
66 * console: ['new_dependency']
67 */
41 const NEW_DEPENDENCIES_BY_EXISTING_MODULES = { 68 const NEW_DEPENDENCIES_BY_EXISTING_MODULES = {
42 // resources: ['components'], 69 // resources: ['components'],
43 }; 70 };
44 71
72 /**
73 * If an existing module will no longer have a dependency on a module:
74 * console: ['former_dependency']
75 */
45 const REMOVE_DEPENDENCIES_BY_EXISTING_MODULES = {}; 76 const REMOVE_DEPENDENCIES_BY_EXISTING_MODULES = {};
46 77
78 /*
79 * ==========================================
80 * STOP EDITING HERE
81 * ==========================================
82 */
83
47 const DEPENDENCIES_BY_MODULE = Object.keys(MODULE_MAPPING).reduce((acc, module) => { 84 const DEPENDENCIES_BY_MODULE = Object.keys(MODULE_MAPPING).reduce((acc, module) => {
48 acc[module] = MODULE_MAPPING[module].dependencies; 85 acc[module] = MODULE_MAPPING[module].dependencies;
49 return acc; 86 return acc;
50 }, {}); 87 }, {});
51 88
52 const APPLICATIONS_BY_MODULE = Object.keys(MODULE_MAPPING).reduce((acc, module) => { 89 const APPLICATIONS_BY_MODULE = Object.keys(MODULE_MAPPING).reduce((acc, module) => {
53 acc[module] = MODULE_MAPPING[module].applications; 90 acc[module] = MODULE_MAPPING[module].applications;
54 return acc; 91 return acc;
55 }, {}); 92 }, {});
56 93
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 if (newModules.length === 0) 666 if (newModules.length === 0)
630 return; 667 return;
631 let includeNewModules = (acc, line) => { 668 let includeNewModules = (acc, line) => {
632 if (line.includes('{') && line.endsWith('}')) { 669 if (line.includes('{') && line.endsWith('}')) {
633 line += ','; 670 line += ',';
634 acc.push(line); 671 acc.push(line);
635 return acc.concat(newModules.map((m, i) => { 672 return acc.concat(newModules.map((m, i) => {
636 // Need spacing to preserve indentation 673 // Need spacing to preserve indentation
637 let string; 674 let string;
638 if (MODULE_MAPPING[m].autostart) 675 if (MODULE_MAPPING[m].autostart)
639 string = ` { "name": "${m}", "type": "autostart"}`; 676 string = ` { "name": "${m}", "type": "autostart" }`;
640 else 677 else
641 string = ` { "name": "${m}" }`; 678 string = ` { "name": "${m}" }`;
642 if (i !== newModules.length - 1) 679 if (i !== newModules.length - 1)
643 string += ','; 680 string += ',';
644 return string; 681 return string;
645 })); 682 }));
646 } 683 }
647 return acc.concat([line]); 684 return acc.concat([line]);
648 }; 685 };
649 let removeModules = (acc, line) => MODULES_TO_REMOVE.every(m => !line.includes (m)) ? acc.concat([line]) : acc; 686 let removeModules = (acc, line) => MODULES_TO_REMOVE.every(m => !line.includes (m)) ? acc.concat([line]) : acc;
(...skipping 30 matching lines...) Expand all
680 return string.split('') 717 return string.split('')
681 .map(function(char) { 718 .map(function(char) {
682 var charCode = char.charCodeAt(0); 719 var charCode = char.charCodeAt(0);
683 return charCode > 127 ? unicodeCharEscape(charCode) : char; 720 return charCode > 127 ? unicodeCharEscape(charCode) : char;
684 }) 721 })
685 .join(''); 722 .join('');
686 } 723 }
687 724
688 if (require.main === module) 725 if (require.main === module)
689 extractModule(); 726 extractModule();
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/package.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698