Skip to content

Commit eedcaec

Browse files
committed
chore: make LivePreviewEdit.js movable to extension
1 parent 443d3a7 commit eedcaec

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

gulpfile.js/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ function _renameExtensionConcatAsExtensionJSInDist(extensionName) {
789789
}
790790

791791
const minifyableExtensions = ["CloseOthers", "CodeFolding", "DebugCommands", "Git",
792-
"HealthData", "JavaScriptCodeHints", "JavaScriptRefactoring", "QuickView"];
792+
"HealthData", "JavaScriptCodeHints", "JavaScriptRefactoring", "QuickView", "phoenix-pro"];
793793
// extensions that nned not be minified either coz they are single file extensions or some other reason.
794794
const nonMinifyExtensions = ["CSSAtRuleCodeHints", "CSSCodeHints",
795795
"CSSPseudoSelectorHints", "DarkTheme", "HandlebarsSupport", "HTMLCodeHints", "HtmlEntityCodeHints",

src/LiveDevelopment/LivePreviewEdit.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ define(function (require, exports, module) {
4141
const ProDialogs = require("services/pro-dialogs");
4242
const Mustache = require("thirdparty/mustache/mustache");
4343
const Strings = require("strings");
44-
const ImageFolderDialogTemplate = require("text!htmlContent/image-folder-dialog.html");
44+
const ImageFolderDialogTemplate = require("text!htmlContent/image-folder-dialog.html"); // todo move to extension
45+
const LiveDevProtocol = require("LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol");
4546

4647
// state manager key, to save the download location of the image
4748
const IMAGE_DOWNLOAD_FOLDER_KEY = "imageGallery.downloadFolder";
@@ -1820,5 +1821,9 @@ define(function (require, exports, module) {
18201821
}
18211822
}
18221823

1823-
exports.handleLivePreviewEditOperation = handleLivePreviewEditOperation;
1824+
LiveDevProtocol.setLivePreviewMessageHandler((msg)=>{
1825+
if (msg.livePreviewEditEnabled) {
1826+
handleLivePreviewEditOperation(msg);
1827+
}
1828+
});
18241829
});

src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ define(function (require, exports, module) {
5252
HTMLInstrumentation = require("LiveDevelopment/MultiBrowserImpl/language/HTMLInstrumentation"),
5353
StringUtils = require("utils/StringUtils"),
5454
FileViewController = require("project/FileViewController"),
55-
MainViewManager = require("view/MainViewManager"),
56-
LivePreviewEdit = require("LiveDevelopment/LivePreviewEdit");
55+
MainViewManager = require("view/MainViewManager");
5756

5857
const LIVE_DEV_REMOTE_SCRIPTS_FILE_NAME = `phoenix_live_preview_scripts_instrumented_${StringUtils.randomString(8)}.js`;
5958
const LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME = `pageLoaderWorker_${StringUtils.randomString(8)}.js`;
@@ -203,6 +202,11 @@ define(function (require, exports, module) {
203202
// for a fraction of a second. so a size of 1000 should be more than enough.
204203
});
205204

205+
let _livePreviewMessageHandler;
206+
function setLivePreviewMessageHandler(handler) {
207+
_livePreviewMessageHandler = handler;
208+
}
209+
206210
/**
207211
* @private
208212
* Handles a message received from the remote protocol handler via the transport.
@@ -227,8 +231,8 @@ define(function (require, exports, module) {
227231
} else if (messageID) {
228232
processedMessageIDs.set(messageID, true);
229233
}
230-
if (msg.livePreviewEditEnabled) {
231-
LivePreviewEdit.handleLivePreviewEditOperation(msg);
234+
if(_livePreviewMessageHandler) {
235+
_livePreviewMessageHandler(msg);
232236
}
233237

234238
if (msg.id) {
@@ -498,6 +502,7 @@ define(function (require, exports, module) {
498502
exports.getConnectionIds = getConnectionIds;
499503
exports.closeAllConnections = closeAllConnections;
500504
exports.addRemoteFunctionScript = addRemoteFunctionScript;
505+
exports.setLivePreviewMessageHandler = setLivePreviewMessageHandler;
501506
exports.LIVE_DEV_REMOTE_SCRIPTS_FILE_NAME = LIVE_DEV_REMOTE_SCRIPTS_FILE_NAME;
502507
exports.LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME = LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME;
503508
exports.EVENT_LIVE_PREVIEW_CLICKED = EVENT_LIVE_PREVIEW_CLICKED;

src/LiveDevelopment/RemoteHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535

3636
define(function (require, exports, module) {
37-
const Strings = require("strings");
37+
const Strings = require("strings"); // todo move to code construction logic
3838

3939
// list of all the strings that are used in the remoteFunctions file
4040
const remoteStrings = {

0 commit comments

Comments
 (0)