Skip to content

Commit 324f0ff

Browse files
committed
deploy: 606b7d0
1 parent f1b88ac commit 324f0ff

File tree

58 files changed

+428
-217
lines changed

Some content is hidden

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

58 files changed

+428
-217
lines changed

LiveDevelopment/LiveDevMultiBrowser.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
* - "navigated_away" (The browser changed to a location outside of the project)
5555
* - "detached_target_closed" (The tab or window was closed)
5656
*/
57+
58+
/*global jsPromise */
59+
5760
define(function (require, exports, module) {
5861

5962

@@ -521,24 +524,18 @@ define(function (require, exports, module) {
521524
isViewable = _server && _server.canServe(doc.file.fullPath);
522525

523526
if (_liveDocument && _liveDocument.doc.url !== docUrl && isViewable) {
524-
// clear live doc and related docs
525-
_closeDocuments();
526-
// create new live doc
527-
_createLiveDocumentForFrame(doc);
528-
_setStatus(STATUS_RESTARTING);
529-
_open(doc);
530-
527+
open();
531528
}
532529
}
533530

534531

535532
/**
536533
* Open a live preview on the current docuemnt.
537534
*/
538-
function open() {
535+
async function open() {
539536
let doc = DocumentManager.getCurrentDocument();
540537
if(livePreviewUrlPinned){
541-
doc = DocumentManager.getDocumentForPath(currentPreviewFilePath);
538+
doc = await jsPromise(DocumentManager.getDocumentForPath(currentPreviewFilePath));
542539
}
543540

544541
// wait for server (StaticServer, Base URL or file:)
@@ -548,6 +545,9 @@ define(function (require, exports, module) {
548545
return;
549546
}
550547
_setStatus(STATUS_CONNECTING);
548+
// clear live doc and related docs
549+
_closeDocuments();
550+
// create new live doc
551551
doc && _createLiveDocumentForFrame(doc);
552552
if(_server.isActive()){
553553
doc && _open(doc);

LiveDevelopment/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ define(function main(require, exports, module) {
130130
MultiBrowserLiveDev.close();
131131
}
132132

133-
function openLivePreview() {
133+
function openLivePreview(doc) {
134134
if (!Phoenix.isTestWindow) {
135-
MultiBrowserLiveDev.open();
135+
MultiBrowserLiveDev.open(doc);
136136
}
137137
}
138138

appConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ window.AppConfig = {
2424
"app_notification_url": "assets/notifications/dev/",
2525
"app_update_url": "https://updates.phcode.io/tauri/update-latest-experimental-build.json",
2626
"linting.enabled_by_default": true,
27-
"build_timestamp": "2024-04-04T12:26:17.548Z",
27+
"build_timestamp": "2024-04-06T05:32:32.865Z",
2828
"googleAnalyticsID": "G-P4HJFPDB76",
2929
"googleAnalyticsIDDesktop": "G-VE5BXWJ0HF",
3030
"mixPanelID": "49c4d164b592be2350fc7af06a259bf3",
@@ -36,7 +36,7 @@ window.AppConfig = {
3636
"bugsnagEnv": "development"
3737
},
3838
"name": "Phoenix Code",
39-
"version": "3.6.1-20114",
39+
"version": "3.6.1-20116",
4040
"apiVersion": "3.6.1",
4141
"homepage": "https://core.ai",
4242
"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.

brackets-min.js

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3400,6 +3400,9 @@ define("JSUtils/Session", function (require, exports, module) {
34003400
* - "navigated_away" (The browser changed to a location outside of the project)
34013401
* - "detached_target_closed" (The tab or window was closed)
34023402
*/
3403+
3404+
/*global jsPromise */
3405+
34033406
define("LiveDevelopment/LiveDevMultiBrowser", function (require, exports, module) {
34043407

34053408

@@ -3867,24 +3870,18 @@ define("LiveDevelopment/LiveDevMultiBrowser", function (require, exports, module
38673870
isViewable = _server && _server.canServe(doc.file.fullPath);
38683871

38693872
if (_liveDocument && _liveDocument.doc.url !== docUrl && isViewable) {
3870-
// clear live doc and related docs
3871-
_closeDocuments();
3872-
// create new live doc
3873-
_createLiveDocumentForFrame(doc);
3874-
_setStatus(STATUS_RESTARTING);
3875-
_open(doc);
3876-
3873+
open();
38773874
}
38783875
}
38793876

38803877

38813878
/**
38823879
* Open a live preview on the current docuemnt.
38833880
*/
3884-
function open() {
3881+
async function open() {
38853882
let doc = DocumentManager.getCurrentDocument();
38863883
if(livePreviewUrlPinned){
3887-
doc = DocumentManager.getDocumentForPath(currentPreviewFilePath);
3884+
doc = await jsPromise(DocumentManager.getDocumentForPath(currentPreviewFilePath));
38883885
}
38893886

38903887
// wait for server (StaticServer, Base URL or file:)
@@ -3894,6 +3891,9 @@ define("LiveDevelopment/LiveDevMultiBrowser", function (require, exports, module
38943891
return;
38953892
}
38963893
_setStatus(STATUS_CONNECTING);
3894+
// clear live doc and related docs
3895+
_closeDocuments();
3896+
// create new live doc
38973897
doc && _createLiveDocumentForFrame(doc);
38983898
if(_server.isActive()){
38993899
doc && _open(doc);
@@ -7617,9 +7617,9 @@ define("LiveDevelopment/main", function main(require, exports, module) {
76177617
MultiBrowserLiveDev.close();
76187618
}
76197619

7620-
function openLivePreview() {
7620+
function openLivePreview(doc) {
76217621
if (!Phoenix.isTestWindow) {
7622-
MultiBrowserLiveDev.open();
7622+
MultiBrowserLiveDev.open(doc);
76237623
}
76247624
}
76257625

@@ -37514,7 +37514,7 @@ table tr{background-color:#fff;border-top:1px solid #c6cbd1}table tr:nth-child(2
3751437514
*/
3751537515

3751637516
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */
37517-
/*global path*/
37517+
/*global path, jsPromise*/
3751837518
//jshint-ignore:no-start
3751937519

3752037520
define("extensionsIntegrated/Phoenix-live-preview/main", function (require, exports, module) {
@@ -38031,13 +38031,12 @@ define("extensionsIntegrated/Phoenix-live-preview/main", function (require, expo
3803138031
$highlightBtn.click(_toggleLiveHighlights);
3803238032
$livePreviewPopBtn.click(_popoutLivePreview);
3803338033
$reloadBtn.click(()=>{
38034-
LiveDevelopment.openLivePreview();
38035-
_loadPreview(true);
38034+
_loadPreview(true, true);
3803638035
Metrics.countEvent(Metrics.EVENT_TYPE.LIVE_PREVIEW, "reloadBtn", "click");
3803738036
});
3803838037
}
3803938038

38040-
async function _loadPreview(force) {
38039+
async function _loadPreview(force, isReload) {
3804138040
// we wait till the first server ready event is received till we render anything. else a 404-page may
3804238041
// briefly flash on first load of phoenix as we try to load the page before the server is available.
3804338042
const isPreviewLoadable = panel.isVisible() || StaticServer.hasActiveLivePreviews();
@@ -38061,6 +38060,15 @@ define("extensionsIntegrated/Phoenix-live-preview/main", function (require, expo
3806138060
currentLivePreviewURL = newSrc;
3806238061
currentPreviewFile = previewDetails.fullPath;
3806338062
}
38063+
const existingPreviewFile = $iframe && $iframe.attr('data-original-path');
38064+
const existingPreviewURL = $iframe && $iframe.attr('data-original-src');
38065+
if(isReload && previewDetails.isNoPreview && existingPreviewURL &&
38066+
existingPreviewFile && ProjectManager.isWithinProject(existingPreviewFile)) {
38067+
currentLivePreviewURL = existingPreviewURL;
38068+
currentPreviewFile = existingPreviewFile;
38069+
} else if(isReload){
38070+
LiveDevelopment.openLivePreview();
38071+
}
3806438072
let relativeOrFullPath= ProjectManager.makeProjectRelativeIfPossible(currentPreviewFile);
3806538073
relativeOrFullPath = Phoenix.app.getDisplayPath(relativeOrFullPath);
3806638074
_setTitle(relativeOrFullPath, currentPreviewFile);
@@ -38071,6 +38079,10 @@ define("extensionsIntegrated/Phoenix-live-preview/main", function (require, expo
3807138079
$iframe = newIframe;
3807238080
if(_isProjectPreviewTrusted()){
3807338081
$iframe.attr('src', currentLivePreviewURL);
38082+
// we have to save src as the iframe src attribute may have redirected, and we cannot read it as its
38083+
// a third party domain once its redirected.
38084+
$iframe.attr('data-original-src', currentLivePreviewURL);
38085+
$iframe.attr('data-original-path', currentPreviewFile);
3807438086
} else {
3807538087
$iframe.attr('srcdoc', _getTrustProjectPage());
3807638088
}
@@ -141128,18 +141140,19 @@ define("utils/StringUtils", function (require, exports, module) {
141128141140
*
141129141141
* !!!Should not be used for crypto secure workflows.!!!
141130141142
*
141131-
* @param {number} stringLength - The length of the nonce in bytes.
141143+
* @param {number} stringLength - The length of the nonce in bytes. default 10.
141144+
* @param {string} [prefix] - optional prefix
141132141145
* @returns {string} - The randomly generated nonce.
141133141146
*/
141134-
function randomString(stringLength) {
141147+
function randomString(stringLength=10, prefix="") {
141135141148
const randomBuffer = new Uint8Array(stringLength);
141136141149
crypto.getRandomValues(randomBuffer);
141137141150

141138141151
// Define the character set for the random string
141139141152
const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
141140141153

141141141154
// Convert the ArrayBuffer to a case-sensitive random string with numbers
141142-
let randomId = '';
141155+
let randomId = prefix || '';
141143141156
Array.from(randomBuffer).forEach(byte => {
141144141157
randomId += charset[byte % charset.length];
141145141158
});

0 commit comments

Comments
 (0)