Stuck with Ziffers compiler errors

This commit is contained in:
2024-04-20 12:44:58 +02:00
parent 0d2f7046c9
commit 7f48b94ffa
7 changed files with 68 additions and 60 deletions

View File

@ -395,7 +395,7 @@ export class UserAPI {
this.almostAlways = Probability.almostAlways(this); this.almostAlways = Probability.almostAlways(this);
this.always = Probability.always(); this.always = Probability.always();
this.dice = Probability.dice(this); this.dice = Probability.dice(this);
this.osc = OSC.osc(this.app); this.osc = OSC.osc();
this.getOSC = OSC.getOSC(); this.getOSC = OSC.getOSC();
this.gif = Canvas.gif(this.app); this.gif = Canvas.gif(this.app);
this.scope = Canvas.scope(this.app); this.scope = Canvas.scope(this.app);

View File

@ -26,15 +26,15 @@ export const delete_script = (app: Editor) => (script: number): void => {
}; };
export const copy_script = (app: Editor) => (from: number, to: number): void => { export const copy_script = (app: Editor) => (from: number, to: number): void => {
//@ts-ignore
app.universes[app.selected_universe].locals[to] = { app.universes[app.selected_universe].locals[to] = {
...app.universes[app.selected_universe]!.locals[from], ...app.universes[app.selected_universe]!.locals[from],
}; };
}; };
export const copy_universe = (app: Editor) => (from: string, to: string): void => { export const copy_universe = (app: Editor) => (from: string, to: string): void => {
app.universes[to] = { //@ts-ignore
...app.universes[from], app.universes[to] = { ...app.universes[from], };
};
}; };
export const delete_universe = (app: Editor) => (universe: string): void => { export const delete_universe = (app: Editor) => (universe: string): void => {

View File

@ -65,29 +65,29 @@ export const getCodeMirrorTheme = (theme: { [key: string]: string }): Extension
selection_background = theme["selection_background"]; selection_background = theme["selection_background"];
const toposTheme = EditorView.theme({ const toposTheme = EditorView.theme({
"&": { "&": {
color: background, color: background || "",
backgroundColor: "transparent", backgroundColor: "transparent",
fontSize: "24px", fontSize: "24px",
fontFamily: "IBM Plex Mono", fontFamily: "IBM Plex Mono",
}, },
".cm-content": { ".cm-content": {
caretColor: cursor, caretColor: cursor || '',
fontFamily: "IBM Plex Mono", fontFamily: "IBM Plex Mono",
}, },
".cm-line": { ".cm-line": {
color: `${brightwhite}`, color: `${brightwhite}`,
}, },
".cm-cursor, .cm-dropCursor": { ".cm-cursor, .cm-dropCursor": {
borderLeftColor: cursor, borderLeftColor: cursor || 'white',
}, },
"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": "&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":
{ {
backgroundColor: brightwhite, backgroundColor: brightwhite || 'black',
border: `1px solid ${brightwhite}`, border: `1px solid ${brightwhite}`,
}, },
".cm-panels": { ".cm-panels": {
backgroundColor: selection_background, backgroundColor: selection_background || 'gray',
color: red, color: red || '',
}, },
".cm-panels.cm-panels-top": { borderBottom: "2px solid black" }, ".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" }, ".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
@ -96,30 +96,30 @@ export const getCodeMirrorTheme = (theme: { [key: string]: string }): Extension
outline: `1px solid ${magenta}`, outline: `1px solid ${magenta}`,
}, },
".cm-searchMatch.cm-searchMatch-selected": { ".cm-searchMatch.cm-searchMatch-selected": {
backgroundColor: red, backgroundColor: red || '',
}, },
".cm-activeLine": { ".cm-activeLine": {
backgroundColor: `rgba(${(parseInt(selection_background.slice(1, 3), 16))}, ${(parseInt(selection_background.slice(3, 5), 16))}, ${(parseInt(selection_background.slice(5, 7), 16))}, 0.25)`, backgroundColor: `rgba(${(parseInt(selection_background!.slice(1, 3), 16))}, ${(parseInt(selection_background!.slice(3, 5), 16))}, ${(parseInt(selection_background!.slice(5, 7), 16))}, 0.25)`,
}, },
".cm-selectionMatch": { ".cm-selectionMatch": {
backgroundColor: `rgba(${(parseInt(selection_background.slice(1, 3), 16))}, ${(parseInt(selection_background.slice(3, 5), 16))}, ${(parseInt(selection_background.slice(5, 7), 16))}, 0.25)`, backgroundColor: `rgba(${(parseInt(selection_background!.slice(1, 3), 16))}, ${(parseInt(selection_background!.slice(3, 5), 16))}, ${(parseInt(selection_background!.slice(5, 7), 16))}, 0.25)`,
outline: `1px solid ${brightwhite}`, outline: `1px solid ${brightwhite}`,
}, },
"&.cm-focused .cm-matchingBracket": { "&.cm-focused .cm-matchingBracket": {
color: `rgba(${(parseInt(selection_background.slice(1, 3), 16))}, ${(parseInt(selection_background.slice(3, 5), 16))}, ${(parseInt(selection_background.slice(5, 7), 16))}, 0.25)`, color: `rgba(${(parseInt(selection_background!.slice(1, 3), 16))}, ${(parseInt(selection_background!.slice(3, 5), 16))}, ${(parseInt(selection_background!.slice(5, 7), 16))}, 0.25)`,
}, },
"&.cm-focused .cm-nonmatchingBracket": { "&.cm-focused .cm-nonmatchingBracket": {
color: yellow, color: yellow || '',
}, },
".cm-gutters": { ".cm-gutters": {
//backgroundColor: base00, //backgroundColor: base00,
backgroundColor: "transparent", backgroundColor: "transparent",
color: foreground, color: foreground || '',
}, },
".cm-activeLineGutter": { ".cm-activeLineGutter": {
backgroundColor: selection_background, backgroundColor: selection_background || '',
color: selection_foreground, color: selection_foreground || '',
}, },
".cm-foldPlaceholder": { ".cm-foldPlaceholder": {
@ -128,17 +128,17 @@ export const getCodeMirrorTheme = (theme: { [key: string]: string }): Extension
}, },
".cm-tooltip": { ".cm-tooltip": {
border: "none", border: "none",
backgroundColor: background, backgroundColor: background || '',
}, },
".cm-tooltip .cm-tooltip-arrow:before": {}, ".cm-tooltip .cm-tooltip-arrow:before": {},
".cm-tooltip .cm-tooltip-arrow:after": { ".cm-tooltip .cm-tooltip-arrow:after": {
borderTopColor: background, borderTopColor: background || '',
borderBottomColor: background, borderBottomColor: background || '',
}, },
".cm-tooltip-autocomplete": { ".cm-tooltip-autocomplete": {
"& > ul > li[aria-selected]": { "& > ul > li[aria-selected]": {
backgroundColor: background, backgroundColor: background || '',
color: brightwhite, color: brightwhite || '',
}, },
}, },
}, },
@ -343,7 +343,7 @@ export const installEditor = (app: Editor) => {
), ),
keymap.of([indentWithTab]), keymap.of([indentWithTab]),
], ],
doc: app.universes[app.selected_universe].global.candidate, doc: app.universes[app.selected_universe]!.global.candidate,
}); });
app.view = new EditorView({ app.view = new EditorView({
parent: document.getElementById("editor") as HTMLElement, parent: document.getElementById("editor") as HTMLElement,

View File

@ -1,4 +1,5 @@
import { UserAPI } from "../API/API"; import { UserAPI } from "../API/API";
import { MidiEvent } from "../Classes/MidiEvent";
import { AppSettings } from "../Editor/FileManagement"; import { AppSettings } from "../Editor/FileManagement";
export type MidiNoteEvent = { export type MidiNoteEvent = {
@ -297,36 +298,37 @@ export class MidiConnection {
const input = this.midiInputs[inputIndex]; const input = this.midiInputs[inputIndex];
if (input && !input.onmidimessage) { if (input && !input.onmidimessage) {
input.onmidimessage = (event: Event) => { input.onmidimessage = (event: Event) => {
const message = event as MIDIMessageEvent; // @ts-ignore
const message: MidiEvent = event as MIDIMessageEvent;
/* MIDI CLOCK */ /* MIDI CLOCK */
if (input.name === this.settings.midi_clock_input) { if (input.name === this.settings.midi_clock_input) {
if (message.data![0] === 0xf8) { if (message['data'][0] === 0xf8) {
if (this.skipOnError > 0) { if (this.skipOnError > 0) {
this.skipOnError -= 1; this.skipOnError -= 1;
} else { } else {
this.onMidiClock(event.timeStamp); this.onMidiClock(event.timeStamp);
} }
} else if (message.data![0] === 0xfa) { } else if (message["data"]![0] === 0xfa) {
console.log("MIDI start received"); console.log("MIDI start received");
this.api.stop(); this.api.stop();
this.api.play(); this.api.play();
} else if (message.data![0] === 0xfc) { } else if (message["data"]![0] === 0xfc) {
console.log("MIDI stop received"); console.log("MIDI stop received");
this.api.pause(); this.api.pause();
} else if (message.data![0] === 0xfb) { } else if (message["data"]![0] === 0xfb) {
console.log("MIDI continue received"); console.log("MIDI continue received");
this.api.play(); this.api.play();
} else if (message.data![0] === 0xfe) { } else if (message["data"]![0] === 0xfe) {
console.log("MIDI active sensing received"); console.log("MIDI active sensing received");
} }
} }
/* DEFAULT MIDI INPUT */ /* DEFAULT MIDI INPUT */
if (input.name === this.settings.default_midi_input) { if (input.name === this.settings.default_midi_input) {
// If message is one of note ons // If message is one of note ons
if (message.data![0] >= 0x90 && message.data![0] <= 0x9f) { if (message["data"][0] >= 0x90 && message["data"]![0] <= 0x9f) {
const channel = message.data![0] - 0x90 + 1; const channel = message["data"]![0] - 0x90 + 1;
const note = message.data![1]; const note = message["data"]![1];
const velocity = message.data![2]; const velocity = message["data"]![2];
this.lastNote = { this.lastNote = {
note, note,
@ -367,24 +369,24 @@ export class MidiConnection {
} }
// If note off // If note off
if (message.data![0] >= 0x80 && message.data![0] <= 0x8f) { if (message["data"]![0] >= 0x80 && message["data"]![0] <= 0x8f) {
const channel = message.data![0] - 0x80 + 1; const channel = message["data"]![0] - 0x80 + 1;
const note = message.data![1]; const note = message["data"]![1];
this.removeFromActiveNotes(note, channel); this.removeFromActiveNotes(note, channel);
} }
// If message is one of CCs // If message is one of CCs
if (message.data![0] >= 0xb0 && message.data![0] <= 0xbf) { if (message["data"]![0] >= 0xb0 && message["data"]![0] <= 0xbf) {
const channel = message.data![0] - 0xb0 + 1; const channel = message["data"]![0] - 0xb0 + 1;
const control = message.data![1]; const control = message["data"]![1];
const value = message.data![2]; const value = message["data"]![2];
this.lastCC[control] = value; this.lastCC[control] = value;
if (this.lastCCInChannel[channel]) { if (this.lastCCInChannel[channel]) {
this.lastCCInChannel[channel][control] = value; this.lastCCInChannel[channel]![control] = value;
} else { } else {
this.lastCCInChannel[channel] = {}; this.lastCCInChannel[channel] = {};
this.lastCCInChannel[channel][control] = value; this.lastCCInChannel[channel]![control] = value;
} }
//console.log(`CC: ${control} VALUE: ${value} CHANNEL: ${channel}`); //console.log(`CC: ${control} VALUE: ${value} CHANNEL: ${channel}`);

View File

@ -211,12 +211,12 @@ export class AbstractEvent {
* @param func - The function to be applied to the Event * @param func - The function to be applied to the Event
* @returns The transformed Event * @returns The transformed Event
*/ */
return this.modify(func).update(); return this.modify(func)["update"]();
}; };
mod = (value: number): AbstractEvent => { mod = (value: number): AbstractEvent => {
this.values.originalPitch = safeMod(this.values.originalPitch, value); this.values["originalPitch"] = safeMod(this.values["originalPitch"], value);
return this.update(); return this["update"]();
} }
noteLength = ( noteLength = (
@ -230,17 +230,18 @@ export class AbstractEvent {
value = Array.isArray(value) ? value.concat(kwargs) : [value, ...kwargs]; value = Array.isArray(value) ? value.concat(kwargs) : [value, ...kwargs];
} }
if (Array.isArray(value)) { if (Array.isArray(value)) {
this.values.dur = value.map((v) => this.values["dur"] = value.map((v) =>
this.app.clock.convertPulseToSecond(v * 4 * this.app.clock.ppqn), this.app.clock.convertPulseToSecond(v * 4 * this.app.clock.ppqn),
); );
} else { } else {
this.values.dur = this.app.clock.convertPulseToSecond( this.values["dur"] = this.app.clock.convertPulseToSecond(
value * 4 * this.app.clock.ppqn, value * 4 * this.app.clock.ppqn,
); );
} }
if(this.current) { if(this["current"]) {
value = Array.isArray(value) ? value[this.index%value.length] : value; // @ts-ignore
this.current.duration = value; value = Array.isArray(value) ? value[this["index"]%value.length] : value;
this["current"].duration = value;
} }
return this; return this;
}; };
@ -253,7 +254,9 @@ export class AbstractEvent {
const n: number[] = []; const n: number[] = [];
sound.forEach((str) => { sound.forEach((str) => {
const parts = (str as string).split(":"); const parts = (str as string).split(":");
s.push(parts[0]); if (parts[0] !== undefined) {
s.push(parts[0]);
}
if (parts[1]) { if (parts[1]) {
n.push(parseInt(parts[1])); n.push(parseInt(parts[1]));
} }
@ -273,7 +276,7 @@ export class AbstractEvent {
if (sound.includes(":")) { if (sound.includes(":")) {
const vals = sound.split(":"); const vals = sound.split(":");
const s = vals[0]; const s = vals[0];
const n = parseInt(vals[1]); const n = parseInt(vals[1] ?? '');
return { return {
s, s,
n, n,
@ -472,7 +475,7 @@ export abstract class AudibleEvent extends AbstractEvent {
return this; return this;
} }
public clear = () => { public override clear = () => {
this.app.api.clear(); this.app.api.clear();
return this; return this;
} }
@ -524,8 +527,8 @@ export abstract class AudibleEvent extends AbstractEvent {
runChain = (): this => { runChain = (): this => {
// chainAll is defined using all() in the API // chainAll is defined using all() in the API
if("chainAll" in this && typeof this.chainAll === "function") { if("chainAll" in this && typeof this["chainAll"] === "function") {
this.values = this.chainAll().values; this.values = this["chainAll"]().values;
} }
return this; return this;
} }

View File

@ -1,3 +1,4 @@
// @ts-ignore
import { ClockNode } from "./ClockNode"; import { ClockNode } from "./ClockNode";
import TransportProcessor from "./ClockProcessor?worker&url"; import TransportProcessor from "./ClockProcessor?worker&url";
import { Editor } from "../main"; import { Editor } from "../main";

View File

@ -8,7 +8,6 @@
"DOM.Iterable" "DOM.Iterable"
], ],
"skipLibCheck": true, "skipLibCheck": true,
// Strict mode (9)
"strict": true, "strict": true,
"alwaysStrict": true, "alwaysStrict": true,
"noImplicitAny": true, "noImplicitAny": true,
@ -32,16 +31,19 @@
"allowImportingTsExtensions": true, "allowImportingTsExtensions": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"maxNodeModuleJsDepth": 0,
"noEmit": true, "noEmit": true,
// Others (5) // Others
"noUncheckedIndexedAccess": true, "noUncheckedIndexedAccess": true,
"noPropertyAccessFromIndexSignature": true, "noPropertyAccessFromIndexSignature": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true "forceConsistentCasingInFileNames": true
}, },
"include": [ "include": [
"src", "src/**/*",
"../definitions/" "../definitions/"
],
"exclude": [
"node_modules/**/*",
] ]
} }