From 9158fa60c51ef9d7d696229d8b3f5cf0118f424d Mon Sep 17 00:00:00 2001 From: dlrm Date: Wed, 8 Jun 2022 15:02:38 +0200 Subject: [PATCH] fix(tracker): fix tracker date recording, added new obscure dates opt fix(tracker): rm consolelog fix(tracker): change compile import fix(tracker): fix node v and import --- tracker/tracker/package.json | 2 +- tracker/tracker/scripts/compile.js | 2 +- tracker/tracker/src/main/modules/input.ts | 33 ++++++++++++----------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/tracker/tracker/package.json b/tracker/tracker/package.json index fec46d597..d9e218a59 100644 --- a/tracker/tracker/package.json +++ b/tracker/tracker/package.json @@ -41,6 +41,6 @@ "error-stack-parser": "^2.0.6" }, "engines": { - "node": ">=12" + "node": ">=17.5" } } diff --git a/tracker/tracker/scripts/compile.js b/tracker/tracker/scripts/compile.js index 563254016..172ed9060 100644 --- a/tracker/tracker/scripts/compile.js +++ b/tracker/tracker/scripts/compile.js @@ -26,7 +26,7 @@ async function main() { from: /\.\.\/\.\.\/common/g, to: '../common', }); - + await fs.rename('build/cjs/main', 'cjs'); await fs.rename('build/cjs/common', 'cjs/common'); diff --git a/tracker/tracker/src/main/modules/input.ts b/tracker/tracker/src/main/modules/input.ts index 2fb79d2f9..55edb8d59 100644 --- a/tracker/tracker/src/main/modules/input.ts +++ b/tracker/tracker/src/main/modules/input.ts @@ -8,24 +8,20 @@ import { import { hasTag } from "../app/guards.js"; import { SetInputTarget, SetInputValue, SetInputChecked } from "../../common/messages.js"; +const INPUT_TYPES = ['text', 'password', 'email', 'search', 'number', 'range', 'date'] + // TODO: take into consideration "contenteditable" attribute type TextEditableElement = HTMLInputElement | HTMLTextAreaElement function isTextEditable(node: any): node is TextEditableElement { - if (hasTag(node, "TEXTAREA")) { + if (hasTag(node, "TEXTAREA")) { return true; } if (!hasTag(node, "INPUT")) { return false; } const type = node.type; - return ( - type === 'text' || - type === 'password' || - type === 'email' || - type === 'search' || - type === 'number' || - type === 'range' - ); + + return INPUT_TYPES.includes(type) } function isCheckable(node: any): node is HTMLInputElement { @@ -72,11 +68,11 @@ export function getInputLabel(node: TextEditableElement): string { let label = getLabelAttribute(node); if (label === null) { const labelElement = labelElementFor(node); - label = (labelElement && labelElement.innerText) - || node.placeholder - || node.name - || node.id - || node.className + label = (labelElement && labelElement.innerText) + || node.placeholder + || node.name + || node.id + || node.className || node.type } return normSpaces(label).slice(0, 100); @@ -92,6 +88,7 @@ export interface Options { obscureInputNumbers: boolean; obscureInputEmails: boolean; defaultInputMode: InputMode; + obscureDateInputs: boolean; } export default function (app: App, opts: Partial): void { @@ -100,6 +97,7 @@ export default function (app: App, opts: Partial): void { obscureInputNumbers: true, obscureInputEmails: true, defaultInputMode: InputMode.Plain, + obscureDateInputs: false, }, opts, ); @@ -112,7 +110,11 @@ export default function (app: App, opts: Partial): void { function sendInputValue(id: number, node: TextEditableElement | HTMLSelectElement): void { let value = node.value; let inputMode: InputMode = options.defaultInputMode; - if (node.type === 'password' || hasOpenreplayAttribute(node, 'hidden')) { + if (node.type === 'date') { + if (options.obscureDateInputs) { + inputMode = InputMode.Obscured + } + } else if (node.type === 'password' || hasOpenreplayAttribute(node, 'hidden')) { inputMode = InputMode.Hidden; } else if ( hasOpenreplayAttribute(node, 'obscured') || @@ -134,6 +136,7 @@ export default function (app: App, opts: Partial): void { value = ''; break; } + app.send(new SetInputValue(id, value, mask)); }