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

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

Issue 2678203002: DevTools: extract event_listeners module (Closed)
Patch Set: fix - earlier ps didn't include all changes 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/sources/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: 'components/NetworkConditionsSelector.js', new: 'network_conditions'}, 27 {file: 'components/EventListenersView.js', new: 'event_listeners'},
28 {file: 'components/EventListenersUtils.js', new: 'event_listeners'},
28 // {file: 'module/file.js', existing: 'module'} 29 // {file: 'module/file.js', existing: 'module'}
29 ]; 30 ];
30 31
31 const MODULE_MAPPING = { 32 const MODULE_MAPPING = {
32 network_conditions: { 33 event_listeners: {
33 dependencies: ['common', 'sdk', 'ui', 'protocol'], 34 dependencies: ['ui', 'common', 'components', 'sdk'],
34 dependents: ['emulation', 'resources', 'network', 'timeline'], 35 dependents: ['elements', 'sources'],
35 applications: ['inspector.json'], 36 applications: ['inspector.json'],
36 autostart: true, // because emulation is autostart 37 autostart: false,
37 }, 38 },
38 }; 39 };
39 40
40 const NEW_DEPENDENCIES_BY_EXISTING_MODULES = { 41 const NEW_DEPENDENCIES_BY_EXISTING_MODULES = {
41 // resources: ['components'], 42 // resources: ['components'],
42 }; 43 };
43 44
44 const REMOVE_DEPENDENCIES_BY_EXISTING_MODULES = {}; 45 const REMOVE_DEPENDENCIES_BY_EXISTING_MODULES = {};
45 46
46 const DEPENDENCIES_BY_MODULE = Object.keys(MODULE_MAPPING).reduce((acc, module) => { 47 const DEPENDENCIES_BY_MODULE = Object.keys(MODULE_MAPPING).reduce((acc, module) => {
(...skipping 19 matching lines...) Expand all
66 } 67 }
67 const newModuleSet = JS_FILES_MAPPING.reduce((acc, file) => file.new ? acc.add (file.new) : acc, new Set()); 68 const newModuleSet = JS_FILES_MAPPING.reduce((acc, file) => file.new ? acc.add (file.new) : acc, new Set());
68 const targetToOriginalFilesMap = JS_FILES_MAPPING.reduce((acc, f) => { 69 const targetToOriginalFilesMap = JS_FILES_MAPPING.reduce((acc, f) => {
69 let components = f.file.split('/'); 70 let components = f.file.split('/');
70 components[0] = f.new || f.existing; 71 components[0] = f.new || f.existing;
71 acc.set(components.join('/'), f.file); 72 acc.set(components.join('/'), f.file);
72 return acc; 73 return acc;
73 }, new Map()); 74 }, new Map());
74 75
75 const cssFilesMapping = findCSSFiles(); 76 const cssFilesMapping = findCSSFiles();
77 // todo: one-off
78 cssFilesMapping.get('components/EventListenersView.js').delete('objectValue.cs s');
79 console.log('cssFilesMapping', cssFilesMapping);
76 const identifiersByFile = calculateIdentifiers(); 80 const identifiersByFile = calculateIdentifiers();
77 const identifierMap = mapIdentifiers(identifiersByFile, cssFilesMapping); 81 const identifierMap = mapIdentifiers(identifiersByFile, cssFilesMapping);
78 console.log('identifierMap', identifierMap); 82 console.log('identifierMap', identifierMap);
79 const extensionMap = removeFromExistingModuleDescriptors(modules, identifierMa p, cssFilesMapping); 83 const extensionMap = removeFromExistingModuleDescriptors(modules, identifierMa p, cssFilesMapping);
80 84
81 // Find out which files are moving extensions 85 // Find out which files are moving extensions
82 for (let e of extensionMap.keys()) { 86 for (let e of extensionMap.keys()) {
83 for (let [f, identifiers] of identifiersByFile) { 87 for (let [f, identifiers] of identifiersByFile) {
84 if (identifiers.includes(e)) 88 if (identifiers.includes(e))
85 console.log(`extension: ${e} in file: ${f}`); 89 console.log(`extension: ${e} in file: ${f}`);
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 return string.split('') 682 return string.split('')
679 .map(function(char) { 683 .map(function(char) {
680 var charCode = char.charCodeAt(0); 684 var charCode = char.charCodeAt(0);
681 return charCode > 127 ? unicodeCharEscape(charCode) : char; 685 return charCode > 127 ? unicodeCharEscape(charCode) : char;
682 }) 686 })
683 .join(''); 687 .join('');
684 } 688 }
685 689
686 if (require.main === module) 690 if (require.main === module)
687 extractModule(); 691 extractModule();
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sources/module.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698