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