@reasonabletech/config-vitest 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # @reasonabletech/config-vitest
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@reasonabletech/config-vitest.svg)](https://www.npmjs.com/package/@reasonabletech/config-vitest)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@reasonabletech/config-vitest.svg)](https://www.npmjs.com/package/@reasonabletech/config-vitest)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue.svg)](https://www.typescriptlang.org/)
7
+
8
+ `@reasonabletech/config-vitest` provides shared Vitest configuration factories with standardized coverage and workspace-aware module resolution. All configs enforce 100% coverage thresholds by default — disable this for a specific package by setting the `VITEST_COVERAGE_THRESHOLDS_DISABLED` environment variable.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ pnpm add -D @reasonabletech/config-vitest vitest vite @vitest/coverage-v8
14
+ ```
15
+
16
+ ## Peer Dependencies
17
+
18
+ | Dependency | Version | Required |
19
+ | ------------------- | --------- | -------- |
20
+ | vitest | >= 2.0 | Yes |
21
+ | vite | >= 5.0 | Yes |
22
+ | @vitest/coverage-v8 | >= 2.0 | Optional |
23
+
24
+ This package provides Vitest configuration factories and requires vitest 2.0+ and vite 5.0+ for modern test runner features. Install `@vitest/coverage-v8` to enable coverage reporting (enabled by default in configs).
25
+
26
+ ## Exported Entry Points
27
+
28
+ | Import Path | Purpose | Main Exports |
29
+ | ----------------------------------------- | ----------------------------- | -------------------------------------------------------------------------------------------------------- |
30
+ | `@reasonabletech/config-vitest` | Base Vitest config factory | `createVitestConfig`, `createLongRunningTestConfig`, `createReactConfig`, `createReactConfigWithPlugins` |
31
+ | `@reasonabletech/config-vitest/react` | React-specific config factory | `createReactConfig`, `createReactConfigWithPlugins` |
32
+ | `@reasonabletech/config-vitest/node` | Node-specific config factory | `createNodeConfig`, `nodeConfig` |
33
+ | `@reasonabletech/config-vitest/workspace` | Workspace utilities | `findRepoRoot`, `readPackageName` |
34
+
35
+ ## Usage
36
+
37
+ ### Base Configuration
38
+
39
+ ```ts
40
+ // vitest.config.mts
41
+ import { createVitestConfig } from "@reasonabletech/config-vitest";
42
+
43
+ export default createVitestConfig(import.meta.dirname);
44
+ ```
45
+
46
+ ### React Configuration
47
+
48
+ ```ts
49
+ // vitest.config.mts
50
+ import { createReactConfig } from "@reasonabletech/config-vitest/react";
51
+
52
+ export default createReactConfig(import.meta.dirname);
53
+ ```
54
+
55
+ ### Node Configuration
56
+
57
+ ```ts
58
+ // vitest.config.mts
59
+ import { createNodeConfig } from "@reasonabletech/config-vitest/node";
60
+
61
+ export default createNodeConfig(import.meta.dirname);
62
+ ```
63
+
64
+ ### Long-Running Suites
65
+
66
+ ```ts
67
+ // vitest.config.mts
68
+ import { createLongRunningTestConfig } from "@reasonabletech/config-vitest";
69
+
70
+ export default createLongRunningTestConfig(import.meta.dirname, {
71
+ test: {
72
+ include: ["tests/integration/**/*.test.ts"],
73
+ },
74
+ });
75
+ ```
76
+
77
+ ## Coverage Defaults
78
+
79
+ - Provider: `v8`
80
+ - Report directory: `generated/test-coverage`
81
+ - Reporters: `text`, `html`, `lcov`, `json`
82
+ - Thresholds: `100` for lines/functions/branches/statements
83
+
84
+ Set `VITEST_COVERAGE_THRESHOLDS_DISABLED=true` for temporary local diagnostics.
85
+
86
+ ## Changelog
87
+
88
+ See [CHANGELOG.md](./CHANGELOG.md) for release history.
89
+
90
+ This package follows [Semantic Versioning](https://semver.org/). Breaking changes are documented with migration guides when applicable.
91
+
92
+ ## Additional References
93
+
94
+ - [Usage Guide](./docs/guides/usage-guide.md)
95
+ - [Package Docs](./docs/README.md)
96
+ - [Base Config Details](./docs/api/base-config.md)
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Builds the pnpm + turbo CLI arguments needed to build all upstream
3
+ * workspace dependencies of the given package.
4
+ * @param packageName - The package name (e.g. `@reasonabletech/utils`)
5
+ * @returns An array of CLI arguments for `spawnSync("pnpm", ...)`
6
+ */
7
+ export declare function getTurboBuildArgs(packageName: string): readonly string[];
8
+ /**
9
+ * Vitest global setup that builds workspace dependencies before tests run.
10
+ *
11
+ * Skipped when `RT_VITEST_SKIP_DEP_BUILD=true` is set or when
12
+ * a parent build is already in progress (re-entrancy guard).
13
+ */
14
+ export default function globalSetup(): void;
15
+ //# sourceMappingURL=global-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-setup.d.ts","sourceRoot":"","sources":["../../src/global-setup.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAQxE;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,IAAI,IAAI,CAgC1C"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Base Vitest configuration for all packages
3
+ * @module @reasonabletech/config-vitest
4
+ */
5
+ import { defineConfig } from "vitest/config";
6
+ import type { InlineConfig } from "vitest/node";
7
+ /** Recursively makes all properties of T readonly */
8
+ export type DeepReadonly<T> = {
9
+ readonly [P in keyof T]: T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepReadonly<U>> : T[P] extends Array<infer U> ? ReadonlyArray<DeepReadonly<U>> : T[P] extends object ? DeepReadonly<T[P]> : T[P];
10
+ };
11
+ /**
12
+ * Immutable configuration object accepted by {@link createVitestConfig} and
13
+ * related helpers.
14
+ */
15
+ export type VitestConfig = DeepReadonly<{
16
+ test?: InlineConfig;
17
+ resolve?: {
18
+ conditions?: string[];
19
+ alias?: Record<string, string>;
20
+ [key: string]: unknown;
21
+ };
22
+ [key: string]: unknown;
23
+ }>;
24
+ /**
25
+ * Base configuration options that apply to all test environments
26
+ */
27
+ export declare const baseConfig: {
28
+ test: {
29
+ testTimeout: number;
30
+ hookTimeout: number;
31
+ coverage: {
32
+ provider: "v8";
33
+ reporter: string[];
34
+ reportsDirectory: string;
35
+ exclude: string[];
36
+ thresholds: {
37
+ lines: number;
38
+ functions: number;
39
+ branches: number;
40
+ statements: number;
41
+ };
42
+ };
43
+ };
44
+ };
45
+ /** @overload */
46
+ /**
47
+ * Creates a merged configuration from the base and any custom options.
48
+ * @param projectDirOrConfig - Either the absolute project directory (use `import.meta.dirname`) or a prebuilt config.
49
+ * @param customConfig - Additional configuration to merge when a project directory is provided.
50
+ * @returns A merged Vitest configuration tailored for the caller.
51
+ */
52
+ export declare function createVitestConfig(projectDirOrConfig?: string | VitestConfig, customConfig?: VitestConfig): ReturnType<typeof defineConfig>;
53
+ /** @overload */
54
+ /**
55
+ * Creates a configuration with extended timeouts for long-running tests.
56
+ * @param projectDirOrConfig - Either the absolute project directory or an existing configuration to extend.
57
+ * @param customConfig - Additional configuration to merge when a project directory is supplied.
58
+ * @returns A Vitest configuration suited for long-running suites.
59
+ */
60
+ export declare function createLongRunningTestConfig(projectDirOrConfig?: string | VitestConfig, customConfig?: VitestConfig): ReturnType<typeof defineConfig>;
61
+ export { createReactConfig, createReactConfigWithPlugins } from "./react.js";
62
+ export default createVitestConfig;
63
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,qDAAqD;AACrD,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GACxD,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAC9B,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACzB,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAC9B,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GACjB,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAClB,CAAC,CAAC,CAAC,CAAC;CACb,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,CAAC;IACtC,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC,CAAC;AAKH;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;CAwCtB,CAAC;AAuDF,gBAAgB;AAChB;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,kBAAkB,CAAC,EAAE,MAAM,GAAG,YAAY,EAC1C,YAAY,CAAC,EAAE,YAAY,GAC1B,UAAU,CAAC,OAAO,YAAY,CAAC,CAwFjC;AAED,gBAAgB;AAChB;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,kBAAkB,CAAC,EAAE,MAAM,GAAG,YAAY,EAC1C,YAAY,CAAC,EAAE,YAAY,GAC1B,UAAU,CAAC,OAAO,YAAY,CAAC,CA0BjC;AAGD,OAAO,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAE7E,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,352 @@
1
+ // src/index.ts
2
+ import { existsSync as existsSync3 } from "fs";
3
+ import { join as join3 } from "path";
4
+ import { defaultClientConditions as defaultClientConditions2, defaultServerConditions as defaultServerConditions2 } from "vite";
5
+ import { defineConfig as defineConfig2 } from "vitest/config";
6
+
7
+ // src/workspace.ts
8
+ import { existsSync, readFileSync } from "fs";
9
+ import * as path from "path";
10
+ function readPackageName(packageDir) {
11
+ const packageJsonPath = path.join(packageDir, "package.json");
12
+ if (!existsSync(packageJsonPath)) {
13
+ return null;
14
+ }
15
+ try {
16
+ const parsed = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
17
+ return typeof parsed.name === "string" && parsed.name.length > 0 ? parsed.name : null;
18
+ } catch {
19
+ return null;
20
+ }
21
+ }
22
+
23
+ // src/react.ts
24
+ import { existsSync as existsSync2 } from "fs";
25
+ import { join as join2 } from "path";
26
+ import {
27
+ defaultClientConditions,
28
+ defaultServerConditions
29
+ } from "vite";
30
+ import { defineConfig } from "vitest/config";
31
+ import react from "@vitejs/plugin-react";
32
+ var EMPTY_CONFIG = {};
33
+ var EMPTY_PLUGINS = [];
34
+ function generateSelfPackageAliases(projectDir) {
35
+ const packageName = readPackageName(projectDir);
36
+ if (packageName === null) {
37
+ return {};
38
+ }
39
+ return {
40
+ [packageName]: `${projectDir}/src`
41
+ };
42
+ }
43
+ function autoDetectSetupFiles(projectDir) {
44
+ if (projectDir === void 0 || projectDir === "") {
45
+ return [];
46
+ }
47
+ const vitestSetupPath = join2(projectDir, "vitest.setup.ts");
48
+ if (existsSync2(vitestSetupPath)) {
49
+ return ["./vitest.setup.ts"];
50
+ }
51
+ const testsSetupPath = join2(projectDir, "tests/setup.ts");
52
+ if (existsSync2(testsSetupPath)) {
53
+ return ["./tests/setup.ts"];
54
+ }
55
+ return [];
56
+ }
57
+ function autoDetectIncludePatterns() {
58
+ return ["tests/**/*.test.{ts,tsx,js,jsx}"];
59
+ }
60
+ var reactConfig = {
61
+ test: {
62
+ environment: "jsdom",
63
+ exclude: ["**/node_modules/**", "**/dist/**"],
64
+ // Suppress vitest's unhandled error reporting for expected test errors
65
+ silent: false,
66
+ onConsoleLog: () => {
67
+ return void 0;
68
+ }
69
+ }
70
+ };
71
+ function createReactConfig(projectDirOrConfig, customConfig) {
72
+ let projectDir;
73
+ let config;
74
+ if (typeof projectDirOrConfig === "string") {
75
+ projectDir = projectDirOrConfig;
76
+ config = customConfig ?? {};
77
+ } else {
78
+ projectDir = void 0;
79
+ config = projectDirOrConfig ?? {};
80
+ }
81
+ if (projectDir !== void 0) {
82
+ return createReactConfigWithPlugins([react()], projectDir, config);
83
+ }
84
+ return createReactConfigWithPlugins([react()], config);
85
+ }
86
+ function createReactConfigWithPlugins(plugins = EMPTY_PLUGINS, projectDirOrConfig, customConfig) {
87
+ let projectDir;
88
+ let config;
89
+ if (typeof projectDirOrConfig === "string") {
90
+ projectDir = projectDirOrConfig;
91
+ config = customConfig ?? EMPTY_CONFIG;
92
+ } else {
93
+ projectDir = void 0;
94
+ config = projectDirOrConfig ?? EMPTY_CONFIG;
95
+ }
96
+ const autoSetupFiles = config.test?.setupFiles !== void 0 && config.test.setupFiles.length > 0 ? [] : autoDetectSetupFiles(projectDir);
97
+ const autoIncludePatterns = config.test?.include !== void 0 && config.test.include.length > 0 ? [] : autoDetectIncludePatterns();
98
+ return defineConfig({
99
+ plugins: [...plugins],
100
+ ...baseConfig,
101
+ ...reactConfig,
102
+ ...config,
103
+ test: {
104
+ ...baseConfig.test,
105
+ ...reactConfig.test,
106
+ // Auto-detect setupFiles if not explicitly provided
107
+ ...autoSetupFiles.length > 0 && { setupFiles: autoSetupFiles },
108
+ // Auto-detect include patterns if not explicitly provided
109
+ ...autoIncludePatterns.length > 0 && { include: autoIncludePatterns },
110
+ ...config.test,
111
+ coverage: {
112
+ ...baseConfig.test.coverage,
113
+ ...config.test?.coverage,
114
+ exclude: [
115
+ "**/node_modules/**",
116
+ "**/dist/**",
117
+ "**/tests/**",
118
+ "**/*.d.ts",
119
+ "**/*.config.{js,ts,mjs,mts}",
120
+ "**/coverage/**",
121
+ "**/examples/**",
122
+ "**/src/index.ts",
123
+ "**/src/*/index.ts",
124
+ "**/src/types/**",
125
+ "tsup.config.ts",
126
+ "vitest.config.mts",
127
+ "tailwind.config.mjs",
128
+ "**/.next/**",
129
+ "**/vitest.setup.ts",
130
+ "**/types.ts"
131
+ ]
132
+ }
133
+ },
134
+ resolve: {
135
+ // Prefer "source" condition in package.json exports, allowing
136
+ // Vitest to resolve workspace dependencies directly to TypeScript source
137
+ // files without requiring a prior build step.
138
+ //
139
+ // Since Vite 6, resolve.conditions REPLACES the defaults instead of
140
+ // extending them. We must include defaultClientConditions to preserve
141
+ // standard conditions like "module", "browser", "development|production".
142
+ conditions: ["source", ...defaultClientConditions],
143
+ // Deduplicate React to prevent multiple-instance issues in tests.
144
+ // This is Vite's standard API for singleton enforcement — no filesystem
145
+ // paths needed, Vite resolves from the project root automatically.
146
+ dedupe: [
147
+ "react",
148
+ "react-dom",
149
+ "react/jsx-runtime",
150
+ "react/jsx-dev-runtime"
151
+ ],
152
+ alias: {
153
+ // Auto-generate self-package alias
154
+ ...projectDir !== void 0 && projectDir !== "" && generateSelfPackageAliases(projectDir),
155
+ // Standard "@" → src alias
156
+ ...projectDir !== void 0 && projectDir !== "" && { "@": `${projectDir}/src` },
157
+ // Consumer-provided aliases override everything above
158
+ ...config.resolve?.alias
159
+ },
160
+ ...config.resolve
161
+ },
162
+ // Vitest runs in Vite's SSR mode. Since Vite 6, ssr.resolve.conditions is
163
+ // independent from resolve.conditions and defaults to defaultServerConditions.
164
+ // We must explicitly include "source" in ssr.resolve.conditions so
165
+ // workspace dependencies resolve to TypeScript source during test execution.
166
+ ssr: {
167
+ resolve: {
168
+ conditions: ["source", ...defaultServerConditions],
169
+ externalConditions: ["source"]
170
+ }
171
+ }
172
+ });
173
+ }
174
+
175
+ // src/index.ts
176
+ var EMPTY_CONFIG2 = {};
177
+ var baseConfig = {
178
+ test: {
179
+ testTimeout: 1e4,
180
+ // 10 seconds default timeout
181
+ hookTimeout: 1e4,
182
+ // 10 seconds for setup/teardown hooks
183
+ coverage: {
184
+ provider: "v8",
185
+ reporter: ["text", "html", "lcov", "json"],
186
+ reportsDirectory: "./generated/test-coverage",
187
+ exclude: [
188
+ "**/node_modules/**",
189
+ "**/dist/**",
190
+ "**/tests/**",
191
+ "**/*.d.ts",
192
+ "**/*.config.{js,ts,mjs,mts}",
193
+ "**/coverage/**",
194
+ "**/examples/**",
195
+ "**/src/index.ts",
196
+ "**/src/*/index.ts",
197
+ "**/src/types/**",
198
+ "tsup.config.ts",
199
+ "vitest.config.mts",
200
+ "tailwind.config.mjs",
201
+ "**/vitest.setup.ts"
202
+ ],
203
+ thresholds: process.env.VITEST_COVERAGE_THRESHOLDS_DISABLED === "true" ? {
204
+ lines: 0,
205
+ functions: 0,
206
+ branches: 0,
207
+ statements: 0
208
+ } : {
209
+ lines: 100,
210
+ functions: 100,
211
+ branches: 100,
212
+ statements: 100
213
+ }
214
+ }
215
+ }
216
+ };
217
+ function generateSelfPackageAliases2(projectDir) {
218
+ const packageName = readPackageName(projectDir);
219
+ if (packageName === null) {
220
+ return {};
221
+ }
222
+ return {
223
+ [packageName]: `${projectDir}/src`
224
+ };
225
+ }
226
+ function autoDetectSetupFiles2(projectDir) {
227
+ if (projectDir === void 0 || projectDir === "") {
228
+ return [];
229
+ }
230
+ const vitestSetupPath = join3(projectDir, "vitest.setup.ts");
231
+ if (existsSync3(vitestSetupPath)) {
232
+ return ["./vitest.setup.ts"];
233
+ }
234
+ const testsSetupPath = join3(projectDir, "tests/setup.ts");
235
+ if (existsSync3(testsSetupPath)) {
236
+ return ["./tests/setup.ts"];
237
+ }
238
+ return [];
239
+ }
240
+ function autoDetectIncludePatterns2() {
241
+ return ["tests/**/*.test.{ts,tsx,js,jsx}"];
242
+ }
243
+ function createVitestConfig(projectDirOrConfig, customConfig) {
244
+ let projectDir;
245
+ let config;
246
+ if (typeof projectDirOrConfig === "string") {
247
+ projectDir = projectDirOrConfig;
248
+ config = customConfig ?? EMPTY_CONFIG2;
249
+ } else {
250
+ projectDir = void 0;
251
+ config = projectDirOrConfig ?? EMPTY_CONFIG2;
252
+ }
253
+ const autoSetupFiles = config.test?.setupFiles !== void 0 && config.test.setupFiles.length > 0 ? [] : autoDetectSetupFiles2(projectDir);
254
+ const autoIncludePatterns = config.test?.include !== void 0 && config.test.include.length > 0 ? [] : autoDetectIncludePatterns2();
255
+ return defineConfig2({
256
+ ...baseConfig,
257
+ ...config,
258
+ test: {
259
+ ...baseConfig.test,
260
+ // Auto-detect setupFiles if not explicitly provided
261
+ ...autoSetupFiles.length > 0 && { setupFiles: autoSetupFiles },
262
+ // Auto-detect include patterns if not explicitly provided
263
+ ...autoIncludePatterns.length > 0 && { include: autoIncludePatterns },
264
+ ...config.test,
265
+ coverage: {
266
+ ...baseConfig.test.coverage,
267
+ ...config.test?.coverage
268
+ }
269
+ },
270
+ resolve: {
271
+ // Prefer "source" condition in package.json exports, allowing
272
+ // Vitest to resolve workspace dependencies directly to TypeScript source
273
+ // files without requiring a prior build step.
274
+ //
275
+ // Since Vite 6, resolve.conditions REPLACES the defaults instead of
276
+ // extending them. We must include defaultClientConditions to preserve
277
+ // standard conditions like "module", "browser", "development|production".
278
+ conditions: ["source", ...defaultClientConditions2],
279
+ alias: {
280
+ // Work around packages whose "module" entry is bundler-oriented but not
281
+ // directly Node.js ESM-resolvable in Vitest (e.g. extensionless internal
282
+ // specifiers). Prefer the Node/CJS build for tests.
283
+ "@opentelemetry/api": "@opentelemetry/api/build/src/index.js",
284
+ // Auto-generate self-package alias (e.g. "@reasonabletech/utils" → "./src")
285
+ ...projectDir !== void 0 && projectDir !== "" && generateSelfPackageAliases2(projectDir),
286
+ // Standard "@" → src alias
287
+ ...projectDir !== void 0 && projectDir !== "" && { "@": `${projectDir}/src` },
288
+ // Consumer-provided aliases override everything above
289
+ ...config.resolve?.alias
290
+ },
291
+ ...config.resolve
292
+ },
293
+ // Vitest runs in Vite's SSR mode. Since Vite 6, ssr.resolve.conditions is
294
+ // independent from resolve.conditions and defaults to defaultServerConditions.
295
+ // We must explicitly include "source" in ssr.resolve.conditions so
296
+ // workspace dependencies resolve to TypeScript source during test execution.
297
+ // Additionally, ssr.resolve.externalConditions passes "source" to
298
+ // Node.js when it natively resolves externalized packages.
299
+ //
300
+ // Note: We intentionally omit the "module" export condition for SSR tests.
301
+ // Some third-party packages expose a "module" build that is bundler-friendly
302
+ // but not directly Node.js ESM-resolvable (for example: extensionless internal
303
+ // specifiers). For tests, preferring Node-compatible ("node"/"default") entry
304
+ // points avoids runtime import failures.
305
+ ssr: {
306
+ resolve: {
307
+ conditions: [
308
+ "source",
309
+ ...defaultServerConditions2.filter(
310
+ (condition) => condition !== "module"
311
+ )
312
+ ],
313
+ externalConditions: ["source"]
314
+ }
315
+ }
316
+ });
317
+ }
318
+ function createLongRunningTestConfig(projectDirOrConfig, customConfig) {
319
+ let projectDir;
320
+ let config;
321
+ if (typeof projectDirOrConfig === "string") {
322
+ projectDir = projectDirOrConfig;
323
+ config = customConfig ?? EMPTY_CONFIG2;
324
+ } else {
325
+ projectDir = void 0;
326
+ config = projectDirOrConfig ?? EMPTY_CONFIG2;
327
+ }
328
+ const longRunningConfig = {
329
+ ...config,
330
+ test: {
331
+ testTimeout: 3e4,
332
+ // 30 seconds for long-running tests
333
+ hookTimeout: 3e4,
334
+ // 30 seconds for setup/teardown hooks
335
+ ...config.test
336
+ }
337
+ };
338
+ if (projectDir !== void 0) {
339
+ return createVitestConfig(projectDir, longRunningConfig);
340
+ }
341
+ return createVitestConfig(longRunningConfig);
342
+ }
343
+ var index_default = createVitestConfig;
344
+ export {
345
+ baseConfig,
346
+ createLongRunningTestConfig,
347
+ createReactConfig,
348
+ createReactConfigWithPlugins,
349
+ createVitestConfig,
350
+ index_default as default
351
+ };
352
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts","../../src/workspace.ts","../../src/react.ts"],"sourcesContent":["/**\n * Base Vitest configuration for all packages\n * @module @reasonabletech/config-vitest\n */\n\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { defaultClientConditions, defaultServerConditions } from \"vite\";\nimport { defineConfig } from \"vitest/config\";\nimport type { InlineConfig } from \"vitest/node\";\nimport { readPackageName } from \"./workspace.js\";\n\n/** Recursively makes all properties of T readonly */\nexport type DeepReadonly<T> = {\n readonly [P in keyof T]: T[P] extends ReadonlyArray<infer U>\n ? ReadonlyArray<DeepReadonly<U>>\n : T[P] extends Array<infer U>\n ? ReadonlyArray<DeepReadonly<U>>\n : T[P] extends object\n ? DeepReadonly<T[P]>\n : T[P];\n};\n\n/**\n * Immutable configuration object accepted by {@link createVitestConfig} and\n * related helpers.\n */\nexport type VitestConfig = DeepReadonly<{\n test?: InlineConfig;\n resolve?: {\n conditions?: string[];\n alias?: Record<string, string>;\n [key: string]: unknown;\n };\n [key: string]: unknown;\n}>;\n\n// Empty readonly config for default parameters\nconst EMPTY_CONFIG = {} as const satisfies VitestConfig;\n\n/**\n * Base configuration options that apply to all test environments\n */\nexport const baseConfig = {\n test: {\n testTimeout: 10000, // 10 seconds default timeout\n hookTimeout: 10000, // 10 seconds for setup/teardown hooks\n coverage: {\n provider: \"v8\" as const,\n reporter: [\"text\", \"html\", \"lcov\", \"json\"],\n reportsDirectory: \"./generated/test-coverage\",\n exclude: [\n \"**/node_modules/**\",\n \"**/dist/**\",\n \"**/tests/**\",\n \"**/*.d.ts\",\n \"**/*.config.{js,ts,mjs,mts}\",\n \"**/coverage/**\",\n \"**/examples/**\",\n \"**/src/index.ts\",\n \"**/src/*/index.ts\",\n \"**/src/types/**\",\n \"tsup.config.ts\",\n \"vitest.config.mts\",\n \"tailwind.config.mjs\",\n \"**/vitest.setup.ts\",\n ],\n thresholds:\n process.env.VITEST_COVERAGE_THRESHOLDS_DISABLED === \"true\"\n ? {\n lines: 0,\n functions: 0,\n branches: 0,\n statements: 0,\n }\n : {\n lines: 100,\n functions: 100,\n branches: 100,\n statements: 100,\n },\n },\n },\n};\n\n/**\n * Generates resolve aliases that map a package's own name back to its source\n * directory. This allows test files to `import { foo } from \"@reasonabletech/my-pkg\"`\n * and have Vite resolve it to the local `src/` tree instead of requiring a prior\n * build step.\n *\n * Placed before user-supplied aliases so consumers can override if needed.\n * @param projectDir - Absolute path to the project directory\n * @returns A record mapping the package name to its `src/` directory\n */\nfunction generateSelfPackageAliases(\n projectDir: string,\n): Record<string, string> {\n const packageName = readPackageName(projectDir);\n if (packageName === null) {\n return {};\n }\n return {\n [packageName]: `${projectDir}/src`,\n };\n}\n\n/**\n * Auto-detects setup files in a project directory\n * @param projectDir - The project directory path\n * @returns Array of detected setup file paths\n */\nfunction autoDetectSetupFiles(projectDir?: string): string[] {\n if (projectDir === undefined || projectDir === \"\") {\n return [];\n }\n\n const vitestSetupPath = join(projectDir, \"vitest.setup.ts\");\n if (existsSync(vitestSetupPath)) {\n return [\"./vitest.setup.ts\"];\n }\n\n const testsSetupPath = join(projectDir, \"tests/setup.ts\");\n if (existsSync(testsSetupPath)) {\n return [\"./tests/setup.ts\"];\n }\n\n return [];\n}\n\n/**\n * Auto-detects test include patterns based on project structure\n * @returns Array of include patterns\n */\nfunction autoDetectIncludePatterns(): string[] {\n return [\"tests/**/*.test.{ts,tsx,js,jsx}\"];\n}\n\n/** @overload */\n/**\n * Creates a merged configuration from the base and any custom options.\n * @param projectDirOrConfig - Either the absolute project directory (use `import.meta.dirname`) or a prebuilt config.\n * @param customConfig - Additional configuration to merge when a project directory is provided.\n * @returns A merged Vitest configuration tailored for the caller.\n */\nexport function createVitestConfig(\n projectDirOrConfig?: string | VitestConfig,\n customConfig?: VitestConfig,\n): ReturnType<typeof defineConfig> {\n // Handle overloaded parameters\n let projectDir: string | undefined;\n let config: VitestConfig;\n\n if (typeof projectDirOrConfig === \"string\") {\n projectDir = projectDirOrConfig;\n config = customConfig ?? EMPTY_CONFIG;\n } else {\n projectDir = undefined;\n config = projectDirOrConfig ?? EMPTY_CONFIG;\n }\n\n // Auto-detect configuration if not explicitly provided\n const autoSetupFiles =\n config.test?.setupFiles !== undefined && config.test.setupFiles.length > 0\n ? []\n : autoDetectSetupFiles(projectDir);\n const autoIncludePatterns =\n config.test?.include !== undefined && config.test.include.length > 0\n ? []\n : autoDetectIncludePatterns();\n\n return defineConfig({\n ...baseConfig,\n ...config,\n test: {\n ...baseConfig.test,\n // Auto-detect setupFiles if not explicitly provided\n ...(autoSetupFiles.length > 0 && { setupFiles: autoSetupFiles }),\n // Auto-detect include patterns if not explicitly provided\n ...(autoIncludePatterns.length > 0 && { include: autoIncludePatterns }),\n ...config.test,\n coverage: {\n ...baseConfig.test.coverage,\n ...config.test?.coverage,\n },\n },\n resolve: {\n // Prefer \"source\" condition in package.json exports, allowing\n // Vitest to resolve workspace dependencies directly to TypeScript source\n // files without requiring a prior build step.\n //\n // Since Vite 6, resolve.conditions REPLACES the defaults instead of\n // extending them. We must include defaultClientConditions to preserve\n // standard conditions like \"module\", \"browser\", \"development|production\".\n conditions: [\"source\", ...defaultClientConditions],\n alias: {\n // Work around packages whose \"module\" entry is bundler-oriented but not\n // directly Node.js ESM-resolvable in Vitest (e.g. extensionless internal\n // specifiers). Prefer the Node/CJS build for tests.\n \"@opentelemetry/api\": \"@opentelemetry/api/build/src/index.js\",\n // Auto-generate self-package alias (e.g. \"@reasonabletech/utils\" → \"./src\")\n ...(projectDir !== undefined &&\n projectDir !== \"\" &&\n generateSelfPackageAliases(projectDir)),\n // Standard \"@\" → src alias\n ...(projectDir !== undefined &&\n projectDir !== \"\" && { \"@\": `${projectDir}/src` }),\n // Consumer-provided aliases override everything above\n ...config.resolve?.alias,\n },\n ...config.resolve,\n },\n // Vitest runs in Vite's SSR mode. Since Vite 6, ssr.resolve.conditions is\n // independent from resolve.conditions and defaults to defaultServerConditions.\n // We must explicitly include \"source\" in ssr.resolve.conditions so\n // workspace dependencies resolve to TypeScript source during test execution.\n // Additionally, ssr.resolve.externalConditions passes \"source\" to\n // Node.js when it natively resolves externalized packages.\n //\n // Note: We intentionally omit the \"module\" export condition for SSR tests.\n // Some third-party packages expose a \"module\" build that is bundler-friendly\n // but not directly Node.js ESM-resolvable (for example: extensionless internal\n // specifiers). For tests, preferring Node-compatible (\"node\"/\"default\") entry\n // points avoids runtime import failures.\n ssr: {\n resolve: {\n conditions: [\n \"source\",\n ...defaultServerConditions.filter(\n (condition) => condition !== \"module\",\n ),\n ],\n externalConditions: [\"source\"],\n },\n },\n });\n}\n\n/** @overload */\n/**\n * Creates a configuration with extended timeouts for long-running tests.\n * @param projectDirOrConfig - Either the absolute project directory or an existing configuration to extend.\n * @param customConfig - Additional configuration to merge when a project directory is supplied.\n * @returns A Vitest configuration suited for long-running suites.\n */\nexport function createLongRunningTestConfig(\n projectDirOrConfig?: string | VitestConfig,\n customConfig?: VitestConfig,\n): ReturnType<typeof defineConfig> {\n // Handle overloaded parameters\n let projectDir: string | undefined;\n let config: VitestConfig;\n\n if (typeof projectDirOrConfig === \"string\") {\n projectDir = projectDirOrConfig;\n config = customConfig ?? EMPTY_CONFIG;\n } else {\n projectDir = undefined;\n config = projectDirOrConfig ?? EMPTY_CONFIG;\n }\n\n const longRunningConfig: VitestConfig = {\n ...config,\n test: {\n testTimeout: 30000, // 30 seconds for long-running tests\n hookTimeout: 30000, // 30 seconds for setup/teardown hooks\n ...config.test,\n },\n };\n\n if (projectDir !== undefined) {\n return createVitestConfig(projectDir, longRunningConfig);\n }\n return createVitestConfig(longRunningConfig);\n}\n\n// Re-export for convenience\nexport { createReactConfig, createReactConfigWithPlugins } from \"./react.js\";\n\nexport default createVitestConfig;\n","/**\n * Workspace utility functions for discovering monorepo structure\n *\n * These are extracted from global-setup.ts so they can be reused by\n * the Vitest config factories (e.g. auto self-package aliasing).\n * @module @reasonabletech/config-vitest/workspace\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\n\n/**\n * Walks up the directory tree from `startDir` until it finds a directory\n * containing `pnpm-workspace.yaml`, which marks the monorepo root.\n *\n * Returns `startDir` unchanged if no workspace root is found (e.g. when\n * running outside the monorepo).\n * @param startDir - The directory to start searching from\n * @returns The absolute path to the monorepo root, or `startDir` if not found\n */\nexport function findRepoRoot(startDir: string): string {\n let currentDir = startDir;\n for (;;) {\n if (existsSync(path.join(currentDir, \"pnpm-workspace.yaml\"))) {\n return currentDir;\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n return startDir;\n }\n currentDir = parentDir;\n }\n}\n\n/**\n * Reads the `name` field from the `package.json` in the given directory.\n *\n * Returns `null` when:\n * - No `package.json` exists at `packageDir`\n * - The file cannot be parsed as JSON\n * - The `name` field is missing, empty, or not a string\n * @param packageDir - The directory containing the package.json to read\n * @returns The package name string, or `null` if unavailable\n */\nexport function readPackageName(packageDir: string): string | null {\n const packageJsonPath = path.join(packageDir, \"package.json\");\n if (!existsSync(packageJsonPath)) {\n return null;\n }\n\n try {\n const parsed = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n name?: unknown;\n };\n return typeof parsed.name === \"string\" && parsed.name.length > 0\n ? parsed.name\n : null;\n } catch {\n return null;\n }\n}\n","/**\n * React-specific Vitest configuration\n * @module @reasonabletech/config-vitest/react\n */\n\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n defaultClientConditions,\n defaultServerConditions,\n type PluginOption,\n} from \"vite\";\nimport { defineConfig } from \"vitest/config\";\nimport type { InlineConfig } from \"vitest/node\";\nimport react from \"@vitejs/plugin-react\";\nimport { baseConfig, type DeepReadonly } from \"./index.js\";\nimport { readPackageName } from \"./workspace.js\";\n\ntype VitestConfig = DeepReadonly<{\n test?: InlineConfig;\n resolve?: {\n alias?: Record<string, string>;\n [key: string]: unknown;\n };\n [key: string]: unknown;\n}>;\n\n// Empty readonly config and plugins array for default parameters\nconst EMPTY_CONFIG = {} as const satisfies VitestConfig;\nconst EMPTY_PLUGINS = [] as const satisfies readonly PluginOption[];\n\n/**\n * Generates resolve aliases mapping a package's own name to its source directory.\n * @param projectDir - Absolute path to the project directory\n * @returns A record mapping the package name to its `src/` directory\n * @see index.ts for the equivalent function used in the base config\n */\nfunction generateSelfPackageAliases(\n projectDir: string,\n): Record<string, string> {\n const packageName = readPackageName(projectDir);\n if (packageName === null) {\n return {};\n }\n return {\n [packageName]: `${projectDir}/src`,\n };\n}\n\n/**\n * Auto-detects setup files in a project directory\n * @param projectDir - The project directory path\n * @returns Array of detected setup file paths\n */\nfunction autoDetectSetupFiles(projectDir?: string): string[] {\n if (projectDir === undefined || projectDir === \"\") {\n return [];\n }\n\n const vitestSetupPath = join(projectDir, \"vitest.setup.ts\");\n if (existsSync(vitestSetupPath)) {\n return [\"./vitest.setup.ts\"];\n }\n\n const testsSetupPath = join(projectDir, \"tests/setup.ts\");\n if (existsSync(testsSetupPath)) {\n return [\"./tests/setup.ts\"];\n }\n\n return [];\n}\n\n/**\n * Auto-detects test include patterns based on project structure\n * @returns Array of include patterns\n */\nfunction autoDetectIncludePatterns(): string[] {\n return [\"tests/**/*.test.{ts,tsx,js,jsx}\"];\n}\n\n/**\n * React-specific configuration options\n */\nexport const reactConfig = {\n test: {\n environment: \"jsdom\",\n exclude: [\"**/node_modules/**\", \"**/dist/**\"],\n // Suppress vitest's unhandled error reporting for expected test errors\n silent: false,\n onConsoleLog: (): boolean | undefined => {\n // Allow packages to customize console filtering in their own config\n return undefined;\n },\n },\n};\n\n/** @overload */\n/**\n * Creates a Vitest configuration for React-based packages.\n * @param projectDirOrConfig - Either the absolute project directory or an existing configuration to merge.\n * @param customConfig - Additional configuration options for the project-dir overload.\n * @returns A Vitest configuration optimized for React components.\n */\nexport function createReactConfig(\n projectDirOrConfig?: string | VitestConfig,\n customConfig?: VitestConfig,\n): ReturnType<typeof defineConfig> {\n // Handle overloaded parameters\n let projectDir: string | undefined;\n let config: VitestConfig;\n\n if (typeof projectDirOrConfig === \"string\") {\n projectDir = projectDirOrConfig;\n config = customConfig ?? ({} as const);\n } else {\n projectDir = undefined;\n config = projectDirOrConfig ?? ({} as const);\n }\n\n if (projectDir !== undefined) {\n return createReactConfigWithPlugins([react()], projectDir, config);\n }\n return createReactConfigWithPlugins([react()], config);\n}\n\n/** @overload */\n/**\n * Creates a Vitest configuration for React-based packages with plugins.\n * @param plugins - Array of Vite plugins to include.\n * @param projectDirOrConfig - Either the absolute project directory or an existing configuration to merge.\n * @param customConfig - Additional configuration options for the project-dir overload.\n * @returns A Vitest configuration optimized for React components with plugins.\n */\nexport function createReactConfigWithPlugins(\n plugins: readonly PluginOption[] = EMPTY_PLUGINS,\n projectDirOrConfig?: string | VitestConfig,\n customConfig?: VitestConfig,\n): ReturnType<typeof defineConfig> {\n // Handle overloaded parameters\n let projectDir: string | undefined;\n let config: VitestConfig;\n\n if (typeof projectDirOrConfig === \"string\") {\n projectDir = projectDirOrConfig;\n config = customConfig ?? EMPTY_CONFIG;\n } else {\n projectDir = undefined;\n config = projectDirOrConfig ?? EMPTY_CONFIG;\n }\n\n // Auto-detect configuration if not explicitly provided\n const autoSetupFiles =\n config.test?.setupFiles !== undefined && config.test.setupFiles.length > 0\n ? []\n : autoDetectSetupFiles(projectDir);\n const autoIncludePatterns =\n config.test?.include !== undefined && config.test.include.length > 0\n ? []\n : autoDetectIncludePatterns();\n\n return defineConfig({\n plugins: [...plugins],\n ...baseConfig,\n ...reactConfig,\n ...config,\n test: {\n ...baseConfig.test,\n ...reactConfig.test,\n // Auto-detect setupFiles if not explicitly provided\n ...(autoSetupFiles.length > 0 && { setupFiles: autoSetupFiles }),\n // Auto-detect include patterns if not explicitly provided\n ...(autoIncludePatterns.length > 0 && { include: autoIncludePatterns }),\n ...config.test,\n coverage: {\n ...baseConfig.test.coverage,\n ...config.test?.coverage,\n exclude: [\n \"**/node_modules/**\",\n \"**/dist/**\",\n \"**/tests/**\",\n \"**/*.d.ts\",\n \"**/*.config.{js,ts,mjs,mts}\",\n \"**/coverage/**\",\n \"**/examples/**\",\n \"**/src/index.ts\",\n \"**/src/*/index.ts\",\n \"**/src/types/**\",\n \"tsup.config.ts\",\n \"vitest.config.mts\",\n \"tailwind.config.mjs\",\n \"**/.next/**\",\n \"**/vitest.setup.ts\",\n \"**/types.ts\",\n ],\n },\n },\n resolve: {\n // Prefer \"source\" condition in package.json exports, allowing\n // Vitest to resolve workspace dependencies directly to TypeScript source\n // files without requiring a prior build step.\n //\n // Since Vite 6, resolve.conditions REPLACES the defaults instead of\n // extending them. We must include defaultClientConditions to preserve\n // standard conditions like \"module\", \"browser\", \"development|production\".\n conditions: [\"source\", ...defaultClientConditions],\n // Deduplicate React to prevent multiple-instance issues in tests.\n // This is Vite's standard API for singleton enforcement — no filesystem\n // paths needed, Vite resolves from the project root automatically.\n dedupe: [\n \"react\",\n \"react-dom\",\n \"react/jsx-runtime\",\n \"react/jsx-dev-runtime\",\n ],\n alias: {\n // Auto-generate self-package alias\n ...(projectDir !== undefined &&\n projectDir !== \"\" &&\n generateSelfPackageAliases(projectDir)),\n // Standard \"@\" → src alias\n ...(projectDir !== undefined &&\n projectDir !== \"\" && { \"@\": `${projectDir}/src` }),\n // Consumer-provided aliases override everything above\n ...config.resolve?.alias,\n },\n ...config.resolve,\n },\n // Vitest runs in Vite's SSR mode. Since Vite 6, ssr.resolve.conditions is\n // independent from resolve.conditions and defaults to defaultServerConditions.\n // We must explicitly include \"source\" in ssr.resolve.conditions so\n // workspace dependencies resolve to TypeScript source during test execution.\n ssr: {\n resolve: {\n conditions: [\"source\", ...defaultServerConditions],\n externalConditions: [\"source\"],\n },\n },\n });\n}\n\nexport default createReactConfig;\n"],"mappings":";AAKA,SAAS,cAAAA,mBAAkB;AAC3B,SAAS,QAAAC,aAAY;AACrB,SAAS,2BAAAC,0BAAyB,2BAAAC,gCAA+B;AACjE,SAAS,gBAAAC,qBAAoB;;;ACA7B,SAAS,YAAY,oBAAoB;AACzC,YAAY,UAAU;AAoCf,SAAS,gBAAgB,YAAmC;AACjE,QAAM,kBAAuB,UAAK,YAAY,cAAc;AAC5D,MAAI,CAAC,WAAW,eAAe,GAAG;AAChC,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,SAAS,KAAK,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AAQ;","names":["existsSync","join","defaultClientConditions","defaultServerConditions","defineConfig","existsSync","join","join","existsSync","EMPTY_CONFIG","generateSelfPackageAliases","autoDetectSetupFiles","join","existsSync","autoDetectIncludePatterns","defineConfig","defaultClientConditions","defaultServerConditions"]}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Node.js-specific Vitest configuration
3
+ * @module @reasonabletech/config-vitest/node
4
+ */
5
+ import type { InlineConfig } from "vitest/node";
6
+ import type { UserConfig } from "vite";
7
+ import { createVitestConfig, type DeepReadonly } from "./index.js";
8
+ /** Immutable Vitest configuration type combining Vite UserConfig with Vitest InlineConfig */
9
+ export type VitestConfig = DeepReadonly<UserConfig> & {
10
+ readonly test?: DeepReadonly<InlineConfig>;
11
+ };
12
+ /**
13
+ * Node.js-specific configuration options
14
+ */
15
+ export declare const nodeConfig: {
16
+ readonly test: {
17
+ readonly environment: "node";
18
+ readonly include: ["tests/**/*.test.ts"];
19
+ };
20
+ };
21
+ /**
22
+ * Creates a Vitest configuration for Node.js-based packages.
23
+ * @param projectDirOrConfig - Either the absolute project directory (use `import.meta.dirname`) or a prebuilt config.
24
+ * @param customConfig - Additional configuration to merge when a project directory is provided.
25
+ * @returns A Vitest configuration optimized for Node.js environments
26
+ */
27
+ export declare function createNodeConfig(projectDirOrConfig?: string | VitestConfig, customConfig?: VitestConfig): ReturnType<typeof createVitestConfig>;
28
+ export default createNodeConfig;
29
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAEnE,6FAA6F;AAC7F,MAAM,MAAM,YAAY,GAAG,YAAY,CAAC,UAAU,CAAC,GAAG;IACpD,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;CAC5C,CAAC;AAKF;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;CAKU,CAAC;AAElC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,kBAAkB,CAAC,EAAE,MAAM,GAAG,YAAY,EAC1C,YAAY,CAAC,EAAE,YAAY,GAC1B,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAmCvC;AAED,eAAe,gBAAgB,CAAC"}