Skip to content

Commit e5c01e8

Browse files
committed
deploy: 8a905e4
1 parent 44437de commit e5c01e8

Some content is hidden

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

49 files changed

+3790
-1802
lines changed

LiveDevelopment/BrowserScripts/LivePreviewTransportRemote.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
let sentTitle, sentFavIconURL;
5050

5151
function convertImgToBase64(url, callback) {
52+
if(!url){
53+
callback(null);
54+
return;
55+
}
5256
let canvas = document.createElement('CANVAS');
5357
const ctx = canvas.getContext('2d');
5458
const img = new Image();
@@ -70,6 +74,9 @@
7074
if(sentFavIconURL !== faviconUrl){
7175
sentFavIconURL = faviconUrl;
7276
convertImgToBase64(faviconUrl, function(base64) {
77+
if(!base64){
78+
base64 = "favicon.ico";
79+
}
7380
worker.postMessage({
7481
type: "updateTitleIcon",
7582
faviconBase64: base64

LiveDevelopment/LiveDevMultiBrowser.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -728,27 +728,6 @@ define(function (require, exports, module) {
728728
currentPreviewFilePath = currentPinnedFilePath;
729729
}
730730

731-
/**
732-
* Returns current project server config. Copied from original LiveDevelopment.
733-
*/
734-
function getCurrentProjectServerConfig() {
735-
return {
736-
baseUrl: ProjectManager.getBaseUrl(),
737-
pathResolver: ProjectManager.makeProjectRelativeIfPossible,
738-
root: ProjectManager.getProjectRoot().fullPath
739-
};
740-
}
741-
742-
/**
743-
* @private
744-
* Returns the base URL of the current server serving the active live document, or null if
745-
* there is no active live document.
746-
* @return {?string}
747-
*/
748-
function getServerBaseUrl() {
749-
return _server && _server.getBaseUrl();
750-
}
751-
752731
// for unit testing only
753732
function getCurrentLiveDoc() {
754733
return _liveDocument;
@@ -769,10 +748,6 @@ define(function (require, exports, module) {
769748
};
770749
}
771750

772-
function getLivePreviewBaseURL() {
773-
return LiveDevServerManager.getStaticServerBaseURLs().previewBaseURL;
774-
}
775-
776751
EventDispatcher.makeEventDispatcher(exports);
777752

778753
// For unit testing
@@ -797,11 +772,8 @@ define(function (require, exports, module) {
797772
exports.init = init;
798773
exports.isActive = isActive;
799774
exports.setLivePreviewPinned= setLivePreviewPinned;
800-
exports.getServerBaseUrl = getServerBaseUrl;
801775
exports.getCurrentLiveDoc = getCurrentLiveDoc;
802776
exports.getLivePreviewDetails = getLivePreviewDetails;
803-
exports.getLivePreviewBaseURL = getLivePreviewBaseURL;
804-
exports.getCurrentProjectServerConfig = getCurrentProjectServerConfig;
805777
exports.getConnectionIds = getConnectionIds;
806778
exports.setTransport = setTransport;
807779
});

LiveDevelopment/LiveDevServerManager.js

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ define(function (require, exports, module) {
6868

6969
for (i = 0; i < _serverProviders.length; i++) {
7070
provider = _serverProviders[i];
71-
if(!provider.createedInstance ||
72-
(provider.createedInstance.getProjectRoot() !== ProjectManager.getProjectRoot().fullPath)){
73-
provider.createedInstance = provider.create();
71+
if(!provider._createdServer ||
72+
(provider._createdServer.getProjectRoot() !== ProjectManager.getProjectRoot().fullPath)){
73+
provider._createdServer = provider.create();
7474
}
75-
server = provider.createedInstance;
75+
server = provider._createdServer;
7676

7777
if(!highestPriorityServer){
7878
highestPriorityServer = server;
@@ -130,20 +130,6 @@ define(function (require, exports, module) {
130130
}
131131
}
132132

133-
const LIVE_PREVIEW_STATIC_SERVER_BASE_URL = "https://phcode.live/",
134-
LIVE_PREVIEW_STATIC_SERVER_ORIGIN = "https://phcode.live";
135-
// #LIVE_PREVIEW_STATIC_SERVER_BASE_URL_OVERRIDE uncomment below line if you are developing live preview server.
136-
// const LIVE_PREVIEW_STATIC_SERVER_BASE_URL = "http://localhost:8001/";
137-
// const LIVE_PREVIEW_STATIC_SERVER_ORIGIN = "http://localhost:8001";
138-
function getStaticServerBaseURLs() {
139-
return {
140-
baseURL: LIVE_PREVIEW_STATIC_SERVER_BASE_URL,
141-
origin: LIVE_PREVIEW_STATIC_SERVER_ORIGIN,
142-
previewBaseURL:
143-
`${LIVE_PREVIEW_STATIC_SERVER_BASE_URL}vfs/PHOENIX_LIVE_PREVIEW_${Phoenix.PHOENIX_INSTANCE_ID}`
144-
};
145-
}
146-
147133
// Backwards compatibility
148134
exports.getProvider = getServer;
149135
exports.registerProvider = registerServer;
@@ -152,5 +138,4 @@ define(function (require, exports, module) {
152138
exports.getServer = getServer;
153139
exports.registerServer = registerServer;
154140
exports.removeServer = removeServer;
155-
exports.getStaticServerBaseURLs = getStaticServerBaseURLs;
156141
});

LiveDevelopment/LiveDevelopmentUtils.js

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@
2525
define(function (require, exports, module) {
2626

2727

28-
var LanguageManager = require("language/LanguageManager"),
29-
ProjectManager = require("project/ProjectManager");
28+
var LanguageManager = require("language/LanguageManager");
3029

3130
/**
3231
* File extensions - hard-coded for now, but may want to make these preferences
3332
* @const {Array.<string>}
3433
*/
35-
var _staticHtmlFileExts = ["htm", "html", "xhtml"],
36-
_serverHtmlFileExts = ["php", "php3", "php4", "php5", "phtm", "phtml", "cfm", "cfml", "asp", "aspx", "jsp", "jspx", "shtm", "shtml"];
34+
const _staticHtmlFileExts = ["htm", "html", "xhtml"];
3735

3836
/**
3937
* Determine if file extension is a static html file extension.
@@ -48,31 +46,16 @@ define(function (require, exports, module) {
4846
return (_staticHtmlFileExts.indexOf(LanguageManager.getLanguageForPath(filePath).getId()) !== -1);
4947
}
5048

51-
/**
52-
* Determine if file extension is a server html file extension.
53-
* @param {string} filePath could be a path, a file name or just a file extension
54-
* @return {boolean} Returns true if fileExt is in the list
55-
*/
56-
function isServerHtmlFileExt(filePath) {
57-
if (!filePath) {
58-
return false;
59-
}
60-
61-
return (_serverHtmlFileExts.indexOf(LanguageManager.getLanguageForPath(filePath).getId()) !== -1);
62-
}
63-
6449
/**
6550
* Returns true if we think the given extension is for an HTML file.
6651
* @param {string} ext The extension to check.
6752
* @return {boolean} true if this is an HTML extension.
6853
*/
6954
function isHtmlFileExt(ext) {
70-
return (isStaticHtmlFileExt(ext) ||
71-
(ProjectManager.getBaseUrl() && isServerHtmlFileExt(ext)));
55+
return isStaticHtmlFileExt(ext);
7256
}
7357

7458
// Define public API
7559
exports.isHtmlFileExt = isHtmlFileExt;
7660
exports.isStaticHtmlFileExt = isStaticHtmlFileExt;
77-
exports.isServerHtmlFileExt = isServerHtmlFileExt;
7861
});

LiveDevelopment/Servers/BaseServer.js

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,19 @@ define(function (require, exports, module) {
2828
* Base class for live preview servers
2929
*
3030
* Configuration parameters for this server:
31-
* - baseUrl - Optional base URL (populated by the current project)
3231
* - pathResolver - Function to covert absolute native paths to project relative paths
3332
* - root - Native path to the project root (and base URL)
3433
*
3534
* @constructor
36-
* @param {!{baseUrl: string, root: string, pathResolver: function(string): string}} config
35+
* @param {!{root: string, pathResolver: function(string): string}} config
3736
*/
3837
function BaseServer(config) {
39-
this._baseUrl = config.baseUrl;
4038
this._root = config.root; // ProjectManager.getProjectRoot().fullPath
4139
this._pathResolver = config.pathResolver; // ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)
4240
this._liveDocuments = {};
4341
this._virtualServingDocuments = {};
4442
}
4543

46-
/**
47-
* Returns a base url for current project.
48-
*
49-
* @return {string}
50-
* Base url for current project.
51-
*/
52-
BaseServer.prototype.getBaseUrl = function () {
53-
return this._baseUrl;
54-
};
55-
5644
/**
5745
* Get path of the current project this server serves
5846
* @returns {string} Path of the current project this server serves
@@ -95,51 +83,6 @@ define(function (require, exports, module) {
9583
}
9684
};
9785

98-
/**
99-
* Returns a URL for a given path
100-
* @param {string} path Absolute path to covert to a URL
101-
* @return {?string} Converts a path within the project root to a URL.
102-
* Returns null if the path is not a descendant of the project root.
103-
*/
104-
BaseServer.prototype.pathToUrl = function (path) {
105-
var baseUrl = this.getBaseUrl(),
106-
relativePath = this._pathResolver(path);
107-
108-
// See if base url has been specified and path is within project
109-
if (relativePath !== path) {
110-
// Map to server url. Base url is already encoded, so don't encode again.
111-
var encodedDocPath = encodeURI(path);
112-
var encodedProjectPath = encodeURI(this._root);
113-
114-
return encodedDocPath.replace(encodedProjectPath, baseUrl);
115-
}
116-
117-
return null;
118-
};
119-
120-
/**
121-
* Convert a URL to a local full file path
122-
* @param {string} url
123-
* @return {?string} The absolute path for given URL or null if the path is
124-
* not a descendant of the project.
125-
*/
126-
BaseServer.prototype.urlToPath = function (url) {
127-
var path,
128-
baseUrl = "";
129-
130-
baseUrl = this.getBaseUrl();
131-
132-
if (baseUrl !== "" && url.indexOf(baseUrl) === 0) {
133-
// Use base url to translate to local file path.
134-
// Need to use encoded project path because it's decoded below.
135-
path = url.replace(baseUrl, encodeURI(this._root));
136-
137-
return decodeURI(path);
138-
}
139-
140-
return null;
141-
};
142-
14386
/**
14487
* Called by LiveDevelopment before to prepare the server before navigating
14588
* to the project's base URL. The provider returns a jQuery promise.

LiveDevelopment/Servers/FileServer.js

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)