/** * Pure string helpers for glob pattern analysis. * * No filesystem access. These are building blocks for higher-level glob * expansion utilities. Glob patterns always use forward slashes by convention — * this module treats `/` as the only path separator (never `\`). * * ### Escape semantics * A backslash immediately preceding a metachar (`*`, `?`, `[`) neutralises it. * Any other backslash is left as-is. The algorithm scans left-to-right and * sets an `escaped` flag when it sees `\`; the *next* character is skipped for * magic detection if `escaped` is true. */ /** * Returns `true` iff `source` contains at least one unescaped glob metachar * (`*`, `?`, `[`). A backslash immediately before a metachar escapes it. * * @example * isGlob('a/b/*.mjs') // true — unescaped * * isGlob('packs/**\/*') // true — unescaped ** * isGlob('x?.txt') // true — unescaped ? * isGlob('files[1].txt') // true — unescaped [ * isGlob('foo\\*.txt') // false — * is backslash-escaped * isGlob('foo/bar.txt') // false — no metachar */ export declare function isGlob(source: string): boolean; /** * The longest leading path prefix of `pattern` that contains no glob magic — * i.e. the static directory base suitable as a `cwd` for a glob runner. * * Algorithm: * 1. Split pattern on `/` (glob patterns always use forward slashes). * 2. Accumulate segments until (and **excluding**) the first magic segment. * 3. Join accumulated segments with `/`. * 4. If the very first segment is magic → return `'.'`. * 5. If the joined base is empty but the pattern is absolute (leading `/`, * first real segment magic, e.g. `'/*.mjs'`) → return the root `'/'`. * 6. If NO segment is magic (not a glob at all) → return the whole pattern. * * Output always uses forward slashes (pure string ops, no `node:path`). * * @example * staticGlobBase('modules/packs/**\/*') // 'modules/packs' * staticGlobBase('a/b/*.mjs') // 'a/b' * staticGlobBase('*.mjs') // '.' * staticGlobBase('/*.mjs') // '/' (absolute root, not '') * staticGlobBase('../mycli/dist/*.mjs') // '../mycli/dist' * staticGlobBase('foo/bar.txt') // 'foo/bar.txt' */ export declare function staticGlobBase(pattern: string): string; /** * The sub-pattern remaining after stripping the static base, with no leading * `/`. This is the pattern to pass to a glob runner with `cwd` set to the base. * * Only meaningful when `isGlob(pattern)` is true — for a non-glob input the * return value is `''` (the whole pattern was consumed as the base). * * @example * globMagicRemainder('modules/packs/**\/*') // '**\/*' * globMagicRemainder('a/b/*.mjs') // '*.mjs' * globMagicRemainder('*.mjs') // '*.mjs' * globMagicRemainder('../mycli/dist/*.mjs') // '*.mjs' */ export declare function globMagicRemainder(pattern: string): string; //# sourceMappingURL=glob-pattern.d.ts.map