Fix StartOS 0.4 TypeScript packaging to match SDK API

This commit is contained in:
MacPro
2026-04-09 15:10:44 -05:00
parent d5046a0daf
commit 0b70cbb2bf
3436 changed files with 867051 additions and 92 deletions
+85
View File
@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pem = exports.base64Whitespace = exports.base64 = exports.emailWithName = exports.email = exports.domain = exports.ascii = exports.localUrl = exports.url = exports.localHostname = exports.hostname = exports.ipv4 = exports.ipv6 = exports.escapeLiteral = exports.ComposableRegex = void 0;
/**
* A wrapper around RegExp that supports composition into larger patterns.
* Provides helpers to produce anchored (full-match), grouped (sub-expression),
* and unanchored (contains) regex source strings.
*
* @example
* ```ts
* const digit = new ComposableRegex(/\d+/)
* digit.matches() // "^\\d+$"
* digit.contains() // "\\d+"
* digit.asExpr() // "(\\d+)"
* ```
*/
class ComposableRegex {
constructor(regex) {
if (regex instanceof RegExp) {
this.regex = regex;
}
else {
this.regex = new RegExp(regex);
}
}
/** Returns the regex source wrapped in a capturing group, suitable for embedding in a larger expression. */
asExpr() {
return `(${this.regex.source})`;
}
/** Returns the regex source anchored with `^...$` for full-string matching. */
matches() {
return `^${this.regex.source}$`;
}
/** Returns the raw regex source string for substring/containment matching. */
contains() {
return this.regex.source;
}
}
exports.ComposableRegex = ComposableRegex;
/**
* Escapes all regex special characters in a string so it can be used as a literal in a RegExp.
* @param str - The string to escape
* @returns The escaped string safe for regex interpolation
*/
const escapeLiteral = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
exports.escapeLiteral = escapeLiteral;
/** Composable regex for matching IPv6 addresses (all standard forms including `::` shorthand). */
// https://ihateregex.io/expr/ipv6/
exports.ipv6 = new ComposableRegex(/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/);
/** Composable regex for matching IPv4 addresses in dotted-decimal notation. */
// https://ihateregex.io/expr/ipv4/
exports.ipv4 = new ComposableRegex(/(\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/);
/** Composable regex for matching RFC-compliant hostnames. */
exports.hostname = new ComposableRegex(/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])/);
/** Composable regex for matching `.local` mDNS hostnames. */
exports.localHostname = new ComposableRegex(/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.local/);
/** Composable regex for matching HTTP/HTTPS URLs. */
// https://ihateregex.io/expr/url/
exports.url = new ComposableRegex(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/);
/** Composable regex for matching `.local` URLs (mDNS/LAN). */
exports.localUrl = new ComposableRegex(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.local\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/);
/** Composable regex for matching printable ASCII characters (space through tilde). */
// https://ihateregex.io/expr/ascii/
exports.ascii = new ComposableRegex(/[ -~]*/);
/** Composable regex for matching fully qualified domain names. */
exports.domain = new ComposableRegex(/[A-Za-z0-9.-]+\.[A-Za-z]{2,}/);
/** Composable regex for matching email addresses. */
// https://www.regular-expressions.info/email.html
exports.email = new ComposableRegex(`[A-Za-z0-9._%+-]+@${exports.domain.asExpr()}`);
/** Composable regex for matching email addresses optionally preceded by a display name (e.g. `"Name <email>"`). */
exports.emailWithName = new ComposableRegex(`${exports.email.asExpr()}|([^<]*<${exports.email.asExpr()}>)`);
/** Composable regex for matching base64-encoded strings (no whitespace). */
//https://rgxdb.com/r/1NUN74O6
exports.base64 = new ComposableRegex(/(?:[a-zA-Z0-9+\/]{4})*(?:|(?:[a-zA-Z0-9+\/]{3}=)|(?:[a-zA-Z0-9+\/]{2}==)|(?:[a-zA-Z0-9+\/]{1}===))/);
/** Composable regex for matching base64-encoded strings that may contain interspersed whitespace. */
//https://rgxdb.com/r/1NUN74O6
exports.base64Whitespace = new ComposableRegex(/(?:([a-zA-Z0-9+\/]\s*){4})*(?:|(?:([a-zA-Z0-9+\/]\s*){3}=)|(?:([a-zA-Z0-9+\/]\s*){2}==)|(?:([a-zA-Z0-9+\/]\s*){1}===))/);
/**
* Creates a composable regex for matching PEM-encoded blocks with the given label.
* @param label - The PEM label (e.g. `"CERTIFICATE"`, `"RSA PRIVATE KEY"`)
* @returns A ComposableRegex matching `-----BEGIN <label>-----...-----END <label>-----`
*/
const pem = (label) => new ComposableRegex(`-----BEGIN ${(0, exports.escapeLiteral)(label)}-----\r?\n[a-zA-Z0-9+/\n\r=]*?\r?\n-----END ${(0, exports.escapeLiteral)(label)}-----`);
exports.pem = pem;
//# sourceMappingURL=regexes.js.map