fix most typos, add crate-ci/typos to CI (#2653)
* fix most typos, add crate-ci/typos to CI --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
841b447d2a
commit
9167cd9dec
83 files changed
+258
-203
No files matched your search
@@ -5,7 +5,7 @@ type FormValues = {
|
||||
values: { [key: string]: FormDataEntryValue[] };
|
||||
}
|
||||
|
||||
export function retriveValues(event: Event, target: HTMLElement): FormValues {
|
||||
export function retrieveValues(event: Event, target: HTMLElement): FormValues {
|
||||
let contents: FormValues = {
|
||||
values: {}
|
||||
};
|
||||
@@ -47,7 +47,7 @@ export function retrieveFormValues(form: HTMLFormElement): FormValues {
|
||||
};
|
||||
}
|
||||
|
||||
export function retriveSelectValue(target: HTMLSelectElement): string[] {
|
||||
export function retrieveSelectValue(target: HTMLSelectElement): string[] {
|
||||
// there might be multiple...
|
||||
let options = target.selectedOptions;
|
||||
let values = [];
|
||||
|
||||
@@ -7,7 +7,7 @@ import { BaseInterpreter, NodeId } from "./core";
|
||||
import { SerializedEvent, serializeEvent } from "./serialize";
|
||||
|
||||
// okay so, we've got this JSChannel thing from sledgehammer, implicitly imported into our scope
|
||||
// we want to extend it, and it technically extends base intepreter. To make typescript happy,
|
||||
// we want to extend it, and it technically extends base interpreter. To make typescript happy,
|
||||
// we're going to bind the JSChannel_ object to the JSChannel object, and then extend it
|
||||
var JSChannel_: typeof BaseInterpreter;
|
||||
|
||||
@@ -209,7 +209,7 @@ export class NativeInterpreter extends JSChannel_ {
|
||||
// Liveview will still need to use this
|
||||
this.preventDefaults(event, target);
|
||||
|
||||
// liveview does not have syncronous event handling, so we need to send the event to the host
|
||||
// liveview does not have synchronous event handling, so we need to send the event to the host
|
||||
if (this.liveview) {
|
||||
// Okay, so the user might've requested some files to be read
|
||||
if (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Handle serialization of the event data across the IPC boundarytype SerialziedEvent = {};
|
||||
// Handle serialization of the event data across the IPC boundarytype SerializedEvent = {};
|
||||
|
||||
import { retriveSelectValue, retriveValues } from "./form";
|
||||
import { retrieveSelectValue, retrieveValues } from "./form";
|
||||
|
||||
export type AppTouchEvent = TouchEvent;
|
||||
|
||||
@@ -10,29 +10,66 @@ export type SerializedEvent = {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
export function serializeEvent(event: Event, target: EventTarget): SerializedEvent {
|
||||
export function serializeEvent(
|
||||
event: Event,
|
||||
target: EventTarget
|
||||
): SerializedEvent {
|
||||
let contents = {};
|
||||
|
||||
// merge the object into the contents
|
||||
let extend = (obj: any) => (contents = { ...contents, ...obj });
|
||||
|
||||
if (event instanceof WheelEvent) { extend(serializeWheelEvent(event)) };
|
||||
if (event instanceof MouseEvent) { extend(serializeMouseEvent(event)) }
|
||||
if (event instanceof KeyboardEvent) { extend(serializeKeyboardEvent(event)) }
|
||||
if (event instanceof WheelEvent) {
|
||||
extend(serializeWheelEvent(event));
|
||||
}
|
||||
if (event instanceof MouseEvent) {
|
||||
extend(serializeMouseEvent(event));
|
||||
}
|
||||
if (event instanceof KeyboardEvent) {
|
||||
extend(serializeKeyboardEvent(event));
|
||||
}
|
||||
|
||||
if (event instanceof InputEvent) { extend(serializeInputEvent(event, target)) }
|
||||
if (event instanceof PointerEvent) { extend(serializePointerEvent(event)) }
|
||||
if (event instanceof AnimationEvent) { extend(serializeAnimationEvent(event)) }
|
||||
if (event instanceof TransitionEvent) { extend({ property_name: event.propertyName, elapsed_time: event.elapsedTime, pseudo_element: event.pseudoElement, }) }
|
||||
if (event instanceof CompositionEvent) { extend({ data: event.data, }) }
|
||||
if (event instanceof DragEvent) { extend(serializeDragEvent(event)) }
|
||||
if (event instanceof FocusEvent) { extend({}) }
|
||||
if (event instanceof ClipboardEvent) { extend({}) }
|
||||
if (event instanceof InputEvent) {
|
||||
extend(serializeInputEvent(event, target));
|
||||
}
|
||||
if (event instanceof PointerEvent) {
|
||||
extend(serializePointerEvent(event));
|
||||
}
|
||||
if (event instanceof AnimationEvent) {
|
||||
extend(serializeAnimationEvent(event));
|
||||
}
|
||||
if (event instanceof TransitionEvent) {
|
||||
extend({
|
||||
property_name: event.propertyName,
|
||||
elapsed_time: event.elapsedTime,
|
||||
pseudo_element: event.pseudoElement,
|
||||
});
|
||||
}
|
||||
if (event instanceof CompositionEvent) {
|
||||
extend({ data: event.data });
|
||||
}
|
||||
if (event instanceof DragEvent) {
|
||||
extend(serializeDragEvent(event));
|
||||
}
|
||||
if (event instanceof FocusEvent) {
|
||||
extend({});
|
||||
}
|
||||
if (event instanceof ClipboardEvent) {
|
||||
extend({});
|
||||
}
|
||||
|
||||
// safari is quirky and doesn't have TouchEvent
|
||||
if (typeof TouchEvent !== 'undefined' && event instanceof TouchEvent) { extend(serializeTouchEvent(event)); }
|
||||
if (typeof TouchEvent !== "undefined" && event instanceof TouchEvent) {
|
||||
extend(serializeTouchEvent(event));
|
||||
}
|
||||
|
||||
if (event.type === "submit" || event.type === "reset" || event.type === "click" || event.type === "change" || event.type === "input") {
|
||||
if (
|
||||
event.type === "submit" ||
|
||||
event.type === "reset" ||
|
||||
event.type === "click" ||
|
||||
event.type === "change" ||
|
||||
event.type === "input"
|
||||
) {
|
||||
extend(serializeInputEvent(event as InputEvent, target));
|
||||
}
|
||||
|
||||
@@ -59,12 +96,15 @@ export function serializeEvent(event: Event, target: EventTarget): SerializedEve
|
||||
return contents;
|
||||
}
|
||||
|
||||
function serializeInputEvent(event: InputEvent, target: EventTarget): SerializedEvent {
|
||||
function serializeInputEvent(
|
||||
event: InputEvent,
|
||||
target: EventTarget
|
||||
): SerializedEvent {
|
||||
let contents: SerializedEvent = {};
|
||||
|
||||
// Attempt to retrieve the values from the form
|
||||
if (target instanceof HTMLElement) {
|
||||
let values = retriveValues(event, target);
|
||||
let values = retrieveValues(event, target);
|
||||
contents.values = values.values;
|
||||
contents.valid = values.valid;
|
||||
}
|
||||
@@ -87,7 +127,7 @@ function serializeInputEvent(event: InputEvent, target: EventTarget): Serialized
|
||||
}
|
||||
|
||||
if (event.target instanceof HTMLSelectElement) {
|
||||
contents.value = retriveSelectValue(event.target).join(",");
|
||||
contents.value = retrieveSelectValue(event.target).join(",");
|
||||
}
|
||||
|
||||
// Ensure the serializer isn't quirky
|
||||
@@ -95,12 +135,9 @@ function serializeInputEvent(event: InputEvent, target: EventTarget): Serialized
|
||||
contents.value = "";
|
||||
}
|
||||
|
||||
|
||||
return contents;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function serializeWheelEvent(event: WheelEvent): SerializedEvent {
|
||||
return {
|
||||
delta_x: event.deltaX,
|
||||
|
||||
Reference in new issue
Block a user