Skip to content

Commit 76fa505

Browse files
committed
deploy: 8a905e4
1 parent e92d75d commit 76fa505

File tree

33 files changed

+138
-94
lines changed

33 files changed

+138
-94
lines changed

LiveDevelopment/BrowserScripts/LivePreviewTransportRemote.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@
8989

9090
(function (global) {
9191

92+
// The below line will be replaced with the transport scripts provided by the static server at
93+
// LivePreviewTransport.js:getRemoteScript() This is so that the actual live preview page doesnt get hold of
94+
// any phoenix web socket or broadcast channel ids from this closure programatically for security.
95+
96+
//Replace dynamic section start
97+
const TRANSPORT_CONFIG={};
98+
//Replace dynamic section end
99+
92100
function _debugLog(...args) {
93101
if(window.LIVE_PREVIEW_DEBUG_ENABLED) {
94102
console.log(...args);
@@ -97,7 +105,7 @@
97105

98106
const clientID = "" + Math.round( Math.random()*1000000000);
99107

100-
const worker = new Worker(window.LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME);
108+
const worker = new Worker(TRANSPORT_CONFIG.LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME);
101109
let _workerMessageProcessor;
102110
worker.onmessage = (event) => {
103111
const type = event.data.type;
@@ -114,9 +122,9 @@
114122
// via LivePreviewTransport.js while serving the instrumented html file
115123
worker.postMessage({
116124
type: "setupPhoenixComm",
117-
livePreviewDebugModeEnabled: window.LIVE_PREVIEW_DEBUG_ENABLED,
118-
broadcastChannel: window.LIVE_PREVIEW_BROADCAST_CHANNEL_ID, // in browser this will be present, but not in tauri
119-
websocketChannelURL: window.LIVE_PREVIEW_WEBSOCKET_CHANNEL_URL, // in tauri this will be present. not in browser
125+
livePreviewDebugModeEnabled: TRANSPORT_CONFIG.LIVE_PREVIEW_DEBUG_ENABLED,
126+
broadcastChannel: TRANSPORT_CONFIG.LIVE_PREVIEW_BROADCAST_CHANNEL_ID, // in browser this will be present, but not in tauri
127+
websocketChannelURL: TRANSPORT_CONFIG.LIVE_PREVIEW_WEBSOCKET_CHANNEL_URL, // in tauri this will be present. not in browser
120128
clientID
121129
});
122130
function _postLivePreviewMessage(message) {

LiveDevelopment/BrowserScripts/pageLoaderWorker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function _sendMessage(message) {
109109
} else if(_livePreviewNavigationChannel){
110110
_livePreviewNavigationChannel.postMessage(message);
111111
} else {
112-
console.warn("No Channels available for live preview worker messaging," +
112+
livePreviewDebugModeEnabled && console.warn("No Channels available for live preview worker messaging," +
113113
" queueing request, waiting for channel..");
114114
messageQueue.push(message);
115115
}

LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ define(function (require, exports, module) {
4848
EditorManager = require("editor/EditorManager"),
4949
LiveDevMultiBrowser = require("LiveDevelopment/LiveDevMultiBrowser"),
5050
HTMLInstrumentation = require("LiveDevelopment/MultiBrowserImpl/language/HTMLInstrumentation"),
51+
StringUtils = require("utils/StringUtils"),
5152
FileViewController = require("project/FileViewController");
5253

53-
const LIVE_DEV_REMOTE_SCRIPTS_FILE_NAME = "phoenix_live_preview_scripts_instrumented_345Tt96G4.js";
54-
const LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME = "pageLoaderWorker_345Tt96G4.js";
54+
const LIVE_DEV_REMOTE_SCRIPTS_FILE_NAME = `phoenix_live_preview_scripts_instrumented_${StringUtils.randomString(8)}.js`;
55+
const LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME = `pageLoaderWorker_${StringUtils.randomString(8)}.js`;
5556

5657
const EVENT_LIVE_PREVIEW_CLICKED = "livePreviewClicked",
5758
EVENT_LIVE_PREVIEW_RELOAD = "livePreviewReload";

LiveDevelopment/MultiBrowserImpl/transports/LivePreviewTransport.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,20 @@ define(function (require, exports, module) {
6666
* @return {string}
6767
*/
6868
function getRemoteScript() {
69-
const transportScript = (_transportBridge && _transportBridge.getRemoteTransportScript &&
69+
const replaceString = "const TRANSPORT_CONFIG={};";
70+
if(!LivePreviewTransportRemote.includes(replaceString)){
71+
throw new Error("Live preview transport is expected to have replaceable template string:" +
72+
" //REPLACE_ME_WITH_LIVE_PREVIEW_TRANSPORT_CONFIG_AND_SCRIPT_DYNAMIC");
73+
}
74+
let transportScript = (_transportBridge && _transportBridge.getRemoteTransportScript &&
7075
_transportBridge.getRemoteTransportScript()) || "";
71-
return "\n" +
72-
`window.PHOENIX_INSTANCE_ID = "${Phoenix.PHOENIX_INSTANCE_ID}";\n` +
73-
`window.LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME = "${LiveDevProtocol.LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME}";\n` +
74-
`window.LIVE_PREVIEW_DEBUG_ENABLED = ${logger.loggingOptions.logLivePreview};\n` +
75-
transportScript + "\n" +
76-
LivePreviewTransportRemote + "\n" ;
76+
transportScript = "const TRANSPORT_CONFIG={};" +
77+
`TRANSPORT_CONFIG.PHOENIX_INSTANCE_ID = "${Phoenix.PHOENIX_INSTANCE_ID}";\n` +
78+
`TRANSPORT_CONFIG.LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME = "${LiveDevProtocol.LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME}";\n` +
79+
`TRANSPORT_CONFIG.LIVE_PREVIEW_DEBUG_ENABLED = ${logger.loggingOptions.logLivePreview};\n`+
80+
transportScript;
81+
return LivePreviewTransportRemote.replace(replaceString, transportScript)
82+
+ "\n";
7783
}
7884

7985
EventDispatcher.makeEventDispatcher(exports);

appConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ window.AppConfig = {
2323
"extension_store_url": "https://store.core.ai/src/",
2424
"app_notification_url": "assets/notifications/dev/",
2525
"linting.enabled_by_default": true,
26-
"build_timestamp": "2024-01-11T12:00:56.604Z",
26+
"build_timestamp": "2024-01-11T14:14:26.824Z",
2727
"googleAnalyticsID": "G-P4HJFPDB76",
2828
"googleAnalyticsIDDesktop": "G-VE5BXWJ0HF",
2929
"mixPanelID": "49c4d164b592be2350fc7af06a259bf3",
@@ -34,7 +34,7 @@ window.AppConfig = {
3434
"bugsnagEnv": "development"
3535
},
3636
"name": "Phoenix",
37-
"version": "3.2.17-19695",
37+
"version": "3.2.17-19698",
3838
"apiVersion": "3.2.17",
3939
"homepage": "https://core.ai",
4040
"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 commit comments

Comments
 (0)