Skip to content

Commit 70ab201

Browse files
committed
deploy: 8a905e4
1 parent fd06f01 commit 70ab201

1,075 files changed

Lines changed: 358017 additions & 35387 deletions

File tree

Some content is hidden

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

‎LiveDevelopment/BrowserScripts/LivePreviewTransportRemote.js‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,45 @@
4646
type: "setupBroadcast",
4747
broadcastChannel: window.LIVE_PREVIEW_BROADCAST_CHANNEL_ID,
4848
clientID});
49+
let sentTitle, sentFavIconURL;
50+
51+
function convertImgToBase64(url, callback) {
52+
let canvas = document.createElement('CANVAS');
53+
const ctx = canvas.getContext('2d');
54+
const img = new Image();
55+
img.crossOrigin = 'Anonymous';
56+
img.onload = function() {
57+
canvas.height = img.height;
58+
canvas.width = img.width;
59+
ctx.drawImage(img, 0, 0);
60+
const dataURL = canvas.toDataURL();
61+
callback(dataURL);
62+
canvas = null;
63+
};
64+
img.src = url;
65+
}
66+
67+
setInterval(()=>{
68+
const favIcon = document.querySelector("link[rel~='icon']");
69+
const faviconUrl = favIcon && favIcon.href;
70+
if(sentFavIconURL !== faviconUrl){
71+
sentFavIconURL = faviconUrl;
72+
convertImgToBase64(faviconUrl, function(base64) {
73+
worker.postMessage({
74+
type: "updateTitleIcon",
75+
faviconBase64: base64
76+
});
77+
});
78+
}
79+
80+
if(sentTitle!== document.title) {
81+
sentTitle = document.title;
82+
worker.postMessage({
83+
type: "updateTitleIcon",
84+
title: document.title
85+
});
86+
}
87+
}, 1000);
4988

5089
const WebSocketTransport = {
5190
_channelOpen: false,

‎LiveDevelopment/BrowserScripts/pageLoaderWorker.js‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
*/
2626

2727

28+
let _livePreviewNavigationChannel;
29+
2830
function _setupBroadcastChannel(broadcastChannel, clientID) {
2931
if(!broadcastChannel){
3032
return;
3133
}
32-
const _livePreviewNavigationChannel=new BroadcastChannel(broadcastChannel);
34+
_livePreviewNavigationChannel=new BroadcastChannel(broadcastChannel);
3335
_livePreviewNavigationChannel.onmessage = (event) => {
3436
const type = event.data.type;
3537
switch (type) {
@@ -47,13 +49,23 @@ function _setupBroadcastChannel(broadcastChannel, clientID) {
4749
_sendOnlineHeartbeat();
4850
setInterval(()=>{
4951
_sendOnlineHeartbeat();
50-
}, 1000);
52+
}, 3000);
53+
}
54+
55+
function updateTitleAndFavicon(event) {
56+
_livePreviewNavigationChannel.postMessage({
57+
type: 'UPDATE_TITLE_AND_ICON',
58+
title: event.data.title,
59+
faviconBase64: event.data.faviconBase64,
60+
URL: location.href
61+
});
5162
}
5263

5364
onmessage = (event) => {
5465
const type = event.data.type;
5566
switch (type) {
5667
case 'setupBroadcast': _setupBroadcastChannel(event.data.broadcastChannel, event.data.clientID); break;
68+
case 'updateTitleIcon': updateTitleAndFavicon(event); break;
5769
default: console.error("Live Preview page worker: received unknown event:", event);
5870
}
5971
};

‎LiveDevelopment/LiveDevMultiBrowser.js‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ define(function (require, exports, module) {
6969
// events
7070
const EVENT_OPEN_PREVIEW_URL = "openPreviewURL",
7171
EVENT_CONNECTION_CLOSE = "ConnectionClose",
72-
EVENT_STATUS_CHANGE = "statusChange",
73-
EVENT_LIVE_PREVIEW_CLICKED= "livePreviewClicked";
72+
EVENT_STATUS_CHANGE = "statusChange";
7473

7574
const Dialogs = require("widgets/Dialogs"),
7675
DefaultDialogs = require("widgets/DefaultDialogs"),
@@ -576,7 +575,10 @@ define(function (require, exports, module) {
576575
_handleRelatedDocumentDeleted(msg.href);
577576
})
578577
.on(LiveDevProtocol.EVENT_LIVE_PREVIEW_CLICKED + ".livedev", function (event, msg) {
579-
exports.trigger(EVENT_LIVE_PREVIEW_CLICKED, msg);
578+
exports.trigger(LiveDevProtocol.EVENT_LIVE_PREVIEW_CLICKED, msg);
579+
})
580+
.on(LiveDevProtocol.EVENT_LIVE_PREVIEW_RELOAD + ".livedev", function (event, clients) {
581+
exports.trigger(LiveDevProtocol.EVENT_LIVE_PREVIEW_RELOAD, clients);
580582
});
581583
} else {
582584
console.error("LiveDevelopment._open(): No server active");
@@ -604,10 +606,12 @@ define(function (require, exports, module) {
604606
_createLiveDocumentForFrame(initialDoc);
605607

606608
// start listening for requests
607-
_server.start();
609+
_server.start()
610+
.then(()=>{
611+
// open browser to the url
612+
_open(initialDoc);
613+
});
608614

609-
// open browser to the url
610-
_open(initialDoc);
611615
}
612616

613617
/**
@@ -920,7 +924,8 @@ define(function (require, exports, module) {
920924
exports.EVENT_OPEN_PREVIEW_URL = EVENT_OPEN_PREVIEW_URL;
921925
exports.EVENT_CONNECTION_CLOSE = EVENT_CONNECTION_CLOSE;
922926
exports.EVENT_STATUS_CHANGE = EVENT_STATUS_CHANGE;
923-
exports.EVENT_LIVE_PREVIEW_CLICKED = EVENT_LIVE_PREVIEW_CLICKED;
927+
exports.EVENT_LIVE_PREVIEW_CLICKED = LiveDevProtocol.EVENT_LIVE_PREVIEW_CLICKED;
928+
exports.EVENT_LIVE_PREVIEW_RELOAD = LiveDevProtocol.EVENT_LIVE_PREVIEW_RELOAD;
924929

925930
// Export public functions
926931
exports.open = open;

‎LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ define(function (require, exports, module) {
5353
const LIVE_DEV_REMOTE_SCRIPTS_FILE_NAME = "phoenix_live_preview_scripts_instrumented_345Tt96G4.js";
5454
const LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME = "pageLoaderWorker_345Tt96G4.js";
5555

56-
const EVENT_LIVE_PREVIEW_CLICKED = "livePreviewClicked";
56+
const EVENT_LIVE_PREVIEW_CLICKED = "livePreviewClicked",
57+
EVENT_LIVE_PREVIEW_RELOAD = "livePreviewReload";
5758

5859
/**
5960
* @private
@@ -344,6 +345,7 @@ define(function (require, exports, module) {
344345
* to the method.
345346
*/
346347
function reload(ignoreCache, clients) {
348+
exports.trigger(EVENT_LIVE_PREVIEW_RELOAD, clients);
347349
return _send(
348350
{
349351
method: "Page.reload",
@@ -406,4 +408,5 @@ define(function (require, exports, module) {
406408
exports.LIVE_DEV_REMOTE_SCRIPTS_FILE_NAME = LIVE_DEV_REMOTE_SCRIPTS_FILE_NAME;
407409
exports.LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME = LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME;
408410
exports.EVENT_LIVE_PREVIEW_CLICKED = EVENT_LIVE_PREVIEW_CLICKED;
411+
exports.EVENT_LIVE_PREVIEW_RELOAD = EVENT_LIVE_PREVIEW_RELOAD;
409412
});

‎LiveDevelopment/main.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ define(function main(require, exports, module) {
292292
MultiBrowserLiveDev.on(MultiBrowserLiveDev.EVENT_LIVE_PREVIEW_CLICKED, function (_event, clickDetails) {
293293
exports.trigger(exports.EVENT_LIVE_PREVIEW_CLICKED, clickDetails);
294294
});
295+
MultiBrowserLiveDev.on(MultiBrowserLiveDev.EVENT_LIVE_PREVIEW_RELOAD, function (_event, clientDetails) {
296+
exports.trigger(exports.EVENT_LIVE_PREVIEW_RELOAD, clientDetails);
297+
});
295298

296299
});
297300

@@ -316,6 +319,7 @@ define(function main(require, exports, module) {
316319
exports.EVENT_OPEN_PREVIEW_URL = MultiBrowserLiveDev.EVENT_OPEN_PREVIEW_URL;
317320
exports.EVENT_CONNECTION_CLOSE = MultiBrowserLiveDev.EVENT_CONNECTION_CLOSE;
318321
exports.EVENT_LIVE_PREVIEW_CLICKED = MultiBrowserLiveDev.EVENT_LIVE_PREVIEW_CLICKED;
322+
exports.EVENT_LIVE_PREVIEW_RELOAD = MultiBrowserLiveDev.EVENT_LIVE_PREVIEW_RELOAD;
319323
exports.EVENT_LIVE_HIGHLIGHT_PREF_CHANGED = EVENT_LIVE_HIGHLIGHT_PREF_CHANGED;
320324

321325
// Export public functions

0 commit comments

Comments
 (0)