SHA256
Настроить локальный запуск UI с devnet сервером
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
client.version=1.17.0
|
client.version=1.18.0
|
||||||
server.version=1.14.0
|
server.version=1.14.0
|
||||||
|
|||||||
+10
-3
@@ -39,7 +39,7 @@
|
|||||||
}());
|
}());
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
window.__SHINE_BUILD_HASH__ = '20261007235900';
|
window.__SHINE_BUILD_HASH__ = '20261010170500';
|
||||||
window.__SHINE_CLIENT_VERSION__ = '1.2.10';
|
window.__SHINE_CLIENT_VERSION__ = '1.2.10';
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
@@ -445,11 +445,18 @@ window.__SHINE_BUILD_HASH__ = '20261007235900';
|
|||||||
}());
|
}());
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
(function attachAppWithBuildHash() {
|
(async function attachAppWithBuildHash() {
|
||||||
|
const isLocalPreview = ['localhost', '127.0.0.1', '::1'].includes(String(window.location.hostname || '').toLowerCase());
|
||||||
|
if (isLocalPreview && 'serviceWorker' in navigator) {
|
||||||
|
try {
|
||||||
|
const registrations = await navigator.serviceWorker.getRegistrations();
|
||||||
|
await Promise.all(registrations.map((registration) => registration.unregister()));
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
const v = encodeURIComponent(window.__SHINE_BUILD_HASH__ || 'dev');
|
const v = encodeURIComponent(window.__SHINE_BUILD_HASH__ || 'dev');
|
||||||
const script = document.createElement('script');
|
const script = document.createElement('script');
|
||||||
script.type = 'module';
|
script.type = 'module';
|
||||||
script.src = `./js/app.js?v=${v}`;
|
script.src = isLocalPreview ? `./js/app.js?v=${v}&local=${Date.now()}` : `./js/app.js?v=${v}`;
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
}());
|
}());
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ import {
|
|||||||
markOutgoingDeliveryState,
|
markOutgoingDeliveryState,
|
||||||
markOutgoingReadByBaseKey,
|
markOutgoingReadByBaseKey,
|
||||||
normalizeDmChatId,
|
normalizeDmChatId,
|
||||||
|
applyUrlServerLoginOverrideIfNeeded,
|
||||||
|
hasUrlEntrySettingsOverride,
|
||||||
setContacts,
|
setContacts,
|
||||||
} from './state.js';
|
} from './state.js';
|
||||||
|
|
||||||
@@ -226,6 +228,11 @@ const SCROLL_TO_BOTTOM_PAGE_IDS = new Set([
|
|||||||
'channel-thread-view',
|
'channel-thread-view',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
function isLocalPreviewHost() {
|
||||||
|
const host = String(window.location.hostname || '').toLowerCase();
|
||||||
|
return host === 'localhost' || host === '127.0.0.1' || host === '::1';
|
||||||
|
}
|
||||||
|
|
||||||
const FILLED_ACTION_BUTTON_PAGE_IDS = new Set([
|
const FILLED_ACTION_BUTTON_PAGE_IDS = new Set([
|
||||||
...PRE_AUTH_PAGES.filter((pageId) => pageId !== 'entry-settings-view'),
|
...PRE_AUTH_PAGES.filter((pageId) => pageId !== 'entry-settings-view'),
|
||||||
'settings-view',
|
'settings-view',
|
||||||
@@ -1528,10 +1535,12 @@ async function ensureSessionRuntimeStarted() {
|
|||||||
if (!state.session.isAuthorized || sessionRuntimeStarted) return;
|
if (!state.session.isAuthorized || sessionRuntimeStarted) return;
|
||||||
sessionRuntimeStarted = true;
|
sessionRuntimeStarted = true;
|
||||||
|
|
||||||
|
if (!isLocalPreviewHost()) {
|
||||||
await initPwaPush({
|
await initPwaPush({
|
||||||
authService,
|
authService,
|
||||||
onLog: (entry) => addAppLogEntry(entry),
|
onLog: (entry) => addAppLogEntry(entry),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
startConnectionMonitor();
|
startConnectionMonitor();
|
||||||
|
|
||||||
@@ -1956,6 +1965,19 @@ async function init() {
|
|||||||
|
|
||||||
void (async () => {
|
void (async () => {
|
||||||
try {
|
try {
|
||||||
|
let urlEntrySettingsReady = true;
|
||||||
|
try {
|
||||||
|
await applyUrlServerLoginOverrideIfNeeded();
|
||||||
|
} catch (error) {
|
||||||
|
urlEntrySettingsReady = false;
|
||||||
|
addAppLogEntry({
|
||||||
|
level: 'warn',
|
||||||
|
source: 'entry-settings',
|
||||||
|
message: 'Не удалось применить сервер из URL',
|
||||||
|
details: { error: error?.message || 'unknown' },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (hasUrlEntrySettingsOverride() && !urlEntrySettingsReady) return;
|
||||||
await tryAutoLogin();
|
await tryAutoLogin();
|
||||||
if (initialNotificationOpenPayload) {
|
if (initialNotificationOpenPayload) {
|
||||||
await handleNotificationClick(initialNotificationOpenPayload);
|
await handleNotificationClick(initialNotificationOpenPayload);
|
||||||
|
|||||||
+83
-5
@@ -74,6 +74,57 @@ function readLocalWsOverrideUrl() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildHttpUrlFromWsUrl(value) {
|
||||||
|
const raw = String(value || '').trim();
|
||||||
|
if (!raw) return '';
|
||||||
|
try {
|
||||||
|
const parsed = new URL(raw);
|
||||||
|
parsed.protocol = parsed.protocol === 'wss:' ? 'https:' : 'http:';
|
||||||
|
parsed.pathname = '';
|
||||||
|
parsed.search = '';
|
||||||
|
parsed.hash = '';
|
||||||
|
return parsed.toString().replace(/\/$/u, '');
|
||||||
|
} catch {
|
||||||
|
return raw.replace(/^wss:/i, 'https:').replace(/^ws:/i, 'http:').replace(/\/ws\/?$/iu, '').replace(/\/$/u, '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function readUrlShineServerHttpOverride() {
|
||||||
|
try {
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const explicitHttp = String(params.get('serverHttp') || params.get('httpUrl') || params.get('shineServerHttp') || '').trim();
|
||||||
|
if (explicitHttp) return explicitHttp.replace(/\/$/u, '');
|
||||||
|
return buildHttpUrlFromWsUrl(readLocalWsOverrideUrl());
|
||||||
|
} catch {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function readUrlServerLoginOverride() {
|
||||||
|
try {
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const raw = params.get('serverLogin') || params.get('shineServerLogin') || '';
|
||||||
|
return String(raw || '').trim().toLowerCase();
|
||||||
|
} catch {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function readUrlSolanaServerOverride() {
|
||||||
|
try {
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const explicitEndpoint = String(params.get('solanaEndpoint') || params.get('solanaRpc') || '').trim();
|
||||||
|
if (explicitEndpoint) return explicitEndpoint;
|
||||||
|
|
||||||
|
const cluster = String(params.get('solana') || params.get('solanaCluster') || params.get('cluster') || '').trim().toLowerCase();
|
||||||
|
if (cluster === 'devnet') return 'https://devnet.helius-rpc.com/?api-key=0614c894-52d8-4ddc-bbbc-0947ce5ec3a4';
|
||||||
|
if (cluster === 'mainnet' || cluster === 'mainnet-beta') return DEFAULT_SOLANA_SERVER;
|
||||||
|
return '';
|
||||||
|
} catch {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function inferTunnelWsUrl() {
|
function inferTunnelWsUrl() {
|
||||||
try {
|
try {
|
||||||
const host = String(window.location.host || '').toLowerCase();
|
const host = String(window.location.host || '').toLowerCase();
|
||||||
@@ -91,7 +142,10 @@ function inferTunnelWsUrl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const LOCAL_WS_OVERRIDE_URL = readLocalWsOverrideUrl() || inferTunnelWsUrl();
|
const LOCAL_WS_OVERRIDE_URL = readLocalWsOverrideUrl() || inferTunnelWsUrl();
|
||||||
|
const URL_SHINE_SERVER_HTTP_OVERRIDE = readUrlShineServerHttpOverride();
|
||||||
|
const URL_SHINE_SERVER_LOGIN_OVERRIDE = readUrlServerLoginOverride();
|
||||||
const DEFAULT_SOLANA_SERVER = SOLANA_ENDPOINT_DEFAULT;
|
const DEFAULT_SOLANA_SERVER = SOLANA_ENDPOINT_DEFAULT;
|
||||||
|
const URL_SOLANA_SERVER_OVERRIDE = readUrlSolanaServerOverride();
|
||||||
const DEFAULT_SHINE_SERVER = DEFAULT_SHINE_SERVER_WS;
|
const DEFAULT_SHINE_SERVER = DEFAULT_SHINE_SERVER_WS;
|
||||||
const DEFAULT_SHINE_SERVER_LOGIN_VALUE = DEFAULT_SHINE_SERVER_LOGIN;
|
const DEFAULT_SHINE_SERVER_LOGIN_VALUE = DEFAULT_SHINE_SERVER_LOGIN;
|
||||||
const DEFAULT_SHINE_SERVER_HTTP_VALUE = DEFAULT_SHINE_SERVER_HTTP;
|
const DEFAULT_SHINE_SERVER_HTTP_VALUE = DEFAULT_SHINE_SERVER_HTTP;
|
||||||
@@ -370,7 +424,15 @@ function createInitialState({ withStoredSession = true } = {}) {
|
|||||||
const storedLocalDemo = Boolean(storedSession?.isLocalDemo && isLocalPreviewHost());
|
const storedLocalDemo = Boolean(storedSession?.isLocalDemo && isLocalPreviewHost());
|
||||||
const storedReactions = loadStoredReactions();
|
const storedReactions = loadStoredReactions();
|
||||||
const storedEntrySettings = loadStoredEntrySettings();
|
const storedEntrySettings = loadStoredEntrySettings();
|
||||||
const initialShineServer = LOCAL_WS_OVERRIDE_URL || DEFAULT_SHINE_SERVER;
|
const initialSolanaServer = URL_SOLANA_SERVER_OVERRIDE
|
||||||
|
|| storedEntrySettings?.solanaServer
|
||||||
|
|| DEFAULT_SOLANA_SERVER;
|
||||||
|
const initialShineServer = URL_SHINE_SERVER_LOGIN_OVERRIDE || URL_SOLANA_SERVER_OVERRIDE
|
||||||
|
? LOCAL_WS_OVERRIDE_URL
|
||||||
|
: (LOCAL_WS_OVERRIDE_URL || DEFAULT_SHINE_SERVER);
|
||||||
|
const initialShineServerLogin = URL_SHINE_SERVER_LOGIN_OVERRIDE
|
||||||
|
|| storedEntrySettings?.shineServerLogin
|
||||||
|
|| DEFAULT_SHINE_SERVER_LOGIN_VALUE;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
chats: {},
|
chats: {},
|
||||||
@@ -395,10 +457,10 @@ function createInitialState({ withStoredSession = true } = {}) {
|
|||||||
startHint: '',
|
startHint: '',
|
||||||
entrySettings: {
|
entrySettings: {
|
||||||
language: String(storedEntrySettings?.language || 'ru'),
|
language: String(storedEntrySettings?.language || 'ru'),
|
||||||
solanaServer: normalizeStoredSolanaServer(storedEntrySettings?.solanaServer),
|
solanaServer: normalizeStoredSolanaServer(initialSolanaServer),
|
||||||
shineServer: String(LOCAL_WS_OVERRIDE_URL || storedEntrySettings?.shineServer || initialShineServer),
|
shineServer: String(LOCAL_WS_OVERRIDE_URL || storedEntrySettings?.shineServer || initialShineServer),
|
||||||
shineServerLogin: String(storedEntrySettings?.shineServerLogin || DEFAULT_SHINE_SERVER_LOGIN_VALUE),
|
shineServerLogin: String(initialShineServerLogin),
|
||||||
shineServerHttp: String(storedEntrySettings?.shineServerHttp || DEFAULT_SHINE_SERVER_HTTP_VALUE),
|
shineServerHttp: String(URL_SHINE_SERVER_HTTP_OVERRIDE || storedEntrySettings?.shineServerHttp || DEFAULT_SHINE_SERVER_HTTP_VALUE),
|
||||||
arweaveServer: String(storedEntrySettings?.arweaveServer || DEFAULT_ARWEAVE_SERVER),
|
arweaveServer: String(storedEntrySettings?.arweaveServer || DEFAULT_ARWEAVE_SERVER),
|
||||||
callPreflightTimeoutMs: Math.max(1000, Math.min(20000, Number(storedEntrySettings?.callPreflightTimeoutMs || DEFAULT_CALL_PREFLIGHT_TIMEOUT_MS) || DEFAULT_CALL_PREFLIGHT_TIMEOUT_MS)),
|
callPreflightTimeoutMs: Math.max(1000, Math.min(20000, Number(storedEntrySettings?.callPreflightTimeoutMs || DEFAULT_CALL_PREFLIGHT_TIMEOUT_MS) || DEFAULT_CALL_PREFLIGHT_TIMEOUT_MS)),
|
||||||
remoteAddBlockSessionId: String(storedEntrySettings?.remoteAddBlockSessionId || ''),
|
remoteAddBlockSessionId: String(storedEntrySettings?.remoteAddBlockSessionId || ''),
|
||||||
@@ -986,7 +1048,7 @@ export async function saveEntrySettings(nextSettings) {
|
|||||||
const nextShineServerLogin = String(nextSettings?.shineServerLogin || state.entrySettings.shineServerLogin || DEFAULT_SHINE_SERVER_LOGIN_VALUE).trim().toLowerCase()
|
const nextShineServerLogin = String(nextSettings?.shineServerLogin || state.entrySettings.shineServerLogin || DEFAULT_SHINE_SERVER_LOGIN_VALUE).trim().toLowerCase()
|
||||||
|| DEFAULT_SHINE_SERVER_LOGIN_VALUE;
|
|| DEFAULT_SHINE_SERVER_LOGIN_VALUE;
|
||||||
let forcedShineServer = LOCAL_WS_OVERRIDE_URL || '';
|
let forcedShineServer = LOCAL_WS_OVERRIDE_URL || '';
|
||||||
let resolvedShineServerHttp = String(state.entrySettings.shineServerHttp || DEFAULT_SHINE_SERVER_HTTP_VALUE).trim() || DEFAULT_SHINE_SERVER_HTTP_VALUE;
|
let resolvedShineServerHttp = String(URL_SHINE_SERVER_HTTP_OVERRIDE || state.entrySettings.shineServerHttp || DEFAULT_SHINE_SERVER_HTTP_VALUE).trim() || DEFAULT_SHINE_SERVER_HTTP_VALUE;
|
||||||
|
|
||||||
if (!forcedShineServer) {
|
if (!forcedShineServer) {
|
||||||
const resolved = await resolveShineServerByServerLogin({
|
const resolved = await resolveShineServerByServerLogin({
|
||||||
@@ -1016,6 +1078,22 @@ export async function saveEntrySettings(nextSettings) {
|
|||||||
state.startHint = `Настройки входа сохранены. SHiNE: ${state.entrySettings.shineServerHttp}`;
|
state.startHint = `Настройки входа сохранены. SHiNE: ${state.entrySettings.shineServerHttp}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function applyUrlServerLoginOverrideIfNeeded() {
|
||||||
|
if (!URL_SHINE_SERVER_LOGIN_OVERRIDE && !URL_SOLANA_SERVER_OVERRIDE && !LOCAL_WS_OVERRIDE_URL && !URL_SHINE_SERVER_HTTP_OVERRIDE) return false;
|
||||||
|
await saveEntrySettings({
|
||||||
|
...state.entrySettings,
|
||||||
|
solanaServer: URL_SOLANA_SERVER_OVERRIDE || state.entrySettings.solanaServer,
|
||||||
|
shineServer: LOCAL_WS_OVERRIDE_URL || state.entrySettings.shineServer,
|
||||||
|
shineServerLogin: URL_SHINE_SERVER_LOGIN_OVERRIDE || state.entrySettings.shineServerLogin,
|
||||||
|
shineServerHttp: URL_SHINE_SERVER_HTTP_OVERRIDE || state.entrySettings.shineServerHttp,
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function hasUrlEntrySettingsOverride() {
|
||||||
|
return Boolean(URL_SHINE_SERVER_LOGIN_OVERRIDE || URL_SOLANA_SERVER_OVERRIDE || LOCAL_WS_OVERRIDE_URL || URL_SHINE_SERVER_HTTP_OVERRIDE);
|
||||||
|
}
|
||||||
|
|
||||||
export function clearStartHint() {
|
export function clearStartHint() {
|
||||||
state.startHint = '';
|
state.startHint = '';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user