Skip to content

Commit a54fb96

Browse files
committed
deploy: 606b7d0
1 parent fd61dc3 commit a54fb96

File tree

82 files changed

+3269
-1128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+3269
-1128
lines changed

LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 206 additions & 214 deletions
Large diffs are not rendered by default.

LiveDevelopment/LivePreviewEdit.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
/*
2+
* GNU AGPL-3.0 License
3+
*
4+
* Copyright (c) 2021 - present core.ai . All rights reserved.
5+
* Original work Copyright (c) 2012 - 2021 Adobe Systems Incorporated. All rights reserved.
6+
*
7+
* This program is free software: you can redistribute it and/or modify it
8+
* under the terms of the GNU Affero General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful, but WITHOUT
13+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
15+
* for more details.
16+
*
17+
* You should have received a copy of the GNU Affero General Public License
18+
* along with this program. If not, see https://opensource.org/licenses/AGPL-3.0.
19+
*
20+
*/
21+
22+
/*
23+
* This file handles all the editor side source code handling after user performed some live preview edit operation
24+
* when any operation is performed in the browser context (handled inside remoteFunctions.js) it sends a message through
25+
* MessageBroker, now this file then makes the change in the source code
26+
*/
127
define(function (require, exports, module) {
228
const HTMLInstrumentation = require("LiveDevelopment/MultiBrowserImpl/language/HTMLInstrumentation");
329
const LiveDevMultiBrowser = require("LiveDevelopment/LiveDevMultiBrowser");
@@ -194,8 +220,12 @@ define(function (require, exports, module) {
194220
// this is a quick trick because as the code is changed for that element in the file,
195221
// the live preview for that element gets refreshed and the changes are discarded in the live preview
196222
if(!message.isEditSuccessful) {
197-
editor.replaceRange(text, startPos, endPos);
198-
editor.document._markClean();
223+
editor.document.batchOperation(function () {
224+
editor.replaceRange(text, startPos, endPos);
225+
setTimeout(() => {
226+
editor.undo(); // undo the replaceRange so dirty icon won't appear and no net change in undo history
227+
}, 0);
228+
});
199229
} else {
200230

201231
// if the edit operation was successful, we call a helper function that

LiveDevelopment/main.js

Lines changed: 142 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@ define(function main(require, exports, module) {
4343
ExtensionUtils = require("utils/ExtensionUtils"),
4444
StringUtils = require("utils/StringUtils"),
4545
EventDispatcher = require("utils/EventDispatcher"),
46-
WorkspaceManager = require("view/WorkspaceManager");
46+
WorkspaceManager = require("view/WorkspaceManager"),
47+
EditorManager = require("editor/EditorManager");
4748

4849

4950
// this is responsible to make the advanced live preview features active or inactive
50-
// @abose (make this variable false when not a paid user, everything rest is handled automatically)
51-
let isLPEditFeaturesActive = false;
51+
// @abose (make the first value true when its a paid user, everything rest is handled automatically)
52+
let isProUser = window.KernalModeTrust ? true : false;
53+
// when isFreeTrialUser is true isProUser should also be true
54+
// when its false, isProUser can be true/false doesn't matter
55+
let isFreeTrialUser = true;
5256

5357
const EVENT_LIVE_HIGHLIGHT_PREF_CHANGED = "liveHighlightPrefChange";
5458

@@ -64,7 +68,7 @@ define(function main(require, exports, module) {
6468
paddingColor: {r: 147, g: 196, b: 125, a: 0.66},
6569
showInfo: true
6670
},
67-
isLPEditFeaturesActive: isLPEditFeaturesActive,
71+
isProUser: isProUser,
6872
elemHighlights: "hover", // default value, this will get updated when the extension loads
6973
// this strings are used in RemoteFunctions.js
7074
// we need to pass this through config as remoteFunctions runs in browser context and cannot
@@ -269,6 +273,122 @@ define(function main(require, exports, module) {
269273
return false;
270274
}
271275

276+
let $livePreviewPanel = null; // stores the live preview panel, need this as overlay is appended inside this
277+
let $overlayContainer = null; // the overlay container
278+
let shouldShowSyncErrorOverlay = true; // once user closes the overlay we don't show them again
279+
let shouldShowConnectingOverlay = true;
280+
let connectingOverlayTimer = null; // this is needed as we show the connecting overlay after 3s
281+
let connectingOverlayTimeDuration = 3000;
282+
283+
/**
284+
* this function is responsible to check whether to show the overlay or not and how it should be shown
285+
* because if user has closed the overlay manually, we don't show it again
286+
* secondly, for connecting overlay we show that after a 3s timer, but sync error overlay is shown immediately
287+
* @param {String} textMessage - the text that is written inside the overlay
288+
* @param {Number} status - 1 for connect, 4 for sync error but we match it using MultiBrowserLiveDev
289+
*/
290+
function _handleOverlay(textMessage, status) {
291+
if (!$livePreviewPanel) {
292+
$livePreviewPanel = $("#panel-live-preview");
293+
}
294+
295+
// remove any existing overlay & timer
296+
_hideOverlay();
297+
298+
// to not show the overlays if user has already closed it before
299+
if(status === MultiBrowserLiveDev.STATUS_CONNECTING && !shouldShowConnectingOverlay) { return; }
300+
if(status === MultiBrowserLiveDev.STATUS_SYNC_ERROR && !shouldShowSyncErrorOverlay) { return; }
301+
302+
// for connecting status, we delay showing the overlay by 3 seconds
303+
if(status === MultiBrowserLiveDev.STATUS_CONNECTING) {
304+
connectingOverlayTimer = setTimeout(() => {
305+
_createAndShowOverlay(textMessage, status);
306+
connectingOverlayTimer = null;
307+
}, connectingOverlayTimeDuration);
308+
return;
309+
}
310+
311+
// for sync error status, show immediately
312+
_createAndShowOverlay(textMessage, status);
313+
}
314+
315+
/**
316+
* this function is responsible to create & show the overlay.
317+
* so overlay is shown when the live preview is connecting or live preview stopped because of some syntax error
318+
* @param {String} textMessage - the text that is written inside the overlay
319+
* @param {Number} status - 1 for connect, 4 for sync error but we match it using MultiBrowserLiveDev
320+
*/
321+
function _createAndShowOverlay(textMessage, status) {
322+
if (!$livePreviewPanel) {
323+
$livePreviewPanel = $("#panel-live-preview");
324+
}
325+
326+
// create the overlay element
327+
// styled inside the 'src/extensionsIntegrated/Phoenix-live-preview/live-preview.css'
328+
$overlayContainer = $("<div>").addClass("live-preview-status-overlay"); // the wrapper for overlay element
329+
const $message = $("<div>").addClass("live-preview-overlay-message").text(textMessage);
330+
331+
// the close button at the right end of the overlay
332+
const $close = $("<div>").addClass("live-preview-overlay-close")
333+
.attr("title", Strings.LIVE_PREVIEW_HIDE_OVERLAY)
334+
.on('click', () => {
335+
if(status === MultiBrowserLiveDev.STATUS_CONNECTING) {
336+
shouldShowConnectingOverlay = false;
337+
} else if(status === MultiBrowserLiveDev.STATUS_SYNC_ERROR) {
338+
shouldShowSyncErrorOverlay = false;
339+
}
340+
_hideOverlay();
341+
});
342+
const $closeIcon = $("<i>").addClass("fas fa-times");
343+
344+
$close.append($closeIcon);
345+
$overlayContainer.append($message);
346+
$overlayContainer.append($close);
347+
$livePreviewPanel.append($overlayContainer);
348+
}
349+
350+
/**
351+
* responsible to hide the overlay
352+
*/
353+
function _hideOverlay() {
354+
_clearConnectingOverlayTimer();
355+
if ($overlayContainer) {
356+
$overlayContainer.remove();
357+
$overlayContainer = null;
358+
}
359+
}
360+
361+
/**
362+
* This is a helper function that just checks that if connectingOverlayTimer exists, we clear it
363+
*/
364+
function _clearConnectingOverlayTimer() {
365+
if (connectingOverlayTimer) {
366+
clearTimeout(connectingOverlayTimer);
367+
connectingOverlayTimer = null;
368+
}
369+
}
370+
371+
/**
372+
* this function adds/remove the full-width class from the overlay container
373+
* styled inside 'src/extensionsIntegrated/Phoenix-live-preview/live-preview.css'
374+
*
375+
* we need this because
376+
* normally when live preview has a good width (more than 305px) then a 3px divider is shown at the left end
377+
* so in that case we give the overlay a width of (100% - 3px),
378+
* but when the live preview width is reduced
379+
* then that divider line gets cut off, so in that case we make the width 100% for this overlay
380+
*
381+
* without this handling, a white gap appears on the left side, which is distracting
382+
*/
383+
function _setOverlayWidth() {
384+
if(!$overlayContainer || !$livePreviewPanel.length) { return; }
385+
if($livePreviewPanel.width() <= 305) {
386+
$overlayContainer.addClass("full-width");
387+
} else {
388+
$overlayContainer.removeClass("full-width");
389+
}
390+
}
391+
272392
/** Initialize LiveDevelopment */
273393
AppInit.appReady(function () {
274394
params.parse();
@@ -323,6 +443,19 @@ define(function main(require, exports, module) {
323443
exports.trigger(exports.EVENT_LIVE_PREVIEW_RELOAD, clientDetails);
324444
});
325445

446+
MultiBrowserLiveDev.on(MultiBrowserLiveDev.EVENT_STATUS_CHANGE, function(event, status) {
447+
if (status === MultiBrowserLiveDev.STATUS_CONNECTING) {
448+
_handleOverlay(Strings.LIVE_DEV_STATUS_TIP_PROGRESS1, status);
449+
} else if (status === MultiBrowserLiveDev.STATUS_SYNC_ERROR) {
450+
_handleOverlay(Strings.LIVE_DEV_STATUS_TIP_SYNC_ERROR, status);
451+
} else {
452+
_hideOverlay();
453+
}
454+
});
455+
// to understand why we need this, pls read the _setOverlayWidth function
456+
new ResizeObserver(_setOverlayWidth).observe($("#main-plugin-panel")[0]);
457+
EditorManager.on("activeEditorChange", _hideOverlay);
458+
326459
// allow live preview to handle escape key event
327460
// Escape is mainly to hide boxes if they are visible
328461
WorkspaceManager.addEscapeKeyEventHandler("livePreview", _handleLivePreviewEscapeKey);
@@ -341,8 +474,9 @@ define(function main(require, exports, module) {
341474
config.highlight = PreferencesManager.getViewState("livedevHighlight");
342475

343476
function setLivePreviewEditFeaturesActive(enabled) {
344-
isLPEditFeaturesActive = enabled;
345-
config.isLPEditFeaturesActive = enabled;
477+
// TODO: @abose here add kernal mode trust check
478+
isProUser = enabled;
479+
config.isProUser = enabled;
346480
if (MultiBrowserLiveDev && MultiBrowserLiveDev.status >= MultiBrowserLiveDev.STATUS_ACTIVE) {
347481
MultiBrowserLiveDev.updateConfig(JSON.stringify(config));
348482
MultiBrowserLiveDev.registerHandlers();
@@ -368,7 +502,8 @@ define(function main(require, exports, module) {
368502

369503
EventDispatcher.makeEventDispatcher(exports);
370504

371-
exports.isLPEditFeaturesActive = isLPEditFeaturesActive;
505+
exports.isProUser = isProUser;
506+
exports.isFreeTrialUser = isFreeTrialUser;
372507

373508
// public events
374509
exports.EVENT_OPEN_PREVIEW_URL = MultiBrowserLiveDev.EVENT_OPEN_PREVIEW_URL;

appConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ window.AppConfig = {
2828
"app_notification_url": "assets/notifications/dev/",
2929
"app_update_url": "https://updates.phcode.io/tauri/update-latest-experimental-build.json",
3030
"linting.enabled_by_default": true,
31-
"build_timestamp": "2025-08-31T10:55:53.804Z",
31+
"build_timestamp": "2025-09-01T02:54:50.825Z",
3232
"googleAnalyticsID": "G-P4HJFPDB76",
3333
"googleAnalyticsIDDesktop": "G-VE5BXWJ0HF",
3434
"mixPanelID": "49c4d164b592be2350fc7af06a259bf3",
@@ -40,7 +40,7 @@ window.AppConfig = {
4040
"bugsnagEnv": "development"
4141
},
4242
"name": "Phoenix Code",
43-
"version": "4.1.2-21362",
43+
"version": "4.1.2-21381",
4444
"apiVersion": "4.1.2",
4545
"homepage": "https://core.ai",
4646
"issues": {

assets/default-project/en.zip

0 Bytes
Binary file not shown.

assets/sample-projects/HTML5.zip

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

assets/sample-projects/explore.zip

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)