specdx 0.4.0-alpha.9 → 0.5.0
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.
- package/.claude-plugin/plugin.json +7 -2
- package/README.md +283 -0
- package/dist/{check-4FSSC6HN.js → check-RH5SCXWW.js} +68 -30
- package/dist/check-RH5SCXWW.js.map +1 -0
- package/dist/{chunk-N77RNV7J.js → chunk-3YXRWQGX.js} +217 -42
- package/dist/chunk-3YXRWQGX.js.map +1 -0
- package/dist/chunk-5WRI5ZAA.js +31 -0
- package/dist/chunk-6EQIDZ4D.js +185 -0
- package/dist/chunk-6EQIDZ4D.js.map +1 -0
- package/dist/chunk-6WFNZH7F.js +2846 -0
- package/dist/chunk-6WFNZH7F.js.map +1 -0
- package/dist/{chunk-AKNPCB37.js → chunk-BMOOLUPG.js} +32 -12
- package/dist/chunk-BMOOLUPG.js.map +1 -0
- package/dist/{chunk-IHTYAW7C.js → chunk-BP3SB35W.js} +111 -7
- package/dist/chunk-BP3SB35W.js.map +1 -0
- package/dist/chunk-CQETLJTZ.js +103 -0
- package/dist/chunk-CQETLJTZ.js.map +1 -0
- package/dist/chunk-DMGABJ6T.js +41 -0
- package/dist/chunk-DMGABJ6T.js.map +1 -0
- package/dist/chunk-NHD44ZYN.js +20 -0
- package/dist/chunk-NHD44ZYN.js.map +1 -0
- package/dist/{chunk-7JXW2GTJ.js → chunk-XRWLPU24.js} +18 -2
- package/dist/chunk-XRWLPU24.js.map +1 -0
- package/dist/chunk-ZIODMXST.js +1146 -0
- package/dist/chunk-ZIODMXST.js.map +1 -0
- package/dist/diff-QO7HMAK3.js +200 -0
- package/dist/diff-QO7HMAK3.js.map +1 -0
- package/dist/{dist-4DIRTBJH.js → dist-JPWHWMV2.js} +88 -26
- package/dist/dist-JPWHWMV2.js.map +1 -0
- package/dist/{dist-RL2DT3ZE.js → dist-ROHCFKYT.js} +3 -2
- package/dist/dist-ROHCFKYT.js.map +1 -0
- package/dist/generate-MS4BM7RU.js +21 -0
- package/dist/generate-MS4BM7RU.js.map +1 -0
- package/dist/{generate-story-EFHGINHA.js → generate-story-OMM322L7.js} +43 -19
- package/dist/generate-story-OMM322L7.js.map +1 -0
- package/dist/{generate-test-plan-BO7444RG.js → generate-test-plan-75W7SZIO.js} +61 -11
- package/dist/generate-test-plan-75W7SZIO.js.map +1 -0
- package/dist/{graph-5XINV7PT.js → graph-QOTMXENE.js} +49 -11
- package/dist/graph-QOTMXENE.js.map +1 -0
- package/dist/index.d.ts +302 -0
- package/dist/index.js +2996 -357
- package/dist/index.js.map +1 -1
- package/dist/lint-LPFLHVO4.js +184 -0
- package/dist/lint-LPFLHVO4.js.map +1 -0
- package/dist/main.js +10 -229
- package/dist/main.js.map +1 -1
- package/dist/mcp-OEC43SPF.js +35 -0
- package/dist/mcp-OEC43SPF.js.map +1 -0
- package/dist/{migrate-4KF6GHLO.js → migrate-CBP2AVLH.js} +21 -9
- package/dist/migrate-CBP2AVLH.js.map +1 -0
- package/dist/{pack-DSOODXAN.js → pack-X6FSWORJ.js} +41 -13
- package/dist/pack-X6FSWORJ.js.map +1 -0
- package/dist/{ready-6DNKIHP6.js → ready-7MJWRGLT.js} +55 -14
- package/dist/ready-7MJWRGLT.js.map +1 -0
- package/dist/skills/{specdx-author-spec.md → core/specdx-author-spec/SKILL.md} +10 -6
- package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-01-frontmatter.md +1 -1
- package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-02-sections.md +41 -0
- package/dist/skills/{specdx-onboard.md → core/specdx-onboard/SKILL.md} +8 -3
- package/dist/skills/{specdx-plan-from-spec.md → core/specdx-plan-from-spec/SKILL.md} +5 -1
- package/dist/skills/{specdx-pre-commit.md → core/specdx-pre-commit/SKILL.md} +16 -2
- package/dist/skills/{specdx-review-spec.md → core/specdx-review-spec/SKILL.md} +5 -1
- package/dist/skills/core/specdx-router/SKILL.md +67 -0
- package/dist/skills/{specdx-sprint-review.md → core/specdx-sprint-review/SKILL.md} +6 -2
- package/dist/skills/{specdx-start-task.md → core/specdx-start-task/SKILL.md} +5 -1
- package/dist/skills/{specdx-check-drift.md → experimental/specdx-check-drift/SKILL.md} +10 -4
- package/dist/skills/{specdx-verify.md → experimental/specdx-verify/SKILL.md} +6 -2
- package/dist/skills-36SRUEMR.js +121 -0
- package/dist/skills-36SRUEMR.js.map +1 -0
- package/dist/{status-WZK247CI.js → status-UUPZYX3J.js} +63 -32
- package/dist/status-UUPZYX3J.js.map +1 -0
- package/dist/{update-JTNSYX3B.js → update-EI7IJRHG.js} +22 -12
- package/dist/update-EI7IJRHG.js.map +1 -0
- package/dist/{validate-LBDYWUDX.js → validate-HTTZLQWI.js} +36 -17
- package/dist/validate-HTTZLQWI.js.map +1 -0
- package/hooks/hooks.json +12 -6
- package/hooks/session-start +35 -3
- package/package.json +28 -13
- package/dist/changelog-XUVHY3QK.js +0 -93
- package/dist/changelog-XUVHY3QK.js.map +0 -1
- package/dist/check-4FSSC6HN.js.map +0 -1
- package/dist/chunk-7JXW2GTJ.js.map +0 -1
- package/dist/chunk-AKNPCB37.js.map +0 -1
- package/dist/chunk-DAZCOUVK.js +0 -496
- package/dist/chunk-DAZCOUVK.js.map +0 -1
- package/dist/chunk-GAM4MXPC.js +0 -15
- package/dist/chunk-GAM4MXPC.js.map +0 -1
- package/dist/chunk-IHTYAW7C.js.map +0 -1
- package/dist/chunk-N77RNV7J.js.map +0 -1
- package/dist/chunk-SRZ33RJP.js +0 -1147
- package/dist/chunk-SRZ33RJP.js.map +0 -1
- package/dist/diff-OXZ34NU4.js +0 -107
- package/dist/diff-OXZ34NU4.js.map +0 -1
- package/dist/dist-4DIRTBJH.js.map +0 -1
- package/dist/explain-QBV3AESQ.js +0 -109
- package/dist/explain-QBV3AESQ.js.map +0 -1
- package/dist/generate-7GNPT2WJ.js +0 -13
- package/dist/generate-7GNPT2WJ.js.map +0 -1
- package/dist/generate-story-EFHGINHA.js.map +0 -1
- package/dist/generate-test-plan-BO7444RG.js.map +0 -1
- package/dist/graph-5XINV7PT.js.map +0 -1
- package/dist/lint-PTMWMLDQ.js +0 -122
- package/dist/lint-PTMWMLDQ.js.map +0 -1
- package/dist/mcp-BGFAPM6G.js +0 -17
- package/dist/mcp-BGFAPM6G.js.map +0 -1
- package/dist/migrate-4KF6GHLO.js.map +0 -1
- package/dist/pack-DSOODXAN.js.map +0 -1
- package/dist/ready-6DNKIHP6.js.map +0 -1
- package/dist/skills-3GBBWZW2.js +0 -93
- package/dist/skills-3GBBWZW2.js.map +0 -1
- package/dist/status-WZK247CI.js.map +0 -1
- package/dist/update-JTNSYX3B.js.map +0 -1
- package/dist/validate-LBDYWUDX.js.map +0 -1
- /package/dist/{dist-RL2DT3ZE.js.map → chunk-5WRI5ZAA.js.map} +0 -0
- /package/dist/skills/{spec-type-reference.md → core/specdx-author-spec/references/spec-type-reference.md} +0 -0
- /package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-03-finalize.md +0 -0
|
@@ -0,0 +1,2846 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildRelationResolver,
|
|
3
|
+
loadConfig,
|
|
4
|
+
parseSpecFromString
|
|
5
|
+
} from "./chunk-BP3SB35W.js";
|
|
6
|
+
import {
|
|
7
|
+
__commonJS,
|
|
8
|
+
__toESM
|
|
9
|
+
} from "./chunk-5WRI5ZAA.js";
|
|
10
|
+
|
|
11
|
+
// ../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js
|
|
12
|
+
var require_constants = __commonJS({
|
|
13
|
+
"../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js"(exports, module) {
|
|
14
|
+
"use strict";
|
|
15
|
+
var WIN_SLASH = "\\\\/";
|
|
16
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
17
|
+
var DOT_LITERAL = "\\.";
|
|
18
|
+
var PLUS_LITERAL = "\\+";
|
|
19
|
+
var QMARK_LITERAL = "\\?";
|
|
20
|
+
var SLASH_LITERAL = "\\/";
|
|
21
|
+
var ONE_CHAR = "(?=.)";
|
|
22
|
+
var QMARK = "[^/]";
|
|
23
|
+
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
24
|
+
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
25
|
+
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
26
|
+
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
27
|
+
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
28
|
+
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
29
|
+
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
30
|
+
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
31
|
+
var STAR = `${QMARK}*?`;
|
|
32
|
+
var SEP = "/";
|
|
33
|
+
var POSIX_CHARS = {
|
|
34
|
+
DOT_LITERAL,
|
|
35
|
+
PLUS_LITERAL,
|
|
36
|
+
QMARK_LITERAL,
|
|
37
|
+
SLASH_LITERAL,
|
|
38
|
+
ONE_CHAR,
|
|
39
|
+
QMARK,
|
|
40
|
+
END_ANCHOR,
|
|
41
|
+
DOTS_SLASH,
|
|
42
|
+
NO_DOT,
|
|
43
|
+
NO_DOTS,
|
|
44
|
+
NO_DOT_SLASH,
|
|
45
|
+
NO_DOTS_SLASH,
|
|
46
|
+
QMARK_NO_DOT,
|
|
47
|
+
STAR,
|
|
48
|
+
START_ANCHOR,
|
|
49
|
+
SEP
|
|
50
|
+
};
|
|
51
|
+
var WINDOWS_CHARS = {
|
|
52
|
+
...POSIX_CHARS,
|
|
53
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
54
|
+
QMARK: WIN_NO_SLASH,
|
|
55
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
56
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
57
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
58
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
59
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
60
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
61
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
62
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
63
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
64
|
+
SEP: "\\"
|
|
65
|
+
};
|
|
66
|
+
var POSIX_REGEX_SOURCE = {
|
|
67
|
+
alnum: "a-zA-Z0-9",
|
|
68
|
+
alpha: "a-zA-Z",
|
|
69
|
+
ascii: "\\x00-\\x7F",
|
|
70
|
+
blank: " \\t",
|
|
71
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
72
|
+
digit: "0-9",
|
|
73
|
+
graph: "\\x21-\\x7E",
|
|
74
|
+
lower: "a-z",
|
|
75
|
+
print: "\\x20-\\x7E ",
|
|
76
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
77
|
+
space: " \\t\\r\\n\\v\\f",
|
|
78
|
+
upper: "A-Z",
|
|
79
|
+
word: "A-Za-z0-9_",
|
|
80
|
+
xdigit: "A-Fa-f0-9"
|
|
81
|
+
};
|
|
82
|
+
module.exports = {
|
|
83
|
+
MAX_LENGTH: 1024 * 64,
|
|
84
|
+
POSIX_REGEX_SOURCE,
|
|
85
|
+
// regular expressions
|
|
86
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
87
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
88
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
89
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
90
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
91
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
92
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
93
|
+
REPLACEMENTS: {
|
|
94
|
+
__proto__: null,
|
|
95
|
+
"***": "*",
|
|
96
|
+
"**/**": "**",
|
|
97
|
+
"**/**/**": "**"
|
|
98
|
+
},
|
|
99
|
+
// Digits
|
|
100
|
+
CHAR_0: 48,
|
|
101
|
+
/* 0 */
|
|
102
|
+
CHAR_9: 57,
|
|
103
|
+
/* 9 */
|
|
104
|
+
// Alphabet chars.
|
|
105
|
+
CHAR_UPPERCASE_A: 65,
|
|
106
|
+
/* A */
|
|
107
|
+
CHAR_LOWERCASE_A: 97,
|
|
108
|
+
/* a */
|
|
109
|
+
CHAR_UPPERCASE_Z: 90,
|
|
110
|
+
/* Z */
|
|
111
|
+
CHAR_LOWERCASE_Z: 122,
|
|
112
|
+
/* z */
|
|
113
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
114
|
+
/* ( */
|
|
115
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
116
|
+
/* ) */
|
|
117
|
+
CHAR_ASTERISK: 42,
|
|
118
|
+
/* * */
|
|
119
|
+
// Non-alphabetic chars.
|
|
120
|
+
CHAR_AMPERSAND: 38,
|
|
121
|
+
/* & */
|
|
122
|
+
CHAR_AT: 64,
|
|
123
|
+
/* @ */
|
|
124
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
125
|
+
/* \ */
|
|
126
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
127
|
+
/* \r */
|
|
128
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
129
|
+
/* ^ */
|
|
130
|
+
CHAR_COLON: 58,
|
|
131
|
+
/* : */
|
|
132
|
+
CHAR_COMMA: 44,
|
|
133
|
+
/* , */
|
|
134
|
+
CHAR_DOT: 46,
|
|
135
|
+
/* . */
|
|
136
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
137
|
+
/* " */
|
|
138
|
+
CHAR_EQUAL: 61,
|
|
139
|
+
/* = */
|
|
140
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
141
|
+
/* ! */
|
|
142
|
+
CHAR_FORM_FEED: 12,
|
|
143
|
+
/* \f */
|
|
144
|
+
CHAR_FORWARD_SLASH: 47,
|
|
145
|
+
/* / */
|
|
146
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
147
|
+
/* ` */
|
|
148
|
+
CHAR_HASH: 35,
|
|
149
|
+
/* # */
|
|
150
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
151
|
+
/* - */
|
|
152
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
153
|
+
/* < */
|
|
154
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
155
|
+
/* { */
|
|
156
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
157
|
+
/* [ */
|
|
158
|
+
CHAR_LINE_FEED: 10,
|
|
159
|
+
/* \n */
|
|
160
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
161
|
+
/* \u00A0 */
|
|
162
|
+
CHAR_PERCENT: 37,
|
|
163
|
+
/* % */
|
|
164
|
+
CHAR_PLUS: 43,
|
|
165
|
+
/* + */
|
|
166
|
+
CHAR_QUESTION_MARK: 63,
|
|
167
|
+
/* ? */
|
|
168
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
169
|
+
/* > */
|
|
170
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
171
|
+
/* } */
|
|
172
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
173
|
+
/* ] */
|
|
174
|
+
CHAR_SEMICOLON: 59,
|
|
175
|
+
/* ; */
|
|
176
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
177
|
+
/* ' */
|
|
178
|
+
CHAR_SPACE: 32,
|
|
179
|
+
/* */
|
|
180
|
+
CHAR_TAB: 9,
|
|
181
|
+
/* \t */
|
|
182
|
+
CHAR_UNDERSCORE: 95,
|
|
183
|
+
/* _ */
|
|
184
|
+
CHAR_VERTICAL_LINE: 124,
|
|
185
|
+
/* | */
|
|
186
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
187
|
+
/* \uFEFF */
|
|
188
|
+
/**
|
|
189
|
+
* Create EXTGLOB_CHARS
|
|
190
|
+
*/
|
|
191
|
+
extglobChars(chars) {
|
|
192
|
+
return {
|
|
193
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
194
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
195
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
196
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
197
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
/**
|
|
201
|
+
* Create GLOB_CHARS
|
|
202
|
+
*/
|
|
203
|
+
globChars(win32) {
|
|
204
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// ../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js
|
|
211
|
+
var require_utils = __commonJS({
|
|
212
|
+
"../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js"(exports) {
|
|
213
|
+
"use strict";
|
|
214
|
+
var {
|
|
215
|
+
REGEX_BACKSLASH,
|
|
216
|
+
REGEX_REMOVE_BACKSLASH,
|
|
217
|
+
REGEX_SPECIAL_CHARS,
|
|
218
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
219
|
+
} = require_constants();
|
|
220
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
221
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
222
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
223
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
224
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
225
|
+
exports.isWindows = () => {
|
|
226
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
227
|
+
const platform = navigator.platform.toLowerCase();
|
|
228
|
+
return platform === "win32" || platform === "windows";
|
|
229
|
+
}
|
|
230
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
231
|
+
return process.platform === "win32";
|
|
232
|
+
}
|
|
233
|
+
return false;
|
|
234
|
+
};
|
|
235
|
+
exports.removeBackslashes = (str) => {
|
|
236
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
237
|
+
return match === "\\" ? "" : match;
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
241
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
242
|
+
if (idx === -1) return input;
|
|
243
|
+
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
244
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
245
|
+
};
|
|
246
|
+
exports.removePrefix = (input, state = {}) => {
|
|
247
|
+
let output = input;
|
|
248
|
+
if (output.startsWith("./")) {
|
|
249
|
+
output = output.slice(2);
|
|
250
|
+
state.prefix = "./";
|
|
251
|
+
}
|
|
252
|
+
return output;
|
|
253
|
+
};
|
|
254
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
255
|
+
const prepend = options.contains ? "" : "^";
|
|
256
|
+
const append = options.contains ? "" : "$";
|
|
257
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
258
|
+
if (state.negated === true) {
|
|
259
|
+
output = `(?:^(?!${output}).*$)`;
|
|
260
|
+
}
|
|
261
|
+
return output;
|
|
262
|
+
};
|
|
263
|
+
exports.basename = (path, { windows } = {}) => {
|
|
264
|
+
const segs = path.split(windows ? /[\\/]/ : "/");
|
|
265
|
+
const last = segs[segs.length - 1];
|
|
266
|
+
if (last === "") {
|
|
267
|
+
return segs[segs.length - 2];
|
|
268
|
+
}
|
|
269
|
+
return last;
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// ../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js
|
|
275
|
+
var require_scan = __commonJS({
|
|
276
|
+
"../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js"(exports, module) {
|
|
277
|
+
"use strict";
|
|
278
|
+
var utils = require_utils();
|
|
279
|
+
var {
|
|
280
|
+
CHAR_ASTERISK,
|
|
281
|
+
/* * */
|
|
282
|
+
CHAR_AT,
|
|
283
|
+
/* @ */
|
|
284
|
+
CHAR_BACKWARD_SLASH,
|
|
285
|
+
/* \ */
|
|
286
|
+
CHAR_COMMA,
|
|
287
|
+
/* , */
|
|
288
|
+
CHAR_DOT,
|
|
289
|
+
/* . */
|
|
290
|
+
CHAR_EXCLAMATION_MARK,
|
|
291
|
+
/* ! */
|
|
292
|
+
CHAR_FORWARD_SLASH,
|
|
293
|
+
/* / */
|
|
294
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
295
|
+
/* { */
|
|
296
|
+
CHAR_LEFT_PARENTHESES,
|
|
297
|
+
/* ( */
|
|
298
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
299
|
+
/* [ */
|
|
300
|
+
CHAR_PLUS,
|
|
301
|
+
/* + */
|
|
302
|
+
CHAR_QUESTION_MARK,
|
|
303
|
+
/* ? */
|
|
304
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
305
|
+
/* } */
|
|
306
|
+
CHAR_RIGHT_PARENTHESES,
|
|
307
|
+
/* ) */
|
|
308
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
309
|
+
/* ] */
|
|
310
|
+
} = require_constants();
|
|
311
|
+
var isPathSeparator = (code) => {
|
|
312
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
313
|
+
};
|
|
314
|
+
var depth = (token) => {
|
|
315
|
+
if (token.isPrefix !== true) {
|
|
316
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
var scan = (input, options) => {
|
|
320
|
+
const opts = options || {};
|
|
321
|
+
const length = input.length - 1;
|
|
322
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
323
|
+
const slashes = [];
|
|
324
|
+
const tokens = [];
|
|
325
|
+
const parts = [];
|
|
326
|
+
let str = input;
|
|
327
|
+
let index = -1;
|
|
328
|
+
let start = 0;
|
|
329
|
+
let lastIndex = 0;
|
|
330
|
+
let isBrace = false;
|
|
331
|
+
let isBracket = false;
|
|
332
|
+
let isGlob = false;
|
|
333
|
+
let isExtglob = false;
|
|
334
|
+
let isGlobstar = false;
|
|
335
|
+
let braceEscaped = false;
|
|
336
|
+
let backslashes = false;
|
|
337
|
+
let negated = false;
|
|
338
|
+
let negatedExtglob = false;
|
|
339
|
+
let finished = false;
|
|
340
|
+
let braces = 0;
|
|
341
|
+
let prev;
|
|
342
|
+
let code;
|
|
343
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
344
|
+
const eos = () => index >= length;
|
|
345
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
346
|
+
const advance = () => {
|
|
347
|
+
prev = code;
|
|
348
|
+
return str.charCodeAt(++index);
|
|
349
|
+
};
|
|
350
|
+
while (index < length) {
|
|
351
|
+
code = advance();
|
|
352
|
+
let next;
|
|
353
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
354
|
+
backslashes = token.backslashes = true;
|
|
355
|
+
code = advance();
|
|
356
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
357
|
+
braceEscaped = true;
|
|
358
|
+
}
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
362
|
+
braces++;
|
|
363
|
+
while (eos() !== true && (code = advance())) {
|
|
364
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
365
|
+
backslashes = token.backslashes = true;
|
|
366
|
+
advance();
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
370
|
+
braces++;
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
374
|
+
isBrace = token.isBrace = true;
|
|
375
|
+
isGlob = token.isGlob = true;
|
|
376
|
+
finished = true;
|
|
377
|
+
if (scanToEnd === true) {
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
383
|
+
isBrace = token.isBrace = true;
|
|
384
|
+
isGlob = token.isGlob = true;
|
|
385
|
+
finished = true;
|
|
386
|
+
if (scanToEnd === true) {
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
392
|
+
braces--;
|
|
393
|
+
if (braces === 0) {
|
|
394
|
+
braceEscaped = false;
|
|
395
|
+
isBrace = token.isBrace = true;
|
|
396
|
+
finished = true;
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (scanToEnd === true) {
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
407
|
+
slashes.push(index);
|
|
408
|
+
tokens.push(token);
|
|
409
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
410
|
+
if (finished === true) continue;
|
|
411
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
412
|
+
start += 2;
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
lastIndex = index + 1;
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
if (opts.noext !== true) {
|
|
419
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
420
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
421
|
+
isGlob = token.isGlob = true;
|
|
422
|
+
isExtglob = token.isExtglob = true;
|
|
423
|
+
finished = true;
|
|
424
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
425
|
+
negatedExtglob = true;
|
|
426
|
+
}
|
|
427
|
+
if (scanToEnd === true) {
|
|
428
|
+
while (eos() !== true && (code = advance())) {
|
|
429
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
430
|
+
backslashes = token.backslashes = true;
|
|
431
|
+
code = advance();
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
435
|
+
isGlob = token.isGlob = true;
|
|
436
|
+
finished = true;
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
if (code === CHAR_ASTERISK) {
|
|
446
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
447
|
+
isGlob = token.isGlob = true;
|
|
448
|
+
finished = true;
|
|
449
|
+
if (scanToEnd === true) {
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
455
|
+
isGlob = token.isGlob = true;
|
|
456
|
+
finished = true;
|
|
457
|
+
if (scanToEnd === true) {
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
463
|
+
while (eos() !== true && (next = advance())) {
|
|
464
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
465
|
+
backslashes = token.backslashes = true;
|
|
466
|
+
advance();
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
469
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
470
|
+
isBracket = token.isBracket = true;
|
|
471
|
+
isGlob = token.isGlob = true;
|
|
472
|
+
finished = true;
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
if (scanToEnd === true) {
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
482
|
+
negated = token.negated = true;
|
|
483
|
+
start++;
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
487
|
+
isGlob = token.isGlob = true;
|
|
488
|
+
if (scanToEnd === true) {
|
|
489
|
+
while (eos() !== true && (code = advance())) {
|
|
490
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
491
|
+
backslashes = token.backslashes = true;
|
|
492
|
+
code = advance();
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
496
|
+
finished = true;
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
if (isGlob === true) {
|
|
505
|
+
finished = true;
|
|
506
|
+
if (scanToEnd === true) {
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (opts.noext === true) {
|
|
513
|
+
isExtglob = false;
|
|
514
|
+
isGlob = false;
|
|
515
|
+
}
|
|
516
|
+
let base = str;
|
|
517
|
+
let prefix = "";
|
|
518
|
+
let glob = "";
|
|
519
|
+
if (start > 0) {
|
|
520
|
+
prefix = str.slice(0, start);
|
|
521
|
+
str = str.slice(start);
|
|
522
|
+
lastIndex -= start;
|
|
523
|
+
}
|
|
524
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
525
|
+
base = str.slice(0, lastIndex);
|
|
526
|
+
glob = str.slice(lastIndex);
|
|
527
|
+
} else if (isGlob === true) {
|
|
528
|
+
base = "";
|
|
529
|
+
glob = str;
|
|
530
|
+
} else {
|
|
531
|
+
base = str;
|
|
532
|
+
}
|
|
533
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
534
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
535
|
+
base = base.slice(0, -1);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
if (opts.unescape === true) {
|
|
539
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
540
|
+
if (base && backslashes === true) {
|
|
541
|
+
base = utils.removeBackslashes(base);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
const state = {
|
|
545
|
+
prefix,
|
|
546
|
+
input,
|
|
547
|
+
start,
|
|
548
|
+
base,
|
|
549
|
+
glob,
|
|
550
|
+
isBrace,
|
|
551
|
+
isBracket,
|
|
552
|
+
isGlob,
|
|
553
|
+
isExtglob,
|
|
554
|
+
isGlobstar,
|
|
555
|
+
negated,
|
|
556
|
+
negatedExtglob
|
|
557
|
+
};
|
|
558
|
+
if (opts.tokens === true) {
|
|
559
|
+
state.maxDepth = 0;
|
|
560
|
+
if (!isPathSeparator(code)) {
|
|
561
|
+
tokens.push(token);
|
|
562
|
+
}
|
|
563
|
+
state.tokens = tokens;
|
|
564
|
+
}
|
|
565
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
566
|
+
let prevIndex;
|
|
567
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
568
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
569
|
+
const i = slashes[idx];
|
|
570
|
+
const value = input.slice(n, i);
|
|
571
|
+
if (opts.tokens) {
|
|
572
|
+
if (idx === 0 && start !== 0) {
|
|
573
|
+
tokens[idx].isPrefix = true;
|
|
574
|
+
tokens[idx].value = prefix;
|
|
575
|
+
} else {
|
|
576
|
+
tokens[idx].value = value;
|
|
577
|
+
}
|
|
578
|
+
depth(tokens[idx]);
|
|
579
|
+
state.maxDepth += tokens[idx].depth;
|
|
580
|
+
}
|
|
581
|
+
if (idx !== 0 || value !== "") {
|
|
582
|
+
parts.push(value);
|
|
583
|
+
}
|
|
584
|
+
prevIndex = i;
|
|
585
|
+
}
|
|
586
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
587
|
+
const value = input.slice(prevIndex + 1);
|
|
588
|
+
parts.push(value);
|
|
589
|
+
if (opts.tokens) {
|
|
590
|
+
tokens[tokens.length - 1].value = value;
|
|
591
|
+
depth(tokens[tokens.length - 1]);
|
|
592
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
state.slashes = slashes;
|
|
596
|
+
state.parts = parts;
|
|
597
|
+
}
|
|
598
|
+
return state;
|
|
599
|
+
};
|
|
600
|
+
module.exports = scan;
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
// ../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js
|
|
605
|
+
var require_parse = __commonJS({
|
|
606
|
+
"../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js"(exports, module) {
|
|
607
|
+
"use strict";
|
|
608
|
+
var constants = require_constants();
|
|
609
|
+
var utils = require_utils();
|
|
610
|
+
var {
|
|
611
|
+
MAX_LENGTH,
|
|
612
|
+
POSIX_REGEX_SOURCE,
|
|
613
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
614
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
615
|
+
REPLACEMENTS
|
|
616
|
+
} = constants;
|
|
617
|
+
var expandRange = (args, options) => {
|
|
618
|
+
if (typeof options.expandRange === "function") {
|
|
619
|
+
return options.expandRange(...args, options);
|
|
620
|
+
}
|
|
621
|
+
args.sort();
|
|
622
|
+
const value = `[${args.join("-")}]`;
|
|
623
|
+
try {
|
|
624
|
+
new RegExp(value);
|
|
625
|
+
} catch (ex) {
|
|
626
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
627
|
+
}
|
|
628
|
+
return value;
|
|
629
|
+
};
|
|
630
|
+
var syntaxError = (type, char) => {
|
|
631
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
632
|
+
};
|
|
633
|
+
var parse = (input, options) => {
|
|
634
|
+
if (typeof input !== "string") {
|
|
635
|
+
throw new TypeError("Expected a string");
|
|
636
|
+
}
|
|
637
|
+
input = REPLACEMENTS[input] || input;
|
|
638
|
+
const opts = { ...options };
|
|
639
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
640
|
+
let len = input.length;
|
|
641
|
+
if (len > max) {
|
|
642
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
643
|
+
}
|
|
644
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
645
|
+
const tokens = [bos];
|
|
646
|
+
const capture = opts.capture ? "" : "?:";
|
|
647
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
648
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
649
|
+
const {
|
|
650
|
+
DOT_LITERAL,
|
|
651
|
+
PLUS_LITERAL,
|
|
652
|
+
SLASH_LITERAL,
|
|
653
|
+
ONE_CHAR,
|
|
654
|
+
DOTS_SLASH,
|
|
655
|
+
NO_DOT,
|
|
656
|
+
NO_DOT_SLASH,
|
|
657
|
+
NO_DOTS_SLASH,
|
|
658
|
+
QMARK,
|
|
659
|
+
QMARK_NO_DOT,
|
|
660
|
+
STAR,
|
|
661
|
+
START_ANCHOR
|
|
662
|
+
} = PLATFORM_CHARS;
|
|
663
|
+
const globstar = (opts2) => {
|
|
664
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
665
|
+
};
|
|
666
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
667
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
668
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
669
|
+
if (opts.capture) {
|
|
670
|
+
star = `(${star})`;
|
|
671
|
+
}
|
|
672
|
+
if (typeof opts.noext === "boolean") {
|
|
673
|
+
opts.noextglob = opts.noext;
|
|
674
|
+
}
|
|
675
|
+
const state = {
|
|
676
|
+
input,
|
|
677
|
+
index: -1,
|
|
678
|
+
start: 0,
|
|
679
|
+
dot: opts.dot === true,
|
|
680
|
+
consumed: "",
|
|
681
|
+
output: "",
|
|
682
|
+
prefix: "",
|
|
683
|
+
backtrack: false,
|
|
684
|
+
negated: false,
|
|
685
|
+
brackets: 0,
|
|
686
|
+
braces: 0,
|
|
687
|
+
parens: 0,
|
|
688
|
+
quotes: 0,
|
|
689
|
+
globstar: false,
|
|
690
|
+
tokens
|
|
691
|
+
};
|
|
692
|
+
input = utils.removePrefix(input, state);
|
|
693
|
+
len = input.length;
|
|
694
|
+
const extglobs = [];
|
|
695
|
+
const braces = [];
|
|
696
|
+
const stack = [];
|
|
697
|
+
let prev = bos;
|
|
698
|
+
let value;
|
|
699
|
+
const eos = () => state.index === len - 1;
|
|
700
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
701
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
702
|
+
const remaining = () => input.slice(state.index + 1);
|
|
703
|
+
const consume = (value2 = "", num = 0) => {
|
|
704
|
+
state.consumed += value2;
|
|
705
|
+
state.index += num;
|
|
706
|
+
};
|
|
707
|
+
const append = (token) => {
|
|
708
|
+
state.output += token.output != null ? token.output : token.value;
|
|
709
|
+
consume(token.value);
|
|
710
|
+
};
|
|
711
|
+
const negate = () => {
|
|
712
|
+
let count = 1;
|
|
713
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
714
|
+
advance();
|
|
715
|
+
state.start++;
|
|
716
|
+
count++;
|
|
717
|
+
}
|
|
718
|
+
if (count % 2 === 0) {
|
|
719
|
+
return false;
|
|
720
|
+
}
|
|
721
|
+
state.negated = true;
|
|
722
|
+
state.start++;
|
|
723
|
+
return true;
|
|
724
|
+
};
|
|
725
|
+
const increment = (type) => {
|
|
726
|
+
state[type]++;
|
|
727
|
+
stack.push(type);
|
|
728
|
+
};
|
|
729
|
+
const decrement = (type) => {
|
|
730
|
+
state[type]--;
|
|
731
|
+
stack.pop();
|
|
732
|
+
};
|
|
733
|
+
const push = (tok) => {
|
|
734
|
+
if (prev.type === "globstar") {
|
|
735
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
736
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
737
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
738
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
739
|
+
prev.type = "star";
|
|
740
|
+
prev.value = "*";
|
|
741
|
+
prev.output = star;
|
|
742
|
+
state.output += prev.output;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
746
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
747
|
+
}
|
|
748
|
+
if (tok.value || tok.output) append(tok);
|
|
749
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
750
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
751
|
+
prev.value += tok.value;
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
tok.prev = prev;
|
|
755
|
+
tokens.push(tok);
|
|
756
|
+
prev = tok;
|
|
757
|
+
};
|
|
758
|
+
const extglobOpen = (type, value2) => {
|
|
759
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
760
|
+
token.prev = prev;
|
|
761
|
+
token.parens = state.parens;
|
|
762
|
+
token.output = state.output;
|
|
763
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
764
|
+
increment("parens");
|
|
765
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
766
|
+
push({ type: "paren", extglob: true, value: advance(), output });
|
|
767
|
+
extglobs.push(token);
|
|
768
|
+
};
|
|
769
|
+
const extglobClose = (token) => {
|
|
770
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
771
|
+
let rest;
|
|
772
|
+
if (token.type === "negate") {
|
|
773
|
+
let extglobStar = star;
|
|
774
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
775
|
+
extglobStar = globstar(opts);
|
|
776
|
+
}
|
|
777
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
778
|
+
output = token.close = `)$))${extglobStar}`;
|
|
779
|
+
}
|
|
780
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
781
|
+
const expression = parse(rest, { ...options, fastpaths: false }).output;
|
|
782
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
783
|
+
}
|
|
784
|
+
if (token.prev.type === "bos") {
|
|
785
|
+
state.negatedExtglob = true;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
push({ type: "paren", extglob: true, value, output });
|
|
789
|
+
decrement("parens");
|
|
790
|
+
};
|
|
791
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
792
|
+
let backslashes = false;
|
|
793
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
794
|
+
if (first === "\\") {
|
|
795
|
+
backslashes = true;
|
|
796
|
+
return m;
|
|
797
|
+
}
|
|
798
|
+
if (first === "?") {
|
|
799
|
+
if (esc) {
|
|
800
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
801
|
+
}
|
|
802
|
+
if (index === 0) {
|
|
803
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
804
|
+
}
|
|
805
|
+
return QMARK.repeat(chars.length);
|
|
806
|
+
}
|
|
807
|
+
if (first === ".") {
|
|
808
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
809
|
+
}
|
|
810
|
+
if (first === "*") {
|
|
811
|
+
if (esc) {
|
|
812
|
+
return esc + first + (rest ? star : "");
|
|
813
|
+
}
|
|
814
|
+
return star;
|
|
815
|
+
}
|
|
816
|
+
return esc ? m : `\\${m}`;
|
|
817
|
+
});
|
|
818
|
+
if (backslashes === true) {
|
|
819
|
+
if (opts.unescape === true) {
|
|
820
|
+
output = output.replace(/\\/g, "");
|
|
821
|
+
} else {
|
|
822
|
+
output = output.replace(/\\+/g, (m) => {
|
|
823
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
if (output === input && opts.contains === true) {
|
|
828
|
+
state.output = input;
|
|
829
|
+
return state;
|
|
830
|
+
}
|
|
831
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
832
|
+
return state;
|
|
833
|
+
}
|
|
834
|
+
while (!eos()) {
|
|
835
|
+
value = advance();
|
|
836
|
+
if (value === "\0") {
|
|
837
|
+
continue;
|
|
838
|
+
}
|
|
839
|
+
if (value === "\\") {
|
|
840
|
+
const next = peek();
|
|
841
|
+
if (next === "/" && opts.bash !== true) {
|
|
842
|
+
continue;
|
|
843
|
+
}
|
|
844
|
+
if (next === "." || next === ";") {
|
|
845
|
+
continue;
|
|
846
|
+
}
|
|
847
|
+
if (!next) {
|
|
848
|
+
value += "\\";
|
|
849
|
+
push({ type: "text", value });
|
|
850
|
+
continue;
|
|
851
|
+
}
|
|
852
|
+
const match = /^\\+/.exec(remaining());
|
|
853
|
+
let slashes = 0;
|
|
854
|
+
if (match && match[0].length > 2) {
|
|
855
|
+
slashes = match[0].length;
|
|
856
|
+
state.index += slashes;
|
|
857
|
+
if (slashes % 2 !== 0) {
|
|
858
|
+
value += "\\";
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
if (opts.unescape === true) {
|
|
862
|
+
value = advance();
|
|
863
|
+
} else {
|
|
864
|
+
value += advance();
|
|
865
|
+
}
|
|
866
|
+
if (state.brackets === 0) {
|
|
867
|
+
push({ type: "text", value });
|
|
868
|
+
continue;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
872
|
+
if (opts.posix !== false && value === ":") {
|
|
873
|
+
const inner = prev.value.slice(1);
|
|
874
|
+
if (inner.includes("[")) {
|
|
875
|
+
prev.posix = true;
|
|
876
|
+
if (inner.includes(":")) {
|
|
877
|
+
const idx = prev.value.lastIndexOf("[");
|
|
878
|
+
const pre = prev.value.slice(0, idx);
|
|
879
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
880
|
+
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
881
|
+
if (posix) {
|
|
882
|
+
prev.value = pre + posix;
|
|
883
|
+
state.backtrack = true;
|
|
884
|
+
advance();
|
|
885
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
886
|
+
bos.output = ONE_CHAR;
|
|
887
|
+
}
|
|
888
|
+
continue;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
894
|
+
value = `\\${value}`;
|
|
895
|
+
}
|
|
896
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
897
|
+
value = `\\${value}`;
|
|
898
|
+
}
|
|
899
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
900
|
+
value = "^";
|
|
901
|
+
}
|
|
902
|
+
prev.value += value;
|
|
903
|
+
append({ value });
|
|
904
|
+
continue;
|
|
905
|
+
}
|
|
906
|
+
if (state.quotes === 1 && value !== '"') {
|
|
907
|
+
value = utils.escapeRegex(value);
|
|
908
|
+
prev.value += value;
|
|
909
|
+
append({ value });
|
|
910
|
+
continue;
|
|
911
|
+
}
|
|
912
|
+
if (value === '"') {
|
|
913
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
914
|
+
if (opts.keepQuotes === true) {
|
|
915
|
+
push({ type: "text", value });
|
|
916
|
+
}
|
|
917
|
+
continue;
|
|
918
|
+
}
|
|
919
|
+
if (value === "(") {
|
|
920
|
+
increment("parens");
|
|
921
|
+
push({ type: "paren", value });
|
|
922
|
+
continue;
|
|
923
|
+
}
|
|
924
|
+
if (value === ")") {
|
|
925
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
926
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
927
|
+
}
|
|
928
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
929
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
930
|
+
extglobClose(extglobs.pop());
|
|
931
|
+
continue;
|
|
932
|
+
}
|
|
933
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
934
|
+
decrement("parens");
|
|
935
|
+
continue;
|
|
936
|
+
}
|
|
937
|
+
if (value === "[") {
|
|
938
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
939
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
940
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
941
|
+
}
|
|
942
|
+
value = `\\${value}`;
|
|
943
|
+
} else {
|
|
944
|
+
increment("brackets");
|
|
945
|
+
}
|
|
946
|
+
push({ type: "bracket", value });
|
|
947
|
+
continue;
|
|
948
|
+
}
|
|
949
|
+
if (value === "]") {
|
|
950
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
951
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
952
|
+
continue;
|
|
953
|
+
}
|
|
954
|
+
if (state.brackets === 0) {
|
|
955
|
+
if (opts.strictBrackets === true) {
|
|
956
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
957
|
+
}
|
|
958
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
959
|
+
continue;
|
|
960
|
+
}
|
|
961
|
+
decrement("brackets");
|
|
962
|
+
const prevValue = prev.value.slice(1);
|
|
963
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
964
|
+
value = `/${value}`;
|
|
965
|
+
}
|
|
966
|
+
prev.value += value;
|
|
967
|
+
append({ value });
|
|
968
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
969
|
+
continue;
|
|
970
|
+
}
|
|
971
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
972
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
973
|
+
if (opts.literalBrackets === true) {
|
|
974
|
+
state.output += escaped;
|
|
975
|
+
prev.value = escaped;
|
|
976
|
+
continue;
|
|
977
|
+
}
|
|
978
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
979
|
+
state.output += prev.value;
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
982
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
983
|
+
increment("braces");
|
|
984
|
+
const open = {
|
|
985
|
+
type: "brace",
|
|
986
|
+
value,
|
|
987
|
+
output: "(",
|
|
988
|
+
outputIndex: state.output.length,
|
|
989
|
+
tokensIndex: state.tokens.length
|
|
990
|
+
};
|
|
991
|
+
braces.push(open);
|
|
992
|
+
push(open);
|
|
993
|
+
continue;
|
|
994
|
+
}
|
|
995
|
+
if (value === "}") {
|
|
996
|
+
const brace = braces[braces.length - 1];
|
|
997
|
+
if (opts.nobrace === true || !brace) {
|
|
998
|
+
push({ type: "text", value, output: value });
|
|
999
|
+
continue;
|
|
1000
|
+
}
|
|
1001
|
+
let output = ")";
|
|
1002
|
+
if (brace.dots === true) {
|
|
1003
|
+
const arr = tokens.slice();
|
|
1004
|
+
const range = [];
|
|
1005
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
1006
|
+
tokens.pop();
|
|
1007
|
+
if (arr[i].type === "brace") {
|
|
1008
|
+
break;
|
|
1009
|
+
}
|
|
1010
|
+
if (arr[i].type !== "dots") {
|
|
1011
|
+
range.unshift(arr[i].value);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
output = expandRange(range, opts);
|
|
1015
|
+
state.backtrack = true;
|
|
1016
|
+
}
|
|
1017
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
1018
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
1019
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1020
|
+
brace.value = brace.output = "\\{";
|
|
1021
|
+
value = output = "\\}";
|
|
1022
|
+
state.output = out;
|
|
1023
|
+
for (const t of toks) {
|
|
1024
|
+
state.output += t.output || t.value;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
push({ type: "brace", value, output });
|
|
1028
|
+
decrement("braces");
|
|
1029
|
+
braces.pop();
|
|
1030
|
+
continue;
|
|
1031
|
+
}
|
|
1032
|
+
if (value === "|") {
|
|
1033
|
+
if (extglobs.length > 0) {
|
|
1034
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
1035
|
+
}
|
|
1036
|
+
push({ type: "text", value });
|
|
1037
|
+
continue;
|
|
1038
|
+
}
|
|
1039
|
+
if (value === ",") {
|
|
1040
|
+
let output = value;
|
|
1041
|
+
const brace = braces[braces.length - 1];
|
|
1042
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
1043
|
+
brace.comma = true;
|
|
1044
|
+
output = "|";
|
|
1045
|
+
}
|
|
1046
|
+
push({ type: "comma", value, output });
|
|
1047
|
+
continue;
|
|
1048
|
+
}
|
|
1049
|
+
if (value === "/") {
|
|
1050
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1051
|
+
state.start = state.index + 1;
|
|
1052
|
+
state.consumed = "";
|
|
1053
|
+
state.output = "";
|
|
1054
|
+
tokens.pop();
|
|
1055
|
+
prev = bos;
|
|
1056
|
+
continue;
|
|
1057
|
+
}
|
|
1058
|
+
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
1059
|
+
continue;
|
|
1060
|
+
}
|
|
1061
|
+
if (value === ".") {
|
|
1062
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
1063
|
+
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
1064
|
+
const brace = braces[braces.length - 1];
|
|
1065
|
+
prev.type = "dots";
|
|
1066
|
+
prev.output += value;
|
|
1067
|
+
prev.value += value;
|
|
1068
|
+
brace.dots = true;
|
|
1069
|
+
continue;
|
|
1070
|
+
}
|
|
1071
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1072
|
+
push({ type: "text", value, output: DOT_LITERAL });
|
|
1073
|
+
continue;
|
|
1074
|
+
}
|
|
1075
|
+
push({ type: "dot", value, output: DOT_LITERAL });
|
|
1076
|
+
continue;
|
|
1077
|
+
}
|
|
1078
|
+
if (value === "?") {
|
|
1079
|
+
const isGroup = prev && prev.value === "(";
|
|
1080
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1081
|
+
extglobOpen("qmark", value);
|
|
1082
|
+
continue;
|
|
1083
|
+
}
|
|
1084
|
+
if (prev && prev.type === "paren") {
|
|
1085
|
+
const next = peek();
|
|
1086
|
+
let output = value;
|
|
1087
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
1088
|
+
output = `\\${value}`;
|
|
1089
|
+
}
|
|
1090
|
+
push({ type: "text", value, output });
|
|
1091
|
+
continue;
|
|
1092
|
+
}
|
|
1093
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1094
|
+
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
push({ type: "qmark", value, output: QMARK });
|
|
1098
|
+
continue;
|
|
1099
|
+
}
|
|
1100
|
+
if (value === "!") {
|
|
1101
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
1102
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
1103
|
+
extglobOpen("negate", value);
|
|
1104
|
+
continue;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
1108
|
+
negate();
|
|
1109
|
+
continue;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
if (value === "+") {
|
|
1113
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1114
|
+
extglobOpen("plus", value);
|
|
1115
|
+
continue;
|
|
1116
|
+
}
|
|
1117
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1118
|
+
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
1119
|
+
continue;
|
|
1120
|
+
}
|
|
1121
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1122
|
+
push({ type: "plus", value });
|
|
1123
|
+
continue;
|
|
1124
|
+
}
|
|
1125
|
+
push({ type: "plus", value: PLUS_LITERAL });
|
|
1126
|
+
continue;
|
|
1127
|
+
}
|
|
1128
|
+
if (value === "@") {
|
|
1129
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1130
|
+
push({ type: "at", extglob: true, value, output: "" });
|
|
1131
|
+
continue;
|
|
1132
|
+
}
|
|
1133
|
+
push({ type: "text", value });
|
|
1134
|
+
continue;
|
|
1135
|
+
}
|
|
1136
|
+
if (value !== "*") {
|
|
1137
|
+
if (value === "$" || value === "^") {
|
|
1138
|
+
value = `\\${value}`;
|
|
1139
|
+
}
|
|
1140
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1141
|
+
if (match) {
|
|
1142
|
+
value += match[0];
|
|
1143
|
+
state.index += match[0].length;
|
|
1144
|
+
}
|
|
1145
|
+
push({ type: "text", value });
|
|
1146
|
+
continue;
|
|
1147
|
+
}
|
|
1148
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1149
|
+
prev.type = "star";
|
|
1150
|
+
prev.star = true;
|
|
1151
|
+
prev.value += value;
|
|
1152
|
+
prev.output = star;
|
|
1153
|
+
state.backtrack = true;
|
|
1154
|
+
state.globstar = true;
|
|
1155
|
+
consume(value);
|
|
1156
|
+
continue;
|
|
1157
|
+
}
|
|
1158
|
+
let rest = remaining();
|
|
1159
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1160
|
+
extglobOpen("star", value);
|
|
1161
|
+
continue;
|
|
1162
|
+
}
|
|
1163
|
+
if (prev.type === "star") {
|
|
1164
|
+
if (opts.noglobstar === true) {
|
|
1165
|
+
consume(value);
|
|
1166
|
+
continue;
|
|
1167
|
+
}
|
|
1168
|
+
const prior = prev.prev;
|
|
1169
|
+
const before = prior.prev;
|
|
1170
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
1171
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
1172
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
1173
|
+
push({ type: "star", value, output: "" });
|
|
1174
|
+
continue;
|
|
1175
|
+
}
|
|
1176
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1177
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1178
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1179
|
+
push({ type: "star", value, output: "" });
|
|
1180
|
+
continue;
|
|
1181
|
+
}
|
|
1182
|
+
while (rest.slice(0, 3) === "/**") {
|
|
1183
|
+
const after = input[state.index + 4];
|
|
1184
|
+
if (after && after !== "/") {
|
|
1185
|
+
break;
|
|
1186
|
+
}
|
|
1187
|
+
rest = rest.slice(3);
|
|
1188
|
+
consume("/**", 3);
|
|
1189
|
+
}
|
|
1190
|
+
if (prior.type === "bos" && eos()) {
|
|
1191
|
+
prev.type = "globstar";
|
|
1192
|
+
prev.value += value;
|
|
1193
|
+
prev.output = globstar(opts);
|
|
1194
|
+
state.output = prev.output;
|
|
1195
|
+
state.globstar = true;
|
|
1196
|
+
consume(value);
|
|
1197
|
+
continue;
|
|
1198
|
+
}
|
|
1199
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1200
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1201
|
+
prior.output = `(?:${prior.output}`;
|
|
1202
|
+
prev.type = "globstar";
|
|
1203
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1204
|
+
prev.value += value;
|
|
1205
|
+
state.globstar = true;
|
|
1206
|
+
state.output += prior.output + prev.output;
|
|
1207
|
+
consume(value);
|
|
1208
|
+
continue;
|
|
1209
|
+
}
|
|
1210
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1211
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1212
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1213
|
+
prior.output = `(?:${prior.output}`;
|
|
1214
|
+
prev.type = "globstar";
|
|
1215
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1216
|
+
prev.value += value;
|
|
1217
|
+
state.output += prior.output + prev.output;
|
|
1218
|
+
state.globstar = true;
|
|
1219
|
+
consume(value + advance());
|
|
1220
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1221
|
+
continue;
|
|
1222
|
+
}
|
|
1223
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
1224
|
+
prev.type = "globstar";
|
|
1225
|
+
prev.value += value;
|
|
1226
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1227
|
+
state.output = prev.output;
|
|
1228
|
+
state.globstar = true;
|
|
1229
|
+
consume(value + advance());
|
|
1230
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1231
|
+
continue;
|
|
1232
|
+
}
|
|
1233
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1234
|
+
prev.type = "globstar";
|
|
1235
|
+
prev.output = globstar(opts);
|
|
1236
|
+
prev.value += value;
|
|
1237
|
+
state.output += prev.output;
|
|
1238
|
+
state.globstar = true;
|
|
1239
|
+
consume(value);
|
|
1240
|
+
continue;
|
|
1241
|
+
}
|
|
1242
|
+
const token = { type: "star", value, output: star };
|
|
1243
|
+
if (opts.bash === true) {
|
|
1244
|
+
token.output = ".*?";
|
|
1245
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
1246
|
+
token.output = nodot + token.output;
|
|
1247
|
+
}
|
|
1248
|
+
push(token);
|
|
1249
|
+
continue;
|
|
1250
|
+
}
|
|
1251
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
1252
|
+
token.output = value;
|
|
1253
|
+
push(token);
|
|
1254
|
+
continue;
|
|
1255
|
+
}
|
|
1256
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1257
|
+
if (prev.type === "dot") {
|
|
1258
|
+
state.output += NO_DOT_SLASH;
|
|
1259
|
+
prev.output += NO_DOT_SLASH;
|
|
1260
|
+
} else if (opts.dot === true) {
|
|
1261
|
+
state.output += NO_DOTS_SLASH;
|
|
1262
|
+
prev.output += NO_DOTS_SLASH;
|
|
1263
|
+
} else {
|
|
1264
|
+
state.output += nodot;
|
|
1265
|
+
prev.output += nodot;
|
|
1266
|
+
}
|
|
1267
|
+
if (peek() !== "*") {
|
|
1268
|
+
state.output += ONE_CHAR;
|
|
1269
|
+
prev.output += ONE_CHAR;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
push(token);
|
|
1273
|
+
}
|
|
1274
|
+
while (state.brackets > 0) {
|
|
1275
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1276
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
1277
|
+
decrement("brackets");
|
|
1278
|
+
}
|
|
1279
|
+
while (state.parens > 0) {
|
|
1280
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
1281
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
1282
|
+
decrement("parens");
|
|
1283
|
+
}
|
|
1284
|
+
while (state.braces > 0) {
|
|
1285
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
1286
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
1287
|
+
decrement("braces");
|
|
1288
|
+
}
|
|
1289
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
1290
|
+
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
1291
|
+
}
|
|
1292
|
+
if (state.backtrack === true) {
|
|
1293
|
+
state.output = "";
|
|
1294
|
+
for (const token of state.tokens) {
|
|
1295
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1296
|
+
if (token.suffix) {
|
|
1297
|
+
state.output += token.suffix;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
return state;
|
|
1302
|
+
};
|
|
1303
|
+
parse.fastpaths = (input, options) => {
|
|
1304
|
+
const opts = { ...options };
|
|
1305
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1306
|
+
const len = input.length;
|
|
1307
|
+
if (len > max) {
|
|
1308
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1309
|
+
}
|
|
1310
|
+
input = REPLACEMENTS[input] || input;
|
|
1311
|
+
const {
|
|
1312
|
+
DOT_LITERAL,
|
|
1313
|
+
SLASH_LITERAL,
|
|
1314
|
+
ONE_CHAR,
|
|
1315
|
+
DOTS_SLASH,
|
|
1316
|
+
NO_DOT,
|
|
1317
|
+
NO_DOTS,
|
|
1318
|
+
NO_DOTS_SLASH,
|
|
1319
|
+
STAR,
|
|
1320
|
+
START_ANCHOR
|
|
1321
|
+
} = constants.globChars(opts.windows);
|
|
1322
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1323
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1324
|
+
const capture = opts.capture ? "" : "?:";
|
|
1325
|
+
const state = { negated: false, prefix: "" };
|
|
1326
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
1327
|
+
if (opts.capture) {
|
|
1328
|
+
star = `(${star})`;
|
|
1329
|
+
}
|
|
1330
|
+
const globstar = (opts2) => {
|
|
1331
|
+
if (opts2.noglobstar === true) return star;
|
|
1332
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1333
|
+
};
|
|
1334
|
+
const create = (str) => {
|
|
1335
|
+
switch (str) {
|
|
1336
|
+
case "*":
|
|
1337
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
1338
|
+
case ".*":
|
|
1339
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1340
|
+
case "*.*":
|
|
1341
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1342
|
+
case "*/*":
|
|
1343
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
1344
|
+
case "**":
|
|
1345
|
+
return nodot + globstar(opts);
|
|
1346
|
+
case "**/*":
|
|
1347
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
1348
|
+
case "**/*.*":
|
|
1349
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1350
|
+
case "**/.*":
|
|
1351
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1352
|
+
default: {
|
|
1353
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
1354
|
+
if (!match) return;
|
|
1355
|
+
const source2 = create(match[1]);
|
|
1356
|
+
if (!source2) return;
|
|
1357
|
+
return source2 + DOT_LITERAL + match[2];
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
};
|
|
1361
|
+
const output = utils.removePrefix(input, state);
|
|
1362
|
+
let source = create(output);
|
|
1363
|
+
if (source && opts.strictSlashes !== true) {
|
|
1364
|
+
source += `${SLASH_LITERAL}?`;
|
|
1365
|
+
}
|
|
1366
|
+
return source;
|
|
1367
|
+
};
|
|
1368
|
+
module.exports = parse;
|
|
1369
|
+
}
|
|
1370
|
+
});
|
|
1371
|
+
|
|
1372
|
+
// ../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js
|
|
1373
|
+
var require_picomatch = __commonJS({
|
|
1374
|
+
"../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js"(exports, module) {
|
|
1375
|
+
"use strict";
|
|
1376
|
+
var scan = require_scan();
|
|
1377
|
+
var parse = require_parse();
|
|
1378
|
+
var utils = require_utils();
|
|
1379
|
+
var constants = require_constants();
|
|
1380
|
+
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1381
|
+
var picomatch2 = (glob, options, returnState = false) => {
|
|
1382
|
+
if (Array.isArray(glob)) {
|
|
1383
|
+
const fns = glob.map((input) => picomatch2(input, options, returnState));
|
|
1384
|
+
const arrayMatcher = (str) => {
|
|
1385
|
+
for (const isMatch of fns) {
|
|
1386
|
+
const state2 = isMatch(str);
|
|
1387
|
+
if (state2) return state2;
|
|
1388
|
+
}
|
|
1389
|
+
return false;
|
|
1390
|
+
};
|
|
1391
|
+
return arrayMatcher;
|
|
1392
|
+
}
|
|
1393
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1394
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
1395
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
1396
|
+
}
|
|
1397
|
+
const opts = options || {};
|
|
1398
|
+
const posix = opts.windows;
|
|
1399
|
+
const regex = isState ? picomatch2.compileRe(glob, options) : picomatch2.makeRe(glob, options, false, true);
|
|
1400
|
+
const state = regex.state;
|
|
1401
|
+
delete regex.state;
|
|
1402
|
+
let isIgnored = () => false;
|
|
1403
|
+
if (opts.ignore) {
|
|
1404
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
1405
|
+
isIgnored = picomatch2(opts.ignore, ignoreOpts, returnState);
|
|
1406
|
+
}
|
|
1407
|
+
const matcher = (input, returnObject = false) => {
|
|
1408
|
+
const { isMatch, match, output } = picomatch2.test(input, regex, options, { glob, posix });
|
|
1409
|
+
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
1410
|
+
if (typeof opts.onResult === "function") {
|
|
1411
|
+
opts.onResult(result);
|
|
1412
|
+
}
|
|
1413
|
+
if (isMatch === false) {
|
|
1414
|
+
result.isMatch = false;
|
|
1415
|
+
return returnObject ? result : false;
|
|
1416
|
+
}
|
|
1417
|
+
if (isIgnored(input)) {
|
|
1418
|
+
if (typeof opts.onIgnore === "function") {
|
|
1419
|
+
opts.onIgnore(result);
|
|
1420
|
+
}
|
|
1421
|
+
result.isMatch = false;
|
|
1422
|
+
return returnObject ? result : false;
|
|
1423
|
+
}
|
|
1424
|
+
if (typeof opts.onMatch === "function") {
|
|
1425
|
+
opts.onMatch(result);
|
|
1426
|
+
}
|
|
1427
|
+
return returnObject ? result : true;
|
|
1428
|
+
};
|
|
1429
|
+
if (returnState) {
|
|
1430
|
+
matcher.state = state;
|
|
1431
|
+
}
|
|
1432
|
+
return matcher;
|
|
1433
|
+
};
|
|
1434
|
+
picomatch2.test = (input, regex, options, { glob, posix } = {}) => {
|
|
1435
|
+
if (typeof input !== "string") {
|
|
1436
|
+
throw new TypeError("Expected input to be a string");
|
|
1437
|
+
}
|
|
1438
|
+
if (input === "") {
|
|
1439
|
+
return { isMatch: false, output: "" };
|
|
1440
|
+
}
|
|
1441
|
+
const opts = options || {};
|
|
1442
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
1443
|
+
let match = input === glob;
|
|
1444
|
+
let output = match && format ? format(input) : input;
|
|
1445
|
+
if (match === false) {
|
|
1446
|
+
output = format ? format(input) : input;
|
|
1447
|
+
match = output === glob;
|
|
1448
|
+
}
|
|
1449
|
+
if (match === false || opts.capture === true) {
|
|
1450
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
1451
|
+
match = picomatch2.matchBase(input, regex, options, posix);
|
|
1452
|
+
} else {
|
|
1453
|
+
match = regex.exec(output);
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
return { isMatch: Boolean(match), match, output };
|
|
1457
|
+
};
|
|
1458
|
+
picomatch2.matchBase = (input, glob, options) => {
|
|
1459
|
+
const regex = glob instanceof RegExp ? glob : picomatch2.makeRe(glob, options);
|
|
1460
|
+
return regex.test(utils.basename(input));
|
|
1461
|
+
};
|
|
1462
|
+
picomatch2.isMatch = (str, patterns, options) => picomatch2(patterns, options)(str);
|
|
1463
|
+
picomatch2.parse = (pattern, options) => {
|
|
1464
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch2.parse(p, options));
|
|
1465
|
+
return parse(pattern, { ...options, fastpaths: false });
|
|
1466
|
+
};
|
|
1467
|
+
picomatch2.scan = (input, options) => scan(input, options);
|
|
1468
|
+
picomatch2.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
1469
|
+
if (returnOutput === true) {
|
|
1470
|
+
return state.output;
|
|
1471
|
+
}
|
|
1472
|
+
const opts = options || {};
|
|
1473
|
+
const prepend = opts.contains ? "" : "^";
|
|
1474
|
+
const append = opts.contains ? "" : "$";
|
|
1475
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
1476
|
+
if (state && state.negated === true) {
|
|
1477
|
+
source = `^(?!${source}).*$`;
|
|
1478
|
+
}
|
|
1479
|
+
const regex = picomatch2.toRegex(source, options);
|
|
1480
|
+
if (returnState === true) {
|
|
1481
|
+
regex.state = state;
|
|
1482
|
+
}
|
|
1483
|
+
return regex;
|
|
1484
|
+
};
|
|
1485
|
+
picomatch2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
1486
|
+
if (!input || typeof input !== "string") {
|
|
1487
|
+
throw new TypeError("Expected a non-empty string");
|
|
1488
|
+
}
|
|
1489
|
+
let parsed = { negated: false, fastpaths: true };
|
|
1490
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
1491
|
+
parsed.output = parse.fastpaths(input, options);
|
|
1492
|
+
}
|
|
1493
|
+
if (!parsed.output) {
|
|
1494
|
+
parsed = parse(input, options);
|
|
1495
|
+
}
|
|
1496
|
+
return picomatch2.compileRe(parsed, options, returnOutput, returnState);
|
|
1497
|
+
};
|
|
1498
|
+
picomatch2.toRegex = (source, options) => {
|
|
1499
|
+
try {
|
|
1500
|
+
const opts = options || {};
|
|
1501
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
1502
|
+
} catch (err) {
|
|
1503
|
+
if (options && options.debug === true) throw err;
|
|
1504
|
+
return /$^/;
|
|
1505
|
+
}
|
|
1506
|
+
};
|
|
1507
|
+
picomatch2.constants = constants;
|
|
1508
|
+
module.exports = picomatch2;
|
|
1509
|
+
}
|
|
1510
|
+
});
|
|
1511
|
+
|
|
1512
|
+
// ../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js
|
|
1513
|
+
var require_picomatch2 = __commonJS({
|
|
1514
|
+
"../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js"(exports, module) {
|
|
1515
|
+
"use strict";
|
|
1516
|
+
var pico = require_picomatch();
|
|
1517
|
+
var utils = require_utils();
|
|
1518
|
+
function picomatch2(glob, options, returnState = false) {
|
|
1519
|
+
if (options && (options.windows === null || options.windows === void 0)) {
|
|
1520
|
+
options = { ...options, windows: utils.isWindows() };
|
|
1521
|
+
}
|
|
1522
|
+
return pico(glob, options, returnState);
|
|
1523
|
+
}
|
|
1524
|
+
Object.assign(picomatch2, pico);
|
|
1525
|
+
module.exports = picomatch2;
|
|
1526
|
+
}
|
|
1527
|
+
});
|
|
1528
|
+
|
|
1529
|
+
// ../diff/dist/types.js
|
|
1530
|
+
var DEFAULT_DIFF_CONFIG = {
|
|
1531
|
+
baseline_ref: "main",
|
|
1532
|
+
staleness_threshold_days: 14
|
|
1533
|
+
};
|
|
1534
|
+
var DiffError = class extends Error {
|
|
1535
|
+
constructor(message) {
|
|
1536
|
+
super(message);
|
|
1537
|
+
this.name = "DiffError";
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
|
|
1541
|
+
// ../diff/dist/git.js
|
|
1542
|
+
var import_picomatch = __toESM(require_picomatch2(), 1);
|
|
1543
|
+
import { execSync } from "child_process";
|
|
1544
|
+
import { readFileSync, realpathSync } from "fs";
|
|
1545
|
+
import { dirname, relative, resolve, sep } from "path";
|
|
1546
|
+
|
|
1547
|
+
// ../../node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/index.mjs
|
|
1548
|
+
function Diff() {
|
|
1549
|
+
}
|
|
1550
|
+
Diff.prototype = {
|
|
1551
|
+
diff: function diff(oldString, newString) {
|
|
1552
|
+
var _options$timeout;
|
|
1553
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1554
|
+
var callback = options.callback;
|
|
1555
|
+
if (typeof options === "function") {
|
|
1556
|
+
callback = options;
|
|
1557
|
+
options = {};
|
|
1558
|
+
}
|
|
1559
|
+
var self = this;
|
|
1560
|
+
function done(value) {
|
|
1561
|
+
value = self.postProcess(value, options);
|
|
1562
|
+
if (callback) {
|
|
1563
|
+
setTimeout(function() {
|
|
1564
|
+
callback(value);
|
|
1565
|
+
}, 0);
|
|
1566
|
+
return true;
|
|
1567
|
+
} else {
|
|
1568
|
+
return value;
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
oldString = this.castInput(oldString, options);
|
|
1572
|
+
newString = this.castInput(newString, options);
|
|
1573
|
+
oldString = this.removeEmpty(this.tokenize(oldString, options));
|
|
1574
|
+
newString = this.removeEmpty(this.tokenize(newString, options));
|
|
1575
|
+
var newLen = newString.length, oldLen = oldString.length;
|
|
1576
|
+
var editLength = 1;
|
|
1577
|
+
var maxEditLength = newLen + oldLen;
|
|
1578
|
+
if (options.maxEditLength != null) {
|
|
1579
|
+
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
1580
|
+
}
|
|
1581
|
+
var maxExecutionTime = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : Infinity;
|
|
1582
|
+
var abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
1583
|
+
var bestPath = [{
|
|
1584
|
+
oldPos: -1,
|
|
1585
|
+
lastComponent: void 0
|
|
1586
|
+
}];
|
|
1587
|
+
var newPos = this.extractCommon(bestPath[0], newString, oldString, 0, options);
|
|
1588
|
+
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
1589
|
+
return done(buildValues(self, bestPath[0].lastComponent, newString, oldString, self.useLongestToken));
|
|
1590
|
+
}
|
|
1591
|
+
var minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
1592
|
+
function execEditLength() {
|
|
1593
|
+
for (var diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
1594
|
+
var basePath = void 0;
|
|
1595
|
+
var removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
1596
|
+
if (removePath) {
|
|
1597
|
+
bestPath[diagonalPath - 1] = void 0;
|
|
1598
|
+
}
|
|
1599
|
+
var canAdd = false;
|
|
1600
|
+
if (addPath) {
|
|
1601
|
+
var addPathNewPos = addPath.oldPos - diagonalPath;
|
|
1602
|
+
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
1603
|
+
}
|
|
1604
|
+
var canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
1605
|
+
if (!canAdd && !canRemove) {
|
|
1606
|
+
bestPath[diagonalPath] = void 0;
|
|
1607
|
+
continue;
|
|
1608
|
+
}
|
|
1609
|
+
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
1610
|
+
basePath = self.addToPath(addPath, true, false, 0, options);
|
|
1611
|
+
} else {
|
|
1612
|
+
basePath = self.addToPath(removePath, false, true, 1, options);
|
|
1613
|
+
}
|
|
1614
|
+
newPos = self.extractCommon(basePath, newString, oldString, diagonalPath, options);
|
|
1615
|
+
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
1616
|
+
return done(buildValues(self, basePath.lastComponent, newString, oldString, self.useLongestToken));
|
|
1617
|
+
} else {
|
|
1618
|
+
bestPath[diagonalPath] = basePath;
|
|
1619
|
+
if (basePath.oldPos + 1 >= oldLen) {
|
|
1620
|
+
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
1621
|
+
}
|
|
1622
|
+
if (newPos + 1 >= newLen) {
|
|
1623
|
+
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
editLength++;
|
|
1628
|
+
}
|
|
1629
|
+
if (callback) {
|
|
1630
|
+
(function exec() {
|
|
1631
|
+
setTimeout(function() {
|
|
1632
|
+
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
1633
|
+
return callback();
|
|
1634
|
+
}
|
|
1635
|
+
if (!execEditLength()) {
|
|
1636
|
+
exec();
|
|
1637
|
+
}
|
|
1638
|
+
}, 0);
|
|
1639
|
+
})();
|
|
1640
|
+
} else {
|
|
1641
|
+
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
1642
|
+
var ret = execEditLength();
|
|
1643
|
+
if (ret) {
|
|
1644
|
+
return ret;
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
},
|
|
1649
|
+
addToPath: function addToPath(path, added, removed, oldPosInc, options) {
|
|
1650
|
+
var last = path.lastComponent;
|
|
1651
|
+
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
1652
|
+
return {
|
|
1653
|
+
oldPos: path.oldPos + oldPosInc,
|
|
1654
|
+
lastComponent: {
|
|
1655
|
+
count: last.count + 1,
|
|
1656
|
+
added,
|
|
1657
|
+
removed,
|
|
1658
|
+
previousComponent: last.previousComponent
|
|
1659
|
+
}
|
|
1660
|
+
};
|
|
1661
|
+
} else {
|
|
1662
|
+
return {
|
|
1663
|
+
oldPos: path.oldPos + oldPosInc,
|
|
1664
|
+
lastComponent: {
|
|
1665
|
+
count: 1,
|
|
1666
|
+
added,
|
|
1667
|
+
removed,
|
|
1668
|
+
previousComponent: last
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1672
|
+
},
|
|
1673
|
+
extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath, options) {
|
|
1674
|
+
var newLen = newString.length, oldLen = oldString.length, oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
1675
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldString[oldPos + 1], newString[newPos + 1], options)) {
|
|
1676
|
+
newPos++;
|
|
1677
|
+
oldPos++;
|
|
1678
|
+
commonCount++;
|
|
1679
|
+
if (options.oneChangePerToken) {
|
|
1680
|
+
basePath.lastComponent = {
|
|
1681
|
+
count: 1,
|
|
1682
|
+
previousComponent: basePath.lastComponent,
|
|
1683
|
+
added: false,
|
|
1684
|
+
removed: false
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
if (commonCount && !options.oneChangePerToken) {
|
|
1689
|
+
basePath.lastComponent = {
|
|
1690
|
+
count: commonCount,
|
|
1691
|
+
previousComponent: basePath.lastComponent,
|
|
1692
|
+
added: false,
|
|
1693
|
+
removed: false
|
|
1694
|
+
};
|
|
1695
|
+
}
|
|
1696
|
+
basePath.oldPos = oldPos;
|
|
1697
|
+
return newPos;
|
|
1698
|
+
},
|
|
1699
|
+
equals: function equals(left, right, options) {
|
|
1700
|
+
if (options.comparator) {
|
|
1701
|
+
return options.comparator(left, right);
|
|
1702
|
+
} else {
|
|
1703
|
+
return left === right || options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
1704
|
+
}
|
|
1705
|
+
},
|
|
1706
|
+
removeEmpty: function removeEmpty(array) {
|
|
1707
|
+
var ret = [];
|
|
1708
|
+
for (var i = 0; i < array.length; i++) {
|
|
1709
|
+
if (array[i]) {
|
|
1710
|
+
ret.push(array[i]);
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
return ret;
|
|
1714
|
+
},
|
|
1715
|
+
castInput: function castInput(value) {
|
|
1716
|
+
return value;
|
|
1717
|
+
},
|
|
1718
|
+
tokenize: function tokenize(value) {
|
|
1719
|
+
return Array.from(value);
|
|
1720
|
+
},
|
|
1721
|
+
join: function join(chars) {
|
|
1722
|
+
return chars.join("");
|
|
1723
|
+
},
|
|
1724
|
+
postProcess: function postProcess(changeObjects) {
|
|
1725
|
+
return changeObjects;
|
|
1726
|
+
}
|
|
1727
|
+
};
|
|
1728
|
+
function buildValues(diff2, lastComponent, newString, oldString, useLongestToken) {
|
|
1729
|
+
var components = [];
|
|
1730
|
+
var nextComponent;
|
|
1731
|
+
while (lastComponent) {
|
|
1732
|
+
components.push(lastComponent);
|
|
1733
|
+
nextComponent = lastComponent.previousComponent;
|
|
1734
|
+
delete lastComponent.previousComponent;
|
|
1735
|
+
lastComponent = nextComponent;
|
|
1736
|
+
}
|
|
1737
|
+
components.reverse();
|
|
1738
|
+
var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0;
|
|
1739
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
1740
|
+
var component = components[componentPos];
|
|
1741
|
+
if (!component.removed) {
|
|
1742
|
+
if (!component.added && useLongestToken) {
|
|
1743
|
+
var value = newString.slice(newPos, newPos + component.count);
|
|
1744
|
+
value = value.map(function(value2, i) {
|
|
1745
|
+
var oldValue = oldString[oldPos + i];
|
|
1746
|
+
return oldValue.length > value2.length ? oldValue : value2;
|
|
1747
|
+
});
|
|
1748
|
+
component.value = diff2.join(value);
|
|
1749
|
+
} else {
|
|
1750
|
+
component.value = diff2.join(newString.slice(newPos, newPos + component.count));
|
|
1751
|
+
}
|
|
1752
|
+
newPos += component.count;
|
|
1753
|
+
if (!component.added) {
|
|
1754
|
+
oldPos += component.count;
|
|
1755
|
+
}
|
|
1756
|
+
} else {
|
|
1757
|
+
component.value = diff2.join(oldString.slice(oldPos, oldPos + component.count));
|
|
1758
|
+
oldPos += component.count;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
return components;
|
|
1762
|
+
}
|
|
1763
|
+
var characterDiff = new Diff();
|
|
1764
|
+
function longestCommonPrefix(str1, str2) {
|
|
1765
|
+
var i;
|
|
1766
|
+
for (i = 0; i < str1.length && i < str2.length; i++) {
|
|
1767
|
+
if (str1[i] != str2[i]) {
|
|
1768
|
+
return str1.slice(0, i);
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
return str1.slice(0, i);
|
|
1772
|
+
}
|
|
1773
|
+
function longestCommonSuffix(str1, str2) {
|
|
1774
|
+
var i;
|
|
1775
|
+
if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {
|
|
1776
|
+
return "";
|
|
1777
|
+
}
|
|
1778
|
+
for (i = 0; i < str1.length && i < str2.length; i++) {
|
|
1779
|
+
if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
|
|
1780
|
+
return str1.slice(-i);
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
return str1.slice(-i);
|
|
1784
|
+
}
|
|
1785
|
+
function replacePrefix(string, oldPrefix, newPrefix) {
|
|
1786
|
+
if (string.slice(0, oldPrefix.length) != oldPrefix) {
|
|
1787
|
+
throw Error("string ".concat(JSON.stringify(string), " doesn't start with prefix ").concat(JSON.stringify(oldPrefix), "; this is a bug"));
|
|
1788
|
+
}
|
|
1789
|
+
return newPrefix + string.slice(oldPrefix.length);
|
|
1790
|
+
}
|
|
1791
|
+
function replaceSuffix(string, oldSuffix, newSuffix) {
|
|
1792
|
+
if (!oldSuffix) {
|
|
1793
|
+
return string + newSuffix;
|
|
1794
|
+
}
|
|
1795
|
+
if (string.slice(-oldSuffix.length) != oldSuffix) {
|
|
1796
|
+
throw Error("string ".concat(JSON.stringify(string), " doesn't end with suffix ").concat(JSON.stringify(oldSuffix), "; this is a bug"));
|
|
1797
|
+
}
|
|
1798
|
+
return string.slice(0, -oldSuffix.length) + newSuffix;
|
|
1799
|
+
}
|
|
1800
|
+
function removePrefix(string, oldPrefix) {
|
|
1801
|
+
return replacePrefix(string, oldPrefix, "");
|
|
1802
|
+
}
|
|
1803
|
+
function removeSuffix(string, oldSuffix) {
|
|
1804
|
+
return replaceSuffix(string, oldSuffix, "");
|
|
1805
|
+
}
|
|
1806
|
+
function maximumOverlap(string1, string2) {
|
|
1807
|
+
return string2.slice(0, overlapCount(string1, string2));
|
|
1808
|
+
}
|
|
1809
|
+
function overlapCount(a, b) {
|
|
1810
|
+
var startA = 0;
|
|
1811
|
+
if (a.length > b.length) {
|
|
1812
|
+
startA = a.length - b.length;
|
|
1813
|
+
}
|
|
1814
|
+
var endB = b.length;
|
|
1815
|
+
if (a.length < b.length) {
|
|
1816
|
+
endB = a.length;
|
|
1817
|
+
}
|
|
1818
|
+
var map = Array(endB);
|
|
1819
|
+
var k = 0;
|
|
1820
|
+
map[0] = 0;
|
|
1821
|
+
for (var j = 1; j < endB; j++) {
|
|
1822
|
+
if (b[j] == b[k]) {
|
|
1823
|
+
map[j] = map[k];
|
|
1824
|
+
} else {
|
|
1825
|
+
map[j] = k;
|
|
1826
|
+
}
|
|
1827
|
+
while (k > 0 && b[j] != b[k]) {
|
|
1828
|
+
k = map[k];
|
|
1829
|
+
}
|
|
1830
|
+
if (b[j] == b[k]) {
|
|
1831
|
+
k++;
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
k = 0;
|
|
1835
|
+
for (var i = startA; i < a.length; i++) {
|
|
1836
|
+
while (k > 0 && a[i] != b[k]) {
|
|
1837
|
+
k = map[k];
|
|
1838
|
+
}
|
|
1839
|
+
if (a[i] == b[k]) {
|
|
1840
|
+
k++;
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
return k;
|
|
1844
|
+
}
|
|
1845
|
+
var extendedWordChars = "a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
|
|
1846
|
+
var tokenizeIncludingWhitespace = new RegExp("[".concat(extendedWordChars, "]+|\\s+|[^").concat(extendedWordChars, "]"), "ug");
|
|
1847
|
+
var wordDiff = new Diff();
|
|
1848
|
+
wordDiff.equals = function(left, right, options) {
|
|
1849
|
+
if (options.ignoreCase) {
|
|
1850
|
+
left = left.toLowerCase();
|
|
1851
|
+
right = right.toLowerCase();
|
|
1852
|
+
}
|
|
1853
|
+
return left.trim() === right.trim();
|
|
1854
|
+
};
|
|
1855
|
+
wordDiff.tokenize = function(value) {
|
|
1856
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1857
|
+
var parts;
|
|
1858
|
+
if (options.intlSegmenter) {
|
|
1859
|
+
if (options.intlSegmenter.resolvedOptions().granularity != "word") {
|
|
1860
|
+
throw new Error('The segmenter passed must have a granularity of "word"');
|
|
1861
|
+
}
|
|
1862
|
+
parts = Array.from(options.intlSegmenter.segment(value), function(segment) {
|
|
1863
|
+
return segment.segment;
|
|
1864
|
+
});
|
|
1865
|
+
} else {
|
|
1866
|
+
parts = value.match(tokenizeIncludingWhitespace) || [];
|
|
1867
|
+
}
|
|
1868
|
+
var tokens = [];
|
|
1869
|
+
var prevPart = null;
|
|
1870
|
+
parts.forEach(function(part) {
|
|
1871
|
+
if (/\s/.test(part)) {
|
|
1872
|
+
if (prevPart == null) {
|
|
1873
|
+
tokens.push(part);
|
|
1874
|
+
} else {
|
|
1875
|
+
tokens.push(tokens.pop() + part);
|
|
1876
|
+
}
|
|
1877
|
+
} else if (/\s/.test(prevPart)) {
|
|
1878
|
+
if (tokens[tokens.length - 1] == prevPart) {
|
|
1879
|
+
tokens.push(tokens.pop() + part);
|
|
1880
|
+
} else {
|
|
1881
|
+
tokens.push(prevPart + part);
|
|
1882
|
+
}
|
|
1883
|
+
} else {
|
|
1884
|
+
tokens.push(part);
|
|
1885
|
+
}
|
|
1886
|
+
prevPart = part;
|
|
1887
|
+
});
|
|
1888
|
+
return tokens;
|
|
1889
|
+
};
|
|
1890
|
+
wordDiff.join = function(tokens) {
|
|
1891
|
+
return tokens.map(function(token, i) {
|
|
1892
|
+
if (i == 0) {
|
|
1893
|
+
return token;
|
|
1894
|
+
} else {
|
|
1895
|
+
return token.replace(/^\s+/, "");
|
|
1896
|
+
}
|
|
1897
|
+
}).join("");
|
|
1898
|
+
};
|
|
1899
|
+
wordDiff.postProcess = function(changes, options) {
|
|
1900
|
+
if (!changes || options.oneChangePerToken) {
|
|
1901
|
+
return changes;
|
|
1902
|
+
}
|
|
1903
|
+
var lastKeep = null;
|
|
1904
|
+
var insertion = null;
|
|
1905
|
+
var deletion = null;
|
|
1906
|
+
changes.forEach(function(change) {
|
|
1907
|
+
if (change.added) {
|
|
1908
|
+
insertion = change;
|
|
1909
|
+
} else if (change.removed) {
|
|
1910
|
+
deletion = change;
|
|
1911
|
+
} else {
|
|
1912
|
+
if (insertion || deletion) {
|
|
1913
|
+
dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
|
|
1914
|
+
}
|
|
1915
|
+
lastKeep = change;
|
|
1916
|
+
insertion = null;
|
|
1917
|
+
deletion = null;
|
|
1918
|
+
}
|
|
1919
|
+
});
|
|
1920
|
+
if (insertion || deletion) {
|
|
1921
|
+
dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
|
|
1922
|
+
}
|
|
1923
|
+
return changes;
|
|
1924
|
+
};
|
|
1925
|
+
function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
|
|
1926
|
+
if (deletion && insertion) {
|
|
1927
|
+
var oldWsPrefix = deletion.value.match(/^\s*/)[0];
|
|
1928
|
+
var oldWsSuffix = deletion.value.match(/\s*$/)[0];
|
|
1929
|
+
var newWsPrefix = insertion.value.match(/^\s*/)[0];
|
|
1930
|
+
var newWsSuffix = insertion.value.match(/\s*$/)[0];
|
|
1931
|
+
if (startKeep) {
|
|
1932
|
+
var commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
|
|
1933
|
+
startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
|
|
1934
|
+
deletion.value = removePrefix(deletion.value, commonWsPrefix);
|
|
1935
|
+
insertion.value = removePrefix(insertion.value, commonWsPrefix);
|
|
1936
|
+
}
|
|
1937
|
+
if (endKeep) {
|
|
1938
|
+
var commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
|
|
1939
|
+
endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
|
|
1940
|
+
deletion.value = removeSuffix(deletion.value, commonWsSuffix);
|
|
1941
|
+
insertion.value = removeSuffix(insertion.value, commonWsSuffix);
|
|
1942
|
+
}
|
|
1943
|
+
} else if (insertion) {
|
|
1944
|
+
if (startKeep) {
|
|
1945
|
+
insertion.value = insertion.value.replace(/^\s*/, "");
|
|
1946
|
+
}
|
|
1947
|
+
if (endKeep) {
|
|
1948
|
+
endKeep.value = endKeep.value.replace(/^\s*/, "");
|
|
1949
|
+
}
|
|
1950
|
+
} else if (startKeep && endKeep) {
|
|
1951
|
+
var newWsFull = endKeep.value.match(/^\s*/)[0], delWsStart = deletion.value.match(/^\s*/)[0], delWsEnd = deletion.value.match(/\s*$/)[0];
|
|
1952
|
+
var newWsStart = longestCommonPrefix(newWsFull, delWsStart);
|
|
1953
|
+
deletion.value = removePrefix(deletion.value, newWsStart);
|
|
1954
|
+
var newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
|
|
1955
|
+
deletion.value = removeSuffix(deletion.value, newWsEnd);
|
|
1956
|
+
endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
|
|
1957
|
+
startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
|
|
1958
|
+
} else if (endKeep) {
|
|
1959
|
+
var endKeepWsPrefix = endKeep.value.match(/^\s*/)[0];
|
|
1960
|
+
var deletionWsSuffix = deletion.value.match(/\s*$/)[0];
|
|
1961
|
+
var overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
|
|
1962
|
+
deletion.value = removeSuffix(deletion.value, overlap);
|
|
1963
|
+
} else if (startKeep) {
|
|
1964
|
+
var startKeepWsSuffix = startKeep.value.match(/\s*$/)[0];
|
|
1965
|
+
var deletionWsPrefix = deletion.value.match(/^\s*/)[0];
|
|
1966
|
+
var _overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
|
|
1967
|
+
deletion.value = removePrefix(deletion.value, _overlap);
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
var wordWithSpaceDiff = new Diff();
|
|
1971
|
+
wordWithSpaceDiff.tokenize = function(value) {
|
|
1972
|
+
var regex = new RegExp("(\\r?\\n)|[".concat(extendedWordChars, "]+|[^\\S\\n\\r]+|[^").concat(extendedWordChars, "]"), "ug");
|
|
1973
|
+
return value.match(regex) || [];
|
|
1974
|
+
};
|
|
1975
|
+
var lineDiff = new Diff();
|
|
1976
|
+
lineDiff.tokenize = function(value, options) {
|
|
1977
|
+
if (options.stripTrailingCr) {
|
|
1978
|
+
value = value.replace(/\r\n/g, "\n");
|
|
1979
|
+
}
|
|
1980
|
+
var retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
1981
|
+
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
1982
|
+
linesAndNewlines.pop();
|
|
1983
|
+
}
|
|
1984
|
+
for (var i = 0; i < linesAndNewlines.length; i++) {
|
|
1985
|
+
var line = linesAndNewlines[i];
|
|
1986
|
+
if (i % 2 && !options.newlineIsToken) {
|
|
1987
|
+
retLines[retLines.length - 1] += line;
|
|
1988
|
+
} else {
|
|
1989
|
+
retLines.push(line);
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
return retLines;
|
|
1993
|
+
};
|
|
1994
|
+
lineDiff.equals = function(left, right, options) {
|
|
1995
|
+
if (options.ignoreWhitespace) {
|
|
1996
|
+
if (!options.newlineIsToken || !left.includes("\n")) {
|
|
1997
|
+
left = left.trim();
|
|
1998
|
+
}
|
|
1999
|
+
if (!options.newlineIsToken || !right.includes("\n")) {
|
|
2000
|
+
right = right.trim();
|
|
2001
|
+
}
|
|
2002
|
+
} else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
2003
|
+
if (left.endsWith("\n")) {
|
|
2004
|
+
left = left.slice(0, -1);
|
|
2005
|
+
}
|
|
2006
|
+
if (right.endsWith("\n")) {
|
|
2007
|
+
right = right.slice(0, -1);
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
return Diff.prototype.equals.call(this, left, right, options);
|
|
2011
|
+
};
|
|
2012
|
+
function diffLines(oldStr, newStr, callback) {
|
|
2013
|
+
return lineDiff.diff(oldStr, newStr, callback);
|
|
2014
|
+
}
|
|
2015
|
+
var sentenceDiff = new Diff();
|
|
2016
|
+
sentenceDiff.tokenize = function(value) {
|
|
2017
|
+
return value.split(/(\S.+?[.!?])(?=\s+|$)/);
|
|
2018
|
+
};
|
|
2019
|
+
var cssDiff = new Diff();
|
|
2020
|
+
cssDiff.tokenize = function(value) {
|
|
2021
|
+
return value.split(/([{}:;,]|\s+)/);
|
|
2022
|
+
};
|
|
2023
|
+
function ownKeys(e, r) {
|
|
2024
|
+
var t = Object.keys(e);
|
|
2025
|
+
if (Object.getOwnPropertySymbols) {
|
|
2026
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
2027
|
+
r && (o = o.filter(function(r2) {
|
|
2028
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
2029
|
+
})), t.push.apply(t, o);
|
|
2030
|
+
}
|
|
2031
|
+
return t;
|
|
2032
|
+
}
|
|
2033
|
+
function _objectSpread2(e) {
|
|
2034
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
2035
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
2036
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
2037
|
+
_defineProperty(e, r2, t[r2]);
|
|
2038
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
2039
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
2040
|
+
});
|
|
2041
|
+
}
|
|
2042
|
+
return e;
|
|
2043
|
+
}
|
|
2044
|
+
function _toPrimitive(t, r) {
|
|
2045
|
+
if ("object" != typeof t || !t) return t;
|
|
2046
|
+
var e = t[Symbol.toPrimitive];
|
|
2047
|
+
if (void 0 !== e) {
|
|
2048
|
+
var i = e.call(t, r || "default");
|
|
2049
|
+
if ("object" != typeof i) return i;
|
|
2050
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2051
|
+
}
|
|
2052
|
+
return ("string" === r ? String : Number)(t);
|
|
2053
|
+
}
|
|
2054
|
+
function _toPropertyKey(t) {
|
|
2055
|
+
var i = _toPrimitive(t, "string");
|
|
2056
|
+
return "symbol" == typeof i ? i : i + "";
|
|
2057
|
+
}
|
|
2058
|
+
function _typeof(o) {
|
|
2059
|
+
"@babel/helpers - typeof";
|
|
2060
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
2061
|
+
return typeof o2;
|
|
2062
|
+
} : function(o2) {
|
|
2063
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
2064
|
+
}, _typeof(o);
|
|
2065
|
+
}
|
|
2066
|
+
function _defineProperty(obj, key, value) {
|
|
2067
|
+
key = _toPropertyKey(key);
|
|
2068
|
+
if (key in obj) {
|
|
2069
|
+
Object.defineProperty(obj, key, {
|
|
2070
|
+
value,
|
|
2071
|
+
enumerable: true,
|
|
2072
|
+
configurable: true,
|
|
2073
|
+
writable: true
|
|
2074
|
+
});
|
|
2075
|
+
} else {
|
|
2076
|
+
obj[key] = value;
|
|
2077
|
+
}
|
|
2078
|
+
return obj;
|
|
2079
|
+
}
|
|
2080
|
+
function _toConsumableArray(arr) {
|
|
2081
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
2082
|
+
}
|
|
2083
|
+
function _arrayWithoutHoles(arr) {
|
|
2084
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
2085
|
+
}
|
|
2086
|
+
function _iterableToArray(iter) {
|
|
2087
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
2088
|
+
}
|
|
2089
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
2090
|
+
if (!o) return;
|
|
2091
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
2092
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2093
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
2094
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
2095
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
2096
|
+
}
|
|
2097
|
+
function _arrayLikeToArray(arr, len) {
|
|
2098
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
2099
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
2100
|
+
return arr2;
|
|
2101
|
+
}
|
|
2102
|
+
function _nonIterableSpread() {
|
|
2103
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2104
|
+
}
|
|
2105
|
+
var jsonDiff = new Diff();
|
|
2106
|
+
jsonDiff.useLongestToken = true;
|
|
2107
|
+
jsonDiff.tokenize = lineDiff.tokenize;
|
|
2108
|
+
jsonDiff.castInput = function(value, options) {
|
|
2109
|
+
var undefinedReplacement = options.undefinedReplacement, _options$stringifyRep = options.stringifyReplacer, stringifyReplacer = _options$stringifyRep === void 0 ? function(k, v) {
|
|
2110
|
+
return typeof v === "undefined" ? undefinedReplacement : v;
|
|
2111
|
+
} : _options$stringifyRep;
|
|
2112
|
+
return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, " ");
|
|
2113
|
+
};
|
|
2114
|
+
jsonDiff.equals = function(left, right, options) {
|
|
2115
|
+
return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
|
|
2116
|
+
};
|
|
2117
|
+
function canonicalize(obj, stack, replacementStack, replacer, key) {
|
|
2118
|
+
stack = stack || [];
|
|
2119
|
+
replacementStack = replacementStack || [];
|
|
2120
|
+
if (replacer) {
|
|
2121
|
+
obj = replacer(key, obj);
|
|
2122
|
+
}
|
|
2123
|
+
var i;
|
|
2124
|
+
for (i = 0; i < stack.length; i += 1) {
|
|
2125
|
+
if (stack[i] === obj) {
|
|
2126
|
+
return replacementStack[i];
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
var canonicalizedObj;
|
|
2130
|
+
if ("[object Array]" === Object.prototype.toString.call(obj)) {
|
|
2131
|
+
stack.push(obj);
|
|
2132
|
+
canonicalizedObj = new Array(obj.length);
|
|
2133
|
+
replacementStack.push(canonicalizedObj);
|
|
2134
|
+
for (i = 0; i < obj.length; i += 1) {
|
|
2135
|
+
canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
|
|
2136
|
+
}
|
|
2137
|
+
stack.pop();
|
|
2138
|
+
replacementStack.pop();
|
|
2139
|
+
return canonicalizedObj;
|
|
2140
|
+
}
|
|
2141
|
+
if (obj && obj.toJSON) {
|
|
2142
|
+
obj = obj.toJSON();
|
|
2143
|
+
}
|
|
2144
|
+
if (_typeof(obj) === "object" && obj !== null) {
|
|
2145
|
+
stack.push(obj);
|
|
2146
|
+
canonicalizedObj = {};
|
|
2147
|
+
replacementStack.push(canonicalizedObj);
|
|
2148
|
+
var sortedKeys = [], _key;
|
|
2149
|
+
for (_key in obj) {
|
|
2150
|
+
if (Object.prototype.hasOwnProperty.call(obj, _key)) {
|
|
2151
|
+
sortedKeys.push(_key);
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
sortedKeys.sort();
|
|
2155
|
+
for (i = 0; i < sortedKeys.length; i += 1) {
|
|
2156
|
+
_key = sortedKeys[i];
|
|
2157
|
+
canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
|
|
2158
|
+
}
|
|
2159
|
+
stack.pop();
|
|
2160
|
+
replacementStack.pop();
|
|
2161
|
+
} else {
|
|
2162
|
+
canonicalizedObj = obj;
|
|
2163
|
+
}
|
|
2164
|
+
return canonicalizedObj;
|
|
2165
|
+
}
|
|
2166
|
+
var arrayDiff = new Diff();
|
|
2167
|
+
arrayDiff.tokenize = function(value) {
|
|
2168
|
+
return value.slice();
|
|
2169
|
+
};
|
|
2170
|
+
arrayDiff.join = arrayDiff.removeEmpty = function(value) {
|
|
2171
|
+
return value;
|
|
2172
|
+
};
|
|
2173
|
+
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
2174
|
+
if (!options) {
|
|
2175
|
+
options = {};
|
|
2176
|
+
}
|
|
2177
|
+
if (typeof options === "function") {
|
|
2178
|
+
options = {
|
|
2179
|
+
callback: options
|
|
2180
|
+
};
|
|
2181
|
+
}
|
|
2182
|
+
if (typeof options.context === "undefined") {
|
|
2183
|
+
options.context = 4;
|
|
2184
|
+
}
|
|
2185
|
+
if (options.newlineIsToken) {
|
|
2186
|
+
throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
|
|
2187
|
+
}
|
|
2188
|
+
if (!options.callback) {
|
|
2189
|
+
return diffLinesResultToPatch(diffLines(oldStr, newStr, options));
|
|
2190
|
+
} else {
|
|
2191
|
+
var _options = options, _callback = _options.callback;
|
|
2192
|
+
diffLines(oldStr, newStr, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
2193
|
+
callback: function callback(diff2) {
|
|
2194
|
+
var patch = diffLinesResultToPatch(diff2);
|
|
2195
|
+
_callback(patch);
|
|
2196
|
+
}
|
|
2197
|
+
}));
|
|
2198
|
+
}
|
|
2199
|
+
function diffLinesResultToPatch(diff2) {
|
|
2200
|
+
if (!diff2) {
|
|
2201
|
+
return;
|
|
2202
|
+
}
|
|
2203
|
+
diff2.push({
|
|
2204
|
+
value: "",
|
|
2205
|
+
lines: []
|
|
2206
|
+
});
|
|
2207
|
+
function contextLines(lines) {
|
|
2208
|
+
return lines.map(function(entry) {
|
|
2209
|
+
return " " + entry;
|
|
2210
|
+
});
|
|
2211
|
+
}
|
|
2212
|
+
var hunks = [];
|
|
2213
|
+
var oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
|
|
2214
|
+
var _loop = function _loop2() {
|
|
2215
|
+
var current = diff2[i], lines = current.lines || splitLines(current.value);
|
|
2216
|
+
current.lines = lines;
|
|
2217
|
+
if (current.added || current.removed) {
|
|
2218
|
+
var _curRange;
|
|
2219
|
+
if (!oldRangeStart) {
|
|
2220
|
+
var prev = diff2[i - 1];
|
|
2221
|
+
oldRangeStart = oldLine;
|
|
2222
|
+
newRangeStart = newLine;
|
|
2223
|
+
if (prev) {
|
|
2224
|
+
curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
|
|
2225
|
+
oldRangeStart -= curRange.length;
|
|
2226
|
+
newRangeStart -= curRange.length;
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
(_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function(entry) {
|
|
2230
|
+
return (current.added ? "+" : "-") + entry;
|
|
2231
|
+
})));
|
|
2232
|
+
if (current.added) {
|
|
2233
|
+
newLine += lines.length;
|
|
2234
|
+
} else {
|
|
2235
|
+
oldLine += lines.length;
|
|
2236
|
+
}
|
|
2237
|
+
} else {
|
|
2238
|
+
if (oldRangeStart) {
|
|
2239
|
+
if (lines.length <= options.context * 2 && i < diff2.length - 2) {
|
|
2240
|
+
var _curRange2;
|
|
2241
|
+
(_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines)));
|
|
2242
|
+
} else {
|
|
2243
|
+
var _curRange3;
|
|
2244
|
+
var contextSize = Math.min(lines.length, options.context);
|
|
2245
|
+
(_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize))));
|
|
2246
|
+
var _hunk = {
|
|
2247
|
+
oldStart: oldRangeStart,
|
|
2248
|
+
oldLines: oldLine - oldRangeStart + contextSize,
|
|
2249
|
+
newStart: newRangeStart,
|
|
2250
|
+
newLines: newLine - newRangeStart + contextSize,
|
|
2251
|
+
lines: curRange
|
|
2252
|
+
};
|
|
2253
|
+
hunks.push(_hunk);
|
|
2254
|
+
oldRangeStart = 0;
|
|
2255
|
+
newRangeStart = 0;
|
|
2256
|
+
curRange = [];
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
oldLine += lines.length;
|
|
2260
|
+
newLine += lines.length;
|
|
2261
|
+
}
|
|
2262
|
+
};
|
|
2263
|
+
for (var i = 0; i < diff2.length; i++) {
|
|
2264
|
+
_loop();
|
|
2265
|
+
}
|
|
2266
|
+
for (var _i = 0, _hunks = hunks; _i < _hunks.length; _i++) {
|
|
2267
|
+
var hunk = _hunks[_i];
|
|
2268
|
+
for (var _i2 = 0; _i2 < hunk.lines.length; _i2++) {
|
|
2269
|
+
if (hunk.lines[_i2].endsWith("\n")) {
|
|
2270
|
+
hunk.lines[_i2] = hunk.lines[_i2].slice(0, -1);
|
|
2271
|
+
} else {
|
|
2272
|
+
hunk.lines.splice(_i2 + 1, 0, "\");
|
|
2273
|
+
_i2++;
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
return {
|
|
2278
|
+
oldFileName,
|
|
2279
|
+
newFileName,
|
|
2280
|
+
oldHeader,
|
|
2281
|
+
newHeader,
|
|
2282
|
+
hunks
|
|
2283
|
+
};
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
function formatPatch(diff2) {
|
|
2287
|
+
if (Array.isArray(diff2)) {
|
|
2288
|
+
return diff2.map(formatPatch).join("\n");
|
|
2289
|
+
}
|
|
2290
|
+
var ret = [];
|
|
2291
|
+
if (diff2.oldFileName == diff2.newFileName) {
|
|
2292
|
+
ret.push("Index: " + diff2.oldFileName);
|
|
2293
|
+
}
|
|
2294
|
+
ret.push("===================================================================");
|
|
2295
|
+
ret.push("--- " + diff2.oldFileName + (typeof diff2.oldHeader === "undefined" ? "" : " " + diff2.oldHeader));
|
|
2296
|
+
ret.push("+++ " + diff2.newFileName + (typeof diff2.newHeader === "undefined" ? "" : " " + diff2.newHeader));
|
|
2297
|
+
for (var i = 0; i < diff2.hunks.length; i++) {
|
|
2298
|
+
var hunk = diff2.hunks[i];
|
|
2299
|
+
if (hunk.oldLines === 0) {
|
|
2300
|
+
hunk.oldStart -= 1;
|
|
2301
|
+
}
|
|
2302
|
+
if (hunk.newLines === 0) {
|
|
2303
|
+
hunk.newStart -= 1;
|
|
2304
|
+
}
|
|
2305
|
+
ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
|
|
2306
|
+
ret.push.apply(ret, hunk.lines);
|
|
2307
|
+
}
|
|
2308
|
+
return ret.join("\n") + "\n";
|
|
2309
|
+
}
|
|
2310
|
+
function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
2311
|
+
var _options2;
|
|
2312
|
+
if (typeof options === "function") {
|
|
2313
|
+
options = {
|
|
2314
|
+
callback: options
|
|
2315
|
+
};
|
|
2316
|
+
}
|
|
2317
|
+
if (!((_options2 = options) !== null && _options2 !== void 0 && _options2.callback)) {
|
|
2318
|
+
var patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
|
|
2319
|
+
if (!patchObj) {
|
|
2320
|
+
return;
|
|
2321
|
+
}
|
|
2322
|
+
return formatPatch(patchObj);
|
|
2323
|
+
} else {
|
|
2324
|
+
var _options3 = options, _callback2 = _options3.callback;
|
|
2325
|
+
structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
2326
|
+
callback: function callback(patchObj2) {
|
|
2327
|
+
if (!patchObj2) {
|
|
2328
|
+
_callback2();
|
|
2329
|
+
} else {
|
|
2330
|
+
_callback2(formatPatch(patchObj2));
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
}));
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
2337
|
+
return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
|
|
2338
|
+
}
|
|
2339
|
+
function splitLines(text) {
|
|
2340
|
+
var hasTrailingNl = text.endsWith("\n");
|
|
2341
|
+
var result = text.split("\n").map(function(line) {
|
|
2342
|
+
return line + "\n";
|
|
2343
|
+
});
|
|
2344
|
+
if (hasTrailingNl) {
|
|
2345
|
+
result.pop();
|
|
2346
|
+
} else {
|
|
2347
|
+
result.push(result.pop().slice(0, -1));
|
|
2348
|
+
}
|
|
2349
|
+
return result;
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
// ../diff/dist/diff-specs.js
|
|
2353
|
+
function diffSpecs(before, after) {
|
|
2354
|
+
const frontmatter = diffFrontmatter(before.frontmatter, after.frontmatter);
|
|
2355
|
+
const sections = diffSections(before.parsedSections, after.parsedSections);
|
|
2356
|
+
const specId = after.frontmatter.id;
|
|
2357
|
+
const parts = [];
|
|
2358
|
+
if (frontmatter.length > 0)
|
|
2359
|
+
parts.push(`${frontmatter.length} field(s) changed`);
|
|
2360
|
+
if (sections.length > 0)
|
|
2361
|
+
parts.push(`${sections.length} section(s) changed`);
|
|
2362
|
+
const summary = parts.length > 0 ? `${specId}: ${parts.join(", ")}` : `${specId}: no changes`;
|
|
2363
|
+
return { specId, filePath: after.filePath, frontmatter, sections, summary };
|
|
2364
|
+
}
|
|
2365
|
+
function diffFrontmatter(before, after) {
|
|
2366
|
+
const changes = [];
|
|
2367
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)]);
|
|
2368
|
+
for (const key of allKeys) {
|
|
2369
|
+
const inBefore = Object.prototype.hasOwnProperty.call(before, key);
|
|
2370
|
+
const inAfter = Object.prototype.hasOwnProperty.call(after, key);
|
|
2371
|
+
if (inBefore && !inAfter) {
|
|
2372
|
+
changes.push({ field: key, type: "removed", before: before[key] });
|
|
2373
|
+
} else if (!inBefore && inAfter) {
|
|
2374
|
+
changes.push({ field: key, type: "added", after: after[key] });
|
|
2375
|
+
} else if (inBefore && inAfter) {
|
|
2376
|
+
const bVal = before[key];
|
|
2377
|
+
const aVal = after[key];
|
|
2378
|
+
if (JSON.stringify(bVal) !== JSON.stringify(aVal)) {
|
|
2379
|
+
changes.push({ field: key, type: "modified", before: bVal, after: aVal });
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
return changes;
|
|
2384
|
+
}
|
|
2385
|
+
function diffSections(before, after) {
|
|
2386
|
+
const changes = [];
|
|
2387
|
+
const beforeMap = /* @__PURE__ */ new Map();
|
|
2388
|
+
for (const section of before) {
|
|
2389
|
+
beforeMap.set(section.heading, section);
|
|
2390
|
+
}
|
|
2391
|
+
const afterMap = /* @__PURE__ */ new Map();
|
|
2392
|
+
for (const section of after) {
|
|
2393
|
+
afterMap.set(section.heading, section);
|
|
2394
|
+
}
|
|
2395
|
+
for (const [heading] of beforeMap) {
|
|
2396
|
+
if (!afterMap.has(heading)) {
|
|
2397
|
+
changes.push({ heading, type: "removed" });
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
for (const [heading, afterSection] of afterMap) {
|
|
2401
|
+
const beforeSection = beforeMap.get(heading);
|
|
2402
|
+
if (!beforeSection) {
|
|
2403
|
+
changes.push({ heading, type: "added" });
|
|
2404
|
+
} else if (beforeSection.content !== afterSection.content) {
|
|
2405
|
+
const contentDiff = createPatch(heading, beforeSection.content, afterSection.content, "before", "after");
|
|
2406
|
+
changes.push({ heading, type: "modified", contentDiff });
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
return changes;
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
// ../diff/dist/impact.js
|
|
2413
|
+
var STRUCTURAL_SECTIONS = /* @__PURE__ */ new Set([
|
|
2414
|
+
"Goals",
|
|
2415
|
+
"Architecture",
|
|
2416
|
+
"Features",
|
|
2417
|
+
"Endpoints",
|
|
2418
|
+
"Data Model",
|
|
2419
|
+
"API Design",
|
|
2420
|
+
"Problem Statement"
|
|
2421
|
+
]);
|
|
2422
|
+
function bfsDistances(startId, relations) {
|
|
2423
|
+
const distances = /* @__PURE__ */ new Map();
|
|
2424
|
+
const queue = [];
|
|
2425
|
+
for (const edge of relations.edges) {
|
|
2426
|
+
if (edge.from === startId) {
|
|
2427
|
+
if (!distances.has(edge.to)) {
|
|
2428
|
+
distances.set(edge.to, 1);
|
|
2429
|
+
queue.push({ id: edge.to, distance: 1 });
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
while (queue.length > 0) {
|
|
2434
|
+
const item = queue.shift();
|
|
2435
|
+
const currentDist = item.distance;
|
|
2436
|
+
for (const edge of relations.edges) {
|
|
2437
|
+
if (edge.from === item.id && !distances.has(edge.to)) {
|
|
2438
|
+
distances.set(edge.to, currentDist + 1);
|
|
2439
|
+
queue.push({ id: edge.to, distance: currentDist + 1 });
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
return distances;
|
|
2444
|
+
}
|
|
2445
|
+
function daysBetween(dateStr) {
|
|
2446
|
+
const then = new Date(dateStr).getTime();
|
|
2447
|
+
const now = Date.now();
|
|
2448
|
+
return Math.max(0, (now - then) / (1e3 * 60 * 60 * 24));
|
|
2449
|
+
}
|
|
2450
|
+
function clamp(min, max, value) {
|
|
2451
|
+
return Math.min(max, Math.max(min, value));
|
|
2452
|
+
}
|
|
2453
|
+
function analyzeImpact(changedSpecId, diff2, relations, allSpecs, thresholdDays = 14) {
|
|
2454
|
+
const distanceMap = bfsDistances(changedSpecId, relations);
|
|
2455
|
+
if (distanceMap.size === 0) {
|
|
2456
|
+
return {
|
|
2457
|
+
changedSpec: changedSpecId,
|
|
2458
|
+
downstream: [],
|
|
2459
|
+
totalAffected: 0
|
|
2460
|
+
};
|
|
2461
|
+
}
|
|
2462
|
+
const totalSections = Math.max(1, diff2.sections.length);
|
|
2463
|
+
const structuralSectionsChanged = diff2.sections.filter((s) => STRUCTURAL_SECTIONS.has(s.heading)).length;
|
|
2464
|
+
const specById = /* @__PURE__ */ new Map();
|
|
2465
|
+
for (const spec of allSpecs) {
|
|
2466
|
+
const id = spec.frontmatter.id;
|
|
2467
|
+
if (id)
|
|
2468
|
+
specById.set(id, spec);
|
|
2469
|
+
}
|
|
2470
|
+
const downstream = [];
|
|
2471
|
+
for (const [specId, distance] of distanceMap) {
|
|
2472
|
+
const spec = specById.get(specId);
|
|
2473
|
+
const lastUpdated = spec?.frontmatter.updated ?? spec?.frontmatter.created ?? null;
|
|
2474
|
+
const filePath = spec?.filePath ?? `specs/${specId}.md`;
|
|
2475
|
+
let staleness;
|
|
2476
|
+
if (lastUpdated) {
|
|
2477
|
+
const daysSinceUpdate = daysBetween(lastUpdated);
|
|
2478
|
+
staleness = clamp(0, 1, daysSinceUpdate / thresholdDays * 0.5 + structuralSectionsChanged / totalSections * 0.3 + 1 / distance * 0.2);
|
|
2479
|
+
} else {
|
|
2480
|
+
staleness = clamp(0, 1, structuralSectionsChanged / totalSections * 0.3 + 1 / distance * 0.2);
|
|
2481
|
+
}
|
|
2482
|
+
const parts = [];
|
|
2483
|
+
parts.push(`depends on ${changedSpecId} (distance ${distance})`);
|
|
2484
|
+
if (structuralSectionsChanged > 0) {
|
|
2485
|
+
parts.push(`${structuralSectionsChanged} structural section(s) changed`);
|
|
2486
|
+
}
|
|
2487
|
+
if (lastUpdated) {
|
|
2488
|
+
const days = Math.round(daysBetween(lastUpdated));
|
|
2489
|
+
parts.push(`last updated ${days} day(s) ago`);
|
|
2490
|
+
}
|
|
2491
|
+
const reason = parts.join("; ");
|
|
2492
|
+
downstream.push({
|
|
2493
|
+
specId,
|
|
2494
|
+
filePath,
|
|
2495
|
+
distance,
|
|
2496
|
+
lastUpdated,
|
|
2497
|
+
staleness,
|
|
2498
|
+
reason
|
|
2499
|
+
});
|
|
2500
|
+
}
|
|
2501
|
+
downstream.sort((a, b) => a.distance - b.distance || b.staleness - a.staleness);
|
|
2502
|
+
return {
|
|
2503
|
+
changedSpec: changedSpecId,
|
|
2504
|
+
downstream,
|
|
2505
|
+
totalAffected: downstream.length
|
|
2506
|
+
};
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
// ../diff/dist/cross-refs.js
|
|
2510
|
+
function checkCrossReferences(allSpecs, removedIds) {
|
|
2511
|
+
const validIds = new Set(allSpecs.map((s) => s.frontmatter.id));
|
|
2512
|
+
for (const id of removedIds) {
|
|
2513
|
+
validIds.delete(id);
|
|
2514
|
+
}
|
|
2515
|
+
const broken = [];
|
|
2516
|
+
for (const spec of allSpecs) {
|
|
2517
|
+
const references = spec.frontmatter.references;
|
|
2518
|
+
if (!references || references.length === 0) {
|
|
2519
|
+
continue;
|
|
2520
|
+
}
|
|
2521
|
+
for (const ref of references) {
|
|
2522
|
+
if (!validIds.has(ref.id)) {
|
|
2523
|
+
broken.push({
|
|
2524
|
+
specId: spec.frontmatter.id,
|
|
2525
|
+
field: "references",
|
|
2526
|
+
type: "broken-reference",
|
|
2527
|
+
referencedId: ref.id
|
|
2528
|
+
});
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
return broken;
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
// ../diff/dist/git.js
|
|
2536
|
+
function getRepoRoot(cwd) {
|
|
2537
|
+
let root;
|
|
2538
|
+
try {
|
|
2539
|
+
root = execSync("git rev-parse --show-toplevel", {
|
|
2540
|
+
cwd,
|
|
2541
|
+
encoding: "utf-8",
|
|
2542
|
+
stdio: "pipe"
|
|
2543
|
+
}).trim();
|
|
2544
|
+
} catch {
|
|
2545
|
+
throw new DiffError("diff compares specs across git history, and this directory is not inside a git repository. Run `git init` first, or run diff from a checked-out project.");
|
|
2546
|
+
}
|
|
2547
|
+
return realpathSync(root);
|
|
2548
|
+
}
|
|
2549
|
+
function validateRef(ref, cwd) {
|
|
2550
|
+
try {
|
|
2551
|
+
execSync(`git rev-parse --verify ${ref}`, { cwd, encoding: "utf-8", stdio: "pipe" });
|
|
2552
|
+
} catch {
|
|
2553
|
+
throw new DiffError(`Invalid git ref: "${ref}"`);
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
function gitShow(ref, filePath, projectRoot, repoRoot) {
|
|
2557
|
+
const relPath = relative(repoRoot, resolve(projectRoot, filePath));
|
|
2558
|
+
try {
|
|
2559
|
+
return execSync(`git show ${ref}:${relPath}`, {
|
|
2560
|
+
cwd: repoRoot,
|
|
2561
|
+
encoding: "utf-8",
|
|
2562
|
+
stdio: "pipe"
|
|
2563
|
+
});
|
|
2564
|
+
} catch {
|
|
2565
|
+
throw new DiffError(`Cannot read "${filePath}" at ref "${ref}"`);
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
function toPosix(p) {
|
|
2569
|
+
return sep === "/" ? p : p.split(sep).join("/");
|
|
2570
|
+
}
|
|
2571
|
+
function buildEntryMatchers(specPathsByKey, projectRoot, repoRoot) {
|
|
2572
|
+
return [...specPathsByKey].map(([key, specPath]) => ({
|
|
2573
|
+
key,
|
|
2574
|
+
isMatch: (0, import_picomatch.default)(toPosix(relative(repoRoot, resolve(projectRoot, specPath))))
|
|
2575
|
+
}));
|
|
2576
|
+
}
|
|
2577
|
+
function getChangedSpecFiles(baseRef, headRef, matchers, projectRoot, repoRoot) {
|
|
2578
|
+
let diffOutput;
|
|
2579
|
+
try {
|
|
2580
|
+
diffOutput = execSync(`git diff --name-status ${baseRef} ${headRef}`, {
|
|
2581
|
+
cwd: repoRoot,
|
|
2582
|
+
encoding: "utf-8",
|
|
2583
|
+
stdio: "pipe"
|
|
2584
|
+
});
|
|
2585
|
+
} catch {
|
|
2586
|
+
throw new DiffError(`Failed to run git diff between "${baseRef}" and "${headRef}"`);
|
|
2587
|
+
}
|
|
2588
|
+
const result = { modified: [], added: [], deleted: [] };
|
|
2589
|
+
for (const line of diffOutput.trim().split("\n")) {
|
|
2590
|
+
if (!line)
|
|
2591
|
+
continue;
|
|
2592
|
+
const parts = line.split(" ");
|
|
2593
|
+
const status = parts[0];
|
|
2594
|
+
const filePath = parts[1];
|
|
2595
|
+
if (!status || !filePath)
|
|
2596
|
+
continue;
|
|
2597
|
+
const entry = matchers.find((m) => m.isMatch(filePath));
|
|
2598
|
+
if (!entry)
|
|
2599
|
+
continue;
|
|
2600
|
+
const changed = {
|
|
2601
|
+
path: relative(projectRoot, resolve(repoRoot, filePath)),
|
|
2602
|
+
entryKey: entry.key
|
|
2603
|
+
};
|
|
2604
|
+
if (status === "M") {
|
|
2605
|
+
result.modified.push(changed);
|
|
2606
|
+
} else if (status === "A") {
|
|
2607
|
+
result.added.push(changed);
|
|
2608
|
+
} else if (status === "D") {
|
|
2609
|
+
result.deleted.push(changed);
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
return result;
|
|
2613
|
+
}
|
|
2614
|
+
function listSpecFilesAtRef(ref, matchers, projectRoot, repoRoot) {
|
|
2615
|
+
const byEntry = new Map(matchers.map((m) => [m.key, []]));
|
|
2616
|
+
let listing;
|
|
2617
|
+
try {
|
|
2618
|
+
listing = execSync(`git ls-tree -r --name-only ${ref}`, {
|
|
2619
|
+
cwd: repoRoot,
|
|
2620
|
+
encoding: "utf-8",
|
|
2621
|
+
stdio: "pipe"
|
|
2622
|
+
});
|
|
2623
|
+
} catch {
|
|
2624
|
+
throw new DiffError(`Failed to list files at ref "${ref}"`);
|
|
2625
|
+
}
|
|
2626
|
+
for (const filePath of listing.trim().split("\n")) {
|
|
2627
|
+
if (!filePath)
|
|
2628
|
+
continue;
|
|
2629
|
+
const entry = matchers.find((m) => m.isMatch(filePath));
|
|
2630
|
+
if (!entry)
|
|
2631
|
+
continue;
|
|
2632
|
+
byEntry.get(entry.key)?.push(relative(projectRoot, resolve(repoRoot, filePath)));
|
|
2633
|
+
}
|
|
2634
|
+
return byEntry;
|
|
2635
|
+
}
|
|
2636
|
+
function listSpecFilesInWorktree(matchers, projectRoot, repoRoot) {
|
|
2637
|
+
const byEntry = new Map(matchers.map((m) => [m.key, []]));
|
|
2638
|
+
let listing;
|
|
2639
|
+
try {
|
|
2640
|
+
listing = execSync("git ls-files --cached --others --exclude-standard", {
|
|
2641
|
+
cwd: repoRoot,
|
|
2642
|
+
encoding: "utf-8",
|
|
2643
|
+
stdio: "pipe"
|
|
2644
|
+
});
|
|
2645
|
+
} catch {
|
|
2646
|
+
throw new DiffError("Failed to list files in the working tree");
|
|
2647
|
+
}
|
|
2648
|
+
for (const filePath of listing.trim().split("\n")) {
|
|
2649
|
+
if (!filePath)
|
|
2650
|
+
continue;
|
|
2651
|
+
const entry = matchers.find((m) => m.isMatch(filePath));
|
|
2652
|
+
if (!entry)
|
|
2653
|
+
continue;
|
|
2654
|
+
byEntry.get(entry.key)?.push(relative(projectRoot, resolve(repoRoot, filePath)));
|
|
2655
|
+
}
|
|
2656
|
+
return byEntry;
|
|
2657
|
+
}
|
|
2658
|
+
function refSide(ref, matchers, projectRoot, repoRoot) {
|
|
2659
|
+
return {
|
|
2660
|
+
read: (path) => gitShow(ref, path, projectRoot, repoRoot),
|
|
2661
|
+
list: () => listSpecFilesAtRef(ref, matchers, projectRoot, repoRoot)
|
|
2662
|
+
};
|
|
2663
|
+
}
|
|
2664
|
+
function worktreeSide(matchers, projectRoot, repoRoot) {
|
|
2665
|
+
return {
|
|
2666
|
+
read: (path) => {
|
|
2667
|
+
try {
|
|
2668
|
+
return readFileSync(resolve(projectRoot, path), "utf-8");
|
|
2669
|
+
} catch {
|
|
2670
|
+
throw new DiffError(`Cannot read "${path}" in the working tree`);
|
|
2671
|
+
}
|
|
2672
|
+
},
|
|
2673
|
+
list: () => listSpecFilesInWorktree(matchers, projectRoot, repoRoot)
|
|
2674
|
+
};
|
|
2675
|
+
}
|
|
2676
|
+
function getChangedSpecFilesInWorktree(baseRef, matchers, projectRoot, repoRoot) {
|
|
2677
|
+
let diffOutput;
|
|
2678
|
+
try {
|
|
2679
|
+
diffOutput = execSync(`git diff --name-status ${baseRef}`, {
|
|
2680
|
+
cwd: repoRoot,
|
|
2681
|
+
encoding: "utf-8",
|
|
2682
|
+
stdio: "pipe"
|
|
2683
|
+
});
|
|
2684
|
+
} catch {
|
|
2685
|
+
throw new DiffError(`Failed to diff "${baseRef}" against the working tree`);
|
|
2686
|
+
}
|
|
2687
|
+
const result = { modified: [], added: [], deleted: [] };
|
|
2688
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2689
|
+
const record = (status, filePath) => {
|
|
2690
|
+
const entry = matchers.find((m) => m.isMatch(filePath));
|
|
2691
|
+
if (!entry)
|
|
2692
|
+
return;
|
|
2693
|
+
if (seen.has(filePath))
|
|
2694
|
+
return;
|
|
2695
|
+
seen.add(filePath);
|
|
2696
|
+
const changed = {
|
|
2697
|
+
path: relative(projectRoot, resolve(repoRoot, filePath)),
|
|
2698
|
+
entryKey: entry.key
|
|
2699
|
+
};
|
|
2700
|
+
if (status === "M")
|
|
2701
|
+
result.modified.push(changed);
|
|
2702
|
+
else if (status === "A")
|
|
2703
|
+
result.added.push(changed);
|
|
2704
|
+
else if (status === "D")
|
|
2705
|
+
result.deleted.push(changed);
|
|
2706
|
+
};
|
|
2707
|
+
for (const line of diffOutput.trim().split("\n")) {
|
|
2708
|
+
if (!line)
|
|
2709
|
+
continue;
|
|
2710
|
+
const parts = line.split(" ");
|
|
2711
|
+
const status = parts[0];
|
|
2712
|
+
const filePath = parts[1];
|
|
2713
|
+
if (!status || !filePath)
|
|
2714
|
+
continue;
|
|
2715
|
+
record(status, filePath);
|
|
2716
|
+
}
|
|
2717
|
+
let untracked;
|
|
2718
|
+
try {
|
|
2719
|
+
untracked = execSync("git ls-files --others --exclude-standard", {
|
|
2720
|
+
cwd: repoRoot,
|
|
2721
|
+
encoding: "utf-8",
|
|
2722
|
+
stdio: "pipe"
|
|
2723
|
+
});
|
|
2724
|
+
} catch {
|
|
2725
|
+
throw new DiffError("Failed to list untracked files");
|
|
2726
|
+
}
|
|
2727
|
+
for (const filePath of untracked.trim().split("\n")) {
|
|
2728
|
+
if (!filePath)
|
|
2729
|
+
continue;
|
|
2730
|
+
record("A", filePath);
|
|
2731
|
+
}
|
|
2732
|
+
return result;
|
|
2733
|
+
}
|
|
2734
|
+
function listUncommittedSpecFiles(matchers, projectRoot, repoRoot) {
|
|
2735
|
+
let statusOutput;
|
|
2736
|
+
try {
|
|
2737
|
+
statusOutput = execSync("git status --porcelain", {
|
|
2738
|
+
cwd: repoRoot,
|
|
2739
|
+
encoding: "utf-8",
|
|
2740
|
+
stdio: "pipe"
|
|
2741
|
+
});
|
|
2742
|
+
} catch {
|
|
2743
|
+
return [];
|
|
2744
|
+
}
|
|
2745
|
+
const files = [];
|
|
2746
|
+
for (const line of statusOutput.split("\n")) {
|
|
2747
|
+
if (!line.trim())
|
|
2748
|
+
continue;
|
|
2749
|
+
const rawPath = line.slice(3);
|
|
2750
|
+
const renamed = rawPath.includes(" -> ") ? rawPath.split(" -> ")[1] : void 0;
|
|
2751
|
+
const filePath = (renamed ?? rawPath).replace(/^"|"$/g, "");
|
|
2752
|
+
if (!matchers.some((m) => m.isMatch(filePath)))
|
|
2753
|
+
continue;
|
|
2754
|
+
files.push(relative(projectRoot, resolve(repoRoot, filePath)));
|
|
2755
|
+
}
|
|
2756
|
+
return files;
|
|
2757
|
+
}
|
|
2758
|
+
async function specIdsFrom(files, read) {
|
|
2759
|
+
const ids = [];
|
|
2760
|
+
for (const file of files) {
|
|
2761
|
+
try {
|
|
2762
|
+
const parsed = await parseSpecFromString(read(file.path), file.path);
|
|
2763
|
+
ids.push(parsed.frontmatter.id);
|
|
2764
|
+
} catch {
|
|
2765
|
+
ids.push(file.entryKey);
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
return ids;
|
|
2769
|
+
}
|
|
2770
|
+
async function diffBetweenRefs(configPath, baseRef, headRef, options = {}) {
|
|
2771
|
+
const projectRoot = realpathSync(dirname(resolve(configPath)));
|
|
2772
|
+
const repoRoot = getRepoRoot(projectRoot);
|
|
2773
|
+
validateRef(baseRef, projectRoot);
|
|
2774
|
+
if (!options.working)
|
|
2775
|
+
validateRef(headRef, projectRoot);
|
|
2776
|
+
const config = await loadConfig(configPath);
|
|
2777
|
+
const specPathsByKey = /* @__PURE__ */ new Map();
|
|
2778
|
+
for (const [key, entry] of Object.entries(config.specs)) {
|
|
2779
|
+
specPathsByKey.set(key, entry.path);
|
|
2780
|
+
}
|
|
2781
|
+
const matchers = buildEntryMatchers(specPathsByKey, projectRoot, repoRoot);
|
|
2782
|
+
const base = refSide(baseRef, matchers, projectRoot, repoRoot);
|
|
2783
|
+
const head = options.working ? worktreeSide(matchers, projectRoot, repoRoot) : refSide(headRef, matchers, projectRoot, repoRoot);
|
|
2784
|
+
const changed = options.working ? getChangedSpecFilesInWorktree(baseRef, matchers, projectRoot, repoRoot) : getChangedSpecFiles(baseRef, headRef, matchers, projectRoot, repoRoot);
|
|
2785
|
+
const diffs = [];
|
|
2786
|
+
for (const file of changed.modified) {
|
|
2787
|
+
const beforeSpec = await parseSpecFromString(base.read(file.path), file.path);
|
|
2788
|
+
const afterSpec = await parseSpecFromString(head.read(file.path), file.path);
|
|
2789
|
+
const diff2 = diffSpecs(beforeSpec, afterSpec);
|
|
2790
|
+
diffs.push(diff2);
|
|
2791
|
+
}
|
|
2792
|
+
const added = await specIdsFrom(changed.added, head.read);
|
|
2793
|
+
const removed = await specIdsFrom(changed.deleted, base.read);
|
|
2794
|
+
const impact = [];
|
|
2795
|
+
const allSpecs = [];
|
|
2796
|
+
const specsByEntry = /* @__PURE__ */ new Map();
|
|
2797
|
+
const filesAtHead = head.list();
|
|
2798
|
+
for (const [key, paths] of filesAtHead) {
|
|
2799
|
+
const forEntry = [];
|
|
2800
|
+
for (const path of paths) {
|
|
2801
|
+
try {
|
|
2802
|
+
const parsed = await parseSpecFromString(head.read(path), path);
|
|
2803
|
+
forEntry.push(parsed);
|
|
2804
|
+
allSpecs.push(parsed);
|
|
2805
|
+
} catch {
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
specsByEntry.set(key, forEntry);
|
|
2809
|
+
}
|
|
2810
|
+
const relations = buildRelationResolver(config, specsByEntry);
|
|
2811
|
+
const thresholdDays = config.diff?.staleness_threshold_days ?? 14;
|
|
2812
|
+
for (const diff2 of diffs) {
|
|
2813
|
+
const analysis = analyzeImpact(diff2.specId, diff2, relations, allSpecs, thresholdDays);
|
|
2814
|
+
if (analysis.totalAffected > 0) {
|
|
2815
|
+
impact.push(analysis);
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
const _brokenRefs = checkCrossReferences(allSpecs, removed);
|
|
2819
|
+
const summaryParts = [];
|
|
2820
|
+
if (diffs.length > 0) {
|
|
2821
|
+
summaryParts.push(`${diffs.length} spec(s) modified`);
|
|
2822
|
+
}
|
|
2823
|
+
if (added.length > 0) {
|
|
2824
|
+
summaryParts.push(`${added.length} spec(s) added`);
|
|
2825
|
+
}
|
|
2826
|
+
if (removed.length > 0) {
|
|
2827
|
+
summaryParts.push(`${removed.length} spec(s) removed`);
|
|
2828
|
+
}
|
|
2829
|
+
if (impact.length > 0) {
|
|
2830
|
+
const totalDownstream = impact.reduce((sum, i) => sum + i.totalAffected, 0);
|
|
2831
|
+
summaryParts.push(`${totalDownstream} downstream spec(s) potentially affected`);
|
|
2832
|
+
}
|
|
2833
|
+
if (_brokenRefs.length > 0) {
|
|
2834
|
+
summaryParts.push(`${_brokenRefs.length} broken reference(s)`);
|
|
2835
|
+
}
|
|
2836
|
+
const summary = summaryParts.length > 0 ? summaryParts.join("; ") : "No changes detected";
|
|
2837
|
+
const uncommittedSpecFiles = options.working ? [] : listUncommittedSpecFiles(matchers, projectRoot, repoRoot);
|
|
2838
|
+
return { diffs, added, removed, impact, summary, uncommittedSpecFiles };
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2841
|
+
export {
|
|
2842
|
+
DEFAULT_DIFF_CONFIG,
|
|
2843
|
+
DiffError,
|
|
2844
|
+
diffBetweenRefs
|
|
2845
|
+
};
|
|
2846
|
+
//# sourceMappingURL=chunk-6WFNZH7F.js.map
|