Skip to content
Permalink
Browse files

devtools -> dirac as of 5d061be

  • Loading branch information...
babot authored and darwin committed Sep 22, 2019
1 parent 272860d commit 48d5bb505df33b0310542dcdbae395a0f27b45e4
Showing with 17,990 additions and 184 deletions.
  1. +31 −29 BUILD.gn
  2. +4 −0 front_end/Runtime.js
  3. +7 −0 front_end/bindings/ResourceScriptMapping.js
  4. +3 −1 front_end/cm/codemirror.js
  5. +14 −10 front_end/cm/matchbrackets.js
  6. +63 −0 front_end/cm_web_modes/placeholder.js
  7. +72 −0 front_end/cm_web_modes/runmode.js
  8. +12 −1 front_end/components/Linkifier.js
  9. +617 −2 front_end/console/ConsoleView.js
  10. +9 −0 front_end/console/ConsoleViewMessage.js
  11. +938 −0 front_end/console/DiracPrompt.js
  12. +1 −0 front_end/console/Images
  13. +313 −0 front_end/console/clojure-parinfer.js
  14. +516 −0 front_end/console/dirac-codemirror.css
  15. +23 −0 front_end/console/dirac-hacks.css
  16. +131 −0 front_end/console/dirac-prompt.css
  17. +88 −0 front_end/console/dirac-theme.css
  18. +12 −1 front_end/console/module.json
  19. +282 −0 front_end/dirac/dirac.js
  20. +1 −0 front_end/dirac/goog-base-setup.js
  21. +816 −0 front_end/dirac/keysim.js
  22. +24 −0 front_end/dirac/module.json
  23. +659 −0 front_end/dirac/parinfer-codemirror.js
  24. +1,391 −0 front_end/dirac/parinfer.js
  25. +2 −0 front_end/dirac/require-implant.js
  26. +918 −0 front_end/dirac_lazy/dirac_lazy.js
  27. +14 −0 front_end/dirac_lazy/module.json
  28. +273 −1 front_end/externs.js
  29. +184 −0 front_end/generated_namespaces_externs.js
  30. +9,702 −0 front_end/generated_protocol_externs.js
  31. +8 −0 front_end/handshake.html
  32. +28 −0 front_end/handshake.js
  33. +18 −1 front_end/host/InspectorFrontendHost.js
  34. +3 −1 front_end/inspector.html
  35. +4 −0 front_end/inspector.js
  36. +10 −0 front_end/main/Main.js
  37. +1 −0 front_end/main/module.json
  38. +102 −3 front_end/object_ui/ObjectPropertiesSection.js
  39. +6 −1 front_end/object_ui/customPreviewComponent.css
  40. +21 −1 front_end/object_ui/objectPropertiesSection.css
  41. +12 −0 front_end/protocol/InspectorBackend.js
  42. +43 −0 front_end/protocol/InspectorBackendExtensionMode.js
  43. +3 −1 front_end/protocol/module.json
  44. +1 −1 front_end/screencast/ScreencastApp.js
  45. +1 −1 front_end/sdk/Connections.js
  46. +11 −0 front_end/sdk/ConsoleModel.js
  47. +1 −1 front_end/sdk/DebuggerModel.js
  48. +15 −1 front_end/sdk/SourceMap.js
  49. +33 −0 front_end/sdk/SupportedCSSPropertiesExtensionMode.js
  50. +4 −2 front_end/sdk/module.json
  51. +2 −0 front_end/shell.json
  52. +29 −0 front_end/source_frame/SourcesTextEditor.js
  53. +12 −4 front_end/sources/CallStackSidebarPane.js
  54. +60 −29 front_end/sources/DebuggerPlugin.js
  55. +166 −58 front_end/sources/SourceMapNamesResolver.js
  56. +6 −3 front_end/text_editor/cmdevtools.css
  57. +6 −2 front_end/text_editor/module.json
  58. +2 −0 front_end/ui/InspectorView.js
  59. +13 −6 front_end/ui/SuggestBox.js
  60. +24 −5 front_end/ui/TextPrompt.js
  61. +3 −0 front_end/ui/UIUtils.js
  62. +4 −0 front_end/ui/inspectorViewTabbedPane.css
  63. +2 −0 front_end/ui/module.json
  64. +96 −0 front_end/ui/suggestBox-dirac.css
  65. +20 −0 front_end/ui/treeoutline-dirac.css
  66. +1 −0 front_end/ui/treeoutline.js
  67. +12 −0 front_end/workspace/UISourceCode.js
  68. +4 −1 scripts/build/build_release_applications.py
  69. +2 −3 scripts/build/generate_protocol_externs.py
  70. +22 −9 scripts/compile_frontend.py
  71. +11 −0 scripts/generate_namespaces_externs.py
  72. +48 −5 scripts/npm_test.js
@@ -957,11 +957,11 @@ lighthouse_locale_files = [

all_devtools_files += lighthouse_locale_files

all_devtools_modules = [
"front_end/root.js",
"front_end/ui/ARIAUtils.js",
"front_end/ui/ui.js",
]
all_devtools_modules = [ # -- darwin
"front_end/root.js", # -- darwin
"front_end/ui/ARIAUtils.js", # -- darwin
"front_end/ui/ui.js", # -- darwin
] # -- darwin

devtools_test_files = [
"//third_party/axe-core/axe.js",
@@ -1154,30 +1154,32 @@ application_templates = [
"front_end/worker_app.html",
]

copied_devtools_modules = [
"$resources_out_dir/root.js",
"$resources_out_dir/ui/ARIAUtils.js",
"$resources_out_dir/ui/ui.js",
]

generated_applications = [
"$resources_out_dir/audits_worker.js",
"$resources_out_dir/devtools_app.html",
"$resources_out_dir/devtools_app.js",
"$resources_out_dir/formatter_worker.js",
"$resources_out_dir/heap_snapshot_worker.js",
"$resources_out_dir/inspector.html",
"$resources_out_dir/inspector.js",
"$resources_out_dir/js_app.html",
"$resources_out_dir/js_app.js",
"$resources_out_dir/node_app.html",
"$resources_out_dir/node_app.js",
"$resources_out_dir/shell.js",
"$resources_out_dir/toolbox.html",
"$resources_out_dir/toolbox.js",
"$resources_out_dir/worker_app.html",
"$resources_out_dir/worker_app.js",
]
# mark for conflicts -- darwin
copied_devtools_modules = [ # -- darwin
"$resources_out_dir/root.js", # -- darwin
"$resources_out_dir/ui/ARIAUtils.js", # -- darwin
"$resources_out_dir/ui/ui.js", # -- darwin
] # -- darwin

# mark for conflicts -- darwin
generated_applications = [ # -- darwin
"$resources_out_dir/audits_worker.js", # -- darwin
"$resources_out_dir/devtools_app.html", # -- darwin
"$resources_out_dir/devtools_app.js", # -- darwin
"$resources_out_dir/formatter_worker.js", # -- darwin
"$resources_out_dir/heap_snapshot_worker.js", # -- darwin
"$resources_out_dir/inspector.html", # -- darwin
"$resources_out_dir/inspector.js", # -- darwin
"$resources_out_dir/js_app.html", # -- darwin
"$resources_out_dir/js_app.js", # -- darwin
"$resources_out_dir/node_app.html", # -- darwin
"$resources_out_dir/node_app.js", # -- darwin
"$resources_out_dir/shell.js", # -- darwin
"$resources_out_dir/toolbox.html", # -- darwin
"$resources_out_dir/toolbox.js", # -- darwin
"$resources_out_dir/worker_app.html", # -- darwin
"$resources_out_dir/worker_app.js", # -- darwin
] # -- darwin

generated_non_autostart_non_remote_modules = [
"$resources_out_dir/animation/animation_module.js",
@@ -207,6 +207,10 @@ var Runtime = class { // eslint-disable-line
* @param {string=} scriptSource
*/
function evaluateScript(sourceURL, scriptSource) {
if (_loadedScripts[sourceURL]) {
// darwin: prevent multiple loading of the same script, does this happen to me only?
return;
}
_loadedScripts[sourceURL] = true;
if (!scriptSource) {
// Do not reject, as this is normal in the hosted mode.
@@ -261,6 +261,13 @@ Bindings.ResourceScriptFile = class extends Common.Object {
Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this);
}

/**
* @return {?SDK.Script}
*/
getScript() {
return this._script;
}

/**
* @param {!Array.<!SDK.Script>} scripts
* @return {boolean}
@@ -9403,7 +9403,9 @@
// possible when it is clear that nothing happened. hasSelection
// will be the case when there is a lot of text in the textarea,
// in which case reading its value would be expensive.
if (this.contextMenuPending || !cm.state.focused ||
if (this.contextMenuPending || /* DIRAC-HACK !cm.state.focused ||
codemirror is too smart here and this disabled automation of code completions done by dirac via keysim.js
*/
(hasSelection(input) && !prevInput && !this.composing) ||
cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
{ return false }
@@ -44,6 +44,13 @@
match: found && found.ch == match.charAt(0), forward: dir > 0};
}

// Parinfer edit:
// (we add style classes to closing brackets, so we ignore them here)
function bracketStylesMatch(a, b) {
var valid = function(x) { return x.indexOf("bracket") == 0; }
return (a == b || valid(a) && valid(b));
}

// bracketRegex is used to specify which type of bracket to scan
// should be a regexp, e.g. /[[\]]/
//
@@ -67,7 +74,7 @@
if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
for (; pos != end; pos += dir) {
var ch = line.charAt(pos);
if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
if (re.test(ch) && (style === undefined || bracketStylesMatch(cm.getTokenTypeAt(Pos(lineNo, pos + 1)), style))) {
var match = matching[ch];
if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
@@ -107,23 +114,20 @@
}
}

// Parinfer edit:
// (currentlyHighlighted should be local state if we want each editor to have their own highlighted brackets)
function doMatchBrackets(cm) {
cm.operation(function() {
if (cm.state.matchBrackets.currentlyHighlighted) {
cm.state.matchBrackets.currentlyHighlighted();
cm.state.matchBrackets.currentlyHighlighted = null;
}
cm.state.matchBrackets.currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
var state = cm.state.matchBrackets;
if (state.currentlyHighlighted) {state.currentlyHighlighted(); state.currentlyHighlighted = null;}
state.currentlyHighlighted = matchBrackets(cm, false, state);
});
}

CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
if (old && old != CodeMirror.Init) {
cm.off("cursorActivity", doMatchBrackets);
if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) {
cm.state.matchBrackets.currentlyHighlighted();
cm.state.matchBrackets.currentlyHighlighted = null;
}
if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;}
}
if (val) {
cm.state.matchBrackets = typeof val == "object" ? val : {};
@@ -0,0 +1,63 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
var prev = old && old != CodeMirror.Init;
if (val && !prev) {
cm.on("blur", onBlur);
cm.on("change", onChange);
cm.on("swapDoc", onChange);
onChange(cm);
} else if (!val && prev) {
cm.off("blur", onBlur);
cm.off("change", onChange);
cm.off("swapDoc", onChange);
clearPlaceholder(cm);
var wrapper = cm.getWrapperElement();
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
}

// if (val && !cm.hasFocus()) onBlur(cm);
if (val) onBlur(cm);
});

function clearPlaceholder(cm) {
if (cm.state.placeholder) {
cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
cm.state.placeholder = null;
}
}
function setPlaceholder(cm) {
clearPlaceholder(cm);
var elt = cm.state.placeholder = document.createElement("pre");
elt.style.cssText = "height: 0; overflow: visible";
elt.className = "CodeMirror-placeholder";
var placeHolder = cm.getOption("placeholder")
if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
elt.appendChild(placeHolder)
cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
}

function onBlur(cm) {
if (isEmpty(cm)) setPlaceholder(cm);
}
function onChange(cm) {
var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");

if (empty) setPlaceholder(cm);
else clearPlaceholder(cm);
}

function isEmpty(cm) {
return (cm.lineCount() === 1) && (cm.getLine(0) === "");
}
});
@@ -0,0 +1,72 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";

CodeMirror.runMode = function(string, modespec, callback, options) {
var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
var ie = /MSIE \d/.test(navigator.userAgent);
var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);

if (callback.nodeType == 1) {
var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
var node = callback, col = 0;
node.innerHTML = "";
callback = function(text, style) {
if (text == "\n") {
// Emitting LF or CRLF on IE8 or earlier results in an incorrect display.
// Emitting a carriage return makes everything ok.
node.appendChild(document.createTextNode(ie_lt9 ? '\r' : text));
col = 0;
return;
}
var content = "";
// replace tabs
for (var pos = 0;;) {
var idx = text.indexOf("\t", pos);
if (idx == -1) {
content += text.slice(pos);
col += text.length - pos;
break;
} else {
col += idx - pos;
content += text.slice(pos, idx);
var size = tabSize - col % tabSize;
col += size;
for (var i = 0; i < size; ++i) content += " ";
pos = idx + 1;
}
}

if (style) {
var sp = node.appendChild(document.createElement("span"));
sp.className = "cm-" + style.replace(/ +/g, " cm-");
sp.appendChild(document.createTextNode(content));
} else {
node.appendChild(document.createTextNode(content));
}
};
}

var lines = CodeMirror.splitLines(string), state = (options && options.state) || CodeMirror.startState(mode);
for (var i = 0, e = lines.length; i < e; ++i) {
if (i) callback("\n");
var stream = new CodeMirror.StringStream(lines[i]);
if (!stream.string && mode.blankLine) mode.blankLine(state);
while (!stream.eol()) {
var style = mode.token(stream, state);
callback(stream.current(), style, i, stream.start, state);
stream.start = stream.pos;
}
}
};

});
@@ -503,7 +503,8 @@ Components.Linkifier = class {
return false;
const actions = Components.Linkifier._linkActions(link);
if (actions.length) {
actions[0].handler.call(null);
const handler = /** @type { function(?Event=) } */(actions[0].handler);
handler.call(null, event);
return true;
}
return false;
@@ -581,6 +582,7 @@ Components.Linkifier = class {
}
if (contentProvider) {
const lineNumber = uiLocation ? uiLocation.lineNumber : info.lineNumber || 0;
const columnNumber = uiLocation ? uiLocation.columnNumber : info.columnNumber || 0;
for (const title of Components.Linkifier._linkHandlers.keys()) {
const handler = Components.Linkifier._linkHandlers.get(title);
const action = {
@@ -593,6 +595,15 @@ Components.Linkifier = class {
else
result.push(action);
}
if (dirac.hasLinkActions) {
const diracAction = Components.Linkifier.diracLinkHandlerAction;
if (diracAction) {
result.unshift({
title: diracAction.title,
handler: diracAction.handler.bind(null, result, contentProvider.contentURL(), lineNumber, columnNumber)
});
}
}
}
if (resource || info.url) {
result.push({

0 comments on commit 48d5bb5

Please sign in to comment.
You can’t perform that action at this time.