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

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

Issue 2668413003: DevTools: extract NetworkConditionsSelector into its own module (Closed)
Patch Set: rebaseline Created 3 years, 10 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/front_end/timeline/module.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 const APPLICATION_DESCRIPTORS = [ 14 const APPLICATION_DESCRIPTORS = [
15 'inspector.json', 15 'inspector.json',
16 'toolbox.json', 16 'toolbox.json',
17 'unit_test_runner.json', 17 'unit_test_runner.json',
18 'formatter_worker.json', 18 'formatter_worker.json',
19 'heap_snapshot_worker.json', 19 'heap_snapshot_worker.json',
20 'utility_shared_worker.json', 20 'utility_shared_worker.json',
21 ]; 21 ];
22 22
23 // Replace based on specified transformation 23 // Replace based on specified transformation
24 const MODULES_TO_REMOVE = []; 24 const MODULES_TO_REMOVE = [];
25 25
26 const JS_FILES_MAPPING = [ 26 const JS_FILES_MAPPING = [
27 {file: 'common/CSSShadowModel.js', existing: 'inline_editor'}, {file: 'common/ Geometry.js', existing: 'ui'}, 27 {file: 'components/NetworkConditionsSelector.js', new: 'network_conditions'},
28 // {file: 'module/file.js', existing: 'module'} 28 // {file: 'module/file.js', existing: 'module'}
29 ]; 29 ];
30 30
31 const MODULE_MAPPING = { 31 const MODULE_MAPPING = {
32 // heap_snapshot_model: { 32 network_conditions: {
33 // dependencies: [], 33 dependencies: ['common', 'sdk', 'ui', 'protocol'],
34 // dependents: ['heap_snapshot_worker', 'profiler'], 34 dependents: ['emulation', 'resources', 'network', 'timeline'],
35 // applications: ['inspector.json'], // need to manually add to heap snaps hot worker b/c it's autostart 35 applications: ['inspector.json'],
36 // autostart: false, 36 autostart: true, // because emulation is autostart
37 // }, 37 },
38 }; 38 };
39 39
40 const NEW_DEPENDENCIES_BY_EXISTING_MODULES = { 40 const NEW_DEPENDENCIES_BY_EXISTING_MODULES = {
41 // resources: ['components'], 41 // resources: ['components'],
42 }; 42 };
43 43
44 const REMOVE_DEPENDENCIES_BY_EXISTING_MODULES = {}; 44 const REMOVE_DEPENDENCIES_BY_EXISTING_MODULES = {};
45 45
46 const DEPENDENCIES_BY_MODULE = Object.keys(MODULE_MAPPING).reduce((acc, module) => { 46 const DEPENDENCIES_BY_MODULE = Object.keys(MODULE_MAPPING).reduce((acc, module) => {
47 acc[module] = MODULE_MAPPING[module].dependencies; 47 acc[module] = MODULE_MAPPING[module].dependencies;
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 remainingResources.push(resource); 427 remainingResources.push(resource);
428 } 428 }
429 moduleObj.resources = remainingResources; 429 moduleObj.resources = remainingResources;
430 } 430 }
431 431
432 function removeExtensions(moduleObj) { 432 function removeExtensions(moduleObj) {
433 if (!moduleObj.extensions) 433 if (!moduleObj.extensions)
434 return; 434 return;
435 let remainingExtensions = []; 435 let remainingExtensions = [];
436 for (let extension of moduleObj.extensions) { 436 for (let extension of moduleObj.extensions) {
437 if (!objectIncludesIdentifier(extension)) 437 if (!objectIncludesIdentifier(extension)) {
438 remainingExtensions.push(extension); 438 remainingExtensions.push(extension);
439 else 439 } else {
440 extensionMap.set(objectIncludesIdentifier(extension), extension); 440 if (extensionMap.has(objectIncludesIdentifier(extension))) {
441 let existingExtensions = extensionMap.get(objectIncludesIdentifier(ext ension));
442 extensionMap.set(objectIncludesIdentifier(extension), existingExtensio ns.concat(extension));
443 } else {
444 extensionMap.set(objectIncludesIdentifier(extension), [extension]);
445 }
446 }
441 } 447 }
442 moduleObj.extensions = remainingExtensions; 448 moduleObj.extensions = remainingExtensions;
443 } 449 }
444 450
445 function objectIncludesIdentifier(object) { 451 function objectIncludesIdentifier(object) {
446 for (let key in object) { 452 for (let key in object) {
447 let value = object[key]; 453 let value = object[key];
448 if (identifierMap.has(value)) 454 if (identifierMap.has(value))
449 return value; 455 return value;
450 } 456 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 return resources; 510 return resources;
505 } 511 }
506 512
507 function getModuleExtensions(scripts, module) { 513 function getModuleExtensions(scripts, module) {
508 let extensions = []; 514 let extensions = [];
509 let identifiers = 515 let identifiers =
510 scripts.map(script => module + '/' + script) 516 scripts.map(script => module + '/' + script)
511 .reduce((acc, file) => acc.concat(identifiersByFile.get(targetToOrig inalFilesMap.get(file))), []); 517 .reduce((acc, file) => acc.concat(identifiersByFile.get(targetToOrig inalFilesMap.get(file))), []);
512 for (let identifier of identifiers) { 518 for (let identifier of identifiers) {
513 if (extensionMap.has(identifier)) 519 if (extensionMap.has(identifier))
514 extensions.push(extensionMap.get(identifier)); 520 extensions = extensions.concat(extensionMap.get(identifier));
515 } 521 }
516 return extensions; 522 return extensions;
517 } 523 }
518 } 524 }
519 525
520 function calculateFilesByModuleType(type) { 526 function calculateFilesByModuleType(type) {
521 let filesByNewModule = new Map(); 527 let filesByNewModule = new Map();
522 for (let fileObj of JS_FILES_MAPPING) { 528 for (let fileObj of JS_FILES_MAPPING) {
523 if (!fileObj[type]) 529 if (!fileObj[type])
524 continue; 530 continue;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 return resources; 576 return resources;
571 } 577 }
572 578
573 function getModuleExtensions(scripts, module) { 579 function getModuleExtensions(scripts, module) {
574 let extensions = []; 580 let extensions = [];
575 let identifiers = 581 let identifiers =
576 scripts.map(script => module + '/' + script) 582 scripts.map(script => module + '/' + script)
577 .reduce((acc, file) => acc.concat(identifiersByFile.get(targetToOrig inalFilesMap.get(file))), []); 583 .reduce((acc, file) => acc.concat(identifiersByFile.get(targetToOrig inalFilesMap.get(file))), []);
578 for (let identifier of identifiers) { 584 for (let identifier of identifiers) {
579 if (extensionMap.has(identifier)) 585 if (extensionMap.has(identifier))
580 extensions.push(extensionMap.get(identifier)); 586 extensions = extensions.concat(extensionMap.get(identifier));
581 } 587 }
582 return extensions; 588 return extensions;
583 } 589 }
584 } 590 }
585 591
586 function addDependenciesToDescriptors() { 592 function addDependenciesToDescriptors() {
587 for (let module of getModules()) { 593 for (let module of getModules()) {
588 let moduleJSONPath = path.resolve(FRONTEND_PATH, module, 'module.json'); 594 let moduleJSONPath = path.resolve(FRONTEND_PATH, module, 'module.json');
589 let content = fs.readFileSync(moduleJSONPath).toString(); 595 let content = fs.readFileSync(moduleJSONPath).toString();
590 let moduleObj = parseJSON(content); 596 let moduleObj = parseJSON(content);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 return string.split('') 678 return string.split('')
673 .map(function(char) { 679 .map(function(char) {
674 var charCode = char.charCodeAt(0); 680 var charCode = char.charCodeAt(0);
675 return charCode > 127 ? unicodeCharEscape(charCode) : char; 681 return charCode > 127 ? unicodeCharEscape(charCode) : char;
676 }) 682 })
677 .join(''); 683 .join('');
678 } 684 }
679 685
680 if (require.main === module) 686 if (require.main === module)
681 extractModule(); 687 extractModule();
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/timeline/module.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698