mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 23:16:21 +00:00
merge: integrate duckietm/Dev (JSON mode selector, split-gamedata script, installer, IT→ENG)
# Conflicts: # vite.config.mjs
This commit is contained in:
+31
-3
@@ -2,6 +2,22 @@ import { GetConfiguration } from '@nitrots/nitro-renderer';
|
||||
import JSON5 from 'json5';
|
||||
import { configFileUrl, getClientMode, installSecureFetch } from './secure-assets';
|
||||
|
||||
declare const __NITRO_JSON_MODE__: 'legacy' | 'json5' | 'auto' | undefined;
|
||||
|
||||
const resolveJsonMode = (): 'legacy' | 'json5' | 'auto' =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if(typeof __NITRO_JSON_MODE__ !== 'undefined' && __NITRO_JSON_MODE__)
|
||||
{
|
||||
if(__NITRO_JSON_MODE__ === 'legacy' || __NITRO_JSON_MODE__ === 'json5' || __NITRO_JSON_MODE__ === 'auto') return __NITRO_JSON_MODE__;
|
||||
}
|
||||
}
|
||||
catch {}
|
||||
|
||||
return 'auto';
|
||||
};
|
||||
|
||||
const ensureMobileViewport = () =>
|
||||
{
|
||||
let viewport = document.querySelector<HTMLMetaElement>('meta[name="viewport"]');
|
||||
@@ -78,16 +94,28 @@ const loadClientMode = async () =>
|
||||
if(!response.ok) throw new Error(`HTTP ${ response.status }`);
|
||||
|
||||
const text = await response.text();
|
||||
const mode = resolveJsonMode();
|
||||
|
||||
try
|
||||
if(mode === 'legacy')
|
||||
{
|
||||
(window as any).__nitroClientMode = JSON.parse(text);
|
||||
}
|
||||
catch
|
||||
else if(mode === 'json5')
|
||||
{
|
||||
(window as any).__nitroClientMode = JSON5.parse(text);
|
||||
}
|
||||
setBootDebug('boot: client-mode loaded');
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
(window as any).__nitroClientMode = JSON.parse(text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
(window as any).__nitroClientMode = JSON5.parse(text);
|
||||
}
|
||||
}
|
||||
setBootDebug(`boot: client-mode loaded (mode=${ mode })`);
|
||||
}
|
||||
catch(error)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user