Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move to phcode protocol in tauri instead of tauri protocol #1150

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/assets/new-project/assets/js/new-project-more.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function _getIconURL(iconURL) {
} else if(iconURL === 'appLogo'){
return 'images/logo.png';
} else if(iconURL && (iconURL.startsWith("https://") || iconURL.startsWith("http://")
|| iconURL.startsWith("tauri://") || iconURL.startsWith("asset://"))){
|| iconURL.startsWith("phcode://") || iconURL.startsWith("asset://"))){
return iconURL;
}
return 'images/tab-img2.png'; // HTML icon
Expand Down
2 changes: 1 addition & 1 deletion src/extensibility/Package.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ define(function (require, exports, module) {
return d.promise();
}
if (!(parsed.protocol === "http:" || parsed.protocol === "https:"
|| parsed.protocol === "tauri:" || parsed.protocol === "asset:")) {
|| parsed.protocol === "phcode:" || parsed.protocol === "asset:")) {
d.reject(Errors.UNSUPPORTED_PROTOCOL);
return d.promise();
}
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/HTMLCodeHints/HTMLJumpToDef.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ define(function (require, exports, module) {

function _openFile(fileRelativePath, mainDocPath) {
if(fileRelativePath.startsWith("http://") || fileRelativePath.startsWith("https://")
|| fileRelativePath.startsWith("tauri://") || fileRelativePath.startsWith("asset://")){
|| fileRelativePath.startsWith("phcode://") || fileRelativePath.startsWith("asset://")){
return FileViewController.openAndSelectDocument(fileRelativePath, FileViewController.PROJECT_MANAGER);
}
const targetPath = path.resolve(mainDocPath, fileRelativePath);
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/QuickView/ImagePreviewProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ define(function (require, exports, module) {
extensionlessImagePreview; // Whether to try and preview extensionless URLs

// List of protocols which we will support for image preview urls
let validProtocols = ["data:", "http:", "https:", "tauri:", "asset:", "ftp:", "file:"];
let validProtocols = ["data:", "http:", "https:", "phcode:", "asset:", "ftp:", "file:"];

prefs = PreferencesManager.getExtensionPrefs("quickview");

Expand Down
6 changes: 3 additions & 3 deletions src/extensions/default/RemoteFileAdapter/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ define(function (require, exports, module) {

const HTTP_PROTOCOL = "http:",
HTTPS_PROTOCOL = "https:",
TAURI_PROTOCOL = "tauri:",
TAURI_PROTOCOL = "phcode:",
TAURI_ASSET_PROTOCOL = "asset:";

ExtensionUtils.loadStyleSheet(module, "styles.css");
Expand All @@ -48,8 +48,8 @@ define(function (require, exports, module) {
return "https";
}

if (data.fullPath.startsWith("tauri://")) {
return "tauri";
if (data.fullPath.startsWith("phcode://")) {
return "phcode";
}

if (data.fullPath.startsWith("asset://")) {
Expand Down
2 changes: 1 addition & 1 deletion src/filesystem/FileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ define(function (require, exports, module) {
// attach remote file handlers
var HTTP_PROTOCOL = "http:",
HTTPS_PROTOCOL = "https:",
TAURI_PROTOCOL = "tauri:",
TAURI_PROTOCOL = "phcode:",
TAURI_ASSET_PROTOCOL = "asset:";

var protocolAdapter = {
Expand Down
9 changes: 8 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
<!-- start inline javascript and non module bootstrap scripts. you must add module scripts to the
javascript module section only!!-->
<script>
if(location.href.startsWith("tauri://") || location.href.startsWith('https://tauri.localhost')){
Dismissed Show dismissed Hide dismissed
const errorMessage = `You should use custom protocol phcode:// instead of tauri protocol ${location.href} .`;
alert(errorMessage);
console.error(errorMessage);
throw new Error(errorMessage);
}
function _isTestWindow() {
const isTestPhoenixWindow = !!(new window.URLSearchParams(window.location.search || "")).get("testEnvironment");
const isSpecRunnerWindow = window.location.pathname.endsWith("/SpecRunner.html");
Expand Down Expand Up @@ -262,7 +268,8 @@
'http://127.0.0.1:8000': true, // phcode dev server
'http://127.0.0.1:8001': true, // phcode dev live preview server
'http://127.0.0.1:5000': true, // playwright tests
'tauri://localhost': true, // tauri prod app
'phcode://localhost': true, // tauri prod app
'https://phcode.localhost': true, // tauri
'https://phcode.live': true, // phcode prod live preview server
'https://phcode.dev': true,
'https://dev.phcode.dev': true,
Expand Down
4 changes: 2 additions & 2 deletions src/utils/ExtensionLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ define(function (require, exports, module) {
*/
function _mergeConfig(baseConfig) {
if(baseConfig.baseUrl.startsWith("http://") || baseConfig.baseUrl.startsWith("https://")
|| baseConfig.baseUrl.startsWith("tauri://") || baseConfig.baseUrl.startsWith("asset://")) {
|| baseConfig.baseUrl.startsWith("phcode://") || baseConfig.baseUrl.startsWith("asset://")) {
return _mergeConfigFromURL(baseConfig);
}
throw new Error("Config can only be loaded from an http url, but got" + baseConfig.baseUrl);
Expand Down Expand Up @@ -394,7 +394,7 @@ define(function (require, exports, module) {
var result = new $.Deferred(),
extensionPath = config.baseUrl + "/" + entryPoint + ".js";
if(extensionPath.startsWith("http://") || extensionPath.startsWith("https://")
|| extensionPath.startsWith("tauri://") || extensionPath.startsWith("asset://")) {
|| extensionPath.startsWith("phcode://") || extensionPath.startsWith("asset://")) {
return _testExtensionByURL(name, config, entryPoint);
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/ExtensionUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ define(function (require, exports, module) {
*/
function loadMetadata(metadataURL, extensionName) {
if(metadataURL.startsWith("http://") || metadataURL.startsWith("https://")
|| metadataURL.startsWith("tauri://") || metadataURL.startsWith("asset://")) {
|| metadataURL.startsWith("phcode://") || metadataURL.startsWith("asset://")) {
return _loadExtensionMetadata(metadataURL, extensionName);
}
throw new Error(`Cannot load extension metadata for ${extensionName} at path ${metadataURL}`);
Expand Down
2 changes: 1 addition & 1 deletion src/view/ThemeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ define(function (require, exports, module) {
*/
function loadFile(fileName, options) {
if(fileName.startsWith("http://") || fileName.startsWith("https://")
|| fileName.startsWith("tauri://") || fileName.startsWith("asset://")) {
|| fileName.startsWith("phcode://") || fileName.startsWith("asset://")) {
if(Phoenix.VFS.getPathForVirtualServingURL(fileName)){
fileName = Phoenix.VFS.getPathForVirtualServingURL(fileName);
} else {
Expand Down
10 changes: 8 additions & 2 deletions test/SpecRunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
frame-src * localhost:* asset: https://asset.localhost ;
connect-src * localhost:* asset: https://asset.localhost ;">
<script type="text/javascript">
//brackets.app.showDeveloperTools();
if(location.href.startsWith("tauri://") || location.href.startsWith('https://tauri.localhost')){
Dismissed Show dismissed Hide dismissed
const errorMessage = `You should use custom protocol phcode:// instead of tauri protocol ${location.href} .`;
alert(errorMessage);
console.error(errorMessage);
throw new Error(errorMessage);
}
console.warn('Make sure to run this following command before starting tests : npm run build ');
if(window.__TAURI__) {
window.testRunnerLogToConsole = function (...args) {
Expand Down Expand Up @@ -240,7 +245,8 @@
'http://127.0.0.1:8000': true, // phcode dev server
'http://127.0.0.1:8001': true, // phcode dev live preview server
'http://127.0.0.1:5000': true, // playwright tests
'tauri://localhost': true, // tauri prod app
'phcode://localhost': true, // tauri prod app
'https://phcode.localhost': true, // tauri
'https://phcode.live': true, // phcode prod live preview server
'https://phcode.dev': true,
'https://dev.phcode.dev': true,
Expand Down
Loading