Fixed default UI load
This commit is contained in:
parent
c158f2930f
commit
750dbf5d66
|
@ -15,8 +15,7 @@ import {localUiCache, saveLocalUiCache} from "./Cache";
|
||||||
import {shippedClientUi} from "./Shipped";
|
import {shippedClientUi} from "./Shipped";
|
||||||
import {downloadUiPack, queryRemoteUiPacks} from "./Remote";
|
import {downloadUiPack, queryRemoteUiPacks} from "./Remote";
|
||||||
import * as url from "url";
|
import * as url from "url";
|
||||||
import {protocol, session} from "electron";
|
import {protocol} from "electron";
|
||||||
import {kWindowPartitionMainApp} from "../windows/main-window/controller/MainWindow";
|
|
||||||
|
|
||||||
const kUiPackProtocol = "shared-ui";
|
const kUiPackProtocol = "shared-ui";
|
||||||
|
|
||||||
|
@ -127,31 +126,10 @@ async function unpackLocalUiPack(version: CachedUIPack) : Promise<string> {
|
||||||
return targetDirectory;
|
return targetDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function streamFilesFromDevServer(_channel: string, _callbackStatus: (message: string, index: number) => any) : Promise<string> {
|
|
||||||
return remoteUiUrl() + "index.html";
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadBundledUiPack(channel: string, callbackStatus: (message: string, index: number) => any) : Promise<string> {
|
|
||||||
callbackStatus("Query local UI pack info", .33);
|
|
||||||
|
|
||||||
const bundledUi = await shippedClientUi();
|
|
||||||
if(!bundledUi) {
|
|
||||||
throw "client has no bundled UI pack";
|
|
||||||
}
|
|
||||||
|
|
||||||
callbackStatus("Unpacking bundled UI", .66);
|
|
||||||
const result = await unpackLocalUiPack(bundledUi);
|
|
||||||
|
|
||||||
callbackStatus("Local UI pack loaded", 1);
|
|
||||||
console.log("Loaded bundles UI pack successfully. Version: {timestamp: %d, hash: %s}", bundledUi.packInfo.timestamp, bundledUi.packInfo.versions_hash);
|
|
||||||
return url.pathToFileURL(path.join(result, "index.html")).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
function initializeFileSystemProtocol(directory: string) {
|
function initializeFileSystemProtocol(directory: string) {
|
||||||
directory = path.normalize(directory);
|
directory = path.normalize(directory);
|
||||||
|
|
||||||
const sessionProtocol = session.fromPartition(kWindowPartitionMainApp).protocol;
|
protocol.registerFileProtocol(kUiPackProtocol, (request, callback) => {
|
||||||
sessionProtocol.registerFileProtocol(kUiPackProtocol, (request, callback) => {
|
|
||||||
let targetPath;
|
let targetPath;
|
||||||
const pathStartIndex = request.url.indexOf('/', kUiPackProtocol.length + 3);
|
const pathStartIndex = request.url.indexOf('/', kUiPackProtocol.length + 3);
|
||||||
if(pathStartIndex === -1) {
|
if(pathStartIndex === -1) {
|
||||||
|
@ -173,6 +151,27 @@ function initializeFileSystemProtocol(directory: string) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function streamFilesFromDevServer(_channel: string, _callbackStatus: (message: string, index: number) => any) : Promise<string> {
|
||||||
|
return remoteUiUrl() + "index.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadBundledUiPack(channel: string, callbackStatus: (message: string, index: number) => any) : Promise<string> {
|
||||||
|
callbackStatus("Query local UI pack info", .33);
|
||||||
|
|
||||||
|
const bundledUi = await shippedClientUi();
|
||||||
|
if(!bundledUi) {
|
||||||
|
throw "client has no bundled UI pack";
|
||||||
|
}
|
||||||
|
|
||||||
|
callbackStatus("Unpacking bundled UI", .66);
|
||||||
|
const result = await unpackLocalUiPack(bundledUi);
|
||||||
|
|
||||||
|
callbackStatus("Local UI pack loaded", 1);
|
||||||
|
console.log("Loaded bundles UI pack successfully. Version: {timestamp: %d, hash: %s}", bundledUi.packInfo.timestamp, bundledUi.packInfo.versions_hash);
|
||||||
|
initializeFileSystemProtocol(result);
|
||||||
|
return kUiPackProtocol + "://shared-ui/index.html";
|
||||||
|
}
|
||||||
|
|
||||||
async function loadCachedOrRemoteUiPack(channel: string, callbackStatus: (message: string, index: number) => any, ignoreNewVersionTimestamp: boolean) : Promise<string> {
|
async function loadCachedOrRemoteUiPack(channel: string, callbackStatus: (message: string, index: number) => any, ignoreNewVersionTimestamp: boolean) : Promise<string> {
|
||||||
callbackStatus("Fetching info", 0);
|
callbackStatus("Fetching info", 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue