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,71 @@
import { toArrayBuffer } from "../bytes/index.js";
import { base64, base64url, binary, hex, utf8, utf16 } from "../encoding/index.js";
import { defaultConverterRegistry } from "./defaults.js";
function encode(name, data, ...args) {
return defaultConverterRegistry.encode(name, data, ...args);
}
function decode(name, text, ...args) {
return defaultConverterRegistry.decode(name, text, ...args);
}
function tryDecode(name, text, ...args) {
return defaultConverterRegistry.tryDecode(name, text, ...args);
}
function normalize(name, text, ...args) {
return defaultConverterRegistry.normalize(name, text, ...args);
}
function parse(name, text, ...args) {
return defaultConverterRegistry.parse(name, text, ...args);
}
function format(name, data, value) {
return defaultConverterRegistry.format(name, data, value);
}
function transcode(text, options) {
return defaultConverterRegistry.transcode(text, options);
}
function detect(text, options) {
return defaultConverterRegistry.detect(text, options);
}
function normalizeEncodingName(encoding) {
return encoding.toLowerCase();
}
export const convert = {
encode,
decode,
tryDecode,
normalize,
parse,
format,
transcode,
detect,
to(format, data, ...args) {
return encode(format, data, ...args);
},
from(format, text, ...args) {
return decode(format, text, ...args);
},
toString(data, encoding = "utf8") {
return encode(encoding, data);
},
fromString(text, encoding = "utf8") {
if (normalizeEncodingName(encoding) === "hex") {
return toArrayBuffer(hex.decode(text, { allowOddLength: true }));
}
return toArrayBuffer(decode(encoding, text));
},
toBase64: base64.encode,
fromBase64: (text) => toArrayBuffer(base64.decode(text)),
toBase64Url: base64url.encode,
fromBase64Url: (text) => toArrayBuffer(base64url.decode(text)),
toHex: hex.encode,
fromHex: (text) => toArrayBuffer(hex.decode(text, { allowOddLength: true })),
toBinary: binary.encode,
fromBinary: (text) => toArrayBuffer(binary.decode(text)),
toUtf8String: utf8.decode,
fromUtf8String: (text) => toArrayBuffer(utf8.encode(text)),
toUtf16String: (data, littleEndian = false) => utf16.decode(data, { littleEndian }),
fromUtf16String: (text, littleEndian = false) => toArrayBuffer(utf16.encode(text, { littleEndian })),
isHex: hex.is,
isBase64: base64.is,
isBase64Url: base64url.is,
formatString: base64.normalize,
};

View file

@ -0,0 +1,68 @@
import { base64, base64url, binary, hex, utf8, utf16 } from "../encoding/index.js";
import { pemConverter } from "../pem/index.js";
export { pemConverter } from "../pem/index.js";
import { createConverterRegistry } from "./registry.js";
export const binaryConverter = {
name: "binary",
aliases: ["latin1"],
encode: binary.encode,
decode: binary.decode,
is: binary.is,
};
export const hexConverter = {
name: "hex",
encode: hex.encode,
decode: hex.decode,
format: hex.format,
is: hex.is,
normalize: hex.normalize,
parse: hex.parse,
};
export const base64Converter = {
name: "base64",
aliases: ["b64"],
encode: base64.encode,
decode: base64.decode,
is: base64.is,
normalize: base64.normalize,
};
export const base64urlConverter = {
name: "base64url",
aliases: ["base64-url", "b64url"],
encode: base64url.encode,
decode: base64url.decode,
is: base64url.is,
normalize: base64url.normalize,
};
export const utf8Converter = {
name: "utf8",
aliases: ["utf-8"],
encode: (data) => utf8.decode(data),
decode: (text) => utf8.encode(text),
is: (text) => typeof text === "string",
};
export const utf16beConverter = {
name: "utf16be",
aliases: ["utf16", "utf-16", "utf-16be"],
encode: (data) => utf16.decode(data),
decode: (text) => utf16.encode(text),
is: (text) => typeof text === "string",
};
export const utf16leConverter = {
name: "utf16le",
aliases: ["utf-16le", "ucs2", "usc2"],
encode: (data) => utf16.decode(data, { littleEndian: true }),
decode: (text) => utf16.encode(text, { littleEndian: true }),
is: (text) => typeof text === "string",
};
export const defaultConverters = [
binaryConverter,
hexConverter,
base64Converter,
base64urlConverter,
utf8Converter,
utf16beConverter,
utf16leConverter,
pemConverter,
];
export const defaultConverterRegistry = createConverterRegistry(defaultConverters);

View file

@ -0,0 +1,3 @@
export { createConverterRegistry } from "./registry.js";
export { base64Converter, base64urlConverter, binaryConverter, defaultConverterRegistry, defaultConverters, hexConverter, pemConverter, utf16beConverter, utf16leConverter, utf8Converter, } from "./defaults.js";
export { convert } from "./convert.js";

View file

@ -0,0 +1,185 @@
function keyOf(name) {
return name.trim().toLowerCase();
}
function toError(error) {
return error instanceof Error ? error : new Error(String(error));
}
function removeConverter(converters, primaryNames, converter) {
for (const alias of [converter.name, ...(converter.aliases ?? [])]) {
converters.delete(keyOf(alias));
}
primaryNames.delete(keyOf(converter.name));
}
function requireCapability(converter, name, capability) {
const method = converter[capability];
if (typeof method !== "function") {
throw new Error(`Converter '${name}' does not support ${capability}()`);
}
return method;
}
function detectConfidence(name, text, converter) {
const normalizedName = keyOf(converter.name || name);
const trimmed = text.trim();
if (!trimmed) {
return 0;
}
let accepted = false;
if (converter.is) {
accepted = converter.is(text);
}
let decodable = false;
try {
converter.decode(text);
decodable = true;
}
catch {
decodable = false;
}
if (!accepted && !decodable) {
return 0;
}
switch (normalizedName) {
case "pem":
return /-----BEGIN [^-]+-----/.test(text) ? 1 : 0;
case "hex": {
const compact = trimmed.replace(/^0x/i, "").replace(/[\s:.-]/g, "");
if (!compact || /[^0-9a-f]/i.test(compact) || compact.length % 2 !== 0) {
return 0;
}
if (/^0x/i.test(trimmed) || /[:\s.-]/.test(trimmed)) {
return 0.95;
}
if (/[a-f]/.test(trimmed) || /[A-F]/.test(trimmed)) {
return 0.8;
}
return 0.45;
}
case "base64url":
if (/[-_]/.test(trimmed)) {
return 0.95;
}
if (/=/.test(trimmed)) {
return 0.1;
}
return 0.6;
case "base64":
if (/[+/=]/.test(trimmed)) {
return 0.9;
}
return 0.55;
case "binary":
case "utf8":
case "utf16be":
case "utf16le":
return 0;
default:
return accepted && decodable ? 0.75 : 0.5;
}
}
export function createConverterRegistry(initialConverters = []) {
const converters = new Map();
const primaryNames = new Set();
const api = {
register(converter, options = {}) {
if (!converter.name || !keyOf(converter.name)) {
throw new TypeError("Converter name is required");
}
const names = [...new Set([converter.name, ...(converter.aliases ?? [])].map(keyOf))];
const conflicts = new Set();
for (const name of names) {
const existing = converters.get(name);
if (!existing) {
continue;
}
if (!options.override) {
throw new Error(`Converter '${name}' is already registered`);
}
conflicts.add(existing);
}
for (const conflicting of conflicts) {
removeConverter(converters, primaryNames, conflicting);
}
for (const name of names) {
converters.set(name, converter);
}
primaryNames.add(keyOf(converter.name));
return this;
},
unregister(name) {
const converter = converters.get(keyOf(name));
if (!converter) {
return false;
}
removeConverter(converters, primaryNames, converter);
return true;
},
has(name) {
return converters.has(keyOf(name));
},
get(name) {
const converter = converters.get(keyOf(name));
if (!converter) {
throw new Error(`Converter '${name}' is not registered`);
}
return converter;
},
list() {
return [...primaryNames].map((name) => this.get(name));
},
encode(name, data, options) {
return this.get(name).encode(data, options);
},
decode(name, text, options) {
return this.get(name).decode(text, options);
},
tryDecode(name, text, options) {
try {
return { ok: true, bytes: this.decode(name, text, options) };
}
catch (error) {
return { ok: false, error: toError(error) };
}
},
normalize(name, text, options) {
const converter = this.get(name);
return requireCapability(converter, name, "normalize").call(converter, text, options);
},
parse(name, text, options) {
const converter = this.get(name);
return requireCapability(converter, name, "parse").call(converter, text, options);
},
format(name, data, format) {
const converter = this.get(name);
return requireCapability(converter, name, "format").call(converter, data, format);
},
transcode(text, options) {
const bytes = this.decode(options.from, text, options.fromOptions);
return this.encode(options.to, bytes, options.toOptions);
},
detect(text, options = {}) {
const formatNames = options.formats?.length
? options.formats.map((name) => String(name))
: this.list()
.map((converter) => converter.name)
.filter((name) => !["binary", "utf8", "utf16be", "utf16le"].includes(keyOf(name)));
const detections = new Map();
for (const requestedName of formatNames) {
const converter = this.get(requestedName);
const confidence = detectConfidence(requestedName, text, converter);
if (confidence <= 0) {
continue;
}
const format = converter.name;
const current = detections.get(format);
if (!current || confidence > current.confidence) {
detections.set(format, { format, confidence });
}
}
return [...detections.values()].sort((left, right) => right.confidence - left.confidence);
},
};
for (const converter of initialConverters) {
api.register(converter);
}
return api;
}

View file

@ -0,0 +1 @@
export {};