Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- novas/novacore-zephyr/claude-code-router/node_modules/chalk/node_modules/ansi-styles/index.d.ts +345 -0
- novas/novacore-zephyr/claude-code-router/node_modules/chalk/node_modules/ansi-styles/index.js +163 -0
- novas/novacore-zephyr/claude-code-router/node_modules/chalk/node_modules/ansi-styles/license +9 -0
- novas/novacore-zephyr/claude-code-router/node_modules/chalk/node_modules/ansi-styles/package.json +56 -0
- novas/novacore-zephyr/claude-code-router/node_modules/chalk/node_modules/ansi-styles/readme.md +152 -0
- novas/novacore-zephyr/claude-code-router/node_modules/chalk/source/index.js +229 -0
- novas/novacore-zephyr/claude-code-router/node_modules/chalk/source/templates.js +134 -0
- novas/novacore-zephyr/claude-code-router/node_modules/chalk/source/util.js +39 -0
- novas/novacore-zephyr/claude-code-router/node_modules/create-jest/bin/create-jest.js +8 -0
- novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/errors.js +31 -0
- novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/generateConfigFile.js +92 -0
- novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/index.d.ts +12 -0
- novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/index.js +18 -0
- novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/modifyPackageJson.js +26 -0
- novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/questions.js +76 -0
- novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/runCreate.js +237 -0
- novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/types.js +1 -0
- novas/novacore-zephyr/claude-code-router/node_modules/diff-sequences/build/index.d.ts +38 -0
- novas/novacore-zephyr/claude-code-router/node_modules/diff-sequences/build/index.js +798 -0
- novas/novacore-zephyr/claude-code-router/node_modules/expect/build/asymmetricMatchers.js +375 -0
- novas/novacore-zephyr/claude-code-router/node_modules/expect/build/extractExpectedAssertionsErrors.js +86 -0
- novas/novacore-zephyr/claude-code-router/node_modules/expect/build/index.d.ts +370 -0
- novas/novacore-zephyr/claude-code-router/node_modules/expect/build/index.js +410 -0
- novas/novacore-zephyr/claude-code-router/node_modules/expect/build/jestMatchersObject.js +123 -0
- novas/novacore-zephyr/claude-code-router/node_modules/expect/build/matchers.js +1292 -0
- novas/novacore-zephyr/claude-code-router/node_modules/expect/build/print.js +122 -0
- novas/novacore-zephyr/claude-code-router/node_modules/expect/build/spyMatchers.js +1254 -0
- novas/novacore-zephyr/claude-code-router/node_modules/expect/build/toThrowMatchers.js +481 -0
- novas/novacore-zephyr/claude-code-router/node_modules/expect/build/types.js +3 -0
- novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/import-es6-export-test.js +13 -0
- novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/import-es6-import-export-test.js +13 -0
- novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/import-es6-import-test.js +13 -0
- novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/import-vanilla-test.js +13 -0
- novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/index-test.js +13 -0
- novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/require-es6-export-test.js +13 -0
- novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/require-es6-import-export-test.js +13 -0
- novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/require-es6-import-test.js +13 -0
- novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/require-vanilla-test.js +13 -0
- novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/index.js +26 -0
- novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/test-redirections/idObjES6Export.js +3 -0
- novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/test-redirections/idObjES6Import.js +3 -0
- novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/test-redirections/idObjES6ImportExport.js +3 -0
- novas/novacore-zephyr/claude-code-router/node_modules/istanbul-lib-source-maps/lib/get-mapping.js +182 -0
- novas/novacore-zephyr/claude-code-router/node_modules/istanbul-lib-source-maps/lib/map-store.js +226 -0
- novas/novacore-zephyr/claude-code-router/node_modules/istanbul-lib-source-maps/lib/mapped.js +113 -0
- novas/novacore-zephyr/claude-code-router/node_modules/istanbul-lib-source-maps/lib/pathutils.js +21 -0
- novas/novacore-zephyr/claude-code-router/node_modules/istanbul-lib-source-maps/lib/transform-utils.js +21 -0
- novas/novacore-zephyr/claude-code-router/node_modules/istanbul-lib-source-maps/lib/transformer.js +147 -0
- novas/novacore-zephyr/claude-code-router/node_modules/jest-changed-files/build/git.js +169 -0
- novas/novacore-zephyr/claude-code-router/node_modules/jest-changed-files/build/hg.js +130 -0
novas/novacore-zephyr/claude-code-router/node_modules/chalk/node_modules/ansi-styles/index.d.ts
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
declare type CSSColor =
|
| 2 |
+
| 'aliceblue'
|
| 3 |
+
| 'antiquewhite'
|
| 4 |
+
| 'aqua'
|
| 5 |
+
| 'aquamarine'
|
| 6 |
+
| 'azure'
|
| 7 |
+
| 'beige'
|
| 8 |
+
| 'bisque'
|
| 9 |
+
| 'black'
|
| 10 |
+
| 'blanchedalmond'
|
| 11 |
+
| 'blue'
|
| 12 |
+
| 'blueviolet'
|
| 13 |
+
| 'brown'
|
| 14 |
+
| 'burlywood'
|
| 15 |
+
| 'cadetblue'
|
| 16 |
+
| 'chartreuse'
|
| 17 |
+
| 'chocolate'
|
| 18 |
+
| 'coral'
|
| 19 |
+
| 'cornflowerblue'
|
| 20 |
+
| 'cornsilk'
|
| 21 |
+
| 'crimson'
|
| 22 |
+
| 'cyan'
|
| 23 |
+
| 'darkblue'
|
| 24 |
+
| 'darkcyan'
|
| 25 |
+
| 'darkgoldenrod'
|
| 26 |
+
| 'darkgray'
|
| 27 |
+
| 'darkgreen'
|
| 28 |
+
| 'darkgrey'
|
| 29 |
+
| 'darkkhaki'
|
| 30 |
+
| 'darkmagenta'
|
| 31 |
+
| 'darkolivegreen'
|
| 32 |
+
| 'darkorange'
|
| 33 |
+
| 'darkorchid'
|
| 34 |
+
| 'darkred'
|
| 35 |
+
| 'darksalmon'
|
| 36 |
+
| 'darkseagreen'
|
| 37 |
+
| 'darkslateblue'
|
| 38 |
+
| 'darkslategray'
|
| 39 |
+
| 'darkslategrey'
|
| 40 |
+
| 'darkturquoise'
|
| 41 |
+
| 'darkviolet'
|
| 42 |
+
| 'deeppink'
|
| 43 |
+
| 'deepskyblue'
|
| 44 |
+
| 'dimgray'
|
| 45 |
+
| 'dimgrey'
|
| 46 |
+
| 'dodgerblue'
|
| 47 |
+
| 'firebrick'
|
| 48 |
+
| 'floralwhite'
|
| 49 |
+
| 'forestgreen'
|
| 50 |
+
| 'fuchsia'
|
| 51 |
+
| 'gainsboro'
|
| 52 |
+
| 'ghostwhite'
|
| 53 |
+
| 'gold'
|
| 54 |
+
| 'goldenrod'
|
| 55 |
+
| 'gray'
|
| 56 |
+
| 'green'
|
| 57 |
+
| 'greenyellow'
|
| 58 |
+
| 'grey'
|
| 59 |
+
| 'honeydew'
|
| 60 |
+
| 'hotpink'
|
| 61 |
+
| 'indianred'
|
| 62 |
+
| 'indigo'
|
| 63 |
+
| 'ivory'
|
| 64 |
+
| 'khaki'
|
| 65 |
+
| 'lavender'
|
| 66 |
+
| 'lavenderblush'
|
| 67 |
+
| 'lawngreen'
|
| 68 |
+
| 'lemonchiffon'
|
| 69 |
+
| 'lightblue'
|
| 70 |
+
| 'lightcoral'
|
| 71 |
+
| 'lightcyan'
|
| 72 |
+
| 'lightgoldenrodyellow'
|
| 73 |
+
| 'lightgray'
|
| 74 |
+
| 'lightgreen'
|
| 75 |
+
| 'lightgrey'
|
| 76 |
+
| 'lightpink'
|
| 77 |
+
| 'lightsalmon'
|
| 78 |
+
| 'lightseagreen'
|
| 79 |
+
| 'lightskyblue'
|
| 80 |
+
| 'lightslategray'
|
| 81 |
+
| 'lightslategrey'
|
| 82 |
+
| 'lightsteelblue'
|
| 83 |
+
| 'lightyellow'
|
| 84 |
+
| 'lime'
|
| 85 |
+
| 'limegreen'
|
| 86 |
+
| 'linen'
|
| 87 |
+
| 'magenta'
|
| 88 |
+
| 'maroon'
|
| 89 |
+
| 'mediumaquamarine'
|
| 90 |
+
| 'mediumblue'
|
| 91 |
+
| 'mediumorchid'
|
| 92 |
+
| 'mediumpurple'
|
| 93 |
+
| 'mediumseagreen'
|
| 94 |
+
| 'mediumslateblue'
|
| 95 |
+
| 'mediumspringgreen'
|
| 96 |
+
| 'mediumturquoise'
|
| 97 |
+
| 'mediumvioletred'
|
| 98 |
+
| 'midnightblue'
|
| 99 |
+
| 'mintcream'
|
| 100 |
+
| 'mistyrose'
|
| 101 |
+
| 'moccasin'
|
| 102 |
+
| 'navajowhite'
|
| 103 |
+
| 'navy'
|
| 104 |
+
| 'oldlace'
|
| 105 |
+
| 'olive'
|
| 106 |
+
| 'olivedrab'
|
| 107 |
+
| 'orange'
|
| 108 |
+
| 'orangered'
|
| 109 |
+
| 'orchid'
|
| 110 |
+
| 'palegoldenrod'
|
| 111 |
+
| 'palegreen'
|
| 112 |
+
| 'paleturquoise'
|
| 113 |
+
| 'palevioletred'
|
| 114 |
+
| 'papayawhip'
|
| 115 |
+
| 'peachpuff'
|
| 116 |
+
| 'peru'
|
| 117 |
+
| 'pink'
|
| 118 |
+
| 'plum'
|
| 119 |
+
| 'powderblue'
|
| 120 |
+
| 'purple'
|
| 121 |
+
| 'rebeccapurple'
|
| 122 |
+
| 'red'
|
| 123 |
+
| 'rosybrown'
|
| 124 |
+
| 'royalblue'
|
| 125 |
+
| 'saddlebrown'
|
| 126 |
+
| 'salmon'
|
| 127 |
+
| 'sandybrown'
|
| 128 |
+
| 'seagreen'
|
| 129 |
+
| 'seashell'
|
| 130 |
+
| 'sienna'
|
| 131 |
+
| 'silver'
|
| 132 |
+
| 'skyblue'
|
| 133 |
+
| 'slateblue'
|
| 134 |
+
| 'slategray'
|
| 135 |
+
| 'slategrey'
|
| 136 |
+
| 'snow'
|
| 137 |
+
| 'springgreen'
|
| 138 |
+
| 'steelblue'
|
| 139 |
+
| 'tan'
|
| 140 |
+
| 'teal'
|
| 141 |
+
| 'thistle'
|
| 142 |
+
| 'tomato'
|
| 143 |
+
| 'turquoise'
|
| 144 |
+
| 'violet'
|
| 145 |
+
| 'wheat'
|
| 146 |
+
| 'white'
|
| 147 |
+
| 'whitesmoke'
|
| 148 |
+
| 'yellow'
|
| 149 |
+
| 'yellowgreen';
|
| 150 |
+
|
| 151 |
+
declare namespace ansiStyles {
|
| 152 |
+
interface ColorConvert {
|
| 153 |
+
/**
|
| 154 |
+
The RGB color space.
|
| 155 |
+
|
| 156 |
+
@param red - (`0`-`255`)
|
| 157 |
+
@param green - (`0`-`255`)
|
| 158 |
+
@param blue - (`0`-`255`)
|
| 159 |
+
*/
|
| 160 |
+
rgb(red: number, green: number, blue: number): string;
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
The RGB HEX color space.
|
| 164 |
+
|
| 165 |
+
@param hex - A hexadecimal string containing RGB data.
|
| 166 |
+
*/
|
| 167 |
+
hex(hex: string): string;
|
| 168 |
+
|
| 169 |
+
/**
|
| 170 |
+
@param keyword - A CSS color name.
|
| 171 |
+
*/
|
| 172 |
+
keyword(keyword: CSSColor): string;
|
| 173 |
+
|
| 174 |
+
/**
|
| 175 |
+
The HSL color space.
|
| 176 |
+
|
| 177 |
+
@param hue - (`0`-`360`)
|
| 178 |
+
@param saturation - (`0`-`100`)
|
| 179 |
+
@param lightness - (`0`-`100`)
|
| 180 |
+
*/
|
| 181 |
+
hsl(hue: number, saturation: number, lightness: number): string;
|
| 182 |
+
|
| 183 |
+
/**
|
| 184 |
+
The HSV color space.
|
| 185 |
+
|
| 186 |
+
@param hue - (`0`-`360`)
|
| 187 |
+
@param saturation - (`0`-`100`)
|
| 188 |
+
@param value - (`0`-`100`)
|
| 189 |
+
*/
|
| 190 |
+
hsv(hue: number, saturation: number, value: number): string;
|
| 191 |
+
|
| 192 |
+
/**
|
| 193 |
+
The HSV color space.
|
| 194 |
+
|
| 195 |
+
@param hue - (`0`-`360`)
|
| 196 |
+
@param whiteness - (`0`-`100`)
|
| 197 |
+
@param blackness - (`0`-`100`)
|
| 198 |
+
*/
|
| 199 |
+
hwb(hue: number, whiteness: number, blackness: number): string;
|
| 200 |
+
|
| 201 |
+
/**
|
| 202 |
+
Use a [4-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4-bit) to set text color.
|
| 203 |
+
*/
|
| 204 |
+
ansi(ansi: number): string;
|
| 205 |
+
|
| 206 |
+
/**
|
| 207 |
+
Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
| 208 |
+
*/
|
| 209 |
+
ansi256(ansi: number): string;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
interface CSPair {
|
| 213 |
+
/**
|
| 214 |
+
The ANSI terminal control sequence for starting this style.
|
| 215 |
+
*/
|
| 216 |
+
readonly open: string;
|
| 217 |
+
|
| 218 |
+
/**
|
| 219 |
+
The ANSI terminal control sequence for ending this style.
|
| 220 |
+
*/
|
| 221 |
+
readonly close: string;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
interface ColorBase {
|
| 225 |
+
readonly ansi: ColorConvert;
|
| 226 |
+
readonly ansi256: ColorConvert;
|
| 227 |
+
readonly ansi16m: ColorConvert;
|
| 228 |
+
|
| 229 |
+
/**
|
| 230 |
+
The ANSI terminal control sequence for ending this color.
|
| 231 |
+
*/
|
| 232 |
+
readonly close: string;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
interface Modifier {
|
| 236 |
+
/**
|
| 237 |
+
Resets the current color chain.
|
| 238 |
+
*/
|
| 239 |
+
readonly reset: CSPair;
|
| 240 |
+
|
| 241 |
+
/**
|
| 242 |
+
Make text bold.
|
| 243 |
+
*/
|
| 244 |
+
readonly bold: CSPair;
|
| 245 |
+
|
| 246 |
+
/**
|
| 247 |
+
Emitting only a small amount of light.
|
| 248 |
+
*/
|
| 249 |
+
readonly dim: CSPair;
|
| 250 |
+
|
| 251 |
+
/**
|
| 252 |
+
Make text italic. (Not widely supported)
|
| 253 |
+
*/
|
| 254 |
+
readonly italic: CSPair;
|
| 255 |
+
|
| 256 |
+
/**
|
| 257 |
+
Make text underline. (Not widely supported)
|
| 258 |
+
*/
|
| 259 |
+
readonly underline: CSPair;
|
| 260 |
+
|
| 261 |
+
/**
|
| 262 |
+
Inverse background and foreground colors.
|
| 263 |
+
*/
|
| 264 |
+
readonly inverse: CSPair;
|
| 265 |
+
|
| 266 |
+
/**
|
| 267 |
+
Prints the text, but makes it invisible.
|
| 268 |
+
*/
|
| 269 |
+
readonly hidden: CSPair;
|
| 270 |
+
|
| 271 |
+
/**
|
| 272 |
+
Puts a horizontal line through the center of the text. (Not widely supported)
|
| 273 |
+
*/
|
| 274 |
+
readonly strikethrough: CSPair;
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
interface ForegroundColor {
|
| 278 |
+
readonly black: CSPair;
|
| 279 |
+
readonly red: CSPair;
|
| 280 |
+
readonly green: CSPair;
|
| 281 |
+
readonly yellow: CSPair;
|
| 282 |
+
readonly blue: CSPair;
|
| 283 |
+
readonly cyan: CSPair;
|
| 284 |
+
readonly magenta: CSPair;
|
| 285 |
+
readonly white: CSPair;
|
| 286 |
+
|
| 287 |
+
/**
|
| 288 |
+
Alias for `blackBright`.
|
| 289 |
+
*/
|
| 290 |
+
readonly gray: CSPair;
|
| 291 |
+
|
| 292 |
+
/**
|
| 293 |
+
Alias for `blackBright`.
|
| 294 |
+
*/
|
| 295 |
+
readonly grey: CSPair;
|
| 296 |
+
|
| 297 |
+
readonly blackBright: CSPair;
|
| 298 |
+
readonly redBright: CSPair;
|
| 299 |
+
readonly greenBright: CSPair;
|
| 300 |
+
readonly yellowBright: CSPair;
|
| 301 |
+
readonly blueBright: CSPair;
|
| 302 |
+
readonly cyanBright: CSPair;
|
| 303 |
+
readonly magentaBright: CSPair;
|
| 304 |
+
readonly whiteBright: CSPair;
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
interface BackgroundColor {
|
| 308 |
+
readonly bgBlack: CSPair;
|
| 309 |
+
readonly bgRed: CSPair;
|
| 310 |
+
readonly bgGreen: CSPair;
|
| 311 |
+
readonly bgYellow: CSPair;
|
| 312 |
+
readonly bgBlue: CSPair;
|
| 313 |
+
readonly bgCyan: CSPair;
|
| 314 |
+
readonly bgMagenta: CSPair;
|
| 315 |
+
readonly bgWhite: CSPair;
|
| 316 |
+
|
| 317 |
+
/**
|
| 318 |
+
Alias for `bgBlackBright`.
|
| 319 |
+
*/
|
| 320 |
+
readonly bgGray: CSPair;
|
| 321 |
+
|
| 322 |
+
/**
|
| 323 |
+
Alias for `bgBlackBright`.
|
| 324 |
+
*/
|
| 325 |
+
readonly bgGrey: CSPair;
|
| 326 |
+
|
| 327 |
+
readonly bgBlackBright: CSPair;
|
| 328 |
+
readonly bgRedBright: CSPair;
|
| 329 |
+
readonly bgGreenBright: CSPair;
|
| 330 |
+
readonly bgYellowBright: CSPair;
|
| 331 |
+
readonly bgBlueBright: CSPair;
|
| 332 |
+
readonly bgCyanBright: CSPair;
|
| 333 |
+
readonly bgMagentaBright: CSPair;
|
| 334 |
+
readonly bgWhiteBright: CSPair;
|
| 335 |
+
}
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
declare const ansiStyles: {
|
| 339 |
+
readonly modifier: ansiStyles.Modifier;
|
| 340 |
+
readonly color: ansiStyles.ForegroundColor & ansiStyles.ColorBase;
|
| 341 |
+
readonly bgColor: ansiStyles.BackgroundColor & ansiStyles.ColorBase;
|
| 342 |
+
readonly codes: ReadonlyMap<number, number>;
|
| 343 |
+
} & ansiStyles.BackgroundColor & ansiStyles.ForegroundColor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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
const wrapAnsi16 = (fn, offset) => (...args) => {
|
| 4 |
+
const code = fn(...args);
|
| 5 |
+
return `\u001B[${code + offset}m`;
|
| 6 |
+
};
|
| 7 |
+
|
| 8 |
+
const wrapAnsi256 = (fn, offset) => (...args) => {
|
| 9 |
+
const code = fn(...args);
|
| 10 |
+
return `\u001B[${38 + offset};5;${code}m`;
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
const wrapAnsi16m = (fn, offset) => (...args) => {
|
| 14 |
+
const rgb = fn(...args);
|
| 15 |
+
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
| 16 |
+
};
|
| 17 |
+
|
| 18 |
+
const ansi2ansi = n => n;
|
| 19 |
+
const rgb2rgb = (r, g, b) => [r, g, b];
|
| 20 |
+
|
| 21 |
+
const setLazyProperty = (object, property, get) => {
|
| 22 |
+
Object.defineProperty(object, property, {
|
| 23 |
+
get: () => {
|
| 24 |
+
const value = get();
|
| 25 |
+
|
| 26 |
+
Object.defineProperty(object, property, {
|
| 27 |
+
value,
|
| 28 |
+
enumerable: true,
|
| 29 |
+
configurable: true
|
| 30 |
+
});
|
| 31 |
+
|
| 32 |
+
return value;
|
| 33 |
+
},
|
| 34 |
+
enumerable: true,
|
| 35 |
+
configurable: true
|
| 36 |
+
});
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
/** @type {typeof import('color-convert')} */
|
| 40 |
+
let colorConvert;
|
| 41 |
+
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
| 42 |
+
if (colorConvert === undefined) {
|
| 43 |
+
colorConvert = require('color-convert');
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
const offset = isBackground ? 10 : 0;
|
| 47 |
+
const styles = {};
|
| 48 |
+
|
| 49 |
+
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
|
| 50 |
+
const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
|
| 51 |
+
if (sourceSpace === targetSpace) {
|
| 52 |
+
styles[name] = wrap(identity, offset);
|
| 53 |
+
} else if (typeof suite === 'object') {
|
| 54 |
+
styles[name] = wrap(suite[targetSpace], offset);
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
return styles;
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
+
function assembleStyles() {
|
| 62 |
+
const codes = new Map();
|
| 63 |
+
const styles = {
|
| 64 |
+
modifier: {
|
| 65 |
+
reset: [0, 0],
|
| 66 |
+
// 21 isn't widely supported and 22 does the same thing
|
| 67 |
+
bold: [1, 22],
|
| 68 |
+
dim: [2, 22],
|
| 69 |
+
italic: [3, 23],
|
| 70 |
+
underline: [4, 24],
|
| 71 |
+
inverse: [7, 27],
|
| 72 |
+
hidden: [8, 28],
|
| 73 |
+
strikethrough: [9, 29]
|
| 74 |
+
},
|
| 75 |
+
color: {
|
| 76 |
+
black: [30, 39],
|
| 77 |
+
red: [31, 39],
|
| 78 |
+
green: [32, 39],
|
| 79 |
+
yellow: [33, 39],
|
| 80 |
+
blue: [34, 39],
|
| 81 |
+
magenta: [35, 39],
|
| 82 |
+
cyan: [36, 39],
|
| 83 |
+
white: [37, 39],
|
| 84 |
+
|
| 85 |
+
// Bright color
|
| 86 |
+
blackBright: [90, 39],
|
| 87 |
+
redBright: [91, 39],
|
| 88 |
+
greenBright: [92, 39],
|
| 89 |
+
yellowBright: [93, 39],
|
| 90 |
+
blueBright: [94, 39],
|
| 91 |
+
magentaBright: [95, 39],
|
| 92 |
+
cyanBright: [96, 39],
|
| 93 |
+
whiteBright: [97, 39]
|
| 94 |
+
},
|
| 95 |
+
bgColor: {
|
| 96 |
+
bgBlack: [40, 49],
|
| 97 |
+
bgRed: [41, 49],
|
| 98 |
+
bgGreen: [42, 49],
|
| 99 |
+
bgYellow: [43, 49],
|
| 100 |
+
bgBlue: [44, 49],
|
| 101 |
+
bgMagenta: [45, 49],
|
| 102 |
+
bgCyan: [46, 49],
|
| 103 |
+
bgWhite: [47, 49],
|
| 104 |
+
|
| 105 |
+
// Bright color
|
| 106 |
+
bgBlackBright: [100, 49],
|
| 107 |
+
bgRedBright: [101, 49],
|
| 108 |
+
bgGreenBright: [102, 49],
|
| 109 |
+
bgYellowBright: [103, 49],
|
| 110 |
+
bgBlueBright: [104, 49],
|
| 111 |
+
bgMagentaBright: [105, 49],
|
| 112 |
+
bgCyanBright: [106, 49],
|
| 113 |
+
bgWhiteBright: [107, 49]
|
| 114 |
+
}
|
| 115 |
+
};
|
| 116 |
+
|
| 117 |
+
// Alias bright black as gray (and grey)
|
| 118 |
+
styles.color.gray = styles.color.blackBright;
|
| 119 |
+
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
| 120 |
+
styles.color.grey = styles.color.blackBright;
|
| 121 |
+
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
| 122 |
+
|
| 123 |
+
for (const [groupName, group] of Object.entries(styles)) {
|
| 124 |
+
for (const [styleName, style] of Object.entries(group)) {
|
| 125 |
+
styles[styleName] = {
|
| 126 |
+
open: `\u001B[${style[0]}m`,
|
| 127 |
+
close: `\u001B[${style[1]}m`
|
| 128 |
+
};
|
| 129 |
+
|
| 130 |
+
group[styleName] = styles[styleName];
|
| 131 |
+
|
| 132 |
+
codes.set(style[0], style[1]);
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
Object.defineProperty(styles, groupName, {
|
| 136 |
+
value: group,
|
| 137 |
+
enumerable: false
|
| 138 |
+
});
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
Object.defineProperty(styles, 'codes', {
|
| 142 |
+
value: codes,
|
| 143 |
+
enumerable: false
|
| 144 |
+
});
|
| 145 |
+
|
| 146 |
+
styles.color.close = '\u001B[39m';
|
| 147 |
+
styles.bgColor.close = '\u001B[49m';
|
| 148 |
+
|
| 149 |
+
setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
|
| 150 |
+
setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
|
| 151 |
+
setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
|
| 152 |
+
setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
|
| 153 |
+
setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
|
| 154 |
+
setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
|
| 155 |
+
|
| 156 |
+
return styles;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
// Make the export immutable
|
| 160 |
+
Object.defineProperty(module, 'exports', {
|
| 161 |
+
enumerable: true,
|
| 162 |
+
get: assembleStyles
|
| 163 |
+
});
|
novas/novacore-zephyr/claude-code-router/node_modules/chalk/node_modules/ansi-styles/license
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
| 6 |
+
|
| 7 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 8 |
+
|
| 9 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
novas/novacore-zephyr/claude-code-router/node_modules/chalk/node_modules/ansi-styles/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "ansi-styles",
|
| 3 |
+
"version": "4.3.0",
|
| 4 |
+
"description": "ANSI escape codes for styling strings in the terminal",
|
| 5 |
+
"license": "MIT",
|
| 6 |
+
"repository": "chalk/ansi-styles",
|
| 7 |
+
"funding": "https://github.com/chalk/ansi-styles?sponsor=1",
|
| 8 |
+
"author": {
|
| 9 |
+
"name": "Sindre Sorhus",
|
| 10 |
+
"email": "sindresorhus@gmail.com",
|
| 11 |
+
"url": "sindresorhus.com"
|
| 12 |
+
},
|
| 13 |
+
"engines": {
|
| 14 |
+
"node": ">=8"
|
| 15 |
+
},
|
| 16 |
+
"scripts": {
|
| 17 |
+
"test": "xo && ava && tsd",
|
| 18 |
+
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
|
| 19 |
+
},
|
| 20 |
+
"files": [
|
| 21 |
+
"index.js",
|
| 22 |
+
"index.d.ts"
|
| 23 |
+
],
|
| 24 |
+
"keywords": [
|
| 25 |
+
"ansi",
|
| 26 |
+
"styles",
|
| 27 |
+
"color",
|
| 28 |
+
"colour",
|
| 29 |
+
"colors",
|
| 30 |
+
"terminal",
|
| 31 |
+
"console",
|
| 32 |
+
"cli",
|
| 33 |
+
"string",
|
| 34 |
+
"tty",
|
| 35 |
+
"escape",
|
| 36 |
+
"formatting",
|
| 37 |
+
"rgb",
|
| 38 |
+
"256",
|
| 39 |
+
"shell",
|
| 40 |
+
"xterm",
|
| 41 |
+
"log",
|
| 42 |
+
"logging",
|
| 43 |
+
"command-line",
|
| 44 |
+
"text"
|
| 45 |
+
],
|
| 46 |
+
"dependencies": {
|
| 47 |
+
"color-convert": "^2.0.1"
|
| 48 |
+
},
|
| 49 |
+
"devDependencies": {
|
| 50 |
+
"@types/color-convert": "^1.9.0",
|
| 51 |
+
"ava": "^2.3.0",
|
| 52 |
+
"svg-term-cli": "^2.1.1",
|
| 53 |
+
"tsd": "^0.11.0",
|
| 54 |
+
"xo": "^0.25.3"
|
| 55 |
+
}
|
| 56 |
+
}
|
novas/novacore-zephyr/claude-code-router/node_modules/chalk/node_modules/ansi-styles/readme.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ansi-styles [](https://travis-ci.org/chalk/ansi-styles)
|
| 2 |
+
|
| 3 |
+
> [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
|
| 4 |
+
|
| 5 |
+
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
|
| 6 |
+
|
| 7 |
+
<img src="screenshot.svg" width="900">
|
| 8 |
+
|
| 9 |
+
## Install
|
| 10 |
+
|
| 11 |
+
```
|
| 12 |
+
$ npm install ansi-styles
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
## Usage
|
| 16 |
+
|
| 17 |
+
```js
|
| 18 |
+
const style = require('ansi-styles');
|
| 19 |
+
|
| 20 |
+
console.log(`${style.green.open}Hello world!${style.green.close}`);
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
// Color conversion between 16/256/truecolor
|
| 24 |
+
// NOTE: If conversion goes to 16 colors or 256 colors, the original color
|
| 25 |
+
// may be degraded to fit that color palette. This means terminals
|
| 26 |
+
// that do not support 16 million colors will best-match the
|
| 27 |
+
// original color.
|
| 28 |
+
console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
|
| 29 |
+
console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
|
| 30 |
+
console.log(style.color.ansi16m.hex('#abcdef') + 'Hello world!' + style.color.close);
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
## API
|
| 34 |
+
|
| 35 |
+
Each style has an `open` and `close` property.
|
| 36 |
+
|
| 37 |
+
## Styles
|
| 38 |
+
|
| 39 |
+
### Modifiers
|
| 40 |
+
|
| 41 |
+
- `reset`
|
| 42 |
+
- `bold`
|
| 43 |
+
- `dim`
|
| 44 |
+
- `italic` *(Not widely supported)*
|
| 45 |
+
- `underline`
|
| 46 |
+
- `inverse`
|
| 47 |
+
- `hidden`
|
| 48 |
+
- `strikethrough` *(Not widely supported)*
|
| 49 |
+
|
| 50 |
+
### Colors
|
| 51 |
+
|
| 52 |
+
- `black`
|
| 53 |
+
- `red`
|
| 54 |
+
- `green`
|
| 55 |
+
- `yellow`
|
| 56 |
+
- `blue`
|
| 57 |
+
- `magenta`
|
| 58 |
+
- `cyan`
|
| 59 |
+
- `white`
|
| 60 |
+
- `blackBright` (alias: `gray`, `grey`)
|
| 61 |
+
- `redBright`
|
| 62 |
+
- `greenBright`
|
| 63 |
+
- `yellowBright`
|
| 64 |
+
- `blueBright`
|
| 65 |
+
- `magentaBright`
|
| 66 |
+
- `cyanBright`
|
| 67 |
+
- `whiteBright`
|
| 68 |
+
|
| 69 |
+
### Background colors
|
| 70 |
+
|
| 71 |
+
- `bgBlack`
|
| 72 |
+
- `bgRed`
|
| 73 |
+
- `bgGreen`
|
| 74 |
+
- `bgYellow`
|
| 75 |
+
- `bgBlue`
|
| 76 |
+
- `bgMagenta`
|
| 77 |
+
- `bgCyan`
|
| 78 |
+
- `bgWhite`
|
| 79 |
+
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
|
| 80 |
+
- `bgRedBright`
|
| 81 |
+
- `bgGreenBright`
|
| 82 |
+
- `bgYellowBright`
|
| 83 |
+
- `bgBlueBright`
|
| 84 |
+
- `bgMagentaBright`
|
| 85 |
+
- `bgCyanBright`
|
| 86 |
+
- `bgWhiteBright`
|
| 87 |
+
|
| 88 |
+
## Advanced usage
|
| 89 |
+
|
| 90 |
+
By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
|
| 91 |
+
|
| 92 |
+
- `style.modifier`
|
| 93 |
+
- `style.color`
|
| 94 |
+
- `style.bgColor`
|
| 95 |
+
|
| 96 |
+
###### Example
|
| 97 |
+
|
| 98 |
+
```js
|
| 99 |
+
console.log(style.color.green.open);
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
|
| 103 |
+
|
| 104 |
+
###### Example
|
| 105 |
+
|
| 106 |
+
```js
|
| 107 |
+
console.log(style.codes.get(36));
|
| 108 |
+
//=> 39
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
|
| 112 |
+
|
| 113 |
+
`ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
|
| 114 |
+
|
| 115 |
+
The following color spaces from `color-convert` are supported:
|
| 116 |
+
|
| 117 |
+
- `rgb`
|
| 118 |
+
- `hex`
|
| 119 |
+
- `keyword`
|
| 120 |
+
- `hsl`
|
| 121 |
+
- `hsv`
|
| 122 |
+
- `hwb`
|
| 123 |
+
- `ansi`
|
| 124 |
+
- `ansi256`
|
| 125 |
+
|
| 126 |
+
To use these, call the associated conversion function with the intended output, for example:
|
| 127 |
+
|
| 128 |
+
```js
|
| 129 |
+
style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code
|
| 130 |
+
style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code
|
| 131 |
+
|
| 132 |
+
style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
|
| 133 |
+
style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
|
| 134 |
+
|
| 135 |
+
style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code
|
| 136 |
+
style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
## Related
|
| 140 |
+
|
| 141 |
+
- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
|
| 142 |
+
|
| 143 |
+
## Maintainers
|
| 144 |
+
|
| 145 |
+
- [Sindre Sorhus](https://github.com/sindresorhus)
|
| 146 |
+
- [Josh Junon](https://github.com/qix-)
|
| 147 |
+
|
| 148 |
+
## For enterprise
|
| 149 |
+
|
| 150 |
+
Available as part of the Tidelift Subscription.
|
| 151 |
+
|
| 152 |
+
The maintainers of `ansi-styles` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
novas/novacore-zephyr/claude-code-router/node_modules/chalk/source/index.js
ADDED
|
@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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
const ansiStyles = require('ansi-styles');
|
| 3 |
+
const {stdout: stdoutColor, stderr: stderrColor} = require('supports-color');
|
| 4 |
+
const {
|
| 5 |
+
stringReplaceAll,
|
| 6 |
+
stringEncaseCRLFWithFirstIndex
|
| 7 |
+
} = require('./util');
|
| 8 |
+
|
| 9 |
+
const {isArray} = Array;
|
| 10 |
+
|
| 11 |
+
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
| 12 |
+
const levelMapping = [
|
| 13 |
+
'ansi',
|
| 14 |
+
'ansi',
|
| 15 |
+
'ansi256',
|
| 16 |
+
'ansi16m'
|
| 17 |
+
];
|
| 18 |
+
|
| 19 |
+
const styles = Object.create(null);
|
| 20 |
+
|
| 21 |
+
const applyOptions = (object, options = {}) => {
|
| 22 |
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
| 23 |
+
throw new Error('The `level` option should be an integer from 0 to 3');
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
// Detect level if not set manually
|
| 27 |
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
| 28 |
+
object.level = options.level === undefined ? colorLevel : options.level;
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
class ChalkClass {
|
| 32 |
+
constructor(options) {
|
| 33 |
+
// eslint-disable-next-line no-constructor-return
|
| 34 |
+
return chalkFactory(options);
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
const chalkFactory = options => {
|
| 39 |
+
const chalk = {};
|
| 40 |
+
applyOptions(chalk, options);
|
| 41 |
+
|
| 42 |
+
chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
|
| 43 |
+
|
| 44 |
+
Object.setPrototypeOf(chalk, Chalk.prototype);
|
| 45 |
+
Object.setPrototypeOf(chalk.template, chalk);
|
| 46 |
+
|
| 47 |
+
chalk.template.constructor = () => {
|
| 48 |
+
throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
chalk.template.Instance = ChalkClass;
|
| 52 |
+
|
| 53 |
+
return chalk.template;
|
| 54 |
+
};
|
| 55 |
+
|
| 56 |
+
function Chalk(options) {
|
| 57 |
+
return chalkFactory(options);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
| 61 |
+
styles[styleName] = {
|
| 62 |
+
get() {
|
| 63 |
+
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
| 64 |
+
Object.defineProperty(this, styleName, {value: builder});
|
| 65 |
+
return builder;
|
| 66 |
+
}
|
| 67 |
+
};
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
styles.visible = {
|
| 71 |
+
get() {
|
| 72 |
+
const builder = createBuilder(this, this._styler, true);
|
| 73 |
+
Object.defineProperty(this, 'visible', {value: builder});
|
| 74 |
+
return builder;
|
| 75 |
+
}
|
| 76 |
+
};
|
| 77 |
+
|
| 78 |
+
const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
|
| 79 |
+
|
| 80 |
+
for (const model of usedModels) {
|
| 81 |
+
styles[model] = {
|
| 82 |
+
get() {
|
| 83 |
+
const {level} = this;
|
| 84 |
+
return function (...arguments_) {
|
| 85 |
+
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
| 86 |
+
return createBuilder(this, styler, this._isEmpty);
|
| 87 |
+
};
|
| 88 |
+
}
|
| 89 |
+
};
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
for (const model of usedModels) {
|
| 93 |
+
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
| 94 |
+
styles[bgModel] = {
|
| 95 |
+
get() {
|
| 96 |
+
const {level} = this;
|
| 97 |
+
return function (...arguments_) {
|
| 98 |
+
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
| 99 |
+
return createBuilder(this, styler, this._isEmpty);
|
| 100 |
+
};
|
| 101 |
+
}
|
| 102 |
+
};
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
const proto = Object.defineProperties(() => {}, {
|
| 106 |
+
...styles,
|
| 107 |
+
level: {
|
| 108 |
+
enumerable: true,
|
| 109 |
+
get() {
|
| 110 |
+
return this._generator.level;
|
| 111 |
+
},
|
| 112 |
+
set(level) {
|
| 113 |
+
this._generator.level = level;
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
});
|
| 117 |
+
|
| 118 |
+
const createStyler = (open, close, parent) => {
|
| 119 |
+
let openAll;
|
| 120 |
+
let closeAll;
|
| 121 |
+
if (parent === undefined) {
|
| 122 |
+
openAll = open;
|
| 123 |
+
closeAll = close;
|
| 124 |
+
} else {
|
| 125 |
+
openAll = parent.openAll + open;
|
| 126 |
+
closeAll = close + parent.closeAll;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
return {
|
| 130 |
+
open,
|
| 131 |
+
close,
|
| 132 |
+
openAll,
|
| 133 |
+
closeAll,
|
| 134 |
+
parent
|
| 135 |
+
};
|
| 136 |
+
};
|
| 137 |
+
|
| 138 |
+
const createBuilder = (self, _styler, _isEmpty) => {
|
| 139 |
+
const builder = (...arguments_) => {
|
| 140 |
+
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
| 141 |
+
// Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
|
| 142 |
+
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
// Single argument is hot path, implicit coercion is faster than anything
|
| 146 |
+
// eslint-disable-next-line no-implicit-coercion
|
| 147 |
+
return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
| 148 |
+
};
|
| 149 |
+
|
| 150 |
+
// We alter the prototype because we must return a function, but there is
|
| 151 |
+
// no way to create a function with a different prototype
|
| 152 |
+
Object.setPrototypeOf(builder, proto);
|
| 153 |
+
|
| 154 |
+
builder._generator = self;
|
| 155 |
+
builder._styler = _styler;
|
| 156 |
+
builder._isEmpty = _isEmpty;
|
| 157 |
+
|
| 158 |
+
return builder;
|
| 159 |
+
};
|
| 160 |
+
|
| 161 |
+
const applyStyle = (self, string) => {
|
| 162 |
+
if (self.level <= 0 || !string) {
|
| 163 |
+
return self._isEmpty ? '' : string;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
let styler = self._styler;
|
| 167 |
+
|
| 168 |
+
if (styler === undefined) {
|
| 169 |
+
return string;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
const {openAll, closeAll} = styler;
|
| 173 |
+
if (string.indexOf('\u001B') !== -1) {
|
| 174 |
+
while (styler !== undefined) {
|
| 175 |
+
// Replace any instances already present with a re-opening code
|
| 176 |
+
// otherwise only the part of the string until said closing code
|
| 177 |
+
// will be colored, and the rest will simply be 'plain'.
|
| 178 |
+
string = stringReplaceAll(string, styler.close, styler.open);
|
| 179 |
+
|
| 180 |
+
styler = styler.parent;
|
| 181 |
+
}
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
// We can move both next actions out of loop, because remaining actions in loop won't have
|
| 185 |
+
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
|
| 186 |
+
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
| 187 |
+
const lfIndex = string.indexOf('\n');
|
| 188 |
+
if (lfIndex !== -1) {
|
| 189 |
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
return openAll + string + closeAll;
|
| 193 |
+
};
|
| 194 |
+
|
| 195 |
+
let template;
|
| 196 |
+
const chalkTag = (chalk, ...strings) => {
|
| 197 |
+
const [firstString] = strings;
|
| 198 |
+
|
| 199 |
+
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
| 200 |
+
// If chalk() was called by itself or with a string,
|
| 201 |
+
// return the string itself as a string.
|
| 202 |
+
return strings.join(' ');
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
const arguments_ = strings.slice(1);
|
| 206 |
+
const parts = [firstString.raw[0]];
|
| 207 |
+
|
| 208 |
+
for (let i = 1; i < firstString.length; i++) {
|
| 209 |
+
parts.push(
|
| 210 |
+
String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
|
| 211 |
+
String(firstString.raw[i])
|
| 212 |
+
);
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
if (template === undefined) {
|
| 216 |
+
template = require('./templates');
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
return template(chalk, parts.join(''));
|
| 220 |
+
};
|
| 221 |
+
|
| 222 |
+
Object.defineProperties(Chalk.prototype, styles);
|
| 223 |
+
|
| 224 |
+
const chalk = Chalk(); // eslint-disable-line new-cap
|
| 225 |
+
chalk.supportsColor = stdoutColor;
|
| 226 |
+
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
|
| 227 |
+
chalk.stderr.supportsColor = stderrColor;
|
| 228 |
+
|
| 229 |
+
module.exports = chalk;
|
novas/novacore-zephyr/claude-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[\r\n\f])+?)/gi;
|
| 3 |
+
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
| 4 |
+
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
| 5 |
+
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
| 6 |
+
|
| 7 |
+
const ESCAPES = new Map([
|
| 8 |
+
['n', '\n'],
|
| 9 |
+
['r', '\r'],
|
| 10 |
+
['t', '\t'],
|
| 11 |
+
['b', '\b'],
|
| 12 |
+
['f', '\f'],
|
| 13 |
+
['v', '\v'],
|
| 14 |
+
['0', '\0'],
|
| 15 |
+
['\\', '\\'],
|
| 16 |
+
['e', '\u001B'],
|
| 17 |
+
['a', '\u0007']
|
| 18 |
+
]);
|
| 19 |
+
|
| 20 |
+
function unescape(c) {
|
| 21 |
+
const u = c[0] === 'u';
|
| 22 |
+
const bracket = c[1] === '{';
|
| 23 |
+
|
| 24 |
+
if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
|
| 25 |
+
return String.fromCharCode(parseInt(c.slice(1), 16));
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
if (u && bracket) {
|
| 29 |
+
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
return ESCAPES.get(c) || c;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
function parseArguments(name, arguments_) {
|
| 36 |
+
const results = [];
|
| 37 |
+
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
| 38 |
+
let matches;
|
| 39 |
+
|
| 40 |
+
for (const chunk of chunks) {
|
| 41 |
+
const number = Number(chunk);
|
| 42 |
+
if (!Number.isNaN(number)) {
|
| 43 |
+
results.push(number);
|
| 44 |
+
} else if ((matches = chunk.match(STRING_REGEX))) {
|
| 45 |
+
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
| 46 |
+
} else {
|
| 47 |
+
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
return results;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
function parseStyle(style) {
|
| 55 |
+
STYLE_REGEX.lastIndex = 0;
|
| 56 |
+
|
| 57 |
+
const results = [];
|
| 58 |
+
let matches;
|
| 59 |
+
|
| 60 |
+
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
| 61 |
+
const name = matches[1];
|
| 62 |
+
|
| 63 |
+
if (matches[2]) {
|
| 64 |
+
const args = parseArguments(name, matches[2]);
|
| 65 |
+
results.push([name].concat(args));
|
| 66 |
+
} else {
|
| 67 |
+
results.push([name]);
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
return results;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
function buildStyle(chalk, styles) {
|
| 75 |
+
const enabled = {};
|
| 76 |
+
|
| 77 |
+
for (const layer of styles) {
|
| 78 |
+
for (const style of layer.styles) {
|
| 79 |
+
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
let current = chalk;
|
| 84 |
+
for (const [styleName, styles] of Object.entries(enabled)) {
|
| 85 |
+
if (!Array.isArray(styles)) {
|
| 86 |
+
continue;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
if (!(styleName in current)) {
|
| 90 |
+
throw new Error(`Unknown Chalk style: ${styleName}`);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
return current;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
module.exports = (chalk, temporary) => {
|
| 100 |
+
const styles = [];
|
| 101 |
+
const chunks = [];
|
| 102 |
+
let chunk = [];
|
| 103 |
+
|
| 104 |
+
// eslint-disable-next-line max-params
|
| 105 |
+
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
| 106 |
+
if (escapeCharacter) {
|
| 107 |
+
chunk.push(unescape(escapeCharacter));
|
| 108 |
+
} else if (style) {
|
| 109 |
+
const string = chunk.join('');
|
| 110 |
+
chunk = [];
|
| 111 |
+
chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
|
| 112 |
+
styles.push({inverse, styles: parseStyle(style)});
|
| 113 |
+
} else if (close) {
|
| 114 |
+
if (styles.length === 0) {
|
| 115 |
+
throw new Error('Found extraneous } in Chalk template literal');
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
chunks.push(buildStyle(chalk, styles)(chunk.join('')));
|
| 119 |
+
chunk = [];
|
| 120 |
+
styles.pop();
|
| 121 |
+
} else {
|
| 122 |
+
chunk.push(character);
|
| 123 |
+
}
|
| 124 |
+
});
|
| 125 |
+
|
| 126 |
+
chunks.push(chunk.join(''));
|
| 127 |
+
|
| 128 |
+
if (styles.length > 0) {
|
| 129 |
+
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
| 130 |
+
throw new Error(errMessage);
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
return chunks.join('');
|
| 134 |
+
};
|
novas/novacore-zephyr/claude-code-router/node_modules/chalk/source/util.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
const stringReplaceAll = (string, substring, replacer) => {
|
| 4 |
+
let index = string.indexOf(substring);
|
| 5 |
+
if (index === -1) {
|
| 6 |
+
return string;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
const substringLength = substring.length;
|
| 10 |
+
let endIndex = 0;
|
| 11 |
+
let returnValue = '';
|
| 12 |
+
do {
|
| 13 |
+
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
| 14 |
+
endIndex = index + substringLength;
|
| 15 |
+
index = string.indexOf(substring, endIndex);
|
| 16 |
+
} while (index !== -1);
|
| 17 |
+
|
| 18 |
+
returnValue += string.substr(endIndex);
|
| 19 |
+
return returnValue;
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
|
| 23 |
+
let endIndex = 0;
|
| 24 |
+
let returnValue = '';
|
| 25 |
+
do {
|
| 26 |
+
const gotCR = string[index - 1] === '\r';
|
| 27 |
+
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
|
| 28 |
+
endIndex = index + 1;
|
| 29 |
+
index = string.indexOf('\n', endIndex);
|
| 30 |
+
} while (index !== -1);
|
| 31 |
+
|
| 32 |
+
returnValue += string.substr(endIndex);
|
| 33 |
+
return returnValue;
|
| 34 |
+
};
|
| 35 |
+
|
| 36 |
+
module.exports = {
|
| 37 |
+
stringReplaceAll,
|
| 38 |
+
stringEncaseCRLFWithFirstIndex
|
| 39 |
+
};
|
novas/novacore-zephyr/claude-code-router/node_modules/create-jest/bin/create-jest.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env node
|
| 2 |
+
/**
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
*
|
| 5 |
+
* This source code is licensed under the MIT license found in the
|
| 6 |
+
* LICENSE file in the root directory of this source tree.
|
| 7 |
+
*/
|
| 8 |
+
require('..').runCLI();
|
novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/errors.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.NotFoundPackageJsonError = exports.MalformedPackageJsonError = void 0;
|
| 7 |
+
/**
|
| 8 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 9 |
+
*
|
| 10 |
+
* This source code is licensed under the MIT license found in the
|
| 11 |
+
* LICENSE file in the root directory of this source tree.
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
class NotFoundPackageJsonError extends Error {
|
| 15 |
+
constructor(rootDir) {
|
| 16 |
+
super(`Could not find a "package.json" file in ${rootDir}`);
|
| 17 |
+
this.name = '';
|
| 18 |
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
| 19 |
+
Error.captureStackTrace(this, () => {});
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
exports.NotFoundPackageJsonError = NotFoundPackageJsonError;
|
| 23 |
+
class MalformedPackageJsonError extends Error {
|
| 24 |
+
constructor(packageJsonPath) {
|
| 25 |
+
super(`There is malformed json in ${packageJsonPath}`);
|
| 26 |
+
this.name = '';
|
| 27 |
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
| 28 |
+
Error.captureStackTrace(this, () => {});
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
exports.MalformedPackageJsonError = MalformedPackageJsonError;
|
novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/generateConfigFile.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = void 0;
|
| 7 |
+
function _jestConfig() {
|
| 8 |
+
const data = require('jest-config');
|
| 9 |
+
_jestConfig = function () {
|
| 10 |
+
return data;
|
| 11 |
+
};
|
| 12 |
+
return data;
|
| 13 |
+
}
|
| 14 |
+
/**
|
| 15 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 16 |
+
*
|
| 17 |
+
* This source code is licensed under the MIT license found in the
|
| 18 |
+
* LICENSE file in the root directory of this source tree.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
const stringifyOption = (option, map, linePrefix = '') => {
|
| 22 |
+
const description = _jestConfig().descriptions[option];
|
| 23 |
+
const optionDescription =
|
| 24 |
+
description != null && description.length > 0 ? ` // ${description}` : '';
|
| 25 |
+
const stringifiedObject = `${option}: ${JSON.stringify(
|
| 26 |
+
map[option],
|
| 27 |
+
null,
|
| 28 |
+
2
|
| 29 |
+
)}`;
|
| 30 |
+
return `${optionDescription}\n${stringifiedObject
|
| 31 |
+
.split('\n')
|
| 32 |
+
.map(line => ` ${linePrefix}${line}`)
|
| 33 |
+
.join('\n')},`;
|
| 34 |
+
};
|
| 35 |
+
const generateConfigFile = (results, generateEsm = false) => {
|
| 36 |
+
const {useTypescript, coverage, coverageProvider, clearMocks, environment} =
|
| 37 |
+
results;
|
| 38 |
+
const overrides = {};
|
| 39 |
+
if (coverage) {
|
| 40 |
+
Object.assign(overrides, {
|
| 41 |
+
collectCoverage: true,
|
| 42 |
+
coverageDirectory: 'coverage'
|
| 43 |
+
});
|
| 44 |
+
}
|
| 45 |
+
if (coverageProvider === 'v8') {
|
| 46 |
+
Object.assign(overrides, {
|
| 47 |
+
coverageProvider: 'v8'
|
| 48 |
+
});
|
| 49 |
+
}
|
| 50 |
+
if (environment === 'jsdom') {
|
| 51 |
+
Object.assign(overrides, {
|
| 52 |
+
testEnvironment: 'jsdom'
|
| 53 |
+
});
|
| 54 |
+
}
|
| 55 |
+
if (clearMocks) {
|
| 56 |
+
Object.assign(overrides, {
|
| 57 |
+
clearMocks: true
|
| 58 |
+
});
|
| 59 |
+
}
|
| 60 |
+
const overrideKeys = Object.keys(overrides);
|
| 61 |
+
const properties = [];
|
| 62 |
+
for (const option in _jestConfig().descriptions) {
|
| 63 |
+
const opt = option;
|
| 64 |
+
if (overrideKeys.includes(opt)) {
|
| 65 |
+
properties.push(stringifyOption(opt, overrides));
|
| 66 |
+
} else {
|
| 67 |
+
properties.push(stringifyOption(opt, _jestConfig().defaults, '// '));
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
const configHeaderMessage = `/**
|
| 71 |
+
* For a detailed explanation regarding each configuration property, visit:
|
| 72 |
+
* https://jestjs.io/docs/configuration
|
| 73 |
+
*/
|
| 74 |
+
`;
|
| 75 |
+
const jsDeclaration = `/** @type {import('jest').Config} */
|
| 76 |
+
const config = {`;
|
| 77 |
+
const tsDeclaration = `import type {Config} from 'jest';
|
| 78 |
+
|
| 79 |
+
const config: Config = {`;
|
| 80 |
+
const cjsExport = 'module.exports = config;';
|
| 81 |
+
const esmExport = 'export default config;';
|
| 82 |
+
return [
|
| 83 |
+
configHeaderMessage,
|
| 84 |
+
useTypescript ? tsDeclaration : jsDeclaration,
|
| 85 |
+
properties.join('\n\n'),
|
| 86 |
+
'};\n',
|
| 87 |
+
useTypescript || generateEsm ? esmExport : cjsExport,
|
| 88 |
+
''
|
| 89 |
+
].join('\n');
|
| 90 |
+
};
|
| 91 |
+
var _default = generateConfigFile;
|
| 92 |
+
exports.default = _default;
|
novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 3 |
+
*
|
| 4 |
+
* This source code is licensed under the MIT license found in the
|
| 5 |
+
* LICENSE file in the root directory of this source tree.
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
export declare function runCLI(): Promise<void>;
|
| 9 |
+
|
| 10 |
+
export declare function runCreate(rootDir?: string): Promise<void>;
|
| 11 |
+
|
| 12 |
+
export {};
|
novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
Object.defineProperty(exports, 'runCLI', {
|
| 7 |
+
enumerable: true,
|
| 8 |
+
get: function () {
|
| 9 |
+
return _runCreate.runCLI;
|
| 10 |
+
}
|
| 11 |
+
});
|
| 12 |
+
Object.defineProperty(exports, 'runCreate', {
|
| 13 |
+
enumerable: true,
|
| 14 |
+
get: function () {
|
| 15 |
+
return _runCreate.runCreate;
|
| 16 |
+
}
|
| 17 |
+
});
|
| 18 |
+
var _runCreate = require('./runCreate');
|
novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/modifyPackageJson.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = void 0;
|
| 7 |
+
/**
|
| 8 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 9 |
+
*
|
| 10 |
+
* This source code is licensed under the MIT license found in the
|
| 11 |
+
* LICENSE file in the root directory of this source tree.
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
const modifyPackageJson = ({projectPackageJson, shouldModifyScripts}) => {
|
| 15 |
+
if (shouldModifyScripts) {
|
| 16 |
+
projectPackageJson.scripts
|
| 17 |
+
? (projectPackageJson.scripts.test = 'jest')
|
| 18 |
+
: (projectPackageJson.scripts = {
|
| 19 |
+
test: 'jest'
|
| 20 |
+
});
|
| 21 |
+
}
|
| 22 |
+
delete projectPackageJson.jest;
|
| 23 |
+
return `${JSON.stringify(projectPackageJson, null, 2)}\n`;
|
| 24 |
+
};
|
| 25 |
+
var _default = modifyPackageJson;
|
| 26 |
+
exports.default = _default;
|
novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/questions.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.testScriptQuestion = exports.default = void 0;
|
| 7 |
+
/**
|
| 8 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 9 |
+
*
|
| 10 |
+
* This source code is licensed under the MIT license found in the
|
| 11 |
+
* LICENSE file in the root directory of this source tree.
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
const defaultQuestions = [
|
| 15 |
+
{
|
| 16 |
+
initial: false,
|
| 17 |
+
message: 'Would you like to use Typescript for the configuration file?',
|
| 18 |
+
name: 'useTypescript',
|
| 19 |
+
type: 'confirm'
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
choices: [
|
| 23 |
+
{
|
| 24 |
+
title: 'node',
|
| 25 |
+
value: 'node'
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
title: 'jsdom (browser-like)',
|
| 29 |
+
value: 'jsdom'
|
| 30 |
+
}
|
| 31 |
+
],
|
| 32 |
+
initial: 0,
|
| 33 |
+
message: 'Choose the test environment that will be used for testing',
|
| 34 |
+
name: 'environment',
|
| 35 |
+
type: 'select'
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
initial: false,
|
| 39 |
+
message: 'Do you want Jest to add coverage reports?',
|
| 40 |
+
name: 'coverage',
|
| 41 |
+
type: 'confirm'
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
choices: [
|
| 45 |
+
{
|
| 46 |
+
title: 'v8',
|
| 47 |
+
value: 'v8'
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
title: 'babel',
|
| 51 |
+
value: 'babel'
|
| 52 |
+
}
|
| 53 |
+
],
|
| 54 |
+
initial: 0,
|
| 55 |
+
message: 'Which provider should be used to instrument code for coverage?',
|
| 56 |
+
name: 'coverageProvider',
|
| 57 |
+
type: 'select'
|
| 58 |
+
},
|
| 59 |
+
{
|
| 60 |
+
initial: false,
|
| 61 |
+
message:
|
| 62 |
+
'Automatically clear mock calls, instances, contexts and results before every test?',
|
| 63 |
+
name: 'clearMocks',
|
| 64 |
+
type: 'confirm'
|
| 65 |
+
}
|
| 66 |
+
];
|
| 67 |
+
var _default = defaultQuestions;
|
| 68 |
+
exports.default = _default;
|
| 69 |
+
const testScriptQuestion = {
|
| 70 |
+
initial: true,
|
| 71 |
+
message:
|
| 72 |
+
'Would you like to use Jest when running "test" script in "package.json"?',
|
| 73 |
+
name: 'scripts',
|
| 74 |
+
type: 'confirm'
|
| 75 |
+
};
|
| 76 |
+
exports.testScriptQuestion = testScriptQuestion;
|
novas/novacore-zephyr/claude-code-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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.runCLI = runCLI;
|
| 7 |
+
exports.runCreate = runCreate;
|
| 8 |
+
function path() {
|
| 9 |
+
const data = _interopRequireWildcard(require('path'));
|
| 10 |
+
path = function () {
|
| 11 |
+
return data;
|
| 12 |
+
};
|
| 13 |
+
return data;
|
| 14 |
+
}
|
| 15 |
+
function _chalk() {
|
| 16 |
+
const data = _interopRequireDefault(require('chalk'));
|
| 17 |
+
_chalk = function () {
|
| 18 |
+
return data;
|
| 19 |
+
};
|
| 20 |
+
return data;
|
| 21 |
+
}
|
| 22 |
+
function _exit() {
|
| 23 |
+
const data = _interopRequireDefault(require('exit'));
|
| 24 |
+
_exit = function () {
|
| 25 |
+
return data;
|
| 26 |
+
};
|
| 27 |
+
return data;
|
| 28 |
+
}
|
| 29 |
+
function fs() {
|
| 30 |
+
const data = _interopRequireWildcard(require('graceful-fs'));
|
| 31 |
+
fs = function () {
|
| 32 |
+
return data;
|
| 33 |
+
};
|
| 34 |
+
return data;
|
| 35 |
+
}
|
| 36 |
+
function _prompts() {
|
| 37 |
+
const data = _interopRequireDefault(require('prompts'));
|
| 38 |
+
_prompts = function () {
|
| 39 |
+
return data;
|
| 40 |
+
};
|
| 41 |
+
return data;
|
| 42 |
+
}
|
| 43 |
+
function _jestConfig() {
|
| 44 |
+
const data = require('jest-config');
|
| 45 |
+
_jestConfig = function () {
|
| 46 |
+
return data;
|
| 47 |
+
};
|
| 48 |
+
return data;
|
| 49 |
+
}
|
| 50 |
+
function _jestUtil() {
|
| 51 |
+
const data = require('jest-util');
|
| 52 |
+
_jestUtil = function () {
|
| 53 |
+
return data;
|
| 54 |
+
};
|
| 55 |
+
return data;
|
| 56 |
+
}
|
| 57 |
+
var _errors = require('./errors');
|
| 58 |
+
var _generateConfigFile = _interopRequireDefault(
|
| 59 |
+
require('./generateConfigFile')
|
| 60 |
+
);
|
| 61 |
+
var _modifyPackageJson = _interopRequireDefault(require('./modifyPackageJson'));
|
| 62 |
+
var _questions = _interopRequireWildcard(require('./questions'));
|
| 63 |
+
function _interopRequireDefault(obj) {
|
| 64 |
+
return obj && obj.__esModule ? obj : {default: obj};
|
| 65 |
+
}
|
| 66 |
+
function _getRequireWildcardCache(nodeInterop) {
|
| 67 |
+
if (typeof WeakMap !== 'function') return null;
|
| 68 |
+
var cacheBabelInterop = new WeakMap();
|
| 69 |
+
var cacheNodeInterop = new WeakMap();
|
| 70 |
+
return (_getRequireWildcardCache = function (nodeInterop) {
|
| 71 |
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
| 72 |
+
})(nodeInterop);
|
| 73 |
+
}
|
| 74 |
+
function _interopRequireWildcard(obj, nodeInterop) {
|
| 75 |
+
if (!nodeInterop && obj && obj.__esModule) {
|
| 76 |
+
return obj;
|
| 77 |
+
}
|
| 78 |
+
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
| 79 |
+
return {default: obj};
|
| 80 |
+
}
|
| 81 |
+
var cache = _getRequireWildcardCache(nodeInterop);
|
| 82 |
+
if (cache && cache.has(obj)) {
|
| 83 |
+
return cache.get(obj);
|
| 84 |
+
}
|
| 85 |
+
var newObj = {};
|
| 86 |
+
var hasPropertyDescriptor =
|
| 87 |
+
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
| 88 |
+
for (var key in obj) {
|
| 89 |
+
if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
|
| 90 |
+
var desc = hasPropertyDescriptor
|
| 91 |
+
? Object.getOwnPropertyDescriptor(obj, key)
|
| 92 |
+
: null;
|
| 93 |
+
if (desc && (desc.get || desc.set)) {
|
| 94 |
+
Object.defineProperty(newObj, key, desc);
|
| 95 |
+
} else {
|
| 96 |
+
newObj[key] = obj[key];
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
newObj.default = obj;
|
| 101 |
+
if (cache) {
|
| 102 |
+
cache.set(obj, newObj);
|
| 103 |
+
}
|
| 104 |
+
return newObj;
|
| 105 |
+
}
|
| 106 |
+
/**
|
| 107 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 108 |
+
*
|
| 109 |
+
* This source code is licensed under the MIT license found in the
|
| 110 |
+
* LICENSE file in the root directory of this source tree.
|
| 111 |
+
*/
|
| 112 |
+
|
| 113 |
+
const {
|
| 114 |
+
JEST_CONFIG_BASE_NAME,
|
| 115 |
+
JEST_CONFIG_EXT_MJS,
|
| 116 |
+
JEST_CONFIG_EXT_JS,
|
| 117 |
+
JEST_CONFIG_EXT_TS,
|
| 118 |
+
JEST_CONFIG_EXT_ORDER,
|
| 119 |
+
PACKAGE_JSON
|
| 120 |
+
} = _jestConfig().constants;
|
| 121 |
+
const getConfigFilename = ext => JEST_CONFIG_BASE_NAME + ext;
|
| 122 |
+
async function runCLI() {
|
| 123 |
+
try {
|
| 124 |
+
const rootDir = process.argv[2];
|
| 125 |
+
await runCreate(rootDir);
|
| 126 |
+
} catch (error) {
|
| 127 |
+
(0, _jestUtil().clearLine)(process.stderr);
|
| 128 |
+
(0, _jestUtil().clearLine)(process.stdout);
|
| 129 |
+
if (error instanceof Error && Boolean(error?.stack)) {
|
| 130 |
+
console.error(_chalk().default.red(error.stack));
|
| 131 |
+
} else {
|
| 132 |
+
console.error(_chalk().default.red(error));
|
| 133 |
+
}
|
| 134 |
+
(0, _exit().default)(1);
|
| 135 |
+
throw error;
|
| 136 |
+
}
|
| 137 |
+
}
|
| 138 |
+
async function runCreate(rootDir = process.cwd()) {
|
| 139 |
+
rootDir = (0, _jestUtil().tryRealpath)(rootDir);
|
| 140 |
+
// prerequisite checks
|
| 141 |
+
const projectPackageJsonPath = path().join(rootDir, PACKAGE_JSON);
|
| 142 |
+
if (!fs().existsSync(projectPackageJsonPath)) {
|
| 143 |
+
throw new _errors.NotFoundPackageJsonError(rootDir);
|
| 144 |
+
}
|
| 145 |
+
const questions = _questions.default.slice(0);
|
| 146 |
+
let hasJestProperty = false;
|
| 147 |
+
let projectPackageJson;
|
| 148 |
+
try {
|
| 149 |
+
projectPackageJson = JSON.parse(
|
| 150 |
+
fs().readFileSync(projectPackageJsonPath, 'utf-8')
|
| 151 |
+
);
|
| 152 |
+
} catch {
|
| 153 |
+
throw new _errors.MalformedPackageJsonError(projectPackageJsonPath);
|
| 154 |
+
}
|
| 155 |
+
if (projectPackageJson.jest) {
|
| 156 |
+
hasJestProperty = true;
|
| 157 |
+
}
|
| 158 |
+
const existingJestConfigExt = JEST_CONFIG_EXT_ORDER.find(ext =>
|
| 159 |
+
fs().existsSync(path().join(rootDir, getConfigFilename(ext)))
|
| 160 |
+
);
|
| 161 |
+
if (hasJestProperty || existingJestConfigExt != null) {
|
| 162 |
+
const result = await (0, _prompts().default)({
|
| 163 |
+
initial: true,
|
| 164 |
+
message:
|
| 165 |
+
'It seems that you already have a jest configuration, do you want to override it?',
|
| 166 |
+
name: 'continue',
|
| 167 |
+
type: 'confirm'
|
| 168 |
+
});
|
| 169 |
+
if (!result.continue) {
|
| 170 |
+
console.log();
|
| 171 |
+
console.log('Aborting...');
|
| 172 |
+
return;
|
| 173 |
+
}
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
// Add test script installation only if needed
|
| 177 |
+
if (
|
| 178 |
+
!projectPackageJson.scripts ||
|
| 179 |
+
projectPackageJson.scripts.test !== 'jest'
|
| 180 |
+
) {
|
| 181 |
+
questions.unshift(_questions.testScriptQuestion);
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
// Start the init process
|
| 185 |
+
console.log();
|
| 186 |
+
console.log(
|
| 187 |
+
_chalk().default.underline(
|
| 188 |
+
'The following questions will help Jest to create a suitable configuration for your project\n'
|
| 189 |
+
)
|
| 190 |
+
);
|
| 191 |
+
let promptAborted = false;
|
| 192 |
+
const results = await (0, _prompts().default)(questions, {
|
| 193 |
+
onCancel: () => {
|
| 194 |
+
promptAborted = true;
|
| 195 |
+
}
|
| 196 |
+
});
|
| 197 |
+
if (promptAborted) {
|
| 198 |
+
console.log();
|
| 199 |
+
console.log('Aborting...');
|
| 200 |
+
return;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
// Determine if Jest should use JS or TS for the config file
|
| 204 |
+
const jestConfigFileExt = results.useTypescript
|
| 205 |
+
? JEST_CONFIG_EXT_TS
|
| 206 |
+
: projectPackageJson.type === 'module'
|
| 207 |
+
? JEST_CONFIG_EXT_MJS
|
| 208 |
+
: JEST_CONFIG_EXT_JS;
|
| 209 |
+
|
| 210 |
+
// Determine Jest config path
|
| 211 |
+
const jestConfigPath =
|
| 212 |
+
existingJestConfigExt != null
|
| 213 |
+
? getConfigFilename(existingJestConfigExt)
|
| 214 |
+
: path().join(rootDir, getConfigFilename(jestConfigFileExt));
|
| 215 |
+
const shouldModifyScripts = results.scripts;
|
| 216 |
+
if (shouldModifyScripts || hasJestProperty) {
|
| 217 |
+
const modifiedPackageJson = (0, _modifyPackageJson.default)({
|
| 218 |
+
projectPackageJson,
|
| 219 |
+
shouldModifyScripts
|
| 220 |
+
});
|
| 221 |
+
fs().writeFileSync(projectPackageJsonPath, modifiedPackageJson);
|
| 222 |
+
console.log('');
|
| 223 |
+
console.log(
|
| 224 |
+
`✏️ Modified ${_chalk().default.cyan(projectPackageJsonPath)}`
|
| 225 |
+
);
|
| 226 |
+
}
|
| 227 |
+
const generatedConfig = (0, _generateConfigFile.default)(
|
| 228 |
+
results,
|
| 229 |
+
projectPackageJson.type === 'module' ||
|
| 230 |
+
jestConfigPath.endsWith(JEST_CONFIG_EXT_MJS)
|
| 231 |
+
);
|
| 232 |
+
fs().writeFileSync(jestConfigPath, generatedConfig);
|
| 233 |
+
console.log('');
|
| 234 |
+
console.log(
|
| 235 |
+
`📝 Configuration file created at ${_chalk().default.cyan(jestConfigPath)}`
|
| 236 |
+
);
|
| 237 |
+
}
|
novas/novacore-zephyr/claude-code-router/node_modules/create-jest/build/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
novas/novacore-zephyr/claude-code-router/node_modules/diff-sequences/build/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 3 |
+
*
|
| 4 |
+
* This source code is licensed under the MIT license found in the
|
| 5 |
+
* LICENSE file in the root directory of this source tree.
|
| 6 |
+
*/
|
| 7 |
+
export declare type Callbacks = {
|
| 8 |
+
foundSubsequence: FoundSubsequence;
|
| 9 |
+
isCommon: IsCommon;
|
| 10 |
+
};
|
| 11 |
+
|
| 12 |
+
declare function diffSequence(
|
| 13 |
+
aLength: number,
|
| 14 |
+
bLength: number,
|
| 15 |
+
isCommon: IsCommon,
|
| 16 |
+
foundSubsequence: FoundSubsequence,
|
| 17 |
+
): void;
|
| 18 |
+
export default diffSequence;
|
| 19 |
+
|
| 20 |
+
declare type FoundSubsequence = (
|
| 21 |
+
nCommon: number, // caller can assume: 0 < nCommon
|
| 22 |
+
aCommon: number, // caller can assume: 0 <= aCommon && aCommon < aLength
|
| 23 |
+
bCommon: number,
|
| 24 |
+
) => void;
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 28 |
+
*
|
| 29 |
+
* This source code is licensed under the MIT license found in the
|
| 30 |
+
* LICENSE file in the root directory of this source tree.
|
| 31 |
+
*
|
| 32 |
+
*/
|
| 33 |
+
declare type IsCommon = (
|
| 34 |
+
aIndex: number, // caller can assume: 0 <= aIndex && aIndex < aLength
|
| 35 |
+
bIndex: number,
|
| 36 |
+
) => boolean;
|
| 37 |
+
|
| 38 |
+
export {};
|
novas/novacore-zephyr/claude-code-router/node_modules/diff-sequences/build/index.js
ADDED
|
@@ -0,0 +1,798 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = diffSequence;
|
| 7 |
+
/**
|
| 8 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 9 |
+
*
|
| 10 |
+
* This source code is licensed under the MIT license found in the
|
| 11 |
+
* LICENSE file in the root directory of this source tree.
|
| 12 |
+
*
|
| 13 |
+
*/
|
| 14 |
+
|
| 15 |
+
// This diff-sequences package implements the linear space variation in
|
| 16 |
+
// An O(ND) Difference Algorithm and Its Variations by Eugene W. Myers
|
| 17 |
+
|
| 18 |
+
// Relationship in notation between Myers paper and this package:
|
| 19 |
+
// A is a
|
| 20 |
+
// N is aLength, aEnd - aStart, and so on
|
| 21 |
+
// x is aIndex, aFirst, aLast, and so on
|
| 22 |
+
// B is b
|
| 23 |
+
// M is bLength, bEnd - bStart, and so on
|
| 24 |
+
// y is bIndex, bFirst, bLast, and so on
|
| 25 |
+
// Δ = N - M is negative of baDeltaLength = bLength - aLength
|
| 26 |
+
// D is d
|
| 27 |
+
// k is kF
|
| 28 |
+
// k + Δ is kF = kR - baDeltaLength
|
| 29 |
+
// V is aIndexesF or aIndexesR (see comment below about Indexes type)
|
| 30 |
+
// index intervals [1, N] and [1, M] are [0, aLength) and [0, bLength)
|
| 31 |
+
// starting point in forward direction (0, 0) is (-1, -1)
|
| 32 |
+
// starting point in reverse direction (N + 1, M + 1) is (aLength, bLength)
|
| 33 |
+
|
| 34 |
+
// The “edit graph” for sequences a and b corresponds to items:
|
| 35 |
+
// in a on the horizontal axis
|
| 36 |
+
// in b on the vertical axis
|
| 37 |
+
//
|
| 38 |
+
// Given a-coordinate of a point in a diagonal, you can compute b-coordinate.
|
| 39 |
+
//
|
| 40 |
+
// Forward diagonals kF:
|
| 41 |
+
// zero diagonal intersects top left corner
|
| 42 |
+
// positive diagonals intersect top edge
|
| 43 |
+
// negative diagonals insersect left edge
|
| 44 |
+
//
|
| 45 |
+
// Reverse diagonals kR:
|
| 46 |
+
// zero diagonal intersects bottom right corner
|
| 47 |
+
// positive diagonals intersect right edge
|
| 48 |
+
// negative diagonals intersect bottom edge
|
| 49 |
+
|
| 50 |
+
// The graph contains a directed acyclic graph of edges:
|
| 51 |
+
// horizontal: delete an item from a
|
| 52 |
+
// vertical: insert an item from b
|
| 53 |
+
// diagonal: common item in a and b
|
| 54 |
+
//
|
| 55 |
+
// The algorithm solves dual problems in the graph analogy:
|
| 56 |
+
// Find longest common subsequence: path with maximum number of diagonal edges
|
| 57 |
+
// Find shortest edit script: path with minimum number of non-diagonal edges
|
| 58 |
+
|
| 59 |
+
// Input callback function compares items at indexes in the sequences.
|
| 60 |
+
|
| 61 |
+
// Output callback function receives the number of adjacent items
|
| 62 |
+
// and starting indexes of each common subsequence.
|
| 63 |
+
// Either original functions or wrapped to swap indexes if graph is transposed.
|
| 64 |
+
// Indexes in sequence a of last point of forward or reverse paths in graph.
|
| 65 |
+
// Myers algorithm indexes by diagonal k which for negative is bad deopt in V8.
|
| 66 |
+
// This package indexes by iF and iR which are greater than or equal to zero.
|
| 67 |
+
// and also updates the index arrays in place to cut memory in half.
|
| 68 |
+
// kF = 2 * iF - d
|
| 69 |
+
// kR = d - 2 * iR
|
| 70 |
+
// Division of index intervals in sequences a and b at the middle change.
|
| 71 |
+
// Invariant: intervals do not have common items at the start or end.
|
| 72 |
+
const pkg = 'diff-sequences'; // for error messages
|
| 73 |
+
const NOT_YET_SET = 0; // small int instead of undefined to avoid deopt in V8
|
| 74 |
+
|
| 75 |
+
// Return the number of common items that follow in forward direction.
|
| 76 |
+
// The length of what Myers paper calls a “snake” in a forward path.
|
| 77 |
+
const countCommonItemsF = (aIndex, aEnd, bIndex, bEnd, isCommon) => {
|
| 78 |
+
let nCommon = 0;
|
| 79 |
+
while (aIndex < aEnd && bIndex < bEnd && isCommon(aIndex, bIndex)) {
|
| 80 |
+
aIndex += 1;
|
| 81 |
+
bIndex += 1;
|
| 82 |
+
nCommon += 1;
|
| 83 |
+
}
|
| 84 |
+
return nCommon;
|
| 85 |
+
};
|
| 86 |
+
|
| 87 |
+
// Return the number of common items that precede in reverse direction.
|
| 88 |
+
// The length of what Myers paper calls a “snake” in a reverse path.
|
| 89 |
+
const countCommonItemsR = (aStart, aIndex, bStart, bIndex, isCommon) => {
|
| 90 |
+
let nCommon = 0;
|
| 91 |
+
while (aStart <= aIndex && bStart <= bIndex && isCommon(aIndex, bIndex)) {
|
| 92 |
+
aIndex -= 1;
|
| 93 |
+
bIndex -= 1;
|
| 94 |
+
nCommon += 1;
|
| 95 |
+
}
|
| 96 |
+
return nCommon;
|
| 97 |
+
};
|
| 98 |
+
|
| 99 |
+
// A simple function to extend forward paths from (d - 1) to d changes
|
| 100 |
+
// when forward and reverse paths cannot yet overlap.
|
| 101 |
+
const extendPathsF = (
|
| 102 |
+
d,
|
| 103 |
+
aEnd,
|
| 104 |
+
bEnd,
|
| 105 |
+
bF,
|
| 106 |
+
isCommon,
|
| 107 |
+
aIndexesF,
|
| 108 |
+
iMaxF // return the value because optimization might decrease it
|
| 109 |
+
) => {
|
| 110 |
+
// Unroll the first iteration.
|
| 111 |
+
let iF = 0;
|
| 112 |
+
let kF = -d; // kF = 2 * iF - d
|
| 113 |
+
let aFirst = aIndexesF[iF]; // in first iteration always insert
|
| 114 |
+
let aIndexPrev1 = aFirst; // prev value of [iF - 1] in next iteration
|
| 115 |
+
aIndexesF[iF] += countCommonItemsF(
|
| 116 |
+
aFirst + 1,
|
| 117 |
+
aEnd,
|
| 118 |
+
bF + aFirst - kF + 1,
|
| 119 |
+
bEnd,
|
| 120 |
+
isCommon
|
| 121 |
+
);
|
| 122 |
+
|
| 123 |
+
// Optimization: skip diagonals in which paths cannot ever overlap.
|
| 124 |
+
const nF = d < iMaxF ? d : iMaxF;
|
| 125 |
+
|
| 126 |
+
// The diagonals kF are odd when d is odd and even when d is even.
|
| 127 |
+
for (iF += 1, kF += 2; iF <= nF; iF += 1, kF += 2) {
|
| 128 |
+
// To get first point of path segment, move one change in forward direction
|
| 129 |
+
// from last point of previous path segment in an adjacent diagonal.
|
| 130 |
+
// In last possible iteration when iF === d and kF === d always delete.
|
| 131 |
+
if (iF !== d && aIndexPrev1 < aIndexesF[iF]) {
|
| 132 |
+
aFirst = aIndexesF[iF]; // vertical to insert from b
|
| 133 |
+
} else {
|
| 134 |
+
aFirst = aIndexPrev1 + 1; // horizontal to delete from a
|
| 135 |
+
|
| 136 |
+
if (aEnd <= aFirst) {
|
| 137 |
+
// Optimization: delete moved past right of graph.
|
| 138 |
+
return iF - 1;
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
// To get last point of path segment, move along diagonal of common items.
|
| 143 |
+
aIndexPrev1 = aIndexesF[iF];
|
| 144 |
+
aIndexesF[iF] =
|
| 145 |
+
aFirst +
|
| 146 |
+
countCommonItemsF(aFirst + 1, aEnd, bF + aFirst - kF + 1, bEnd, isCommon);
|
| 147 |
+
}
|
| 148 |
+
return iMaxF;
|
| 149 |
+
};
|
| 150 |
+
|
| 151 |
+
// A simple function to extend reverse paths from (d - 1) to d changes
|
| 152 |
+
// when reverse and forward paths cannot yet overlap.
|
| 153 |
+
const extendPathsR = (
|
| 154 |
+
d,
|
| 155 |
+
aStart,
|
| 156 |
+
bStart,
|
| 157 |
+
bR,
|
| 158 |
+
isCommon,
|
| 159 |
+
aIndexesR,
|
| 160 |
+
iMaxR // return the value because optimization might decrease it
|
| 161 |
+
) => {
|
| 162 |
+
// Unroll the first iteration.
|
| 163 |
+
let iR = 0;
|
| 164 |
+
let kR = d; // kR = d - 2 * iR
|
| 165 |
+
let aFirst = aIndexesR[iR]; // in first iteration always insert
|
| 166 |
+
let aIndexPrev1 = aFirst; // prev value of [iR - 1] in next iteration
|
| 167 |
+
aIndexesR[iR] -= countCommonItemsR(
|
| 168 |
+
aStart,
|
| 169 |
+
aFirst - 1,
|
| 170 |
+
bStart,
|
| 171 |
+
bR + aFirst - kR - 1,
|
| 172 |
+
isCommon
|
| 173 |
+
);
|
| 174 |
+
|
| 175 |
+
// Optimization: skip diagonals in which paths cannot ever overlap.
|
| 176 |
+
const nR = d < iMaxR ? d : iMaxR;
|
| 177 |
+
|
| 178 |
+
// The diagonals kR are odd when d is odd and even when d is even.
|
| 179 |
+
for (iR += 1, kR -= 2; iR <= nR; iR += 1, kR -= 2) {
|
| 180 |
+
// To get first point of path segment, move one change in reverse direction
|
| 181 |
+
// from last point of previous path segment in an adjacent diagonal.
|
| 182 |
+
// In last possible iteration when iR === d and kR === -d always delete.
|
| 183 |
+
if (iR !== d && aIndexesR[iR] < aIndexPrev1) {
|
| 184 |
+
aFirst = aIndexesR[iR]; // vertical to insert from b
|
| 185 |
+
} else {
|
| 186 |
+
aFirst = aIndexPrev1 - 1; // horizontal to delete from a
|
| 187 |
+
|
| 188 |
+
if (aFirst < aStart) {
|
| 189 |
+
// Optimization: delete moved past left of graph.
|
| 190 |
+
return iR - 1;
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
// To get last point of path segment, move along diagonal of common items.
|
| 195 |
+
aIndexPrev1 = aIndexesR[iR];
|
| 196 |
+
aIndexesR[iR] =
|
| 197 |
+
aFirst -
|
| 198 |
+
countCommonItemsR(
|
| 199 |
+
aStart,
|
| 200 |
+
aFirst - 1,
|
| 201 |
+
bStart,
|
| 202 |
+
bR + aFirst - kR - 1,
|
| 203 |
+
isCommon
|
| 204 |
+
);
|
| 205 |
+
}
|
| 206 |
+
return iMaxR;
|
| 207 |
+
};
|
| 208 |
+
|
| 209 |
+
// A complete function to extend forward paths from (d - 1) to d changes.
|
| 210 |
+
// Return true if a path overlaps reverse path of (d - 1) changes in its diagonal.
|
| 211 |
+
const extendOverlappablePathsF = (
|
| 212 |
+
d,
|
| 213 |
+
aStart,
|
| 214 |
+
aEnd,
|
| 215 |
+
bStart,
|
| 216 |
+
bEnd,
|
| 217 |
+
isCommon,
|
| 218 |
+
aIndexesF,
|
| 219 |
+
iMaxF,
|
| 220 |
+
aIndexesR,
|
| 221 |
+
iMaxR,
|
| 222 |
+
division // update prop values if return true
|
| 223 |
+
) => {
|
| 224 |
+
const bF = bStart - aStart; // bIndex = bF + aIndex - kF
|
| 225 |
+
const aLength = aEnd - aStart;
|
| 226 |
+
const bLength = bEnd - bStart;
|
| 227 |
+
const baDeltaLength = bLength - aLength; // kF = kR - baDeltaLength
|
| 228 |
+
|
| 229 |
+
// Range of diagonals in which forward and reverse paths might overlap.
|
| 230 |
+
const kMinOverlapF = -baDeltaLength - (d - 1); // -(d - 1) <= kR
|
| 231 |
+
const kMaxOverlapF = -baDeltaLength + (d - 1); // kR <= (d - 1)
|
| 232 |
+
|
| 233 |
+
let aIndexPrev1 = NOT_YET_SET; // prev value of [iF - 1] in next iteration
|
| 234 |
+
|
| 235 |
+
// Optimization: skip diagonals in which paths cannot ever overlap.
|
| 236 |
+
const nF = d < iMaxF ? d : iMaxF;
|
| 237 |
+
|
| 238 |
+
// The diagonals kF = 2 * iF - d are odd when d is odd and even when d is even.
|
| 239 |
+
for (let iF = 0, kF = -d; iF <= nF; iF += 1, kF += 2) {
|
| 240 |
+
// To get first point of path segment, move one change in forward direction
|
| 241 |
+
// from last point of previous path segment in an adjacent diagonal.
|
| 242 |
+
// In first iteration when iF === 0 and kF === -d always insert.
|
| 243 |
+
// In last possible iteration when iF === d and kF === d always delete.
|
| 244 |
+
const insert = iF === 0 || (iF !== d && aIndexPrev1 < aIndexesF[iF]);
|
| 245 |
+
const aLastPrev = insert ? aIndexesF[iF] : aIndexPrev1;
|
| 246 |
+
const aFirst = insert
|
| 247 |
+
? aLastPrev // vertical to insert from b
|
| 248 |
+
: aLastPrev + 1; // horizontal to delete from a
|
| 249 |
+
|
| 250 |
+
// To get last point of path segment, move along diagonal of common items.
|
| 251 |
+
const bFirst = bF + aFirst - kF;
|
| 252 |
+
const nCommonF = countCommonItemsF(
|
| 253 |
+
aFirst + 1,
|
| 254 |
+
aEnd,
|
| 255 |
+
bFirst + 1,
|
| 256 |
+
bEnd,
|
| 257 |
+
isCommon
|
| 258 |
+
);
|
| 259 |
+
const aLast = aFirst + nCommonF;
|
| 260 |
+
aIndexPrev1 = aIndexesF[iF];
|
| 261 |
+
aIndexesF[iF] = aLast;
|
| 262 |
+
if (kMinOverlapF <= kF && kF <= kMaxOverlapF) {
|
| 263 |
+
// Solve for iR of reverse path with (d - 1) changes in diagonal kF:
|
| 264 |
+
// kR = kF + baDeltaLength
|
| 265 |
+
// kR = (d - 1) - 2 * iR
|
| 266 |
+
const iR = (d - 1 - (kF + baDeltaLength)) / 2;
|
| 267 |
+
|
| 268 |
+
// If this forward path overlaps the reverse path in this diagonal,
|
| 269 |
+
// then this is the middle change of the index intervals.
|
| 270 |
+
if (iR <= iMaxR && aIndexesR[iR] - 1 <= aLast) {
|
| 271 |
+
// Unlike the Myers algorithm which finds only the middle “snake”
|
| 272 |
+
// this package can find two common subsequences per division.
|
| 273 |
+
// Last point of previous path segment is on an adjacent diagonal.
|
| 274 |
+
const bLastPrev = bF + aLastPrev - (insert ? kF + 1 : kF - 1);
|
| 275 |
+
|
| 276 |
+
// Because of invariant that intervals preceding the middle change
|
| 277 |
+
// cannot have common items at the end,
|
| 278 |
+
// move in reverse direction along a diagonal of common items.
|
| 279 |
+
const nCommonR = countCommonItemsR(
|
| 280 |
+
aStart,
|
| 281 |
+
aLastPrev,
|
| 282 |
+
bStart,
|
| 283 |
+
bLastPrev,
|
| 284 |
+
isCommon
|
| 285 |
+
);
|
| 286 |
+
const aIndexPrevFirst = aLastPrev - nCommonR;
|
| 287 |
+
const bIndexPrevFirst = bLastPrev - nCommonR;
|
| 288 |
+
const aEndPreceding = aIndexPrevFirst + 1;
|
| 289 |
+
const bEndPreceding = bIndexPrevFirst + 1;
|
| 290 |
+
division.nChangePreceding = d - 1;
|
| 291 |
+
if (d - 1 === aEndPreceding + bEndPreceding - aStart - bStart) {
|
| 292 |
+
// Optimization: number of preceding changes in forward direction
|
| 293 |
+
// is equal to number of items in preceding interval,
|
| 294 |
+
// therefore it cannot contain any common items.
|
| 295 |
+
division.aEndPreceding = aStart;
|
| 296 |
+
division.bEndPreceding = bStart;
|
| 297 |
+
} else {
|
| 298 |
+
division.aEndPreceding = aEndPreceding;
|
| 299 |
+
division.bEndPreceding = bEndPreceding;
|
| 300 |
+
}
|
| 301 |
+
division.nCommonPreceding = nCommonR;
|
| 302 |
+
if (nCommonR !== 0) {
|
| 303 |
+
division.aCommonPreceding = aEndPreceding;
|
| 304 |
+
division.bCommonPreceding = bEndPreceding;
|
| 305 |
+
}
|
| 306 |
+
division.nCommonFollowing = nCommonF;
|
| 307 |
+
if (nCommonF !== 0) {
|
| 308 |
+
division.aCommonFollowing = aFirst + 1;
|
| 309 |
+
division.bCommonFollowing = bFirst + 1;
|
| 310 |
+
}
|
| 311 |
+
const aStartFollowing = aLast + 1;
|
| 312 |
+
const bStartFollowing = bFirst + nCommonF + 1;
|
| 313 |
+
division.nChangeFollowing = d - 1;
|
| 314 |
+
if (d - 1 === aEnd + bEnd - aStartFollowing - bStartFollowing) {
|
| 315 |
+
// Optimization: number of changes in reverse direction
|
| 316 |
+
// is equal to number of items in following interval,
|
| 317 |
+
// therefore it cannot contain any common items.
|
| 318 |
+
division.aStartFollowing = aEnd;
|
| 319 |
+
division.bStartFollowing = bEnd;
|
| 320 |
+
} else {
|
| 321 |
+
division.aStartFollowing = aStartFollowing;
|
| 322 |
+
division.bStartFollowing = bStartFollowing;
|
| 323 |
+
}
|
| 324 |
+
return true;
|
| 325 |
+
}
|
| 326 |
+
}
|
| 327 |
+
}
|
| 328 |
+
return false;
|
| 329 |
+
};
|
| 330 |
+
|
| 331 |
+
// A complete function to extend reverse paths from (d - 1) to d changes.
|
| 332 |
+
// Return true if a path overlaps forward path of d changes in its diagonal.
|
| 333 |
+
const extendOverlappablePathsR = (
|
| 334 |
+
d,
|
| 335 |
+
aStart,
|
| 336 |
+
aEnd,
|
| 337 |
+
bStart,
|
| 338 |
+
bEnd,
|
| 339 |
+
isCommon,
|
| 340 |
+
aIndexesF,
|
| 341 |
+
iMaxF,
|
| 342 |
+
aIndexesR,
|
| 343 |
+
iMaxR,
|
| 344 |
+
division // update prop values if return true
|
| 345 |
+
) => {
|
| 346 |
+
const bR = bEnd - aEnd; // bIndex = bR + aIndex - kR
|
| 347 |
+
const aLength = aEnd - aStart;
|
| 348 |
+
const bLength = bEnd - bStart;
|
| 349 |
+
const baDeltaLength = bLength - aLength; // kR = kF + baDeltaLength
|
| 350 |
+
|
| 351 |
+
// Range of diagonals in which forward and reverse paths might overlap.
|
| 352 |
+
const kMinOverlapR = baDeltaLength - d; // -d <= kF
|
| 353 |
+
const kMaxOverlapR = baDeltaLength + d; // kF <= d
|
| 354 |
+
|
| 355 |
+
let aIndexPrev1 = NOT_YET_SET; // prev value of [iR - 1] in next iteration
|
| 356 |
+
|
| 357 |
+
// Optimization: skip diagonals in which paths cannot ever overlap.
|
| 358 |
+
const nR = d < iMaxR ? d : iMaxR;
|
| 359 |
+
|
| 360 |
+
// The diagonals kR = d - 2 * iR are odd when d is odd and even when d is even.
|
| 361 |
+
for (let iR = 0, kR = d; iR <= nR; iR += 1, kR -= 2) {
|
| 362 |
+
// To get first point of path segment, move one change in reverse direction
|
| 363 |
+
// from last point of previous path segment in an adjacent diagonal.
|
| 364 |
+
// In first iteration when iR === 0 and kR === d always insert.
|
| 365 |
+
// In last possible iteration when iR === d and kR === -d always delete.
|
| 366 |
+
const insert = iR === 0 || (iR !== d && aIndexesR[iR] < aIndexPrev1);
|
| 367 |
+
const aLastPrev = insert ? aIndexesR[iR] : aIndexPrev1;
|
| 368 |
+
const aFirst = insert
|
| 369 |
+
? aLastPrev // vertical to insert from b
|
| 370 |
+
: aLastPrev - 1; // horizontal to delete from a
|
| 371 |
+
|
| 372 |
+
// To get last point of path segment, move along diagonal of common items.
|
| 373 |
+
const bFirst = bR + aFirst - kR;
|
| 374 |
+
const nCommonR = countCommonItemsR(
|
| 375 |
+
aStart,
|
| 376 |
+
aFirst - 1,
|
| 377 |
+
bStart,
|
| 378 |
+
bFirst - 1,
|
| 379 |
+
isCommon
|
| 380 |
+
);
|
| 381 |
+
const aLast = aFirst - nCommonR;
|
| 382 |
+
aIndexPrev1 = aIndexesR[iR];
|
| 383 |
+
aIndexesR[iR] = aLast;
|
| 384 |
+
if (kMinOverlapR <= kR && kR <= kMaxOverlapR) {
|
| 385 |
+
// Solve for iF of forward path with d changes in diagonal kR:
|
| 386 |
+
// kF = kR - baDeltaLength
|
| 387 |
+
// kF = 2 * iF - d
|
| 388 |
+
const iF = (d + (kR - baDeltaLength)) / 2;
|
| 389 |
+
|
| 390 |
+
// If this reverse path overlaps the forward path in this diagonal,
|
| 391 |
+
// then this is a middle change of the index intervals.
|
| 392 |
+
if (iF <= iMaxF && aLast - 1 <= aIndexesF[iF]) {
|
| 393 |
+
const bLast = bFirst - nCommonR;
|
| 394 |
+
division.nChangePreceding = d;
|
| 395 |
+
if (d === aLast + bLast - aStart - bStart) {
|
| 396 |
+
// Optimization: number of changes in reverse direction
|
| 397 |
+
// is equal to number of items in preceding interval,
|
| 398 |
+
// therefore it cannot contain any common items.
|
| 399 |
+
division.aEndPreceding = aStart;
|
| 400 |
+
division.bEndPreceding = bStart;
|
| 401 |
+
} else {
|
| 402 |
+
division.aEndPreceding = aLast;
|
| 403 |
+
division.bEndPreceding = bLast;
|
| 404 |
+
}
|
| 405 |
+
division.nCommonPreceding = nCommonR;
|
| 406 |
+
if (nCommonR !== 0) {
|
| 407 |
+
// The last point of reverse path segment is start of common subsequence.
|
| 408 |
+
division.aCommonPreceding = aLast;
|
| 409 |
+
division.bCommonPreceding = bLast;
|
| 410 |
+
}
|
| 411 |
+
division.nChangeFollowing = d - 1;
|
| 412 |
+
if (d === 1) {
|
| 413 |
+
// There is no previous path segment.
|
| 414 |
+
division.nCommonFollowing = 0;
|
| 415 |
+
division.aStartFollowing = aEnd;
|
| 416 |
+
division.bStartFollowing = bEnd;
|
| 417 |
+
} else {
|
| 418 |
+
// Unlike the Myers algorithm which finds only the middle “snake”
|
| 419 |
+
// this package can find two common subsequences per division.
|
| 420 |
+
// Last point of previous path segment is on an adjacent diagonal.
|
| 421 |
+
const bLastPrev = bR + aLastPrev - (insert ? kR - 1 : kR + 1);
|
| 422 |
+
|
| 423 |
+
// Because of invariant that intervals following the middle change
|
| 424 |
+
// cannot have common items at the start,
|
| 425 |
+
// move in forward direction along a diagonal of common items.
|
| 426 |
+
const nCommonF = countCommonItemsF(
|
| 427 |
+
aLastPrev,
|
| 428 |
+
aEnd,
|
| 429 |
+
bLastPrev,
|
| 430 |
+
bEnd,
|
| 431 |
+
isCommon
|
| 432 |
+
);
|
| 433 |
+
division.nCommonFollowing = nCommonF;
|
| 434 |
+
if (nCommonF !== 0) {
|
| 435 |
+
// The last point of reverse path segment is start of common subsequence.
|
| 436 |
+
division.aCommonFollowing = aLastPrev;
|
| 437 |
+
division.bCommonFollowing = bLastPrev;
|
| 438 |
+
}
|
| 439 |
+
const aStartFollowing = aLastPrev + nCommonF; // aFirstPrev
|
| 440 |
+
const bStartFollowing = bLastPrev + nCommonF; // bFirstPrev
|
| 441 |
+
|
| 442 |
+
if (d - 1 === aEnd + bEnd - aStartFollowing - bStartFollowing) {
|
| 443 |
+
// Optimization: number of changes in forward direction
|
| 444 |
+
// is equal to number of items in following interval,
|
| 445 |
+
// therefore it cannot contain any common items.
|
| 446 |
+
division.aStartFollowing = aEnd;
|
| 447 |
+
division.bStartFollowing = bEnd;
|
| 448 |
+
} else {
|
| 449 |
+
division.aStartFollowing = aStartFollowing;
|
| 450 |
+
division.bStartFollowing = bStartFollowing;
|
| 451 |
+
}
|
| 452 |
+
}
|
| 453 |
+
return true;
|
| 454 |
+
}
|
| 455 |
+
}
|
| 456 |
+
}
|
| 457 |
+
return false;
|
| 458 |
+
};
|
| 459 |
+
|
| 460 |
+
// Given index intervals and input function to compare items at indexes,
|
| 461 |
+
// divide at the middle change.
|
| 462 |
+
//
|
| 463 |
+
// DO NOT CALL if start === end, because interval cannot contain common items
|
| 464 |
+
// and because this function will throw the “no overlap” error.
|
| 465 |
+
const divide = (
|
| 466 |
+
nChange,
|
| 467 |
+
aStart,
|
| 468 |
+
aEnd,
|
| 469 |
+
bStart,
|
| 470 |
+
bEnd,
|
| 471 |
+
isCommon,
|
| 472 |
+
aIndexesF,
|
| 473 |
+
aIndexesR,
|
| 474 |
+
division // output
|
| 475 |
+
) => {
|
| 476 |
+
const bF = bStart - aStart; // bIndex = bF + aIndex - kF
|
| 477 |
+
const bR = bEnd - aEnd; // bIndex = bR + aIndex - kR
|
| 478 |
+
const aLength = aEnd - aStart;
|
| 479 |
+
const bLength = bEnd - bStart;
|
| 480 |
+
|
| 481 |
+
// Because graph has square or portrait orientation,
|
| 482 |
+
// length difference is minimum number of items to insert from b.
|
| 483 |
+
// Corresponding forward and reverse diagonals in graph
|
| 484 |
+
// depend on length difference of the sequences:
|
| 485 |
+
// kF = kR - baDeltaLength
|
| 486 |
+
// kR = kF + baDeltaLength
|
| 487 |
+
const baDeltaLength = bLength - aLength;
|
| 488 |
+
|
| 489 |
+
// Optimization: max diagonal in graph intersects corner of shorter side.
|
| 490 |
+
let iMaxF = aLength;
|
| 491 |
+
let iMaxR = aLength;
|
| 492 |
+
|
| 493 |
+
// Initialize no changes yet in forward or reverse direction:
|
| 494 |
+
aIndexesF[0] = aStart - 1; // at open start of interval, outside closed start
|
| 495 |
+
aIndexesR[0] = aEnd; // at open end of interval
|
| 496 |
+
|
| 497 |
+
if (baDeltaLength % 2 === 0) {
|
| 498 |
+
// The number of changes in paths is 2 * d if length difference is even.
|
| 499 |
+
const dMin = (nChange || baDeltaLength) / 2;
|
| 500 |
+
const dMax = (aLength + bLength) / 2;
|
| 501 |
+
for (let d = 1; d <= dMax; d += 1) {
|
| 502 |
+
iMaxF = extendPathsF(d, aEnd, bEnd, bF, isCommon, aIndexesF, iMaxF);
|
| 503 |
+
if (d < dMin) {
|
| 504 |
+
iMaxR = extendPathsR(d, aStart, bStart, bR, isCommon, aIndexesR, iMaxR);
|
| 505 |
+
} else if (
|
| 506 |
+
// If a reverse path overlaps a forward path in the same diagonal,
|
| 507 |
+
// return a division of the index intervals at the middle change.
|
| 508 |
+
extendOverlappablePathsR(
|
| 509 |
+
d,
|
| 510 |
+
aStart,
|
| 511 |
+
aEnd,
|
| 512 |
+
bStart,
|
| 513 |
+
bEnd,
|
| 514 |
+
isCommon,
|
| 515 |
+
aIndexesF,
|
| 516 |
+
iMaxF,
|
| 517 |
+
aIndexesR,
|
| 518 |
+
iMaxR,
|
| 519 |
+
division
|
| 520 |
+
)
|
| 521 |
+
) {
|
| 522 |
+
return;
|
| 523 |
+
}
|
| 524 |
+
}
|
| 525 |
+
} else {
|
| 526 |
+
// The number of changes in paths is 2 * d - 1 if length difference is odd.
|
| 527 |
+
const dMin = ((nChange || baDeltaLength) + 1) / 2;
|
| 528 |
+
const dMax = (aLength + bLength + 1) / 2;
|
| 529 |
+
|
| 530 |
+
// Unroll first half iteration so loop extends the relevant pairs of paths.
|
| 531 |
+
// Because of invariant that intervals have no common items at start or end,
|
| 532 |
+
// and limitation not to call divide with empty intervals,
|
| 533 |
+
// therefore it cannot be called if a forward path with one change
|
| 534 |
+
// would overlap a reverse path with no changes, even if dMin === 1.
|
| 535 |
+
let d = 1;
|
| 536 |
+
iMaxF = extendPathsF(d, aEnd, bEnd, bF, isCommon, aIndexesF, iMaxF);
|
| 537 |
+
for (d += 1; d <= dMax; d += 1) {
|
| 538 |
+
iMaxR = extendPathsR(
|
| 539 |
+
d - 1,
|
| 540 |
+
aStart,
|
| 541 |
+
bStart,
|
| 542 |
+
bR,
|
| 543 |
+
isCommon,
|
| 544 |
+
aIndexesR,
|
| 545 |
+
iMaxR
|
| 546 |
+
);
|
| 547 |
+
if (d < dMin) {
|
| 548 |
+
iMaxF = extendPathsF(d, aEnd, bEnd, bF, isCommon, aIndexesF, iMaxF);
|
| 549 |
+
} else if (
|
| 550 |
+
// If a forward path overlaps a reverse path in the same diagonal,
|
| 551 |
+
// return a division of the index intervals at the middle change.
|
| 552 |
+
extendOverlappablePathsF(
|
| 553 |
+
d,
|
| 554 |
+
aStart,
|
| 555 |
+
aEnd,
|
| 556 |
+
bStart,
|
| 557 |
+
bEnd,
|
| 558 |
+
isCommon,
|
| 559 |
+
aIndexesF,
|
| 560 |
+
iMaxF,
|
| 561 |
+
aIndexesR,
|
| 562 |
+
iMaxR,
|
| 563 |
+
division
|
| 564 |
+
)
|
| 565 |
+
) {
|
| 566 |
+
return;
|
| 567 |
+
}
|
| 568 |
+
}
|
| 569 |
+
}
|
| 570 |
+
|
| 571 |
+
/* istanbul ignore next */
|
| 572 |
+
throw new Error(
|
| 573 |
+
`${pkg}: no overlap aStart=${aStart} aEnd=${aEnd} bStart=${bStart} bEnd=${bEnd}`
|
| 574 |
+
);
|
| 575 |
+
};
|
| 576 |
+
|
| 577 |
+
// Given index intervals and input function to compare items at indexes,
|
| 578 |
+
// return by output function the number of adjacent items and starting indexes
|
| 579 |
+
// of each common subsequence. Divide and conquer with only linear space.
|
| 580 |
+
//
|
| 581 |
+
// The index intervals are half open [start, end) like array slice method.
|
| 582 |
+
// DO NOT CALL if start === end, because interval cannot contain common items
|
| 583 |
+
// and because divide function will throw the “no overlap” error.
|
| 584 |
+
const findSubsequences = (
|
| 585 |
+
nChange,
|
| 586 |
+
aStart,
|
| 587 |
+
aEnd,
|
| 588 |
+
bStart,
|
| 589 |
+
bEnd,
|
| 590 |
+
transposed,
|
| 591 |
+
callbacks,
|
| 592 |
+
aIndexesF,
|
| 593 |
+
aIndexesR,
|
| 594 |
+
division // temporary memory, not input nor output
|
| 595 |
+
) => {
|
| 596 |
+
if (bEnd - bStart < aEnd - aStart) {
|
| 597 |
+
// Transpose graph so it has portrait instead of landscape orientation.
|
| 598 |
+
// Always compare shorter to longer sequence for consistency and optimization.
|
| 599 |
+
transposed = !transposed;
|
| 600 |
+
if (transposed && callbacks.length === 1) {
|
| 601 |
+
// Lazily wrap callback functions to swap args if graph is transposed.
|
| 602 |
+
const {foundSubsequence, isCommon} = callbacks[0];
|
| 603 |
+
callbacks[1] = {
|
| 604 |
+
foundSubsequence: (nCommon, bCommon, aCommon) => {
|
| 605 |
+
foundSubsequence(nCommon, aCommon, bCommon);
|
| 606 |
+
},
|
| 607 |
+
isCommon: (bIndex, aIndex) => isCommon(aIndex, bIndex)
|
| 608 |
+
};
|
| 609 |
+
}
|
| 610 |
+
const tStart = aStart;
|
| 611 |
+
const tEnd = aEnd;
|
| 612 |
+
aStart = bStart;
|
| 613 |
+
aEnd = bEnd;
|
| 614 |
+
bStart = tStart;
|
| 615 |
+
bEnd = tEnd;
|
| 616 |
+
}
|
| 617 |
+
const {foundSubsequence, isCommon} = callbacks[transposed ? 1 : 0];
|
| 618 |
+
|
| 619 |
+
// Divide the index intervals at the middle change.
|
| 620 |
+
divide(
|
| 621 |
+
nChange,
|
| 622 |
+
aStart,
|
| 623 |
+
aEnd,
|
| 624 |
+
bStart,
|
| 625 |
+
bEnd,
|
| 626 |
+
isCommon,
|
| 627 |
+
aIndexesF,
|
| 628 |
+
aIndexesR,
|
| 629 |
+
division
|
| 630 |
+
);
|
| 631 |
+
const {
|
| 632 |
+
nChangePreceding,
|
| 633 |
+
aEndPreceding,
|
| 634 |
+
bEndPreceding,
|
| 635 |
+
nCommonPreceding,
|
| 636 |
+
aCommonPreceding,
|
| 637 |
+
bCommonPreceding,
|
| 638 |
+
nCommonFollowing,
|
| 639 |
+
aCommonFollowing,
|
| 640 |
+
bCommonFollowing,
|
| 641 |
+
nChangeFollowing,
|
| 642 |
+
aStartFollowing,
|
| 643 |
+
bStartFollowing
|
| 644 |
+
} = division;
|
| 645 |
+
|
| 646 |
+
// Unless either index interval is empty, they might contain common items.
|
| 647 |
+
if (aStart < aEndPreceding && bStart < bEndPreceding) {
|
| 648 |
+
// Recursely find and return common subsequences preceding the division.
|
| 649 |
+
findSubsequences(
|
| 650 |
+
nChangePreceding,
|
| 651 |
+
aStart,
|
| 652 |
+
aEndPreceding,
|
| 653 |
+
bStart,
|
| 654 |
+
bEndPreceding,
|
| 655 |
+
transposed,
|
| 656 |
+
callbacks,
|
| 657 |
+
aIndexesF,
|
| 658 |
+
aIndexesR,
|
| 659 |
+
division
|
| 660 |
+
);
|
| 661 |
+
}
|
| 662 |
+
|
| 663 |
+
// Return common subsequences that are adjacent to the middle change.
|
| 664 |
+
if (nCommonPreceding !== 0) {
|
| 665 |
+
foundSubsequence(nCommonPreceding, aCommonPreceding, bCommonPreceding);
|
| 666 |
+
}
|
| 667 |
+
if (nCommonFollowing !== 0) {
|
| 668 |
+
foundSubsequence(nCommonFollowing, aCommonFollowing, bCommonFollowing);
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
// Unless either index interval is empty, they might contain common items.
|
| 672 |
+
if (aStartFollowing < aEnd && bStartFollowing < bEnd) {
|
| 673 |
+
// Recursely find and return common subsequences following the division.
|
| 674 |
+
findSubsequences(
|
| 675 |
+
nChangeFollowing,
|
| 676 |
+
aStartFollowing,
|
| 677 |
+
aEnd,
|
| 678 |
+
bStartFollowing,
|
| 679 |
+
bEnd,
|
| 680 |
+
transposed,
|
| 681 |
+
callbacks,
|
| 682 |
+
aIndexesF,
|
| 683 |
+
aIndexesR,
|
| 684 |
+
division
|
| 685 |
+
);
|
| 686 |
+
}
|
| 687 |
+
};
|
| 688 |
+
const validateLength = (name, arg) => {
|
| 689 |
+
if (typeof arg !== 'number') {
|
| 690 |
+
throw new TypeError(`${pkg}: ${name} typeof ${typeof arg} is not a number`);
|
| 691 |
+
}
|
| 692 |
+
if (!Number.isSafeInteger(arg)) {
|
| 693 |
+
throw new RangeError(`${pkg}: ${name} value ${arg} is not a safe integer`);
|
| 694 |
+
}
|
| 695 |
+
if (arg < 0) {
|
| 696 |
+
throw new RangeError(`${pkg}: ${name} value ${arg} is a negative integer`);
|
| 697 |
+
}
|
| 698 |
+
};
|
| 699 |
+
const validateCallback = (name, arg) => {
|
| 700 |
+
const type = typeof arg;
|
| 701 |
+
if (type !== 'function') {
|
| 702 |
+
throw new TypeError(`${pkg}: ${name} typeof ${type} is not a function`);
|
| 703 |
+
}
|
| 704 |
+
};
|
| 705 |
+
|
| 706 |
+
// Compare items in two sequences to find a longest common subsequence.
|
| 707 |
+
// Given lengths of sequences and input function to compare items at indexes,
|
| 708 |
+
// return by output function the number of adjacent items and starting indexes
|
| 709 |
+
// of each common subsequence.
|
| 710 |
+
function diffSequence(aLength, bLength, isCommon, foundSubsequence) {
|
| 711 |
+
validateLength('aLength', aLength);
|
| 712 |
+
validateLength('bLength', bLength);
|
| 713 |
+
validateCallback('isCommon', isCommon);
|
| 714 |
+
validateCallback('foundSubsequence', foundSubsequence);
|
| 715 |
+
|
| 716 |
+
// Count common items from the start in the forward direction.
|
| 717 |
+
const nCommonF = countCommonItemsF(0, aLength, 0, bLength, isCommon);
|
| 718 |
+
if (nCommonF !== 0) {
|
| 719 |
+
foundSubsequence(nCommonF, 0, 0);
|
| 720 |
+
}
|
| 721 |
+
|
| 722 |
+
// Unless both sequences consist of common items only,
|
| 723 |
+
// find common items in the half-trimmed index intervals.
|
| 724 |
+
if (aLength !== nCommonF || bLength !== nCommonF) {
|
| 725 |
+
// Invariant: intervals do not have common items at the start.
|
| 726 |
+
// The start of an index interval is closed like array slice method.
|
| 727 |
+
const aStart = nCommonF;
|
| 728 |
+
const bStart = nCommonF;
|
| 729 |
+
|
| 730 |
+
// Count common items from the end in the reverse direction.
|
| 731 |
+
const nCommonR = countCommonItemsR(
|
| 732 |
+
aStart,
|
| 733 |
+
aLength - 1,
|
| 734 |
+
bStart,
|
| 735 |
+
bLength - 1,
|
| 736 |
+
isCommon
|
| 737 |
+
);
|
| 738 |
+
|
| 739 |
+
// Invariant: intervals do not have common items at the end.
|
| 740 |
+
// The end of an index interval is open like array slice method.
|
| 741 |
+
const aEnd = aLength - nCommonR;
|
| 742 |
+
const bEnd = bLength - nCommonR;
|
| 743 |
+
|
| 744 |
+
// Unless one sequence consists of common items only,
|
| 745 |
+
// therefore the other trimmed index interval consists of changes only,
|
| 746 |
+
// find common items in the trimmed index intervals.
|
| 747 |
+
const nCommonFR = nCommonF + nCommonR;
|
| 748 |
+
if (aLength !== nCommonFR && bLength !== nCommonFR) {
|
| 749 |
+
const nChange = 0; // number of change items is not yet known
|
| 750 |
+
const transposed = false; // call the original unwrapped functions
|
| 751 |
+
const callbacks = [
|
| 752 |
+
{
|
| 753 |
+
foundSubsequence,
|
| 754 |
+
isCommon
|
| 755 |
+
}
|
| 756 |
+
];
|
| 757 |
+
|
| 758 |
+
// Indexes in sequence a of last points in furthest reaching paths
|
| 759 |
+
// from outside the start at top left in the forward direction:
|
| 760 |
+
const aIndexesF = [NOT_YET_SET];
|
| 761 |
+
// from the end at bottom right in the reverse direction:
|
| 762 |
+
const aIndexesR = [NOT_YET_SET];
|
| 763 |
+
|
| 764 |
+
// Initialize one object as output of all calls to divide function.
|
| 765 |
+
const division = {
|
| 766 |
+
aCommonFollowing: NOT_YET_SET,
|
| 767 |
+
aCommonPreceding: NOT_YET_SET,
|
| 768 |
+
aEndPreceding: NOT_YET_SET,
|
| 769 |
+
aStartFollowing: NOT_YET_SET,
|
| 770 |
+
bCommonFollowing: NOT_YET_SET,
|
| 771 |
+
bCommonPreceding: NOT_YET_SET,
|
| 772 |
+
bEndPreceding: NOT_YET_SET,
|
| 773 |
+
bStartFollowing: NOT_YET_SET,
|
| 774 |
+
nChangeFollowing: NOT_YET_SET,
|
| 775 |
+
nChangePreceding: NOT_YET_SET,
|
| 776 |
+
nCommonFollowing: NOT_YET_SET,
|
| 777 |
+
nCommonPreceding: NOT_YET_SET
|
| 778 |
+
};
|
| 779 |
+
|
| 780 |
+
// Find and return common subsequences in the trimmed index intervals.
|
| 781 |
+
findSubsequences(
|
| 782 |
+
nChange,
|
| 783 |
+
aStart,
|
| 784 |
+
aEnd,
|
| 785 |
+
bStart,
|
| 786 |
+
bEnd,
|
| 787 |
+
transposed,
|
| 788 |
+
callbacks,
|
| 789 |
+
aIndexesF,
|
| 790 |
+
aIndexesR,
|
| 791 |
+
division
|
| 792 |
+
);
|
| 793 |
+
}
|
| 794 |
+
if (nCommonR !== 0) {
|
| 795 |
+
foundSubsequence(nCommonR, aEnd, bEnd);
|
| 796 |
+
}
|
| 797 |
+
}
|
| 798 |
+
}
|
novas/novacore-zephyr/claude-code-router/node_modules/expect/build/asymmetricMatchers.js
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.closeTo =
|
| 7 |
+
exports.arrayNotContaining =
|
| 8 |
+
exports.arrayContaining =
|
| 9 |
+
exports.anything =
|
| 10 |
+
exports.any =
|
| 11 |
+
exports.AsymmetricMatcher =
|
| 12 |
+
void 0;
|
| 13 |
+
exports.hasProperty = hasProperty;
|
| 14 |
+
exports.stringNotMatching =
|
| 15 |
+
exports.stringNotContaining =
|
| 16 |
+
exports.stringMatching =
|
| 17 |
+
exports.stringContaining =
|
| 18 |
+
exports.objectNotContaining =
|
| 19 |
+
exports.objectContaining =
|
| 20 |
+
exports.notCloseTo =
|
| 21 |
+
void 0;
|
| 22 |
+
var _expectUtils = require('@jest/expect-utils');
|
| 23 |
+
var matcherUtils = _interopRequireWildcard(require('jest-matcher-utils'));
|
| 24 |
+
var _jestUtil = require('jest-util');
|
| 25 |
+
var _jestMatchersObject = require('./jestMatchersObject');
|
| 26 |
+
function _getRequireWildcardCache(nodeInterop) {
|
| 27 |
+
if (typeof WeakMap !== 'function') return null;
|
| 28 |
+
var cacheBabelInterop = new WeakMap();
|
| 29 |
+
var cacheNodeInterop = new WeakMap();
|
| 30 |
+
return (_getRequireWildcardCache = function (nodeInterop) {
|
| 31 |
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
| 32 |
+
})(nodeInterop);
|
| 33 |
+
}
|
| 34 |
+
function _interopRequireWildcard(obj, nodeInterop) {
|
| 35 |
+
if (!nodeInterop && obj && obj.__esModule) {
|
| 36 |
+
return obj;
|
| 37 |
+
}
|
| 38 |
+
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
| 39 |
+
return {default: obj};
|
| 40 |
+
}
|
| 41 |
+
var cache = _getRequireWildcardCache(nodeInterop);
|
| 42 |
+
if (cache && cache.has(obj)) {
|
| 43 |
+
return cache.get(obj);
|
| 44 |
+
}
|
| 45 |
+
var newObj = {};
|
| 46 |
+
var hasPropertyDescriptor =
|
| 47 |
+
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
| 48 |
+
for (var key in obj) {
|
| 49 |
+
if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
|
| 50 |
+
var desc = hasPropertyDescriptor
|
| 51 |
+
? Object.getOwnPropertyDescriptor(obj, key)
|
| 52 |
+
: null;
|
| 53 |
+
if (desc && (desc.get || desc.set)) {
|
| 54 |
+
Object.defineProperty(newObj, key, desc);
|
| 55 |
+
} else {
|
| 56 |
+
newObj[key] = obj[key];
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
newObj.default = obj;
|
| 61 |
+
if (cache) {
|
| 62 |
+
cache.set(obj, newObj);
|
| 63 |
+
}
|
| 64 |
+
return newObj;
|
| 65 |
+
}
|
| 66 |
+
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
|
| 67 |
+
/**
|
| 68 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 69 |
+
*
|
| 70 |
+
* This source code is licensed under the MIT license found in the
|
| 71 |
+
* LICENSE file in the root directory of this source tree.
|
| 72 |
+
*
|
| 73 |
+
*/
|
| 74 |
+
const functionToString = Function.prototype.toString;
|
| 75 |
+
function fnNameFor(func) {
|
| 76 |
+
if (func.name) {
|
| 77 |
+
return func.name;
|
| 78 |
+
}
|
| 79 |
+
const matches = functionToString
|
| 80 |
+
.call(func)
|
| 81 |
+
.match(/^(?:async)?\s*function\s*\*?\s*([\w$]+)\s*\(/);
|
| 82 |
+
return matches ? matches[1] : '<anonymous>';
|
| 83 |
+
}
|
| 84 |
+
const utils = Object.freeze({
|
| 85 |
+
...matcherUtils,
|
| 86 |
+
iterableEquality: _expectUtils.iterableEquality,
|
| 87 |
+
subsetEquality: _expectUtils.subsetEquality
|
| 88 |
+
});
|
| 89 |
+
function getPrototype(obj) {
|
| 90 |
+
if (Object.getPrototypeOf) {
|
| 91 |
+
return Object.getPrototypeOf(obj);
|
| 92 |
+
}
|
| 93 |
+
if (obj.constructor.prototype == obj) {
|
| 94 |
+
return null;
|
| 95 |
+
}
|
| 96 |
+
return obj.constructor.prototype;
|
| 97 |
+
}
|
| 98 |
+
function hasProperty(obj, property) {
|
| 99 |
+
if (!obj) {
|
| 100 |
+
return false;
|
| 101 |
+
}
|
| 102 |
+
if (Object.prototype.hasOwnProperty.call(obj, property)) {
|
| 103 |
+
return true;
|
| 104 |
+
}
|
| 105 |
+
return hasProperty(getPrototype(obj), property);
|
| 106 |
+
}
|
| 107 |
+
class AsymmetricMatcher {
|
| 108 |
+
$$typeof = Symbol.for('jest.asymmetricMatcher');
|
| 109 |
+
constructor(sample, inverse = false) {
|
| 110 |
+
this.sample = sample;
|
| 111 |
+
this.inverse = inverse;
|
| 112 |
+
}
|
| 113 |
+
getMatcherContext() {
|
| 114 |
+
return {
|
| 115 |
+
customTesters: (0, _jestMatchersObject.getCustomEqualityTesters)(),
|
| 116 |
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
| 117 |
+
dontThrow: () => {},
|
| 118 |
+
...(0, _jestMatchersObject.getState)(),
|
| 119 |
+
equals: _expectUtils.equals,
|
| 120 |
+
isNot: this.inverse,
|
| 121 |
+
utils
|
| 122 |
+
};
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
exports.AsymmetricMatcher = AsymmetricMatcher;
|
| 126 |
+
class Any extends AsymmetricMatcher {
|
| 127 |
+
constructor(sample) {
|
| 128 |
+
if (typeof sample === 'undefined') {
|
| 129 |
+
throw new TypeError(
|
| 130 |
+
'any() expects to be passed a constructor function. ' +
|
| 131 |
+
'Please pass one or use anything() to match any object.'
|
| 132 |
+
);
|
| 133 |
+
}
|
| 134 |
+
super(sample);
|
| 135 |
+
}
|
| 136 |
+
asymmetricMatch(other) {
|
| 137 |
+
if (this.sample == String) {
|
| 138 |
+
return typeof other == 'string' || other instanceof String;
|
| 139 |
+
}
|
| 140 |
+
if (this.sample == Number) {
|
| 141 |
+
return typeof other == 'number' || other instanceof Number;
|
| 142 |
+
}
|
| 143 |
+
if (this.sample == Function) {
|
| 144 |
+
return typeof other == 'function' || other instanceof Function;
|
| 145 |
+
}
|
| 146 |
+
if (this.sample == Boolean) {
|
| 147 |
+
return typeof other == 'boolean' || other instanceof Boolean;
|
| 148 |
+
}
|
| 149 |
+
if (this.sample == BigInt) {
|
| 150 |
+
return typeof other == 'bigint' || other instanceof BigInt;
|
| 151 |
+
}
|
| 152 |
+
if (this.sample == Symbol) {
|
| 153 |
+
return typeof other == 'symbol' || other instanceof Symbol;
|
| 154 |
+
}
|
| 155 |
+
if (this.sample == Object) {
|
| 156 |
+
return typeof other == 'object';
|
| 157 |
+
}
|
| 158 |
+
return other instanceof this.sample;
|
| 159 |
+
}
|
| 160 |
+
toString() {
|
| 161 |
+
return 'Any';
|
| 162 |
+
}
|
| 163 |
+
getExpectedType() {
|
| 164 |
+
if (this.sample == String) {
|
| 165 |
+
return 'string';
|
| 166 |
+
}
|
| 167 |
+
if (this.sample == Number) {
|
| 168 |
+
return 'number';
|
| 169 |
+
}
|
| 170 |
+
if (this.sample == Function) {
|
| 171 |
+
return 'function';
|
| 172 |
+
}
|
| 173 |
+
if (this.sample == Object) {
|
| 174 |
+
return 'object';
|
| 175 |
+
}
|
| 176 |
+
if (this.sample == Boolean) {
|
| 177 |
+
return 'boolean';
|
| 178 |
+
}
|
| 179 |
+
return fnNameFor(this.sample);
|
| 180 |
+
}
|
| 181 |
+
toAsymmetricMatcher() {
|
| 182 |
+
return `Any<${fnNameFor(this.sample)}>`;
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
class Anything extends AsymmetricMatcher {
|
| 186 |
+
asymmetricMatch(other) {
|
| 187 |
+
return other != null;
|
| 188 |
+
}
|
| 189 |
+
toString() {
|
| 190 |
+
return 'Anything';
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
// No getExpectedType method, because it matches either null or undefined.
|
| 194 |
+
|
| 195 |
+
toAsymmetricMatcher() {
|
| 196 |
+
return 'Anything';
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
class ArrayContaining extends AsymmetricMatcher {
|
| 200 |
+
constructor(sample, inverse = false) {
|
| 201 |
+
super(sample, inverse);
|
| 202 |
+
}
|
| 203 |
+
asymmetricMatch(other) {
|
| 204 |
+
if (!Array.isArray(this.sample)) {
|
| 205 |
+
throw new Error(
|
| 206 |
+
`You must provide an array to ${this.toString()}, not '${typeof this
|
| 207 |
+
.sample}'.`
|
| 208 |
+
);
|
| 209 |
+
}
|
| 210 |
+
const matcherContext = this.getMatcherContext();
|
| 211 |
+
const result =
|
| 212 |
+
this.sample.length === 0 ||
|
| 213 |
+
(Array.isArray(other) &&
|
| 214 |
+
this.sample.every(item =>
|
| 215 |
+
other.some(another =>
|
| 216 |
+
(0, _expectUtils.equals)(
|
| 217 |
+
item,
|
| 218 |
+
another,
|
| 219 |
+
matcherContext.customTesters
|
| 220 |
+
)
|
| 221 |
+
)
|
| 222 |
+
));
|
| 223 |
+
return this.inverse ? !result : result;
|
| 224 |
+
}
|
| 225 |
+
toString() {
|
| 226 |
+
return `Array${this.inverse ? 'Not' : ''}Containing`;
|
| 227 |
+
}
|
| 228 |
+
getExpectedType() {
|
| 229 |
+
return 'array';
|
| 230 |
+
}
|
| 231 |
+
}
|
| 232 |
+
class ObjectContaining extends AsymmetricMatcher {
|
| 233 |
+
constructor(sample, inverse = false) {
|
| 234 |
+
super(sample, inverse);
|
| 235 |
+
}
|
| 236 |
+
asymmetricMatch(other) {
|
| 237 |
+
if (typeof this.sample !== 'object') {
|
| 238 |
+
throw new Error(
|
| 239 |
+
`You must provide an object to ${this.toString()}, not '${typeof this
|
| 240 |
+
.sample}'.`
|
| 241 |
+
);
|
| 242 |
+
}
|
| 243 |
+
let result = true;
|
| 244 |
+
const matcherContext = this.getMatcherContext();
|
| 245 |
+
const objectKeys = (0, _expectUtils.getObjectKeys)(this.sample);
|
| 246 |
+
for (const key of objectKeys) {
|
| 247 |
+
if (
|
| 248 |
+
!hasProperty(other, key) ||
|
| 249 |
+
!(0, _expectUtils.equals)(
|
| 250 |
+
this.sample[key],
|
| 251 |
+
other[key],
|
| 252 |
+
matcherContext.customTesters
|
| 253 |
+
)
|
| 254 |
+
) {
|
| 255 |
+
result = false;
|
| 256 |
+
break;
|
| 257 |
+
}
|
| 258 |
+
}
|
| 259 |
+
return this.inverse ? !result : result;
|
| 260 |
+
}
|
| 261 |
+
toString() {
|
| 262 |
+
return `Object${this.inverse ? 'Not' : ''}Containing`;
|
| 263 |
+
}
|
| 264 |
+
getExpectedType() {
|
| 265 |
+
return 'object';
|
| 266 |
+
}
|
| 267 |
+
}
|
| 268 |
+
class StringContaining extends AsymmetricMatcher {
|
| 269 |
+
constructor(sample, inverse = false) {
|
| 270 |
+
if (!(0, _expectUtils.isA)('String', sample)) {
|
| 271 |
+
throw new Error('Expected is not a string');
|
| 272 |
+
}
|
| 273 |
+
super(sample, inverse);
|
| 274 |
+
}
|
| 275 |
+
asymmetricMatch(other) {
|
| 276 |
+
const result =
|
| 277 |
+
(0, _expectUtils.isA)('String', other) && other.includes(this.sample);
|
| 278 |
+
return this.inverse ? !result : result;
|
| 279 |
+
}
|
| 280 |
+
toString() {
|
| 281 |
+
return `String${this.inverse ? 'Not' : ''}Containing`;
|
| 282 |
+
}
|
| 283 |
+
getExpectedType() {
|
| 284 |
+
return 'string';
|
| 285 |
+
}
|
| 286 |
+
}
|
| 287 |
+
class StringMatching extends AsymmetricMatcher {
|
| 288 |
+
constructor(sample, inverse = false) {
|
| 289 |
+
if (
|
| 290 |
+
!(0, _expectUtils.isA)('String', sample) &&
|
| 291 |
+
!(0, _expectUtils.isA)('RegExp', sample)
|
| 292 |
+
) {
|
| 293 |
+
throw new Error('Expected is not a String or a RegExp');
|
| 294 |
+
}
|
| 295 |
+
super(new RegExp(sample), inverse);
|
| 296 |
+
}
|
| 297 |
+
asymmetricMatch(other) {
|
| 298 |
+
const result =
|
| 299 |
+
(0, _expectUtils.isA)('String', other) && this.sample.test(other);
|
| 300 |
+
return this.inverse ? !result : result;
|
| 301 |
+
}
|
| 302 |
+
toString() {
|
| 303 |
+
return `String${this.inverse ? 'Not' : ''}Matching`;
|
| 304 |
+
}
|
| 305 |
+
getExpectedType() {
|
| 306 |
+
return 'string';
|
| 307 |
+
}
|
| 308 |
+
}
|
| 309 |
+
class CloseTo extends AsymmetricMatcher {
|
| 310 |
+
precision;
|
| 311 |
+
constructor(sample, precision = 2, inverse = false) {
|
| 312 |
+
if (!(0, _expectUtils.isA)('Number', sample)) {
|
| 313 |
+
throw new Error('Expected is not a Number');
|
| 314 |
+
}
|
| 315 |
+
if (!(0, _expectUtils.isA)('Number', precision)) {
|
| 316 |
+
throw new Error('Precision is not a Number');
|
| 317 |
+
}
|
| 318 |
+
super(sample);
|
| 319 |
+
this.inverse = inverse;
|
| 320 |
+
this.precision = precision;
|
| 321 |
+
}
|
| 322 |
+
asymmetricMatch(other) {
|
| 323 |
+
if (!(0, _expectUtils.isA)('Number', other)) {
|
| 324 |
+
return false;
|
| 325 |
+
}
|
| 326 |
+
let result = false;
|
| 327 |
+
if (other === Infinity && this.sample === Infinity) {
|
| 328 |
+
result = true; // Infinity - Infinity is NaN
|
| 329 |
+
} else if (other === -Infinity && this.sample === -Infinity) {
|
| 330 |
+
result = true; // -Infinity - -Infinity is NaN
|
| 331 |
+
} else {
|
| 332 |
+
result =
|
| 333 |
+
Math.abs(this.sample - other) < Math.pow(10, -this.precision) / 2;
|
| 334 |
+
}
|
| 335 |
+
return this.inverse ? !result : result;
|
| 336 |
+
}
|
| 337 |
+
toString() {
|
| 338 |
+
return `Number${this.inverse ? 'Not' : ''}CloseTo`;
|
| 339 |
+
}
|
| 340 |
+
getExpectedType() {
|
| 341 |
+
return 'number';
|
| 342 |
+
}
|
| 343 |
+
toAsymmetricMatcher() {
|
| 344 |
+
return [
|
| 345 |
+
this.toString(),
|
| 346 |
+
this.sample,
|
| 347 |
+
`(${(0, _jestUtil.pluralize)('digit', this.precision)})`
|
| 348 |
+
].join(' ');
|
| 349 |
+
}
|
| 350 |
+
}
|
| 351 |
+
const any = expectedObject => new Any(expectedObject);
|
| 352 |
+
exports.any = any;
|
| 353 |
+
const anything = () => new Anything();
|
| 354 |
+
exports.anything = anything;
|
| 355 |
+
const arrayContaining = sample => new ArrayContaining(sample);
|
| 356 |
+
exports.arrayContaining = arrayContaining;
|
| 357 |
+
const arrayNotContaining = sample => new ArrayContaining(sample, true);
|
| 358 |
+
exports.arrayNotContaining = arrayNotContaining;
|
| 359 |
+
const objectContaining = sample => new ObjectContaining(sample);
|
| 360 |
+
exports.objectContaining = objectContaining;
|
| 361 |
+
const objectNotContaining = sample => new ObjectContaining(sample, true);
|
| 362 |
+
exports.objectNotContaining = objectNotContaining;
|
| 363 |
+
const stringContaining = expected => new StringContaining(expected);
|
| 364 |
+
exports.stringContaining = stringContaining;
|
| 365 |
+
const stringNotContaining = expected => new StringContaining(expected, true);
|
| 366 |
+
exports.stringNotContaining = stringNotContaining;
|
| 367 |
+
const stringMatching = expected => new StringMatching(expected);
|
| 368 |
+
exports.stringMatching = stringMatching;
|
| 369 |
+
const stringNotMatching = expected => new StringMatching(expected, true);
|
| 370 |
+
exports.stringNotMatching = stringNotMatching;
|
| 371 |
+
const closeTo = (expected, precision) => new CloseTo(expected, precision);
|
| 372 |
+
exports.closeTo = closeTo;
|
| 373 |
+
const notCloseTo = (expected, precision) =>
|
| 374 |
+
new CloseTo(expected, precision, true);
|
| 375 |
+
exports.notCloseTo = notCloseTo;
|
novas/novacore-zephyr/claude-code-router/node_modules/expect/build/extractExpectedAssertionsErrors.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = void 0;
|
| 7 |
+
var _jestMatcherUtils = require('jest-matcher-utils');
|
| 8 |
+
var _jestMatchersObject = require('./jestMatchersObject');
|
| 9 |
+
/**
|
| 10 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 11 |
+
*
|
| 12 |
+
* This source code is licensed under the MIT license found in the
|
| 13 |
+
* LICENSE file in the root directory of this source tree.
|
| 14 |
+
*
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
const resetAssertionsLocalState = () => {
|
| 18 |
+
(0, _jestMatchersObject.setState)({
|
| 19 |
+
assertionCalls: 0,
|
| 20 |
+
expectedAssertionsNumber: null,
|
| 21 |
+
isExpectingAssertions: false,
|
| 22 |
+
numPassingAsserts: 0
|
| 23 |
+
});
|
| 24 |
+
};
|
| 25 |
+
|
| 26 |
+
// Create and format all errors related to the mismatched number of `expect`
|
| 27 |
+
// calls and reset the matcher's state.
|
| 28 |
+
const extractExpectedAssertionsErrors = () => {
|
| 29 |
+
const result = [];
|
| 30 |
+
const {
|
| 31 |
+
assertionCalls,
|
| 32 |
+
expectedAssertionsNumber,
|
| 33 |
+
expectedAssertionsNumberError,
|
| 34 |
+
isExpectingAssertions,
|
| 35 |
+
isExpectingAssertionsError
|
| 36 |
+
} = (0, _jestMatchersObject.getState)();
|
| 37 |
+
resetAssertionsLocalState();
|
| 38 |
+
if (
|
| 39 |
+
typeof expectedAssertionsNumber === 'number' &&
|
| 40 |
+
assertionCalls !== expectedAssertionsNumber
|
| 41 |
+
) {
|
| 42 |
+
const numOfAssertionsExpected = (0, _jestMatcherUtils.EXPECTED_COLOR)(
|
| 43 |
+
(0, _jestMatcherUtils.pluralize)('assertion', expectedAssertionsNumber)
|
| 44 |
+
);
|
| 45 |
+
expectedAssertionsNumberError.message =
|
| 46 |
+
`${(0, _jestMatcherUtils.matcherHint)(
|
| 47 |
+
'.assertions',
|
| 48 |
+
'',
|
| 49 |
+
expectedAssertionsNumber.toString(),
|
| 50 |
+
{
|
| 51 |
+
isDirectExpectCall: true
|
| 52 |
+
}
|
| 53 |
+
)}\n\n` +
|
| 54 |
+
`Expected ${numOfAssertionsExpected} to be called but received ${(0,
|
| 55 |
+
_jestMatcherUtils.RECEIVED_COLOR)(
|
| 56 |
+
(0, _jestMatcherUtils.pluralize)('assertion call', assertionCalls || 0)
|
| 57 |
+
)}.`;
|
| 58 |
+
result.push({
|
| 59 |
+
actual: assertionCalls.toString(),
|
| 60 |
+
error: expectedAssertionsNumberError,
|
| 61 |
+
expected: expectedAssertionsNumber.toString()
|
| 62 |
+
});
|
| 63 |
+
}
|
| 64 |
+
if (isExpectingAssertions && assertionCalls === 0) {
|
| 65 |
+
const expected = (0, _jestMatcherUtils.EXPECTED_COLOR)(
|
| 66 |
+
'at least one assertion'
|
| 67 |
+
);
|
| 68 |
+
const received = (0, _jestMatcherUtils.RECEIVED_COLOR)('received none');
|
| 69 |
+
isExpectingAssertionsError.message = `${(0, _jestMatcherUtils.matcherHint)(
|
| 70 |
+
'.hasAssertions',
|
| 71 |
+
'',
|
| 72 |
+
'',
|
| 73 |
+
{
|
| 74 |
+
isDirectExpectCall: true
|
| 75 |
+
}
|
| 76 |
+
)}\n\nExpected ${expected} to be called but ${received}.`;
|
| 77 |
+
result.push({
|
| 78 |
+
actual: 'none',
|
| 79 |
+
error: isExpectingAssertionsError,
|
| 80 |
+
expected: 'at least one'
|
| 81 |
+
});
|
| 82 |
+
}
|
| 83 |
+
return result;
|
| 84 |
+
};
|
| 85 |
+
var _default = extractExpectedAssertionsErrors;
|
| 86 |
+
exports.default = _default;
|
novas/novacore-zephyr/claude-code-router/node_modules/expect/build/index.d.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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 3 |
+
*
|
| 4 |
+
* This source code is licensed under the MIT license found in the
|
| 5 |
+
* LICENSE file in the root directory of this source tree.
|
| 6 |
+
*/
|
| 7 |
+
import type {EqualsFunction} from '@jest/expect-utils';
|
| 8 |
+
import type * as jestMatcherUtils from 'jest-matcher-utils';
|
| 9 |
+
import {Tester} from '@jest/expect-utils';
|
| 10 |
+
import {TesterContext} from '@jest/expect-utils';
|
| 11 |
+
|
| 12 |
+
export declare abstract class AsymmetricMatcher<T>
|
| 13 |
+
implements AsymmetricMatcher_2
|
| 14 |
+
{
|
| 15 |
+
protected sample: T;
|
| 16 |
+
protected inverse: boolean;
|
| 17 |
+
$$typeof: symbol;
|
| 18 |
+
constructor(sample: T, inverse?: boolean);
|
| 19 |
+
protected getMatcherContext(): MatcherContext;
|
| 20 |
+
abstract asymmetricMatch(other: unknown): boolean;
|
| 21 |
+
abstract toString(): string;
|
| 22 |
+
getExpectedType?(): string;
|
| 23 |
+
toAsymmetricMatcher?(): string;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
declare type AsymmetricMatcher_2 = {
|
| 27 |
+
asymmetricMatch(other: unknown): boolean;
|
| 28 |
+
toString(): string;
|
| 29 |
+
getExpectedType?(): string;
|
| 30 |
+
toAsymmetricMatcher?(): string;
|
| 31 |
+
};
|
| 32 |
+
|
| 33 |
+
export declare interface AsymmetricMatchers {
|
| 34 |
+
any(sample: unknown): AsymmetricMatcher_2;
|
| 35 |
+
anything(): AsymmetricMatcher_2;
|
| 36 |
+
arrayContaining(sample: Array<unknown>): AsymmetricMatcher_2;
|
| 37 |
+
closeTo(sample: number, precision?: number): AsymmetricMatcher_2;
|
| 38 |
+
objectContaining(sample: Record<string, unknown>): AsymmetricMatcher_2;
|
| 39 |
+
stringContaining(sample: string): AsymmetricMatcher_2;
|
| 40 |
+
stringMatching(sample: string | RegExp): AsymmetricMatcher_2;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
export declare type AsyncExpectationResult = Promise<SyncExpectationResult>;
|
| 44 |
+
|
| 45 |
+
export declare interface BaseExpect {
|
| 46 |
+
assertions(numberOfAssertions: number): void;
|
| 47 |
+
addEqualityTesters(testers: Array<Tester>): void;
|
| 48 |
+
extend(matchers: MatchersObject): void;
|
| 49 |
+
extractExpectedAssertionsErrors(): ExpectedAssertionsErrors;
|
| 50 |
+
getState(): MatcherState;
|
| 51 |
+
hasAssertions(): void;
|
| 52 |
+
setState(state: Partial<MatcherState>): void;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
export declare type Expect = {
|
| 56 |
+
<T = unknown>(actual: T): Matchers<void, T> &
|
| 57 |
+
Inverse<Matchers<void, T>> &
|
| 58 |
+
PromiseMatchers<T>;
|
| 59 |
+
} & BaseExpect &
|
| 60 |
+
AsymmetricMatchers &
|
| 61 |
+
Inverse<Omit<AsymmetricMatchers, 'any' | 'anything'>>;
|
| 62 |
+
|
| 63 |
+
declare const expect: Expect;
|
| 64 |
+
export default expect;
|
| 65 |
+
export {expect};
|
| 66 |
+
|
| 67 |
+
export declare type ExpectationResult =
|
| 68 |
+
| SyncExpectationResult
|
| 69 |
+
| AsyncExpectationResult;
|
| 70 |
+
|
| 71 |
+
declare type ExpectedAssertionsErrors = Array<{
|
| 72 |
+
actual: string | number;
|
| 73 |
+
error: Error;
|
| 74 |
+
expected: string;
|
| 75 |
+
}>;
|
| 76 |
+
|
| 77 |
+
declare type Inverse<Matchers> = {
|
| 78 |
+
/**
|
| 79 |
+
* Inverse next matcher. If you know how to test something, `.not` lets you test its opposite.
|
| 80 |
+
*/
|
| 81 |
+
not: Matchers;
|
| 82 |
+
};
|
| 83 |
+
|
| 84 |
+
export declare class JestAssertionError extends Error {
|
| 85 |
+
matcherResult?: Omit<SyncExpectationResult, 'message'> & {
|
| 86 |
+
message: string;
|
| 87 |
+
};
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
export declare type MatcherContext = MatcherUtils & Readonly<MatcherState>;
|
| 91 |
+
|
| 92 |
+
export declare type MatcherFunction<Expected extends Array<unknown> = []> =
|
| 93 |
+
MatcherFunctionWithContext<MatcherContext, Expected>;
|
| 94 |
+
|
| 95 |
+
export declare type MatcherFunctionWithContext<
|
| 96 |
+
Context extends MatcherContext = MatcherContext,
|
| 97 |
+
Expected extends Array<any> = [] /** TODO should be: extends Array<unknown> = [] */,
|
| 98 |
+
> = (
|
| 99 |
+
this: Context,
|
| 100 |
+
actual: unknown,
|
| 101 |
+
...expected: Expected
|
| 102 |
+
) => ExpectationResult;
|
| 103 |
+
|
| 104 |
+
export declare interface Matchers<R extends void | Promise<void>, T = unknown> {
|
| 105 |
+
/**
|
| 106 |
+
* Ensures the last call to a mock function was provided specific args.
|
| 107 |
+
*/
|
| 108 |
+
lastCalledWith(...expected: Array<unknown>): R;
|
| 109 |
+
/**
|
| 110 |
+
* Ensure that the last call to a mock function has returned a specified value.
|
| 111 |
+
*/
|
| 112 |
+
lastReturnedWith(expected?: unknown): R;
|
| 113 |
+
/**
|
| 114 |
+
* Ensure that a mock function is called with specific arguments on an Nth call.
|
| 115 |
+
*/
|
| 116 |
+
nthCalledWith(nth: number, ...expected: Array<unknown>): R;
|
| 117 |
+
/**
|
| 118 |
+
* Ensure that the nth call to a mock function has returned a specified value.
|
| 119 |
+
*/
|
| 120 |
+
nthReturnedWith(nth: number, expected?: unknown): R;
|
| 121 |
+
/**
|
| 122 |
+
* Checks that a value is what you expect. It calls `Object.is` to compare values.
|
| 123 |
+
* Don't use `toBe` with floating-point numbers.
|
| 124 |
+
*/
|
| 125 |
+
toBe(expected: unknown): R;
|
| 126 |
+
/**
|
| 127 |
+
* Ensures that a mock function is called.
|
| 128 |
+
*/
|
| 129 |
+
toBeCalled(): R;
|
| 130 |
+
/**
|
| 131 |
+
* Ensures that a mock function is called an exact number of times.
|
| 132 |
+
*/
|
| 133 |
+
toBeCalledTimes(expected: number): R;
|
| 134 |
+
/**
|
| 135 |
+
* Ensure that a mock function is called with specific arguments.
|
| 136 |
+
*/
|
| 137 |
+
toBeCalledWith(...expected: Array<unknown>): R;
|
| 138 |
+
/**
|
| 139 |
+
* Using exact equality with floating point numbers is a bad idea.
|
| 140 |
+
* Rounding means that intuitive things fail.
|
| 141 |
+
* The default for `precision` is 2.
|
| 142 |
+
*/
|
| 143 |
+
toBeCloseTo(expected: number, precision?: number): R;
|
| 144 |
+
/**
|
| 145 |
+
* Ensure that a variable is not undefined.
|
| 146 |
+
*/
|
| 147 |
+
toBeDefined(): R;
|
| 148 |
+
/**
|
| 149 |
+
* When you don't care what a value is, you just want to
|
| 150 |
+
* ensure a value is false in a boolean context.
|
| 151 |
+
*/
|
| 152 |
+
toBeFalsy(): R;
|
| 153 |
+
/**
|
| 154 |
+
* For comparing floating point numbers.
|
| 155 |
+
*/
|
| 156 |
+
toBeGreaterThan(expected: number | bigint): R;
|
| 157 |
+
/**
|
| 158 |
+
* For comparing floating point numbers.
|
| 159 |
+
*/
|
| 160 |
+
toBeGreaterThanOrEqual(expected: number | bigint): R;
|
| 161 |
+
/**
|
| 162 |
+
* Ensure that an object is an instance of a class.
|
| 163 |
+
* This matcher uses `instanceof` underneath.
|
| 164 |
+
*/
|
| 165 |
+
toBeInstanceOf(expected: unknown): R;
|
| 166 |
+
/**
|
| 167 |
+
* For comparing floating point numbers.
|
| 168 |
+
*/
|
| 169 |
+
toBeLessThan(expected: number | bigint): R;
|
| 170 |
+
/**
|
| 171 |
+
* For comparing floating point numbers.
|
| 172 |
+
*/
|
| 173 |
+
toBeLessThanOrEqual(expected: number | bigint): R;
|
| 174 |
+
/**
|
| 175 |
+
* Used to check that a variable is NaN.
|
| 176 |
+
*/
|
| 177 |
+
toBeNaN(): R;
|
| 178 |
+
/**
|
| 179 |
+
* This is the same as `.toBe(null)` but the error messages are a bit nicer.
|
| 180 |
+
* So use `.toBeNull()` when you want to check that something is null.
|
| 181 |
+
*/
|
| 182 |
+
toBeNull(): R;
|
| 183 |
+
/**
|
| 184 |
+
* Use when you don't care what a value is, you just want to ensure a value
|
| 185 |
+
* is true in a boolean context. In JavaScript, there are six falsy values:
|
| 186 |
+
* `false`, `0`, `''`, `null`, `undefined`, and `NaN`. Everything else is truthy.
|
| 187 |
+
*/
|
| 188 |
+
toBeTruthy(): R;
|
| 189 |
+
/**
|
| 190 |
+
* Used to check that a variable is undefined.
|
| 191 |
+
*/
|
| 192 |
+
toBeUndefined(): R;
|
| 193 |
+
/**
|
| 194 |
+
* Used when you want to check that an item is in a list.
|
| 195 |
+
* For testing the items in the list, this uses `===`, a strict equality check.
|
| 196 |
+
*/
|
| 197 |
+
toContain(expected: unknown): R;
|
| 198 |
+
/**
|
| 199 |
+
* Used when you want to check that an item is in a list.
|
| 200 |
+
* For testing the items in the list, this matcher recursively checks the
|
| 201 |
+
* equality of all fields, rather than checking for object identity.
|
| 202 |
+
*/
|
| 203 |
+
toContainEqual(expected: unknown): R;
|
| 204 |
+
/**
|
| 205 |
+
* Used when you want to check that two objects have the same value.
|
| 206 |
+
* This matcher recursively checks the equality of all fields, rather than checking for object identity.
|
| 207 |
+
*/
|
| 208 |
+
toEqual(expected: unknown): R;
|
| 209 |
+
/**
|
| 210 |
+
* Ensures that a mock function is called.
|
| 211 |
+
*/
|
| 212 |
+
toHaveBeenCalled(): R;
|
| 213 |
+
/**
|
| 214 |
+
* Ensures that a mock function is called an exact number of times.
|
| 215 |
+
*/
|
| 216 |
+
toHaveBeenCalledTimes(expected: number): R;
|
| 217 |
+
/**
|
| 218 |
+
* Ensure that a mock function is called with specific arguments.
|
| 219 |
+
*/
|
| 220 |
+
toHaveBeenCalledWith(...expected: Array<unknown>): R;
|
| 221 |
+
/**
|
| 222 |
+
* Ensure that a mock function is called with specific arguments on an Nth call.
|
| 223 |
+
*/
|
| 224 |
+
toHaveBeenNthCalledWith(nth: number, ...expected: Array<unknown>): R;
|
| 225 |
+
/**
|
| 226 |
+
* If you have a mock function, you can use `.toHaveBeenLastCalledWith`
|
| 227 |
+
* to test what arguments it was last called with.
|
| 228 |
+
*/
|
| 229 |
+
toHaveBeenLastCalledWith(...expected: Array<unknown>): R;
|
| 230 |
+
/**
|
| 231 |
+
* Use to test the specific value that a mock function last returned.
|
| 232 |
+
* If the last call to the mock function threw an error, then this matcher will fail
|
| 233 |
+
* no matter what value you provided as the expected return value.
|
| 234 |
+
*/
|
| 235 |
+
toHaveLastReturnedWith(expected?: unknown): R;
|
| 236 |
+
/**
|
| 237 |
+
* Used to check that an object has a `.length` property
|
| 238 |
+
* and it is set to a certain numeric value.
|
| 239 |
+
*/
|
| 240 |
+
toHaveLength(expected: number): R;
|
| 241 |
+
/**
|
| 242 |
+
* Use to test the specific value that a mock function returned for the nth call.
|
| 243 |
+
* If the nth call to the mock function threw an error, then this matcher will fail
|
| 244 |
+
* no matter what value you provided as the expected return value.
|
| 245 |
+
*/
|
| 246 |
+
toHaveNthReturnedWith(nth: number, expected?: unknown): R;
|
| 247 |
+
/**
|
| 248 |
+
* Use to check if property at provided reference keyPath exists for an object.
|
| 249 |
+
* For checking deeply nested properties in an object you may use dot notation or an array containing
|
| 250 |
+
* the keyPath for deep references.
|
| 251 |
+
*
|
| 252 |
+
* Optionally, you can provide a value to check if it's equal to the value present at keyPath
|
| 253 |
+
* on the target object. This matcher uses 'deep equality' (like `toEqual()`) and recursively checks
|
| 254 |
+
* the equality of all fields.
|
| 255 |
+
*
|
| 256 |
+
* @example
|
| 257 |
+
*
|
| 258 |
+
* expect(houseForSale).toHaveProperty('kitchen.area', 20);
|
| 259 |
+
*/
|
| 260 |
+
toHaveProperty(
|
| 261 |
+
expectedPath: string | Array<string>,
|
| 262 |
+
expectedValue?: unknown,
|
| 263 |
+
): R;
|
| 264 |
+
/**
|
| 265 |
+
* Use to test that the mock function successfully returned (i.e., did not throw an error) at least one time
|
| 266 |
+
*/
|
| 267 |
+
toHaveReturned(): R;
|
| 268 |
+
/**
|
| 269 |
+
* Use to ensure that a mock function returned successfully (i.e., did not throw an error) an exact number of times.
|
| 270 |
+
* Any calls to the mock function that throw an error are not counted toward the number of times the function returned.
|
| 271 |
+
*/
|
| 272 |
+
toHaveReturnedTimes(expected: number): R;
|
| 273 |
+
/**
|
| 274 |
+
* Use to ensure that a mock function returned a specific value.
|
| 275 |
+
*/
|
| 276 |
+
toHaveReturnedWith(expected?: unknown): R;
|
| 277 |
+
/**
|
| 278 |
+
* Check that a string matches a regular expression.
|
| 279 |
+
*/
|
| 280 |
+
toMatch(expected: string | RegExp): R;
|
| 281 |
+
/**
|
| 282 |
+
* Used to check that a JavaScript object matches a subset of the properties of an object
|
| 283 |
+
*/
|
| 284 |
+
toMatchObject(
|
| 285 |
+
expected: Record<string, unknown> | Array<Record<string, unknown>>,
|
| 286 |
+
): R;
|
| 287 |
+
/**
|
| 288 |
+
* Ensure that a mock function has returned (as opposed to thrown) at least once.
|
| 289 |
+
*/
|
| 290 |
+
toReturn(): R;
|
| 291 |
+
/**
|
| 292 |
+
* Ensure that a mock function has returned (as opposed to thrown) a specified number of times.
|
| 293 |
+
*/
|
| 294 |
+
toReturnTimes(expected: number): R;
|
| 295 |
+
/**
|
| 296 |
+
* Ensure that a mock function has returned a specified value at least once.
|
| 297 |
+
*/
|
| 298 |
+
toReturnWith(expected?: unknown): R;
|
| 299 |
+
/**
|
| 300 |
+
* Use to test that objects have the same types as well as structure.
|
| 301 |
+
*/
|
| 302 |
+
toStrictEqual(expected: unknown): R;
|
| 303 |
+
/**
|
| 304 |
+
* Used to test that a function throws when it is called.
|
| 305 |
+
*/
|
| 306 |
+
toThrow(expected?: unknown): R;
|
| 307 |
+
/**
|
| 308 |
+
* If you want to test that a specific error is thrown inside a function.
|
| 309 |
+
*/
|
| 310 |
+
toThrowError(expected?: unknown): R;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
declare type MatchersObject = {
|
| 314 |
+
[name: string]: RawMatcherFn;
|
| 315 |
+
};
|
| 316 |
+
|
| 317 |
+
export declare interface MatcherState {
|
| 318 |
+
assertionCalls: number;
|
| 319 |
+
currentConcurrentTestName?: () => string | undefined;
|
| 320 |
+
currentTestName?: string;
|
| 321 |
+
error?: Error;
|
| 322 |
+
expand?: boolean;
|
| 323 |
+
expectedAssertionsNumber: number | null;
|
| 324 |
+
expectedAssertionsNumberError?: Error;
|
| 325 |
+
isExpectingAssertions: boolean;
|
| 326 |
+
isExpectingAssertionsError?: Error;
|
| 327 |
+
isNot?: boolean;
|
| 328 |
+
numPassingAsserts: number;
|
| 329 |
+
promise?: string;
|
| 330 |
+
suppressedErrors: Array<Error>;
|
| 331 |
+
testPath?: string;
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
export declare interface MatcherUtils {
|
| 335 |
+
customTesters: Array<Tester>;
|
| 336 |
+
dontThrow(): void;
|
| 337 |
+
equals: EqualsFunction;
|
| 338 |
+
utils: typeof jestMatcherUtils & {
|
| 339 |
+
iterableEquality: Tester;
|
| 340 |
+
subsetEquality: Tester;
|
| 341 |
+
};
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
declare type PromiseMatchers<T = unknown> = {
|
| 345 |
+
/**
|
| 346 |
+
* Unwraps the reason of a rejected promise so any other matcher can be chained.
|
| 347 |
+
* If the promise is fulfilled the assertion fails.
|
| 348 |
+
*/
|
| 349 |
+
rejects: Matchers<Promise<void>, T> & Inverse<Matchers<Promise<void>, T>>;
|
| 350 |
+
/**
|
| 351 |
+
* Unwraps the value of a fulfilled promise so any other matcher can be chained.
|
| 352 |
+
* If the promise is rejected the assertion fails.
|
| 353 |
+
*/
|
| 354 |
+
resolves: Matchers<Promise<void>, T> & Inverse<Matchers<Promise<void>, T>>;
|
| 355 |
+
};
|
| 356 |
+
|
| 357 |
+
declare type RawMatcherFn<Context extends MatcherContext = MatcherContext> = {
|
| 358 |
+
(this: Context, actual: any, ...expected: Array<any>): ExpectationResult;
|
| 359 |
+
};
|
| 360 |
+
|
| 361 |
+
export declare type SyncExpectationResult = {
|
| 362 |
+
pass: boolean;
|
| 363 |
+
message(): string;
|
| 364 |
+
};
|
| 365 |
+
|
| 366 |
+
export {Tester};
|
| 367 |
+
|
| 368 |
+
export {TesterContext};
|
| 369 |
+
|
| 370 |
+
export {};
|
novas/novacore-zephyr/claude-code-router/node_modules/expect/build/index.js
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
Object.defineProperty(exports, 'AsymmetricMatcher', {
|
| 7 |
+
enumerable: true,
|
| 8 |
+
get: function () {
|
| 9 |
+
return _asymmetricMatchers.AsymmetricMatcher;
|
| 10 |
+
}
|
| 11 |
+
});
|
| 12 |
+
exports.expect = exports.default = exports.JestAssertionError = void 0;
|
| 13 |
+
var _expectUtils = require('@jest/expect-utils');
|
| 14 |
+
var matcherUtils = _interopRequireWildcard(require('jest-matcher-utils'));
|
| 15 |
+
var _jestUtil = require('jest-util');
|
| 16 |
+
var _asymmetricMatchers = require('./asymmetricMatchers');
|
| 17 |
+
var _extractExpectedAssertionsErrors = _interopRequireDefault(
|
| 18 |
+
require('./extractExpectedAssertionsErrors')
|
| 19 |
+
);
|
| 20 |
+
var _jestMatchersObject = require('./jestMatchersObject');
|
| 21 |
+
var _matchers = _interopRequireDefault(require('./matchers'));
|
| 22 |
+
var _spyMatchers = _interopRequireDefault(require('./spyMatchers'));
|
| 23 |
+
var _toThrowMatchers = _interopRequireWildcard(require('./toThrowMatchers'));
|
| 24 |
+
function _interopRequireDefault(obj) {
|
| 25 |
+
return obj && obj.__esModule ? obj : {default: obj};
|
| 26 |
+
}
|
| 27 |
+
function _getRequireWildcardCache(nodeInterop) {
|
| 28 |
+
if (typeof WeakMap !== 'function') return null;
|
| 29 |
+
var cacheBabelInterop = new WeakMap();
|
| 30 |
+
var cacheNodeInterop = new WeakMap();
|
| 31 |
+
return (_getRequireWildcardCache = function (nodeInterop) {
|
| 32 |
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
| 33 |
+
})(nodeInterop);
|
| 34 |
+
}
|
| 35 |
+
function _interopRequireWildcard(obj, nodeInterop) {
|
| 36 |
+
if (!nodeInterop && obj && obj.__esModule) {
|
| 37 |
+
return obj;
|
| 38 |
+
}
|
| 39 |
+
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
| 40 |
+
return {default: obj};
|
| 41 |
+
}
|
| 42 |
+
var cache = _getRequireWildcardCache(nodeInterop);
|
| 43 |
+
if (cache && cache.has(obj)) {
|
| 44 |
+
return cache.get(obj);
|
| 45 |
+
}
|
| 46 |
+
var newObj = {};
|
| 47 |
+
var hasPropertyDescriptor =
|
| 48 |
+
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
| 49 |
+
for (var key in obj) {
|
| 50 |
+
if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
|
| 51 |
+
var desc = hasPropertyDescriptor
|
| 52 |
+
? Object.getOwnPropertyDescriptor(obj, key)
|
| 53 |
+
: null;
|
| 54 |
+
if (desc && (desc.get || desc.set)) {
|
| 55 |
+
Object.defineProperty(newObj, key, desc);
|
| 56 |
+
} else {
|
| 57 |
+
newObj[key] = obj[key];
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
newObj.default = obj;
|
| 62 |
+
if (cache) {
|
| 63 |
+
cache.set(obj, newObj);
|
| 64 |
+
}
|
| 65 |
+
return newObj;
|
| 66 |
+
}
|
| 67 |
+
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
|
| 68 |
+
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
|
| 69 |
+
var Promise =
|
| 70 |
+
globalThis[Symbol.for('jest-native-promise')] || globalThis.Promise;
|
| 71 |
+
/**
|
| 72 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 73 |
+
*
|
| 74 |
+
* This source code is licensed under the MIT license found in the
|
| 75 |
+
* LICENSE file in the root directory of this source tree.
|
| 76 |
+
*
|
| 77 |
+
*/
|
| 78 |
+
/* eslint-disable local/prefer-spread-eventually */
|
| 79 |
+
class JestAssertionError extends Error {
|
| 80 |
+
matcherResult;
|
| 81 |
+
}
|
| 82 |
+
exports.JestAssertionError = JestAssertionError;
|
| 83 |
+
const createToThrowErrorMatchingSnapshotMatcher = function (matcher) {
|
| 84 |
+
return function (received, testNameOrInlineSnapshot) {
|
| 85 |
+
return matcher.apply(this, [received, testNameOrInlineSnapshot, true]);
|
| 86 |
+
};
|
| 87 |
+
};
|
| 88 |
+
const getPromiseMatcher = (name, matcher) => {
|
| 89 |
+
if (name === 'toThrow' || name === 'toThrowError') {
|
| 90 |
+
return (0, _toThrowMatchers.createMatcher)(name, true);
|
| 91 |
+
} else if (
|
| 92 |
+
name === 'toThrowErrorMatchingSnapshot' ||
|
| 93 |
+
name === 'toThrowErrorMatchingInlineSnapshot'
|
| 94 |
+
) {
|
| 95 |
+
return createToThrowErrorMatchingSnapshotMatcher(matcher);
|
| 96 |
+
}
|
| 97 |
+
return null;
|
| 98 |
+
};
|
| 99 |
+
const expect = (actual, ...rest) => {
|
| 100 |
+
if (rest.length !== 0) {
|
| 101 |
+
throw new Error('Expect takes at most one argument.');
|
| 102 |
+
}
|
| 103 |
+
const allMatchers = (0, _jestMatchersObject.getMatchers)();
|
| 104 |
+
const expectation = {
|
| 105 |
+
not: {},
|
| 106 |
+
rejects: {
|
| 107 |
+
not: {}
|
| 108 |
+
},
|
| 109 |
+
resolves: {
|
| 110 |
+
not: {}
|
| 111 |
+
}
|
| 112 |
+
};
|
| 113 |
+
const err = new JestAssertionError();
|
| 114 |
+
Object.keys(allMatchers).forEach(name => {
|
| 115 |
+
const matcher = allMatchers[name];
|
| 116 |
+
const promiseMatcher = getPromiseMatcher(name, matcher) || matcher;
|
| 117 |
+
expectation[name] = makeThrowingMatcher(matcher, false, '', actual);
|
| 118 |
+
expectation.not[name] = makeThrowingMatcher(matcher, true, '', actual);
|
| 119 |
+
expectation.resolves[name] = makeResolveMatcher(
|
| 120 |
+
name,
|
| 121 |
+
promiseMatcher,
|
| 122 |
+
false,
|
| 123 |
+
actual,
|
| 124 |
+
err
|
| 125 |
+
);
|
| 126 |
+
expectation.resolves.not[name] = makeResolveMatcher(
|
| 127 |
+
name,
|
| 128 |
+
promiseMatcher,
|
| 129 |
+
true,
|
| 130 |
+
actual,
|
| 131 |
+
err
|
| 132 |
+
);
|
| 133 |
+
expectation.rejects[name] = makeRejectMatcher(
|
| 134 |
+
name,
|
| 135 |
+
promiseMatcher,
|
| 136 |
+
false,
|
| 137 |
+
actual,
|
| 138 |
+
err
|
| 139 |
+
);
|
| 140 |
+
expectation.rejects.not[name] = makeRejectMatcher(
|
| 141 |
+
name,
|
| 142 |
+
promiseMatcher,
|
| 143 |
+
true,
|
| 144 |
+
actual,
|
| 145 |
+
err
|
| 146 |
+
);
|
| 147 |
+
});
|
| 148 |
+
return expectation;
|
| 149 |
+
};
|
| 150 |
+
exports.expect = expect;
|
| 151 |
+
const getMessage = message =>
|
| 152 |
+
(message && message()) ||
|
| 153 |
+
matcherUtils.RECEIVED_COLOR('No message was specified for this matcher.');
|
| 154 |
+
const makeResolveMatcher =
|
| 155 |
+
(matcherName, matcher, isNot, actual, outerErr) =>
|
| 156 |
+
(...args) => {
|
| 157 |
+
const options = {
|
| 158 |
+
isNot,
|
| 159 |
+
promise: 'resolves'
|
| 160 |
+
};
|
| 161 |
+
if (!(0, _jestUtil.isPromise)(actual)) {
|
| 162 |
+
throw new JestAssertionError(
|
| 163 |
+
matcherUtils.matcherErrorMessage(
|
| 164 |
+
matcherUtils.matcherHint(matcherName, undefined, '', options),
|
| 165 |
+
`${matcherUtils.RECEIVED_COLOR('received')} value must be a promise`,
|
| 166 |
+
matcherUtils.printWithType(
|
| 167 |
+
'Received',
|
| 168 |
+
actual,
|
| 169 |
+
matcherUtils.printReceived
|
| 170 |
+
)
|
| 171 |
+
)
|
| 172 |
+
);
|
| 173 |
+
}
|
| 174 |
+
const innerErr = new JestAssertionError();
|
| 175 |
+
return actual.then(
|
| 176 |
+
result =>
|
| 177 |
+
makeThrowingMatcher(matcher, isNot, 'resolves', result, innerErr).apply(
|
| 178 |
+
null,
|
| 179 |
+
args
|
| 180 |
+
),
|
| 181 |
+
reason => {
|
| 182 |
+
outerErr.message =
|
| 183 |
+
`${matcherUtils.matcherHint(
|
| 184 |
+
matcherName,
|
| 185 |
+
undefined,
|
| 186 |
+
'',
|
| 187 |
+
options
|
| 188 |
+
)}\n\n` +
|
| 189 |
+
'Received promise rejected instead of resolved\n' +
|
| 190 |
+
`Rejected to value: ${matcherUtils.printReceived(reason)}`;
|
| 191 |
+
return Promise.reject(outerErr);
|
| 192 |
+
}
|
| 193 |
+
);
|
| 194 |
+
};
|
| 195 |
+
const makeRejectMatcher =
|
| 196 |
+
(matcherName, matcher, isNot, actual, outerErr) =>
|
| 197 |
+
(...args) => {
|
| 198 |
+
const options = {
|
| 199 |
+
isNot,
|
| 200 |
+
promise: 'rejects'
|
| 201 |
+
};
|
| 202 |
+
const actualWrapper = typeof actual === 'function' ? actual() : actual;
|
| 203 |
+
if (!(0, _jestUtil.isPromise)(actualWrapper)) {
|
| 204 |
+
throw new JestAssertionError(
|
| 205 |
+
matcherUtils.matcherErrorMessage(
|
| 206 |
+
matcherUtils.matcherHint(matcherName, undefined, '', options),
|
| 207 |
+
`${matcherUtils.RECEIVED_COLOR(
|
| 208 |
+
'received'
|
| 209 |
+
)} value must be a promise or a function returning a promise`,
|
| 210 |
+
matcherUtils.printWithType(
|
| 211 |
+
'Received',
|
| 212 |
+
actual,
|
| 213 |
+
matcherUtils.printReceived
|
| 214 |
+
)
|
| 215 |
+
)
|
| 216 |
+
);
|
| 217 |
+
}
|
| 218 |
+
const innerErr = new JestAssertionError();
|
| 219 |
+
return actualWrapper.then(
|
| 220 |
+
result => {
|
| 221 |
+
outerErr.message =
|
| 222 |
+
`${matcherUtils.matcherHint(
|
| 223 |
+
matcherName,
|
| 224 |
+
undefined,
|
| 225 |
+
'',
|
| 226 |
+
options
|
| 227 |
+
)}\n\n` +
|
| 228 |
+
'Received promise resolved instead of rejected\n' +
|
| 229 |
+
`Resolved to value: ${matcherUtils.printReceived(result)}`;
|
| 230 |
+
return Promise.reject(outerErr);
|
| 231 |
+
},
|
| 232 |
+
reason =>
|
| 233 |
+
makeThrowingMatcher(matcher, isNot, 'rejects', reason, innerErr).apply(
|
| 234 |
+
null,
|
| 235 |
+
args
|
| 236 |
+
)
|
| 237 |
+
);
|
| 238 |
+
};
|
| 239 |
+
const makeThrowingMatcher = (matcher, isNot, promise, actual, err) =>
|
| 240 |
+
function throwingMatcher(...args) {
|
| 241 |
+
let throws = true;
|
| 242 |
+
const utils = {
|
| 243 |
+
...matcherUtils,
|
| 244 |
+
iterableEquality: _expectUtils.iterableEquality,
|
| 245 |
+
subsetEquality: _expectUtils.subsetEquality
|
| 246 |
+
};
|
| 247 |
+
const matcherUtilsThing = {
|
| 248 |
+
customTesters: (0, _jestMatchersObject.getCustomEqualityTesters)(),
|
| 249 |
+
// When throws is disabled, the matcher will not throw errors during test
|
| 250 |
+
// execution but instead add them to the global matcher state. If a
|
| 251 |
+
// matcher throws, test execution is normally stopped immediately. The
|
| 252 |
+
// snapshot matcher uses it because we want to log all snapshot
|
| 253 |
+
// failures in a test.
|
| 254 |
+
dontThrow: () => (throws = false),
|
| 255 |
+
equals: _expectUtils.equals,
|
| 256 |
+
utils
|
| 257 |
+
};
|
| 258 |
+
const matcherContext = {
|
| 259 |
+
...(0, _jestMatchersObject.getState)(),
|
| 260 |
+
...matcherUtilsThing,
|
| 261 |
+
error: err,
|
| 262 |
+
isNot,
|
| 263 |
+
promise
|
| 264 |
+
};
|
| 265 |
+
const processResult = (result, asyncError) => {
|
| 266 |
+
_validateResult(result);
|
| 267 |
+
(0, _jestMatchersObject.getState)().assertionCalls++;
|
| 268 |
+
if ((result.pass && isNot) || (!result.pass && !isNot)) {
|
| 269 |
+
// XOR
|
| 270 |
+
const message = getMessage(result.message);
|
| 271 |
+
let error;
|
| 272 |
+
if (err) {
|
| 273 |
+
error = err;
|
| 274 |
+
error.message = message;
|
| 275 |
+
} else if (asyncError) {
|
| 276 |
+
error = asyncError;
|
| 277 |
+
error.message = message;
|
| 278 |
+
} else {
|
| 279 |
+
error = new JestAssertionError(message);
|
| 280 |
+
|
| 281 |
+
// Try to remove this function from the stack trace frame.
|
| 282 |
+
// Guard for some environments (browsers) that do not support this feature.
|
| 283 |
+
if (Error.captureStackTrace) {
|
| 284 |
+
Error.captureStackTrace(error, throwingMatcher);
|
| 285 |
+
}
|
| 286 |
+
}
|
| 287 |
+
// Passing the result of the matcher with the error so that a custom
|
| 288 |
+
// reporter could access the actual and expected objects of the result
|
| 289 |
+
// for example in order to display a custom visual diff
|
| 290 |
+
error.matcherResult = {
|
| 291 |
+
...result,
|
| 292 |
+
message
|
| 293 |
+
};
|
| 294 |
+
if (throws) {
|
| 295 |
+
throw error;
|
| 296 |
+
} else {
|
| 297 |
+
(0, _jestMatchersObject.getState)().suppressedErrors.push(error);
|
| 298 |
+
}
|
| 299 |
+
} else {
|
| 300 |
+
(0, _jestMatchersObject.getState)().numPassingAsserts++;
|
| 301 |
+
}
|
| 302 |
+
};
|
| 303 |
+
const handleError = error => {
|
| 304 |
+
if (
|
| 305 |
+
matcher[_jestMatchersObject.INTERNAL_MATCHER_FLAG] === true &&
|
| 306 |
+
!(error instanceof JestAssertionError) &&
|
| 307 |
+
error.name !== 'PrettyFormatPluginError' &&
|
| 308 |
+
// Guard for some environments (browsers) that do not support this feature.
|
| 309 |
+
Error.captureStackTrace
|
| 310 |
+
) {
|
| 311 |
+
// Try to remove this and deeper functions from the stack trace frame.
|
| 312 |
+
Error.captureStackTrace(error, throwingMatcher);
|
| 313 |
+
}
|
| 314 |
+
throw error;
|
| 315 |
+
};
|
| 316 |
+
let potentialResult;
|
| 317 |
+
try {
|
| 318 |
+
potentialResult =
|
| 319 |
+
matcher[_jestMatchersObject.INTERNAL_MATCHER_FLAG] === true
|
| 320 |
+
? matcher.call(matcherContext, actual, ...args)
|
| 321 |
+
: // It's a trap specifically for inline snapshot to capture this name
|
| 322 |
+
// in the stack trace, so that it can correctly get the custom matcher
|
| 323 |
+
// function call.
|
| 324 |
+
(function __EXTERNAL_MATCHER_TRAP__() {
|
| 325 |
+
return matcher.call(matcherContext, actual, ...args);
|
| 326 |
+
})();
|
| 327 |
+
if ((0, _jestUtil.isPromise)(potentialResult)) {
|
| 328 |
+
const asyncError = new JestAssertionError();
|
| 329 |
+
if (Error.captureStackTrace) {
|
| 330 |
+
Error.captureStackTrace(asyncError, throwingMatcher);
|
| 331 |
+
}
|
| 332 |
+
return potentialResult
|
| 333 |
+
.then(aResult => processResult(aResult, asyncError))
|
| 334 |
+
.catch(handleError);
|
| 335 |
+
} else {
|
| 336 |
+
return processResult(potentialResult);
|
| 337 |
+
}
|
| 338 |
+
} catch (error) {
|
| 339 |
+
return handleError(error);
|
| 340 |
+
}
|
| 341 |
+
};
|
| 342 |
+
expect.extend = matchers =>
|
| 343 |
+
(0, _jestMatchersObject.setMatchers)(matchers, false, expect);
|
| 344 |
+
expect.addEqualityTesters = customTesters =>
|
| 345 |
+
(0, _jestMatchersObject.addCustomEqualityTesters)(customTesters);
|
| 346 |
+
expect.anything = _asymmetricMatchers.anything;
|
| 347 |
+
expect.any = _asymmetricMatchers.any;
|
| 348 |
+
expect.not = {
|
| 349 |
+
arrayContaining: _asymmetricMatchers.arrayNotContaining,
|
| 350 |
+
closeTo: _asymmetricMatchers.notCloseTo,
|
| 351 |
+
objectContaining: _asymmetricMatchers.objectNotContaining,
|
| 352 |
+
stringContaining: _asymmetricMatchers.stringNotContaining,
|
| 353 |
+
stringMatching: _asymmetricMatchers.stringNotMatching
|
| 354 |
+
};
|
| 355 |
+
expect.arrayContaining = _asymmetricMatchers.arrayContaining;
|
| 356 |
+
expect.closeTo = _asymmetricMatchers.closeTo;
|
| 357 |
+
expect.objectContaining = _asymmetricMatchers.objectContaining;
|
| 358 |
+
expect.stringContaining = _asymmetricMatchers.stringContaining;
|
| 359 |
+
expect.stringMatching = _asymmetricMatchers.stringMatching;
|
| 360 |
+
const _validateResult = result => {
|
| 361 |
+
if (
|
| 362 |
+
typeof result !== 'object' ||
|
| 363 |
+
typeof result.pass !== 'boolean' ||
|
| 364 |
+
(result.message &&
|
| 365 |
+
typeof result.message !== 'string' &&
|
| 366 |
+
typeof result.message !== 'function')
|
| 367 |
+
) {
|
| 368 |
+
throw new Error(
|
| 369 |
+
'Unexpected return from a matcher function.\n' +
|
| 370 |
+
'Matcher functions should ' +
|
| 371 |
+
'return an object in the following format:\n' +
|
| 372 |
+
' {message?: string | function, pass: boolean}\n' +
|
| 373 |
+
`'${matcherUtils.stringify(result)}' was returned`
|
| 374 |
+
);
|
| 375 |
+
}
|
| 376 |
+
};
|
| 377 |
+
function assertions(expected) {
|
| 378 |
+
const error = new Error();
|
| 379 |
+
if (Error.captureStackTrace) {
|
| 380 |
+
Error.captureStackTrace(error, assertions);
|
| 381 |
+
}
|
| 382 |
+
(0, _jestMatchersObject.setState)({
|
| 383 |
+
expectedAssertionsNumber: expected,
|
| 384 |
+
expectedAssertionsNumberError: error
|
| 385 |
+
});
|
| 386 |
+
}
|
| 387 |
+
function hasAssertions(...args) {
|
| 388 |
+
const error = new Error();
|
| 389 |
+
if (Error.captureStackTrace) {
|
| 390 |
+
Error.captureStackTrace(error, hasAssertions);
|
| 391 |
+
}
|
| 392 |
+
matcherUtils.ensureNoExpected(args[0], '.hasAssertions');
|
| 393 |
+
(0, _jestMatchersObject.setState)({
|
| 394 |
+
isExpectingAssertions: true,
|
| 395 |
+
isExpectingAssertionsError: error
|
| 396 |
+
});
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
// add default jest matchers
|
| 400 |
+
(0, _jestMatchersObject.setMatchers)(_matchers.default, true, expect);
|
| 401 |
+
(0, _jestMatchersObject.setMatchers)(_spyMatchers.default, true, expect);
|
| 402 |
+
(0, _jestMatchersObject.setMatchers)(_toThrowMatchers.default, true, expect);
|
| 403 |
+
expect.assertions = assertions;
|
| 404 |
+
expect.hasAssertions = hasAssertions;
|
| 405 |
+
expect.getState = _jestMatchersObject.getState;
|
| 406 |
+
expect.setState = _jestMatchersObject.setState;
|
| 407 |
+
expect.extractExpectedAssertionsErrors =
|
| 408 |
+
_extractExpectedAssertionsErrors.default;
|
| 409 |
+
var _default = expect;
|
| 410 |
+
exports.default = _default;
|
novas/novacore-zephyr/claude-code-router/node_modules/expect/build/jestMatchersObject.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.setState =
|
| 7 |
+
exports.setMatchers =
|
| 8 |
+
exports.getState =
|
| 9 |
+
exports.getMatchers =
|
| 10 |
+
exports.getCustomEqualityTesters =
|
| 11 |
+
exports.addCustomEqualityTesters =
|
| 12 |
+
exports.INTERNAL_MATCHER_FLAG =
|
| 13 |
+
void 0;
|
| 14 |
+
var _jestGetType = require('jest-get-type');
|
| 15 |
+
var _asymmetricMatchers = require('./asymmetricMatchers');
|
| 16 |
+
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
|
| 17 |
+
/**
|
| 18 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 19 |
+
*
|
| 20 |
+
* This source code is licensed under the MIT license found in the
|
| 21 |
+
* LICENSE file in the root directory of this source tree.
|
| 22 |
+
*
|
| 23 |
+
*/
|
| 24 |
+
// Global matchers object holds the list of available matchers and
|
| 25 |
+
// the state, that can hold matcher specific values that change over time.
|
| 26 |
+
const JEST_MATCHERS_OBJECT = Symbol.for('$$jest-matchers-object');
|
| 27 |
+
|
| 28 |
+
// Notes a built-in/internal Jest matcher.
|
| 29 |
+
// Jest may override the stack trace of Errors thrown by internal matchers.
|
| 30 |
+
const INTERNAL_MATCHER_FLAG = Symbol.for('$$jest-internal-matcher');
|
| 31 |
+
exports.INTERNAL_MATCHER_FLAG = INTERNAL_MATCHER_FLAG;
|
| 32 |
+
if (!Object.prototype.hasOwnProperty.call(globalThis, JEST_MATCHERS_OBJECT)) {
|
| 33 |
+
const defaultState = {
|
| 34 |
+
assertionCalls: 0,
|
| 35 |
+
expectedAssertionsNumber: null,
|
| 36 |
+
isExpectingAssertions: false,
|
| 37 |
+
numPassingAsserts: 0,
|
| 38 |
+
suppressedErrors: [] // errors that are not thrown immediately.
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
Object.defineProperty(globalThis, JEST_MATCHERS_OBJECT, {
|
| 42 |
+
value: {
|
| 43 |
+
customEqualityTesters: [],
|
| 44 |
+
matchers: Object.create(null),
|
| 45 |
+
state: defaultState
|
| 46 |
+
}
|
| 47 |
+
});
|
| 48 |
+
}
|
| 49 |
+
const getState = () => globalThis[JEST_MATCHERS_OBJECT].state;
|
| 50 |
+
exports.getState = getState;
|
| 51 |
+
const setState = state => {
|
| 52 |
+
Object.assign(globalThis[JEST_MATCHERS_OBJECT].state, state);
|
| 53 |
+
};
|
| 54 |
+
exports.setState = setState;
|
| 55 |
+
const getMatchers = () => globalThis[JEST_MATCHERS_OBJECT].matchers;
|
| 56 |
+
exports.getMatchers = getMatchers;
|
| 57 |
+
const setMatchers = (matchers, isInternal, expect) => {
|
| 58 |
+
Object.keys(matchers).forEach(key => {
|
| 59 |
+
const matcher = matchers[key];
|
| 60 |
+
if (typeof matcher !== 'function') {
|
| 61 |
+
throw new TypeError(
|
| 62 |
+
`expect.extend: \`${key}\` is not a valid matcher. Must be a function, is "${(0,
|
| 63 |
+
_jestGetType.getType)(matcher)}"`
|
| 64 |
+
);
|
| 65 |
+
}
|
| 66 |
+
Object.defineProperty(matcher, INTERNAL_MATCHER_FLAG, {
|
| 67 |
+
value: isInternal
|
| 68 |
+
});
|
| 69 |
+
if (!isInternal) {
|
| 70 |
+
// expect is defined
|
| 71 |
+
|
| 72 |
+
class CustomMatcher extends _asymmetricMatchers.AsymmetricMatcher {
|
| 73 |
+
constructor(inverse = false, ...sample) {
|
| 74 |
+
super(sample, inverse);
|
| 75 |
+
}
|
| 76 |
+
asymmetricMatch(other) {
|
| 77 |
+
const {pass} = matcher.call(
|
| 78 |
+
this.getMatcherContext(),
|
| 79 |
+
other,
|
| 80 |
+
...this.sample
|
| 81 |
+
);
|
| 82 |
+
return this.inverse ? !pass : pass;
|
| 83 |
+
}
|
| 84 |
+
toString() {
|
| 85 |
+
return `${this.inverse ? 'not.' : ''}${key}`;
|
| 86 |
+
}
|
| 87 |
+
getExpectedType() {
|
| 88 |
+
return 'any';
|
| 89 |
+
}
|
| 90 |
+
toAsymmetricMatcher() {
|
| 91 |
+
return `${this.toString()}<${this.sample.map(String).join(', ')}>`;
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
Object.defineProperty(expect, key, {
|
| 95 |
+
configurable: true,
|
| 96 |
+
enumerable: true,
|
| 97 |
+
value: (...sample) => new CustomMatcher(false, ...sample),
|
| 98 |
+
writable: true
|
| 99 |
+
});
|
| 100 |
+
Object.defineProperty(expect.not, key, {
|
| 101 |
+
configurable: true,
|
| 102 |
+
enumerable: true,
|
| 103 |
+
value: (...sample) => new CustomMatcher(true, ...sample),
|
| 104 |
+
writable: true
|
| 105 |
+
});
|
| 106 |
+
}
|
| 107 |
+
});
|
| 108 |
+
Object.assign(globalThis[JEST_MATCHERS_OBJECT].matchers, matchers);
|
| 109 |
+
};
|
| 110 |
+
exports.setMatchers = setMatchers;
|
| 111 |
+
const getCustomEqualityTesters = () =>
|
| 112 |
+
globalThis[JEST_MATCHERS_OBJECT].customEqualityTesters;
|
| 113 |
+
exports.getCustomEqualityTesters = getCustomEqualityTesters;
|
| 114 |
+
const addCustomEqualityTesters = newTesters => {
|
| 115 |
+
if (!Array.isArray(newTesters)) {
|
| 116 |
+
throw new TypeError(
|
| 117 |
+
`expect.customEqualityTesters: Must be set to an array of Testers. Was given "${(0,
|
| 118 |
+
_jestGetType.getType)(newTesters)}"`
|
| 119 |
+
);
|
| 120 |
+
}
|
| 121 |
+
globalThis[JEST_MATCHERS_OBJECT].customEqualityTesters.push(...newTesters);
|
| 122 |
+
};
|
| 123 |
+
exports.addCustomEqualityTesters = addCustomEqualityTesters;
|
novas/novacore-zephyr/claude-code-router/node_modules/expect/build/matchers.js
ADDED
|
@@ -0,0 +1,1292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = void 0;
|
| 7 |
+
var _expectUtils = require('@jest/expect-utils');
|
| 8 |
+
var _jestGetType = require('jest-get-type');
|
| 9 |
+
var _jestMatcherUtils = require('jest-matcher-utils');
|
| 10 |
+
var _print = require('./print');
|
| 11 |
+
/**
|
| 12 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 13 |
+
*
|
| 14 |
+
* This source code is licensed under the MIT license found in the
|
| 15 |
+
* LICENSE file in the root directory of this source tree.
|
| 16 |
+
*
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
/* eslint-disable local/ban-types-eventually */
|
| 20 |
+
|
| 21 |
+
// Omit colon and one or more spaces, so can call getLabelPrinter.
|
| 22 |
+
const EXPECTED_LABEL = 'Expected';
|
| 23 |
+
const RECEIVED_LABEL = 'Received';
|
| 24 |
+
const EXPECTED_VALUE_LABEL = 'Expected value';
|
| 25 |
+
const RECEIVED_VALUE_LABEL = 'Received value';
|
| 26 |
+
|
| 27 |
+
// The optional property of matcher context is true if undefined.
|
| 28 |
+
const isExpand = expand => expand !== false;
|
| 29 |
+
const toStrictEqualTesters = [
|
| 30 |
+
_expectUtils.iterableEquality,
|
| 31 |
+
_expectUtils.typeEquality,
|
| 32 |
+
_expectUtils.sparseArrayEquality,
|
| 33 |
+
_expectUtils.arrayBufferEquality
|
| 34 |
+
];
|
| 35 |
+
const matchers = {
|
| 36 |
+
toBe(received, expected) {
|
| 37 |
+
const matcherName = 'toBe';
|
| 38 |
+
const options = {
|
| 39 |
+
comment: 'Object.is equality',
|
| 40 |
+
isNot: this.isNot,
|
| 41 |
+
promise: this.promise
|
| 42 |
+
};
|
| 43 |
+
const pass = Object.is(received, expected);
|
| 44 |
+
const message = pass
|
| 45 |
+
? () =>
|
| 46 |
+
// eslint-disable-next-line prefer-template
|
| 47 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 48 |
+
matcherName,
|
| 49 |
+
undefined,
|
| 50 |
+
undefined,
|
| 51 |
+
options
|
| 52 |
+
) +
|
| 53 |
+
'\n\n' +
|
| 54 |
+
`Expected: not ${(0, _jestMatcherUtils.printExpected)(expected)}`
|
| 55 |
+
: () => {
|
| 56 |
+
const expectedType = (0, _jestGetType.getType)(expected);
|
| 57 |
+
let deepEqualityName = null;
|
| 58 |
+
if (expectedType !== 'map' && expectedType !== 'set') {
|
| 59 |
+
// If deep equality passes when referential identity fails,
|
| 60 |
+
// but exclude map and set until review of their equality logic.
|
| 61 |
+
if (
|
| 62 |
+
(0, _expectUtils.equals)(
|
| 63 |
+
received,
|
| 64 |
+
expected,
|
| 65 |
+
[...this.customTesters, ...toStrictEqualTesters],
|
| 66 |
+
true
|
| 67 |
+
)
|
| 68 |
+
) {
|
| 69 |
+
deepEqualityName = 'toStrictEqual';
|
| 70 |
+
} else if (
|
| 71 |
+
(0, _expectUtils.equals)(received, expected, [
|
| 72 |
+
...this.customTesters,
|
| 73 |
+
_expectUtils.iterableEquality
|
| 74 |
+
])
|
| 75 |
+
) {
|
| 76 |
+
deepEqualityName = 'toEqual';
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
return (
|
| 80 |
+
// eslint-disable-next-line prefer-template
|
| 81 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 82 |
+
matcherName,
|
| 83 |
+
undefined,
|
| 84 |
+
undefined,
|
| 85 |
+
options
|
| 86 |
+
) +
|
| 87 |
+
'\n\n' +
|
| 88 |
+
(deepEqualityName !== null
|
| 89 |
+
? `${(0, _jestMatcherUtils.DIM_COLOR)(
|
| 90 |
+
`If it should pass with deep equality, replace "${matcherName}" with "${deepEqualityName}"`
|
| 91 |
+
)}\n\n`
|
| 92 |
+
: '') +
|
| 93 |
+
(0, _jestMatcherUtils.printDiffOrStringify)(
|
| 94 |
+
expected,
|
| 95 |
+
received,
|
| 96 |
+
EXPECTED_LABEL,
|
| 97 |
+
RECEIVED_LABEL,
|
| 98 |
+
isExpand(this.expand)
|
| 99 |
+
)
|
| 100 |
+
);
|
| 101 |
+
};
|
| 102 |
+
|
| 103 |
+
// Passing the actual and expected objects so that a custom reporter
|
| 104 |
+
// could access them, for example in order to display a custom visual diff,
|
| 105 |
+
// or create a different error message
|
| 106 |
+
return {
|
| 107 |
+
actual: received,
|
| 108 |
+
expected,
|
| 109 |
+
message,
|
| 110 |
+
name: matcherName,
|
| 111 |
+
pass
|
| 112 |
+
};
|
| 113 |
+
},
|
| 114 |
+
toBeCloseTo(received, expected, precision = 2) {
|
| 115 |
+
const matcherName = 'toBeCloseTo';
|
| 116 |
+
const secondArgument = arguments.length === 3 ? 'precision' : undefined;
|
| 117 |
+
const isNot = this.isNot;
|
| 118 |
+
const options = {
|
| 119 |
+
isNot,
|
| 120 |
+
promise: this.promise,
|
| 121 |
+
secondArgument,
|
| 122 |
+
secondArgumentColor: arg => arg
|
| 123 |
+
};
|
| 124 |
+
if (typeof expected !== 'number') {
|
| 125 |
+
throw new Error(
|
| 126 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 127 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 128 |
+
matcherName,
|
| 129 |
+
undefined,
|
| 130 |
+
undefined,
|
| 131 |
+
options
|
| 132 |
+
),
|
| 133 |
+
`${(0, _jestMatcherUtils.EXPECTED_COLOR)(
|
| 134 |
+
'expected'
|
| 135 |
+
)} value must be a number`,
|
| 136 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 137 |
+
'Expected',
|
| 138 |
+
expected,
|
| 139 |
+
_jestMatcherUtils.printExpected
|
| 140 |
+
)
|
| 141 |
+
)
|
| 142 |
+
);
|
| 143 |
+
}
|
| 144 |
+
if (typeof received !== 'number') {
|
| 145 |
+
throw new Error(
|
| 146 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 147 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 148 |
+
matcherName,
|
| 149 |
+
undefined,
|
| 150 |
+
undefined,
|
| 151 |
+
options
|
| 152 |
+
),
|
| 153 |
+
`${(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 154 |
+
'received'
|
| 155 |
+
)} value must be a number`,
|
| 156 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 157 |
+
'Received',
|
| 158 |
+
received,
|
| 159 |
+
_jestMatcherUtils.printReceived
|
| 160 |
+
)
|
| 161 |
+
)
|
| 162 |
+
);
|
| 163 |
+
}
|
| 164 |
+
let pass = false;
|
| 165 |
+
let expectedDiff = 0;
|
| 166 |
+
let receivedDiff = 0;
|
| 167 |
+
if (received === Infinity && expected === Infinity) {
|
| 168 |
+
pass = true; // Infinity - Infinity is NaN
|
| 169 |
+
} else if (received === -Infinity && expected === -Infinity) {
|
| 170 |
+
pass = true; // -Infinity - -Infinity is NaN
|
| 171 |
+
} else {
|
| 172 |
+
expectedDiff = Math.pow(10, -precision) / 2;
|
| 173 |
+
receivedDiff = Math.abs(expected - received);
|
| 174 |
+
pass = receivedDiff < expectedDiff;
|
| 175 |
+
}
|
| 176 |
+
const message = pass
|
| 177 |
+
? () =>
|
| 178 |
+
// eslint-disable-next-line prefer-template
|
| 179 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 180 |
+
matcherName,
|
| 181 |
+
undefined,
|
| 182 |
+
undefined,
|
| 183 |
+
options
|
| 184 |
+
) +
|
| 185 |
+
'\n\n' +
|
| 186 |
+
`Expected: not ${(0, _jestMatcherUtils.printExpected)(expected)}\n` +
|
| 187 |
+
(receivedDiff === 0
|
| 188 |
+
? ''
|
| 189 |
+
: `Received: ${(0, _jestMatcherUtils.printReceived)(
|
| 190 |
+
received
|
| 191 |
+
)}\n` +
|
| 192 |
+
`\n${(0, _print.printCloseTo)(
|
| 193 |
+
receivedDiff,
|
| 194 |
+
expectedDiff,
|
| 195 |
+
precision,
|
| 196 |
+
isNot
|
| 197 |
+
)}`)
|
| 198 |
+
: () =>
|
| 199 |
+
// eslint-disable-next-line prefer-template
|
| 200 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 201 |
+
matcherName,
|
| 202 |
+
undefined,
|
| 203 |
+
undefined,
|
| 204 |
+
options
|
| 205 |
+
) +
|
| 206 |
+
'\n\n' +
|
| 207 |
+
`Expected: ${(0, _jestMatcherUtils.printExpected)(expected)}\n` +
|
| 208 |
+
`Received: ${(0, _jestMatcherUtils.printReceived)(received)}\n` +
|
| 209 |
+
'\n' +
|
| 210 |
+
(0, _print.printCloseTo)(
|
| 211 |
+
receivedDiff,
|
| 212 |
+
expectedDiff,
|
| 213 |
+
precision,
|
| 214 |
+
isNot
|
| 215 |
+
);
|
| 216 |
+
return {
|
| 217 |
+
message,
|
| 218 |
+
pass
|
| 219 |
+
};
|
| 220 |
+
},
|
| 221 |
+
toBeDefined(received, expected) {
|
| 222 |
+
const matcherName = 'toBeDefined';
|
| 223 |
+
const options = {
|
| 224 |
+
isNot: this.isNot,
|
| 225 |
+
promise: this.promise
|
| 226 |
+
};
|
| 227 |
+
(0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options);
|
| 228 |
+
const pass = received !== void 0;
|
| 229 |
+
const message = () =>
|
| 230 |
+
// eslint-disable-next-line prefer-template
|
| 231 |
+
(0, _jestMatcherUtils.matcherHint)(matcherName, undefined, '', options) +
|
| 232 |
+
'\n\n' +
|
| 233 |
+
`Received: ${(0, _jestMatcherUtils.printReceived)(received)}`;
|
| 234 |
+
return {
|
| 235 |
+
message,
|
| 236 |
+
pass
|
| 237 |
+
};
|
| 238 |
+
},
|
| 239 |
+
toBeFalsy(received, expected) {
|
| 240 |
+
const matcherName = 'toBeFalsy';
|
| 241 |
+
const options = {
|
| 242 |
+
isNot: this.isNot,
|
| 243 |
+
promise: this.promise
|
| 244 |
+
};
|
| 245 |
+
(0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options);
|
| 246 |
+
const pass = !received;
|
| 247 |
+
const message = () =>
|
| 248 |
+
// eslint-disable-next-line prefer-template
|
| 249 |
+
(0, _jestMatcherUtils.matcherHint)(matcherName, undefined, '', options) +
|
| 250 |
+
'\n\n' +
|
| 251 |
+
`Received: ${(0, _jestMatcherUtils.printReceived)(received)}`;
|
| 252 |
+
return {
|
| 253 |
+
message,
|
| 254 |
+
pass
|
| 255 |
+
};
|
| 256 |
+
},
|
| 257 |
+
toBeGreaterThan(received, expected) {
|
| 258 |
+
const matcherName = 'toBeGreaterThan';
|
| 259 |
+
const isNot = this.isNot;
|
| 260 |
+
const options = {
|
| 261 |
+
isNot,
|
| 262 |
+
promise: this.promise
|
| 263 |
+
};
|
| 264 |
+
(0, _jestMatcherUtils.ensureNumbers)(
|
| 265 |
+
received,
|
| 266 |
+
expected,
|
| 267 |
+
matcherName,
|
| 268 |
+
options
|
| 269 |
+
);
|
| 270 |
+
const pass = received > expected;
|
| 271 |
+
const message = () =>
|
| 272 |
+
// eslint-disable-next-line prefer-template
|
| 273 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 274 |
+
matcherName,
|
| 275 |
+
undefined,
|
| 276 |
+
undefined,
|
| 277 |
+
options
|
| 278 |
+
) +
|
| 279 |
+
'\n\n' +
|
| 280 |
+
`Expected:${isNot ? ' not' : ''} > ${(0, _jestMatcherUtils.printExpected)(
|
| 281 |
+
expected
|
| 282 |
+
)}\n` +
|
| 283 |
+
`Received:${isNot ? ' ' : ''} ${(0, _jestMatcherUtils.printReceived)(
|
| 284 |
+
received
|
| 285 |
+
)}`;
|
| 286 |
+
return {
|
| 287 |
+
message,
|
| 288 |
+
pass
|
| 289 |
+
};
|
| 290 |
+
},
|
| 291 |
+
toBeGreaterThanOrEqual(received, expected) {
|
| 292 |
+
const matcherName = 'toBeGreaterThanOrEqual';
|
| 293 |
+
const isNot = this.isNot;
|
| 294 |
+
const options = {
|
| 295 |
+
isNot,
|
| 296 |
+
promise: this.promise
|
| 297 |
+
};
|
| 298 |
+
(0, _jestMatcherUtils.ensureNumbers)(
|
| 299 |
+
received,
|
| 300 |
+
expected,
|
| 301 |
+
matcherName,
|
| 302 |
+
options
|
| 303 |
+
);
|
| 304 |
+
const pass = received >= expected;
|
| 305 |
+
const message = () =>
|
| 306 |
+
// eslint-disable-next-line prefer-template
|
| 307 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 308 |
+
matcherName,
|
| 309 |
+
undefined,
|
| 310 |
+
undefined,
|
| 311 |
+
options
|
| 312 |
+
) +
|
| 313 |
+
'\n\n' +
|
| 314 |
+
`Expected:${isNot ? ' not' : ''} >= ${(0,
|
| 315 |
+
_jestMatcherUtils.printExpected)(expected)}\n` +
|
| 316 |
+
`Received:${isNot ? ' ' : ''} ${(0,
|
| 317 |
+
_jestMatcherUtils.printReceived)(received)}`;
|
| 318 |
+
return {
|
| 319 |
+
message,
|
| 320 |
+
pass
|
| 321 |
+
};
|
| 322 |
+
},
|
| 323 |
+
toBeInstanceOf(received, expected) {
|
| 324 |
+
const matcherName = 'toBeInstanceOf';
|
| 325 |
+
const options = {
|
| 326 |
+
isNot: this.isNot,
|
| 327 |
+
promise: this.promise
|
| 328 |
+
};
|
| 329 |
+
if (typeof expected !== 'function') {
|
| 330 |
+
throw new Error(
|
| 331 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 332 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 333 |
+
matcherName,
|
| 334 |
+
undefined,
|
| 335 |
+
undefined,
|
| 336 |
+
options
|
| 337 |
+
),
|
| 338 |
+
`${(0, _jestMatcherUtils.EXPECTED_COLOR)(
|
| 339 |
+
'expected'
|
| 340 |
+
)} value must be a function`,
|
| 341 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 342 |
+
'Expected',
|
| 343 |
+
expected,
|
| 344 |
+
_jestMatcherUtils.printExpected
|
| 345 |
+
)
|
| 346 |
+
)
|
| 347 |
+
);
|
| 348 |
+
}
|
| 349 |
+
const pass = received instanceof expected;
|
| 350 |
+
const message = pass
|
| 351 |
+
? () =>
|
| 352 |
+
// eslint-disable-next-line prefer-template
|
| 353 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 354 |
+
matcherName,
|
| 355 |
+
undefined,
|
| 356 |
+
undefined,
|
| 357 |
+
options
|
| 358 |
+
) +
|
| 359 |
+
'\n\n' +
|
| 360 |
+
(0, _print.printExpectedConstructorNameNot)(
|
| 361 |
+
'Expected constructor',
|
| 362 |
+
expected
|
| 363 |
+
) +
|
| 364 |
+
(typeof received.constructor === 'function' &&
|
| 365 |
+
received.constructor !== expected
|
| 366 |
+
? (0, _print.printReceivedConstructorNameNot)(
|
| 367 |
+
'Received constructor',
|
| 368 |
+
received.constructor,
|
| 369 |
+
expected
|
| 370 |
+
)
|
| 371 |
+
: '')
|
| 372 |
+
: () =>
|
| 373 |
+
// eslint-disable-next-line prefer-template
|
| 374 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 375 |
+
matcherName,
|
| 376 |
+
undefined,
|
| 377 |
+
undefined,
|
| 378 |
+
options
|
| 379 |
+
) +
|
| 380 |
+
'\n\n' +
|
| 381 |
+
(0, _print.printExpectedConstructorName)(
|
| 382 |
+
'Expected constructor',
|
| 383 |
+
expected
|
| 384 |
+
) +
|
| 385 |
+
((0, _jestGetType.isPrimitive)(received) ||
|
| 386 |
+
Object.getPrototypeOf(received) === null
|
| 387 |
+
? `\nReceived value has no prototype\nReceived value: ${(0,
|
| 388 |
+
_jestMatcherUtils.printReceived)(received)}`
|
| 389 |
+
: typeof received.constructor !== 'function'
|
| 390 |
+
? `\nReceived value: ${(0, _jestMatcherUtils.printReceived)(
|
| 391 |
+
received
|
| 392 |
+
)}`
|
| 393 |
+
: (0, _print.printReceivedConstructorName)(
|
| 394 |
+
'Received constructor',
|
| 395 |
+
received.constructor
|
| 396 |
+
));
|
| 397 |
+
return {
|
| 398 |
+
message,
|
| 399 |
+
pass
|
| 400 |
+
};
|
| 401 |
+
},
|
| 402 |
+
toBeLessThan(received, expected) {
|
| 403 |
+
const matcherName = 'toBeLessThan';
|
| 404 |
+
const isNot = this.isNot;
|
| 405 |
+
const options = {
|
| 406 |
+
isNot,
|
| 407 |
+
promise: this.promise
|
| 408 |
+
};
|
| 409 |
+
(0, _jestMatcherUtils.ensureNumbers)(
|
| 410 |
+
received,
|
| 411 |
+
expected,
|
| 412 |
+
matcherName,
|
| 413 |
+
options
|
| 414 |
+
);
|
| 415 |
+
const pass = received < expected;
|
| 416 |
+
const message = () =>
|
| 417 |
+
// eslint-disable-next-line prefer-template
|
| 418 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 419 |
+
matcherName,
|
| 420 |
+
undefined,
|
| 421 |
+
undefined,
|
| 422 |
+
options
|
| 423 |
+
) +
|
| 424 |
+
'\n\n' +
|
| 425 |
+
`Expected:${isNot ? ' not' : ''} < ${(0, _jestMatcherUtils.printExpected)(
|
| 426 |
+
expected
|
| 427 |
+
)}\n` +
|
| 428 |
+
`Received:${isNot ? ' ' : ''} ${(0, _jestMatcherUtils.printReceived)(
|
| 429 |
+
received
|
| 430 |
+
)}`;
|
| 431 |
+
return {
|
| 432 |
+
message,
|
| 433 |
+
pass
|
| 434 |
+
};
|
| 435 |
+
},
|
| 436 |
+
toBeLessThanOrEqual(received, expected) {
|
| 437 |
+
const matcherName = 'toBeLessThanOrEqual';
|
| 438 |
+
const isNot = this.isNot;
|
| 439 |
+
const options = {
|
| 440 |
+
isNot,
|
| 441 |
+
promise: this.promise
|
| 442 |
+
};
|
| 443 |
+
(0, _jestMatcherUtils.ensureNumbers)(
|
| 444 |
+
received,
|
| 445 |
+
expected,
|
| 446 |
+
matcherName,
|
| 447 |
+
options
|
| 448 |
+
);
|
| 449 |
+
const pass = received <= expected;
|
| 450 |
+
const message = () =>
|
| 451 |
+
// eslint-disable-next-line prefer-template
|
| 452 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 453 |
+
matcherName,
|
| 454 |
+
undefined,
|
| 455 |
+
undefined,
|
| 456 |
+
options
|
| 457 |
+
) +
|
| 458 |
+
'\n\n' +
|
| 459 |
+
`Expected:${isNot ? ' not' : ''} <= ${(0,
|
| 460 |
+
_jestMatcherUtils.printExpected)(expected)}\n` +
|
| 461 |
+
`Received:${isNot ? ' ' : ''} ${(0,
|
| 462 |
+
_jestMatcherUtils.printReceived)(received)}`;
|
| 463 |
+
return {
|
| 464 |
+
message,
|
| 465 |
+
pass
|
| 466 |
+
};
|
| 467 |
+
},
|
| 468 |
+
toBeNaN(received, expected) {
|
| 469 |
+
const matcherName = 'toBeNaN';
|
| 470 |
+
const options = {
|
| 471 |
+
isNot: this.isNot,
|
| 472 |
+
promise: this.promise
|
| 473 |
+
};
|
| 474 |
+
(0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options);
|
| 475 |
+
const pass = Number.isNaN(received);
|
| 476 |
+
const message = () =>
|
| 477 |
+
// eslint-disable-next-line prefer-template
|
| 478 |
+
(0, _jestMatcherUtils.matcherHint)(matcherName, undefined, '', options) +
|
| 479 |
+
'\n\n' +
|
| 480 |
+
`Received: ${(0, _jestMatcherUtils.printReceived)(received)}`;
|
| 481 |
+
return {
|
| 482 |
+
message,
|
| 483 |
+
pass
|
| 484 |
+
};
|
| 485 |
+
},
|
| 486 |
+
toBeNull(received, expected) {
|
| 487 |
+
const matcherName = 'toBeNull';
|
| 488 |
+
const options = {
|
| 489 |
+
isNot: this.isNot,
|
| 490 |
+
promise: this.promise
|
| 491 |
+
};
|
| 492 |
+
(0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options);
|
| 493 |
+
const pass = received === null;
|
| 494 |
+
const message = () =>
|
| 495 |
+
// eslint-disable-next-line prefer-template
|
| 496 |
+
(0, _jestMatcherUtils.matcherHint)(matcherName, undefined, '', options) +
|
| 497 |
+
'\n\n' +
|
| 498 |
+
`Received: ${(0, _jestMatcherUtils.printReceived)(received)}`;
|
| 499 |
+
return {
|
| 500 |
+
message,
|
| 501 |
+
pass
|
| 502 |
+
};
|
| 503 |
+
},
|
| 504 |
+
toBeTruthy(received, expected) {
|
| 505 |
+
const matcherName = 'toBeTruthy';
|
| 506 |
+
const options = {
|
| 507 |
+
isNot: this.isNot,
|
| 508 |
+
promise: this.promise
|
| 509 |
+
};
|
| 510 |
+
(0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options);
|
| 511 |
+
const pass = !!received;
|
| 512 |
+
const message = () =>
|
| 513 |
+
// eslint-disable-next-line prefer-template
|
| 514 |
+
(0, _jestMatcherUtils.matcherHint)(matcherName, undefined, '', options) +
|
| 515 |
+
'\n\n' +
|
| 516 |
+
`Received: ${(0, _jestMatcherUtils.printReceived)(received)}`;
|
| 517 |
+
return {
|
| 518 |
+
message,
|
| 519 |
+
pass
|
| 520 |
+
};
|
| 521 |
+
},
|
| 522 |
+
toBeUndefined(received, expected) {
|
| 523 |
+
const matcherName = 'toBeUndefined';
|
| 524 |
+
const options = {
|
| 525 |
+
isNot: this.isNot,
|
| 526 |
+
promise: this.promise
|
| 527 |
+
};
|
| 528 |
+
(0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options);
|
| 529 |
+
const pass = received === void 0;
|
| 530 |
+
const message = () =>
|
| 531 |
+
// eslint-disable-next-line prefer-template
|
| 532 |
+
(0, _jestMatcherUtils.matcherHint)(matcherName, undefined, '', options) +
|
| 533 |
+
'\n\n' +
|
| 534 |
+
`Received: ${(0, _jestMatcherUtils.printReceived)(received)}`;
|
| 535 |
+
return {
|
| 536 |
+
message,
|
| 537 |
+
pass
|
| 538 |
+
};
|
| 539 |
+
},
|
| 540 |
+
toContain(received, expected) {
|
| 541 |
+
const matcherName = 'toContain';
|
| 542 |
+
const isNot = this.isNot;
|
| 543 |
+
const options = {
|
| 544 |
+
comment: 'indexOf',
|
| 545 |
+
isNot,
|
| 546 |
+
promise: this.promise
|
| 547 |
+
};
|
| 548 |
+
if (received == null) {
|
| 549 |
+
throw new Error(
|
| 550 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 551 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 552 |
+
matcherName,
|
| 553 |
+
undefined,
|
| 554 |
+
undefined,
|
| 555 |
+
options
|
| 556 |
+
),
|
| 557 |
+
`${(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 558 |
+
'received'
|
| 559 |
+
)} value must not be null nor undefined`,
|
| 560 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 561 |
+
'Received',
|
| 562 |
+
received,
|
| 563 |
+
_jestMatcherUtils.printReceived
|
| 564 |
+
)
|
| 565 |
+
)
|
| 566 |
+
);
|
| 567 |
+
}
|
| 568 |
+
if (typeof received === 'string') {
|
| 569 |
+
const wrongTypeErrorMessage = `${(0, _jestMatcherUtils.EXPECTED_COLOR)(
|
| 570 |
+
'expected'
|
| 571 |
+
)} value must be a string if ${(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 572 |
+
'received'
|
| 573 |
+
)} value is a string`;
|
| 574 |
+
if (typeof expected !== 'string') {
|
| 575 |
+
throw new Error(
|
| 576 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 577 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 578 |
+
matcherName,
|
| 579 |
+
received,
|
| 580 |
+
String(expected),
|
| 581 |
+
options
|
| 582 |
+
),
|
| 583 |
+
wrongTypeErrorMessage,
|
| 584 |
+
// eslint-disable-next-line prefer-template
|
| 585 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 586 |
+
'Expected',
|
| 587 |
+
expected,
|
| 588 |
+
_jestMatcherUtils.printExpected
|
| 589 |
+
) +
|
| 590 |
+
'\n' +
|
| 591 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 592 |
+
'Received',
|
| 593 |
+
received,
|
| 594 |
+
_jestMatcherUtils.printReceived
|
| 595 |
+
)
|
| 596 |
+
)
|
| 597 |
+
);
|
| 598 |
+
}
|
| 599 |
+
const index = received.indexOf(String(expected));
|
| 600 |
+
const pass = index !== -1;
|
| 601 |
+
const message = () => {
|
| 602 |
+
const labelExpected = `Expected ${
|
| 603 |
+
typeof expected === 'string' ? 'substring' : 'value'
|
| 604 |
+
}`;
|
| 605 |
+
const labelReceived = 'Received string';
|
| 606 |
+
const printLabel = (0, _jestMatcherUtils.getLabelPrinter)(
|
| 607 |
+
labelExpected,
|
| 608 |
+
labelReceived
|
| 609 |
+
);
|
| 610 |
+
return (
|
| 611 |
+
// eslint-disable-next-line prefer-template
|
| 612 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 613 |
+
matcherName,
|
| 614 |
+
undefined,
|
| 615 |
+
undefined,
|
| 616 |
+
options
|
| 617 |
+
) +
|
| 618 |
+
'\n\n' +
|
| 619 |
+
`${printLabel(labelExpected)}${isNot ? 'not ' : ''}${(0,
|
| 620 |
+
_jestMatcherUtils.printExpected)(expected)}\n` +
|
| 621 |
+
`${printLabel(labelReceived)}${isNot ? ' ' : ''}${
|
| 622 |
+
isNot
|
| 623 |
+
? (0, _print.printReceivedStringContainExpectedSubstring)(
|
| 624 |
+
received,
|
| 625 |
+
index,
|
| 626 |
+
String(expected).length
|
| 627 |
+
)
|
| 628 |
+
: (0, _jestMatcherUtils.printReceived)(received)
|
| 629 |
+
}`
|
| 630 |
+
);
|
| 631 |
+
};
|
| 632 |
+
return {
|
| 633 |
+
message,
|
| 634 |
+
pass
|
| 635 |
+
};
|
| 636 |
+
}
|
| 637 |
+
const indexable = Array.from(received);
|
| 638 |
+
const index = indexable.indexOf(expected);
|
| 639 |
+
const pass = index !== -1;
|
| 640 |
+
const message = () => {
|
| 641 |
+
const labelExpected = 'Expected value';
|
| 642 |
+
const labelReceived = `Received ${(0, _jestGetType.getType)(received)}`;
|
| 643 |
+
const printLabel = (0, _jestMatcherUtils.getLabelPrinter)(
|
| 644 |
+
labelExpected,
|
| 645 |
+
labelReceived
|
| 646 |
+
);
|
| 647 |
+
return (
|
| 648 |
+
// eslint-disable-next-line prefer-template
|
| 649 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 650 |
+
matcherName,
|
| 651 |
+
undefined,
|
| 652 |
+
undefined,
|
| 653 |
+
options
|
| 654 |
+
) +
|
| 655 |
+
'\n\n' +
|
| 656 |
+
`${printLabel(labelExpected)}${isNot ? 'not ' : ''}${(0,
|
| 657 |
+
_jestMatcherUtils.printExpected)(expected)}\n` +
|
| 658 |
+
`${printLabel(labelReceived)}${isNot ? ' ' : ''}${
|
| 659 |
+
isNot && Array.isArray(received)
|
| 660 |
+
? (0, _print.printReceivedArrayContainExpectedItem)(received, index)
|
| 661 |
+
: (0, _jestMatcherUtils.printReceived)(received)
|
| 662 |
+
}` +
|
| 663 |
+
(!isNot &&
|
| 664 |
+
indexable.findIndex(item =>
|
| 665 |
+
(0, _expectUtils.equals)(item, expected, [
|
| 666 |
+
...this.customTesters,
|
| 667 |
+
_expectUtils.iterableEquality
|
| 668 |
+
])
|
| 669 |
+
) !== -1
|
| 670 |
+
? `\n\n${_jestMatcherUtils.SUGGEST_TO_CONTAIN_EQUAL}`
|
| 671 |
+
: '')
|
| 672 |
+
);
|
| 673 |
+
};
|
| 674 |
+
return {
|
| 675 |
+
message,
|
| 676 |
+
pass
|
| 677 |
+
};
|
| 678 |
+
},
|
| 679 |
+
toContainEqual(received, expected) {
|
| 680 |
+
const matcherName = 'toContainEqual';
|
| 681 |
+
const isNot = this.isNot;
|
| 682 |
+
const options = {
|
| 683 |
+
comment: 'deep equality',
|
| 684 |
+
isNot,
|
| 685 |
+
promise: this.promise
|
| 686 |
+
};
|
| 687 |
+
if (received == null) {
|
| 688 |
+
throw new Error(
|
| 689 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 690 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 691 |
+
matcherName,
|
| 692 |
+
undefined,
|
| 693 |
+
undefined,
|
| 694 |
+
options
|
| 695 |
+
),
|
| 696 |
+
`${(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 697 |
+
'received'
|
| 698 |
+
)} value must not be null nor undefined`,
|
| 699 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 700 |
+
'Received',
|
| 701 |
+
received,
|
| 702 |
+
_jestMatcherUtils.printReceived
|
| 703 |
+
)
|
| 704 |
+
)
|
| 705 |
+
);
|
| 706 |
+
}
|
| 707 |
+
const index = Array.from(received).findIndex(item =>
|
| 708 |
+
(0, _expectUtils.equals)(item, expected, [
|
| 709 |
+
...this.customTesters,
|
| 710 |
+
_expectUtils.iterableEquality
|
| 711 |
+
])
|
| 712 |
+
);
|
| 713 |
+
const pass = index !== -1;
|
| 714 |
+
const message = () => {
|
| 715 |
+
const labelExpected = 'Expected value';
|
| 716 |
+
const labelReceived = `Received ${(0, _jestGetType.getType)(received)}`;
|
| 717 |
+
const printLabel = (0, _jestMatcherUtils.getLabelPrinter)(
|
| 718 |
+
labelExpected,
|
| 719 |
+
labelReceived
|
| 720 |
+
);
|
| 721 |
+
return (
|
| 722 |
+
// eslint-disable-next-line prefer-template
|
| 723 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 724 |
+
matcherName,
|
| 725 |
+
undefined,
|
| 726 |
+
undefined,
|
| 727 |
+
options
|
| 728 |
+
) +
|
| 729 |
+
'\n\n' +
|
| 730 |
+
`${printLabel(labelExpected)}${isNot ? 'not ' : ''}${(0,
|
| 731 |
+
_jestMatcherUtils.printExpected)(expected)}\n` +
|
| 732 |
+
`${printLabel(labelReceived)}${isNot ? ' ' : ''}${
|
| 733 |
+
isNot && Array.isArray(received)
|
| 734 |
+
? (0, _print.printReceivedArrayContainExpectedItem)(received, index)
|
| 735 |
+
: (0, _jestMatcherUtils.printReceived)(received)
|
| 736 |
+
}`
|
| 737 |
+
);
|
| 738 |
+
};
|
| 739 |
+
return {
|
| 740 |
+
message,
|
| 741 |
+
pass
|
| 742 |
+
};
|
| 743 |
+
},
|
| 744 |
+
toEqual(received, expected) {
|
| 745 |
+
const matcherName = 'toEqual';
|
| 746 |
+
const options = {
|
| 747 |
+
comment: 'deep equality',
|
| 748 |
+
isNot: this.isNot,
|
| 749 |
+
promise: this.promise
|
| 750 |
+
};
|
| 751 |
+
const pass = (0, _expectUtils.equals)(received, expected, [
|
| 752 |
+
...this.customTesters,
|
| 753 |
+
_expectUtils.iterableEquality
|
| 754 |
+
]);
|
| 755 |
+
const message = pass
|
| 756 |
+
? () =>
|
| 757 |
+
// eslint-disable-next-line prefer-template
|
| 758 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 759 |
+
matcherName,
|
| 760 |
+
undefined,
|
| 761 |
+
undefined,
|
| 762 |
+
options
|
| 763 |
+
) +
|
| 764 |
+
'\n\n' +
|
| 765 |
+
`Expected: not ${(0, _jestMatcherUtils.printExpected)(expected)}\n` +
|
| 766 |
+
((0, _jestMatcherUtils.stringify)(expected) !==
|
| 767 |
+
(0, _jestMatcherUtils.stringify)(received)
|
| 768 |
+
? `Received: ${(0, _jestMatcherUtils.printReceived)(received)}`
|
| 769 |
+
: '')
|
| 770 |
+
: () =>
|
| 771 |
+
// eslint-disable-next-line prefer-template
|
| 772 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 773 |
+
matcherName,
|
| 774 |
+
undefined,
|
| 775 |
+
undefined,
|
| 776 |
+
options
|
| 777 |
+
) +
|
| 778 |
+
'\n\n' +
|
| 779 |
+
(0, _jestMatcherUtils.printDiffOrStringify)(
|
| 780 |
+
expected,
|
| 781 |
+
received,
|
| 782 |
+
EXPECTED_LABEL,
|
| 783 |
+
RECEIVED_LABEL,
|
| 784 |
+
isExpand(this.expand)
|
| 785 |
+
);
|
| 786 |
+
|
| 787 |
+
// Passing the actual and expected objects so that a custom reporter
|
| 788 |
+
// could access them, for example in order to display a custom visual diff,
|
| 789 |
+
// or create a different error message
|
| 790 |
+
return {
|
| 791 |
+
actual: received,
|
| 792 |
+
expected,
|
| 793 |
+
message,
|
| 794 |
+
name: matcherName,
|
| 795 |
+
pass
|
| 796 |
+
};
|
| 797 |
+
},
|
| 798 |
+
toHaveLength(received, expected) {
|
| 799 |
+
const matcherName = 'toHaveLength';
|
| 800 |
+
const isNot = this.isNot;
|
| 801 |
+
const options = {
|
| 802 |
+
isNot,
|
| 803 |
+
promise: this.promise
|
| 804 |
+
};
|
| 805 |
+
if (typeof received?.length !== 'number') {
|
| 806 |
+
throw new Error(
|
| 807 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 808 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 809 |
+
matcherName,
|
| 810 |
+
undefined,
|
| 811 |
+
undefined,
|
| 812 |
+
options
|
| 813 |
+
),
|
| 814 |
+
`${(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 815 |
+
'received'
|
| 816 |
+
)} value must have a length property whose value must be a number`,
|
| 817 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 818 |
+
'Received',
|
| 819 |
+
received,
|
| 820 |
+
_jestMatcherUtils.printReceived
|
| 821 |
+
)
|
| 822 |
+
)
|
| 823 |
+
);
|
| 824 |
+
}
|
| 825 |
+
(0, _jestMatcherUtils.ensureExpectedIsNonNegativeInteger)(
|
| 826 |
+
expected,
|
| 827 |
+
matcherName,
|
| 828 |
+
options
|
| 829 |
+
);
|
| 830 |
+
const pass = received.length === expected;
|
| 831 |
+
const message = () => {
|
| 832 |
+
const labelExpected = 'Expected length';
|
| 833 |
+
const labelReceivedLength = 'Received length';
|
| 834 |
+
const labelReceivedValue = `Received ${(0, _jestGetType.getType)(
|
| 835 |
+
received
|
| 836 |
+
)}`;
|
| 837 |
+
const printLabel = (0, _jestMatcherUtils.getLabelPrinter)(
|
| 838 |
+
labelExpected,
|
| 839 |
+
labelReceivedLength,
|
| 840 |
+
labelReceivedValue
|
| 841 |
+
);
|
| 842 |
+
return (
|
| 843 |
+
// eslint-disable-next-line prefer-template
|
| 844 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 845 |
+
matcherName,
|
| 846 |
+
undefined,
|
| 847 |
+
undefined,
|
| 848 |
+
options
|
| 849 |
+
) +
|
| 850 |
+
'\n\n' +
|
| 851 |
+
`${printLabel(labelExpected)}${isNot ? 'not ' : ''}${(0,
|
| 852 |
+
_jestMatcherUtils.printExpected)(expected)}\n` +
|
| 853 |
+
(isNot
|
| 854 |
+
? ''
|
| 855 |
+
: `${printLabel(labelReceivedLength)}${(0,
|
| 856 |
+
_jestMatcherUtils.printReceived)(received.length)}\n`) +
|
| 857 |
+
`${printLabel(labelReceivedValue)}${isNot ? ' ' : ''}${(0,
|
| 858 |
+
_jestMatcherUtils.printReceived)(received)}`
|
| 859 |
+
);
|
| 860 |
+
};
|
| 861 |
+
return {
|
| 862 |
+
message,
|
| 863 |
+
pass
|
| 864 |
+
};
|
| 865 |
+
},
|
| 866 |
+
toHaveProperty(received, expectedPath, expectedValue) {
|
| 867 |
+
const matcherName = 'toHaveProperty';
|
| 868 |
+
const expectedArgument = 'path';
|
| 869 |
+
const hasValue = arguments.length === 3;
|
| 870 |
+
const options = {
|
| 871 |
+
isNot: this.isNot,
|
| 872 |
+
promise: this.promise,
|
| 873 |
+
secondArgument: hasValue ? 'value' : ''
|
| 874 |
+
};
|
| 875 |
+
if (received === null || received === undefined) {
|
| 876 |
+
throw new Error(
|
| 877 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 878 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 879 |
+
matcherName,
|
| 880 |
+
undefined,
|
| 881 |
+
expectedArgument,
|
| 882 |
+
options
|
| 883 |
+
),
|
| 884 |
+
`${(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 885 |
+
'received'
|
| 886 |
+
)} value must not be null nor undefined`,
|
| 887 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 888 |
+
'Received',
|
| 889 |
+
received,
|
| 890 |
+
_jestMatcherUtils.printReceived
|
| 891 |
+
)
|
| 892 |
+
)
|
| 893 |
+
);
|
| 894 |
+
}
|
| 895 |
+
const expectedPathType = (0, _jestGetType.getType)(expectedPath);
|
| 896 |
+
if (expectedPathType !== 'string' && expectedPathType !== 'array') {
|
| 897 |
+
throw new Error(
|
| 898 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 899 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 900 |
+
matcherName,
|
| 901 |
+
undefined,
|
| 902 |
+
expectedArgument,
|
| 903 |
+
options
|
| 904 |
+
),
|
| 905 |
+
`${(0, _jestMatcherUtils.EXPECTED_COLOR)(
|
| 906 |
+
'expected'
|
| 907 |
+
)} path must be a string or array`,
|
| 908 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 909 |
+
'Expected',
|
| 910 |
+
expectedPath,
|
| 911 |
+
_jestMatcherUtils.printExpected
|
| 912 |
+
)
|
| 913 |
+
)
|
| 914 |
+
);
|
| 915 |
+
}
|
| 916 |
+
const expectedPathLength =
|
| 917 |
+
typeof expectedPath === 'string'
|
| 918 |
+
? (0, _expectUtils.pathAsArray)(expectedPath).length
|
| 919 |
+
: expectedPath.length;
|
| 920 |
+
if (expectedPathType === 'array' && expectedPathLength === 0) {
|
| 921 |
+
throw new Error(
|
| 922 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 923 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 924 |
+
matcherName,
|
| 925 |
+
undefined,
|
| 926 |
+
expectedArgument,
|
| 927 |
+
options
|
| 928 |
+
),
|
| 929 |
+
`${(0, _jestMatcherUtils.EXPECTED_COLOR)(
|
| 930 |
+
'expected'
|
| 931 |
+
)} path must not be an empty array`,
|
| 932 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 933 |
+
'Expected',
|
| 934 |
+
expectedPath,
|
| 935 |
+
_jestMatcherUtils.printExpected
|
| 936 |
+
)
|
| 937 |
+
)
|
| 938 |
+
);
|
| 939 |
+
}
|
| 940 |
+
const result = (0, _expectUtils.getPath)(received, expectedPath);
|
| 941 |
+
const {lastTraversedObject, endPropIsDefined, hasEndProp, value} = result;
|
| 942 |
+
const receivedPath = result.traversedPath;
|
| 943 |
+
const hasCompletePath = receivedPath.length === expectedPathLength;
|
| 944 |
+
const receivedValue = hasCompletePath ? result.value : lastTraversedObject;
|
| 945 |
+
const pass =
|
| 946 |
+
hasValue && endPropIsDefined
|
| 947 |
+
? (0, _expectUtils.equals)(value, expectedValue, [
|
| 948 |
+
...this.customTesters,
|
| 949 |
+
_expectUtils.iterableEquality
|
| 950 |
+
])
|
| 951 |
+
: Boolean(hasEndProp);
|
| 952 |
+
const message = pass
|
| 953 |
+
? () =>
|
| 954 |
+
// eslint-disable-next-line prefer-template
|
| 955 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 956 |
+
matcherName,
|
| 957 |
+
undefined,
|
| 958 |
+
expectedArgument,
|
| 959 |
+
options
|
| 960 |
+
) +
|
| 961 |
+
'\n\n' +
|
| 962 |
+
(hasValue
|
| 963 |
+
? `Expected path: ${(0, _jestMatcherUtils.printExpected)(
|
| 964 |
+
expectedPath
|
| 965 |
+
)}\n\n` +
|
| 966 |
+
`Expected value: not ${(0, _jestMatcherUtils.printExpected)(
|
| 967 |
+
expectedValue
|
| 968 |
+
)}${
|
| 969 |
+
(0, _jestMatcherUtils.stringify)(expectedValue) !==
|
| 970 |
+
(0, _jestMatcherUtils.stringify)(receivedValue)
|
| 971 |
+
? `\nReceived value: ${(0,
|
| 972 |
+
_jestMatcherUtils.printReceived)(receivedValue)}`
|
| 973 |
+
: ''
|
| 974 |
+
}`
|
| 975 |
+
: `Expected path: not ${(0, _jestMatcherUtils.printExpected)(
|
| 976 |
+
expectedPath
|
| 977 |
+
)}\n\n` +
|
| 978 |
+
`Received value: ${(0, _jestMatcherUtils.printReceived)(
|
| 979 |
+
receivedValue
|
| 980 |
+
)}`)
|
| 981 |
+
: () =>
|
| 982 |
+
// eslint-disable-next-line prefer-template
|
| 983 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 984 |
+
matcherName,
|
| 985 |
+
undefined,
|
| 986 |
+
expectedArgument,
|
| 987 |
+
options
|
| 988 |
+
) +
|
| 989 |
+
'\n\n' +
|
| 990 |
+
`Expected path: ${(0, _jestMatcherUtils.printExpected)(
|
| 991 |
+
expectedPath
|
| 992 |
+
)}\n` +
|
| 993 |
+
(hasCompletePath
|
| 994 |
+
? `\n${(0, _jestMatcherUtils.printDiffOrStringify)(
|
| 995 |
+
expectedValue,
|
| 996 |
+
receivedValue,
|
| 997 |
+
EXPECTED_VALUE_LABEL,
|
| 998 |
+
RECEIVED_VALUE_LABEL,
|
| 999 |
+
isExpand(this.expand)
|
| 1000 |
+
)}`
|
| 1001 |
+
: `Received path: ${(0, _jestMatcherUtils.printReceived)(
|
| 1002 |
+
expectedPathType === 'array' || receivedPath.length === 0
|
| 1003 |
+
? receivedPath
|
| 1004 |
+
: receivedPath.join('.')
|
| 1005 |
+
)}\n\n${
|
| 1006 |
+
hasValue
|
| 1007 |
+
? `Expected value: ${(0, _jestMatcherUtils.printExpected)(
|
| 1008 |
+
expectedValue
|
| 1009 |
+
)}\n`
|
| 1010 |
+
: ''
|
| 1011 |
+
}Received value: ${(0, _jestMatcherUtils.printReceived)(
|
| 1012 |
+
receivedValue
|
| 1013 |
+
)}`);
|
| 1014 |
+
return {
|
| 1015 |
+
message,
|
| 1016 |
+
pass
|
| 1017 |
+
};
|
| 1018 |
+
},
|
| 1019 |
+
toMatch(received, expected) {
|
| 1020 |
+
const matcherName = 'toMatch';
|
| 1021 |
+
const options = {
|
| 1022 |
+
isNot: this.isNot,
|
| 1023 |
+
promise: this.promise
|
| 1024 |
+
};
|
| 1025 |
+
if (typeof received !== 'string') {
|
| 1026 |
+
throw new Error(
|
| 1027 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 1028 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1029 |
+
matcherName,
|
| 1030 |
+
undefined,
|
| 1031 |
+
undefined,
|
| 1032 |
+
options
|
| 1033 |
+
),
|
| 1034 |
+
`${(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 1035 |
+
'received'
|
| 1036 |
+
)} value must be a string`,
|
| 1037 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 1038 |
+
'Received',
|
| 1039 |
+
received,
|
| 1040 |
+
_jestMatcherUtils.printReceived
|
| 1041 |
+
)
|
| 1042 |
+
)
|
| 1043 |
+
);
|
| 1044 |
+
}
|
| 1045 |
+
if (
|
| 1046 |
+
!(typeof expected === 'string') &&
|
| 1047 |
+
!(expected && typeof expected.test === 'function')
|
| 1048 |
+
) {
|
| 1049 |
+
throw new Error(
|
| 1050 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 1051 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1052 |
+
matcherName,
|
| 1053 |
+
undefined,
|
| 1054 |
+
undefined,
|
| 1055 |
+
options
|
| 1056 |
+
),
|
| 1057 |
+
`${(0, _jestMatcherUtils.EXPECTED_COLOR)(
|
| 1058 |
+
'expected'
|
| 1059 |
+
)} value must be a string or regular expression`,
|
| 1060 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 1061 |
+
'Expected',
|
| 1062 |
+
expected,
|
| 1063 |
+
_jestMatcherUtils.printExpected
|
| 1064 |
+
)
|
| 1065 |
+
)
|
| 1066 |
+
);
|
| 1067 |
+
}
|
| 1068 |
+
const pass =
|
| 1069 |
+
typeof expected === 'string'
|
| 1070 |
+
? received.includes(expected)
|
| 1071 |
+
: new RegExp(expected).test(received);
|
| 1072 |
+
const message = pass
|
| 1073 |
+
? () =>
|
| 1074 |
+
typeof expected === 'string'
|
| 1075 |
+
? // eslint-disable-next-line prefer-template
|
| 1076 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1077 |
+
matcherName,
|
| 1078 |
+
undefined,
|
| 1079 |
+
undefined,
|
| 1080 |
+
options
|
| 1081 |
+
) +
|
| 1082 |
+
'\n\n' +
|
| 1083 |
+
`Expected substring: not ${(0, _jestMatcherUtils.printExpected)(
|
| 1084 |
+
expected
|
| 1085 |
+
)}\n` +
|
| 1086 |
+
`Received string: ${(0,
|
| 1087 |
+
_print.printReceivedStringContainExpectedSubstring)(
|
| 1088 |
+
received,
|
| 1089 |
+
received.indexOf(expected),
|
| 1090 |
+
expected.length
|
| 1091 |
+
)}`
|
| 1092 |
+
: // eslint-disable-next-line prefer-template
|
| 1093 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1094 |
+
matcherName,
|
| 1095 |
+
undefined,
|
| 1096 |
+
undefined,
|
| 1097 |
+
options
|
| 1098 |
+
) +
|
| 1099 |
+
'\n\n' +
|
| 1100 |
+
`Expected pattern: not ${(0, _jestMatcherUtils.printExpected)(
|
| 1101 |
+
expected
|
| 1102 |
+
)}\n` +
|
| 1103 |
+
`Received string: ${(0,
|
| 1104 |
+
_print.printReceivedStringContainExpectedResult)(
|
| 1105 |
+
received,
|
| 1106 |
+
typeof expected.exec === 'function'
|
| 1107 |
+
? expected.exec(received)
|
| 1108 |
+
: null
|
| 1109 |
+
)}`
|
| 1110 |
+
: () => {
|
| 1111 |
+
const labelExpected = `Expected ${
|
| 1112 |
+
typeof expected === 'string' ? 'substring' : 'pattern'
|
| 1113 |
+
}`;
|
| 1114 |
+
const labelReceived = 'Received string';
|
| 1115 |
+
const printLabel = (0, _jestMatcherUtils.getLabelPrinter)(
|
| 1116 |
+
labelExpected,
|
| 1117 |
+
labelReceived
|
| 1118 |
+
);
|
| 1119 |
+
return (
|
| 1120 |
+
// eslint-disable-next-line prefer-template
|
| 1121 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1122 |
+
matcherName,
|
| 1123 |
+
undefined,
|
| 1124 |
+
undefined,
|
| 1125 |
+
options
|
| 1126 |
+
) +
|
| 1127 |
+
'\n\n' +
|
| 1128 |
+
`${printLabel(labelExpected)}${(0, _jestMatcherUtils.printExpected)(
|
| 1129 |
+
expected
|
| 1130 |
+
)}\n` +
|
| 1131 |
+
`${printLabel(labelReceived)}${(0, _jestMatcherUtils.printReceived)(
|
| 1132 |
+
received
|
| 1133 |
+
)}`
|
| 1134 |
+
);
|
| 1135 |
+
};
|
| 1136 |
+
return {
|
| 1137 |
+
message,
|
| 1138 |
+
pass
|
| 1139 |
+
};
|
| 1140 |
+
},
|
| 1141 |
+
toMatchObject(received, expected) {
|
| 1142 |
+
const matcherName = 'toMatchObject';
|
| 1143 |
+
const options = {
|
| 1144 |
+
isNot: this.isNot,
|
| 1145 |
+
promise: this.promise
|
| 1146 |
+
};
|
| 1147 |
+
if (typeof received !== 'object' || received === null) {
|
| 1148 |
+
throw new Error(
|
| 1149 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 1150 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1151 |
+
matcherName,
|
| 1152 |
+
undefined,
|
| 1153 |
+
undefined,
|
| 1154 |
+
options
|
| 1155 |
+
),
|
| 1156 |
+
`${(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 1157 |
+
'received'
|
| 1158 |
+
)} value must be a non-null object`,
|
| 1159 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 1160 |
+
'Received',
|
| 1161 |
+
received,
|
| 1162 |
+
_jestMatcherUtils.printReceived
|
| 1163 |
+
)
|
| 1164 |
+
)
|
| 1165 |
+
);
|
| 1166 |
+
}
|
| 1167 |
+
if (typeof expected !== 'object' || expected === null) {
|
| 1168 |
+
throw new Error(
|
| 1169 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 1170 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1171 |
+
matcherName,
|
| 1172 |
+
undefined,
|
| 1173 |
+
undefined,
|
| 1174 |
+
options
|
| 1175 |
+
),
|
| 1176 |
+
`${(0, _jestMatcherUtils.EXPECTED_COLOR)(
|
| 1177 |
+
'expected'
|
| 1178 |
+
)} value must be a non-null object`,
|
| 1179 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 1180 |
+
'Expected',
|
| 1181 |
+
expected,
|
| 1182 |
+
_jestMatcherUtils.printExpected
|
| 1183 |
+
)
|
| 1184 |
+
)
|
| 1185 |
+
);
|
| 1186 |
+
}
|
| 1187 |
+
const pass = (0, _expectUtils.equals)(received, expected, [
|
| 1188 |
+
...this.customTesters,
|
| 1189 |
+
_expectUtils.iterableEquality,
|
| 1190 |
+
_expectUtils.subsetEquality
|
| 1191 |
+
]);
|
| 1192 |
+
const message = pass
|
| 1193 |
+
? () =>
|
| 1194 |
+
// eslint-disable-next-line prefer-template
|
| 1195 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1196 |
+
matcherName,
|
| 1197 |
+
undefined,
|
| 1198 |
+
undefined,
|
| 1199 |
+
options
|
| 1200 |
+
) +
|
| 1201 |
+
'\n\n' +
|
| 1202 |
+
`Expected: not ${(0, _jestMatcherUtils.printExpected)(expected)}` +
|
| 1203 |
+
((0, _jestMatcherUtils.stringify)(expected) !==
|
| 1204 |
+
(0, _jestMatcherUtils.stringify)(received)
|
| 1205 |
+
? `\nReceived: ${(0, _jestMatcherUtils.printReceived)(
|
| 1206 |
+
received
|
| 1207 |
+
)}`
|
| 1208 |
+
: '')
|
| 1209 |
+
: () =>
|
| 1210 |
+
// eslint-disable-next-line prefer-template
|
| 1211 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1212 |
+
matcherName,
|
| 1213 |
+
undefined,
|
| 1214 |
+
undefined,
|
| 1215 |
+
options
|
| 1216 |
+
) +
|
| 1217 |
+
'\n\n' +
|
| 1218 |
+
(0, _jestMatcherUtils.printDiffOrStringify)(
|
| 1219 |
+
expected,
|
| 1220 |
+
(0, _expectUtils.getObjectSubset)(
|
| 1221 |
+
received,
|
| 1222 |
+
expected,
|
| 1223 |
+
this.customTesters
|
| 1224 |
+
),
|
| 1225 |
+
EXPECTED_LABEL,
|
| 1226 |
+
RECEIVED_LABEL,
|
| 1227 |
+
isExpand(this.expand)
|
| 1228 |
+
);
|
| 1229 |
+
return {
|
| 1230 |
+
message,
|
| 1231 |
+
pass
|
| 1232 |
+
};
|
| 1233 |
+
},
|
| 1234 |
+
toStrictEqual(received, expected) {
|
| 1235 |
+
const matcherName = 'toStrictEqual';
|
| 1236 |
+
const options = {
|
| 1237 |
+
comment: 'deep equality',
|
| 1238 |
+
isNot: this.isNot,
|
| 1239 |
+
promise: this.promise
|
| 1240 |
+
};
|
| 1241 |
+
const pass = (0, _expectUtils.equals)(
|
| 1242 |
+
received,
|
| 1243 |
+
expected,
|
| 1244 |
+
[...this.customTesters, ...toStrictEqualTesters],
|
| 1245 |
+
true
|
| 1246 |
+
);
|
| 1247 |
+
const message = pass
|
| 1248 |
+
? () =>
|
| 1249 |
+
// eslint-disable-next-line prefer-template
|
| 1250 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1251 |
+
matcherName,
|
| 1252 |
+
undefined,
|
| 1253 |
+
undefined,
|
| 1254 |
+
options
|
| 1255 |
+
) +
|
| 1256 |
+
'\n\n' +
|
| 1257 |
+
`Expected: not ${(0, _jestMatcherUtils.printExpected)(expected)}\n` +
|
| 1258 |
+
((0, _jestMatcherUtils.stringify)(expected) !==
|
| 1259 |
+
(0, _jestMatcherUtils.stringify)(received)
|
| 1260 |
+
? `Received: ${(0, _jestMatcherUtils.printReceived)(received)}`
|
| 1261 |
+
: '')
|
| 1262 |
+
: () =>
|
| 1263 |
+
// eslint-disable-next-line prefer-template
|
| 1264 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1265 |
+
matcherName,
|
| 1266 |
+
undefined,
|
| 1267 |
+
undefined,
|
| 1268 |
+
options
|
| 1269 |
+
) +
|
| 1270 |
+
'\n\n' +
|
| 1271 |
+
(0, _jestMatcherUtils.printDiffOrStringify)(
|
| 1272 |
+
expected,
|
| 1273 |
+
received,
|
| 1274 |
+
EXPECTED_LABEL,
|
| 1275 |
+
RECEIVED_LABEL,
|
| 1276 |
+
isExpand(this.expand)
|
| 1277 |
+
);
|
| 1278 |
+
|
| 1279 |
+
// Passing the actual and expected objects so that a custom reporter
|
| 1280 |
+
// could access them, for example in order to display a custom visual diff,
|
| 1281 |
+
// or create a different error message
|
| 1282 |
+
return {
|
| 1283 |
+
actual: received,
|
| 1284 |
+
expected,
|
| 1285 |
+
message,
|
| 1286 |
+
name: matcherName,
|
| 1287 |
+
pass
|
| 1288 |
+
};
|
| 1289 |
+
}
|
| 1290 |
+
};
|
| 1291 |
+
var _default = matchers;
|
| 1292 |
+
exports.default = _default;
|
novas/novacore-zephyr/claude-code-router/node_modules/expect/build/print.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.printReceivedStringContainExpectedSubstring =
|
| 7 |
+
exports.printReceivedStringContainExpectedResult =
|
| 8 |
+
exports.printReceivedConstructorNameNot =
|
| 9 |
+
exports.printReceivedConstructorName =
|
| 10 |
+
exports.printReceivedArrayContainExpectedItem =
|
| 11 |
+
exports.printExpectedConstructorNameNot =
|
| 12 |
+
exports.printExpectedConstructorName =
|
| 13 |
+
exports.printCloseTo =
|
| 14 |
+
void 0;
|
| 15 |
+
var _jestMatcherUtils = require('jest-matcher-utils');
|
| 16 |
+
/**
|
| 17 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 18 |
+
*
|
| 19 |
+
* This source code is licensed under the MIT license found in the
|
| 20 |
+
* LICENSE file in the root directory of this source tree.
|
| 21 |
+
*
|
| 22 |
+
*/
|
| 23 |
+
|
| 24 |
+
/* eslint-disable local/ban-types-eventually */
|
| 25 |
+
|
| 26 |
+
// Format substring but do not enclose in double quote marks.
|
| 27 |
+
// The replacement is compatible with pretty-format package.
|
| 28 |
+
const printSubstring = val => val.replace(/"|\\/g, '\\$&');
|
| 29 |
+
const printReceivedStringContainExpectedSubstring = (
|
| 30 |
+
received,
|
| 31 |
+
start,
|
| 32 |
+
length // not end
|
| 33 |
+
) =>
|
| 34 |
+
(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 35 |
+
`"${printSubstring(received.slice(0, start))}${(0,
|
| 36 |
+
_jestMatcherUtils.INVERTED_COLOR)(
|
| 37 |
+
printSubstring(received.slice(start, start + length))
|
| 38 |
+
)}${printSubstring(received.slice(start + length))}"`
|
| 39 |
+
);
|
| 40 |
+
exports.printReceivedStringContainExpectedSubstring =
|
| 41 |
+
printReceivedStringContainExpectedSubstring;
|
| 42 |
+
const printReceivedStringContainExpectedResult = (received, result) =>
|
| 43 |
+
result === null
|
| 44 |
+
? (0, _jestMatcherUtils.printReceived)(received)
|
| 45 |
+
: printReceivedStringContainExpectedSubstring(
|
| 46 |
+
received,
|
| 47 |
+
result.index,
|
| 48 |
+
result[0].length
|
| 49 |
+
);
|
| 50 |
+
|
| 51 |
+
// The serialized array is compatible with pretty-format package min option.
|
| 52 |
+
// However, items have default stringify depth (instead of depth - 1)
|
| 53 |
+
// so expected item looks consistent by itself and enclosed in the array.
|
| 54 |
+
exports.printReceivedStringContainExpectedResult =
|
| 55 |
+
printReceivedStringContainExpectedResult;
|
| 56 |
+
const printReceivedArrayContainExpectedItem = (received, index) =>
|
| 57 |
+
(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 58 |
+
`[${received
|
| 59 |
+
.map((item, i) => {
|
| 60 |
+
const stringified = (0, _jestMatcherUtils.stringify)(item);
|
| 61 |
+
return i === index
|
| 62 |
+
? (0, _jestMatcherUtils.INVERTED_COLOR)(stringified)
|
| 63 |
+
: stringified;
|
| 64 |
+
})
|
| 65 |
+
.join(', ')}]`
|
| 66 |
+
);
|
| 67 |
+
exports.printReceivedArrayContainExpectedItem =
|
| 68 |
+
printReceivedArrayContainExpectedItem;
|
| 69 |
+
const printCloseTo = (receivedDiff, expectedDiff, precision, isNot) => {
|
| 70 |
+
const receivedDiffString = (0, _jestMatcherUtils.stringify)(receivedDiff);
|
| 71 |
+
const expectedDiffString = receivedDiffString.includes('e')
|
| 72 |
+
? // toExponential arg is number of digits after the decimal point.
|
| 73 |
+
expectedDiff.toExponential(0)
|
| 74 |
+
: 0 <= precision && precision < 20
|
| 75 |
+
? // toFixed arg is number of digits after the decimal point.
|
| 76 |
+
// It may be a value between 0 and 20 inclusive.
|
| 77 |
+
// Implementations may optionally support a larger range of values.
|
| 78 |
+
expectedDiff.toFixed(precision + 1)
|
| 79 |
+
: (0, _jestMatcherUtils.stringify)(expectedDiff);
|
| 80 |
+
return (
|
| 81 |
+
`Expected precision: ${isNot ? ' ' : ''} ${(0,
|
| 82 |
+
_jestMatcherUtils.stringify)(precision)}\n` +
|
| 83 |
+
`Expected difference: ${isNot ? 'not ' : ''}< ${(0,
|
| 84 |
+
_jestMatcherUtils.EXPECTED_COLOR)(expectedDiffString)}\n` +
|
| 85 |
+
`Received difference: ${isNot ? ' ' : ''} ${(0,
|
| 86 |
+
_jestMatcherUtils.RECEIVED_COLOR)(receivedDiffString)}`
|
| 87 |
+
);
|
| 88 |
+
};
|
| 89 |
+
exports.printCloseTo = printCloseTo;
|
| 90 |
+
const printExpectedConstructorName = (label, expected) =>
|
| 91 |
+
`${printConstructorName(label, expected, false, true)}\n`;
|
| 92 |
+
exports.printExpectedConstructorName = printExpectedConstructorName;
|
| 93 |
+
const printExpectedConstructorNameNot = (label, expected) =>
|
| 94 |
+
`${printConstructorName(label, expected, true, true)}\n`;
|
| 95 |
+
exports.printExpectedConstructorNameNot = printExpectedConstructorNameNot;
|
| 96 |
+
const printReceivedConstructorName = (label, received) =>
|
| 97 |
+
`${printConstructorName(label, received, false, false)}\n`;
|
| 98 |
+
|
| 99 |
+
// Do not call function if received is equal to expected.
|
| 100 |
+
exports.printReceivedConstructorName = printReceivedConstructorName;
|
| 101 |
+
const printReceivedConstructorNameNot = (label, received, expected) =>
|
| 102 |
+
typeof expected.name === 'string' &&
|
| 103 |
+
expected.name.length !== 0 &&
|
| 104 |
+
typeof received.name === 'string' &&
|
| 105 |
+
received.name.length !== 0
|
| 106 |
+
? `${printConstructorName(label, received, true, false)} ${
|
| 107 |
+
Object.getPrototypeOf(received) === expected
|
| 108 |
+
? 'extends'
|
| 109 |
+
: 'extends … extends'
|
| 110 |
+
} ${(0, _jestMatcherUtils.EXPECTED_COLOR)(expected.name)}\n`
|
| 111 |
+
: `${printConstructorName(label, received, false, false)}\n`;
|
| 112 |
+
exports.printReceivedConstructorNameNot = printReceivedConstructorNameNot;
|
| 113 |
+
const printConstructorName = (label, constructor, isNot, isExpected) =>
|
| 114 |
+
typeof constructor.name !== 'string'
|
| 115 |
+
? `${label} name is not a string`
|
| 116 |
+
: constructor.name.length === 0
|
| 117 |
+
? `${label} name is an empty string`
|
| 118 |
+
: `${label}: ${!isNot ? '' : isExpected ? 'not ' : ' '}${
|
| 119 |
+
isExpected
|
| 120 |
+
? (0, _jestMatcherUtils.EXPECTED_COLOR)(constructor.name)
|
| 121 |
+
: (0, _jestMatcherUtils.RECEIVED_COLOR)(constructor.name)
|
| 122 |
+
}`;
|
novas/novacore-zephyr/claude-code-router/node_modules/expect/build/spyMatchers.js
ADDED
|
@@ -0,0 +1,1254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = void 0;
|
| 7 |
+
var _expectUtils = require('@jest/expect-utils');
|
| 8 |
+
var _jestGetType = require('jest-get-type');
|
| 9 |
+
var _jestMatcherUtils = require('jest-matcher-utils');
|
| 10 |
+
var _jestMatchersObject = require('./jestMatchersObject');
|
| 11 |
+
/**
|
| 12 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 13 |
+
*
|
| 14 |
+
* This source code is licensed under the MIT license found in the
|
| 15 |
+
* LICENSE file in the root directory of this source tree.
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
// The optional property of matcher context is true if undefined.
|
| 19 |
+
const isExpand = expand => expand !== false;
|
| 20 |
+
const PRINT_LIMIT = 3;
|
| 21 |
+
const NO_ARGUMENTS = 'called with 0 arguments';
|
| 22 |
+
const printExpectedArgs = expected =>
|
| 23 |
+
expected.length === 0
|
| 24 |
+
? NO_ARGUMENTS
|
| 25 |
+
: expected.map(arg => (0, _jestMatcherUtils.printExpected)(arg)).join(', ');
|
| 26 |
+
const printReceivedArgs = (received, expected) =>
|
| 27 |
+
received.length === 0
|
| 28 |
+
? NO_ARGUMENTS
|
| 29 |
+
: received
|
| 30 |
+
.map((arg, i) =>
|
| 31 |
+
Array.isArray(expected) &&
|
| 32 |
+
i < expected.length &&
|
| 33 |
+
isEqualValue(expected[i], arg)
|
| 34 |
+
? printCommon(arg)
|
| 35 |
+
: (0, _jestMatcherUtils.printReceived)(arg)
|
| 36 |
+
)
|
| 37 |
+
.join(', ');
|
| 38 |
+
const printCommon = val =>
|
| 39 |
+
(0, _jestMatcherUtils.DIM_COLOR)((0, _jestMatcherUtils.stringify)(val));
|
| 40 |
+
const isEqualValue = (expected, received) =>
|
| 41 |
+
(0, _expectUtils.equals)(expected, received, [
|
| 42 |
+
...(0, _jestMatchersObject.getCustomEqualityTesters)(),
|
| 43 |
+
_expectUtils.iterableEquality
|
| 44 |
+
]);
|
| 45 |
+
const isEqualCall = (expected, received) =>
|
| 46 |
+
received.length === expected.length && isEqualValue(expected, received);
|
| 47 |
+
const isEqualReturn = (expected, result) =>
|
| 48 |
+
result.type === 'return' && isEqualValue(expected, result.value);
|
| 49 |
+
const countReturns = results =>
|
| 50 |
+
results.reduce((n, result) => (result.type === 'return' ? n + 1 : n), 0);
|
| 51 |
+
const printNumberOfReturns = (countReturns, countCalls) =>
|
| 52 |
+
`\nNumber of returns: ${(0, _jestMatcherUtils.printReceived)(countReturns)}${
|
| 53 |
+
countCalls !== countReturns
|
| 54 |
+
? `\nNumber of calls: ${(0, _jestMatcherUtils.printReceived)(
|
| 55 |
+
countCalls
|
| 56 |
+
)}`
|
| 57 |
+
: ''
|
| 58 |
+
}`;
|
| 59 |
+
// Given a label, return a function which given a string,
|
| 60 |
+
// right-aligns it preceding the colon in the label.
|
| 61 |
+
const getRightAlignedPrinter = label => {
|
| 62 |
+
// Assume that the label contains a colon.
|
| 63 |
+
const index = label.indexOf(':');
|
| 64 |
+
const suffix = label.slice(index);
|
| 65 |
+
return (string, isExpectedCall) =>
|
| 66 |
+
(isExpectedCall
|
| 67 |
+
? `->${' '.repeat(Math.max(0, index - 2 - string.length))}`
|
| 68 |
+
: ' '.repeat(Math.max(index - string.length))) +
|
| 69 |
+
string +
|
| 70 |
+
suffix;
|
| 71 |
+
};
|
| 72 |
+
const printReceivedCallsNegative = (
|
| 73 |
+
expected,
|
| 74 |
+
indexedCalls,
|
| 75 |
+
isOnlyCall,
|
| 76 |
+
iExpectedCall
|
| 77 |
+
) => {
|
| 78 |
+
if (indexedCalls.length === 0) {
|
| 79 |
+
return '';
|
| 80 |
+
}
|
| 81 |
+
const label = 'Received: ';
|
| 82 |
+
if (isOnlyCall) {
|
| 83 |
+
return `${label + printReceivedArgs(indexedCalls[0], expected)}\n`;
|
| 84 |
+
}
|
| 85 |
+
const printAligned = getRightAlignedPrinter(label);
|
| 86 |
+
return `Received\n${indexedCalls.reduce(
|
| 87 |
+
(printed, [i, args]) =>
|
| 88 |
+
`${
|
| 89 |
+
printed +
|
| 90 |
+
printAligned(String(i + 1), i === iExpectedCall) +
|
| 91 |
+
printReceivedArgs(args, expected)
|
| 92 |
+
}\n`,
|
| 93 |
+
''
|
| 94 |
+
)}`;
|
| 95 |
+
};
|
| 96 |
+
const printExpectedReceivedCallsPositive = (
|
| 97 |
+
expected,
|
| 98 |
+
indexedCalls,
|
| 99 |
+
expand,
|
| 100 |
+
isOnlyCall,
|
| 101 |
+
iExpectedCall
|
| 102 |
+
) => {
|
| 103 |
+
const expectedLine = `Expected: ${printExpectedArgs(expected)}\n`;
|
| 104 |
+
if (indexedCalls.length === 0) {
|
| 105 |
+
return expectedLine;
|
| 106 |
+
}
|
| 107 |
+
const label = 'Received: ';
|
| 108 |
+
if (isOnlyCall && (iExpectedCall === 0 || iExpectedCall === undefined)) {
|
| 109 |
+
const received = indexedCalls[0][1];
|
| 110 |
+
if (isLineDiffableCall(expected, received)) {
|
| 111 |
+
// Display diff without indentation.
|
| 112 |
+
const lines = [
|
| 113 |
+
(0, _jestMatcherUtils.EXPECTED_COLOR)('- Expected'),
|
| 114 |
+
(0, _jestMatcherUtils.RECEIVED_COLOR)('+ Received'),
|
| 115 |
+
''
|
| 116 |
+
];
|
| 117 |
+
const length = Math.max(expected.length, received.length);
|
| 118 |
+
for (let i = 0; i < length; i += 1) {
|
| 119 |
+
if (i < expected.length && i < received.length) {
|
| 120 |
+
if (isEqualValue(expected[i], received[i])) {
|
| 121 |
+
lines.push(` ${printCommon(received[i])},`);
|
| 122 |
+
continue;
|
| 123 |
+
}
|
| 124 |
+
if (isLineDiffableArg(expected[i], received[i])) {
|
| 125 |
+
const difference = (0, _jestMatcherUtils.diff)(
|
| 126 |
+
expected[i],
|
| 127 |
+
received[i],
|
| 128 |
+
{
|
| 129 |
+
expand
|
| 130 |
+
}
|
| 131 |
+
);
|
| 132 |
+
if (
|
| 133 |
+
typeof difference === 'string' &&
|
| 134 |
+
difference.includes('- Expected') &&
|
| 135 |
+
difference.includes('+ Received')
|
| 136 |
+
) {
|
| 137 |
+
// Omit annotation in case multiple args have diff.
|
| 138 |
+
lines.push(`${difference.split('\n').slice(3).join('\n')},`);
|
| 139 |
+
continue;
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
if (i < expected.length) {
|
| 144 |
+
lines.push(
|
| 145 |
+
`${(0, _jestMatcherUtils.EXPECTED_COLOR)(
|
| 146 |
+
`- ${(0, _jestMatcherUtils.stringify)(expected[i])}`
|
| 147 |
+
)},`
|
| 148 |
+
);
|
| 149 |
+
}
|
| 150 |
+
if (i < received.length) {
|
| 151 |
+
lines.push(
|
| 152 |
+
`${(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 153 |
+
`+ ${(0, _jestMatcherUtils.stringify)(received[i])}`
|
| 154 |
+
)},`
|
| 155 |
+
);
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
return `${lines.join('\n')}\n`;
|
| 159 |
+
}
|
| 160 |
+
return `${expectedLine + label + printReceivedArgs(received, expected)}\n`;
|
| 161 |
+
}
|
| 162 |
+
const printAligned = getRightAlignedPrinter(label);
|
| 163 |
+
return (
|
| 164 |
+
// eslint-disable-next-line prefer-template
|
| 165 |
+
expectedLine +
|
| 166 |
+
'Received\n' +
|
| 167 |
+
indexedCalls.reduce((printed, [i, received]) => {
|
| 168 |
+
const aligned = printAligned(String(i + 1), i === iExpectedCall);
|
| 169 |
+
return `${
|
| 170 |
+
printed +
|
| 171 |
+
((i === iExpectedCall || iExpectedCall === undefined) &&
|
| 172 |
+
isLineDiffableCall(expected, received)
|
| 173 |
+
? aligned.replace(': ', '\n') +
|
| 174 |
+
printDiffCall(expected, received, expand)
|
| 175 |
+
: aligned + printReceivedArgs(received, expected))
|
| 176 |
+
}\n`;
|
| 177 |
+
}, '')
|
| 178 |
+
);
|
| 179 |
+
};
|
| 180 |
+
const indentation = 'Received'.replace(/\w/g, ' ');
|
| 181 |
+
const printDiffCall = (expected, received, expand) =>
|
| 182 |
+
received
|
| 183 |
+
.map((arg, i) => {
|
| 184 |
+
if (i < expected.length) {
|
| 185 |
+
if (isEqualValue(expected[i], arg)) {
|
| 186 |
+
return `${indentation} ${printCommon(arg)},`;
|
| 187 |
+
}
|
| 188 |
+
if (isLineDiffableArg(expected[i], arg)) {
|
| 189 |
+
const difference = (0, _jestMatcherUtils.diff)(expected[i], arg, {
|
| 190 |
+
expand
|
| 191 |
+
});
|
| 192 |
+
if (
|
| 193 |
+
typeof difference === 'string' &&
|
| 194 |
+
difference.includes('- Expected') &&
|
| 195 |
+
difference.includes('+ Received')
|
| 196 |
+
) {
|
| 197 |
+
// Display diff with indentation.
|
| 198 |
+
// Omit annotation in case multiple args have diff.
|
| 199 |
+
return `${difference
|
| 200 |
+
.split('\n')
|
| 201 |
+
.slice(3)
|
| 202 |
+
.map(line => indentation + line)
|
| 203 |
+
.join('\n')},`;
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
// Display + only if received arg has no corresponding expected arg.
|
| 209 |
+
return `${
|
| 210 |
+
indentation +
|
| 211 |
+
(i < expected.length
|
| 212 |
+
? ` ${(0, _jestMatcherUtils.printReceived)(arg)}`
|
| 213 |
+
: (0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 214 |
+
`+ ${(0, _jestMatcherUtils.stringify)(arg)}`
|
| 215 |
+
))
|
| 216 |
+
},`;
|
| 217 |
+
})
|
| 218 |
+
.join('\n');
|
| 219 |
+
const isLineDiffableCall = (expected, received) =>
|
| 220 |
+
expected.some(
|
| 221 |
+
(arg, i) => i < received.length && isLineDiffableArg(arg, received[i])
|
| 222 |
+
);
|
| 223 |
+
|
| 224 |
+
// Almost redundant with function in jest-matcher-utils,
|
| 225 |
+
// except no line diff for any strings.
|
| 226 |
+
const isLineDiffableArg = (expected, received) => {
|
| 227 |
+
const expectedType = (0, _jestGetType.getType)(expected);
|
| 228 |
+
const receivedType = (0, _jestGetType.getType)(received);
|
| 229 |
+
if (expectedType !== receivedType) {
|
| 230 |
+
return false;
|
| 231 |
+
}
|
| 232 |
+
if ((0, _jestGetType.isPrimitive)(expected)) {
|
| 233 |
+
return false;
|
| 234 |
+
}
|
| 235 |
+
if (
|
| 236 |
+
expectedType === 'date' ||
|
| 237 |
+
expectedType === 'function' ||
|
| 238 |
+
expectedType === 'regexp'
|
| 239 |
+
) {
|
| 240 |
+
return false;
|
| 241 |
+
}
|
| 242 |
+
if (expected instanceof Error && received instanceof Error) {
|
| 243 |
+
return false;
|
| 244 |
+
}
|
| 245 |
+
if (
|
| 246 |
+
expectedType === 'object' &&
|
| 247 |
+
typeof expected.asymmetricMatch === 'function'
|
| 248 |
+
) {
|
| 249 |
+
return false;
|
| 250 |
+
}
|
| 251 |
+
if (
|
| 252 |
+
receivedType === 'object' &&
|
| 253 |
+
typeof received.asymmetricMatch === 'function'
|
| 254 |
+
) {
|
| 255 |
+
return false;
|
| 256 |
+
}
|
| 257 |
+
return true;
|
| 258 |
+
};
|
| 259 |
+
const printResult = (result, expected) =>
|
| 260 |
+
result.type === 'throw'
|
| 261 |
+
? 'function call threw an error'
|
| 262 |
+
: result.type === 'incomplete'
|
| 263 |
+
? 'function call has not returned yet'
|
| 264 |
+
: isEqualValue(expected, result.value)
|
| 265 |
+
? printCommon(result.value)
|
| 266 |
+
: (0, _jestMatcherUtils.printReceived)(result.value);
|
| 267 |
+
// Return either empty string or one line per indexed result,
|
| 268 |
+
// so additional empty line can separate from `Number of returns` which follows.
|
| 269 |
+
const printReceivedResults = (
|
| 270 |
+
label,
|
| 271 |
+
expected,
|
| 272 |
+
indexedResults,
|
| 273 |
+
isOnlyCall,
|
| 274 |
+
iExpectedCall
|
| 275 |
+
) => {
|
| 276 |
+
if (indexedResults.length === 0) {
|
| 277 |
+
return '';
|
| 278 |
+
}
|
| 279 |
+
if (isOnlyCall && (iExpectedCall === 0 || iExpectedCall === undefined)) {
|
| 280 |
+
return `${label + printResult(indexedResults[0][1], expected)}\n`;
|
| 281 |
+
}
|
| 282 |
+
const printAligned = getRightAlignedPrinter(label);
|
| 283 |
+
return (
|
| 284 |
+
// eslint-disable-next-line prefer-template
|
| 285 |
+
label.replace(':', '').trim() +
|
| 286 |
+
'\n' +
|
| 287 |
+
indexedResults.reduce(
|
| 288 |
+
(printed, [i, result]) =>
|
| 289 |
+
`${
|
| 290 |
+
printed +
|
| 291 |
+
printAligned(String(i + 1), i === iExpectedCall) +
|
| 292 |
+
printResult(result, expected)
|
| 293 |
+
}\n`,
|
| 294 |
+
''
|
| 295 |
+
)
|
| 296 |
+
);
|
| 297 |
+
};
|
| 298 |
+
const createToBeCalledMatcher = matcherName =>
|
| 299 |
+
function (received, expected) {
|
| 300 |
+
const expectedArgument = '';
|
| 301 |
+
const options = {
|
| 302 |
+
isNot: this.isNot,
|
| 303 |
+
promise: this.promise
|
| 304 |
+
};
|
| 305 |
+
(0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options);
|
| 306 |
+
ensureMockOrSpy(received, matcherName, expectedArgument, options);
|
| 307 |
+
const receivedIsSpy = isSpy(received);
|
| 308 |
+
const receivedName = receivedIsSpy ? 'spy' : received.getMockName();
|
| 309 |
+
const count = receivedIsSpy
|
| 310 |
+
? received.calls.count()
|
| 311 |
+
: received.mock.calls.length;
|
| 312 |
+
const calls = receivedIsSpy
|
| 313 |
+
? received.calls.all().map(x => x.args)
|
| 314 |
+
: received.mock.calls;
|
| 315 |
+
const pass = count > 0;
|
| 316 |
+
const message = pass
|
| 317 |
+
? () =>
|
| 318 |
+
// eslint-disable-next-line prefer-template
|
| 319 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 320 |
+
matcherName,
|
| 321 |
+
receivedName,
|
| 322 |
+
expectedArgument,
|
| 323 |
+
options
|
| 324 |
+
) +
|
| 325 |
+
'\n\n' +
|
| 326 |
+
`Expected number of calls: ${(0, _jestMatcherUtils.printExpected)(
|
| 327 |
+
0
|
| 328 |
+
)}\n` +
|
| 329 |
+
`Received number of calls: ${(0, _jestMatcherUtils.printReceived)(
|
| 330 |
+
count
|
| 331 |
+
)}\n\n` +
|
| 332 |
+
calls
|
| 333 |
+
.reduce((lines, args, i) => {
|
| 334 |
+
if (lines.length < PRINT_LIMIT) {
|
| 335 |
+
lines.push(`${i + 1}: ${printReceivedArgs(args)}`);
|
| 336 |
+
}
|
| 337 |
+
return lines;
|
| 338 |
+
}, [])
|
| 339 |
+
.join('\n')
|
| 340 |
+
: () =>
|
| 341 |
+
// eslint-disable-next-line prefer-template
|
| 342 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 343 |
+
matcherName,
|
| 344 |
+
receivedName,
|
| 345 |
+
expectedArgument,
|
| 346 |
+
options
|
| 347 |
+
) +
|
| 348 |
+
'\n\n' +
|
| 349 |
+
`Expected number of calls: >= ${(0, _jestMatcherUtils.printExpected)(
|
| 350 |
+
1
|
| 351 |
+
)}\n` +
|
| 352 |
+
`Received number of calls: ${(0, _jestMatcherUtils.printReceived)(
|
| 353 |
+
count
|
| 354 |
+
)}`;
|
| 355 |
+
return {
|
| 356 |
+
message,
|
| 357 |
+
pass
|
| 358 |
+
};
|
| 359 |
+
};
|
| 360 |
+
const createToReturnMatcher = matcherName =>
|
| 361 |
+
function (received, expected) {
|
| 362 |
+
const expectedArgument = '';
|
| 363 |
+
const options = {
|
| 364 |
+
isNot: this.isNot,
|
| 365 |
+
promise: this.promise
|
| 366 |
+
};
|
| 367 |
+
(0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options);
|
| 368 |
+
ensureMock(received, matcherName, expectedArgument, options);
|
| 369 |
+
const receivedName = received.getMockName();
|
| 370 |
+
|
| 371 |
+
// Count return values that correspond only to calls that returned
|
| 372 |
+
const count = received.mock.results.reduce(
|
| 373 |
+
(n, result) => (result.type === 'return' ? n + 1 : n),
|
| 374 |
+
0
|
| 375 |
+
);
|
| 376 |
+
const pass = count > 0;
|
| 377 |
+
const message = pass
|
| 378 |
+
? () =>
|
| 379 |
+
// eslint-disable-next-line prefer-template
|
| 380 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 381 |
+
matcherName,
|
| 382 |
+
receivedName,
|
| 383 |
+
expectedArgument,
|
| 384 |
+
options
|
| 385 |
+
) +
|
| 386 |
+
'\n\n' +
|
| 387 |
+
`Expected number of returns: ${(0, _jestMatcherUtils.printExpected)(
|
| 388 |
+
0
|
| 389 |
+
)}\n` +
|
| 390 |
+
`Received number of returns: ${(0, _jestMatcherUtils.printReceived)(
|
| 391 |
+
count
|
| 392 |
+
)}\n\n` +
|
| 393 |
+
received.mock.results
|
| 394 |
+
.reduce((lines, result, i) => {
|
| 395 |
+
if (result.type === 'return' && lines.length < PRINT_LIMIT) {
|
| 396 |
+
lines.push(
|
| 397 |
+
`${i + 1}: ${(0, _jestMatcherUtils.printReceived)(
|
| 398 |
+
result.value
|
| 399 |
+
)}`
|
| 400 |
+
);
|
| 401 |
+
}
|
| 402 |
+
return lines;
|
| 403 |
+
}, [])
|
| 404 |
+
.join('\n') +
|
| 405 |
+
(received.mock.calls.length !== count
|
| 406 |
+
? `\n\nReceived number of calls: ${(0,
|
| 407 |
+
_jestMatcherUtils.printReceived)(received.mock.calls.length)}`
|
| 408 |
+
: '')
|
| 409 |
+
: () =>
|
| 410 |
+
// eslint-disable-next-line prefer-template
|
| 411 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 412 |
+
matcherName,
|
| 413 |
+
receivedName,
|
| 414 |
+
expectedArgument,
|
| 415 |
+
options
|
| 416 |
+
) +
|
| 417 |
+
'\n\n' +
|
| 418 |
+
`Expected number of returns: >= ${(0,
|
| 419 |
+
_jestMatcherUtils.printExpected)(1)}\n` +
|
| 420 |
+
`Received number of returns: ${(0,
|
| 421 |
+
_jestMatcherUtils.printReceived)(count)}` +
|
| 422 |
+
(received.mock.calls.length !== count
|
| 423 |
+
? `\nReceived number of calls: ${(0,
|
| 424 |
+
_jestMatcherUtils.printReceived)(received.mock.calls.length)}`
|
| 425 |
+
: '');
|
| 426 |
+
return {
|
| 427 |
+
message,
|
| 428 |
+
pass
|
| 429 |
+
};
|
| 430 |
+
};
|
| 431 |
+
const createToBeCalledTimesMatcher = matcherName =>
|
| 432 |
+
function (received, expected) {
|
| 433 |
+
const expectedArgument = 'expected';
|
| 434 |
+
const options = {
|
| 435 |
+
isNot: this.isNot,
|
| 436 |
+
promise: this.promise
|
| 437 |
+
};
|
| 438 |
+
(0, _jestMatcherUtils.ensureExpectedIsNonNegativeInteger)(
|
| 439 |
+
expected,
|
| 440 |
+
matcherName,
|
| 441 |
+
options
|
| 442 |
+
);
|
| 443 |
+
ensureMockOrSpy(received, matcherName, expectedArgument, options);
|
| 444 |
+
const receivedIsSpy = isSpy(received);
|
| 445 |
+
const receivedName = receivedIsSpy ? 'spy' : received.getMockName();
|
| 446 |
+
const count = receivedIsSpy
|
| 447 |
+
? received.calls.count()
|
| 448 |
+
: received.mock.calls.length;
|
| 449 |
+
const pass = count === expected;
|
| 450 |
+
const message = pass
|
| 451 |
+
? () =>
|
| 452 |
+
// eslint-disable-next-line prefer-template
|
| 453 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 454 |
+
matcherName,
|
| 455 |
+
receivedName,
|
| 456 |
+
expectedArgument,
|
| 457 |
+
options
|
| 458 |
+
) +
|
| 459 |
+
'\n\n' +
|
| 460 |
+
`Expected number of calls: not ${(0, _jestMatcherUtils.printExpected)(
|
| 461 |
+
expected
|
| 462 |
+
)}`
|
| 463 |
+
: () =>
|
| 464 |
+
// eslint-disable-next-line prefer-template
|
| 465 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 466 |
+
matcherName,
|
| 467 |
+
receivedName,
|
| 468 |
+
expectedArgument,
|
| 469 |
+
options
|
| 470 |
+
) +
|
| 471 |
+
'\n\n' +
|
| 472 |
+
`Expected number of calls: ${(0, _jestMatcherUtils.printExpected)(
|
| 473 |
+
expected
|
| 474 |
+
)}\n` +
|
| 475 |
+
`Received number of calls: ${(0, _jestMatcherUtils.printReceived)(
|
| 476 |
+
count
|
| 477 |
+
)}`;
|
| 478 |
+
return {
|
| 479 |
+
message,
|
| 480 |
+
pass
|
| 481 |
+
};
|
| 482 |
+
};
|
| 483 |
+
const createToReturnTimesMatcher = matcherName =>
|
| 484 |
+
function (received, expected) {
|
| 485 |
+
const expectedArgument = 'expected';
|
| 486 |
+
const options = {
|
| 487 |
+
isNot: this.isNot,
|
| 488 |
+
promise: this.promise
|
| 489 |
+
};
|
| 490 |
+
(0, _jestMatcherUtils.ensureExpectedIsNonNegativeInteger)(
|
| 491 |
+
expected,
|
| 492 |
+
matcherName,
|
| 493 |
+
options
|
| 494 |
+
);
|
| 495 |
+
ensureMock(received, matcherName, expectedArgument, options);
|
| 496 |
+
const receivedName = received.getMockName();
|
| 497 |
+
|
| 498 |
+
// Count return values that correspond only to calls that returned
|
| 499 |
+
const count = received.mock.results.reduce(
|
| 500 |
+
(n, result) => (result.type === 'return' ? n + 1 : n),
|
| 501 |
+
0
|
| 502 |
+
);
|
| 503 |
+
const pass = count === expected;
|
| 504 |
+
const message = pass
|
| 505 |
+
? () =>
|
| 506 |
+
// eslint-disable-next-line prefer-template
|
| 507 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 508 |
+
matcherName,
|
| 509 |
+
receivedName,
|
| 510 |
+
expectedArgument,
|
| 511 |
+
options
|
| 512 |
+
) +
|
| 513 |
+
'\n\n' +
|
| 514 |
+
`Expected number of returns: not ${(0,
|
| 515 |
+
_jestMatcherUtils.printExpected)(expected)}` +
|
| 516 |
+
(received.mock.calls.length !== count
|
| 517 |
+
? `\n\nReceived number of calls: ${(0,
|
| 518 |
+
_jestMatcherUtils.printReceived)(received.mock.calls.length)}`
|
| 519 |
+
: '')
|
| 520 |
+
: () =>
|
| 521 |
+
// eslint-disable-next-line prefer-template
|
| 522 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 523 |
+
matcherName,
|
| 524 |
+
receivedName,
|
| 525 |
+
expectedArgument,
|
| 526 |
+
options
|
| 527 |
+
) +
|
| 528 |
+
'\n\n' +
|
| 529 |
+
`Expected number of returns: ${(0, _jestMatcherUtils.printExpected)(
|
| 530 |
+
expected
|
| 531 |
+
)}\n` +
|
| 532 |
+
`Received number of returns: ${(0, _jestMatcherUtils.printReceived)(
|
| 533 |
+
count
|
| 534 |
+
)}` +
|
| 535 |
+
(received.mock.calls.length !== count
|
| 536 |
+
? `\nReceived number of calls: ${(0,
|
| 537 |
+
_jestMatcherUtils.printReceived)(received.mock.calls.length)}`
|
| 538 |
+
: '');
|
| 539 |
+
return {
|
| 540 |
+
message,
|
| 541 |
+
pass
|
| 542 |
+
};
|
| 543 |
+
};
|
| 544 |
+
const createToBeCalledWithMatcher = matcherName =>
|
| 545 |
+
function (received, ...expected) {
|
| 546 |
+
const expectedArgument = '...expected';
|
| 547 |
+
const options = {
|
| 548 |
+
isNot: this.isNot,
|
| 549 |
+
promise: this.promise
|
| 550 |
+
};
|
| 551 |
+
ensureMockOrSpy(received, matcherName, expectedArgument, options);
|
| 552 |
+
const receivedIsSpy = isSpy(received);
|
| 553 |
+
const receivedName = receivedIsSpy ? 'spy' : received.getMockName();
|
| 554 |
+
const calls = receivedIsSpy
|
| 555 |
+
? received.calls.all().map(x => x.args)
|
| 556 |
+
: received.mock.calls;
|
| 557 |
+
const pass = calls.some(call => isEqualCall(expected, call));
|
| 558 |
+
const message = pass
|
| 559 |
+
? () => {
|
| 560 |
+
// Some examples of calls that are equal to expected value.
|
| 561 |
+
const indexedCalls = [];
|
| 562 |
+
let i = 0;
|
| 563 |
+
while (i < calls.length && indexedCalls.length < PRINT_LIMIT) {
|
| 564 |
+
if (isEqualCall(expected, calls[i])) {
|
| 565 |
+
indexedCalls.push([i, calls[i]]);
|
| 566 |
+
}
|
| 567 |
+
i += 1;
|
| 568 |
+
}
|
| 569 |
+
return (
|
| 570 |
+
// eslint-disable-next-line prefer-template
|
| 571 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 572 |
+
matcherName,
|
| 573 |
+
receivedName,
|
| 574 |
+
expectedArgument,
|
| 575 |
+
options
|
| 576 |
+
) +
|
| 577 |
+
'\n\n' +
|
| 578 |
+
`Expected: not ${printExpectedArgs(expected)}\n` +
|
| 579 |
+
(calls.length === 1 &&
|
| 580 |
+
(0, _jestMatcherUtils.stringify)(calls[0]) ===
|
| 581 |
+
(0, _jestMatcherUtils.stringify)(expected)
|
| 582 |
+
? ''
|
| 583 |
+
: printReceivedCallsNegative(
|
| 584 |
+
expected,
|
| 585 |
+
indexedCalls,
|
| 586 |
+
calls.length === 1
|
| 587 |
+
)) +
|
| 588 |
+
`\nNumber of calls: ${(0, _jestMatcherUtils.printReceived)(
|
| 589 |
+
calls.length
|
| 590 |
+
)}`
|
| 591 |
+
);
|
| 592 |
+
}
|
| 593 |
+
: () => {
|
| 594 |
+
// Some examples of calls that are not equal to expected value.
|
| 595 |
+
const indexedCalls = [];
|
| 596 |
+
let i = 0;
|
| 597 |
+
while (i < calls.length && indexedCalls.length < PRINT_LIMIT) {
|
| 598 |
+
indexedCalls.push([i, calls[i]]);
|
| 599 |
+
i += 1;
|
| 600 |
+
}
|
| 601 |
+
return (
|
| 602 |
+
// eslint-disable-next-line prefer-template
|
| 603 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 604 |
+
matcherName,
|
| 605 |
+
receivedName,
|
| 606 |
+
expectedArgument,
|
| 607 |
+
options
|
| 608 |
+
) +
|
| 609 |
+
'\n\n' +
|
| 610 |
+
printExpectedReceivedCallsPositive(
|
| 611 |
+
expected,
|
| 612 |
+
indexedCalls,
|
| 613 |
+
isExpand(this.expand),
|
| 614 |
+
calls.length === 1
|
| 615 |
+
) +
|
| 616 |
+
`\nNumber of calls: ${(0, _jestMatcherUtils.printReceived)(
|
| 617 |
+
calls.length
|
| 618 |
+
)}`
|
| 619 |
+
);
|
| 620 |
+
};
|
| 621 |
+
return {
|
| 622 |
+
message,
|
| 623 |
+
pass
|
| 624 |
+
};
|
| 625 |
+
};
|
| 626 |
+
const createToReturnWithMatcher = matcherName =>
|
| 627 |
+
function (received, expected) {
|
| 628 |
+
const expectedArgument = 'expected';
|
| 629 |
+
const options = {
|
| 630 |
+
isNot: this.isNot,
|
| 631 |
+
promise: this.promise
|
| 632 |
+
};
|
| 633 |
+
ensureMock(received, matcherName, expectedArgument, options);
|
| 634 |
+
const receivedName = received.getMockName();
|
| 635 |
+
const {calls, results} = received.mock;
|
| 636 |
+
const pass = results.some(result => isEqualReturn(expected, result));
|
| 637 |
+
const message = pass
|
| 638 |
+
? () => {
|
| 639 |
+
// Some examples of results that are equal to expected value.
|
| 640 |
+
const indexedResults = [];
|
| 641 |
+
let i = 0;
|
| 642 |
+
while (i < results.length && indexedResults.length < PRINT_LIMIT) {
|
| 643 |
+
if (isEqualReturn(expected, results[i])) {
|
| 644 |
+
indexedResults.push([i, results[i]]);
|
| 645 |
+
}
|
| 646 |
+
i += 1;
|
| 647 |
+
}
|
| 648 |
+
return (
|
| 649 |
+
// eslint-disable-next-line prefer-template
|
| 650 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 651 |
+
matcherName,
|
| 652 |
+
receivedName,
|
| 653 |
+
expectedArgument,
|
| 654 |
+
options
|
| 655 |
+
) +
|
| 656 |
+
'\n\n' +
|
| 657 |
+
`Expected: not ${(0, _jestMatcherUtils.printExpected)(
|
| 658 |
+
expected
|
| 659 |
+
)}\n` +
|
| 660 |
+
(results.length === 1 &&
|
| 661 |
+
results[0].type === 'return' &&
|
| 662 |
+
(0, _jestMatcherUtils.stringify)(results[0].value) ===
|
| 663 |
+
(0, _jestMatcherUtils.stringify)(expected)
|
| 664 |
+
? ''
|
| 665 |
+
: printReceivedResults(
|
| 666 |
+
'Received: ',
|
| 667 |
+
expected,
|
| 668 |
+
indexedResults,
|
| 669 |
+
results.length === 1
|
| 670 |
+
)) +
|
| 671 |
+
printNumberOfReturns(countReturns(results), calls.length)
|
| 672 |
+
);
|
| 673 |
+
}
|
| 674 |
+
: () => {
|
| 675 |
+
// Some examples of results that are not equal to expected value.
|
| 676 |
+
const indexedResults = [];
|
| 677 |
+
let i = 0;
|
| 678 |
+
while (i < results.length && indexedResults.length < PRINT_LIMIT) {
|
| 679 |
+
indexedResults.push([i, results[i]]);
|
| 680 |
+
i += 1;
|
| 681 |
+
}
|
| 682 |
+
return (
|
| 683 |
+
// eslint-disable-next-line prefer-template
|
| 684 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 685 |
+
matcherName,
|
| 686 |
+
receivedName,
|
| 687 |
+
expectedArgument,
|
| 688 |
+
options
|
| 689 |
+
) +
|
| 690 |
+
'\n\n' +
|
| 691 |
+
`Expected: ${(0, _jestMatcherUtils.printExpected)(expected)}\n` +
|
| 692 |
+
printReceivedResults(
|
| 693 |
+
'Received: ',
|
| 694 |
+
expected,
|
| 695 |
+
indexedResults,
|
| 696 |
+
results.length === 1
|
| 697 |
+
) +
|
| 698 |
+
printNumberOfReturns(countReturns(results), calls.length)
|
| 699 |
+
);
|
| 700 |
+
};
|
| 701 |
+
return {
|
| 702 |
+
message,
|
| 703 |
+
pass
|
| 704 |
+
};
|
| 705 |
+
};
|
| 706 |
+
const createLastCalledWithMatcher = matcherName =>
|
| 707 |
+
function (received, ...expected) {
|
| 708 |
+
const expectedArgument = '...expected';
|
| 709 |
+
const options = {
|
| 710 |
+
isNot: this.isNot,
|
| 711 |
+
promise: this.promise
|
| 712 |
+
};
|
| 713 |
+
ensureMockOrSpy(received, matcherName, expectedArgument, options);
|
| 714 |
+
const receivedIsSpy = isSpy(received);
|
| 715 |
+
const receivedName = receivedIsSpy ? 'spy' : received.getMockName();
|
| 716 |
+
const calls = receivedIsSpy
|
| 717 |
+
? received.calls.all().map(x => x.args)
|
| 718 |
+
: received.mock.calls;
|
| 719 |
+
const iLast = calls.length - 1;
|
| 720 |
+
const pass = iLast >= 0 && isEqualCall(expected, calls[iLast]);
|
| 721 |
+
const message = pass
|
| 722 |
+
? () => {
|
| 723 |
+
const indexedCalls = [];
|
| 724 |
+
if (iLast > 0) {
|
| 725 |
+
// Display preceding call as context.
|
| 726 |
+
indexedCalls.push([iLast - 1, calls[iLast - 1]]);
|
| 727 |
+
}
|
| 728 |
+
indexedCalls.push([iLast, calls[iLast]]);
|
| 729 |
+
return (
|
| 730 |
+
// eslint-disable-next-line prefer-template
|
| 731 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 732 |
+
matcherName,
|
| 733 |
+
receivedName,
|
| 734 |
+
expectedArgument,
|
| 735 |
+
options
|
| 736 |
+
) +
|
| 737 |
+
'\n\n' +
|
| 738 |
+
`Expected: not ${printExpectedArgs(expected)}\n` +
|
| 739 |
+
(calls.length === 1 &&
|
| 740 |
+
(0, _jestMatcherUtils.stringify)(calls[0]) ===
|
| 741 |
+
(0, _jestMatcherUtils.stringify)(expected)
|
| 742 |
+
? ''
|
| 743 |
+
: printReceivedCallsNegative(
|
| 744 |
+
expected,
|
| 745 |
+
indexedCalls,
|
| 746 |
+
calls.length === 1,
|
| 747 |
+
iLast
|
| 748 |
+
)) +
|
| 749 |
+
`\nNumber of calls: ${(0, _jestMatcherUtils.printReceived)(
|
| 750 |
+
calls.length
|
| 751 |
+
)}`
|
| 752 |
+
);
|
| 753 |
+
}
|
| 754 |
+
: () => {
|
| 755 |
+
const indexedCalls = [];
|
| 756 |
+
if (iLast >= 0) {
|
| 757 |
+
if (iLast > 0) {
|
| 758 |
+
let i = iLast - 1;
|
| 759 |
+
// Is there a preceding call that is equal to expected args?
|
| 760 |
+
while (i >= 0 && !isEqualCall(expected, calls[i])) {
|
| 761 |
+
i -= 1;
|
| 762 |
+
}
|
| 763 |
+
if (i < 0) {
|
| 764 |
+
i = iLast - 1; // otherwise, preceding call
|
| 765 |
+
}
|
| 766 |
+
|
| 767 |
+
indexedCalls.push([i, calls[i]]);
|
| 768 |
+
}
|
| 769 |
+
indexedCalls.push([iLast, calls[iLast]]);
|
| 770 |
+
}
|
| 771 |
+
return (
|
| 772 |
+
// eslint-disable-next-line prefer-template
|
| 773 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 774 |
+
matcherName,
|
| 775 |
+
receivedName,
|
| 776 |
+
expectedArgument,
|
| 777 |
+
options
|
| 778 |
+
) +
|
| 779 |
+
'\n\n' +
|
| 780 |
+
printExpectedReceivedCallsPositive(
|
| 781 |
+
expected,
|
| 782 |
+
indexedCalls,
|
| 783 |
+
isExpand(this.expand),
|
| 784 |
+
calls.length === 1,
|
| 785 |
+
iLast
|
| 786 |
+
) +
|
| 787 |
+
`\nNumber of calls: ${(0, _jestMatcherUtils.printReceived)(
|
| 788 |
+
calls.length
|
| 789 |
+
)}`
|
| 790 |
+
);
|
| 791 |
+
};
|
| 792 |
+
return {
|
| 793 |
+
message,
|
| 794 |
+
pass
|
| 795 |
+
};
|
| 796 |
+
};
|
| 797 |
+
const createLastReturnedMatcher = matcherName =>
|
| 798 |
+
function (received, expected) {
|
| 799 |
+
const expectedArgument = 'expected';
|
| 800 |
+
const options = {
|
| 801 |
+
isNot: this.isNot,
|
| 802 |
+
promise: this.promise
|
| 803 |
+
};
|
| 804 |
+
ensureMock(received, matcherName, expectedArgument, options);
|
| 805 |
+
const receivedName = received.getMockName();
|
| 806 |
+
const {calls, results} = received.mock;
|
| 807 |
+
const iLast = results.length - 1;
|
| 808 |
+
const pass = iLast >= 0 && isEqualReturn(expected, results[iLast]);
|
| 809 |
+
const message = pass
|
| 810 |
+
? () => {
|
| 811 |
+
const indexedResults = [];
|
| 812 |
+
if (iLast > 0) {
|
| 813 |
+
// Display preceding result as context.
|
| 814 |
+
indexedResults.push([iLast - 1, results[iLast - 1]]);
|
| 815 |
+
}
|
| 816 |
+
indexedResults.push([iLast, results[iLast]]);
|
| 817 |
+
return (
|
| 818 |
+
// eslint-disable-next-line prefer-template
|
| 819 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 820 |
+
matcherName,
|
| 821 |
+
receivedName,
|
| 822 |
+
expectedArgument,
|
| 823 |
+
options
|
| 824 |
+
) +
|
| 825 |
+
'\n\n' +
|
| 826 |
+
`Expected: not ${(0, _jestMatcherUtils.printExpected)(
|
| 827 |
+
expected
|
| 828 |
+
)}\n` +
|
| 829 |
+
(results.length === 1 &&
|
| 830 |
+
results[0].type === 'return' &&
|
| 831 |
+
(0, _jestMatcherUtils.stringify)(results[0].value) ===
|
| 832 |
+
(0, _jestMatcherUtils.stringify)(expected)
|
| 833 |
+
? ''
|
| 834 |
+
: printReceivedResults(
|
| 835 |
+
'Received: ',
|
| 836 |
+
expected,
|
| 837 |
+
indexedResults,
|
| 838 |
+
results.length === 1,
|
| 839 |
+
iLast
|
| 840 |
+
)) +
|
| 841 |
+
printNumberOfReturns(countReturns(results), calls.length)
|
| 842 |
+
);
|
| 843 |
+
}
|
| 844 |
+
: () => {
|
| 845 |
+
const indexedResults = [];
|
| 846 |
+
if (iLast >= 0) {
|
| 847 |
+
if (iLast > 0) {
|
| 848 |
+
let i = iLast - 1;
|
| 849 |
+
// Is there a preceding result that is equal to expected value?
|
| 850 |
+
while (i >= 0 && !isEqualReturn(expected, results[i])) {
|
| 851 |
+
i -= 1;
|
| 852 |
+
}
|
| 853 |
+
if (i < 0) {
|
| 854 |
+
i = iLast - 1; // otherwise, preceding result
|
| 855 |
+
}
|
| 856 |
+
|
| 857 |
+
indexedResults.push([i, results[i]]);
|
| 858 |
+
}
|
| 859 |
+
indexedResults.push([iLast, results[iLast]]);
|
| 860 |
+
}
|
| 861 |
+
return (
|
| 862 |
+
// eslint-disable-next-line prefer-template
|
| 863 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 864 |
+
matcherName,
|
| 865 |
+
receivedName,
|
| 866 |
+
expectedArgument,
|
| 867 |
+
options
|
| 868 |
+
) +
|
| 869 |
+
'\n\n' +
|
| 870 |
+
`Expected: ${(0, _jestMatcherUtils.printExpected)(expected)}\n` +
|
| 871 |
+
printReceivedResults(
|
| 872 |
+
'Received: ',
|
| 873 |
+
expected,
|
| 874 |
+
indexedResults,
|
| 875 |
+
results.length === 1,
|
| 876 |
+
iLast
|
| 877 |
+
) +
|
| 878 |
+
printNumberOfReturns(countReturns(results), calls.length)
|
| 879 |
+
);
|
| 880 |
+
};
|
| 881 |
+
return {
|
| 882 |
+
message,
|
| 883 |
+
pass
|
| 884 |
+
};
|
| 885 |
+
};
|
| 886 |
+
const createNthCalledWithMatcher = matcherName =>
|
| 887 |
+
function (received, nth, ...expected) {
|
| 888 |
+
const expectedArgument = 'n';
|
| 889 |
+
const options = {
|
| 890 |
+
expectedColor: arg => arg,
|
| 891 |
+
isNot: this.isNot,
|
| 892 |
+
promise: this.promise,
|
| 893 |
+
secondArgument: '...expected'
|
| 894 |
+
};
|
| 895 |
+
ensureMockOrSpy(received, matcherName, expectedArgument, options);
|
| 896 |
+
if (!Number.isSafeInteger(nth) || nth < 1) {
|
| 897 |
+
throw new Error(
|
| 898 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 899 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 900 |
+
matcherName,
|
| 901 |
+
undefined,
|
| 902 |
+
expectedArgument,
|
| 903 |
+
options
|
| 904 |
+
),
|
| 905 |
+
`${expectedArgument} must be a positive integer`,
|
| 906 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 907 |
+
expectedArgument,
|
| 908 |
+
nth,
|
| 909 |
+
_jestMatcherUtils.stringify
|
| 910 |
+
)
|
| 911 |
+
)
|
| 912 |
+
);
|
| 913 |
+
}
|
| 914 |
+
const receivedIsSpy = isSpy(received);
|
| 915 |
+
const receivedName = receivedIsSpy ? 'spy' : received.getMockName();
|
| 916 |
+
const calls = receivedIsSpy
|
| 917 |
+
? received.calls.all().map(x => x.args)
|
| 918 |
+
: received.mock.calls;
|
| 919 |
+
const length = calls.length;
|
| 920 |
+
const iNth = nth - 1;
|
| 921 |
+
const pass = iNth < length && isEqualCall(expected, calls[iNth]);
|
| 922 |
+
const message = pass
|
| 923 |
+
? () => {
|
| 924 |
+
// Display preceding and following calls,
|
| 925 |
+
// in case assertions fails because index is off by one.
|
| 926 |
+
const indexedCalls = [];
|
| 927 |
+
if (iNth - 1 >= 0) {
|
| 928 |
+
indexedCalls.push([iNth - 1, calls[iNth - 1]]);
|
| 929 |
+
}
|
| 930 |
+
indexedCalls.push([iNth, calls[iNth]]);
|
| 931 |
+
if (iNth + 1 < length) {
|
| 932 |
+
indexedCalls.push([iNth + 1, calls[iNth + 1]]);
|
| 933 |
+
}
|
| 934 |
+
return (
|
| 935 |
+
// eslint-disable-next-line prefer-template
|
| 936 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 937 |
+
matcherName,
|
| 938 |
+
receivedName,
|
| 939 |
+
expectedArgument,
|
| 940 |
+
options
|
| 941 |
+
) +
|
| 942 |
+
'\n\n' +
|
| 943 |
+
`n: ${nth}\n` +
|
| 944 |
+
`Expected: not ${printExpectedArgs(expected)}\n` +
|
| 945 |
+
(calls.length === 1 &&
|
| 946 |
+
(0, _jestMatcherUtils.stringify)(calls[0]) ===
|
| 947 |
+
(0, _jestMatcherUtils.stringify)(expected)
|
| 948 |
+
? ''
|
| 949 |
+
: printReceivedCallsNegative(
|
| 950 |
+
expected,
|
| 951 |
+
indexedCalls,
|
| 952 |
+
calls.length === 1,
|
| 953 |
+
iNth
|
| 954 |
+
)) +
|
| 955 |
+
`\nNumber of calls: ${(0, _jestMatcherUtils.printReceived)(
|
| 956 |
+
calls.length
|
| 957 |
+
)}`
|
| 958 |
+
);
|
| 959 |
+
}
|
| 960 |
+
: () => {
|
| 961 |
+
// Display preceding and following calls:
|
| 962 |
+
// * nearest call that is equal to expected args
|
| 963 |
+
// * otherwise, adjacent call
|
| 964 |
+
// in case assertions fails because of index, especially off by one.
|
| 965 |
+
const indexedCalls = [];
|
| 966 |
+
if (iNth < length) {
|
| 967 |
+
if (iNth - 1 >= 0) {
|
| 968 |
+
let i = iNth - 1;
|
| 969 |
+
// Is there a preceding call that is equal to expected args?
|
| 970 |
+
while (i >= 0 && !isEqualCall(expected, calls[i])) {
|
| 971 |
+
i -= 1;
|
| 972 |
+
}
|
| 973 |
+
if (i < 0) {
|
| 974 |
+
i = iNth - 1; // otherwise, adjacent call
|
| 975 |
+
}
|
| 976 |
+
|
| 977 |
+
indexedCalls.push([i, calls[i]]);
|
| 978 |
+
}
|
| 979 |
+
indexedCalls.push([iNth, calls[iNth]]);
|
| 980 |
+
if (iNth + 1 < length) {
|
| 981 |
+
let i = iNth + 1;
|
| 982 |
+
// Is there a following call that is equal to expected args?
|
| 983 |
+
while (i < length && !isEqualCall(expected, calls[i])) {
|
| 984 |
+
i += 1;
|
| 985 |
+
}
|
| 986 |
+
if (i >= length) {
|
| 987 |
+
i = iNth + 1; // otherwise, adjacent call
|
| 988 |
+
}
|
| 989 |
+
|
| 990 |
+
indexedCalls.push([i, calls[i]]);
|
| 991 |
+
}
|
| 992 |
+
} else if (length > 0) {
|
| 993 |
+
// The number of received calls is fewer than the expected number.
|
| 994 |
+
let i = length - 1;
|
| 995 |
+
// Is there a call that is equal to expected args?
|
| 996 |
+
while (i >= 0 && !isEqualCall(expected, calls[i])) {
|
| 997 |
+
i -= 1;
|
| 998 |
+
}
|
| 999 |
+
if (i < 0) {
|
| 1000 |
+
i = length - 1; // otherwise, last call
|
| 1001 |
+
}
|
| 1002 |
+
|
| 1003 |
+
indexedCalls.push([i, calls[i]]);
|
| 1004 |
+
}
|
| 1005 |
+
return (
|
| 1006 |
+
// eslint-disable-next-line prefer-template
|
| 1007 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1008 |
+
matcherName,
|
| 1009 |
+
receivedName,
|
| 1010 |
+
expectedArgument,
|
| 1011 |
+
options
|
| 1012 |
+
) +
|
| 1013 |
+
'\n\n' +
|
| 1014 |
+
`n: ${nth}\n` +
|
| 1015 |
+
printExpectedReceivedCallsPositive(
|
| 1016 |
+
expected,
|
| 1017 |
+
indexedCalls,
|
| 1018 |
+
isExpand(this.expand),
|
| 1019 |
+
calls.length === 1,
|
| 1020 |
+
iNth
|
| 1021 |
+
) +
|
| 1022 |
+
`\nNumber of calls: ${(0, _jestMatcherUtils.printReceived)(
|
| 1023 |
+
calls.length
|
| 1024 |
+
)}`
|
| 1025 |
+
);
|
| 1026 |
+
};
|
| 1027 |
+
return {
|
| 1028 |
+
message,
|
| 1029 |
+
pass
|
| 1030 |
+
};
|
| 1031 |
+
};
|
| 1032 |
+
const createNthReturnedWithMatcher = matcherName =>
|
| 1033 |
+
function (received, nth, expected) {
|
| 1034 |
+
const expectedArgument = 'n';
|
| 1035 |
+
const options = {
|
| 1036 |
+
expectedColor: arg => arg,
|
| 1037 |
+
isNot: this.isNot,
|
| 1038 |
+
promise: this.promise,
|
| 1039 |
+
secondArgument: 'expected'
|
| 1040 |
+
};
|
| 1041 |
+
ensureMock(received, matcherName, expectedArgument, options);
|
| 1042 |
+
if (!Number.isSafeInteger(nth) || nth < 1) {
|
| 1043 |
+
throw new Error(
|
| 1044 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 1045 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1046 |
+
matcherName,
|
| 1047 |
+
undefined,
|
| 1048 |
+
expectedArgument,
|
| 1049 |
+
options
|
| 1050 |
+
),
|
| 1051 |
+
`${expectedArgument} must be a positive integer`,
|
| 1052 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 1053 |
+
expectedArgument,
|
| 1054 |
+
nth,
|
| 1055 |
+
_jestMatcherUtils.stringify
|
| 1056 |
+
)
|
| 1057 |
+
)
|
| 1058 |
+
);
|
| 1059 |
+
}
|
| 1060 |
+
const receivedName = received.getMockName();
|
| 1061 |
+
const {calls, results} = received.mock;
|
| 1062 |
+
const length = results.length;
|
| 1063 |
+
const iNth = nth - 1;
|
| 1064 |
+
const pass = iNth < length && isEqualReturn(expected, results[iNth]);
|
| 1065 |
+
const message = pass
|
| 1066 |
+
? () => {
|
| 1067 |
+
// Display preceding and following results,
|
| 1068 |
+
// in case assertions fails because index is off by one.
|
| 1069 |
+
const indexedResults = [];
|
| 1070 |
+
if (iNth - 1 >= 0) {
|
| 1071 |
+
indexedResults.push([iNth - 1, results[iNth - 1]]);
|
| 1072 |
+
}
|
| 1073 |
+
indexedResults.push([iNth, results[iNth]]);
|
| 1074 |
+
if (iNth + 1 < length) {
|
| 1075 |
+
indexedResults.push([iNth + 1, results[iNth + 1]]);
|
| 1076 |
+
}
|
| 1077 |
+
return (
|
| 1078 |
+
// eslint-disable-next-line prefer-template
|
| 1079 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1080 |
+
matcherName,
|
| 1081 |
+
receivedName,
|
| 1082 |
+
expectedArgument,
|
| 1083 |
+
options
|
| 1084 |
+
) +
|
| 1085 |
+
'\n\n' +
|
| 1086 |
+
`n: ${nth}\n` +
|
| 1087 |
+
`Expected: not ${(0, _jestMatcherUtils.printExpected)(
|
| 1088 |
+
expected
|
| 1089 |
+
)}\n` +
|
| 1090 |
+
(results.length === 1 &&
|
| 1091 |
+
results[0].type === 'return' &&
|
| 1092 |
+
(0, _jestMatcherUtils.stringify)(results[0].value) ===
|
| 1093 |
+
(0, _jestMatcherUtils.stringify)(expected)
|
| 1094 |
+
? ''
|
| 1095 |
+
: printReceivedResults(
|
| 1096 |
+
'Received: ',
|
| 1097 |
+
expected,
|
| 1098 |
+
indexedResults,
|
| 1099 |
+
results.length === 1,
|
| 1100 |
+
iNth
|
| 1101 |
+
)) +
|
| 1102 |
+
printNumberOfReturns(countReturns(results), calls.length)
|
| 1103 |
+
);
|
| 1104 |
+
}
|
| 1105 |
+
: () => {
|
| 1106 |
+
// Display preceding and following results:
|
| 1107 |
+
// * nearest result that is equal to expected value
|
| 1108 |
+
// * otherwise, adjacent result
|
| 1109 |
+
// in case assertions fails because of index, especially off by one.
|
| 1110 |
+
const indexedResults = [];
|
| 1111 |
+
if (iNth < length) {
|
| 1112 |
+
if (iNth - 1 >= 0) {
|
| 1113 |
+
let i = iNth - 1;
|
| 1114 |
+
// Is there a preceding result that is equal to expected value?
|
| 1115 |
+
while (i >= 0 && !isEqualReturn(expected, results[i])) {
|
| 1116 |
+
i -= 1;
|
| 1117 |
+
}
|
| 1118 |
+
if (i < 0) {
|
| 1119 |
+
i = iNth - 1; // otherwise, adjacent result
|
| 1120 |
+
}
|
| 1121 |
+
|
| 1122 |
+
indexedResults.push([i, results[i]]);
|
| 1123 |
+
}
|
| 1124 |
+
indexedResults.push([iNth, results[iNth]]);
|
| 1125 |
+
if (iNth + 1 < length) {
|
| 1126 |
+
let i = iNth + 1;
|
| 1127 |
+
// Is there a following result that is equal to expected value?
|
| 1128 |
+
while (i < length && !isEqualReturn(expected, results[i])) {
|
| 1129 |
+
i += 1;
|
| 1130 |
+
}
|
| 1131 |
+
if (i >= length) {
|
| 1132 |
+
i = iNth + 1; // otherwise, adjacent result
|
| 1133 |
+
}
|
| 1134 |
+
|
| 1135 |
+
indexedResults.push([i, results[i]]);
|
| 1136 |
+
}
|
| 1137 |
+
} else if (length > 0) {
|
| 1138 |
+
// The number of received calls is fewer than the expected number.
|
| 1139 |
+
let i = length - 1;
|
| 1140 |
+
// Is there a result that is equal to expected value?
|
| 1141 |
+
while (i >= 0 && !isEqualReturn(expected, results[i])) {
|
| 1142 |
+
i -= 1;
|
| 1143 |
+
}
|
| 1144 |
+
if (i < 0) {
|
| 1145 |
+
i = length - 1; // otherwise, last result
|
| 1146 |
+
}
|
| 1147 |
+
|
| 1148 |
+
indexedResults.push([i, results[i]]);
|
| 1149 |
+
}
|
| 1150 |
+
return (
|
| 1151 |
+
// eslint-disable-next-line prefer-template
|
| 1152 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1153 |
+
matcherName,
|
| 1154 |
+
receivedName,
|
| 1155 |
+
expectedArgument,
|
| 1156 |
+
options
|
| 1157 |
+
) +
|
| 1158 |
+
'\n\n' +
|
| 1159 |
+
`n: ${nth}\n` +
|
| 1160 |
+
`Expected: ${(0, _jestMatcherUtils.printExpected)(expected)}\n` +
|
| 1161 |
+
printReceivedResults(
|
| 1162 |
+
'Received: ',
|
| 1163 |
+
expected,
|
| 1164 |
+
indexedResults,
|
| 1165 |
+
results.length === 1,
|
| 1166 |
+
iNth
|
| 1167 |
+
) +
|
| 1168 |
+
printNumberOfReturns(countReturns(results), calls.length)
|
| 1169 |
+
);
|
| 1170 |
+
};
|
| 1171 |
+
return {
|
| 1172 |
+
message,
|
| 1173 |
+
pass
|
| 1174 |
+
};
|
| 1175 |
+
};
|
| 1176 |
+
const spyMatchers = {
|
| 1177 |
+
lastCalledWith: createLastCalledWithMatcher('lastCalledWith'),
|
| 1178 |
+
lastReturnedWith: createLastReturnedMatcher('lastReturnedWith'),
|
| 1179 |
+
nthCalledWith: createNthCalledWithMatcher('nthCalledWith'),
|
| 1180 |
+
nthReturnedWith: createNthReturnedWithMatcher('nthReturnedWith'),
|
| 1181 |
+
toBeCalled: createToBeCalledMatcher('toBeCalled'),
|
| 1182 |
+
toBeCalledTimes: createToBeCalledTimesMatcher('toBeCalledTimes'),
|
| 1183 |
+
toBeCalledWith: createToBeCalledWithMatcher('toBeCalledWith'),
|
| 1184 |
+
toHaveBeenCalled: createToBeCalledMatcher('toHaveBeenCalled'),
|
| 1185 |
+
toHaveBeenCalledTimes: createToBeCalledTimesMatcher('toHaveBeenCalledTimes'),
|
| 1186 |
+
toHaveBeenCalledWith: createToBeCalledWithMatcher('toHaveBeenCalledWith'),
|
| 1187 |
+
toHaveBeenLastCalledWith: createLastCalledWithMatcher(
|
| 1188 |
+
'toHaveBeenLastCalledWith'
|
| 1189 |
+
),
|
| 1190 |
+
toHaveBeenNthCalledWith: createNthCalledWithMatcher(
|
| 1191 |
+
'toHaveBeenNthCalledWith'
|
| 1192 |
+
),
|
| 1193 |
+
toHaveLastReturnedWith: createLastReturnedMatcher('toHaveLastReturnedWith'),
|
| 1194 |
+
toHaveNthReturnedWith: createNthReturnedWithMatcher('toHaveNthReturnedWith'),
|
| 1195 |
+
toHaveReturned: createToReturnMatcher('toHaveReturned'),
|
| 1196 |
+
toHaveReturnedTimes: createToReturnTimesMatcher('toHaveReturnedTimes'),
|
| 1197 |
+
toHaveReturnedWith: createToReturnWithMatcher('toHaveReturnedWith'),
|
| 1198 |
+
toReturn: createToReturnMatcher('toReturn'),
|
| 1199 |
+
toReturnTimes: createToReturnTimesMatcher('toReturnTimes'),
|
| 1200 |
+
toReturnWith: createToReturnWithMatcher('toReturnWith')
|
| 1201 |
+
};
|
| 1202 |
+
const isMock = received =>
|
| 1203 |
+
received != null && received._isMockFunction === true;
|
| 1204 |
+
const isSpy = received =>
|
| 1205 |
+
received != null &&
|
| 1206 |
+
received.calls != null &&
|
| 1207 |
+
typeof received.calls.all === 'function' &&
|
| 1208 |
+
typeof received.calls.count === 'function';
|
| 1209 |
+
const ensureMockOrSpy = (received, matcherName, expectedArgument, options) => {
|
| 1210 |
+
if (!isMock(received) && !isSpy(received)) {
|
| 1211 |
+
throw new Error(
|
| 1212 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 1213 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1214 |
+
matcherName,
|
| 1215 |
+
undefined,
|
| 1216 |
+
expectedArgument,
|
| 1217 |
+
options
|
| 1218 |
+
),
|
| 1219 |
+
`${(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 1220 |
+
'received'
|
| 1221 |
+
)} value must be a mock or spy function`,
|
| 1222 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 1223 |
+
'Received',
|
| 1224 |
+
received,
|
| 1225 |
+
_jestMatcherUtils.printReceived
|
| 1226 |
+
)
|
| 1227 |
+
)
|
| 1228 |
+
);
|
| 1229 |
+
}
|
| 1230 |
+
};
|
| 1231 |
+
const ensureMock = (received, matcherName, expectedArgument, options) => {
|
| 1232 |
+
if (!isMock(received)) {
|
| 1233 |
+
throw new Error(
|
| 1234 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 1235 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 1236 |
+
matcherName,
|
| 1237 |
+
undefined,
|
| 1238 |
+
expectedArgument,
|
| 1239 |
+
options
|
| 1240 |
+
),
|
| 1241 |
+
`${(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 1242 |
+
'received'
|
| 1243 |
+
)} value must be a mock function`,
|
| 1244 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 1245 |
+
'Received',
|
| 1246 |
+
received,
|
| 1247 |
+
_jestMatcherUtils.printReceived
|
| 1248 |
+
)
|
| 1249 |
+
)
|
| 1250 |
+
);
|
| 1251 |
+
}
|
| 1252 |
+
};
|
| 1253 |
+
var _default = spyMatchers;
|
| 1254 |
+
exports.default = _default;
|
novas/novacore-zephyr/claude-code-router/node_modules/expect/build/toThrowMatchers.js
ADDED
|
@@ -0,0 +1,481 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = exports.createMatcher = void 0;
|
| 7 |
+
var _expectUtils = require('@jest/expect-utils');
|
| 8 |
+
var _jestMatcherUtils = require('jest-matcher-utils');
|
| 9 |
+
var _jestMessageUtil = require('jest-message-util');
|
| 10 |
+
var _print = require('./print');
|
| 11 |
+
/**
|
| 12 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 13 |
+
*
|
| 14 |
+
* This source code is licensed under the MIT license found in the
|
| 15 |
+
* LICENSE file in the root directory of this source tree.
|
| 16 |
+
*
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
/* eslint-disable local/ban-types-eventually */
|
| 20 |
+
|
| 21 |
+
const DID_NOT_THROW = 'Received function did not throw';
|
| 22 |
+
const getThrown = e => {
|
| 23 |
+
const hasMessage =
|
| 24 |
+
e !== null && e !== undefined && typeof e.message === 'string';
|
| 25 |
+
if (hasMessage && typeof e.name === 'string' && typeof e.stack === 'string') {
|
| 26 |
+
return {
|
| 27 |
+
hasMessage,
|
| 28 |
+
isError: true,
|
| 29 |
+
message: e.message,
|
| 30 |
+
value: e
|
| 31 |
+
};
|
| 32 |
+
}
|
| 33 |
+
return {
|
| 34 |
+
hasMessage,
|
| 35 |
+
isError: false,
|
| 36 |
+
message: hasMessage ? e.message : String(e),
|
| 37 |
+
value: e
|
| 38 |
+
};
|
| 39 |
+
};
|
| 40 |
+
const createMatcher = (matcherName, fromPromise) =>
|
| 41 |
+
function (received, expected) {
|
| 42 |
+
const options = {
|
| 43 |
+
isNot: this.isNot,
|
| 44 |
+
promise: this.promise
|
| 45 |
+
};
|
| 46 |
+
let thrown = null;
|
| 47 |
+
if (fromPromise && (0, _expectUtils.isError)(received)) {
|
| 48 |
+
thrown = getThrown(received);
|
| 49 |
+
} else {
|
| 50 |
+
if (typeof received !== 'function') {
|
| 51 |
+
if (!fromPromise) {
|
| 52 |
+
const placeholder = expected === undefined ? '' : 'expected';
|
| 53 |
+
throw new Error(
|
| 54 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 55 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 56 |
+
matcherName,
|
| 57 |
+
undefined,
|
| 58 |
+
placeholder,
|
| 59 |
+
options
|
| 60 |
+
),
|
| 61 |
+
`${(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
| 62 |
+
'received'
|
| 63 |
+
)} value must be a function`,
|
| 64 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 65 |
+
'Received',
|
| 66 |
+
received,
|
| 67 |
+
_jestMatcherUtils.printReceived
|
| 68 |
+
)
|
| 69 |
+
)
|
| 70 |
+
);
|
| 71 |
+
}
|
| 72 |
+
} else {
|
| 73 |
+
try {
|
| 74 |
+
received();
|
| 75 |
+
} catch (e) {
|
| 76 |
+
thrown = getThrown(e);
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
if (expected === undefined) {
|
| 81 |
+
return toThrow(matcherName, options, thrown);
|
| 82 |
+
} else if (typeof expected === 'function') {
|
| 83 |
+
return toThrowExpectedClass(matcherName, options, thrown, expected);
|
| 84 |
+
} else if (typeof expected === 'string') {
|
| 85 |
+
return toThrowExpectedString(matcherName, options, thrown, expected);
|
| 86 |
+
} else if (expected !== null && typeof expected.test === 'function') {
|
| 87 |
+
return toThrowExpectedRegExp(matcherName, options, thrown, expected);
|
| 88 |
+
} else if (
|
| 89 |
+
expected !== null &&
|
| 90 |
+
typeof expected.asymmetricMatch === 'function'
|
| 91 |
+
) {
|
| 92 |
+
return toThrowExpectedAsymmetric(matcherName, options, thrown, expected);
|
| 93 |
+
} else if (expected !== null && typeof expected === 'object') {
|
| 94 |
+
return toThrowExpectedObject(matcherName, options, thrown, expected);
|
| 95 |
+
} else {
|
| 96 |
+
throw new Error(
|
| 97 |
+
(0, _jestMatcherUtils.matcherErrorMessage)(
|
| 98 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 99 |
+
matcherName,
|
| 100 |
+
undefined,
|
| 101 |
+
undefined,
|
| 102 |
+
options
|
| 103 |
+
),
|
| 104 |
+
`${(0, _jestMatcherUtils.EXPECTED_COLOR)(
|
| 105 |
+
'expected'
|
| 106 |
+
)} value must be a string or regular expression or class or error`,
|
| 107 |
+
(0, _jestMatcherUtils.printWithType)(
|
| 108 |
+
'Expected',
|
| 109 |
+
expected,
|
| 110 |
+
_jestMatcherUtils.printExpected
|
| 111 |
+
)
|
| 112 |
+
)
|
| 113 |
+
);
|
| 114 |
+
}
|
| 115 |
+
};
|
| 116 |
+
exports.createMatcher = createMatcher;
|
| 117 |
+
const matchers = {
|
| 118 |
+
toThrow: createMatcher('toThrow'),
|
| 119 |
+
toThrowError: createMatcher('toThrowError')
|
| 120 |
+
};
|
| 121 |
+
const toThrowExpectedRegExp = (matcherName, options, thrown, expected) => {
|
| 122 |
+
const pass = thrown !== null && expected.test(thrown.message);
|
| 123 |
+
const message = pass
|
| 124 |
+
? () =>
|
| 125 |
+
// eslint-disable-next-line prefer-template
|
| 126 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 127 |
+
matcherName,
|
| 128 |
+
undefined,
|
| 129 |
+
undefined,
|
| 130 |
+
options
|
| 131 |
+
) +
|
| 132 |
+
'\n\n' +
|
| 133 |
+
formatExpected('Expected pattern: not ', expected) +
|
| 134 |
+
(thrown !== null && thrown.hasMessage
|
| 135 |
+
? formatReceived(
|
| 136 |
+
'Received message: ',
|
| 137 |
+
thrown,
|
| 138 |
+
'message',
|
| 139 |
+
expected
|
| 140 |
+
) + formatStack(thrown)
|
| 141 |
+
: formatReceived('Received value: ', thrown, 'value'))
|
| 142 |
+
: () =>
|
| 143 |
+
// eslint-disable-next-line prefer-template
|
| 144 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 145 |
+
matcherName,
|
| 146 |
+
undefined,
|
| 147 |
+
undefined,
|
| 148 |
+
options
|
| 149 |
+
) +
|
| 150 |
+
'\n\n' +
|
| 151 |
+
formatExpected('Expected pattern: ', expected) +
|
| 152 |
+
(thrown === null
|
| 153 |
+
? `\n${DID_NOT_THROW}`
|
| 154 |
+
: thrown.hasMessage
|
| 155 |
+
? formatReceived('Received message: ', thrown, 'message') +
|
| 156 |
+
formatStack(thrown)
|
| 157 |
+
: formatReceived('Received value: ', thrown, 'value'));
|
| 158 |
+
return {
|
| 159 |
+
message,
|
| 160 |
+
pass
|
| 161 |
+
};
|
| 162 |
+
};
|
| 163 |
+
const toThrowExpectedAsymmetric = (matcherName, options, thrown, expected) => {
|
| 164 |
+
const pass = thrown !== null && expected.asymmetricMatch(thrown.value);
|
| 165 |
+
const message = pass
|
| 166 |
+
? () =>
|
| 167 |
+
// eslint-disable-next-line prefer-template
|
| 168 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 169 |
+
matcherName,
|
| 170 |
+
undefined,
|
| 171 |
+
undefined,
|
| 172 |
+
options
|
| 173 |
+
) +
|
| 174 |
+
'\n\n' +
|
| 175 |
+
formatExpected('Expected asymmetric matcher: not ', expected) +
|
| 176 |
+
'\n' +
|
| 177 |
+
(thrown !== null && thrown.hasMessage
|
| 178 |
+
? formatReceived('Received name: ', thrown, 'name') +
|
| 179 |
+
formatReceived('Received message: ', thrown, 'message') +
|
| 180 |
+
formatStack(thrown)
|
| 181 |
+
: formatReceived('Thrown value: ', thrown, 'value'))
|
| 182 |
+
: () =>
|
| 183 |
+
// eslint-disable-next-line prefer-template
|
| 184 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 185 |
+
matcherName,
|
| 186 |
+
undefined,
|
| 187 |
+
undefined,
|
| 188 |
+
options
|
| 189 |
+
) +
|
| 190 |
+
'\n\n' +
|
| 191 |
+
formatExpected('Expected asymmetric matcher: ', expected) +
|
| 192 |
+
'\n' +
|
| 193 |
+
(thrown === null
|
| 194 |
+
? DID_NOT_THROW
|
| 195 |
+
: thrown.hasMessage
|
| 196 |
+
? formatReceived('Received name: ', thrown, 'name') +
|
| 197 |
+
formatReceived('Received message: ', thrown, 'message') +
|
| 198 |
+
formatStack(thrown)
|
| 199 |
+
: formatReceived('Thrown value: ', thrown, 'value'));
|
| 200 |
+
return {
|
| 201 |
+
message,
|
| 202 |
+
pass
|
| 203 |
+
};
|
| 204 |
+
};
|
| 205 |
+
const toThrowExpectedObject = (matcherName, options, thrown, expected) => {
|
| 206 |
+
const expectedMessageAndCause = createMessageAndCause(expected);
|
| 207 |
+
const thrownMessageAndCause =
|
| 208 |
+
thrown !== null ? createMessageAndCause(thrown.value) : null;
|
| 209 |
+
const pass =
|
| 210 |
+
thrown !== null &&
|
| 211 |
+
thrown.message === expected.message &&
|
| 212 |
+
thrownMessageAndCause === expectedMessageAndCause;
|
| 213 |
+
const message = pass
|
| 214 |
+
? () =>
|
| 215 |
+
// eslint-disable-next-line prefer-template
|
| 216 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 217 |
+
matcherName,
|
| 218 |
+
undefined,
|
| 219 |
+
undefined,
|
| 220 |
+
options
|
| 221 |
+
) +
|
| 222 |
+
'\n\n' +
|
| 223 |
+
formatExpected(
|
| 224 |
+
`Expected ${messageAndCause(expected)}: not `,
|
| 225 |
+
expectedMessageAndCause
|
| 226 |
+
) +
|
| 227 |
+
(thrown !== null && thrown.hasMessage
|
| 228 |
+
? formatStack(thrown)
|
| 229 |
+
: formatReceived('Received value: ', thrown, 'value'))
|
| 230 |
+
: () =>
|
| 231 |
+
// eslint-disable-next-line prefer-template
|
| 232 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 233 |
+
matcherName,
|
| 234 |
+
undefined,
|
| 235 |
+
undefined,
|
| 236 |
+
options
|
| 237 |
+
) +
|
| 238 |
+
'\n\n' +
|
| 239 |
+
(thrown === null
|
| 240 |
+
? // eslint-disable-next-line prefer-template
|
| 241 |
+
formatExpected(
|
| 242 |
+
`Expected ${messageAndCause(expected)}: `,
|
| 243 |
+
expectedMessageAndCause
|
| 244 |
+
) +
|
| 245 |
+
'\n' +
|
| 246 |
+
DID_NOT_THROW
|
| 247 |
+
: thrown.hasMessage
|
| 248 |
+
? // eslint-disable-next-line prefer-template
|
| 249 |
+
(0, _jestMatcherUtils.printDiffOrStringify)(
|
| 250 |
+
expectedMessageAndCause,
|
| 251 |
+
thrownMessageAndCause,
|
| 252 |
+
`Expected ${messageAndCause(expected)}`,
|
| 253 |
+
`Received ${messageAndCause(thrown.value)}`,
|
| 254 |
+
true
|
| 255 |
+
) +
|
| 256 |
+
'\n' +
|
| 257 |
+
formatStack(thrown)
|
| 258 |
+
: formatExpected(
|
| 259 |
+
`Expected ${messageAndCause(expected)}: `,
|
| 260 |
+
expectedMessageAndCause
|
| 261 |
+
) + formatReceived('Received value: ', thrown, 'value'));
|
| 262 |
+
return {
|
| 263 |
+
message,
|
| 264 |
+
pass
|
| 265 |
+
};
|
| 266 |
+
};
|
| 267 |
+
const toThrowExpectedClass = (matcherName, options, thrown, expected) => {
|
| 268 |
+
const pass = thrown !== null && thrown.value instanceof expected;
|
| 269 |
+
const message = pass
|
| 270 |
+
? () =>
|
| 271 |
+
// eslint-disable-next-line prefer-template
|
| 272 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 273 |
+
matcherName,
|
| 274 |
+
undefined,
|
| 275 |
+
undefined,
|
| 276 |
+
options
|
| 277 |
+
) +
|
| 278 |
+
'\n\n' +
|
| 279 |
+
(0, _print.printExpectedConstructorNameNot)(
|
| 280 |
+
'Expected constructor',
|
| 281 |
+
expected
|
| 282 |
+
) +
|
| 283 |
+
(thrown !== null &&
|
| 284 |
+
thrown.value != null &&
|
| 285 |
+
typeof thrown.value.constructor === 'function' &&
|
| 286 |
+
thrown.value.constructor !== expected
|
| 287 |
+
? (0, _print.printReceivedConstructorNameNot)(
|
| 288 |
+
'Received constructor',
|
| 289 |
+
thrown.value.constructor,
|
| 290 |
+
expected
|
| 291 |
+
)
|
| 292 |
+
: '') +
|
| 293 |
+
'\n' +
|
| 294 |
+
(thrown !== null && thrown.hasMessage
|
| 295 |
+
? formatReceived('Received message: ', thrown, 'message') +
|
| 296 |
+
formatStack(thrown)
|
| 297 |
+
: formatReceived('Received value: ', thrown, 'value'))
|
| 298 |
+
: () =>
|
| 299 |
+
// eslint-disable-next-line prefer-template
|
| 300 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 301 |
+
matcherName,
|
| 302 |
+
undefined,
|
| 303 |
+
undefined,
|
| 304 |
+
options
|
| 305 |
+
) +
|
| 306 |
+
'\n\n' +
|
| 307 |
+
(0, _print.printExpectedConstructorName)(
|
| 308 |
+
'Expected constructor',
|
| 309 |
+
expected
|
| 310 |
+
) +
|
| 311 |
+
(thrown === null
|
| 312 |
+
? `\n${DID_NOT_THROW}`
|
| 313 |
+
: `${
|
| 314 |
+
thrown.value != null &&
|
| 315 |
+
typeof thrown.value.constructor === 'function'
|
| 316 |
+
? (0, _print.printReceivedConstructorName)(
|
| 317 |
+
'Received constructor',
|
| 318 |
+
thrown.value.constructor
|
| 319 |
+
)
|
| 320 |
+
: ''
|
| 321 |
+
}\n${
|
| 322 |
+
thrown.hasMessage
|
| 323 |
+
? formatReceived('Received message: ', thrown, 'message') +
|
| 324 |
+
formatStack(thrown)
|
| 325 |
+
: formatReceived('Received value: ', thrown, 'value')
|
| 326 |
+
}`);
|
| 327 |
+
return {
|
| 328 |
+
message,
|
| 329 |
+
pass
|
| 330 |
+
};
|
| 331 |
+
};
|
| 332 |
+
const toThrowExpectedString = (matcherName, options, thrown, expected) => {
|
| 333 |
+
const pass = thrown !== null && thrown.message.includes(expected);
|
| 334 |
+
const message = pass
|
| 335 |
+
? () =>
|
| 336 |
+
// eslint-disable-next-line prefer-template
|
| 337 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 338 |
+
matcherName,
|
| 339 |
+
undefined,
|
| 340 |
+
undefined,
|
| 341 |
+
options
|
| 342 |
+
) +
|
| 343 |
+
'\n\n' +
|
| 344 |
+
formatExpected('Expected substring: not ', expected) +
|
| 345 |
+
(thrown !== null && thrown.hasMessage
|
| 346 |
+
? formatReceived(
|
| 347 |
+
'Received message: ',
|
| 348 |
+
thrown,
|
| 349 |
+
'message',
|
| 350 |
+
expected
|
| 351 |
+
) + formatStack(thrown)
|
| 352 |
+
: formatReceived('Received value: ', thrown, 'value'))
|
| 353 |
+
: () =>
|
| 354 |
+
// eslint-disable-next-line prefer-template
|
| 355 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 356 |
+
matcherName,
|
| 357 |
+
undefined,
|
| 358 |
+
undefined,
|
| 359 |
+
options
|
| 360 |
+
) +
|
| 361 |
+
'\n\n' +
|
| 362 |
+
formatExpected('Expected substring: ', expected) +
|
| 363 |
+
(thrown === null
|
| 364 |
+
? `\n${DID_NOT_THROW}`
|
| 365 |
+
: thrown.hasMessage
|
| 366 |
+
? formatReceived('Received message: ', thrown, 'message') +
|
| 367 |
+
formatStack(thrown)
|
| 368 |
+
: formatReceived('Received value: ', thrown, 'value'));
|
| 369 |
+
return {
|
| 370 |
+
message,
|
| 371 |
+
pass
|
| 372 |
+
};
|
| 373 |
+
};
|
| 374 |
+
const toThrow = (matcherName, options, thrown) => {
|
| 375 |
+
const pass = thrown !== null;
|
| 376 |
+
const message = pass
|
| 377 |
+
? () =>
|
| 378 |
+
// eslint-disable-next-line prefer-template
|
| 379 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 380 |
+
matcherName,
|
| 381 |
+
undefined,
|
| 382 |
+
'',
|
| 383 |
+
options
|
| 384 |
+
) +
|
| 385 |
+
'\n\n' +
|
| 386 |
+
(thrown !== null && thrown.hasMessage
|
| 387 |
+
? formatReceived('Error name: ', thrown, 'name') +
|
| 388 |
+
formatReceived('Error message: ', thrown, 'message') +
|
| 389 |
+
formatStack(thrown)
|
| 390 |
+
: formatReceived('Thrown value: ', thrown, 'value'))
|
| 391 |
+
: () =>
|
| 392 |
+
// eslint-disable-next-line prefer-template
|
| 393 |
+
(0, _jestMatcherUtils.matcherHint)(
|
| 394 |
+
matcherName,
|
| 395 |
+
undefined,
|
| 396 |
+
'',
|
| 397 |
+
options
|
| 398 |
+
) +
|
| 399 |
+
'\n\n' +
|
| 400 |
+
DID_NOT_THROW;
|
| 401 |
+
return {
|
| 402 |
+
message,
|
| 403 |
+
pass
|
| 404 |
+
};
|
| 405 |
+
};
|
| 406 |
+
const formatExpected = (label, expected) =>
|
| 407 |
+
`${label + (0, _jestMatcherUtils.printExpected)(expected)}\n`;
|
| 408 |
+
const formatReceived = (label, thrown, key, expected) => {
|
| 409 |
+
if (thrown === null) {
|
| 410 |
+
return '';
|
| 411 |
+
}
|
| 412 |
+
if (key === 'message') {
|
| 413 |
+
const message = thrown.message;
|
| 414 |
+
if (typeof expected === 'string') {
|
| 415 |
+
const index = message.indexOf(expected);
|
| 416 |
+
if (index !== -1) {
|
| 417 |
+
return `${
|
| 418 |
+
label +
|
| 419 |
+
(0, _print.printReceivedStringContainExpectedSubstring)(
|
| 420 |
+
message,
|
| 421 |
+
index,
|
| 422 |
+
expected.length
|
| 423 |
+
)
|
| 424 |
+
}\n`;
|
| 425 |
+
}
|
| 426 |
+
} else if (expected instanceof RegExp) {
|
| 427 |
+
return `${
|
| 428 |
+
label +
|
| 429 |
+
(0, _print.printReceivedStringContainExpectedResult)(
|
| 430 |
+
message,
|
| 431 |
+
typeof expected.exec === 'function' ? expected.exec(message) : null
|
| 432 |
+
)
|
| 433 |
+
}\n`;
|
| 434 |
+
}
|
| 435 |
+
return `${label + (0, _jestMatcherUtils.printReceived)(message)}\n`;
|
| 436 |
+
}
|
| 437 |
+
if (key === 'name') {
|
| 438 |
+
return thrown.isError
|
| 439 |
+
? `${label + (0, _jestMatcherUtils.printReceived)(thrown.value.name)}\n`
|
| 440 |
+
: '';
|
| 441 |
+
}
|
| 442 |
+
if (key === 'value') {
|
| 443 |
+
return thrown.isError
|
| 444 |
+
? ''
|
| 445 |
+
: `${label + (0, _jestMatcherUtils.printReceived)(thrown.value)}\n`;
|
| 446 |
+
}
|
| 447 |
+
return '';
|
| 448 |
+
};
|
| 449 |
+
const formatStack = thrown =>
|
| 450 |
+
thrown === null || !thrown.isError
|
| 451 |
+
? ''
|
| 452 |
+
: (0, _jestMessageUtil.formatStackTrace)(
|
| 453 |
+
(0, _jestMessageUtil.separateMessageFromStack)(thrown.value.stack)
|
| 454 |
+
.stack,
|
| 455 |
+
{
|
| 456 |
+
rootDir: process.cwd(),
|
| 457 |
+
testMatch: []
|
| 458 |
+
},
|
| 459 |
+
{
|
| 460 |
+
noStackTrace: false
|
| 461 |
+
}
|
| 462 |
+
);
|
| 463 |
+
function createMessageAndCauseMessage(error) {
|
| 464 |
+
if (error.cause instanceof Error) {
|
| 465 |
+
return `{ message: ${error.message}, cause: ${createMessageAndCauseMessage(
|
| 466 |
+
error.cause
|
| 467 |
+
)}}`;
|
| 468 |
+
}
|
| 469 |
+
return `{ message: ${error.message} }`;
|
| 470 |
+
}
|
| 471 |
+
function createMessageAndCause(error) {
|
| 472 |
+
if (error.cause instanceof Error) {
|
| 473 |
+
return createMessageAndCauseMessage(error);
|
| 474 |
+
}
|
| 475 |
+
return error.message;
|
| 476 |
+
}
|
| 477 |
+
function messageAndCause(error) {
|
| 478 |
+
return error.cause === undefined ? 'message' : 'message and cause';
|
| 479 |
+
}
|
| 480 |
+
var _default = matchers;
|
| 481 |
+
exports.default = _default;
|
novas/novacore-zephyr/claude-code-router/node_modules/expect/build/types.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var _jestMatchersObject = require('./jestMatchersObject');
|
novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/import-es6-export-test.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import idObj from '../test-redirections/idObjES6Export';
|
| 2 |
+
|
| 3 |
+
describe('idObj', () => {
|
| 4 |
+
it('should return the key as a string', () => {
|
| 5 |
+
expect(idObj.foo).toBe('foo');
|
| 6 |
+
});
|
| 7 |
+
it('should support dot notation', () => {
|
| 8 |
+
expect(idObj.bar).toBe('bar');
|
| 9 |
+
});
|
| 10 |
+
it('should support bracket notation', () => {
|
| 11 |
+
expect(idObj[1]).toBe('1');
|
| 12 |
+
});
|
| 13 |
+
});
|
novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/import-es6-import-export-test.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import idObj from '../test-redirections/idObjES6ImportExport';
|
| 2 |
+
|
| 3 |
+
describe('idObj', () => {
|
| 4 |
+
it('should return the key as a string', () => {
|
| 5 |
+
expect(idObj.foo).toBe('foo');
|
| 6 |
+
});
|
| 7 |
+
it('should support dot notation', () => {
|
| 8 |
+
expect(idObj.bar).toBe('bar');
|
| 9 |
+
});
|
| 10 |
+
it('should support bracket notation', () => {
|
| 11 |
+
expect(idObj[1]).toBe('1');
|
| 12 |
+
});
|
| 13 |
+
});
|
novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/import-es6-import-test.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import idObj from '../test-redirections/idObjES6Import';
|
| 2 |
+
|
| 3 |
+
describe('idObj', () => {
|
| 4 |
+
it('should return the key as a string', () => {
|
| 5 |
+
expect(idObj.foo).toBe('foo');
|
| 6 |
+
});
|
| 7 |
+
it('should support dot notation', () => {
|
| 8 |
+
expect(idObj.bar).toBe('bar');
|
| 9 |
+
});
|
| 10 |
+
it('should support bracket notation', () => {
|
| 11 |
+
expect(idObj[1]).toBe('1');
|
| 12 |
+
});
|
| 13 |
+
});
|
novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/import-vanilla-test.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import idObj from '..';
|
| 2 |
+
|
| 3 |
+
describe('idObj', () => {
|
| 4 |
+
it('should return the key as a string', () => {
|
| 5 |
+
expect(idObj.foo).toBe('foo');
|
| 6 |
+
});
|
| 7 |
+
it('should support dot notation', () => {
|
| 8 |
+
expect(idObj.bar).toBe('bar');
|
| 9 |
+
});
|
| 10 |
+
it('should support bracket notation', () => {
|
| 11 |
+
expect(idObj[1]).toBe('1');
|
| 12 |
+
});
|
| 13 |
+
});
|
novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/index-test.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const idObj = require('..');
|
| 2 |
+
|
| 3 |
+
describe('idObj', () => {
|
| 4 |
+
it('should return the key as a string', () => {
|
| 5 |
+
expect(idObj.foo).toBe('foo');
|
| 6 |
+
});
|
| 7 |
+
it('should support dot notation', () => {
|
| 8 |
+
expect(idObj.bar).toBe('bar');
|
| 9 |
+
});
|
| 10 |
+
it('should support bracket notation', () => {
|
| 11 |
+
expect(idObj[1]).toBe('1');
|
| 12 |
+
});
|
| 13 |
+
});
|
novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/require-es6-export-test.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const idObj = require('../test-redirections/idObjES6Export').default;
|
| 2 |
+
|
| 3 |
+
describe('idObj', () => {
|
| 4 |
+
it('should return the key as a string', () => {
|
| 5 |
+
expect(idObj.foo).toBe('foo');
|
| 6 |
+
});
|
| 7 |
+
it('should support dot notation', () => {
|
| 8 |
+
expect(idObj.bar).toBe('bar');
|
| 9 |
+
});
|
| 10 |
+
it('should support bracket notation', () => {
|
| 11 |
+
expect(idObj[1]).toBe('1');
|
| 12 |
+
});
|
| 13 |
+
});
|
novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/require-es6-import-export-test.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const idObj = require('../test-redirections/idObjES6ImportExport').default;
|
| 2 |
+
|
| 3 |
+
describe('idObj', () => {
|
| 4 |
+
it('should return the key as a string', () => {
|
| 5 |
+
expect(idObj.foo).toBe('foo');
|
| 6 |
+
});
|
| 7 |
+
it('should support dot notation', () => {
|
| 8 |
+
expect(idObj.bar).toBe('bar');
|
| 9 |
+
});
|
| 10 |
+
it('should support bracket notation', () => {
|
| 11 |
+
expect(idObj[1]).toBe('1');
|
| 12 |
+
});
|
| 13 |
+
});
|
novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/require-es6-import-test.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const idObj = require('../test-redirections/idObjES6Import');
|
| 2 |
+
|
| 3 |
+
describe('idObj', () => {
|
| 4 |
+
it('should return the key as a string', () => {
|
| 5 |
+
expect(idObj.foo).toBe('foo');
|
| 6 |
+
});
|
| 7 |
+
it('should support dot notation', () => {
|
| 8 |
+
expect(idObj.bar).toBe('bar');
|
| 9 |
+
});
|
| 10 |
+
it('should support bracket notation', () => {
|
| 11 |
+
expect(idObj[1]).toBe('1');
|
| 12 |
+
});
|
| 13 |
+
});
|
novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/__tests__/require-vanilla-test.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const idObj = require('..');
|
| 2 |
+
|
| 3 |
+
describe('idObj', () => {
|
| 4 |
+
it('should return the key as a string', () => {
|
| 5 |
+
expect(idObj.foo).toBe('foo');
|
| 6 |
+
});
|
| 7 |
+
it('should support dot notation', () => {
|
| 8 |
+
expect(idObj.bar).toBe('bar');
|
| 9 |
+
});
|
| 10 |
+
it('should support bracket notation', () => {
|
| 11 |
+
expect(idObj[1]).toBe('1');
|
| 12 |
+
});
|
| 13 |
+
});
|
novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* eslint-disable no-var, comma-dangle */
|
| 2 |
+
var Reflect; // eslint-disable-line no-unused-vars
|
| 3 |
+
var idObj;
|
| 4 |
+
|
| 5 |
+
function checkIsNodeV6OrAbove() {
|
| 6 |
+
if (typeof process === 'undefined') {
|
| 7 |
+
return false;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
return parseInt(process.versions.node.split('.')[0], 10) >= 6;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
if (!checkIsNodeV6OrAbove()) {
|
| 14 |
+
Reflect = require('harmony-reflect'); // eslint-disable-line global-require
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
idObj = new Proxy({}, {
|
| 18 |
+
get: function getter(target, key) {
|
| 19 |
+
if (key === '__esModule') {
|
| 20 |
+
return false;
|
| 21 |
+
}
|
| 22 |
+
return key;
|
| 23 |
+
}
|
| 24 |
+
});
|
| 25 |
+
|
| 26 |
+
module.exports = idObj;
|
novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/test-redirections/idObjES6Export.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const idObj = require('..');
|
| 2 |
+
|
| 3 |
+
export default idObj;
|
novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/test-redirections/idObjES6Import.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import idObj from '..';
|
| 2 |
+
|
| 3 |
+
module.exports = idObj;
|
novas/novacore-zephyr/claude-code-router/node_modules/identity-obj-proxy/src/test-redirections/idObjES6ImportExport.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import idObj from '..';
|
| 2 |
+
|
| 3 |
+
export default idObj;
|
novas/novacore-zephyr/claude-code-router/node_modules/istanbul-lib-source-maps/lib/get-mapping.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
Copyright 2015, Yahoo Inc.
|
| 3 |
+
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
| 4 |
+
*/
|
| 5 |
+
'use strict';
|
| 6 |
+
|
| 7 |
+
const pathutils = require('./pathutils');
|
| 8 |
+
const {
|
| 9 |
+
GREATEST_LOWER_BOUND,
|
| 10 |
+
LEAST_UPPER_BOUND
|
| 11 |
+
} = require('source-map').SourceMapConsumer;
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* AST ranges are inclusive for start positions and exclusive for end positions.
|
| 15 |
+
* Source maps are also logically ranges over text, though interacting with
|
| 16 |
+
* them is generally achieved by working with explicit positions.
|
| 17 |
+
*
|
| 18 |
+
* When finding the _end_ location of an AST item, the range behavior is
|
| 19 |
+
* important because what we're asking for is the _end_ of whatever range
|
| 20 |
+
* corresponds to the end location we seek.
|
| 21 |
+
*
|
| 22 |
+
* This boils down to the following steps, conceptually, though the source-map
|
| 23 |
+
* library doesn't expose primitives to do this nicely:
|
| 24 |
+
*
|
| 25 |
+
* 1. Find the range on the generated file that ends at, or exclusively
|
| 26 |
+
* contains the end position of the AST node.
|
| 27 |
+
* 2. Find the range on the original file that corresponds to
|
| 28 |
+
* that generated range.
|
| 29 |
+
* 3. Find the _end_ location of that original range.
|
| 30 |
+
*/
|
| 31 |
+
function originalEndPositionFor(sourceMap, generatedEnd) {
|
| 32 |
+
// Given the generated location, find the original location of the mapping
|
| 33 |
+
// that corresponds to a range on the generated file that overlaps the
|
| 34 |
+
// generated file end location. Note however that this position on its
|
| 35 |
+
// own is not useful because it is the position of the _start_ of the range
|
| 36 |
+
// on the original file, and we want the _end_ of the range.
|
| 37 |
+
const beforeEndMapping = originalPositionTryBoth(
|
| 38 |
+
sourceMap,
|
| 39 |
+
generatedEnd.line,
|
| 40 |
+
generatedEnd.column - 1
|
| 41 |
+
);
|
| 42 |
+
if (beforeEndMapping.source === null) {
|
| 43 |
+
return null;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
// Convert that original position back to a generated one, with a bump
|
| 47 |
+
// to the right, and a rightward bias. Since 'generatedPositionFor' searches
|
| 48 |
+
// for mappings in the original-order sorted list, this will find the
|
| 49 |
+
// mapping that corresponds to the one immediately after the
|
| 50 |
+
// beforeEndMapping mapping.
|
| 51 |
+
const afterEndMapping = sourceMap.generatedPositionFor({
|
| 52 |
+
source: beforeEndMapping.source,
|
| 53 |
+
line: beforeEndMapping.line,
|
| 54 |
+
column: beforeEndMapping.column + 1,
|
| 55 |
+
bias: LEAST_UPPER_BOUND
|
| 56 |
+
});
|
| 57 |
+
if (
|
| 58 |
+
// If this is null, it means that we've hit the end of the file,
|
| 59 |
+
// so we can use Infinity as the end column.
|
| 60 |
+
afterEndMapping.line === null ||
|
| 61 |
+
// If these don't match, it means that the call to
|
| 62 |
+
// 'generatedPositionFor' didn't find any other original mappings on
|
| 63 |
+
// the line we gave, so consider the binding to extend to infinity.
|
| 64 |
+
sourceMap.originalPositionFor(afterEndMapping).line !==
|
| 65 |
+
beforeEndMapping.line
|
| 66 |
+
) {
|
| 67 |
+
return {
|
| 68 |
+
source: beforeEndMapping.source,
|
| 69 |
+
line: beforeEndMapping.line,
|
| 70 |
+
column: Infinity
|
| 71 |
+
};
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
// Convert the end mapping into the real original position.
|
| 75 |
+
return sourceMap.originalPositionFor(afterEndMapping);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Attempts to determine the original source position, first
|
| 80 |
+
* returning the closest element to the left (GREATEST_LOWER_BOUND),
|
| 81 |
+
* and next returning the closest element to the right (LEAST_UPPER_BOUND).
|
| 82 |
+
*/
|
| 83 |
+
function originalPositionTryBoth(sourceMap, line, column) {
|
| 84 |
+
const mapping = sourceMap.originalPositionFor({
|
| 85 |
+
line,
|
| 86 |
+
column,
|
| 87 |
+
bias: GREATEST_LOWER_BOUND
|
| 88 |
+
});
|
| 89 |
+
if (mapping.source === null) {
|
| 90 |
+
return sourceMap.originalPositionFor({
|
| 91 |
+
line,
|
| 92 |
+
column,
|
| 93 |
+
bias: LEAST_UPPER_BOUND
|
| 94 |
+
});
|
| 95 |
+
} else {
|
| 96 |
+
return mapping;
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
function isInvalidPosition(pos) {
|
| 101 |
+
return (
|
| 102 |
+
!pos ||
|
| 103 |
+
typeof pos.line !== 'number' ||
|
| 104 |
+
typeof pos.column !== 'number' ||
|
| 105 |
+
pos.line < 0 ||
|
| 106 |
+
pos.column < 0
|
| 107 |
+
);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
* determines the original position for a given location
|
| 112 |
+
* @param {SourceMapConsumer} sourceMap the source map
|
| 113 |
+
* @param {Object} generatedLocation the original location Object
|
| 114 |
+
* @returns {Object} the remapped location Object
|
| 115 |
+
*/
|
| 116 |
+
function getMapping(sourceMap, generatedLocation, origFile) {
|
| 117 |
+
if (!generatedLocation) {
|
| 118 |
+
return null;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
if (
|
| 122 |
+
isInvalidPosition(generatedLocation.start) ||
|
| 123 |
+
isInvalidPosition(generatedLocation.end)
|
| 124 |
+
) {
|
| 125 |
+
return null;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
const start = originalPositionTryBoth(
|
| 129 |
+
sourceMap,
|
| 130 |
+
generatedLocation.start.line,
|
| 131 |
+
generatedLocation.start.column
|
| 132 |
+
);
|
| 133 |
+
let end = originalEndPositionFor(sourceMap, generatedLocation.end);
|
| 134 |
+
|
| 135 |
+
/* istanbul ignore if: edge case too hard to test for */
|
| 136 |
+
if (!(start && end)) {
|
| 137 |
+
return null;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
if (!(start.source && end.source)) {
|
| 141 |
+
return null;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
if (start.source !== end.source) {
|
| 145 |
+
return null;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
/* istanbul ignore if: edge case too hard to test for */
|
| 149 |
+
if (start.line === null || start.column === null) {
|
| 150 |
+
return null;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
/* istanbul ignore if: edge case too hard to test for */
|
| 154 |
+
if (end.line === null || end.column === null) {
|
| 155 |
+
return null;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
if (start.line === end.line && start.column === end.column) {
|
| 159 |
+
end = sourceMap.originalPositionFor({
|
| 160 |
+
line: generatedLocation.end.line,
|
| 161 |
+
column: generatedLocation.end.column,
|
| 162 |
+
bias: LEAST_UPPER_BOUND
|
| 163 |
+
});
|
| 164 |
+
end.column -= 1;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
return {
|
| 168 |
+
source: pathutils.relativeTo(start.source, origFile),
|
| 169 |
+
loc: {
|
| 170 |
+
start: {
|
| 171 |
+
line: start.line,
|
| 172 |
+
column: start.column
|
| 173 |
+
},
|
| 174 |
+
end: {
|
| 175 |
+
line: end.line,
|
| 176 |
+
column: end.column
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
};
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
module.exports = getMapping;
|
novas/novacore-zephyr/claude-code-router/node_modules/istanbul-lib-source-maps/lib/map-store.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
Copyright 2015, Yahoo Inc.
|
| 3 |
+
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
| 4 |
+
*/
|
| 5 |
+
'use strict';
|
| 6 |
+
|
| 7 |
+
const path = require('path');
|
| 8 |
+
const fs = require('fs');
|
| 9 |
+
const debug = require('debug')('istanbuljs');
|
| 10 |
+
const { SourceMapConsumer } = require('source-map');
|
| 11 |
+
const pathutils = require('./pathutils');
|
| 12 |
+
const { SourceMapTransformer } = require('./transformer');
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* Tracks source maps for registered files
|
| 16 |
+
*/
|
| 17 |
+
class MapStore {
|
| 18 |
+
/**
|
| 19 |
+
* @param {Object} opts [opts=undefined] options.
|
| 20 |
+
* @param {Boolean} opts.verbose [opts.verbose=false] verbose mode
|
| 21 |
+
* @param {String} opts.baseDir [opts.baseDir=null] alternate base directory
|
| 22 |
+
* to resolve sourcemap files
|
| 23 |
+
* @param {Class} opts.SourceStore [opts.SourceStore=Map] class to use for
|
| 24 |
+
* SourceStore. Must support `get`, `set` and `clear` methods.
|
| 25 |
+
* @param {Array} opts.sourceStoreOpts [opts.sourceStoreOpts=[]] arguments
|
| 26 |
+
* to use in the SourceStore constructor.
|
| 27 |
+
* @constructor
|
| 28 |
+
*/
|
| 29 |
+
constructor(opts) {
|
| 30 |
+
opts = {
|
| 31 |
+
baseDir: null,
|
| 32 |
+
verbose: false,
|
| 33 |
+
SourceStore: Map,
|
| 34 |
+
sourceStoreOpts: [],
|
| 35 |
+
...opts
|
| 36 |
+
};
|
| 37 |
+
this.baseDir = opts.baseDir;
|
| 38 |
+
this.verbose = opts.verbose;
|
| 39 |
+
this.sourceStore = new opts.SourceStore(...opts.sourceStoreOpts);
|
| 40 |
+
this.data = Object.create(null);
|
| 41 |
+
this.sourceFinder = this.sourceFinder.bind(this);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Registers a source map URL with this store. It makes some input sanity checks
|
| 46 |
+
* and silently fails on malformed input.
|
| 47 |
+
* @param transformedFilePath - the file path for which the source map is valid.
|
| 48 |
+
* This must *exactly* match the path stashed for the coverage object to be
|
| 49 |
+
* useful.
|
| 50 |
+
* @param sourceMapUrl - the source map URL, **not** a comment
|
| 51 |
+
*/
|
| 52 |
+
registerURL(transformedFilePath, sourceMapUrl) {
|
| 53 |
+
const d = 'data:';
|
| 54 |
+
|
| 55 |
+
if (
|
| 56 |
+
sourceMapUrl.length > d.length &&
|
| 57 |
+
sourceMapUrl.substring(0, d.length) === d
|
| 58 |
+
) {
|
| 59 |
+
const b64 = 'base64,';
|
| 60 |
+
const pos = sourceMapUrl.indexOf(b64);
|
| 61 |
+
if (pos > 0) {
|
| 62 |
+
this.data[transformedFilePath] = {
|
| 63 |
+
type: 'encoded',
|
| 64 |
+
data: sourceMapUrl.substring(pos + b64.length)
|
| 65 |
+
};
|
| 66 |
+
} else {
|
| 67 |
+
debug(`Unable to interpret source map URL: ${sourceMapUrl}`);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
return;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
const dir = path.dirname(path.resolve(transformedFilePath));
|
| 74 |
+
const file = path.resolve(dir, sourceMapUrl);
|
| 75 |
+
this.data[transformedFilePath] = { type: 'file', data: file };
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Registers a source map object with this store. Makes some basic sanity checks
|
| 80 |
+
* and silently fails on malformed input.
|
| 81 |
+
* @param transformedFilePath - the file path for which the source map is valid
|
| 82 |
+
* @param sourceMap - the source map object
|
| 83 |
+
*/
|
| 84 |
+
registerMap(transformedFilePath, sourceMap) {
|
| 85 |
+
if (sourceMap && sourceMap.version) {
|
| 86 |
+
this.data[transformedFilePath] = {
|
| 87 |
+
type: 'object',
|
| 88 |
+
data: sourceMap
|
| 89 |
+
};
|
| 90 |
+
} else {
|
| 91 |
+
debug(
|
| 92 |
+
'Invalid source map object: ' +
|
| 93 |
+
JSON.stringify(sourceMap, null, 2)
|
| 94 |
+
);
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* Retrieve a source map object from this store.
|
| 100 |
+
* @param filePath - the file path for which the source map is valid
|
| 101 |
+
* @returns {Object} a parsed source map object
|
| 102 |
+
*/
|
| 103 |
+
getSourceMapSync(filePath) {
|
| 104 |
+
try {
|
| 105 |
+
if (!this.data[filePath]) {
|
| 106 |
+
return;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
const d = this.data[filePath];
|
| 110 |
+
if (d.type === 'file') {
|
| 111 |
+
return JSON.parse(fs.readFileSync(d.data, 'utf8'));
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
if (d.type === 'encoded') {
|
| 115 |
+
return JSON.parse(Buffer.from(d.data, 'base64').toString());
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
/* The caller might delete properties */
|
| 119 |
+
return {
|
| 120 |
+
...d.data
|
| 121 |
+
};
|
| 122 |
+
} catch (error) {
|
| 123 |
+
debug('Error returning source map for ' + filePath);
|
| 124 |
+
debug(error.stack);
|
| 125 |
+
|
| 126 |
+
return;
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
* Add inputSourceMap property to coverage data
|
| 132 |
+
* @param coverageData - the __coverage__ object
|
| 133 |
+
* @returns {Object} a parsed source map object
|
| 134 |
+
*/
|
| 135 |
+
addInputSourceMapsSync(coverageData) {
|
| 136 |
+
Object.entries(coverageData).forEach(([filePath, data]) => {
|
| 137 |
+
if (data.inputSourceMap) {
|
| 138 |
+
return;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
const sourceMap = this.getSourceMapSync(filePath);
|
| 142 |
+
if (sourceMap) {
|
| 143 |
+
data.inputSourceMap = sourceMap;
|
| 144 |
+
/* This huge property is not needed. */
|
| 145 |
+
delete data.inputSourceMap.sourcesContent;
|
| 146 |
+
}
|
| 147 |
+
});
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
sourceFinder(filePath) {
|
| 151 |
+
const content = this.sourceStore.get(filePath);
|
| 152 |
+
if (content !== undefined) {
|
| 153 |
+
return content;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
if (path.isAbsolute(filePath)) {
|
| 157 |
+
return fs.readFileSync(filePath, 'utf8');
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
return fs.readFileSync(
|
| 161 |
+
pathutils.asAbsolute(filePath, this.baseDir),
|
| 162 |
+
'utf8'
|
| 163 |
+
);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
/**
|
| 167 |
+
* Transforms the coverage map provided into one that refers to original
|
| 168 |
+
* sources when valid mappings have been registered with this store.
|
| 169 |
+
* @param {CoverageMap} coverageMap - the coverage map to transform
|
| 170 |
+
* @returns {Promise<CoverageMap>} the transformed coverage map
|
| 171 |
+
*/
|
| 172 |
+
async transformCoverage(coverageMap) {
|
| 173 |
+
const hasInputSourceMaps = coverageMap
|
| 174 |
+
.files()
|
| 175 |
+
.some(
|
| 176 |
+
file => coverageMap.fileCoverageFor(file).data.inputSourceMap
|
| 177 |
+
);
|
| 178 |
+
|
| 179 |
+
if (!hasInputSourceMaps && Object.keys(this.data).length === 0) {
|
| 180 |
+
return coverageMap;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
const transformer = new SourceMapTransformer(
|
| 184 |
+
async (filePath, coverage) => {
|
| 185 |
+
try {
|
| 186 |
+
const obj =
|
| 187 |
+
coverage.data.inputSourceMap ||
|
| 188 |
+
this.getSourceMapSync(filePath);
|
| 189 |
+
if (!obj) {
|
| 190 |
+
return null;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
const smc = new SourceMapConsumer(obj);
|
| 194 |
+
smc.sources.forEach(s => {
|
| 195 |
+
const content = smc.sourceContentFor(s);
|
| 196 |
+
if (content) {
|
| 197 |
+
const sourceFilePath = pathutils.relativeTo(
|
| 198 |
+
s,
|
| 199 |
+
filePath
|
| 200 |
+
);
|
| 201 |
+
this.sourceStore.set(sourceFilePath, content);
|
| 202 |
+
}
|
| 203 |
+
});
|
| 204 |
+
|
| 205 |
+
return smc;
|
| 206 |
+
} catch (error) {
|
| 207 |
+
debug('Error returning source map for ' + filePath);
|
| 208 |
+
debug(error.stack);
|
| 209 |
+
|
| 210 |
+
return null;
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
);
|
| 214 |
+
|
| 215 |
+
return await transformer.transform(coverageMap);
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
/**
|
| 219 |
+
* Disposes temporary resources allocated by this map store
|
| 220 |
+
*/
|
| 221 |
+
dispose() {
|
| 222 |
+
this.sourceStore.clear();
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
module.exports = { MapStore };
|
novas/novacore-zephyr/claude-code-router/node_modules/istanbul-lib-source-maps/lib/mapped.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
Copyright 2015, Yahoo Inc.
|
| 3 |
+
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
| 4 |
+
*/
|
| 5 |
+
'use strict';
|
| 6 |
+
|
| 7 |
+
const { FileCoverage } = require('istanbul-lib-coverage').classes;
|
| 8 |
+
|
| 9 |
+
function locString(loc) {
|
| 10 |
+
return [
|
| 11 |
+
loc.start.line,
|
| 12 |
+
loc.start.column,
|
| 13 |
+
loc.end.line,
|
| 14 |
+
loc.end.column
|
| 15 |
+
].join(':');
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
class MappedCoverage extends FileCoverage {
|
| 19 |
+
constructor(pathOrObj) {
|
| 20 |
+
super(pathOrObj);
|
| 21 |
+
|
| 22 |
+
this.meta = {
|
| 23 |
+
last: {
|
| 24 |
+
s: 0,
|
| 25 |
+
f: 0,
|
| 26 |
+
b: 0
|
| 27 |
+
},
|
| 28 |
+
seen: {}
|
| 29 |
+
};
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
addStatement(loc, hits) {
|
| 33 |
+
const key = 's:' + locString(loc);
|
| 34 |
+
const { meta } = this;
|
| 35 |
+
let index = meta.seen[key];
|
| 36 |
+
|
| 37 |
+
if (index === undefined) {
|
| 38 |
+
index = meta.last.s;
|
| 39 |
+
meta.last.s += 1;
|
| 40 |
+
meta.seen[key] = index;
|
| 41 |
+
this.statementMap[index] = this.cloneLocation(loc);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
this.s[index] = this.s[index] || 0;
|
| 45 |
+
this.s[index] += hits;
|
| 46 |
+
return index;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
addFunction(name, decl, loc, hits) {
|
| 50 |
+
const key = 'f:' + locString(decl);
|
| 51 |
+
const { meta } = this;
|
| 52 |
+
let index = meta.seen[key];
|
| 53 |
+
|
| 54 |
+
if (index === undefined) {
|
| 55 |
+
index = meta.last.f;
|
| 56 |
+
meta.last.f += 1;
|
| 57 |
+
meta.seen[key] = index;
|
| 58 |
+
name = name || `(unknown_${index})`;
|
| 59 |
+
this.fnMap[index] = {
|
| 60 |
+
name,
|
| 61 |
+
decl: this.cloneLocation(decl),
|
| 62 |
+
loc: this.cloneLocation(loc)
|
| 63 |
+
};
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
this.f[index] = this.f[index] || 0;
|
| 67 |
+
this.f[index] += hits;
|
| 68 |
+
return index;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
addBranch(type, loc, branchLocations, hits) {
|
| 72 |
+
const key = ['b', ...branchLocations.map(l => locString(l))].join(':');
|
| 73 |
+
const { meta } = this;
|
| 74 |
+
let index = meta.seen[key];
|
| 75 |
+
if (index === undefined) {
|
| 76 |
+
index = meta.last.b;
|
| 77 |
+
meta.last.b += 1;
|
| 78 |
+
meta.seen[key] = index;
|
| 79 |
+
this.branchMap[index] = {
|
| 80 |
+
loc,
|
| 81 |
+
type,
|
| 82 |
+
locations: branchLocations.map(l => this.cloneLocation(l))
|
| 83 |
+
};
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
if (!this.b[index]) {
|
| 87 |
+
this.b[index] = branchLocations.map(() => 0);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
hits.forEach((hit, i) => {
|
| 91 |
+
this.b[index][i] += hit;
|
| 92 |
+
});
|
| 93 |
+
return index;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/* Returns a clone of the location object with only the attributes of interest */
|
| 97 |
+
cloneLocation(loc) {
|
| 98 |
+
return {
|
| 99 |
+
start: {
|
| 100 |
+
line: loc.start.line,
|
| 101 |
+
column: loc.start.column
|
| 102 |
+
},
|
| 103 |
+
end: {
|
| 104 |
+
line: loc.end.line,
|
| 105 |
+
column: loc.end.column
|
| 106 |
+
}
|
| 107 |
+
};
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
module.exports = {
|
| 112 |
+
MappedCoverage
|
| 113 |
+
};
|
novas/novacore-zephyr/claude-code-router/node_modules/istanbul-lib-source-maps/lib/pathutils.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
Copyright 2015, Yahoo Inc.
|
| 3 |
+
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
| 4 |
+
*/
|
| 5 |
+
'use strict';
|
| 6 |
+
|
| 7 |
+
const path = require('path');
|
| 8 |
+
|
| 9 |
+
module.exports = {
|
| 10 |
+
isAbsolute: path.isAbsolute,
|
| 11 |
+
asAbsolute(file, baseDir) {
|
| 12 |
+
return path.isAbsolute(file)
|
| 13 |
+
? file
|
| 14 |
+
: path.resolve(baseDir || process.cwd(), file);
|
| 15 |
+
},
|
| 16 |
+
relativeTo(file, origFile) {
|
| 17 |
+
return path.isAbsolute(file)
|
| 18 |
+
? file
|
| 19 |
+
: path.resolve(path.dirname(origFile), file);
|
| 20 |
+
}
|
| 21 |
+
};
|
novas/novacore-zephyr/claude-code-router/node_modules/istanbul-lib-source-maps/lib/transform-utils.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
Copyright 2015, Yahoo Inc.
|
| 3 |
+
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
| 4 |
+
*/
|
| 5 |
+
'use strict';
|
| 6 |
+
|
| 7 |
+
function getUniqueKey(pathname) {
|
| 8 |
+
return pathname.replace(/[\\/]/g, '_');
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function getOutput(cache) {
|
| 12 |
+
return Object.values(cache).reduce(
|
| 13 |
+
(output, { file, mappedCoverage }) => ({
|
| 14 |
+
...output,
|
| 15 |
+
[file]: mappedCoverage
|
| 16 |
+
}),
|
| 17 |
+
{}
|
| 18 |
+
);
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
module.exports = { getUniqueKey, getOutput };
|
novas/novacore-zephyr/claude-code-router/node_modules/istanbul-lib-source-maps/lib/transformer.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
Copyright 2015, Yahoo Inc.
|
| 3 |
+
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
| 4 |
+
*/
|
| 5 |
+
'use strict';
|
| 6 |
+
|
| 7 |
+
const debug = require('debug')('istanbuljs');
|
| 8 |
+
const libCoverage = require('istanbul-lib-coverage');
|
| 9 |
+
const { MappedCoverage } = require('./mapped');
|
| 10 |
+
const getMapping = require('./get-mapping');
|
| 11 |
+
const { getUniqueKey, getOutput } = require('./transform-utils');
|
| 12 |
+
|
| 13 |
+
class SourceMapTransformer {
|
| 14 |
+
constructor(finder, opts = {}) {
|
| 15 |
+
this.finder = finder;
|
| 16 |
+
this.baseDir = opts.baseDir || process.cwd();
|
| 17 |
+
this.resolveMapping = opts.getMapping || getMapping;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
processFile(fc, sourceMap, coverageMapper) {
|
| 21 |
+
let changes = 0;
|
| 22 |
+
|
| 23 |
+
Object.entries(fc.statementMap).forEach(([s, loc]) => {
|
| 24 |
+
const hits = fc.s[s];
|
| 25 |
+
const mapping = this.resolveMapping(sourceMap, loc, fc.path);
|
| 26 |
+
|
| 27 |
+
if (mapping) {
|
| 28 |
+
changes += 1;
|
| 29 |
+
const mappedCoverage = coverageMapper(mapping.source);
|
| 30 |
+
mappedCoverage.addStatement(mapping.loc, hits);
|
| 31 |
+
}
|
| 32 |
+
});
|
| 33 |
+
|
| 34 |
+
Object.entries(fc.fnMap).forEach(([f, fnMeta]) => {
|
| 35 |
+
const hits = fc.f[f];
|
| 36 |
+
const mapping = this.resolveMapping(
|
| 37 |
+
sourceMap,
|
| 38 |
+
fnMeta.decl,
|
| 39 |
+
fc.path
|
| 40 |
+
);
|
| 41 |
+
|
| 42 |
+
const spanMapping = this.resolveMapping(
|
| 43 |
+
sourceMap,
|
| 44 |
+
fnMeta.loc,
|
| 45 |
+
fc.path
|
| 46 |
+
);
|
| 47 |
+
|
| 48 |
+
if (
|
| 49 |
+
mapping &&
|
| 50 |
+
spanMapping &&
|
| 51 |
+
mapping.source === spanMapping.source
|
| 52 |
+
) {
|
| 53 |
+
changes += 1;
|
| 54 |
+
const mappedCoverage = coverageMapper(mapping.source);
|
| 55 |
+
mappedCoverage.addFunction(
|
| 56 |
+
fnMeta.name,
|
| 57 |
+
mapping.loc,
|
| 58 |
+
spanMapping.loc,
|
| 59 |
+
hits
|
| 60 |
+
);
|
| 61 |
+
}
|
| 62 |
+
});
|
| 63 |
+
|
| 64 |
+
Object.entries(fc.branchMap).forEach(([b, branchMeta]) => {
|
| 65 |
+
const hits = fc.b[b];
|
| 66 |
+
const locs = [];
|
| 67 |
+
const mappedHits = [];
|
| 68 |
+
let source;
|
| 69 |
+
let skip;
|
| 70 |
+
|
| 71 |
+
branchMeta.locations.forEach((loc, i) => {
|
| 72 |
+
const mapping = this.resolveMapping(sourceMap, loc, fc.path);
|
| 73 |
+
if (mapping) {
|
| 74 |
+
if (!source) {
|
| 75 |
+
source = mapping.source;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
if (mapping.source !== source) {
|
| 79 |
+
skip = true;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
locs.push(mapping.loc);
|
| 83 |
+
mappedHits.push(hits[i]);
|
| 84 |
+
}
|
| 85 |
+
});
|
| 86 |
+
|
| 87 |
+
const locMapping = branchMeta.loc
|
| 88 |
+
? this.resolveMapping(sourceMap, branchMeta.loc, fc.path)
|
| 89 |
+
: null;
|
| 90 |
+
|
| 91 |
+
if (!skip && locs.length > 0) {
|
| 92 |
+
changes += 1;
|
| 93 |
+
const mappedCoverage = coverageMapper(source);
|
| 94 |
+
mappedCoverage.addBranch(
|
| 95 |
+
branchMeta.type,
|
| 96 |
+
locMapping ? locMapping.loc : locs[0],
|
| 97 |
+
locs,
|
| 98 |
+
mappedHits
|
| 99 |
+
);
|
| 100 |
+
}
|
| 101 |
+
});
|
| 102 |
+
|
| 103 |
+
return changes > 0;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
async transform(coverageMap) {
|
| 107 |
+
const uniqueFiles = {};
|
| 108 |
+
const getMappedCoverage = file => {
|
| 109 |
+
const key = getUniqueKey(file);
|
| 110 |
+
if (!uniqueFiles[key]) {
|
| 111 |
+
uniqueFiles[key] = {
|
| 112 |
+
file,
|
| 113 |
+
mappedCoverage: new MappedCoverage(file)
|
| 114 |
+
};
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
return uniqueFiles[key].mappedCoverage;
|
| 118 |
+
};
|
| 119 |
+
|
| 120 |
+
for (const file of coverageMap.files()) {
|
| 121 |
+
const fc = coverageMap.fileCoverageFor(file);
|
| 122 |
+
const sourceMap = await this.finder(file, fc);
|
| 123 |
+
|
| 124 |
+
if (sourceMap) {
|
| 125 |
+
const changed = this.processFile(
|
| 126 |
+
fc,
|
| 127 |
+
sourceMap,
|
| 128 |
+
getMappedCoverage
|
| 129 |
+
);
|
| 130 |
+
if (!changed) {
|
| 131 |
+
debug(`File [${file}] ignored, nothing could be mapped`);
|
| 132 |
+
}
|
| 133 |
+
} else {
|
| 134 |
+
uniqueFiles[getUniqueKey(file)] = {
|
| 135 |
+
file,
|
| 136 |
+
mappedCoverage: new MappedCoverage(fc)
|
| 137 |
+
};
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
return libCoverage.createCoverageMap(getOutput(uniqueFiles));
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
module.exports = {
|
| 146 |
+
SourceMapTransformer
|
| 147 |
+
};
|
novas/novacore-zephyr/claude-code-router/node_modules/jest-changed-files/build/git.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = void 0;
|
| 7 |
+
function path() {
|
| 8 |
+
const data = _interopRequireWildcard(require('path'));
|
| 9 |
+
path = function () {
|
| 10 |
+
return data;
|
| 11 |
+
};
|
| 12 |
+
return data;
|
| 13 |
+
}
|
| 14 |
+
function _util() {
|
| 15 |
+
const data = require('util');
|
| 16 |
+
_util = function () {
|
| 17 |
+
return data;
|
| 18 |
+
};
|
| 19 |
+
return data;
|
| 20 |
+
}
|
| 21 |
+
function _execa() {
|
| 22 |
+
const data = _interopRequireDefault(require('execa'));
|
| 23 |
+
_execa = function () {
|
| 24 |
+
return data;
|
| 25 |
+
};
|
| 26 |
+
return data;
|
| 27 |
+
}
|
| 28 |
+
function _interopRequireDefault(obj) {
|
| 29 |
+
return obj && obj.__esModule ? obj : {default: obj};
|
| 30 |
+
}
|
| 31 |
+
function _getRequireWildcardCache(nodeInterop) {
|
| 32 |
+
if (typeof WeakMap !== 'function') return null;
|
| 33 |
+
var cacheBabelInterop = new WeakMap();
|
| 34 |
+
var cacheNodeInterop = new WeakMap();
|
| 35 |
+
return (_getRequireWildcardCache = function (nodeInterop) {
|
| 36 |
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
| 37 |
+
})(nodeInterop);
|
| 38 |
+
}
|
| 39 |
+
function _interopRequireWildcard(obj, nodeInterop) {
|
| 40 |
+
if (!nodeInterop && obj && obj.__esModule) {
|
| 41 |
+
return obj;
|
| 42 |
+
}
|
| 43 |
+
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
| 44 |
+
return {default: obj};
|
| 45 |
+
}
|
| 46 |
+
var cache = _getRequireWildcardCache(nodeInterop);
|
| 47 |
+
if (cache && cache.has(obj)) {
|
| 48 |
+
return cache.get(obj);
|
| 49 |
+
}
|
| 50 |
+
var newObj = {};
|
| 51 |
+
var hasPropertyDescriptor =
|
| 52 |
+
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
| 53 |
+
for (var key in obj) {
|
| 54 |
+
if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
|
| 55 |
+
var desc = hasPropertyDescriptor
|
| 56 |
+
? Object.getOwnPropertyDescriptor(obj, key)
|
| 57 |
+
: null;
|
| 58 |
+
if (desc && (desc.get || desc.set)) {
|
| 59 |
+
Object.defineProperty(newObj, key, desc);
|
| 60 |
+
} else {
|
| 61 |
+
newObj[key] = obj[key];
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
newObj.default = obj;
|
| 66 |
+
if (cache) {
|
| 67 |
+
cache.set(obj, newObj);
|
| 68 |
+
}
|
| 69 |
+
return newObj;
|
| 70 |
+
}
|
| 71 |
+
/**
|
| 72 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 73 |
+
*
|
| 74 |
+
* This source code is licensed under the MIT license found in the
|
| 75 |
+
* LICENSE file in the root directory of this source tree.
|
| 76 |
+
*
|
| 77 |
+
*/
|
| 78 |
+
|
| 79 |
+
const findChangedFilesUsingCommand = async (args, cwd) => {
|
| 80 |
+
let result;
|
| 81 |
+
try {
|
| 82 |
+
result = await (0, _execa().default)('git', args, {
|
| 83 |
+
cwd
|
| 84 |
+
});
|
| 85 |
+
} catch (e) {
|
| 86 |
+
if (_util().types.isNativeError(e)) {
|
| 87 |
+
const err = e;
|
| 88 |
+
// TODO: Should we keep the original `message`?
|
| 89 |
+
err.message = err.stderr;
|
| 90 |
+
}
|
| 91 |
+
throw e;
|
| 92 |
+
}
|
| 93 |
+
return result.stdout
|
| 94 |
+
.split('\n')
|
| 95 |
+
.filter(s => s !== '')
|
| 96 |
+
.map(changedPath => path().resolve(cwd, changedPath));
|
| 97 |
+
};
|
| 98 |
+
const adapter = {
|
| 99 |
+
findChangedFiles: async (cwd, options) => {
|
| 100 |
+
const changedSince =
|
| 101 |
+
options.withAncestor === true ? 'HEAD^' : options.changedSince;
|
| 102 |
+
const includePaths = (options.includePaths ?? []).map(absoluteRoot =>
|
| 103 |
+
path().normalize(path().relative(cwd, absoluteRoot))
|
| 104 |
+
);
|
| 105 |
+
if (options.lastCommit === true) {
|
| 106 |
+
return findChangedFilesUsingCommand(
|
| 107 |
+
['show', '--name-only', '--pretty=format:', 'HEAD', '--'].concat(
|
| 108 |
+
includePaths
|
| 109 |
+
),
|
| 110 |
+
cwd
|
| 111 |
+
);
|
| 112 |
+
}
|
| 113 |
+
if (changedSince != null && changedSince.length > 0) {
|
| 114 |
+
const [committed, staged, unstaged] = await Promise.all([
|
| 115 |
+
findChangedFilesUsingCommand(
|
| 116 |
+
['diff', '--name-only', `${changedSince}...HEAD`, '--'].concat(
|
| 117 |
+
includePaths
|
| 118 |
+
),
|
| 119 |
+
cwd
|
| 120 |
+
),
|
| 121 |
+
findChangedFilesUsingCommand(
|
| 122 |
+
['diff', '--cached', '--name-only', '--'].concat(includePaths),
|
| 123 |
+
cwd
|
| 124 |
+
),
|
| 125 |
+
findChangedFilesUsingCommand(
|
| 126 |
+
[
|
| 127 |
+
'ls-files',
|
| 128 |
+
'--other',
|
| 129 |
+
'--modified',
|
| 130 |
+
'--exclude-standard',
|
| 131 |
+
'--'
|
| 132 |
+
].concat(includePaths),
|
| 133 |
+
cwd
|
| 134 |
+
)
|
| 135 |
+
]);
|
| 136 |
+
return [...committed, ...staged, ...unstaged];
|
| 137 |
+
}
|
| 138 |
+
const [staged, unstaged] = await Promise.all([
|
| 139 |
+
findChangedFilesUsingCommand(
|
| 140 |
+
['diff', '--cached', '--name-only', '--'].concat(includePaths),
|
| 141 |
+
cwd
|
| 142 |
+
),
|
| 143 |
+
findChangedFilesUsingCommand(
|
| 144 |
+
[
|
| 145 |
+
'ls-files',
|
| 146 |
+
'--other',
|
| 147 |
+
'--modified',
|
| 148 |
+
'--exclude-standard',
|
| 149 |
+
'--'
|
| 150 |
+
].concat(includePaths),
|
| 151 |
+
cwd
|
| 152 |
+
)
|
| 153 |
+
]);
|
| 154 |
+
return [...staged, ...unstaged];
|
| 155 |
+
},
|
| 156 |
+
getRoot: async cwd => {
|
| 157 |
+
const options = ['rev-parse', '--show-cdup'];
|
| 158 |
+
try {
|
| 159 |
+
const result = await (0, _execa().default)('git', options, {
|
| 160 |
+
cwd
|
| 161 |
+
});
|
| 162 |
+
return path().resolve(cwd, result.stdout);
|
| 163 |
+
} catch {
|
| 164 |
+
return null;
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
};
|
| 168 |
+
var _default = adapter;
|
| 169 |
+
exports.default = _default;
|
novas/novacore-zephyr/claude-code-router/node_modules/jest-changed-files/build/hg.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = void 0;
|
| 7 |
+
function path() {
|
| 8 |
+
const data = _interopRequireWildcard(require('path'));
|
| 9 |
+
path = function () {
|
| 10 |
+
return data;
|
| 11 |
+
};
|
| 12 |
+
return data;
|
| 13 |
+
}
|
| 14 |
+
function _util() {
|
| 15 |
+
const data = require('util');
|
| 16 |
+
_util = function () {
|
| 17 |
+
return data;
|
| 18 |
+
};
|
| 19 |
+
return data;
|
| 20 |
+
}
|
| 21 |
+
function _execa() {
|
| 22 |
+
const data = _interopRequireDefault(require('execa'));
|
| 23 |
+
_execa = function () {
|
| 24 |
+
return data;
|
| 25 |
+
};
|
| 26 |
+
return data;
|
| 27 |
+
}
|
| 28 |
+
function _interopRequireDefault(obj) {
|
| 29 |
+
return obj && obj.__esModule ? obj : {default: obj};
|
| 30 |
+
}
|
| 31 |
+
function _getRequireWildcardCache(nodeInterop) {
|
| 32 |
+
if (typeof WeakMap !== 'function') return null;
|
| 33 |
+
var cacheBabelInterop = new WeakMap();
|
| 34 |
+
var cacheNodeInterop = new WeakMap();
|
| 35 |
+
return (_getRequireWildcardCache = function (nodeInterop) {
|
| 36 |
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
| 37 |
+
})(nodeInterop);
|
| 38 |
+
}
|
| 39 |
+
function _interopRequireWildcard(obj, nodeInterop) {
|
| 40 |
+
if (!nodeInterop && obj && obj.__esModule) {
|
| 41 |
+
return obj;
|
| 42 |
+
}
|
| 43 |
+
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
| 44 |
+
return {default: obj};
|
| 45 |
+
}
|
| 46 |
+
var cache = _getRequireWildcardCache(nodeInterop);
|
| 47 |
+
if (cache && cache.has(obj)) {
|
| 48 |
+
return cache.get(obj);
|
| 49 |
+
}
|
| 50 |
+
var newObj = {};
|
| 51 |
+
var hasPropertyDescriptor =
|
| 52 |
+
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
| 53 |
+
for (var key in obj) {
|
| 54 |
+
if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
|
| 55 |
+
var desc = hasPropertyDescriptor
|
| 56 |
+
? Object.getOwnPropertyDescriptor(obj, key)
|
| 57 |
+
: null;
|
| 58 |
+
if (desc && (desc.get || desc.set)) {
|
| 59 |
+
Object.defineProperty(newObj, key, desc);
|
| 60 |
+
} else {
|
| 61 |
+
newObj[key] = obj[key];
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
newObj.default = obj;
|
| 66 |
+
if (cache) {
|
| 67 |
+
cache.set(obj, newObj);
|
| 68 |
+
}
|
| 69 |
+
return newObj;
|
| 70 |
+
}
|
| 71 |
+
/**
|
| 72 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 73 |
+
*
|
| 74 |
+
* This source code is licensed under the MIT license found in the
|
| 75 |
+
* LICENSE file in the root directory of this source tree.
|
| 76 |
+
*
|
| 77 |
+
*/
|
| 78 |
+
|
| 79 |
+
const env = {
|
| 80 |
+
...process.env,
|
| 81 |
+
HGPLAIN: '1'
|
| 82 |
+
};
|
| 83 |
+
const adapter = {
|
| 84 |
+
findChangedFiles: async (cwd, options) => {
|
| 85 |
+
const includePaths = options.includePaths ?? [];
|
| 86 |
+
const args = ['status', '-amnu'];
|
| 87 |
+
if (options.withAncestor === true) {
|
| 88 |
+
args.push('--rev', 'first(min(!public() & ::.)^+.^)');
|
| 89 |
+
} else if (
|
| 90 |
+
options.changedSince != null &&
|
| 91 |
+
options.changedSince.length > 0
|
| 92 |
+
) {
|
| 93 |
+
args.push('--rev', `ancestor(., ${options.changedSince})`);
|
| 94 |
+
} else if (options.lastCommit === true) {
|
| 95 |
+
args.push('--change', '.');
|
| 96 |
+
}
|
| 97 |
+
args.push(...includePaths);
|
| 98 |
+
let result;
|
| 99 |
+
try {
|
| 100 |
+
result = await (0, _execa().default)('hg', args, {
|
| 101 |
+
cwd,
|
| 102 |
+
env
|
| 103 |
+
});
|
| 104 |
+
} catch (e) {
|
| 105 |
+
if (_util().types.isNativeError(e)) {
|
| 106 |
+
const err = e;
|
| 107 |
+
// TODO: Should we keep the original `message`?
|
| 108 |
+
err.message = err.stderr;
|
| 109 |
+
}
|
| 110 |
+
throw e;
|
| 111 |
+
}
|
| 112 |
+
return result.stdout
|
| 113 |
+
.split('\n')
|
| 114 |
+
.filter(s => s !== '')
|
| 115 |
+
.map(changedPath => path().resolve(cwd, changedPath));
|
| 116 |
+
},
|
| 117 |
+
getRoot: async cwd => {
|
| 118 |
+
try {
|
| 119 |
+
const result = await (0, _execa().default)('hg', ['root'], {
|
| 120 |
+
cwd,
|
| 121 |
+
env
|
| 122 |
+
});
|
| 123 |
+
return result.stdout;
|
| 124 |
+
} catch {
|
| 125 |
+
return null;
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
};
|
| 129 |
+
var _default = adapter;
|
| 130 |
+
exports.default = _default;
|