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

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

Issue 2712513002: DevTools: extract ObjectUI module from Components (Closed)
Patch Set: fix build.gn 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
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/EventListenersView.js', new: 'event_listeners'}, 27 {file: 'components/CustomPreviewComponent.js', new: 'object_ui'},
28 {file: 'components/EventListenersUtils.js', new: 'event_listeners'}, 28 {file: 'components/ObjectPopoverHelper.js', new: 'object_ui'},
29 // {file: 'module/file.js', existing: 'module'} 29 {file: 'components/ObjectPropertiesSection.js', new: 'object_ui'},
30 {file: 'components/JavaScriptAutocomplete.js', new: 'object_ui'},
31 {file: 'components/RemoteObjectPreviewFormatter.js', new: 'object_ui'},
30 ]; 32 ];
31 33
32 const MODULE_MAPPING = { 34 const MODULE_MAPPING = {
33 event_listeners: { 35 object_ui: {
34 dependencies: ['ui', 'common', 'components', 'sdk'], 36 dependencies: ['ui', 'sdk', 'components'],
35 dependents: ['elements', 'sources'], 37 dependents: ['console', 'sources', 'extensions', 'event_listeners', 'resourc es', 'profiler', 'network'],
36 applications: ['inspector.json'], 38 applications: ['inspector.json'],
37 autostart: false, 39 autostart: true, // set to autostart because of extensions
38 }, 40 },
39 }; 41 };
40 42
41 const NEW_DEPENDENCIES_BY_EXISTING_MODULES = { 43 const NEW_DEPENDENCIES_BY_EXISTING_MODULES = {
42 // resources: ['components'], 44 // resources: ['components'],
43 }; 45 };
44 46
45 const REMOVE_DEPENDENCIES_BY_EXISTING_MODULES = {}; 47 const REMOVE_DEPENDENCIES_BY_EXISTING_MODULES = {};
46 48
47 const DEPENDENCIES_BY_MODULE = Object.keys(MODULE_MAPPING).reduce((acc, module) => { 49 const DEPENDENCIES_BY_MODULE = Object.keys(MODULE_MAPPING).reduce((acc, module) => {
(...skipping 19 matching lines...) Expand all
67 } 69 }
68 const newModuleSet = JS_FILES_MAPPING.reduce((acc, file) => file.new ? acc.add (file.new) : acc, new Set()); 70 const newModuleSet = JS_FILES_MAPPING.reduce((acc, file) => file.new ? acc.add (file.new) : acc, new Set());
69 const targetToOriginalFilesMap = JS_FILES_MAPPING.reduce((acc, f) => { 71 const targetToOriginalFilesMap = JS_FILES_MAPPING.reduce((acc, f) => {
70 let components = f.file.split('/'); 72 let components = f.file.split('/');
71 components[0] = f.new || f.existing; 73 components[0] = f.new || f.existing;
72 acc.set(components.join('/'), f.file); 74 acc.set(components.join('/'), f.file);
73 return acc; 75 return acc;
74 }, new Map()); 76 }, new Map());
75 77
76 const cssFilesMapping = findCSSFiles(); 78 const cssFilesMapping = findCSSFiles();
77 // todo: one-off
78 cssFilesMapping.get('components/EventListenersView.js').delete('objectValue.cs s');
79 console.log('cssFilesMapping', cssFilesMapping); 79 console.log('cssFilesMapping', cssFilesMapping);
80 const identifiersByFile = calculateIdentifiers(); 80 const identifiersByFile = calculateIdentifiers();
81 const identifierMap = mapIdentifiers(identifiersByFile, cssFilesMapping); 81 const identifierMap = mapIdentifiers(identifiersByFile, cssFilesMapping);
82 console.log('identifierMap', identifierMap); 82 console.log('identifierMap', identifierMap);
83 const extensionMap = removeFromExistingModuleDescriptors(modules, identifierMa p, cssFilesMapping); 83 const extensionMap = removeFromExistingModuleDescriptors(modules, identifierMa p, cssFilesMapping);
84 84
85 // Find out which files are moving extensions 85 // Find out which files are moving extensions
86 for (let e of extensionMap.keys()) { 86 for (let e of extensionMap.keys()) {
87 for (let [f, identifiers] of identifiersByFile) { 87 for (let [f, identifiers] of identifiersByFile) {
88 if (identifiers.includes(e)) 88 if (identifiers.includes(e))
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 if (line === startLine) 282 if (line === startLine)
283 seenStartLine = true; 283 seenStartLine = true;
284 284
285 if (line === endLine && seenStartLine) 285 if (line === endLine && seenStartLine)
286 break; 286 break;
287 287
288 if (!seenStartLine) 288 if (!seenStartLine)
289 continue; 289 continue;
290 290
291 const nextContent = top(contentStack) ? top(contentStack).toLowerCase() : ''; 291 const nextContent = top(contentStack) ? top(contentStack).toLowerCase() : '';
292 if ((line === startLine || nextContent > line.toLowerCase()) && 292 if ((line === startLine || nextContent >= line.toLowerCase()) &&
293 (nextLine === endLine || nextContent < nextLine.toLowerCase())) 293 (nextLine === endLine || nextContent <= nextLine.toLowerCase()))
294 lines.splice(i + 1, 0, contentStack.pop()); 294 lines.splice(i + 1, 0, contentStack.pop());
295 } 295 }
296 if (contentStack.length) 296 if (contentStack.length)
297 lines.splice(i, 0, ...contentStack); 297 lines.splice(i, 0, ...contentStack);
298 return lines.join('\n'); 298 return lines.join('\n');
299 } 299 }
300 } 300 }
301 301
302 function mapIdentifiers(identifiersByFile, cssFilesMapping) { 302 function mapIdentifiers(identifiersByFile, cssFilesMapping) {
303 const filesToTargetModule = new Map(); 303 const filesToTargetModule = new Map();
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 return string.split('') 682 return string.split('')
683 .map(function(char) { 683 .map(function(char) {
684 var charCode = char.charCodeAt(0); 684 var charCode = char.charCodeAt(0);
685 return charCode > 127 ? unicodeCharEscape(charCode) : char; 685 return charCode > 127 ? unicodeCharEscape(charCode) : char;
686 }) 686 })
687 .join(''); 687 .join('');
688 } 688 }
689 689
690 if (require.main === module) 690 if (require.main === module)
691 extractModule(); 691 extractModule();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698