add install/uninstall options in the setup menu
This commit is contained in:
parent
ed11fbd82a
commit
783f39bb4e
8 changed files with 41 additions and 10 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"compress": false,
|
||||
"outputs": {
|
||||
"bundle": "./web/boot/bundle.bin"
|
||||
"bundle": "./web/boot/bundle-{version}.bin"
|
||||
},
|
||||
"inputs": [
|
||||
{ "root": "web", "prefix": "" },
|
||||
|
|
@ -12,6 +12,6 @@
|
|||
],
|
||||
"excludes": [
|
||||
"src/pack",
|
||||
"web/boot/bundle.bin"
|
||||
"web/boot/bundle*"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ import path from 'path';
|
|||
import uglify from 'uglify-js';
|
||||
import { Buffer } from 'buffer';
|
||||
|
||||
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
|
||||
const cfg = JSON.parse(fs.readFileSync(process.argv[2] || './bin/bundle.config.json', 'utf8'));
|
||||
const { inputs, outputs, excludes, compress } = cfg;
|
||||
const excludePre = (excludes ?? []).filter(s => s.indexOf('*') >= 0).map(s => s.replaceAll('*',''));
|
||||
const envcomp = process.env.COMPRESS ? JSON.parse(process.env.COMPRESS) : undefined;
|
||||
const debug = process.env.DEBUG;
|
||||
|
||||
|
|
@ -65,7 +67,7 @@ if (compEnable) {
|
|||
|
||||
function fileTime(path) {
|
||||
try {
|
||||
return (fs.statSync(path).ctimeMs/1000) | 0;
|
||||
return (fs.statSync(path).ctimeMs / 1000) | 0;
|
||||
} catch (e) {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -75,6 +77,9 @@ for (const { file, virt } of entries) {
|
|||
if (excludes.indexOf(file) >= 0) {
|
||||
continue;
|
||||
}
|
||||
if (excludePre.filter(ex => file.startsWith(ex)).length) {
|
||||
continue;
|
||||
}
|
||||
let record = cache.get(file);
|
||||
if (record) {
|
||||
if (debug) console.log({ alias: virt, from: file });
|
||||
|
|
@ -86,7 +91,7 @@ for (const { file, virt } of entries) {
|
|||
let cpath = path.resolve(cacheDir, file);
|
||||
if (fileTime(cpath) > fileTime(file)) {
|
||||
data = fs.readFileSync(cpath);
|
||||
console.log('cached', file);
|
||||
// console.log('cached', file);
|
||||
} else {
|
||||
console.log('compress', file);
|
||||
data = uglify.minify(data.toString(), {
|
||||
|
|
@ -141,7 +146,7 @@ const header = Buffer.concat([count, ...headerParts]);
|
|||
const full = Buffer.concat([header, ...dataParts]);
|
||||
|
||||
// --- write final bundle ---
|
||||
const outPath = outputs.bundle || './bundle.bin';
|
||||
const outPath = (outputs.bundle || './bundle.bin').replace('{version}', version);
|
||||
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
||||
fs.writeFileSync(outPath, full); // ⚡ write raw binary
|
||||
|
||||
|
|
|
|||
|
|
@ -93,13 +93,15 @@
|
|||
"build-win-arm": "npm run build -- --win --arm64",
|
||||
"build-mac": "npm run build -- --mac --arm64",
|
||||
"build-mac-intel": "npm run build -- --mac --x64",
|
||||
"bundle": "npm run dev -- --alt --dryrun && COMPRESS=1 node bin/bundler.mjs",
|
||||
"bundle:dev": "npm run dev -- --alt --dryrun && node bin/bundler.mjs",
|
||||
"clean": "rm -rf build data dist src/pack tmp src.old web.old .bcache",
|
||||
"docs-dev": "docusaurus start --config conf/docusaurus.config.js",
|
||||
"docs-build": "docusaurus build --config conf/docusaurus.config.js",
|
||||
"docs-serve": "docusaurus serve --config conf/docusaurus.config.js",
|
||||
"docs-check": "prettier --config ./conf/prettier.config.js ./docs --check",
|
||||
"dev": "npm run webpack-ext && gs-app-server --debug --single",
|
||||
"prod": "npm run webpack-ext && npm run webpack-src prod && COMPRESS=1 node bin/bundler.mjs && gs-app-server",
|
||||
"prod": "npm run webpack-ext && npm run webpack-src prod && npm run bundle && gs-app-server",
|
||||
"prod-pack": "npm run webpack-ext && npm run webpack-src prod",
|
||||
"prod-dryrun": "gs-app-server --dryrun",
|
||||
"start": "npm run prebuild prod && electron .",
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ function safeExec(fn) {
|
|||
|
||||
function checkReady() {
|
||||
if (document.readyState === 'complete') {
|
||||
console.log(`kiri | boot ctrl | ` + (navigator.serviceWorker.controller ? true : false));
|
||||
let bootctrl = navigator.serviceWorker.controller;
|
||||
console.log(`kiri | boot ctrl | ` + (bootctrl ? true : false));
|
||||
kiri.api = run();
|
||||
self.$ = kiri.api.web.$;
|
||||
for (let fn of load) {
|
||||
|
|
@ -45,6 +46,18 @@ function checkReady() {
|
|||
}
|
||||
load = undefined;
|
||||
kiri.api.event.emit('load-done', stats);
|
||||
if (bootctrl) {
|
||||
$('install').classList.add('hide');
|
||||
$('uninstall').classList.remove('hide');
|
||||
$('uninstall').onclick = () => {
|
||||
bootctrl.postMessage({ clear: true, disable: true });
|
||||
location.reload();
|
||||
}
|
||||
} else {
|
||||
$('install').onclick = () => {
|
||||
location.replace('/boot');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
// --- configurable ---
|
||||
const CACHE_VERSION = 'boot-001';
|
||||
const BUNDLE_URL = '/boot/bundle.bin';
|
||||
const VERSION_KEY = '/__version__';
|
||||
|
||||
let loaded = 0;
|
||||
let mode = 'cached';
|
||||
let currentVersion = null;
|
||||
let BUNDLE_URL = '/boot/bundle.bin';
|
||||
|
||||
// --- logging ---
|
||||
const log = (...a) => console.log('[SW]', ...a);
|
||||
|
|
@ -30,6 +29,7 @@ self.addEventListener('message', e => {
|
|||
unregister();
|
||||
} else if (version !== undefined) {
|
||||
mode = 'cached';
|
||||
BUNDLE_URL = `/boot/bundle-${version}.bin`;
|
||||
log('version', version);
|
||||
ensureVersion(version);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -229,6 +229,15 @@
|
|||
<label lk="prefs">prefs</label>
|
||||
<span><i class="fa-solid fa-square-check"></i></span>
|
||||
</div>
|
||||
<hr>
|
||||
<div id="install">
|
||||
<label lk="install">install</label>
|
||||
<span><i class="fa-solid fa-plus"></i></span>
|
||||
</div>
|
||||
<div id="uninstall" class="hide">
|
||||
<label lk="uninstall">uninstall</label>
|
||||
<span><i class="fa-solid fa-trash"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ self.lang['en-us'] = {
|
|||
hide: "hide", // left render pop menu (invisible)
|
||||
home: "home",
|
||||
import: "import",
|
||||
install: "install",
|
||||
language: "language",
|
||||
left: "left",
|
||||
machines: "machines", // device or machine
|
||||
|
|
@ -58,6 +59,7 @@ self.lang['en-us'] = {
|
|||
tools: "tools", // CAM tool menu button
|
||||
top: "top",
|
||||
type: "type", // CAM tool type
|
||||
uninstall: "uninstall",
|
||||
version: "version",
|
||||
view: "view", // left view pop menu
|
||||
wire: "wire", // left render pop menu
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "Kiri:Moto 4.4.0",
|
||||
"short_name": "Kiri:Moto",
|
||||
"description": "Slicer for 3D printers, CNC mills, laser cutters and more",
|
||||
"start_url": "/kiri/",
|
||||
"start_url": "/boot/",
|
||||
"id": "/kiri/",
|
||||
"display": "standalone",
|
||||
"theme_color": "#7e99b7",
|
||||
|
|
|
|||
Loading…
Reference in a new issue