Astro+Directus(Visual-Editing)+Snipcart Test-Stack

This commit is contained in:
till committed 2026-06-21 06:27:52 +00:00
commit 1459e99cb0
10119 files changed
+1499318

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
/**
Apply transformations for atomic groups: `(?>…)`.
@param {string} expression
@param {PluginData} [data]
@returns {Required<PluginResult>}
*/
export function atomic(expression: string, data?: PluginData): Required<PluginResult>;
/**
Transform posessive quantifiers into atomic groups. The posessessive quantifiers are:
`?+`, `*+`, `++`, `{N}+`, `{N,}+`, `{N,N}+`.
This follows Java, PCRE, Perl, and Python.
Possessive quantifiers in Oniguruma and Onigmo are only: `?+`, `*+`, `++`.
@param {string} expression
@returns {PluginResult}
*/
export function possessive(expression: string): PluginResult;
import type { PluginData } from './regex.js';
import type { PluginResult } from './regex.js';
+8
View File
@@ -0,0 +1,8 @@
/**
Applies flag v rules when using flag u, for forward compatibility.
Assumes flag u and doesn't worry about syntax errors that are caught by it.
@param {string} expression
@returns {PluginResult}
*/
export function backcompatPlugin(expression: string): PluginResult;
import type { PluginResult } from './regex.js';
+4
View File
@@ -0,0 +1,4 @@
export function flagNPreprocessor(value: import("./regex.js").InterpolatedValue, runningContext: import("./utils.js").RunningContext, options: Required<import("./regex.js").RegexTagOptions>): {
transformed: string;
runningContext: import("./utils.js").RunningContext;
};
+11
View File
@@ -0,0 +1,11 @@
/**
Remove `(?:)` token separators (most likely added by flag x) in cases where it's safe to do so.
@param {string} expression
@returns {PluginResult}
*/
export function clean(expression: string): PluginResult;
export function flagXPreprocessor(value: import("./regex.js").InterpolatedValue, runningContext: import("./utils.js").RunningContext, options: Required<import("./regex.js").RegexTagOptions>): {
transformed: string;
runningContext: import("./utils.js").RunningContext;
};
import type { PluginResult } from './regex.js';
+2
View File
@@ -0,0 +1,2 @@
export { RegExpSubclass } from "./subclass.js";
export { atomic, possessive } from "./atomic.js";
+1
View File
@@ -0,0 +1 @@
{"type":"module"}
+43
View File
@@ -0,0 +1,43 @@
export class Pattern {
/** @param {string} value */
constructor(value: string);
/** @returns {string} */
toString(): string;
#private;
}
/**
Returns a value that can be interpolated into a `regex` template string without having its special
characters escaped.
Can be called as a function or template tag:
- `pattern(value)` - String or value coerced to string.
- `` pattern`…` `` - Same as ``pattern(String.raw`…`)``.
@overload
@param {string | number} value
@returns {Pattern}
@overload
@param {TemplateStringsArray} template
@param {...string} substitutions
@returns {Pattern}
*/
export function pattern(value: string | number): Pattern;
/**
Returns a value that can be interpolated into a `regex` template string without having its special
characters escaped.
Can be called as a function or template tag:
- `pattern(value)` - String or value coerced to string.
- `` pattern`…` `` - Same as ``pattern(String.raw`…`)``.
@overload
@param {string | number} value
@returns {Pattern}
@overload
@param {TemplateStringsArray} template
@param {...string} substitutions
@returns {Pattern}
*/
export function pattern(template: TemplateStringsArray, ...substitutions: string[]): Pattern;
+111
View File
@@ -0,0 +1,111 @@
export type InterpolatedValue = string | RegExp | Pattern | number;
export type PluginData = {
flags?: string;
captureTransfers?: Map<number, Array<number>>;
hiddenCaptures?: Array<number>;
};
export type PluginResult = {
pattern: string;
captureTransfers?: Map<number, Array<number>>;
hiddenCaptures?: Array<number>;
};
export type RawTemplate = TemplateStringsArray | {
raw: Array<string>;
};
export type RegexTagOptions = {
flags?: string;
subclass?: boolean;
plugins?: Array<(expression: string, data: PluginData) => PluginResult>;
unicodeSetsPlugin?: ((expression: string, data: PluginData) => PluginResult) | null;
disable?: {
x?: boolean;
n?: boolean;
v?: boolean;
atomic?: boolean;
subroutines?: boolean;
};
force?: {
v?: boolean;
};
};
export type RegexTag<T> = {
(template: RawTemplate, ...substitutions: ReadonlyArray<InterpolatedValue>): T;
(flags?: string): RegexTag<T>;
(options: RegexTagOptions & {
subclass?: false;
}): RegexTag<T>;
(options: RegexTagOptions & {
subclass: true;
}): RegexTag<RegExpSubclass>;
};
export type RegexFromTemplate<T> = {
(options: RegexTagOptions, template: RawTemplate, ...substitutions: ReadonlyArray<InterpolatedValue>): T;
};
import { pattern } from './pattern.js';
/**
@typedef {string | RegExp | Pattern | number} InterpolatedValue
@typedef {{
flags?: string;
captureTransfers?: Map<number, Array<number>>;
hiddenCaptures?: Array<number>;
}} PluginData
@typedef {{
pattern: string;
captureTransfers?: Map<number, Array<number>>;
hiddenCaptures?: Array<number>;
}} PluginResult
@typedef {TemplateStringsArray | {raw: Array<string>}} RawTemplate
@typedef {{
flags?: string;
subclass?: boolean;
plugins?: Array<(expression: string, data: PluginData) => PluginResult>;
unicodeSetsPlugin?: ((expression: string, data: PluginData) => PluginResult) | null;
disable?: {
x?: boolean;
n?: boolean;
v?: boolean;
atomic?: boolean;
subroutines?: boolean;
};
force?: {
v?: boolean;
};
}} RegexTagOptions
*/
/**
@template T
@typedef RegexTag
@type {{
(template: RawTemplate, ...substitutions: ReadonlyArray<InterpolatedValue>): T;
(flags?: string): RegexTag<T>;
(options: RegexTagOptions & {subclass?: false}): RegexTag<T>;
(options: RegexTagOptions & {subclass: true}): RegexTag<RegExpSubclass>;
}}
*/
/**
Template tag for constructing a regex with extended syntax and context-aware interpolation of
regexes, strings, and patterns.
Can be called in several ways:
1. `` regex`…` `` - Regex pattern as a raw string.
2. `` regex('gi')`…` `` - To specify flags.
3. `` regex({flags: 'gi'})`…` `` - With options.
@type {RegexTag<RegExp>}
*/
export const regex: RegexTag<RegExp>;
/**
Returns the processed expression and flags as strings.
@param {string} expression
@param {RegexTagOptions} [options]
@returns {{
pattern: string;
flags: string;
}}
*/
export function rewrite(expression?: string, options?: RegexTagOptions): {
pattern: string;
flags: string;
};
import { Pattern } from './pattern.js';
import { RegExpSubclass } from './subclass.js';
export { pattern };
+1313
View File
File diff suppressed because it is too large. Load diff
+7
View File
@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../src/utils-internals.js", "../../node_modules/.pnpm/regex-utilities@2.3.0/node_modules/regex-utilities/src/index.js", "../../src/atomic.js", "../../src/pattern.js", "../../src/utils.js", "../../src/backcompat.js", "../../src/flag-n.js", "../../src/flag-x.js", "../../src/subclass.js", "../../src/subroutines.js", "../../src/regex.js"],
"sourcesContent": ["// Separating some utils for improved tree shaking of the `./internals` export\n\nconst noncapturingDelim = String.raw`\\(\\?(?:[:=!>A-Za-z\\-]|<[=!]|\\(DEFINE\\))`;\n\n/**\nUpdates the array in place by incrementing each value greater than or equal to the threshold.\n@param {Array<number>} arr\n@param {number} threshold\n*/\nfunction incrementIfAtLeast(arr, threshold) {\n for (let i = 0; i < arr.length; i++) {\n if (arr[i] >= threshold) {\n arr[i]++;\n }\n }\n}\n\n/**\n@param {string} str\n@param {number} pos\n@param {string} oldValue\n@param {string} newValue\n@returns {string}\n*/\nfunction spliceStr(str, pos, oldValue, newValue) {\n return str.slice(0, pos) + newValue + str.slice(pos + oldValue.length);\n}\n\nexport {\n incrementIfAtLeast,\n noncapturingDelim,\n spliceStr,\n};\n", "// Constant properties for tracking regex syntax context\nexport const Context = Object.freeze({\n DEFAULT: 'DEFAULT',\n CHAR_CLASS: 'CHAR_CLASS',\n});\n\n/**\nReplaces all unescaped instances of a regex pattern in the given context, using a replacement\nstring or callback.\n\nDoesn't skip over complete multicharacter tokens (only `\\` plus its folowing char) so must be used\nwith knowledge of what's safe to do given regex syntax. Assumes UnicodeSets-mode syntax.\n@param {string} expression Search target\n@param {string} needle Search as a regex pattern, with flags `su` applied\n@param {string | (match: RegExpExecArray, details: {\n context: 'DEFAULT' | 'CHAR_CLASS';\n negated: boolean;\n}) => string} replacement\n@param {'DEFAULT' | 'CHAR_CLASS'} [context] All contexts if not specified\n@returns {string} Updated expression\n@example\nconst str = '.\\\\.\\\\\\\\.[[\\\\.].].';\nreplaceUnescaped(str, '\\\\.', '@');\n// \u2192 '@\\\\.\\\\\\\\@[[\\\\.]@]@'\nreplaceUnescaped(str, '\\\\.', '@', Context.DEFAULT);\n// \u2192 '@\\\\.\\\\\\\\@[[\\\\.].]@'\nreplaceUnescaped(str, '\\\\.', '@', Context.CHAR_CLASS);\n// \u2192 '.\\\\.\\\\\\\\.[[\\\\.]@].'\n*/\nexport function replaceUnescaped(expression, needle, replacement, context) {\n const re = new RegExp(String.raw`${needle}|(?<$skip>\\[\\^?|\\\\?.)`, 'gsu');\n const negated = [false];\n let numCharClassesOpen = 0;\n let result = '';\n for (const match of expression.matchAll(re)) {\n const {0: m, groups: {$skip}} = match;\n if (!$skip && (!context || (context === Context.DEFAULT) === !numCharClassesOpen)) {\n if (replacement instanceof Function) {\n result += replacement(match, {\n context: numCharClassesOpen ? Context.CHAR_CLASS : Context.DEFAULT,\n negated: negated[negated.length - 1],\n });\n } else {\n result += replacement;\n }\n continue;\n }\n if (m[0] === '[') {\n numCharClassesOpen++;\n negated.push(m[1] === '^');\n } else if (m === ']' && numCharClassesOpen) {\n numCharClassesOpen--;\n negated.pop();\n }\n result += m;\n }\n return result;\n}\n\n/**\nRuns a callback for each unescaped instance of a regex pattern in the given context.\n\nDoesn't skip over complete multicharacter tokens (only `\\` plus its folowing char) so must be used\nwith knowledge of what's safe to do given regex syntax. Assumes UnicodeSets-mode syntax.\n@param {string} expression Search target\n@param {string} needle Search as a regex pattern, with flags `su` applied\n@param {(match: RegExpExecArray, details: {\n context: 'DEFAULT' | 'CHAR_CLASS';\n negated: boolean;\n}) => void} callback\n@param {'DEFAULT' | 'CHAR_CLASS'} [context] All contexts if not specified\n*/\nexport function forEachUnescaped(expression, needle, callback, context) {\n // Do this the easy way\n replaceUnescaped(expression, needle, callback, context);\n}\n\n/**\nReturns a match object for the first unescaped instance of a regex pattern in the given context, or\n`null`.\n\nDoesn't skip over complete multicharacter tokens (only `\\` plus its folowing char) so must be used\nwith knowledge of what's safe to do given regex syntax. Assumes UnicodeSets-mode syntax.\n@param {string} expression Search target\n@param {string} needle Search as a regex pattern, with flags `su` applied\n@param {number} [pos] Offset to start the search\n@param {'DEFAULT' | 'CHAR_CLASS'} [context] All contexts if not specified\n@returns {RegExpExecArray | null}\n*/\nexport function execUnescaped(expression, needle, pos = 0, context) {\n // Quick partial test; avoid the loop if not needed\n if (!(new RegExp(needle, 'su').test(expression))) {\n return null;\n }\n const re = new RegExp(`${needle}|(?<$skip>\\\\\\\\?.)`, 'gsu');\n re.lastIndex = pos;\n let numCharClassesOpen = 0;\n let match;\n while (match = re.exec(expression)) {\n const {0: m, groups: {$skip}} = match;\n if (!$skip && (!context || (context === Context.DEFAULT) === !numCharClassesOpen)) {\n return match;\n }\n if (m === '[') {\n numCharClassesOpen++;\n } else if (m === ']' && numCharClassesOpen) {\n numCharCLine truncated
"mappings": ";AAEA,IAAM,oBAAoB,OAAO;AAOjC,SAAS,mBAAmB,KAAK,WAAW;AAC1C,WAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;AACnC,QAAI,IAAI,CAAC,KAAK,WAAW;AACvB,UAAI,CAAC;AAAA,IACP;AAAA,EACF;AACF;AASA,SAAS,UAAU,KAAK,KAAK,UAAU,UAAU;AAC/C,SAAO,IAAI,MAAM,GAAG,GAAG,IAAI,WAAW,IAAI,MAAM,MAAM,SAAS,MAAM;AACvE;;;ACzBO,IAAM,UAAU,OAAO,OAAO;AAAA,EACnC,SAAS;AAAA,EACT,YAAY;AACd,CAAC;AAyBM,SAAS,iBAAiB,YAAY,QAAQ,aAAa,SAAS;AACzE,QAAM,KAAK,IAAI,OAAO,OAAO,MAAM,MAAM,yBAAyB,KAAK;AACvE,QAAM,UAAU,CAAC,KAAK;AACtB,MAAI,qBAAqB;AACzB,MAAI,SAAS;AACb,aAAW,SAAS,WAAW,SAAS,EAAE,GAAG;AAC3C,UAAM,EAAC,GAAG,GAAG,QAAQ,EAAC,MAAK,EAAC,IAAI;AAChC,QAAI,CAAC,UAAU,CAAC,WAAY,YAAY,QAAQ,YAAa,CAAC,qBAAqB;AACjF,UAAI,uBAAuB,UAAU;AACnC,kBAAU,YAAY,OAAO;AAAA,UAC3B,SAAS,qBAAqB,QAAQ,aAAa,QAAQ;AAAA,UAC3D,SAAS,QAAQ,QAAQ,SAAS,CAAC;AAAA,QACrC,CAAC;AAAA,MACH,OAAO;AACL,kBAAU;AAAA,MACZ;AAC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
@@ -0,0 +1,31 @@
/**
Works the same as JavaScript's native `RegExp` constructor in all contexts, but automatically
adjusts subpattern matches and indices (with flag `d`) to account for captures added as part of
emulating extended syntax.
*/
export class RegExpSubclass extends RegExp {
/**
@overload
@param {string} expression
@param {string} [flags]
@param {{
hiddenCaptures?: Array<number>;
}} [options]
*/
constructor(expression: string, flags?: string, options?: {
hiddenCaptures?: Array<number>;
});
/**
@overload
@param {RegExpSubclass} expression
@param {string} [flags]
*/
constructor(expression: RegExpSubclass, flags?: string);
/**
@private
@type {Map<number, {
hidden: true;
}>}
*/
private _captureMap;
}
+17
View File
@@ -0,0 +1,17 @@
export type NamedCapturingGroupsMap = Map<string, {
isUnique: boolean;
contents?: string;
groupNum?: number;
numCaptures?: number;
}>;
/**
@import {PluginData, PluginResult} from './regex.js';
*/
/**
@param {string} expression
@param {PluginData} [data]
@returns {PluginResult}
*/
export function subroutines(expression: string, data?: PluginData): PluginResult;
import type { PluginData } from './regex.js';
import type { PluginResult } from './regex.js';
+15
View File
@@ -0,0 +1,15 @@
/**
Updates the array in place by incrementing each value greater than or equal to the threshold.
@param {Array<number>} arr
@param {number} threshold
*/
export function incrementIfAtLeast(arr: Array<number>, threshold: number): void;
export const noncapturingDelim: any;
/**
@param {string} str
@param {number} pos
@param {string} oldValue
@param {string} newValue
@returns {string}
*/
export function spliceStr(str: string, pos: number, oldValue: string, newValue: string): string;
+115
View File
@@ -0,0 +1,115 @@
export type RunningContext = {
regexContext: string;
charClassContext: string;
charClassDepth: number;
lastPos: number;
};
export type InterpolatedValue = InterpolatedValue;
export type RawTemplate = RawTemplate;
export type RegexTagOptions = RegexTagOptions;
export type Preprocessor = (value: InterpolatedValue, runningContext: RunningContext, options: Required<RegexTagOptions>) => {
transformed: string;
runningContext: RunningContext;
};
/**
@param {string} expression
@param {number} precedingCaptures
@returns {string}
*/
export function adjustNumberedBackrefs(expression: string, precedingCaptures: number): string;
export const capturingDelim: any;
export namespace CharClassContext {
let DEFAULT: string;
let ENCLOSED_P: string;
let ENCLOSED_Q: string;
let ENCLOSED_U: string;
let INVALID_INCOMPLETE_TOKEN: string;
let RANGE: string;
}
export function containsCharClassUnion(charClassPattern: any): boolean;
/**
@param {string} expression
@returns {number}
*/
export function countCaptures(expression: string): number;
export const doublePunctuatorChars: "&!#$%*+,.:;<=>?@^`~";
export const enclosedTokenCharClassContexts: any;
export const enclosedTokenRegexContexts: any;
export const envSupportsFlagGroups: boolean;
export const envSupportsFlagV: boolean;
/**
Escape special characters for the given context, assuming flag v.
@param {string} str String to escape
@param {'DEFAULT' | 'CHAR_CLASS'} context `Context` option from lib `regex-utilities`
@returns {string} Escaped string
*/
export function escapeV(str: string, context: "DEFAULT" | "CHAR_CLASS"): string;
export function getBreakoutChar(expression: any, regexContext: any, charClassContext: any): any;
/**
@typedef {{
regexContext: string;
charClassContext: string;
charClassDepth: number;
lastPos: number;
}} RunningContext
*/
/**
Accepts and returns its full state so it doesn't have to reprocess parts that have already been
seen. Assumes flag v and doesn't worry about syntax errors that are caught by it.
@param {string} incompleteExpression
@param {Partial<RunningContext>} [runningContext]
@returns {RunningContext}
*/
export function getEndContextForIncompleteExpression(incompleteExpression: string, runningContext?: Partial<RunningContext>): RunningContext;
export const namedCapturingDelim: any;
/**
@typedef {InterpolatedValue} InterpolatedValue
@typedef {RawTemplate} RawTemplate
@typedef {RegexTagOptions} RegexTagOptions
@typedef {(
value: InterpolatedValue,
runningContext: RunningContext,
options: Required<RegexTagOptions>
) => {
transformed: string;
runningContext: RunningContext;
}} Preprocessor
*/
/**
Returns transformed versions of a template and substitutions, using the given preprocessor. Only
processes substitutions that are instanceof `Pattern`.
@param {RawTemplate} template
@param {ReadonlyArray<InterpolatedValue>} substitutions
@param {Preprocessor} preprocessor
@param {Required<RegexTagOptions>} options
@returns {{template: RawTemplate; substitutions: ReadonlyArray<InterpolatedValue>;}}
*/
export function preprocess(template: RawTemplate, substitutions: ReadonlyArray<InterpolatedValue>, preprocessor: Preprocessor, options: Required<RegexTagOptions>): {
template: RawTemplate;
substitutions: ReadonlyArray<InterpolatedValue>;
};
export namespace RegexContext {
let DEFAULT_1: string;
export { DEFAULT_1 as DEFAULT };
export let CHAR_CLASS: string;
let ENCLOSED_P_1: string;
export { ENCLOSED_P_1 as ENCLOSED_P };
let ENCLOSED_U_1: string;
export { ENCLOSED_U_1 as ENCLOSED_U };
export let GROUP_NAME: string;
export let INTERVAL_QUANTIFIER: string;
let INVALID_INCOMPLETE_TOKEN_1: string;
export { INVALID_INCOMPLETE_TOKEN_1 as INVALID_INCOMPLETE_TOKEN };
}
export function sandboxLoneCharClassCaret(str: any): any;
export function sandboxLoneDoublePunctuatorChar(str: any): any;
/**
Converts `\0` tokens to `\x00` in the given context.
@param {string} str
@param {'DEFAULT' | 'CHAR_CLASS'} [context] `Context` option from lib `regex-utilities`
@returns {string}
*/
export function sandboxUnsafeNulls(str: string, context?: "DEFAULT" | "CHAR_CLASS"): string;
import type { InterpolatedValue } from './regex.js';
import type { RawTemplate } from './regex.js';
import type { RegexTagOptions } from './regex.js';