@teammy/server 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +2 -2
  2. package/dist/main.js +10936 -6840
  3. package/dist/native-pi-entry.js +14 -1
  4. package/dist/project-pi-entry.js +51 -11
  5. package/dist/runtime/workflows/task-bootstrap/prompt.md +2 -0
  6. package/dist/web/assets/Assistant-BeYamS0w.js +1 -0
  7. package/dist/web/assets/Assistant-C7QfFYLo.css +1 -0
  8. package/dist/web/assets/Dashboard-BzmrE4Xv.js +1 -0
  9. package/dist/web/assets/Files-BvCYgjVV.js +1 -0
  10. package/dist/web/assets/{Markdown-oZagG-wy.js → Markdown-BRPMsc7D.js} +4 -4
  11. package/dist/web/assets/Materials-CK-mbNmo.css +1 -0
  12. package/dist/web/assets/Materials-DK3CkLr0.js +6 -0
  13. package/dist/web/assets/Sessions-D_579m-e.js +1 -0
  14. package/dist/web/assets/WorkspaceTree-fMDtGIFa.js +1 -0
  15. package/dist/web/assets/{file-links-CD346_jf.js → file-links-I1K8CwVK.js} +1 -1
  16. package/dist/web/assets/{index-Be5hGscJ.css → index-CTIAGUGG.css} +1 -1
  17. package/dist/web/assets/index-DQsx-e5d.js +66 -0
  18. package/dist/web/downloads/teammy-skill.zip +0 -0
  19. package/dist/web/index.html +2 -2
  20. package/node_modules/@isaacs/nonrecursive-glob-match/LICENSE.md +55 -0
  21. package/node_modules/@isaacs/nonrecursive-glob-match/README.md +333 -0
  22. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.d.ts +114 -0
  23. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.d.ts.map +1 -0
  24. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.js +762 -0
  25. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.js.map +1 -0
  26. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.min.js +3 -0
  27. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.min.js.map +7 -0
  28. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/package.json +3 -0
  29. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.d.ts +4 -0
  30. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.d.ts.map +1 -0
  31. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.js +142 -0
  32. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.js.map +1 -0
  33. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.d.ts +114 -0
  34. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.d.ts.map +1 -0
  35. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js +758 -0
  36. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js.map +1 -0
  37. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.min.js +3 -0
  38. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.min.js.map +7 -0
  39. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/package.json +3 -0
  40. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.d.ts +4 -0
  41. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.d.ts.map +1 -0
  42. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js +138 -0
  43. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js.map +1 -0
  44. package/node_modules/@isaacs/nonrecursive-glob-match/package.json +56 -0
  45. package/node_modules/@isaacs/nonrecursive-glob-match/src/index.ts +900 -0
  46. package/node_modules/@isaacs/nonrecursive-glob-match/src/parse-class.ts +158 -0
  47. package/node_modules/glob/README.md +388 -214
  48. package/node_modules/glob/dist/commonjs/glob.d.ts +20 -11
  49. package/node_modules/glob/dist/commonjs/glob.d.ts.map +1 -1
  50. package/node_modules/glob/dist/commonjs/glob.js +22 -29
  51. package/node_modules/glob/dist/commonjs/glob.js.map +1 -1
  52. package/node_modules/glob/dist/commonjs/has-magic.d.ts +1 -1
  53. package/node_modules/glob/dist/commonjs/has-magic.d.ts.map +1 -1
  54. package/node_modules/glob/dist/commonjs/has-magic.js +1 -4
  55. package/node_modules/glob/dist/commonjs/has-magic.js.map +1 -1
  56. package/node_modules/glob/dist/commonjs/ignore.d.ts +16 -4
  57. package/node_modules/glob/dist/commonjs/ignore.d.ts.map +1 -1
  58. package/node_modules/glob/dist/commonjs/ignore.js +24 -4
  59. package/node_modules/glob/dist/commonjs/ignore.js.map +1 -1
  60. package/node_modules/glob/dist/commonjs/index.d.ts +3 -2
  61. package/node_modules/glob/dist/commonjs/index.d.ts.map +1 -1
  62. package/node_modules/glob/dist/commonjs/index.js.map +1 -1
  63. package/node_modules/glob/dist/commonjs/index.min.js +2 -3
  64. package/node_modules/glob/dist/commonjs/index.min.js.map +4 -4
  65. package/node_modules/glob/dist/commonjs/pattern.d.ts +10 -3
  66. package/node_modules/glob/dist/commonjs/pattern.d.ts.map +1 -1
  67. package/node_modules/glob/dist/commonjs/pattern.js +27 -15
  68. package/node_modules/glob/dist/commonjs/pattern.js.map +1 -1
  69. package/node_modules/glob/dist/commonjs/processor.d.ts +23 -10
  70. package/node_modules/glob/dist/commonjs/processor.d.ts.map +1 -1
  71. package/node_modules/glob/dist/commonjs/processor.js +36 -23
  72. package/node_modules/glob/dist/commonjs/processor.js.map +1 -1
  73. package/node_modules/glob/dist/commonjs/walker.d.ts +19 -17
  74. package/node_modules/glob/dist/commonjs/walker.d.ts.map +1 -1
  75. package/node_modules/glob/dist/commonjs/walker.js +50 -35
  76. package/node_modules/glob/dist/commonjs/walker.js.map +1 -1
  77. package/node_modules/glob/dist/esm/glob.d.ts +20 -11
  78. package/node_modules/glob/dist/esm/glob.d.ts.map +1 -1
  79. package/node_modules/glob/dist/esm/glob.js +22 -29
  80. package/node_modules/glob/dist/esm/glob.js.map +1 -1
  81. package/node_modules/glob/dist/esm/has-magic.d.ts +1 -1
  82. package/node_modules/glob/dist/esm/has-magic.d.ts.map +1 -1
  83. package/node_modules/glob/dist/esm/has-magic.js +1 -4
  84. package/node_modules/glob/dist/esm/has-magic.js.map +1 -1
  85. package/node_modules/glob/dist/esm/ignore.d.ts +16 -4
  86. package/node_modules/glob/dist/esm/ignore.d.ts.map +1 -1
  87. package/node_modules/glob/dist/esm/ignore.js +25 -5
  88. package/node_modules/glob/dist/esm/ignore.js.map +1 -1
  89. package/node_modules/glob/dist/esm/index.d.ts +3 -2
  90. package/node_modules/glob/dist/esm/index.d.ts.map +1 -1
  91. package/node_modules/glob/dist/esm/index.js.map +1 -1
  92. package/node_modules/glob/dist/esm/index.min.js +2 -3
  93. package/node_modules/glob/dist/esm/index.min.js.map +4 -4
  94. package/node_modules/glob/dist/esm/pattern.d.ts +10 -3
  95. package/node_modules/glob/dist/esm/pattern.d.ts.map +1 -1
  96. package/node_modules/glob/dist/esm/pattern.js +27 -15
  97. package/node_modules/glob/dist/esm/pattern.js.map +1 -1
  98. package/node_modules/glob/dist/esm/processor.d.ts +23 -10
  99. package/node_modules/glob/dist/esm/processor.d.ts.map +1 -1
  100. package/node_modules/glob/dist/esm/processor.js +36 -23
  101. package/node_modules/glob/dist/esm/processor.js.map +1 -1
  102. package/node_modules/glob/dist/esm/walker.d.ts +19 -17
  103. package/node_modules/glob/dist/esm/walker.d.ts.map +1 -1
  104. package/node_modules/glob/dist/esm/walker.js +51 -36
  105. package/node_modules/glob/dist/esm/walker.js.map +1 -1
  106. package/node_modules/glob/package.json +28 -12
  107. package/node_modules/glob/src/glob.ts +655 -0
  108. package/node_modules/glob/src/has-magic.ts +23 -0
  109. package/node_modules/glob/src/ignore.ts +162 -0
  110. package/node_modules/glob/src/index.ts +225 -0
  111. package/node_modules/glob/src/pattern.ts +286 -0
  112. package/node_modules/glob/src/processor.ts +333 -0
  113. package/node_modules/glob/src/walker.ts +523 -0
  114. package/node_modules/minimatch/README.md +125 -107
  115. package/node_modules/minimatch/dist/commonjs/index.d.ts +49 -38
  116. package/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -1
  117. package/node_modules/minimatch/dist/commonjs/index.js +782 -359
  118. package/node_modules/minimatch/dist/commonjs/index.js.map +1 -1
  119. package/node_modules/minimatch/dist/esm/index.d.ts +49 -38
  120. package/node_modules/minimatch/dist/esm/index.d.ts.map +1 -1
  121. package/node_modules/minimatch/dist/esm/index.js +781 -356
  122. package/node_modules/minimatch/dist/esm/index.js.map +1 -1
  123. package/node_modules/minimatch/package.json +5 -4
  124. package/node_modules/path-scurry/README.md +0 -1
  125. package/node_modules/path-scurry/dist/commonjs/index.d.ts +7 -0
  126. package/node_modules/path-scurry/dist/commonjs/index.d.ts.map +1 -1
  127. package/node_modules/path-scurry/dist/commonjs/index.js +59 -21
  128. package/node_modules/path-scurry/dist/commonjs/index.js.map +1 -1
  129. package/node_modules/path-scurry/dist/esm/index.d.ts +7 -0
  130. package/node_modules/path-scurry/dist/esm/index.d.ts.map +1 -1
  131. package/node_modules/path-scurry/dist/esm/index.js +42 -14
  132. package/node_modules/path-scurry/dist/esm/index.js.map +1 -1
  133. package/node_modules/path-scurry/package.json +4 -4
  134. package/package.json +2 -1
  135. package/dist/web/assets/Assistant-B3h2yQF3.css +0 -1
  136. package/dist/web/assets/Assistant-Dm_p8EZl.js +0 -1
  137. package/dist/web/assets/Dashboard-fwW9NxcC.js +0 -1
  138. package/dist/web/assets/Files-D-KCDWmO.js +0 -1
  139. package/dist/web/assets/Sessions-BQhGiLvz.js +0 -1
  140. package/dist/web/assets/WorkspaceTree-B9733pV3.js +0 -1
  141. package/dist/web/assets/index-BiiPuwDi.js +0 -66
  142. package/node_modules/minimatch/dist/commonjs/ast.d.ts +0 -22
  143. package/node_modules/minimatch/dist/commonjs/ast.d.ts.map +0 -1
  144. package/node_modules/minimatch/dist/commonjs/ast.js +0 -845
  145. package/node_modules/minimatch/dist/commonjs/ast.js.map +0 -1
  146. package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +0 -8
  147. package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +0 -1
  148. package/node_modules/minimatch/dist/commonjs/brace-expressions.js +0 -150
  149. package/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +0 -1
  150. package/node_modules/minimatch/dist/esm/ast.d.ts +0 -22
  151. package/node_modules/minimatch/dist/esm/ast.d.ts.map +0 -1
  152. package/node_modules/minimatch/dist/esm/ast.js +0 -841
  153. package/node_modules/minimatch/dist/esm/ast.js.map +0 -1
  154. package/node_modules/minimatch/dist/esm/brace-expressions.d.ts +0 -8
  155. package/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +0 -1
  156. package/node_modules/minimatch/dist/esm/brace-expressions.js +0 -146
  157. package/node_modules/minimatch/dist/esm/brace-expressions.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAyCxD,sDAAsD;AACtD,MAAM,KAAK,GAAS,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,CAAA;AAEzC,MAAM,QAAQ,GAAG,OAAO,CAAA;AAExB,MAAM,GAAG,GAAG,CAAC,EAAU,EAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAA;AAEpD,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAA;AAEzE,4DAA4D;AAC5D,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AAErE,oEAAoE;AACpE,qEAAqE;AACrE,SAAS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AC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,IAAI,CAAC,CAAC,IAAI;gBAAE,OAAO,KAAK,CAAA;YACxB,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;YAC5D,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,CAAA;QAC/C,CAAC;QACD,OAAO,CAAC,CAAC,KAAK,CAAA;IAChB,CAAC;IAED,8CAA8C;IAC9C,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC1B,CAAC;CACF","sourcesContent":["import { type Form, parseClass } from './parse-class.js'\n\nexport type { Form }\n\nexport type MatcherOptions = {\n /** perform a case-insensitive match */\n nocase?: boolean\n /** do not treat strings starting with `.` specially */\n dot?: boolean\n /** do not match extglobs (treat them as normal strings) */\n noext?: boolean\n /**\n * normalize unicode in the pattern and the tested strings, with\n * this form. `true` means `'NFC'`.\n */\n normalize?: boolean | Form\n}\n\n// parsed pattern items\nexport type Item =\n | { t: 'lit'; ch: string }\n | { t: 'any' | 'star' }\n | { t: 'class'; re: RegExp }\n | { t: 'ext'; type: string; alts: Item[][] }\n\n// extglob syntax tokens become literals if they are not part of a\n// closed extglob\nexport type Token =\n Item | { t: 'open'; type: string } | { t: 'bar' } | { t: 'close' }\n\n// state machine nodes\nexport type NegNode = { t: 'neg'; id: number; sub: Node; next: Node }\nexport type SplitNode = { t: 'split'; id: number; out: Node[] }\nexport type Node =\n | ({ t: 'lit'; id: number; next: Node } & Lit)\n | { t: 'any' | 'star'; id: number; next: Node }\n | { t: 'class'; id: number; re: RegExp; next: Node }\n | SplitNode\n | NegNode\n | { t: 'match'; id: number }\n\n// the end of the pattern, or of a negated sub-pattern\nconst MATCH: Node = { t: 'match', id: 0 }\n\nconst extTypes = '!?+*@'\n\nconst lit = (ch: string): Item => ({ t: 'lit', ch })\n\nconst reEscape = (s: string) => s.replace(/[\\\\^$.*+?()[\\]{}|/]/g, '\\\\$&')\n\n// a RegExp that only matches `s`, with unicode case folding\nconst newFoldRe = (s: string) => new RegExp(`^${reEscape(s)}$`, 'iu')\n\n// foldRe for one literal char. The same chars are in most patterns,\n// so keep them. A RegExp without the `g` or `y` flag has no state to\n// share.\nconst foldCache = new Map<string, RegExp>()\nconst foldRe = (ch: string) => {\n let re = foldCache.get(ch)\n if (!re) {\n re = newFoldRe(ch)\n if (foldCache.size >= 1000) foldCache.clear()\n foldCache.set(ch, re)\n }\n return re\n}\n\n/**\n * A literal char. With `nocase:true`, `re` folds case, and `ascii`\n * holds its results for ASCII chars, by char code: 1 for a match,\n * and 2 for not.\n */\nexport type Lit = { ch: string; re?: RegExp; ascii?: Uint8Array }\n\nconst litMatch = (l: Lit, c: string) => {\n if (c === l.ch) return true\n if (!l.re) return false\n const code = c.charCodeAt(0)\n if (code >= 128) return l.re.test(c)\n const ascii = (l.ascii ??= new Uint8Array(128))\n ascii[code] ||= l.re.test(c) ? 1 : 2\n return ascii[code] === 1\n}\n\nconst tokenize = (\n p: string,\n nocase: boolean,\n noext: boolean,\n form?: Form,\n) => {\n const toks: Token[] = []\n for (let i = 0; i < p.length;) {\n const c = String.fromCodePoint(p.codePointAt(i)!)\n if (c === '\\\\') {\n // a trailing \\ is a literal \\\n const e = p.codePointAt(i + 1)\n const ch = e === undefined ? c : String.fromCodePoint(e)\n toks.push(lit(ch))\n i += 1 + ch.length\n continue\n }\n if (c === '[') {\n const [re, consumed] = parseClass(p, i, nocase, form)\n if (consumed) {\n toks.push({ t: 'class', re })\n i += consumed\n continue\n }\n }\n if (!noext && extTypes.includes(c) && p[i + 1] === '(') {\n toks.push({ t: 'open', type: c })\n i += 2\n continue\n }\n toks.push(\n !noext && c === '|' ? { t: 'bar' }\n : !noext && c === ')' ? { t: 'close' }\n : c === '*' ? { t: 'star' }\n : c === '?' ? { t: 'any' }\n : lit(c),\n )\n i += c.length\n }\n return toks\n}\n\n// map each open token index to the index of its close token\nconst pair = (toks: Token[]) => {\n const pairs = new Map<number, number>()\n const stack: number[] = []\n toks.forEach((tok, i) => {\n if (tok.t === 'open') stack.push(i)\n else if (tok.t === 'close' && stack.length) pairs.set(stack.pop()!, i)\n })\n return pairs\n}\n\n// build the alternatives between start and end. An open token that\n// is not closed is never inside a closed extglob, so bar and close\n// tokens are only literal at the top level.\nconst build = (\n toks: Token[],\n pairs: Map<number, number>,\n start: number,\n end: number,\n top: boolean,\n): Item[][] => {\n let seq: Item[] = []\n const alts = [seq]\n for (let i = start; i < end; i++) {\n const tok = toks[i]!\n const close = pairs.get(i)\n if (tok.t === 'open' && close !== undefined) {\n const sub = build(toks, pairs, i + 1, close, false)\n seq.push({ t: 'ext', type: tok.type, alts: sub })\n i = close\n } else if (tok.t === 'bar' && !top) {\n alts.push((seq = []))\n } else if (tok.t === 'open') {\n seq.push(lit(tok.type), lit('('))\n } else if (tok.t === 'bar') {\n seq.push(lit('|'))\n } else if (tok.t === 'close') {\n seq.push(lit(')'))\n } else {\n seq.push(tok)\n }\n }\n return alts\n}\n\n// normalize each run of literal chars as one string, so that a char\n// and the combining marks after it compose (or decompose) together.\n// Syntax is already parsed, so a char that normalizes to a syntax\n// char (such as full-width `*` in NFKC) stays a literal.\nconst normalize = (items: Item[], form: Form): Item[] => {\n const out: Item[] = []\n let run = ''\n const flush = () => {\n for (const ch of run.normalize(form)) out.push(lit(ch))\n run = ''\n }\n for (const it of items) {\n if (it.t === 'lit') {\n run += it.ch\n continue\n }\n flush()\n out.push(\n it.t === 'ext' ?\n { ...it, alts: it.alts.map(a => normalize(a, form)) }\n : it,\n )\n }\n flush()\n return out\n}\n\n// the start node, and the number of node ids. Ids are dense, from 0\n// for the match node.\nconst compile = (\n items: Item[],\n nocase: boolean,\n): [start: Node, size: number] => {\n let id = 1\n const split = (out: Node[]): SplitNode => ({ t: 'split', id: id++, out })\n const seq = (items: Item[], next: Node): Node =>\n items.reduceRight((next, it) => item(it, next), next)\n const item = (it: Item, next: Node): Node => {\n switch (it.t) {\n case 'lit':\n const re = nocase ? foldRe(it.ch) : undefined\n return { t: 'lit', id: id++, ch: it.ch, re, next }\n case 'any':\n case 'star':\n return { t: it.t, id: id++, next }\n case 'class':\n return { t: 'class', id: id++, re: it.re, next }\n }\n const alts = (next: Node) => it.alts.map(a => seq(a, next))\n switch (it.type) {\n case '@':\n return split(alts(next))\n case '?':\n return split([next, ...alts(next)])\n case '!':\n return { t: 'neg', id: id++, sub: split(alts(MATCH)), next }\n }\n // * and +, loop back after each match\n const after = split([])\n const entry = split(alts(after))\n after.out.push(next, entry)\n return it.type === '*' ? after : entry\n }\n const start = seq(items, MATCH)\n return [start, id]\n}\n\n// one line per node, in the order that a walk from the start\n// reaches them. Edges point to node ids. The nodes of a negated\n// sub-pattern are indented under their negation.\nconst show = (start: Node): string => {\n const lines: string[] = []\n const seen = new Set<Node>()\n const ref = (n: Node) => (n.t === 'match' ? 'match' : String(n.id))\n const walk = (n: Node, indent: string) => {\n if (n.t === 'match' || seen.has(n)) return\n seen.add(n)\n const line = (desc: string) => lines.push(`${indent}${n.id}: ${desc}`)\n switch (n.t) {\n case 'split':\n line(`split -> ${n.out.map(ref).join(', ')}`)\n for (const o of n.out) walk(o, indent)\n return\n case 'neg':\n line(`!(${ref(n.sub)}) -> ${ref(n.next)}`)\n walk(n.sub, indent + ' ')\n return walk(n.next, indent)\n case 'lit':\n line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`)\n break\n case 'class':\n line(`${n.re} -> ${ref(n.next)}`)\n break\n default:\n line(`${n.t === 'any' ? '?' : '*'} -> ${ref(n.next)}`)\n }\n walk(n.next, indent)\n }\n walk(start, '')\n return [`start -> ${ref(start)}`, ...lines].join('\\n')\n}\n\n// A thread inside a !(...) negation. It holds the threads of the\n// negated sub-pattern, started where the negation started. The\n// negation matches the chars so far if the sub-pattern does not.\ntype Run = { t: 'run'; neg: NegNode; state: State }\n\n// The threads at one position in the string. Each node thread is\n// only kept once, and runs with the same state are only kept once,\n// so that identical threads merge. The match node is not in\n// `threads`, because it can not step. It sets `match` instead.\nclass State {\n // set by the Sim, to mark the nodes that this state has\n gen: number\n threads: Node[] = []\n match = false\n runs: Run[] = []\n // the sorted ids of the threads, with 0 for a match, once the\n // state is done\n ids: number[] = []\n\n constructor(gen: number) {\n this.gen = gen\n }\n\n // no threads, so nothing more can match\n get dead() {\n return !this.threads.length && !this.match && !this.runs.length\n }\n}\n\n// true if the two states hold the same threads\nconst sameState = (a: State, b: State): boolean => {\n if (a.ids.length !== b.ids.length) return false\n if (a.runs.length !== b.runs.length) return false\n if (a.ids.some((id, i) => id !== b.ids[i])) return false\n return a.runs.every(r =>\n b.runs.some(o => o.neg === r.neg && sameState(o.state, r.state)),\n )\n}\n\n/**\n * For each node id, the gen of the last state that has the node as\n * a thread, and of the last state that walked through it. A state is\n * built to the end before the states around it go on, and the nodes\n * of a negated sub-pattern are only in its states (other than the\n * match node, which is never marked). So one mark for each node is\n * enough to know if the state being built has it. The Sims of a\n * matcher never run at the same time, so they share one Marks.\n */\nexport type Marks = { has: Float64Array; seen: Float64Array; gen: number }\n\nconst marks = (size: number): Marks => ({\n has: new Float64Array(size),\n seen: new Float64Array(size),\n gen: 0,\n})\n\nclass Sim {\n // `.` and `..` only match literal dots, even with `dot:true`\n dots: boolean\n // the string starts with `.`, and `dot:true` is not set\n dotStart: boolean\n #marks: Marks\n\n constructor(dots: boolean, dotStart: boolean, marks: Marks) {\n this.dots = dots\n this.dotStart = dotStart\n this.#marks = marks\n }\n\n state() {\n return new State(++this.#marks.gen)\n }\n\n // sort the ids of a state, once it has all of its threads\n done(state: State) {\n state.ids = state.threads.map(n => n.id).sort((a, b) => a - b)\n if (state.match) state.ids.unshift(MATCH.id)\n return state\n }\n\n // true the first time that the state walks through the node, so\n // that loops in the graph stop\n #visit(state: State, node: Node) {\n const { seen } = this.#marks\n if (seen[node.id] === state.gen) return false\n seen[node.id] = state.gen\n return true\n }\n\n #addThread(state: State, node: Node) {\n const { has } = this.#marks\n if (has[node.id] === state.gen) return false\n has[node.id] = state.gen\n state.threads.push(node)\n return true\n }\n\n // wildcards only match a leading dot if `dot:true`. In a negated\n // sub-pattern, this does not apply, because the negation itself\n // can not match a leading dot.\n restricted(i: number, top: boolean) {\n return top && (this.dots || (this.dotStart && i === 0))\n }\n\n add(state: State, node: Node, i: number, top: boolean): void {\n switch (node.t) {\n case 'split':\n if (!this.#visit(state, node)) return\n for (const o of node.out) this.add(state, o, i, top)\n return\n case 'neg':\n if (!this.#visit(state, node)) return\n const sub = this.state()\n this.add(sub, node.sub, i, false)\n this.done(sub)\n return this.addRun(\n state,\n { t: 'run', neg: node, state: sub },\n i,\n top,\n )\n case 'star':\n // a * can not start a dotfile, even if it matches nothing\n if (this.restricted(i, top)) return\n if (this.#addThread(state, node))\n this.add(state, node.next, i, top)\n return\n case 'match':\n state.match = true\n return\n default:\n this.#addThread(state, node)\n }\n }\n\n addRun(state: State, run: Run, i: number, top: boolean) {\n for (const r of state.runs) {\n if (r.neg === run.neg && sameState(r.state, run.state)) return\n }\n state.runs.push(run)\n if (!run.state.match) {\n this.add(state, run.neg.next, i, top)\n }\n }\n\n // the threads after char `c`, at index `i`\n step(state: State, c: string, i: number, top: boolean): State {\n const next = this.state()\n for (const th of state.threads) {\n switch (th.t) {\n case 'lit':\n if (litMatch(th, c)) {\n this.add(next, th.next, i + 1, top)\n }\n break\n case 'any':\n if (!this.restricted(i, top)) this.add(next, th.next, i + 1, top)\n break\n case 'class':\n if (!this.restricted(i, top) && th.re.test(c)) {\n this.add(next, th.next, i + 1, top)\n }\n break\n case 'star':\n if (!this.restricted(i, top)) this.add(next, th, i + 1, top)\n }\n }\n if (!this.restricted(i, top)) {\n for (const run of state.runs) {\n // a sub-pattern with no threads can not match again, so the\n // run stays the same\n if (run.state.dead) {\n this.addRun(next, run, i + 1, top)\n continue\n }\n const sub = this.step(run.state, c, i, false)\n this.addRun(\n next,\n { t: 'run', neg: run.neg, state: sub },\n i + 1,\n top,\n )\n }\n }\n return this.done(next)\n }\n}\n\n// A canonical key for the threads in a state. States with the same\n// key hold the same threads, so they match the same strings.\nconst stateKey = (state: State): string => {\n const ids = state.ids.join()\n if (!state.runs.length) return ids\n const runs = state.runs.map(r => `${r.neg.id}(${stateKey(r.state)})`)\n return `${ids}|${runs.sort().join('|')}`\n}\n\n// A cached state of the simulation, and the states that each char\n// leads to.\ntype DState = {\n state: State\n match: boolean\n // no threads, so nothing more can match\n dead: boolean\n // the next state for each ASCII char, by char code, and for the\n // other chars\n ascii?: (DState | undefined)[]\n next: Map<string, DState>\n}\n\n// The cache can hold about this many chars of state keys and\n// transitions. When it is full, it is cleared, so that a pattern\n// can not use an unbounded amount of memory.\nconst DFA_BUDGET = 1 << 18\n\n// A cache of the states that the simulation reaches, built as the\n// matcher is used. Each char of a string is then one Map lookup,\n// once the states that it leads to are known.\n//\n// The dot rules only restrict the first char of a dotfile (strings\n// that are only `.` or `..` do not use the cache). So a dotfile\n// starts at its own state, which takes its first step with the\n// restriction, and every other state takes steps without it.\nclass Dfa {\n #start: Node\n #states = new Map<string, DState>()\n #size = 0\n #plain?: DState\n #dotStart?: DState\n #sim: Sim\n #dotSim: Sim\n\n constructor(start: Node, marks: Marks) {\n this.#start = start\n this.#sim = new Sim(false, false, marks)\n this.#dotSim = new Sim(false, true, marks)\n }\n\n #make(state: State): DState {\n return {\n state,\n match: state.match,\n dead: state.dead,\n next: new Map(),\n }\n }\n\n #intern(state: State): DState {\n const key = stateKey(state)\n const found = this.#states.get(key)\n if (found) return found\n if (this.#size > DFA_BUDGET) this.#clear()\n const d = this.#make(state)\n this.#states.set(key, d)\n this.#size += key.length + 1\n return d\n }\n\n #clear() {\n this.#states.clear()\n this.#size = 0\n this.#plain = undefined\n this.#dotStart = undefined\n }\n\n start(dotStart: boolean): DState {\n if (dotStart) {\n if (this.#dotStart) return this.#dotStart\n const state = this.#dotSim.state()\n this.#dotSim.add(state, this.#start, 0, true)\n return (this.#dotStart = this.#make(this.#dotSim.done(state)))\n }\n if (this.#plain) return this.#plain\n const state = this.#sim.state()\n this.#sim.add(state, this.#start, 0, true)\n return (this.#plain = this.#intern(this.#sim.done(state)))\n }\n\n // the next state, after a miss in `d.ascii`\n next(d: DState, c: string): DState {\n const code = c.charCodeAt(0)\n const found = code < 128 ? undefined : d.next.get(c)\n if (found) return found\n // the dotfile start is not in the cache, so it is never shared\n const n =\n d === this.#dotStart ?\n this.#intern(this.#dotSim.step(d.state, c, 0, true))\n : this.#intern(this.#sim.step(d.state, c, 1, true))\n if (code < 128) {\n if (!d.ascii) {\n d.ascii = new Array(128)\n this.#size += 128\n }\n d.ascii[code] = n\n } else {\n d.next.set(c, n)\n }\n this.#size++\n return n\n }\n}\n\n/**\n * A node in a graph with no splits or negations. Such a graph is a\n * chain of nodes that each match one char, or a `*`.\n */\nexport type LinearNode = Exclude<\n Node,\n SplitNode | NegNode | { t: 'match' }\n>\n\n// the nodes in order, if the graph is a single chain\nconst linear = (start: Node): LinearNode[] | undefined => {\n const nodes: LinearNode[] = []\n for (let n = start; n.t !== 'match'; n = n.next) {\n if (n.t === 'split' || n.t === 'neg') return undefined\n nodes.push(n)\n }\n return nodes\n}\n\n// Match a chain of nodes. Each node other than `*` matches exactly\n// one char, so on a failure it is enough to go back to the last `*`\n// and let it match one more char. This takes at most\n// nodes.length * chars.length steps.\nconst testLinear = (\n nodes: LinearNode[],\n chars: ArrayLike<string>,\n start: number,\n end: number,\n) => {\n let ni = 0\n let ci = start\n let starNi = -1\n let starCi = 0\n while (ci < end) {\n const n = nodes[ni]\n if (n?.t === 'star') {\n starNi = ni++\n starCi = ci\n continue\n }\n const c = chars[ci]!\n if (\n n &&\n (n.t === 'any' ||\n (n.t === 'lit' && litMatch(n, c)) ||\n (n.t === 'class' && n.re.test(c)))\n ) {\n ni++\n ci++\n continue\n }\n if (starNi === -1) return false\n ni = starNi + 1\n ci = ++starCi\n }\n while (nodes[ni]?.t === 'star') ni++\n return ni === nodes.length\n}\n\n// The least and most chars that the items can match. These are only\n// bounds: a negation can match a string of any length, so it counts\n// as 0 to Infinity.\nconst lengths = (items: Item[]): [min: number, max: number] => {\n let min = 0\n let max = 0\n for (const it of items) {\n const [lo, hi] = itemLengths(it)\n min += lo\n max += hi\n }\n return [min, max]\n}\n\nconst itemLengths = (it: Item): [min: number, max: number] => {\n if (it.t === 'star') return [0, Infinity]\n if (it.t !== 'ext') return [1, 1]\n if (it.type === '!') return [0, Infinity]\n const alts = it.alts.map(lengths)\n const min = Math.min(...alts.map(a => a[0]))\n const max = Math.max(...alts.map(a => a[1]))\n // a loop of alternatives that only match the empty string is empty\n const loop = max === 0 ? 0 : Infinity\n return (\n it.type === '@' ? [min, max]\n : it.type === '?' ? [0, max]\n : it.type === '*' ? [0, loop]\n : [min, loop]\n )\n}\n\n// true if the chars from `start` match the literals\nconst hasAffix = (\n lits: Lit[],\n chars: ArrayLike<string>,\n start: number,\n) => {\n for (let j = 0; j < lits.length; j++) {\n if (!litMatch(lits[j]!, chars[start + j]!)) return false\n }\n return true\n}\n\n// a `/`, or half of a surrogate pair\nconst slashOrSurrogate = /[/\\ud800-\\udfff]/\nconst surrogate = /[\\ud800-\\udfff]/\n\n// a string can be indexed by code point, unless it has surrogate\n// pairs\nconst codePoints = (s: string): ArrayLike<string> =>\n surrogate.test(s) ? [...s] : s\n\nconst noSlash = (s: string) => {\n if (s.includes('/')) {\n throw new Error('can only match a single path portion, got: ' + s)\n }\n}\n\nexport class Matcher {\n pattern: string\n options: MatcherOptions\n #start: Node\n // the number of node ids\n #size: number\n #marks?: Marks\n // the Sim for strings that are only `.` or `..`\n #dotsSim?: Sim\n // the string to compare, if the pattern has no magic. With\n // `nocase:true`, the RegExp that folds case is made when it is\n // first used.\n #literal?: string\n #literalFold = false\n #literalRe?: RegExp\n // the nodes between the prefix and suffix, if the graph is a\n // single chain\n #linear?: LinearNode[]\n // the linear nodes are only `*` and `?`, so the length bounds and\n // the prefix and suffix decide the match\n #wild = false\n // the least and most chars that a match can have\n #min = 0\n #max = Infinity\n // the literals that a match must start and end with. Each one\n // matches exactly one char, and they are distinct items in the\n // pattern, so a string that does not have them can not match.\n #prefix: Lit[] = []\n #suffix: Lit[] = []\n // the prefix and suffix as strings, if they do not fold case\n #prefixStr?: string\n #suffixStr?: string\n // there is a prefix or suffix to check\n #affix = false\n #dfa?: Dfa\n #form?: Form\n\n constructor(pattern: string, options: MatcherOptions = {}) {\n if (pattern.includes('/')) {\n throw new Error(\n 'can only match a single path portion, got pattern: ' + pattern,\n )\n }\n this.pattern = pattern\n this.options = options\n const { nocase = false, noext = false, normalize: n } = options\n this.#form = n === true ? 'NFC' : n || undefined\n // a pattern that is only an empty extglob is a literal string,\n // except for `!()`, which matches any non-empty string\n const literal = /^[?*+@]\\(\\)$/.test(pattern)\n const toks = tokenize(pattern, nocase, noext || literal, this.#form)\n let [items] = build(toks, pair(toks), 0, toks.length, true)\n if (this.#form) items = normalize(items!, this.#form)\n const [start, size] = compile(items!, nocase)\n this.#start = start\n this.#size = size\n if (items!.every(it => it.t === 'lit')) {\n this.#literal = items!.map(it => it.ch).join('')\n this.#literalFold = nocase\n } else {\n const lit = (it: Item): Lit | undefined =>\n it.t !== 'lit' ? undefined\n : nocase ? { ch: it.ch, re: foldRe(it.ch) }\n : { ch: it.ch }\n for (const it of items!) {\n const l = lit(it)\n if (!l) break\n this.#prefix.push(l)\n }\n for (let j = items!.length - 1; j >= 0; j--) {\n const l = lit(items![j]!)\n if (!l) break\n this.#suffix.unshift(l)\n }\n this.#affix = !!(this.#prefix.length || this.#suffix.length)\n if (!nocase) {\n this.#prefixStr = this.#prefix.map(l => l.ch).join('')\n this.#suffixStr = this.#suffix.map(l => l.ch).join('')\n }\n this.#linear = linear(this.#start)?.slice(\n this.#prefix.length,\n -this.#suffix.length || undefined,\n )\n this.#wild = !!this.#linear?.every(\n n => n.t === 'star' || n.t === 'any',\n )\n const [min, max] = lengths(items!)\n this.#min = min\n this.#max = max\n }\n }\n\n test(s: string): boolean {\n // The `/` check uses the string as given, so with normalization it\n // is a separate step. Otherwise, one scan finds both a `/` and the\n // surrogate pairs that stop the string being indexed by code point.\n if (this.#form) {\n noSlash(s)\n return this.#test(s.normalize(this.#form))\n }\n if (slashOrSurrogate.test(s)) {\n noSlash(s)\n return this.#test(s, [...s])\n }\n return this.#test(s, s)\n }\n\n /**\n * The same as {@link Matcher#test}, but the string is not checked\n * for `/` chars, so the result for a string that has one is not\n * defined. Only use it for a string that is known to be one path\n * portion, such as a part of a path that was split on `/`. It can\n * be faster, because some patterns do not need to look at each char\n * of the string.\n */\n testUnchecked(s: string): boolean {\n return this.#test(this.#form ? s.normalize(this.#form) : s)\n }\n\n // Test a string that has no `/`. `chars` indexes it by code point.\n // If it is not given, it is only found if a step needs it.\n #test(s: string, chars?: ArrayLike<string>): boolean {\n if (this.#literal !== undefined) {\n return this.#literalFold ?\n (this.#literalRe ??= newFoldRe(this.#literal)).test(s)\n : s === this.#literal\n }\n // the length check means that the prefix and suffix do not\n // overlap. Without the chars, the length in code points is from\n // half of the UTF-16 length (if each one is a surrogate pair) to\n // all of it, which is often enough to know.\n const min = this.#min\n const max = this.#max\n if (chars === undefined) {\n const most = s.length\n const least = (most + 1) >> 1\n if (most < min || least > max) return false\n if (least < min || most > max) chars = codePoints(s)\n }\n if (\n chars !== undefined &&\n (chars.length < min || chars.length > max)\n ) {\n return false\n }\n const prefix = this.#prefix.length\n if (this.#affix) {\n if (this.#prefixStr !== undefined && this.#suffixStr !== undefined) {\n if (\n !s.startsWith(this.#prefixStr) ||\n !s.endsWith(this.#suffixStr)\n ) {\n return false\n }\n } else {\n chars ??= codePoints(s)\n const end = chars.length - this.#suffix.length\n if (\n !hasAffix(this.#prefix, chars, 0) ||\n !hasAffix(this.#suffix, chars, end)\n ) {\n return false\n }\n }\n }\n const dotStart = !this.options.dot && s.startsWith('.')\n if (this.#linear) {\n // `.` and `..` only match literal dots, even with `dot:true`\n if (s === '.' || s === '..') return false\n // only a literal can match the leading dot. A `*` can not\n // start a dotfile, even if it matches nothing.\n if (dotStart && !prefix) return false\n if (this.#wild) return true\n chars ??= codePoints(s)\n const end = chars.length - this.#suffix.length\n return testLinear(this.#linear, chars, prefix, end)\n }\n chars ??= codePoints(s)\n if (s === '.' || s === '..') {\n this.#marks ??= marks(this.#size)\n const sim = (this.#dotsSim ??= new Sim(true, false, this.#marks))\n const start = sim.state()\n sim.add(start, this.#start, 0, true)\n let state = sim.done(start)\n for (let i = 0; i < chars.length; i++) {\n state = sim.step(state, chars[i]!, i, true)\n }\n return state.match\n }\n this.#marks ??= marks(this.#size)\n const dfa = (this.#dfa ??= new Dfa(this.#start, this.#marks))\n let d = dfa.start(dotStart)\n // read char codes from the string, so that a one-char string is\n // only made for a cache miss\n const str = chars === s\n for (let i = 0; i < chars.length; i++) {\n if (d.dead) return false\n const code = str ? s.charCodeAt(i) : chars[i]!.charCodeAt(0)\n d = d.ascii?.[code] ?? dfa.next(d, chars[i]!)\n }\n return d.match\n }\n\n /** a readable listing of the state machine */\n toString(): string {\n return show(this.#start)\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ var D={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}"],"[:alpha:]":["\\p{L}\\p{Nl}"],"[:ascii:]":["\\x00-\\x7f"],"[:blank:]":["\\p{Zs}\\t"],"[:cntrl:]":["\\p{Cc}"],"[:digit:]":["\\p{Nd}"],"[:graph:]":["\\p{Z}\\p{C}",!0],"[:lower:]":["\\p{Ll}"],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}\\p{S}"],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f"],"[:upper:]":["\\p{Lu}"],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],"[:xdigit:]":["A-Fa-f0-9"]},y=i=>i.replace(/[[\]\\-]/g,"\\$&"),A=/$./,E=(i,t,e=!1,s)=>{let h=p=>{let m=s?p.normalize(s):p;return[...m].length===1?m:p},n=t;if(i.charAt(n)!=="[")throw new Error("not in a brace expression");let o=[],a=[],r=n+1,l=!1,c=!1,u=!1,g=n,d="";t:for(;r<i.length;){let p=String.fromCodePoint(i.codePointAt(r));if((p==="!"||p==="^")&&r===n+1){u=!0,r++;continue}if(p==="]"&&l&&!c){g=r+1;break}if(l=!0,p==="\\"&&!c){c=!0,r++;continue}if(p==="["&&!c){for(let[z,[R,B]]of Object.entries(D))if(i.startsWith(z,r)){if(d)return[A,i.length-n];r+=z.length,B?a.push(R):o.push(R);continue t}}c=!1;let m=h(p);if(d){m.codePointAt(0)>d.codePointAt(0)?o.push(y(d)+"-"+y(m)):m===d&&o.push(y(m)),d="",r+=p.length;continue}if(i.startsWith("-]",r+p.length)){o.push(y(m+"-")),r+=p.length+1;continue}if(i.startsWith("-",r+p.length)){d=m,r+=p.length+1;continue}o.push(y(m)),r+=p.length}if(g<r)return[A,0];if(!o.length&&!a.length)return[A,i.length-n];let f="["+(u?"^":"")+o.join("")+"]",w="["+(u?"":"^")+a.join("")+"]",q="^"+(o.length&&a.length?"("+f+"|"+w+")":o.length?f:w);return[new RegExp(q,e?"iu":"u"),g-n]};var C={t:"match",id:0},G="!?+*@",x=i=>({t:"lit",ch:i}),H=i=>i.replace(/[\\^$.*+?()[\]{}|/]/g,"\\$&"),W=i=>new RegExp(`^${H(i)}$`,"iu"),S=new Map,v=i=>{let t=S.get(i);return t||(t=W(i),S.size>=1e3&&S.clear(),S.set(i,t)),t},P=(i,t)=>{if(t===i.ch)return!0;if(!i.re)return!1;let e=t.charCodeAt(0);if(e>=128)return i.re.test(t);let s=i.ascii??=new Uint8Array(128);return s[e]||=i.re.test(t)?1:2,s[e]===1},J=(i,t,e,s)=>{let h=[];for(let n=0;n<i.length;){let o=String.fromCodePoint(i.codePointAt(n));if(o==="\\"){let a=i.codePointAt(n+1),r=a===void 0?o:String.fromCodePoint(a);h.push(x(r)),n+=1+r.length;continue}if(o==="["){let[a,r]=E(i,n,t,s);if(r){h.push({t:"class",re:a}),n+=r;continue}}if(!e&&G.includes(o)&&i[n+1]==="("){h.push({t:"open",type:o}),n+=2;continue}h.push(!e&&o==="|"?{t:"bar"}:!e&&o===")"?{t:"close"}:o==="*"?{t:"star"}:o==="?"?{t:"any"}:x(o)),n+=o.length}return h},K=i=>{let t=new Map,e=[];return i.forEach((s,h)=>{s.t==="open"?e.push(h):s.t==="close"&&e.length&&t.set(e.pop(),h)}),t},I=(i,t,e,s,h)=>{let n=[],o=[n];for(let a=e;a<s;a++){let r=i[a],l=t.get(a);if(r.t==="open"&&l!==void 0){let c=I(i,t,a+1,l,!1);n.push({t:"ext",type:r.type,alts:c}),a=l}else r.t==="bar"&&!h?o.push(n=[]):r.t==="open"?n.push(x(r.type),x("(")):r.t==="bar"?n.push(x("|")):r.t==="close"?n.push(x(")")):n.push(r)}return o},T=(i,t)=>{let e=[],s="",h=()=>{for(let n of s.normalize(t))e.push(x(n));s=""};for(let n of i){if(n.t==="lit"){s+=n.ch;continue}h(),e.push(n.t==="ext"?{...n,alts:n.alts.map(o=>T(o,t))}:n)}return h(),e},_=(i,t)=>{let e=1,s=a=>({t:"split",id:e++,out:a}),h=(a,r)=>a.reduceRight((l,c)=>n(c,l),r),n=(a,r)=>{switch(a.t){case"lit":let g=t?v(a.ch):void 0;return{t:"lit",id:e++,ch:a.ch,re:g,next:r};case"any":case"star":return{t:a.t,id:e++,next:r};case"class":return{t:"class",id:e++,re:a.re,next:r}}let l=g=>a.alts.map(d=>h(d,g));switch(a.type){case"@":return s(l(r));case"?":return s([r,...l(r)]);case"!":return{t:"neg",id:e++,sub:s(l(C)),next:r}}let c=s([]),u=s(l(c));return c.out.push(r,u),a.type==="*"?c:u};return[h(i,C),e]},Q=i=>{let t=[],e=new Set,s=n=>n.t==="match"?"match":String(n.id),h=(n,o)=>{if(n.t==="match"||e.has(n))return;e.add(n);let a=r=>t.push(`${o}${n.id}: ${r}`);switch(n.t){case"split":a(`split -> ${n.out.map(s).join(", ")}`);for(let r of n.out)h(r,o);return;case"neg":return a(`!(${s(n.sub)}) -> ${s(n.next)}`),h(n.sub,o+" "),h(n.next,o);case"lit":a(`${JSON.stringify(n.ch)} -> ${s(n.next)}`);break;case"class":a(`${n.re} -> ${s(n.next)}`);break;default:a(`${n.t==="any"?"?":"*"} -> ${s(n.next)}`)}h(n.next,o)};return h(i,""),[`start -> ${s(i)}`,...t].join(`
2
+ `)},b=class{gen;threads=[];match=!1;runs=[];ids=[];constructor(t){this.gen=t}get dead(){return!this.threads.length&&!this.match&&!this.runs.length}},O=(i,t)=>i.ids.length!==t.ids.length||i.runs.length!==t.runs.length||i.ids.some((e,s)=>e!==t.ids[s])?!1:i.runs.every(e=>t.runs.some(s=>s.neg===e.neg&&O(s.state,e.state))),N=i=>({has:new Float64Array(i),seen:new Float64Array(i),gen:0}),$=class{dots;dotStart;#t;constructor(t,e,s){this.dots=t,this.dotStart=e,this.#t=s}state(){return new b(++this.#t.gen)}done(t){return t.ids=t.threads.map(e=>e.id).sort((e,s)=>e-s),t.match&&t.ids.unshift(C.id),t}#s(t,e){let{seen:s}=this.#t;return s[e.id]===t.gen?!1:(s[e.id]=t.gen,!0)}#e(t,e){let{has:s}=this.#t;return s[e.id]===t.gen?!1:(s[e.id]=t.gen,t.threads.push(e),!0)}restricted(t,e){return e&&(this.dots||this.dotStart&&t===0)}add(t,e,s,h){switch(e.t){case"split":if(!this.#s(t,e))return;for(let o of e.out)this.add(t,o,s,h);return;case"neg":if(!this.#s(t,e))return;let n=this.state();return this.add(n,e.sub,s,!1),this.done(n),this.addRun(t,{t:"run",neg:e,state:n},s,h);case"star":if(this.restricted(s,h))return;this.#e(t,e)&&this.add(t,e.next,s,h);return;case"match":t.match=!0;return;default:this.#e(t,e)}}addRun(t,e,s,h){for(let n of t.runs)if(n.neg===e.neg&&O(n.state,e.state))return;t.runs.push(e),e.state.match||this.add(t,e.neg.next,s,h)}step(t,e,s,h){let n=this.state();for(let o of t.threads)switch(o.t){case"lit":P(o,e)&&this.add(n,o.next,s+1,h);break;case"any":this.restricted(s,h)||this.add(n,o.next,s+1,h);break;case"class":!this.restricted(s,h)&&o.re.test(e)&&this.add(n,o.next,s+1,h);break;case"star":this.restricted(s,h)||this.add(n,o,s+1,h)}if(!this.restricted(s,h))for(let o of t.runs){if(o.state.dead){this.addRun(n,o,s+1,h);continue}let a=this.step(o.state,e,s,!1);this.addRun(n,{t:"run",neg:o.neg,state:a},s+1,h)}return this.done(n)}},U=i=>{let t=i.ids.join();if(!i.runs.length)return t;let e=i.runs.map(s=>`${s.neg.id}(${U(s.state)})`);return`${t}|${e.sort().join("|")}`},V=1<<18,j=class{#t;#s=new Map;#e=0;#c;#n;#i;#h;constructor(t,e){this.#t=t,this.#i=new $(!1,!1,e),this.#h=new $(!1,!0,e)}#o(t){return{state:t,match:t.match,dead:t.dead,next:new Map}}#u(t){let e=U(t),s=this.#s.get(e);if(s)return s;this.#e>V&&this.#f();let h=this.#o(t);return this.#s.set(e,h),this.#e+=e.length+1,h}#f(){this.#s.clear(),this.#e=0,this.#c=void 0,this.#n=void 0}start(t){if(t){if(this.#n)return this.#n;let s=this.#h.state();return this.#h.add(s,this.#t,0,!0),this.#n=this.#o(this.#h.done(s))}if(this.#c)return this.#c;let e=this.#i.state();return this.#i.add(e,this.#t,0,!0),this.#c=this.#u(this.#i.done(e))}next(t,e){let s=e.charCodeAt(0),h=s<128?void 0:t.next.get(e);if(h)return h;let n=t===this.#n?this.#u(this.#h.step(t.state,e,0,!0)):this.#u(this.#i.step(t.state,e,1,!0));return s<128?(t.ascii||(t.ascii=new Array(128),this.#e+=128),t.ascii[s]=n):t.next.set(e,n),this.#e++,n}},X=i=>{let t=[];for(let e=i;e.t!=="match";e=e.next){if(e.t==="split"||e.t==="neg")return;t.push(e)}return t},Y=(i,t,e,s)=>{let h=0,n=e,o=-1,a=0;for(;n<s;){let r=i[h];if(r?.t==="star"){o=h++,a=n;continue}let l=t[n];if(r&&(r.t==="any"||r.t==="lit"&&P(r,l)||r.t==="class"&&r.re.test(l))){h++,n++;continue}if(o===-1)return!1;h=o+1,n=++a}for(;i[h]?.t==="star";)h++;return h===i.length},Z=i=>{let t=0,e=0;for(let s of i){let[h,n]=tt(s);t+=h,e+=n}return[t,e]},tt=i=>{if(i.t==="star")return[0,1/0];if(i.t!=="ext")return[1,1];if(i.type==="!")return[0,1/0];let t=i.alts.map(Z),e=Math.min(...t.map(n=>n[0])),s=Math.max(...t.map(n=>n[1])),h=s===0?0:1/0;return i.type==="@"?[e,s]:i.type==="?"?[0,s]:i.type==="*"?[0,h]:[e,h]},M=(i,t,e)=>{for(let s=0;s<i.length;s++)if(!P(i[s],t[e+s]))return!1;return!0},et=/[/\ud800-\udfff]/,st=/[\ud800-\udfff]/,k=i=>st.test(i)?[...i]:i,F=i=>{if(i.includes("/"))throw new Error("can only match a single path portion, got: "+i)},L=class{pattern;options;#t;#s;#e;#c;#n;#i=!1;#h;#o;#u=!1;#f=0;#m=1/0;#l=[];#a=[];#p;#g;#w=!1;#x;#r;constructor(t,e={}){if(t.includes("/"))throw new Error("can only match a single path portion, got pattern: "+t);this.pattern=t,this.options=e;let{nocase:s=!1,noext:h=!1,normalize:n}=e;this.#r=n===!0?"NFC":n||void 0;let o=/^[?*+@]\(\)$/.test(t),a=J(t,s,h||o,this.#r),[r]=I(a,K(a),0,a.length,!0);this.#r&&(r=T(r,this.#r));let[l,c]=_(r,s);if(this.#t=l,this.#s=c,r.every(u=>u.t==="lit"))this.#n=r.map(u=>u.ch).join(""),this.#i=s;else{let u=f=>f.t!=="lit"?void 0:s?{ch:f.ch,re:v(f.ch)}:{ch:f.ch};for(let f of r){let w=u(f);if(!w)break;this.#l.push(w)}for(let f=r.length-1;f>=0;f--){let w=u(r[f]);if(!w)break;this.#a.unshift(w)}this.#w=!!(this.#l.length||this.#a.length),s||(this.#p=this.#l.map(f=>f.ch).join(""),this.#g=this.#a.map(f=>f.ch).join("")),this.#o=X(this.#t)?.slice(this.#l.length,-this.#a.length||void 0),this.#u=!!this.#o?.every(f=>f.t==="star"||f.t==="any");let[g,d]=Z(r);this.#f=g,this.#m=d}}test(t){return this.#r?(F(t),this.#d(t.normalize(this.#r))):et.test(t)?(F(t),this.#d(t,[...t])):this.#d(t,t)}testUnchecked(t){return this.#d(this.#r?t.normalize(this.#r):t)}#d(t,e){if(this.#n!==void 0)return this.#i?(this.#h??=W(this.#n)).test(t):t===this.#n;let s=this.#f,h=this.#m;if(e===void 0){let c=t.length,u=c+1>>1;if(c<s||u>h)return!1;(u<s||c>h)&&(e=k(t))}if(e!==void 0&&(e.length<s||e.length>h))return!1;let n=this.#l.length;if(this.#w)if(this.#p!==void 0&&this.#g!==void 0){if(!t.startsWith(this.#p)||!t.endsWith(this.#g))return!1}else{e??=k(t);let c=e.length-this.#a.length;if(!M(this.#l,e,0)||!M(this.#a,e,c))return!1}let o=!this.options.dot&&t.startsWith(".");if(this.#o){if(t==="."||t===".."||o&&!n)return!1;if(this.#u)return!0;e??=k(t);let c=e.length-this.#a.length;return Y(this.#o,e,n,c)}if(e??=k(t),t==="."||t===".."){this.#e??=N(this.#s);let c=this.#c??=new $(!0,!1,this.#e),u=c.state();c.add(u,this.#t,0,!0);let g=c.done(u);for(let d=0;d<e.length;d++)g=c.step(g,e[d],d,!0);return g.match}this.#e??=N(this.#s);let a=this.#x??=new j(this.#t,this.#e),r=a.start(o),l=e===t;for(let c=0;c<e.length;c++){if(r.dead)return!1;let u=l?t.charCodeAt(c):e[c].charCodeAt(0);r=r.ascii?.[u]??a.next(r,e[c])}return r.match}toString(){return Q(this.#t)}};export{L as Matcher};
3
+ //# sourceMappingURL=index.min.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/parse-class.ts", "../../src/index.ts"],
4
+ "sourcesContent": ["// translate the various posix character classes into unicode properties\n// this works across all unicode locales\n\n// { <posix class>: [<translation>, negated]\nconst posixClasses: { [k: string]: [e: string, n?: boolean] } = {\n '[:alnum:]': ['\\\\p{L}\\\\p{Nl}\\\\p{Nd}'],\n '[:alpha:]': ['\\\\p{L}\\\\p{Nl}'],\n '[:ascii:]': ['\\\\x' + '00-\\\\x' + '7f'],\n '[:blank:]': ['\\\\p{Zs}\\\\t'],\n '[:cntrl:]': ['\\\\p{Cc}'],\n '[:digit:]': ['\\\\p{Nd}'],\n '[:graph:]': ['\\\\p{Z}\\\\p{C}', true],\n '[:lower:]': ['\\\\p{Ll}'],\n '[:print:]': ['\\\\p{C}', true],\n '[:punct:]': ['\\\\p{P}\\\\p{S}'],\n '[:space:]': ['\\\\p{Z}\\\\t\\\\r\\\\n\\\\v\\\\f'],\n '[:upper:]': ['\\\\p{Lu}'],\n '[:word:]': ['\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}'],\n '[:xdigit:]': ['A-Fa-f0-9'],\n}\n\n// only need to escape a few things inside of brace expressions\n// escapes: [ \\ ] -\nconst braceEscape = (s: string) => s.replace(/[[\\]\\\\-]/g, '\\\\$&')\n\nexport type ParseClassResult = [re: RegExp, consumed: number]\n\nexport type Form = 'NFC' | 'NFD' | 'NFKC' | 'NFKD'\n\nconst noMatch = /$./\n\n// Takes a glob string at a posix brace expression. Returns a RegExp\n// that tests one character, and the number of glob chars consumed.\n// If the class is not closed, consumed is 0, and the `[` must be\n// treated as a literal character.\n// Out of order ranges are removed. If nothing is left, the RegExp\n// is `/$./`, and the rest of the glob is consumed, so that the\n// whole glob cannot match.\nexport const parseClass = (\n glob: string,\n position: number,\n nocase: boolean = false,\n form?: Form,\n): ParseClassResult => {\n // normalize one class member, if it stays one code point\n const norm = (c: string) => {\n const n = form ? c.normalize(form) : c\n return [...n].length === 1 ? n : c\n }\n const pos = position\n /* c8 ignore start */\n if (glob.charAt(pos) !== '[') {\n throw new Error('not in a brace expression')\n }\n /* c8 ignore stop */\n const ranges: string[] = []\n const negs: string[] = []\n\n let i = pos + 1\n let sawStart = false\n let escaping = false\n let negate = false\n let endPos = pos\n let rangeStart = ''\n WHILE: while (i < glob.length) {\n const c = String.fromCodePoint(glob.codePointAt(i)!)\n if ((c === '!' || c === '^') && i === pos + 1) {\n negate = true\n i++\n continue\n }\n\n if (c === ']' && sawStart && !escaping) {\n endPos = i + 1\n break\n }\n\n sawStart = true\n if (c === '\\\\') {\n if (!escaping) {\n escaping = true\n i++\n continue\n }\n // escaped \\ char, fall through and treat like normal char\n }\n if (c === '[' && !escaping) {\n // either a posix class, a collation equivalent, or just a [\n for (const [cls, [unip, neg]] of Object.entries(posixClasses)) {\n if (glob.startsWith(cls, i)) {\n // invalid, [a-[] is fine, but not [a-[:alpha]]\n if (rangeStart) {\n return [noMatch, glob.length - pos]\n }\n i += cls.length\n if (neg) negs.push(unip)\n else ranges.push(unip)\n continue WHILE\n }\n }\n }\n\n // now it's just a normal character, effectively\n escaping = false\n const n = norm(c)\n if (rangeStart) {\n // throw this range away if it's not valid, but others\n // can still match.\n if (n.codePointAt(0)! > rangeStart.codePointAt(0)!) {\n ranges.push(braceEscape(rangeStart) + '-' + braceEscape(n))\n } else if (n === rangeStart) {\n ranges.push(braceEscape(n))\n }\n rangeStart = ''\n i += c.length\n continue\n }\n\n // now might be the start of a range.\n // can be either c-d or c-] or c<more...>] or c] at this point\n if (glob.startsWith('-]', i + c.length)) {\n ranges.push(braceEscape(n + '-'))\n i += c.length + 1\n continue\n }\n if (glob.startsWith('-', i + c.length)) {\n rangeStart = n\n i += c.length + 1\n continue\n }\n\n // not the start of a range, just a single character\n ranges.push(braceEscape(n))\n i += c.length\n }\n\n if (endPos < i) {\n // didn't see the end of the class, not a valid class,\n // but might still be valid as a literal match.\n return [noMatch, 0]\n }\n\n // if we got no ranges and no negates, then we have a range that\n // cannot possibly match anything, and that poisons the whole glob\n if (!ranges.length && !negs.length) {\n return [noMatch, glob.length - pos]\n }\n\n const sranges = '[' + (negate ? '^' : '') + ranges.join('') + ']'\n const snegs = '[' + (negate ? '' : '^') + negs.join('') + ']'\n const comb =\n '^' +\n (ranges.length && negs.length ? '(' + sranges + '|' + snegs + ')'\n : ranges.length ? sranges\n : snegs)\n\n return [new RegExp(comb, nocase ? 'iu' : 'u'), endPos - pos]\n}\n", "import { type Form, parseClass } from './parse-class.js'\n\nexport type { Form }\n\nexport type MatcherOptions = {\n /** perform a case-insensitive match */\n nocase?: boolean\n /** do not treat strings starting with `.` specially */\n dot?: boolean\n /** do not match extglobs (treat them as normal strings) */\n noext?: boolean\n /**\n * normalize unicode in the pattern and the tested strings, with\n * this form. `true` means `'NFC'`.\n */\n normalize?: boolean | Form\n}\n\n// parsed pattern items\nexport type Item =\n | { t: 'lit'; ch: string }\n | { t: 'any' | 'star' }\n | { t: 'class'; re: RegExp }\n | { t: 'ext'; type: string; alts: Item[][] }\n\n// extglob syntax tokens become literals if they are not part of a\n// closed extglob\nexport type Token =\n Item | { t: 'open'; type: string } | { t: 'bar' } | { t: 'close' }\n\n// state machine nodes\nexport type NegNode = { t: 'neg'; id: number; sub: Node; next: Node }\nexport type SplitNode = { t: 'split'; id: number; out: Node[] }\nexport type Node =\n | ({ t: 'lit'; id: number; next: Node } & Lit)\n | { t: 'any' | 'star'; id: number; next: Node }\n | { t: 'class'; id: number; re: RegExp; next: Node }\n | SplitNode\n | NegNode\n | { t: 'match'; id: number }\n\n// the end of the pattern, or of a negated sub-pattern\nconst MATCH: Node = { t: 'match', id: 0 }\n\nconst extTypes = '!?+*@'\n\nconst lit = (ch: string): Item => ({ t: 'lit', ch })\n\nconst reEscape = (s: string) => s.replace(/[\\\\^$.*+?()[\\]{}|/]/g, '\\\\$&')\n\n// a RegExp that only matches `s`, with unicode case folding\nconst newFoldRe = (s: string) => new RegExp(`^${reEscape(s)}$`, 'iu')\n\n// foldRe for one literal char. The same chars are in most patterns,\n// so keep them. A RegExp without the `g` or `y` flag has no state to\n// share.\nconst foldCache = new Map<string, RegExp>()\nconst foldRe = (ch: string) => {\n let re = foldCache.get(ch)\n if (!re) {\n re = newFoldRe(ch)\n if (foldCache.size >= 1000) foldCache.clear()\n foldCache.set(ch, re)\n }\n return re\n}\n\n/**\n * A literal char. With `nocase:true`, `re` folds case, and `ascii`\n * holds its results for ASCII chars, by char code: 1 for a match,\n * and 2 for not.\n */\nexport type Lit = { ch: string; re?: RegExp; ascii?: Uint8Array }\n\nconst litMatch = (l: Lit, c: string) => {\n if (c === l.ch) return true\n if (!l.re) return false\n const code = c.charCodeAt(0)\n if (code >= 128) return l.re.test(c)\n const ascii = (l.ascii ??= new Uint8Array(128))\n ascii[code] ||= l.re.test(c) ? 1 : 2\n return ascii[code] === 1\n}\n\nconst tokenize = (\n p: string,\n nocase: boolean,\n noext: boolean,\n form?: Form,\n) => {\n const toks: Token[] = []\n for (let i = 0; i < p.length;) {\n const c = String.fromCodePoint(p.codePointAt(i)!)\n if (c === '\\\\') {\n // a trailing \\ is a literal \\\n const e = p.codePointAt(i + 1)\n const ch = e === undefined ? c : String.fromCodePoint(e)\n toks.push(lit(ch))\n i += 1 + ch.length\n continue\n }\n if (c === '[') {\n const [re, consumed] = parseClass(p, i, nocase, form)\n if (consumed) {\n toks.push({ t: 'class', re })\n i += consumed\n continue\n }\n }\n if (!noext && extTypes.includes(c) && p[i + 1] === '(') {\n toks.push({ t: 'open', type: c })\n i += 2\n continue\n }\n toks.push(\n !noext && c === '|' ? { t: 'bar' }\n : !noext && c === ')' ? { t: 'close' }\n : c === '*' ? { t: 'star' }\n : c === '?' ? { t: 'any' }\n : lit(c),\n )\n i += c.length\n }\n return toks\n}\n\n// map each open token index to the index of its close token\nconst pair = (toks: Token[]) => {\n const pairs = new Map<number, number>()\n const stack: number[] = []\n toks.forEach((tok, i) => {\n if (tok.t === 'open') stack.push(i)\n else if (tok.t === 'close' && stack.length) pairs.set(stack.pop()!, i)\n })\n return pairs\n}\n\n// build the alternatives between start and end. An open token that\n// is not closed is never inside a closed extglob, so bar and close\n// tokens are only literal at the top level.\nconst build = (\n toks: Token[],\n pairs: Map<number, number>,\n start: number,\n end: number,\n top: boolean,\n): Item[][] => {\n let seq: Item[] = []\n const alts = [seq]\n for (let i = start; i < end; i++) {\n const tok = toks[i]!\n const close = pairs.get(i)\n if (tok.t === 'open' && close !== undefined) {\n const sub = build(toks, pairs, i + 1, close, false)\n seq.push({ t: 'ext', type: tok.type, alts: sub })\n i = close\n } else if (tok.t === 'bar' && !top) {\n alts.push((seq = []))\n } else if (tok.t === 'open') {\n seq.push(lit(tok.type), lit('('))\n } else if (tok.t === 'bar') {\n seq.push(lit('|'))\n } else if (tok.t === 'close') {\n seq.push(lit(')'))\n } else {\n seq.push(tok)\n }\n }\n return alts\n}\n\n// normalize each run of literal chars as one string, so that a char\n// and the combining marks after it compose (or decompose) together.\n// Syntax is already parsed, so a char that normalizes to a syntax\n// char (such as full-width `*` in NFKC) stays a literal.\nconst normalize = (items: Item[], form: Form): Item[] => {\n const out: Item[] = []\n let run = ''\n const flush = () => {\n for (const ch of run.normalize(form)) out.push(lit(ch))\n run = ''\n }\n for (const it of items) {\n if (it.t === 'lit') {\n run += it.ch\n continue\n }\n flush()\n out.push(\n it.t === 'ext' ?\n { ...it, alts: it.alts.map(a => normalize(a, form)) }\n : it,\n )\n }\n flush()\n return out\n}\n\n// the start node, and the number of node ids. Ids are dense, from 0\n// for the match node.\nconst compile = (\n items: Item[],\n nocase: boolean,\n): [start: Node, size: number] => {\n let id = 1\n const split = (out: Node[]): SplitNode => ({ t: 'split', id: id++, out })\n const seq = (items: Item[], next: Node): Node =>\n items.reduceRight((next, it) => item(it, next), next)\n const item = (it: Item, next: Node): Node => {\n switch (it.t) {\n case 'lit':\n const re = nocase ? foldRe(it.ch) : undefined\n return { t: 'lit', id: id++, ch: it.ch, re, next }\n case 'any':\n case 'star':\n return { t: it.t, id: id++, next }\n case 'class':\n return { t: 'class', id: id++, re: it.re, next }\n }\n const alts = (next: Node) => it.alts.map(a => seq(a, next))\n switch (it.type) {\n case '@':\n return split(alts(next))\n case '?':\n return split([next, ...alts(next)])\n case '!':\n return { t: 'neg', id: id++, sub: split(alts(MATCH)), next }\n }\n // * and +, loop back after each match\n const after = split([])\n const entry = split(alts(after))\n after.out.push(next, entry)\n return it.type === '*' ? after : entry\n }\n const start = seq(items, MATCH)\n return [start, id]\n}\n\n// one line per node, in the order that a walk from the start\n// reaches them. Edges point to node ids. The nodes of a negated\n// sub-pattern are indented under their negation.\nconst show = (start: Node): string => {\n const lines: string[] = []\n const seen = new Set<Node>()\n const ref = (n: Node) => (n.t === 'match' ? 'match' : String(n.id))\n const walk = (n: Node, indent: string) => {\n if (n.t === 'match' || seen.has(n)) return\n seen.add(n)\n const line = (desc: string) => lines.push(`${indent}${n.id}: ${desc}`)\n switch (n.t) {\n case 'split':\n line(`split -> ${n.out.map(ref).join(', ')}`)\n for (const o of n.out) walk(o, indent)\n return\n case 'neg':\n line(`!(${ref(n.sub)}) -> ${ref(n.next)}`)\n walk(n.sub, indent + ' ')\n return walk(n.next, indent)\n case 'lit':\n line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`)\n break\n case 'class':\n line(`${n.re} -> ${ref(n.next)}`)\n break\n default:\n line(`${n.t === 'any' ? '?' : '*'} -> ${ref(n.next)}`)\n }\n walk(n.next, indent)\n }\n walk(start, '')\n return [`start -> ${ref(start)}`, ...lines].join('\\n')\n}\n\n// A thread inside a !(...) negation. It holds the threads of the\n// negated sub-pattern, started where the negation started. The\n// negation matches the chars so far if the sub-pattern does not.\ntype Run = { t: 'run'; neg: NegNode; state: State }\n\n// The threads at one position in the string. Each node thread is\n// only kept once, and runs with the same state are only kept once,\n// so that identical threads merge. The match node is not in\n// `threads`, because it can not step. It sets `match` instead.\nclass State {\n // set by the Sim, to mark the nodes that this state has\n gen: number\n threads: Node[] = []\n match = false\n runs: Run[] = []\n // the sorted ids of the threads, with 0 for a match, once the\n // state is done\n ids: number[] = []\n\n constructor(gen: number) {\n this.gen = gen\n }\n\n // no threads, so nothing more can match\n get dead() {\n return !this.threads.length && !this.match && !this.runs.length\n }\n}\n\n// true if the two states hold the same threads\nconst sameState = (a: State, b: State): boolean => {\n if (a.ids.length !== b.ids.length) return false\n if (a.runs.length !== b.runs.length) return false\n if (a.ids.some((id, i) => id !== b.ids[i])) return false\n return a.runs.every(r =>\n b.runs.some(o => o.neg === r.neg && sameState(o.state, r.state)),\n )\n}\n\n/**\n * For each node id, the gen of the last state that has the node as\n * a thread, and of the last state that walked through it. A state is\n * built to the end before the states around it go on, and the nodes\n * of a negated sub-pattern are only in its states (other than the\n * match node, which is never marked). So one mark for each node is\n * enough to know if the state being built has it. The Sims of a\n * matcher never run at the same time, so they share one Marks.\n */\nexport type Marks = { has: Float64Array; seen: Float64Array; gen: number }\n\nconst marks = (size: number): Marks => ({\n has: new Float64Array(size),\n seen: new Float64Array(size),\n gen: 0,\n})\n\nclass Sim {\n // `.` and `..` only match literal dots, even with `dot:true`\n dots: boolean\n // the string starts with `.`, and `dot:true` is not set\n dotStart: boolean\n #marks: Marks\n\n constructor(dots: boolean, dotStart: boolean, marks: Marks) {\n this.dots = dots\n this.dotStart = dotStart\n this.#marks = marks\n }\n\n state() {\n return new State(++this.#marks.gen)\n }\n\n // sort the ids of a state, once it has all of its threads\n done(state: State) {\n state.ids = state.threads.map(n => n.id).sort((a, b) => a - b)\n if (state.match) state.ids.unshift(MATCH.id)\n return state\n }\n\n // true the first time that the state walks through the node, so\n // that loops in the graph stop\n #visit(state: State, node: Node) {\n const { seen } = this.#marks\n if (seen[node.id] === state.gen) return false\n seen[node.id] = state.gen\n return true\n }\n\n #addThread(state: State, node: Node) {\n const { has } = this.#marks\n if (has[node.id] === state.gen) return false\n has[node.id] = state.gen\n state.threads.push(node)\n return true\n }\n\n // wildcards only match a leading dot if `dot:true`. In a negated\n // sub-pattern, this does not apply, because the negation itself\n // can not match a leading dot.\n restricted(i: number, top: boolean) {\n return top && (this.dots || (this.dotStart && i === 0))\n }\n\n add(state: State, node: Node, i: number, top: boolean): void {\n switch (node.t) {\n case 'split':\n if (!this.#visit(state, node)) return\n for (const o of node.out) this.add(state, o, i, top)\n return\n case 'neg':\n if (!this.#visit(state, node)) return\n const sub = this.state()\n this.add(sub, node.sub, i, false)\n this.done(sub)\n return this.addRun(\n state,\n { t: 'run', neg: node, state: sub },\n i,\n top,\n )\n case 'star':\n // a * can not start a dotfile, even if it matches nothing\n if (this.restricted(i, top)) return\n if (this.#addThread(state, node))\n this.add(state, node.next, i, top)\n return\n case 'match':\n state.match = true\n return\n default:\n this.#addThread(state, node)\n }\n }\n\n addRun(state: State, run: Run, i: number, top: boolean) {\n for (const r of state.runs) {\n if (r.neg === run.neg && sameState(r.state, run.state)) return\n }\n state.runs.push(run)\n if (!run.state.match) {\n this.add(state, run.neg.next, i, top)\n }\n }\n\n // the threads after char `c`, at index `i`\n step(state: State, c: string, i: number, top: boolean): State {\n const next = this.state()\n for (const th of state.threads) {\n switch (th.t) {\n case 'lit':\n if (litMatch(th, c)) {\n this.add(next, th.next, i + 1, top)\n }\n break\n case 'any':\n if (!this.restricted(i, top)) this.add(next, th.next, i + 1, top)\n break\n case 'class':\n if (!this.restricted(i, top) && th.re.test(c)) {\n this.add(next, th.next, i + 1, top)\n }\n break\n case 'star':\n if (!this.restricted(i, top)) this.add(next, th, i + 1, top)\n }\n }\n if (!this.restricted(i, top)) {\n for (const run of state.runs) {\n // a sub-pattern with no threads can not match again, so the\n // run stays the same\n if (run.state.dead) {\n this.addRun(next, run, i + 1, top)\n continue\n }\n const sub = this.step(run.state, c, i, false)\n this.addRun(\n next,\n { t: 'run', neg: run.neg, state: sub },\n i + 1,\n top,\n )\n }\n }\n return this.done(next)\n }\n}\n\n// A canonical key for the threads in a state. States with the same\n// key hold the same threads, so they match the same strings.\nconst stateKey = (state: State): string => {\n const ids = state.ids.join()\n if (!state.runs.length) return ids\n const runs = state.runs.map(r => `${r.neg.id}(${stateKey(r.state)})`)\n return `${ids}|${runs.sort().join('|')}`\n}\n\n// A cached state of the simulation, and the states that each char\n// leads to.\ntype DState = {\n state: State\n match: boolean\n // no threads, so nothing more can match\n dead: boolean\n // the next state for each ASCII char, by char code, and for the\n // other chars\n ascii?: (DState | undefined)[]\n next: Map<string, DState>\n}\n\n// The cache can hold about this many chars of state keys and\n// transitions. When it is full, it is cleared, so that a pattern\n// can not use an unbounded amount of memory.\nconst DFA_BUDGET = 1 << 18\n\n// A cache of the states that the simulation reaches, built as the\n// matcher is used. Each char of a string is then one Map lookup,\n// once the states that it leads to are known.\n//\n// The dot rules only restrict the first char of a dotfile (strings\n// that are only `.` or `..` do not use the cache). So a dotfile\n// starts at its own state, which takes its first step with the\n// restriction, and every other state takes steps without it.\nclass Dfa {\n #start: Node\n #states = new Map<string, DState>()\n #size = 0\n #plain?: DState\n #dotStart?: DState\n #sim: Sim\n #dotSim: Sim\n\n constructor(start: Node, marks: Marks) {\n this.#start = start\n this.#sim = new Sim(false, false, marks)\n this.#dotSim = new Sim(false, true, marks)\n }\n\n #make(state: State): DState {\n return {\n state,\n match: state.match,\n dead: state.dead,\n next: new Map(),\n }\n }\n\n #intern(state: State): DState {\n const key = stateKey(state)\n const found = this.#states.get(key)\n if (found) return found\n if (this.#size > DFA_BUDGET) this.#clear()\n const d = this.#make(state)\n this.#states.set(key, d)\n this.#size += key.length + 1\n return d\n }\n\n #clear() {\n this.#states.clear()\n this.#size = 0\n this.#plain = undefined\n this.#dotStart = undefined\n }\n\n start(dotStart: boolean): DState {\n if (dotStart) {\n if (this.#dotStart) return this.#dotStart\n const state = this.#dotSim.state()\n this.#dotSim.add(state, this.#start, 0, true)\n return (this.#dotStart = this.#make(this.#dotSim.done(state)))\n }\n if (this.#plain) return this.#plain\n const state = this.#sim.state()\n this.#sim.add(state, this.#start, 0, true)\n return (this.#plain = this.#intern(this.#sim.done(state)))\n }\n\n // the next state, after a miss in `d.ascii`\n next(d: DState, c: string): DState {\n const code = c.charCodeAt(0)\n const found = code < 128 ? undefined : d.next.get(c)\n if (found) return found\n // the dotfile start is not in the cache, so it is never shared\n const n =\n d === this.#dotStart ?\n this.#intern(this.#dotSim.step(d.state, c, 0, true))\n : this.#intern(this.#sim.step(d.state, c, 1, true))\n if (code < 128) {\n if (!d.ascii) {\n d.ascii = new Array(128)\n this.#size += 128\n }\n d.ascii[code] = n\n } else {\n d.next.set(c, n)\n }\n this.#size++\n return n\n }\n}\n\n/**\n * A node in a graph with no splits or negations. Such a graph is a\n * chain of nodes that each match one char, or a `*`.\n */\nexport type LinearNode = Exclude<\n Node,\n SplitNode | NegNode | { t: 'match' }\n>\n\n// the nodes in order, if the graph is a single chain\nconst linear = (start: Node): LinearNode[] | undefined => {\n const nodes: LinearNode[] = []\n for (let n = start; n.t !== 'match'; n = n.next) {\n if (n.t === 'split' || n.t === 'neg') return undefined\n nodes.push(n)\n }\n return nodes\n}\n\n// Match a chain of nodes. Each node other than `*` matches exactly\n// one char, so on a failure it is enough to go back to the last `*`\n// and let it match one more char. This takes at most\n// nodes.length * chars.length steps.\nconst testLinear = (\n nodes: LinearNode[],\n chars: ArrayLike<string>,\n start: number,\n end: number,\n) => {\n let ni = 0\n let ci = start\n let starNi = -1\n let starCi = 0\n while (ci < end) {\n const n = nodes[ni]\n if (n?.t === 'star') {\n starNi = ni++\n starCi = ci\n continue\n }\n const c = chars[ci]!\n if (\n n &&\n (n.t === 'any' ||\n (n.t === 'lit' && litMatch(n, c)) ||\n (n.t === 'class' && n.re.test(c)))\n ) {\n ni++\n ci++\n continue\n }\n if (starNi === -1) return false\n ni = starNi + 1\n ci = ++starCi\n }\n while (nodes[ni]?.t === 'star') ni++\n return ni === nodes.length\n}\n\n// The least and most chars that the items can match. These are only\n// bounds: a negation can match a string of any length, so it counts\n// as 0 to Infinity.\nconst lengths = (items: Item[]): [min: number, max: number] => {\n let min = 0\n let max = 0\n for (const it of items) {\n const [lo, hi] = itemLengths(it)\n min += lo\n max += hi\n }\n return [min, max]\n}\n\nconst itemLengths = (it: Item): [min: number, max: number] => {\n if (it.t === 'star') return [0, Infinity]\n if (it.t !== 'ext') return [1, 1]\n if (it.type === '!') return [0, Infinity]\n const alts = it.alts.map(lengths)\n const min = Math.min(...alts.map(a => a[0]))\n const max = Math.max(...alts.map(a => a[1]))\n // a loop of alternatives that only match the empty string is empty\n const loop = max === 0 ? 0 : Infinity\n return (\n it.type === '@' ? [min, max]\n : it.type === '?' ? [0, max]\n : it.type === '*' ? [0, loop]\n : [min, loop]\n )\n}\n\n// true if the chars from `start` match the literals\nconst hasAffix = (\n lits: Lit[],\n chars: ArrayLike<string>,\n start: number,\n) => {\n for (let j = 0; j < lits.length; j++) {\n if (!litMatch(lits[j]!, chars[start + j]!)) return false\n }\n return true\n}\n\n// a `/`, or half of a surrogate pair\nconst slashOrSurrogate = /[/\\ud800-\\udfff]/\nconst surrogate = /[\\ud800-\\udfff]/\n\n// a string can be indexed by code point, unless it has surrogate\n// pairs\nconst codePoints = (s: string): ArrayLike<string> =>\n surrogate.test(s) ? [...s] : s\n\nconst noSlash = (s: string) => {\n if (s.includes('/')) {\n throw new Error('can only match a single path portion, got: ' + s)\n }\n}\n\nexport class Matcher {\n pattern: string\n options: MatcherOptions\n #start: Node\n // the number of node ids\n #size: number\n #marks?: Marks\n // the Sim for strings that are only `.` or `..`\n #dotsSim?: Sim\n // the string to compare, if the pattern has no magic. With\n // `nocase:true`, the RegExp that folds case is made when it is\n // first used.\n #literal?: string\n #literalFold = false\n #literalRe?: RegExp\n // the nodes between the prefix and suffix, if the graph is a\n // single chain\n #linear?: LinearNode[]\n // the linear nodes are only `*` and `?`, so the length bounds and\n // the prefix and suffix decide the match\n #wild = false\n // the least and most chars that a match can have\n #min = 0\n #max = Infinity\n // the literals that a match must start and end with. Each one\n // matches exactly one char, and they are distinct items in the\n // pattern, so a string that does not have them can not match.\n #prefix: Lit[] = []\n #suffix: Lit[] = []\n // the prefix and suffix as strings, if they do not fold case\n #prefixStr?: string\n #suffixStr?: string\n // there is a prefix or suffix to check\n #affix = false\n #dfa?: Dfa\n #form?: Form\n\n constructor(pattern: string, options: MatcherOptions = {}) {\n if (pattern.includes('/')) {\n throw new Error(\n 'can only match a single path portion, got pattern: ' + pattern,\n )\n }\n this.pattern = pattern\n this.options = options\n const { nocase = false, noext = false, normalize: n } = options\n this.#form = n === true ? 'NFC' : n || undefined\n // a pattern that is only an empty extglob is a literal string,\n // except for `!()`, which matches any non-empty string\n const literal = /^[?*+@]\\(\\)$/.test(pattern)\n const toks = tokenize(pattern, nocase, noext || literal, this.#form)\n let [items] = build(toks, pair(toks), 0, toks.length, true)\n if (this.#form) items = normalize(items!, this.#form)\n const [start, size] = compile(items!, nocase)\n this.#start = start\n this.#size = size\n if (items!.every(it => it.t === 'lit')) {\n this.#literal = items!.map(it => it.ch).join('')\n this.#literalFold = nocase\n } else {\n const lit = (it: Item): Lit | undefined =>\n it.t !== 'lit' ? undefined\n : nocase ? { ch: it.ch, re: foldRe(it.ch) }\n : { ch: it.ch }\n for (const it of items!) {\n const l = lit(it)\n if (!l) break\n this.#prefix.push(l)\n }\n for (let j = items!.length - 1; j >= 0; j--) {\n const l = lit(items![j]!)\n if (!l) break\n this.#suffix.unshift(l)\n }\n this.#affix = !!(this.#prefix.length || this.#suffix.length)\n if (!nocase) {\n this.#prefixStr = this.#prefix.map(l => l.ch).join('')\n this.#suffixStr = this.#suffix.map(l => l.ch).join('')\n }\n this.#linear = linear(this.#start)?.slice(\n this.#prefix.length,\n -this.#suffix.length || undefined,\n )\n this.#wild = !!this.#linear?.every(\n n => n.t === 'star' || n.t === 'any',\n )\n const [min, max] = lengths(items!)\n this.#min = min\n this.#max = max\n }\n }\n\n test(s: string): boolean {\n // The `/` check uses the string as given, so with normalization it\n // is a separate step. Otherwise, one scan finds both a `/` and the\n // surrogate pairs that stop the string being indexed by code point.\n if (this.#form) {\n noSlash(s)\n return this.#test(s.normalize(this.#form))\n }\n if (slashOrSurrogate.test(s)) {\n noSlash(s)\n return this.#test(s, [...s])\n }\n return this.#test(s, s)\n }\n\n /**\n * The same as {@link Matcher#test}, but the string is not checked\n * for `/` chars, so the result for a string that has one is not\n * defined. Only use it for a string that is known to be one path\n * portion, such as a part of a path that was split on `/`. It can\n * be faster, because some patterns do not need to look at each char\n * of the string.\n */\n testUnchecked(s: string): boolean {\n return this.#test(this.#form ? s.normalize(this.#form) : s)\n }\n\n // Test a string that has no `/`. `chars` indexes it by code point.\n // If it is not given, it is only found if a step needs it.\n #test(s: string, chars?: ArrayLike<string>): boolean {\n if (this.#literal !== undefined) {\n return this.#literalFold ?\n (this.#literalRe ??= newFoldRe(this.#literal)).test(s)\n : s === this.#literal\n }\n // the length check means that the prefix and suffix do not\n // overlap. Without the chars, the length in code points is from\n // half of the UTF-16 length (if each one is a surrogate pair) to\n // all of it, which is often enough to know.\n const min = this.#min\n const max = this.#max\n if (chars === undefined) {\n const most = s.length\n const least = (most + 1) >> 1\n if (most < min || least > max) return false\n if (least < min || most > max) chars = codePoints(s)\n }\n if (\n chars !== undefined &&\n (chars.length < min || chars.length > max)\n ) {\n return false\n }\n const prefix = this.#prefix.length\n if (this.#affix) {\n if (this.#prefixStr !== undefined && this.#suffixStr !== undefined) {\n if (\n !s.startsWith(this.#prefixStr) ||\n !s.endsWith(this.#suffixStr)\n ) {\n return false\n }\n } else {\n chars ??= codePoints(s)\n const end = chars.length - this.#suffix.length\n if (\n !hasAffix(this.#prefix, chars, 0) ||\n !hasAffix(this.#suffix, chars, end)\n ) {\n return false\n }\n }\n }\n const dotStart = !this.options.dot && s.startsWith('.')\n if (this.#linear) {\n // `.` and `..` only match literal dots, even with `dot:true`\n if (s === '.' || s === '..') return false\n // only a literal can match the leading dot. A `*` can not\n // start a dotfile, even if it matches nothing.\n if (dotStart && !prefix) return false\n if (this.#wild) return true\n chars ??= codePoints(s)\n const end = chars.length - this.#suffix.length\n return testLinear(this.#linear, chars, prefix, end)\n }\n chars ??= codePoints(s)\n if (s === '.' || s === '..') {\n this.#marks ??= marks(this.#size)\n const sim = (this.#dotsSim ??= new Sim(true, false, this.#marks))\n const start = sim.state()\n sim.add(start, this.#start, 0, true)\n let state = sim.done(start)\n for (let i = 0; i < chars.length; i++) {\n state = sim.step(state, chars[i]!, i, true)\n }\n return state.match\n }\n this.#marks ??= marks(this.#size)\n const dfa = (this.#dfa ??= new Dfa(this.#start, this.#marks))\n let d = dfa.start(dotStart)\n // read char codes from the string, so that a one-char string is\n // only made for a cache miss\n const str = chars === s\n for (let i = 0; i < chars.length; i++) {\n if (d.dead) return false\n const code = str ? s.charCodeAt(i) : chars[i]!.charCodeAt(0)\n d = d.ascii?.[code] ?? dfa.next(d, chars[i]!)\n }\n return d.match\n }\n\n /** a readable listing of the state machine */\n toString(): string {\n return show(this.#start)\n }\n}\n"],
5
+ "mappings": "AAIA,IAAMA,EAA0D,CAC9D,YAAa,CAAC,sBAAsB,EACpC,YAAa,CAAC,eAAe,EAC7B,YAAa,CAAC,aAAuB,EACrC,YAAa,CAAC,YAAY,EAC1B,YAAa,CAAC,SAAS,EACvB,YAAa,CAAC,SAAS,EACvB,YAAa,CAAC,eAAgB,EAAI,EAClC,YAAa,CAAC,SAAS,EACvB,YAAa,CAAC,SAAU,EAAI,EAC5B,YAAa,CAAC,cAAc,EAC5B,YAAa,CAAC,uBAAuB,EACrC,YAAa,CAAC,SAAS,EACvB,WAAY,CAAC,6BAA6B,EAC1C,aAAc,CAAC,WAAW,GAKtBC,EAAeC,GAAcA,EAAE,QAAQ,YAAa,MAAM,EAM1DC,EAAU,KASHC,EAAa,CACxBC,EACAC,EACAC,EAAkB,GAClBC,IACoB,CAEpB,IAAMC,EAAQC,GAAa,CACzB,IAAMC,EAAIH,EAAOE,EAAE,UAAUF,CAAI,EAAIE,EACrC,MAAO,CAAC,GAAGC,CAAC,EAAE,SAAW,EAAIA,EAAID,CACnC,EACME,EAAMN,EAEZ,GAAID,EAAK,OAAOO,CAAG,IAAM,IACvB,MAAM,IAAI,MAAM,2BAA2B,EAG7C,IAAMC,EAAmB,CAAA,EACnBC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"norm", "c", "n", "pos", "ranges", "negs", "i", "sawStart", "escaping", "negate", "endPos", "rangeStart", "WHILE", "cls", "unip", "neg", "sranges", "snegs", "comb", "MATCH", "extTypes", "lit", "ch", "reEscape", "s", "newFoldRe", "foldCache", "foldRe", "re", "litMatch", "l", "c", "code", "ascii", "tokenize", "p", "nocase", "noext", "form", "toks", "i", "e", "consumed", "parseClass", "pair", "pairs", "stack", "tok", "build", "start", "end", "top", "seq", "alts", "close", "sub", "normalize", "items", "out", "run", "flush", "it", "a", "compile", "id", "split", "next", "item", "after", "entry", "show", "lines", "seen", "ref", "walk", "indent", "line", "desc", "o", "State", "gen", "sameState", "b", "r", "marks", "size", "Sim", "#marks", "dots", "dotStart", "state", "n", "#visit", "node", "#addThread", "has", "th", "stateKey", "ids", "runs", "DFA_BUDGET", "Dfa", "#start", "#states", "#size", "#plain", "#dotStart", "#sim", "#dotSim", "#make", "#intern", "key", "found", "#clear", "d", "linear", "nodes", "testLinear", "chars", "ni", "ci", "starNi", "starCi", "lengths", "min", "max", "lo", "hi", "itemLengths", "loop", "hasAffix", "lits", "j", "slashOrSurrogate", "surrogate", "codePoints", "noSlash", "Matcher", "#dotsSim", "#literal", "#literalFold", "#literalRe", "#linear", "#wild", "#min", "#max", "#prefix", "#suffix", "#prefixStr", "#suffixStr", "#affix", "#dfa", "#form", "pattern", "options", "literal", "#test", "most", "least", "prefix", "sim", "dfa", "str"]
7
+ }
@@ -0,0 +1,4 @@
1
+ export type ParseClassResult = [re: RegExp, consumed: number];
2
+ export type Form = 'NFC' | 'NFD' | 'NFKC' | 'NFKD';
3
+ export declare const parseClass: (glob: string, position: number, nocase?: boolean, form?: Form) => ParseClassResult;
4
+ //# sourceMappingURL=parse-class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-class.d.ts","sourceRoot":"","sources":["../../src/parse-class.ts"],"names":[],"mappings":"AAyBA,MAAM,MAAM,gBAAgB,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;AAE7D,MAAM,MAAM,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AAWlD,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,SAAQ,OAAe,EACvB,OAAO,IAAI,KACV,gBAkHF,CAAA"}
@@ -0,0 +1,138 @@
1
+ // translate the various posix character classes into unicode properties
2
+ // this works across all unicode locales
3
+ // { <posix class>: [<translation>, negated]
4
+ const posixClasses = {
5
+ '[:alnum:]': ['\\p{L}\\p{Nl}\\p{Nd}'],
6
+ '[:alpha:]': ['\\p{L}\\p{Nl}'],
7
+ '[:ascii:]': ['\\x' + '00-\\x' + '7f'],
8
+ '[:blank:]': ['\\p{Zs}\\t'],
9
+ '[:cntrl:]': ['\\p{Cc}'],
10
+ '[:digit:]': ['\\p{Nd}'],
11
+ '[:graph:]': ['\\p{Z}\\p{C}', true],
12
+ '[:lower:]': ['\\p{Ll}'],
13
+ '[:print:]': ['\\p{C}', true],
14
+ '[:punct:]': ['\\p{P}\\p{S}'],
15
+ '[:space:]': ['\\p{Z}\\t\\r\\n\\v\\f'],
16
+ '[:upper:]': ['\\p{Lu}'],
17
+ '[:word:]': ['\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}'],
18
+ '[:xdigit:]': ['A-Fa-f0-9'],
19
+ };
20
+ // only need to escape a few things inside of brace expressions
21
+ // escapes: [ \ ] -
22
+ const braceEscape = (s) => s.replace(/[[\]\\-]/g, '\\$&');
23
+ const noMatch = /$./;
24
+ // Takes a glob string at a posix brace expression. Returns a RegExp
25
+ // that tests one character, and the number of glob chars consumed.
26
+ // If the class is not closed, consumed is 0, and the `[` must be
27
+ // treated as a literal character.
28
+ // Out of order ranges are removed. If nothing is left, the RegExp
29
+ // is `/$./`, and the rest of the glob is consumed, so that the
30
+ // whole glob cannot match.
31
+ export const parseClass = (glob, position, nocase = false, form) => {
32
+ // normalize one class member, if it stays one code point
33
+ const norm = (c) => {
34
+ const n = form ? c.normalize(form) : c;
35
+ return [...n].length === 1 ? n : c;
36
+ };
37
+ const pos = position;
38
+ /* c8 ignore start */
39
+ if (glob.charAt(pos) !== '[') {
40
+ throw new Error('not in a brace expression');
41
+ }
42
+ /* c8 ignore stop */
43
+ const ranges = [];
44
+ const negs = [];
45
+ let i = pos + 1;
46
+ let sawStart = false;
47
+ let escaping = false;
48
+ let negate = false;
49
+ let endPos = pos;
50
+ let rangeStart = '';
51
+ WHILE: while (i < glob.length) {
52
+ const c = String.fromCodePoint(glob.codePointAt(i));
53
+ if ((c === '!' || c === '^') && i === pos + 1) {
54
+ negate = true;
55
+ i++;
56
+ continue;
57
+ }
58
+ if (c === ']' && sawStart && !escaping) {
59
+ endPos = i + 1;
60
+ break;
61
+ }
62
+ sawStart = true;
63
+ if (c === '\\') {
64
+ if (!escaping) {
65
+ escaping = true;
66
+ i++;
67
+ continue;
68
+ }
69
+ // escaped \ char, fall through and treat like normal char
70
+ }
71
+ if (c === '[' && !escaping) {
72
+ // either a posix class, a collation equivalent, or just a [
73
+ for (const [cls, [unip, neg]] of Object.entries(posixClasses)) {
74
+ if (glob.startsWith(cls, i)) {
75
+ // invalid, [a-[] is fine, but not [a-[:alpha]]
76
+ if (rangeStart) {
77
+ return [noMatch, glob.length - pos];
78
+ }
79
+ i += cls.length;
80
+ if (neg)
81
+ negs.push(unip);
82
+ else
83
+ ranges.push(unip);
84
+ continue WHILE;
85
+ }
86
+ }
87
+ }
88
+ // now it's just a normal character, effectively
89
+ escaping = false;
90
+ const n = norm(c);
91
+ if (rangeStart) {
92
+ // throw this range away if it's not valid, but others
93
+ // can still match.
94
+ if (n.codePointAt(0) > rangeStart.codePointAt(0)) {
95
+ ranges.push(braceEscape(rangeStart) + '-' + braceEscape(n));
96
+ }
97
+ else if (n === rangeStart) {
98
+ ranges.push(braceEscape(n));
99
+ }
100
+ rangeStart = '';
101
+ i += c.length;
102
+ continue;
103
+ }
104
+ // now might be the start of a range.
105
+ // can be either c-d or c-] or c<more...>] or c] at this point
106
+ if (glob.startsWith('-]', i + c.length)) {
107
+ ranges.push(braceEscape(n + '-'));
108
+ i += c.length + 1;
109
+ continue;
110
+ }
111
+ if (glob.startsWith('-', i + c.length)) {
112
+ rangeStart = n;
113
+ i += c.length + 1;
114
+ continue;
115
+ }
116
+ // not the start of a range, just a single character
117
+ ranges.push(braceEscape(n));
118
+ i += c.length;
119
+ }
120
+ if (endPos < i) {
121
+ // didn't see the end of the class, not a valid class,
122
+ // but might still be valid as a literal match.
123
+ return [noMatch, 0];
124
+ }
125
+ // if we got no ranges and no negates, then we have a range that
126
+ // cannot possibly match anything, and that poisons the whole glob
127
+ if (!ranges.length && !negs.length) {
128
+ return [noMatch, glob.length - pos];
129
+ }
130
+ const sranges = '[' + (negate ? '^' : '') + ranges.join('') + ']';
131
+ const snegs = '[' + (negate ? '' : '^') + negs.join('') + ']';
132
+ const comb = '^' +
133
+ (ranges.length && negs.length ? '(' + sranges + '|' + snegs + ')'
134
+ : ranges.length ? sranges
135
+ : snegs);
136
+ return [new RegExp(comb, nocase ? 'iu' : 'u'), endPos - pos];
137
+ };
138
+ //# sourceMappingURL=parse-class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-class.js","sourceRoot":"","sources":["../../src/parse-class.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,wCAAwC;AAExC,4CAA4C;AAC5C,MAAM,YAAY,GAA8C;IAC9D,WAAW,EAAE,CAAC,sBAAsB,CAAC;IACrC,WAAW,EAAE,CAAC,eAAe,CAAC;IAC9B,WAAW,EAAE,CAAC,KAAK,GAAG,QAAQ,GAAG,IAAI,CAAC;IACtC,WAAW,EAAE,CAAC,YAAY,CAAC;IAC3B,WAAW,EAAE,CAAC,SAAS,CAAC;IACxB,WAAW,EAAE,CAAC,SAAS,CAAC;IACxB,WAAW,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC;IACnC,WAAW,EAAE,CAAC,SAAS,CAA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AM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,CAAA;AAC9D,CAAC,CAAA","sourcesContent":["// translate the various posix character classes into unicode properties\n// this works across all unicode locales\n\n// { <posix class>: [<translation>, negated]\nconst posixClasses: { [k: string]: [e: string, n?: boolean] } = {\n '[:alnum:]': ['\\\\p{L}\\\\p{Nl}\\\\p{Nd}'],\n '[:alpha:]': ['\\\\p{L}\\\\p{Nl}'],\n '[:ascii:]': ['\\\\x' + '00-\\\\x' + '7f'],\n '[:blank:]': ['\\\\p{Zs}\\\\t'],\n '[:cntrl:]': ['\\\\p{Cc}'],\n '[:digit:]': ['\\\\p{Nd}'],\n '[:graph:]': ['\\\\p{Z}\\\\p{C}', true],\n '[:lower:]': ['\\\\p{Ll}'],\n '[:print:]': ['\\\\p{C}', true],\n '[:punct:]': ['\\\\p{P}\\\\p{S}'],\n '[:space:]': ['\\\\p{Z}\\\\t\\\\r\\\\n\\\\v\\\\f'],\n '[:upper:]': ['\\\\p{Lu}'],\n '[:word:]': ['\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}'],\n '[:xdigit:]': ['A-Fa-f0-9'],\n}\n\n// only need to escape a few things inside of brace expressions\n// escapes: [ \\ ] -\nconst braceEscape = (s: string) => s.replace(/[[\\]\\\\-]/g, '\\\\$&')\n\nexport type ParseClassResult = [re: RegExp, consumed: number]\n\nexport type Form = 'NFC' | 'NFD' | 'NFKC' | 'NFKD'\n\nconst noMatch = /$./\n\n// Takes a glob string at a posix brace expression. Returns a RegExp\n// that tests one character, and the number of glob chars consumed.\n// If the class is not closed, consumed is 0, and the `[` must be\n// treated as a literal character.\n// Out of order ranges are removed. If nothing is left, the RegExp\n// is `/$./`, and the rest of the glob is consumed, so that the\n// whole glob cannot match.\nexport const parseClass = (\n glob: string,\n position: number,\n nocase: boolean = false,\n form?: Form,\n): ParseClassResult => {\n // normalize one class member, if it stays one code point\n const norm = (c: string) => {\n const n = form ? c.normalize(form) : c\n return [...n].length === 1 ? n : c\n }\n const pos = position\n /* c8 ignore start */\n if (glob.charAt(pos) !== '[') {\n throw new Error('not in a brace expression')\n }\n /* c8 ignore stop */\n const ranges: string[] = []\n const negs: string[] = []\n\n let i = pos + 1\n let sawStart = false\n let escaping = false\n let negate = false\n let endPos = pos\n let rangeStart = ''\n WHILE: while (i < glob.length) {\n const c = String.fromCodePoint(glob.codePointAt(i)!)\n if ((c === '!' || c === '^') && i === pos + 1) {\n negate = true\n i++\n continue\n }\n\n if (c === ']' && sawStart && !escaping) {\n endPos = i + 1\n break\n }\n\n sawStart = true\n if (c === '\\\\') {\n if (!escaping) {\n escaping = true\n i++\n continue\n }\n // escaped \\ char, fall through and treat like normal char\n }\n if (c === '[' && !escaping) {\n // either a posix class, a collation equivalent, or just a [\n for (const [cls, [unip, neg]] of Object.entries(posixClasses)) {\n if (glob.startsWith(cls, i)) {\n // invalid, [a-[] is fine, but not [a-[:alpha]]\n if (rangeStart) {\n return [noMatch, glob.length - pos]\n }\n i += cls.length\n if (neg) negs.push(unip)\n else ranges.push(unip)\n continue WHILE\n }\n }\n }\n\n // now it's just a normal character, effectively\n escaping = false\n const n = norm(c)\n if (rangeStart) {\n // throw this range away if it's not valid, but others\n // can still match.\n if (n.codePointAt(0)! > rangeStart.codePointAt(0)!) {\n ranges.push(braceEscape(rangeStart) + '-' + braceEscape(n))\n } else if (n === rangeStart) {\n ranges.push(braceEscape(n))\n }\n rangeStart = ''\n i += c.length\n continue\n }\n\n // now might be the start of a range.\n // can be either c-d or c-] or c<more...>] or c] at this point\n if (glob.startsWith('-]', i + c.length)) {\n ranges.push(braceEscape(n + '-'))\n i += c.length + 1\n continue\n }\n if (glob.startsWith('-', i + c.length)) {\n rangeStart = n\n i += c.length + 1\n continue\n }\n\n // not the start of a range, just a single character\n ranges.push(braceEscape(n))\n i += c.length\n }\n\n if (endPos < i) {\n // didn't see the end of the class, not a valid class,\n // but might still be valid as a literal match.\n return [noMatch, 0]\n }\n\n // if we got no ranges and no negates, then we have a range that\n // cannot possibly match anything, and that poisons the whole glob\n if (!ranges.length && !negs.length) {\n return [noMatch, glob.length - pos]\n }\n\n const sranges = '[' + (negate ? '^' : '') + ranges.join('') + ']'\n const snegs = '[' + (negate ? '' : '^') + negs.join('') + ']'\n const comb =\n '^' +\n (ranges.length && negs.length ? '(' + sranges + '|' + snegs + ')'\n : ranges.length ? sranges\n : snegs)\n\n return [new RegExp(comb, nocase ? 'iu' : 'u'), endPos - pos]\n}\n"]}
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@isaacs/nonrecursive-glob-match",
3
+ "description": "a single-path-portion glob matcher not subject to recursive backtracking ReDoS",
4
+ "version": "1.0.3",
5
+ "license": "BlueOak-1.0.0",
6
+ "files": [
7
+ "dist",
8
+ "src"
9
+ ],
10
+ "devDependencies": {
11
+ "esbuild": "^0.28.2",
12
+ "prettier": "^3.9.10",
13
+ "tap": "^21.8.0",
14
+ "tshy": "^4.1.3",
15
+ "typedoc": "^0.28.20"
16
+ },
17
+ "scripts": {
18
+ "format": "prettier --write .",
19
+ "test": "tap",
20
+ "snap": "tap",
21
+ "typedoc": "typedoc",
22
+ "pretest": "npm run prepare",
23
+ "presnap": "npm run prepare",
24
+ "prepare": "tshy && bash scripts/build.sh",
25
+ "preversion": "npm test",
26
+ "postversion": "npm publish",
27
+ "prepublishOnly": "git push origin --follow-tags"
28
+ },
29
+ "type": "module",
30
+ "tshy": {
31
+ "selfLink": false,
32
+ "exports": {
33
+ "./package.json": "./package.json",
34
+ ".": "./src/index.ts"
35
+ }
36
+ },
37
+ "exports": {
38
+ "./package.json": "./package.json",
39
+ ".": {
40
+ "import": {
41
+ "types": "./dist/esm/index.d.ts",
42
+ "default": "./dist/esm/index.js"
43
+ },
44
+ "require": {
45
+ "types": "./dist/commonjs/index.d.ts",
46
+ "default": "./dist/commonjs/index.js"
47
+ }
48
+ }
49
+ },
50
+ "main": "./dist/commonjs/index.js",
51
+ "types": "./dist/commonjs/index.d.ts",
52
+ "module": "./dist/esm/index.js",
53
+ "allowScripts": {
54
+ "esbuild@0.28.2": true
55
+ }
56
+ }