initial support for pwa mode
This commit is contained in:
@ -12,7 +12,8 @@
|
|||||||
"@tauri-apps/cli": "^1.4.0",
|
"@tauri-apps/cli": "^1.4.0",
|
||||||
"@types/audioworklet": "^0.0.49",
|
"@types/audioworklet": "^0.0.49",
|
||||||
"typescript": "^5.2.2",
|
"typescript": "^5.2.2",
|
||||||
"vite": "^4.4.5"
|
"vite": "^4.4.5",
|
||||||
|
"vite-plugin-pwa": "^0.16.7"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/lang-javascript": "^6.1.9",
|
"@codemirror/lang-javascript": "^6.1.9",
|
||||||
|
|||||||
@ -171,6 +171,7 @@ export class UserAPI {
|
|||||||
this.app.interface.error_line.innerHTML = errorMessage;
|
this.app.interface.error_line.innerHTML = errorMessage;
|
||||||
this.app.interface.error_line.style.color = "color-red-800";
|
this.app.interface.error_line.style.color = "color-red-800";
|
||||||
this.app.interface.error_line.classList.remove("hidden");
|
this.app.interface.error_line.classList.remove("hidden");
|
||||||
|
// @ts-ignore
|
||||||
this.errorTimeoutID = setTimeout(
|
this.errorTimeoutID = setTimeout(
|
||||||
() => this.app.interface.error_line.classList.add("hidden"),
|
() => this.app.interface.error_line.classList.add("hidden"),
|
||||||
2000
|
2000
|
||||||
@ -184,6 +185,7 @@ export class UserAPI {
|
|||||||
this.app.interface.error_line.innerHTML = message as string;
|
this.app.interface.error_line.innerHTML = message as string;
|
||||||
this.app.interface.error_line.style.color = "white";
|
this.app.interface.error_line.style.color = "white";
|
||||||
this.app.interface.error_line.classList.remove("hidden");
|
this.app.interface.error_line.classList.remove("hidden");
|
||||||
|
// @ts-ignore
|
||||||
this.printTimeoutID = setTimeout(
|
this.printTimeoutID = setTimeout(
|
||||||
() => this.app.interface.error_line.classList.add("hidden"),
|
() => this.app.interface.error_line.classList.add("hidden"),
|
||||||
4000
|
4000
|
||||||
|
|||||||
@ -81,6 +81,7 @@ export const blinkScript = (
|
|||||||
_drawBlinker(shiftAmount);
|
_drawBlinker(shiftAmount);
|
||||||
|
|
||||||
// Save timeout ID for later clearing
|
// Save timeout ID for later clearing
|
||||||
|
// @ts-ignore
|
||||||
app.blinkTimeouts[shiftAmount] = setTimeout(() => {
|
app.blinkTimeouts[shiftAmount] = setTimeout(() => {
|
||||||
_clearBlinker(shiftAmount);
|
_clearBlinker(shiftAmount);
|
||||||
// Clear the canvas before drawing new blinkers
|
// Clear the canvas before drawing new blinkers
|
||||||
|
|||||||
@ -578,8 +578,7 @@ export class MidiConnection {
|
|||||||
if (typeof output === "number") {
|
if (typeof output === "number") {
|
||||||
if (output < 0 || output >= this.midiOutputs.length) {
|
if (output < 0 || output >= this.midiOutputs.length) {
|
||||||
console.error(
|
console.error(
|
||||||
`Invalid MIDI output index. Index must be in the range 0-${
|
`Invalid MIDI output index. Index must be in the range 0-${this.midiOutputs.length - 1
|
||||||
this.midiOutputs.length - 1
|
|
||||||
}.`
|
}.`
|
||||||
);
|
);
|
||||||
return this.currentOutputIndex;
|
return this.currentOutputIndex;
|
||||||
@ -608,8 +607,7 @@ export class MidiConnection {
|
|||||||
if (typeof input === "number") {
|
if (typeof input === "number") {
|
||||||
if (input < 0 || input >= this.midiInputs.length) {
|
if (input < 0 || input >= this.midiInputs.length) {
|
||||||
console.error(
|
console.error(
|
||||||
`Invalid MIDI input index. Index must be in the range 0-${
|
`Invalid MIDI input index. Index must be in the range 0-${this.midiInputs.length - 1
|
||||||
this.midiInputs.length - 1
|
|
||||||
}.`
|
}.`
|
||||||
);
|
);
|
||||||
return -1;
|
return -1;
|
||||||
@ -676,6 +674,7 @@ export class MidiConnection {
|
|||||||
delete this.scheduledNotes[noteNumber];
|
delete this.scheduledNotes[noteNumber];
|
||||||
}, (duration - 0.02) * 1000);
|
}, (duration - 0.02) * 1000);
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
this.scheduledNotes[noteNumber] = timeoutId;
|
this.scheduledNotes[noteNumber] = timeoutId;
|
||||||
} else {
|
} else {
|
||||||
console.error("MIDI output not available.");
|
console.error("MIDI output not available.");
|
||||||
|
|||||||
@ -213,6 +213,7 @@ export class Speaker {
|
|||||||
synth.cancel();
|
synth.cancel();
|
||||||
// Set timeout
|
// Set timeout
|
||||||
if (speakerTimeout) clearTimeout(speakerTimeout);
|
if (speakerTimeout) clearTimeout(speakerTimeout);
|
||||||
|
// @ts-ignore
|
||||||
speakerTimeout = setTimeout(() => {
|
speakerTimeout = setTimeout(() => {
|
||||||
synth.speak(utterance);
|
synth.speak(utterance);
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|||||||
@ -1,9 +1,14 @@
|
|||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
|
import { VitePWA } from 'vite-plugin-pwa';
|
||||||
|
|
||||||
// import * as mdPlugin from 'vite-plugin-markdown';
|
// import * as mdPlugin from 'vite-plugin-markdown';
|
||||||
|
|
||||||
export default defineConfig(({ command, mode, ssrBuild }) => {
|
export default defineConfig(({ command, mode, ssrBuild }) => {
|
||||||
if (command === "serve") {
|
if (command === "serve") {
|
||||||
return {
|
return {
|
||||||
|
plugins: [
|
||||||
|
VitePWA({ registerType: 'autoUpdate' })
|
||||||
|
],
|
||||||
assetsInclude: ["**/*.md"],
|
assetsInclude: ["**/*.md"],
|
||||||
server: {
|
server: {
|
||||||
port: 8000,
|
port: 8000,
|
||||||
@ -12,6 +17,9 @@ export default defineConfig(({ command, mode, ssrBuild }) => {
|
|||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
|
plugins: [
|
||||||
|
VitePWA({ registerType: 'autoUpdate' })
|
||||||
|
],
|
||||||
chunkSizeWarningLimit: 1600 * 2,
|
chunkSizeWarningLimit: 1600 * 2,
|
||||||
build: {
|
build: {
|
||||||
outDir: "dist",
|
outDir: "dist",
|
||||||
|
|||||||
Reference in New Issue
Block a user