update electron to v43
All checks were successful
Android Build / publish (push) Successful in 55s
Linux Build / publish (push) Successful in 1m6s

This commit is contained in:
olcxja 2026-07-09 22:38:33 +02:00
commit fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions

View file

@ -0,0 +1,40 @@
import { toUint8Array } from "../bytes/index.js";
import { encode as encodeBinary, decode as decodeBinary } from "./binary.js";
const BASE64_REGEX = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
function nodeBuffer() {
return globalThis.Buffer;
}
export function normalize(text) {
return text.replace(/[\n\r\t ]/g, "");
}
export function pad(text) {
const remainder = text.length % 4;
return remainder ? text + "=".repeat(4 - remainder) : text;
}
export function is(text) {
if (typeof text !== "string") {
return false;
}
const normalized = normalize(text);
return normalized === "" || BASE64_REGEX.test(normalized);
}
export function encode(data, _options) {
const bytes = toUint8Array(data);
const buffer = nodeBuffer();
if (buffer) {
return buffer.from(bytes).toString("base64");
}
return btoa(encodeBinary(bytes));
}
export function decode(text, _options) {
const normalized = normalize(text);
if (!is(normalized)) {
throw new TypeError("Input is not valid Base64 text");
}
const buffer = nodeBuffer();
if (buffer) {
return new Uint8Array(buffer.from(normalized, "base64"));
}
return decodeBinary(atob(normalized));
}
export const base64 = { encode, decode, is, normalize, pad };

View file

@ -0,0 +1,19 @@
import { base64 } from "./base64.js";
const BASE64URL_REGEX = /^[A-Za-z0-9_-]*$/;
export function normalize(text) {
return text.replace(/[\n\r\t ]/g, "");
}
export function is(text) {
return typeof text === "string" && BASE64URL_REGEX.test(normalize(text));
}
export function encode(data, _options) {
return base64.encode(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
}
export function decode(text, _options) {
const normalized = normalize(text);
if (!is(normalized)) {
throw new TypeError("Input is not valid Base64Url text");
}
return base64.decode(base64.pad(normalized.replace(/-/g, "+").replace(/_/g, "/")));
}
export const base64url = { encode, decode, is, normalize };

View file

@ -0,0 +1,20 @@
import { toUint8Array } from "../bytes/index.js";
export function encode(data) {
const bytes = toUint8Array(data);
let result = "";
for (const byte of bytes) {
result += String.fromCharCode(byte);
}
return result;
}
export function decode(text) {
const result = new Uint8Array(text.length);
for (let i = 0; i < text.length; i++) {
result[i] = text.charCodeAt(i) & 0xff;
}
return result;
}
export function is(text) {
return typeof text === "string";
}
export const binary = { encode, decode, is };

View file

@ -0,0 +1,220 @@
import { toUint8Array } from "../bytes/index.js";
const HEX_CHARACTER_REGEX = /^[0-9a-f]$/i;
const COMMON_SEPARATORS = [" ", "\t", "\n", "\r", ":", "-", "."];
function resolveSeparators(options) {
if (options.separators === "none") {
return [];
}
if (!options.separators || options.separators === "common") {
return COMMON_SEPARATORS;
}
return options.separators;
}
function validateSeparator(separator) {
if (!separator) {
throw new TypeError("Hex separators must be non-empty strings");
}
}
function matchSeparator(text, index, separators) {
for (const separator of separators) {
if (text.startsWith(separator, index)) {
return separator;
}
}
return undefined;
}
function detectCase(text) {
const hasUpper = /[A-F]/.test(text);
const hasLower = /[a-f]/.test(text);
return hasUpper && !hasLower ? "upper" : "lower";
}
function detectLineSeparator(text) {
const match = /\r\n|\n/.exec(text);
if (!match) {
return undefined;
}
return match[0] === "\r\n" ? "\r\n" : "\n";
}
function compactForDetection(text) {
return text.replace(/[^0-9a-f]/gi, "");
}
function detectGroup(text) {
const segments = text.match(/[0-9A-Fa-f]+|[^0-9A-Fa-f]+/g) ?? [];
if (segments.length < 3) {
return undefined;
}
const hexSegments = segments.filter((_, index) => index % 2 === 0);
const separators = segments.filter((_, index) => index % 2 === 1);
const separator = separators[0];
if (!separator || separators.some((item) => item !== separator)) {
return undefined;
}
if (hexSegments.some((segment) => segment.length === 0 || segment.length % 2 !== 0)) {
return undefined;
}
const firstLength = hexSegments[0]?.length ?? 0;
if (!firstLength) {
return undefined;
}
if (hexSegments.slice(0, -1).some((segment) => segment.length !== firstLength)) {
return undefined;
}
if ((hexSegments[hexSegments.length - 1]?.length ?? 0) > firstLength) {
return undefined;
}
return {
size: firstLength / 2,
separator,
};
}
function detectFormat(text) {
const trimmed = text.trim();
const prefix = /^0x/i.test(trimmed) ? "0x" : "";
const body = prefix ? trimmed.slice(2) : trimmed;
const lineSeparator = detectLineSeparator(body);
const lines = body.split(/\r\n|\n/).filter((line) => line.length > 0);
const sampleLine = lines[0]?.trim() ?? "";
const group = detectGroup(sampleLine);
const format = {
case: detectCase(trimmed),
prefix,
};
if (group) {
format.group = group;
}
if (lineSeparator && lines.length > 1) {
const firstLineBytes = compactForDetection(lines[0] ?? "").length / 2;
if (firstLineBytes > 0 && lines.slice(0, -1).every((line) => compactForDetection(line).length / 2 === firstLineBytes)) {
format.line = {
bytesPerLine: firstLineBytes,
separator: lineSeparator,
};
}
}
return format;
}
function normalizeText(text, options) {
const allowPrefix = options.allowPrefix ?? true;
const separators = [...resolveSeparators(options)].sort((left, right) => right.length - left.length);
for (const separator of separators) {
validateSeparator(separator);
}
let working = text.trim();
if (/^0x/i.test(working)) {
if (!allowPrefix) {
throw new TypeError("Hexadecimal text must not include a 0x prefix");
}
working = working.slice(2);
}
let normalized = "";
let lastTokenWasSeparator = false;
for (let index = 0; index < working.length;) {
const character = working[index] ?? "";
if (HEX_CHARACTER_REGEX.test(character)) {
normalized += character;
lastTokenWasSeparator = false;
index += 1;
continue;
}
const separator = matchSeparator(working, index, separators);
if (!separator) {
throw new TypeError("Input is not valid hexadecimal text");
}
if (options.strict && (lastTokenWasSeparator || normalized.length === 0)) {
throw new TypeError("Hexadecimal text contains misplaced separators");
}
lastTokenWasSeparator = true;
index += separator.length;
}
if (options.strict && lastTokenWasSeparator && normalized.length > 0) {
throw new TypeError("Hexadecimal text must not end with a separator");
}
if (normalized.length % 2 !== 0) {
if (!options.allowOddLength) {
throw new TypeError("Hexadecimal text must contain an even number of characters");
}
normalized = `0${normalized}`;
}
return normalized.toLowerCase();
}
function groupPairs(pairs, group) {
if (!group) {
return pairs.join("");
}
if (!Number.isInteger(group.size) || group.size < 1) {
throw new RangeError("Hex group size must be a positive integer");
}
const chunks = [];
for (let index = 0; index < pairs.length; index += group.size) {
chunks.push(pairs.slice(index, index + group.size).join(""));
}
return chunks.join(group.separator);
}
export function normalize(text, options = {}) {
return normalizeText(text, options);
}
export function is(text, options = {}) {
if (typeof text !== "string") {
return false;
}
try {
normalize(text, options);
return true;
}
catch {
return false;
}
}
export function encode(data, options = {}) {
const bytes = toUint8Array(data);
const casing = options.case ?? "lower";
const pairs = Array.from(bytes, (byte) => {
const text = byte.toString(16).padStart(2, "0");
return casing === "upper" ? text.toUpperCase() : text;
});
let body = "";
if (options.line) {
const bytesPerLine = options.line.bytesPerLine;
if (!Number.isInteger(bytesPerLine) || bytesPerLine < 1) {
throw new RangeError("Hex bytesPerLine must be a positive integer");
}
const separator = options.line.separator ?? "\n";
const lines = [];
for (let index = 0; index < pairs.length; index += bytesPerLine) {
lines.push(groupPairs(pairs.slice(index, index + bytesPerLine), options.group));
}
body = lines.join(separator);
}
else {
body = groupPairs(pairs, options.group);
}
return `${options.prefix ?? ""}${body}`;
}
export function decode(text, options = {}) {
const normalized = normalize(text, options);
const result = new Uint8Array(normalized.length / 2);
for (let i = 0; i < normalized.length; i += 2) {
result[i / 2] = Number.parseInt(normalized.slice(i, i + 2), 16);
}
return result;
}
export function parse(text, options = {}) {
const normalized = normalize(text, options);
return {
bytes: decode(normalized),
format: detectFormat(text),
normalized,
};
}
export function format(data, value) {
return encode(data, value);
}
export const formats = {
compact: Object.freeze({}),
upper: Object.freeze({ case: "upper" }),
colon: Object.freeze({ group: { size: 1, separator: ":" } }),
colonUpper: Object.freeze({ case: "upper", group: { size: 1, separator: ":" } }),
groupsOf4: Object.freeze({ group: { size: 4, separator: " " } }),
prefixed: Object.freeze({ prefix: "0x" }),
};
export const hex = { encode, decode, format, formats, is, normalize, parse };

View file

@ -0,0 +1,6 @@
export * as binary from "./binary.js";
export * as hex from "./hex.js";
export * as utf8 from "./utf8.js";
export * as utf16 from "./utf16.js";
export * as base64 from "./base64.js";
export * as base64url from "./base64url.js";

View file

@ -0,0 +1,19 @@
import { toArrayBuffer } from "../bytes/index.js";
export function encode(text, options = {}) {
const result = new ArrayBuffer(text.length * 2);
const view = new DataView(result);
for (let i = 0; i < text.length; i++) {
view.setUint16(i * 2, text.charCodeAt(i), options.littleEndian ?? false);
}
return new Uint8Array(result);
}
export function decode(data, options = {}) {
const buffer = toArrayBuffer(data);
const view = new DataView(buffer);
let result = "";
for (let i = 0; i < buffer.byteLength; i += 2) {
result += String.fromCharCode(view.getUint16(i, options.littleEndian ?? false));
}
return result;
}
export const utf16 = { encode, decode };

View file

@ -0,0 +1,8 @@
import { toUint8Array } from "../bytes/index.js";
export function encode(text) {
return new TextEncoder().encode(text);
}
export function decode(data) {
return new TextDecoder("utf-8", { fatal: false }).decode(toUint8Array(data));
}
export const utf8 = { encode, decode };