-
Notifications
You must be signed in to change notification settings - Fork 192
/
main.js
116 lines (100 loc) · 4.72 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
define(function (require, exports, module) {
// TODO: thirdparty module
require("bluebird");
require("eventemitter2");
require("marked");
require("blueimp-md5");
require("moment");
require("URI");
// TODO: do a templates module
require("text!src/dialogs/templates/clone-dialog.html");
require("text!src/dialogs/templates/credentials-template.html");
require("text!src/dialogs/templates/progress-dialog.html");
require("text!src/dialogs/templates/pull-dialog.html");
require("text!src/dialogs/templates/push-dialog.html");
require("text!src/dialogs/templates/remotes-template.html");
require("text!templates/git-branches-menu.html");
require("text!templates/branch-new-dialog.html");
require("text!templates/branch-merge-dialog.html");
require("text!templates/git-changelog-dialog.html");
require("text!templates/error-report.md");
require("text!templates/git-error-dialog.html");
require("text!templates/git-panel-history.html");
require("text!templates/git-panel-history-commits.html");
require("text!templates/history-viewer.html");
require("text!templates/history-viewer-files.html");
require("text!templates/default-gitignore");
require("text!templates/git-panel.html");
require("text!templates/git-panel-results.html");
require("text!templates/authors-dialog.html");
require("text!templates/git-commit-dialog.html");
require("text!templates/git-tag-dialog.html");
require("text!templates/git-diff-dialog.html");
require("text!templates/git-question-dialog.html");
require("text!templates/git-remotes-picker.html");
require("text!templates/git-settings-dialog.html");
require("text!templates/format-diff.html");
require("text!templates/git-question-dialog.html");
require("text!templates/git-output.html");
// Brackets modules
var _ = brackets.getModule("thirdparty/lodash"),
AppInit = brackets.getModule("utils/AppInit"),
CommandManager = brackets.getModule("command/CommandManager"),
Commands = brackets.getModule("command/Commands"),
ExtensionUtils = brackets.getModule("utils/ExtensionUtils"),
Menus = brackets.getModule("command/Menus"),
NodeConnection = brackets.getModule("utils/NodeConnection");
// Local modules
var SettingsDialog = require("dist/SettingsDialog"),
EventEmitter = require("dist/EventEmitter").default,
Events = require("dist/Events"),
Main = require("dist/Main"),
Preferences = require("dist/Preferences"),
Strings = require("strings");
window.bracketsGit = window.bracketsGit || {};
window.bracketsGit.getExtensionPath = function () {
return ExtensionUtils.getModulePath(module);
}
window.bracketsGit.EventEmitter = EventEmitter;
window.bracketsGit.Events = Events;
// Load extension modules that are not included by core
var modules = [
"dist/BracketsEvents",
"dist/GutterManager",
"dist/History",
"dist/NoRepo",
"dist/ProjectTreeMarks",
"dist/Remotes",
"dist/utils/Terminal"
];
if (Preferences.get("useGitFtp")) { modules.push("dist/ftp/Ftp"); }
if (Preferences.get("showTerminalIcon")) { modules.push("dist/TerminalIcon"); }
require(modules);
// Load CSS
ExtensionUtils.loadStyleSheet(module, "styles/brackets-git.less");
ExtensionUtils.loadStyleSheet(module, "styles/fonts/octicon.less");
if (Preferences.get("useGitFtp")) { ExtensionUtils.loadStyleSheet(module, "styles/ftp/ftp.less"); }
// Register command and add it to the menu.
var SETTINGS_COMMAND_ID = "brackets-git.settings";
CommandManager.register(Strings.GIT_SETTINGS, SETTINGS_COMMAND_ID, SettingsDialog.show);
Menus.getMenu(Menus.AppMenuBar.FILE_MENU).addMenuItem(SETTINGS_COMMAND_ID, "", Menus.AFTER, Commands.FILE_PROJECT_SETTINGS);
AppInit.appReady(function () {
Main.init();
});
var nodeDomains = {};
// keeps a track of who is accessing node domains
NodeConnection.prototype.loadDomains = _.wrap(NodeConnection.prototype.loadDomains, function (loadDomains) {
var paths = arguments[1];
if (!Array.isArray(paths)) { paths = [paths]; }
var extId = "unknown";
var stack = new Error().stack.split("\n").slice(2).join("\n");
var m = stack.match(/extensions\/user\/([^\/]+)/);
if (m) {
extId = m[1];
}
if (!nodeDomains[extId]) { nodeDomains[extId] = []; }
nodeDomains[extId] = _.uniq(nodeDomains[extId].concat(paths));
// call the original method
return loadDomains.apply(this, _.toArray(arguments).slice(1));
});
});