remote-debug.plugin.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //var compression = require("./compression");
  2. //var noCachePlugin = require("./no-cache");
  3. var overlayPlugin = require("./overlay-grid/overlay-grid");
  4. var clientFiles = require("./client-files");
  5. const PLUGIN_NAME = "Remote Debug";
  6. /**
  7. * @type {{plugin: Function, plugin:name: string, markup: string}}
  8. */
  9. module.exports = {
  10. /**
  11. * @param ui
  12. * @param bs
  13. */
  14. "plugin": function (ui, bs) {
  15. ui.overlayGrid = overlayPlugin.init(ui, bs);
  16. //ui.noCache = noCachePlugin.init(ui, bs);
  17. //ui.compression = compression.init(ui, bs);
  18. /**
  19. * Listen for file events
  20. */
  21. ui.listen("remote-debug:files", {
  22. "enableFile": function (file) {
  23. ui.enableElement(file);
  24. },
  25. "disableFile": function (file) {
  26. ui.disableElement(file);
  27. }
  28. });
  29. /**
  30. * Listen for overlay-grid events
  31. */
  32. ui.listen("remote-debug:overlay-grid", ui.overlayGrid);
  33. },
  34. /**
  35. * Hooks
  36. */
  37. "hooks": {
  38. "markup": fileContent("remote-debug.html"),
  39. "client:js": [
  40. fileContent("/remote-debug.client.js"),
  41. fileContent("/overlay-grid/overlay-grid.client.js")
  42. ],
  43. "templates": [
  44. getPath("/overlay-grid/overlay-grid.html")
  45. ],
  46. "page": {
  47. path: "/remote-debug",
  48. title: PLUGIN_NAME,
  49. template: "remote-debug.html",
  50. controller: PLUGIN_NAME.replace(" ", "") + "Controller",
  51. order: 4,
  52. icon: "bug"
  53. },
  54. elements: clientFiles.files
  55. },
  56. /**
  57. * Plugin name
  58. */
  59. "plugin:name": PLUGIN_NAME
  60. };
  61. /**
  62. * @param filepath
  63. * @returns {*}
  64. */
  65. function getPath (filepath) {
  66. return require("path").join(__dirname, filepath);
  67. }
  68. /**
  69. * @param filepath
  70. * @returns {*}
  71. */
  72. function fileContent (filepath) {
  73. return require("fs").readFileSync(getPath(filepath), "utf-8");
  74. }