vitest-plugin-vis 4.1.0 → 4.2.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/dist/auto_snapshots/_ctx.mjs +15 -0
- package/dist/auto_snapshots/_ctx.mjs.map +1 -0
- package/dist/auto_snapshots/_extract_auto_snapshot_options.mjs +23 -0
- package/dist/auto_snapshots/_extract_auto_snapshot_options.mjs.map +1 -0
- package/dist/{auto_snapshot_options-BMRtKmod.d.mts → auto_snapshots/auto_snapshot_options.d.mts} +5 -4
- package/dist/auto_snapshots/auto_snapshot_options.d.mts.map +1 -0
- package/dist/{auto_snapshot_options-DUOTpF2N.mjs → auto_snapshots/auto_snapshot_options.mjs} +6 -40
- package/dist/auto_snapshots/auto_snapshot_options.mjs.map +1 -0
- package/dist/auto_snapshots/snapshot_meta.d.mts +15 -0
- package/dist/auto_snapshots/snapshot_meta.d.mts.map +1 -0
- package/dist/client/actions/has_image_snapshot_action.d.mts +8 -0
- package/dist/client/actions/has_image_snapshot_action.d.mts.map +1 -0
- package/dist/client/actions/has_image_snapshot_action.mjs +9 -0
- package/dist/client/actions/has_image_snapshot_action.mjs.map +1 -0
- package/dist/client/actions/load_image_snapshot_results_action.d.mts +7 -0
- package/dist/client/actions/load_image_snapshot_results_action.d.mts.map +1 -0
- package/dist/client/actions/load_image_snapshot_results_action.mjs +8 -0
- package/dist/client/actions/load_image_snapshot_results_action.mjs.map +1 -0
- package/dist/client/actions/match_image_snapshot_action.d.mts +9 -0
- package/dist/client/actions/match_image_snapshot_action.d.mts.map +1 -0
- package/dist/client/actions/match_image_snapshot_action.mjs +20 -0
- package/dist/client/actions/match_image_snapshot_action.mjs.map +1 -0
- package/dist/client/actions/match_page_image_snapshot_action.d.mts +9 -0
- package/dist/client/actions/match_page_image_snapshot_action.d.mts.map +1 -0
- package/dist/client/actions/match_page_image_snapshot_action.mjs +14 -0
- package/dist/client/actions/match_page_image_snapshot_action.mjs.map +1 -0
- package/dist/client/expect/_ctx.mjs +15 -0
- package/dist/client/expect/_ctx.mjs.map +1 -0
- package/dist/client/expect/augment.d.mts +10 -0
- package/dist/client/expect/augment.d.mts.map +1 -0
- package/dist/client/expect/expectation_result.d.mts +7 -0
- package/dist/client/expect/expectation_result.d.mts.map +1 -0
- package/dist/client/expect/expectation_result.mjs +9 -0
- package/dist/client/expect/expectation_result.mjs.map +1 -0
- package/dist/client/expect/extend.d.mts +1 -0
- package/dist/client/expect/extend.mjs +9 -0
- package/dist/client/expect/extend.mjs.map +1 -0
- package/dist/client/expect/to_match_image_snapshot.mjs +16 -0
- package/dist/client/expect/to_match_image_snapshot.mjs.map +1 -0
- package/dist/{to_match_image_snapshot.types--tTmHoRA.d.mts → client/expect/to_match_image_snapshot.types.d.mts} +3 -3
- package/dist/client/expect/to_match_image_snapshot.types.d.mts.map +1 -0
- package/dist/client/external/browser/has_render_content.mjs +8 -0
- package/dist/client/external/browser/has_render_content.mjs.map +1 -0
- package/dist/client/external/browser/image_data.mjs +37 -0
- package/dist/client/external/browser/image_data.mjs.map +1 -0
- package/dist/client/external/browser/image_resizer.mjs +32 -0
- package/dist/client/external/browser/image_resizer.mjs.map +1 -0
- package/dist/client/external/browser/selector.mjs +57 -0
- package/dist/client/external/browser/selector.mjs.map +1 -0
- package/dist/client/external/vitest/vitest_browser_context_proxy.mjs +12 -0
- package/dist/client/external/vitest/vitest_browser_context_proxy.mjs.map +1 -0
- package/dist/client/external/vitest/vitest_suite_proxy.d.mts +3 -0
- package/dist/client/external/vitest/vitest_suite_proxy.mjs +11 -0
- package/dist/client/external/vitest/vitest_suite_proxy.mjs.map +1 -0
- package/dist/client/image/align_images.mjs +14 -0
- package/dist/client/image/align_images.mjs.map +1 -0
- package/dist/client/page/_ctx.d.mts +3 -0
- package/dist/client/page/_ctx.mjs +15 -0
- package/dist/client/page/_ctx.mjs.map +1 -0
- package/dist/client/page/augment.d.mts +9 -0
- package/dist/client/page/augment.d.mts.map +1 -0
- package/dist/client/page/extend.d.mts +1 -0
- package/dist/client/page/extend.mjs +13 -0
- package/dist/client/page/extend.mjs.map +1 -0
- package/dist/client/page/has_image_snapshot.d.mts +13 -0
- package/dist/client/page/has_image_snapshot.d.mts.map +1 -0
- package/dist/client/page/has_image_snapshot.mjs +15 -0
- package/dist/client/page/has_image_snapshot.mjs.map +1 -0
- package/dist/client/page/to_match_image_snapshot.d.mts +9 -0
- package/dist/client/page/to_match_image_snapshot.d.mts.map +1 -0
- package/dist/client/page/to_match_image_snapshot.mjs +15 -0
- package/dist/client/page/to_match_image_snapshot.mjs.map +1 -0
- package/dist/client/snapshot/compare_image_snapshot.logic.mjs +14 -0
- package/dist/client/snapshot/compare_image_snapshot.logic.mjs.map +1 -0
- package/dist/client/snapshot/compare_image_snapshot.mjs +63 -0
- package/dist/client/snapshot/compare_image_snapshot.mjs.map +1 -0
- package/dist/client/snapshot/should_take_snapshot.mjs +10 -0
- package/dist/client/snapshot/should_take_snapshot.mjs.map +1 -0
- package/dist/client/suite/_ctx.mjs +13 -0
- package/dist/client/suite/_ctx.mjs.map +1 -0
- package/dist/client/suite/auto_snapshot_matcher.d.mts +12 -0
- package/dist/client/suite/auto_snapshot_matcher.d.mts.map +1 -0
- package/dist/client/suite/auto_snapshot_matcher.mjs +50 -0
- package/dist/client/suite/auto_snapshot_matcher.mjs.map +1 -0
- package/dist/client/task/task_id.d.mts +9 -0
- package/dist/client/task/task_id.d.mts.map +1 -0
- package/dist/client/task/task_id.mjs +15 -0
- package/dist/client/task/task_id.mjs.map +1 -0
- package/dist/client-api.d.mts +13 -44
- package/dist/client-api.mjs +10 -13
- package/dist/{types-DJYCbyT8.d.mts → config/types.d.mts} +8 -9
- package/dist/config/types.d.mts.map +1 -0
- package/dist/config/vis.d.mts +27 -0
- package/dist/config/vis.d.mts.map +1 -0
- package/dist/config/vis.mjs +31 -0
- package/dist/config/vis.mjs.map +1 -0
- package/dist/config.d.mts +5 -28
- package/dist/config.mjs +3 -411
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +1 -4
- package/dist/presets/auto.mjs +4 -7
- package/dist/presets/auto.mjs.map +1 -1
- package/dist/presets/enable.mjs +2 -6
- package/dist/presets/enable.mjs.map +1 -1
- package/dist/presets/manual.mjs +2 -6
- package/dist/presets/manual.mjs.map +1 -1
- package/dist/server/browser_provider/browser_api.mjs +13 -0
- package/dist/server/browser_provider/browser_api.mjs.map +1 -0
- package/dist/server/browser_provider/playwright.mjs +24 -0
- package/dist/server/browser_provider/playwright.mjs.map +1 -0
- package/dist/server/browser_provider/webdriverio.mjs +16 -0
- package/dist/server/browser_provider/webdriverio.mjs.map +1 -0
- package/dist/server/commands/_assertions.mjs +10 -0
- package/dist/server/commands/_assertions.mjs.map +1 -0
- package/dist/server/commands/augment.d.mts +8 -0
- package/dist/server/commands/augment.d.mts.map +1 -0
- package/dist/server/commands/commands.mjs +20 -0
- package/dist/server/commands/commands.mjs.map +1 -0
- package/dist/server/commands/has_image_snapshot.mjs +12 -0
- package/dist/server/commands/has_image_snapshot.mjs.map +1 -0
- package/dist/server/commands/image_snapshot_next_index.mjs +12 -0
- package/dist/server/commands/image_snapshot_next_index.mjs.map +1 -0
- package/dist/server/commands/load_image_snapshot_results.mjs +12 -0
- package/dist/server/commands/load_image_snapshot_results.mjs.map +1 -0
- package/dist/server/commands/prepare_image_snapshot_comparison.mjs +37 -0
- package/dist/server/commands/prepare_image_snapshot_comparison.mjs.map +1 -0
- package/dist/server/commands/prepare_page_image_snapshot_comparison.mjs +27 -0
- package/dist/server/commands/prepare_page_image_snapshot_comparison.mjs.map +1 -0
- package/dist/server/commands/setup_vis_suite.mjs +12 -0
- package/dist/server/commands/setup_vis_suite.mjs.map +1 -0
- package/dist/server/externals/file.mjs +23 -0
- package/dist/server/externals/file.mjs.map +1 -0
- package/dist/server/project.mjs +13 -0
- package/dist/server/project.mjs.map +1 -0
- package/dist/server/snapshot.mjs +29 -0
- package/dist/server/snapshot.mjs.map +1 -0
- package/dist/server/snapshot_path.d.mts +17 -0
- package/dist/server/snapshot_path.d.mts.map +1 -0
- package/dist/{snapshot_path-7GliOSH_.mjs → server/snapshot_path.mjs} +7 -25
- package/dist/server/snapshot_path.mjs.map +1 -0
- package/dist/server/snapshot_writer.mjs +21 -0
- package/dist/server/snapshot_writer.mjs.map +1 -0
- package/dist/server/suite.mjs +82 -0
- package/dist/server/suite.mjs.map +1 -0
- package/dist/server/vis_options.mjs +19 -0
- package/dist/server/vis_options.mjs.map +1 -0
- package/dist/server/vis_server_context.deps.mjs +16 -0
- package/dist/server/vis_server_context.deps.mjs.map +1 -0
- package/dist/server/vis_server_context.logic.mjs +82 -0
- package/dist/server/vis_server_context.logic.mjs.map +1 -0
- package/dist/server/vis_server_context.mjs +8 -0
- package/dist/server/vis_server_context.mjs.map +1 -0
- package/dist/server/vis_server_context.types.d.mts +2 -0
- package/dist/server-utils.d.mts +4 -19
- package/dist/server-utils.mjs +3 -2
- package/dist/setup/create_vis.d.mts +108 -0
- package/dist/setup/create_vis.d.mts.map +1 -0
- package/dist/setup/create_vis.mjs +58 -0
- package/dist/setup/create_vis.mjs.map +1 -0
- package/dist/setup/vis.d.mts +10 -0
- package/dist/setup/vis.d.mts.map +1 -0
- package/dist/setup/vis.mjs +12 -0
- package/dist/setup/vis.mjs.map +1 -0
- package/dist/setup-api.d.mts +4 -0
- package/dist/setup-api.mjs +5 -0
- package/dist/setup.d.mts +8 -101
- package/dist/setup.d.mts.map +1 -1
- package/dist/setup.mjs +12 -7
- package/dist/setup.mjs.map +1 -0
- package/dist/{asserts--HSSlgPD.mjs → shared/asserts.mjs} +2 -2
- package/dist/shared/asserts.mjs.map +1 -0
- package/dist/{base64-CHSENEAO.mjs → shared/base64.mjs} +2 -2
- package/dist/shared/base64.mjs.map +1 -0
- package/dist/{commands.types-BVhcnnHw.d.mts → shared/commands.types.d.mts} +6 -6
- package/dist/shared/commands.types.d.mts.map +1 -0
- package/dist/shared/compare_image.mjs +46 -0
- package/dist/shared/compare_image.mjs.map +1 -0
- package/dist/shared/constants.d.mts +9 -0
- package/dist/shared/constants.d.mts.map +1 -0
- package/dist/{constants-CTBaz8Ml.mjs → shared/constants.mjs} +2 -2
- package/dist/shared/constants.mjs.map +1 -0
- package/dist/shared/convert_threshold_unit.mjs +12 -0
- package/dist/shared/convert_threshold_unit.mjs.map +1 -0
- package/dist/shared/get_max_size.mjs +11 -0
- package/dist/shared/get_max_size.mjs.map +1 -0
- package/dist/shared/is_same_size.mjs +8 -0
- package/dist/shared/is_same_size.mjs.map +1 -0
- package/dist/{trim_common_folder-DBThLerp.d.mts → shared/trim_common_folder.d.mts} +2 -2
- package/dist/shared/trim_common_folder.d.mts.map +1 -0
- package/dist/shared/trim_common_folder.mjs +23 -0
- package/dist/shared/trim_common_folder.mjs.map +1 -0
- package/dist/{types-CEmjj-A9.d.mts → shared/types.d.mts} +6 -21
- package/dist/shared/types.d.mts.map +1 -0
- package/dist/testing/constants.d.mts +12 -0
- package/dist/testing/constants.d.mts.map +1 -0
- package/dist/testing/constants.mjs +65550 -0
- package/dist/{testing.mjs.map → testing/constants.mjs.map} +1 -1
- package/dist/testing.d.mts +2 -12
- package/dist/testing.mjs +2 -65549
- package/package.json +24 -17
- package/readme.md +48 -3
- package/src/{client/task → auto_snapshots}/_ctx.ts +1 -1
- package/src/auto_snapshots/_extract_auto_snapshot_options.ts +26 -0
- package/src/{client/task → auto_snapshots}/auto_snapshot_options.mdx +1 -2
- package/src/{client/task → auto_snapshots}/auto_snapshot_options.ts +3 -25
- package/src/{client/task → auto_snapshots}/snapshot_meta.ts +1 -1
- package/src/client/actions/match_image_snapshot_action.ts +0 -2
- package/src/client/snapshot/compare_image_snapshot.logic.ts +1 -1
- package/src/client/snapshot/compare_image_snapshot.ts +15 -1
- package/src/client/snapshot/should_take_snapshot.ts +1 -1
- package/src/client/suite/auto_snapshot_matcher.ts +2 -3
- package/src/client-api.ts +1 -1
- package/src/config/overview.mdx +145 -0
- package/src/{shared → config}/trim_common_folder.mdx +1 -1
- package/src/config/types.ts +5 -6
- package/src/config/vis.mdx +313 -0
- package/src/index.ts +1 -1
- package/src/overview.mdx +66 -28
- package/src/server/commands/prepare_image_snapshot_comparison.ts +8 -8
- package/src/server/commands/prepare_page_image_snapshot_comparison.ts +1 -6
- package/src/server/snapshot_path.ts +3 -1
- package/src/{setup.create_vis.mdx → setup/create_vis.mdx} +4 -5
- package/src/setup/create_vis.ts +12 -7
- package/src/setup/overview.mdx +17 -0
- package/src/setup/readme.md +3 -1
- package/src/{setup.vis.mdx → setup/vis.mdx} +15 -18
- package/src/setup-api.ts +5 -0
- package/src/setup.ts +8 -4
- package/src/shared/commands.types.ts +2 -2
- package/src/shared/types.ts +3 -2
- package/dist/asserts--HSSlgPD.mjs.map +0 -1
- package/dist/augment-C1tjdh5B.d.mts +0 -33
- package/dist/augment-C1tjdh5B.d.mts.map +0 -1
- package/dist/auto_snapshot_matcher-C0y6mAeS.mjs +0 -381
- package/dist/auto_snapshot_matcher-C0y6mAeS.mjs.map +0 -1
- package/dist/auto_snapshot_options-BMRtKmod.d.mts.map +0 -1
- package/dist/auto_snapshot_options-DUOTpF2N.mjs.map +0 -1
- package/dist/base64-CHSENEAO.mjs.map +0 -1
- package/dist/client-api.d.mts.map +0 -1
- package/dist/client-api.mjs.map +0 -1
- package/dist/commands.types-BVhcnnHw.d.mts.map +0 -1
- package/dist/config.d.mts.map +0 -1
- package/dist/config.mjs.map +0 -1
- package/dist/constants-CTBaz8Ml.mjs.map +0 -1
- package/dist/server-utils.d.mts.map +0 -1
- package/dist/setup-DCytWz48.mjs +0 -124
- package/dist/setup-DCytWz48.mjs.map +0 -1
- package/dist/snapshot_path-7GliOSH_.mjs.map +0 -1
- package/dist/src-CSQnlFa9.mjs +0 -1
- package/dist/testing.d.mts.map +0 -1
- package/dist/to_match_image_snapshot.types--tTmHoRA.d.mts.map +0 -1
- package/dist/trim_common_folder-DBThLerp.d.mts.map +0 -1
- package/dist/types-CEmjj-A9.d.mts.map +0 -1
- package/dist/types-DJYCbyT8.d.mts.map +0 -1
- package/src/config.vis.mdx +0 -76
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vis_server_context.logic.mjs","names":["r"],"sources":["../../src/server/vis_server_context.logic.ts"],"sourcesContent":["import { basename, join, resolve } from 'pathe'\nimport { pick } from 'type-plus'\nimport type { ImageSnapshotKeyOptions } from '../client-api.ts'\nimport type { ImageSnapshotResult } from '../shared/commands.types.ts'\nimport { file } from './externals/file.ts'\nimport { getSuite, getTaskSubpath } from './suite.ts'\nimport { getVisOption } from './vis_options.ts'\nimport type { ExtendedBrowserCommandContext } from './vis_server_context.types.ts'\n\nexport function createVisServerContext() {\n\tconst context = {\n\t\tasync getSnapshotResults(browserContext: ExtendedBrowserCommandContext, taskId: string) {\n\t\t\tconst suiteInfo = await context.getSuiteInfo(browserContext, taskId)\n\t\t\tconst baselines = await file.glob(join(suiteInfo.projectRoot, suiteInfo.baselineDir, `${suiteInfo.taskId}-*.png`))\n\t\t\tconst results = await file.glob(join(suiteInfo.projectRoot, suiteInfo.resultDir, `${suiteInfo.taskId}-*.png`))\n\t\t\tconst diffs = await file.glob(join(suiteInfo.projectRoot, suiteInfo.diffDir, `${suiteInfo.taskId}-*.png`))\n\n\t\t\tconst r: ImageSnapshotResult[] = []\n\t\t\tawait Promise.all(\n\t\t\t\tbaselines.map(async (baselinePath) => {\n\t\t\t\t\tconst filename = basename(baselinePath)\n\t\t\t\t\tconst resultPath = results.find((r) => r.endsWith(filename))\n\t\t\t\t\tconst diffPath = diffs.find((d) => d.endsWith(filename))\n\n\t\t\t\t\tconst baselineBuffer = await file.tryReadFile(baselinePath)\n\t\t\t\t\tconst resultBuffer = await file.tryReadFile(resultPath)\n\t\t\t\t\tconst diffBuffer = await file.tryReadFile(diffPath)\n\t\t\t\t\tr.push({\n\t\t\t\t\t\tfilename,\n\t\t\t\t\t\tbaseline: baselineBuffer?.toString('base64'),\n\t\t\t\t\t\tresult: resultBuffer?.toString('base64'),\n\t\t\t\t\t\tdiff: diffBuffer?.toString('base64'),\n\t\t\t\t\t})\n\t\t\t\t}),\n\t\t\t)\n\t\t\treturn r\n\t\t},\n\t\tasync getSnapshotInfo(\n\t\t\tbrowserContext: ExtendedBrowserCommandContext,\n\t\t\ttaskId: string,\n\t\t\toptions?: ImageSnapshotKeyOptions,\n\t\t) {\n\t\t\tconst suiteInfo = await context.getSuiteInfo(browserContext, taskId)\n\t\t\tconst snapshotFilename = context.getSnapshotFilename(browserContext, suiteInfo, options?.snapshotKey)\n\n\t\t\tconst { baselineDir, resultDir, diffDir, task } = suiteInfo\n\n\t\t\ttask.count = task.count + 1\n\t\t\tconst baselinePath = join(baselineDir, snapshotFilename)\n\t\t\tconst resultPath = join(resultDir, snapshotFilename)\n\t\t\tconst diffPath = join(diffDir, snapshotFilename)\n\n\t\t\treturn {\n\t\t\t\t...pick(\n\t\t\t\t\tgetVisOption(browserContext),\n\t\t\t\t\t'comparisonMethod',\n\t\t\t\t\t'diffOptions',\n\t\t\t\t\t'failureThreshold',\n\t\t\t\t\t'failureThresholdType',\n\t\t\t\t\t'timeout',\n\t\t\t\t),\n\t\t\t\tbaselinePath,\n\t\t\t\tresultPath,\n\t\t\t\tdiffPath,\n\t\t\t}\n\t\t},\n\n\t\tasync getTaskCount(browserContext: ExtendedBrowserCommandContext, taskId: string) {\n\t\t\treturn (await context.getSuiteInfo(browserContext, taskId)).task.count\n\t\t},\n\t\tasync hasImageSnapshot(\n\t\t\tbrowserContext: ExtendedBrowserCommandContext,\n\t\t\ttaskId: string,\n\t\t\tsnapshotKey: string | undefined,\n\t\t) {\n\t\t\tconst info = await context.getSuiteInfo(browserContext, taskId)\n\n\t\t\treturn file.existFile(\n\t\t\t\tresolve(info.projectRoot, info.baselineDir, context.getSnapshotFilename(browserContext, info, snapshotKey)),\n\t\t\t)\n\t\t},\n\t\tgetSnapshotFilename(\n\t\t\tbrowserContext: ExtendedBrowserCommandContext,\n\t\t\tinfo: { taskId: string; task: { count: number } },\n\t\t\tsnapshotKey: string | undefined,\n\t\t) {\n\t\t\tif (snapshotKey) return `${info.taskId}-${snapshotKey}.png`\n\t\t\tconst visOptions = getVisOption(browserContext)\n\t\t\tif (typeof visOptions.snapshotKey === 'string') {\n\t\t\t\treturn `${info.taskId}-${visOptions.snapshotKey}.png`\n\t\t\t}\n\t\t\treturn `${info.taskId}-${info.task.count}.png`\n\t\t},\n\t\tasync getSuiteInfo(browserContext: ExtendedBrowserCommandContext, taskId: string) {\n\t\t\tconst projectState = await getSuite(browserContext)\n\t\t\tconst visOptions = getVisOption(browserContext)\n\t\t\tconst moduleId = getTaskSubpath(projectState, browserContext.testPath, visOptions)\n\t\t\tconst m = projectState.modules[moduleId]!\n\t\t\tconst task = (m.tasks[taskId] = m.tasks[taskId] ?? { count: 1 })\n\t\t\treturn {\n\t\t\t\tprojectRoot: projectState.projectRoot,\n\t\t\t\tsuiteId: moduleId,\n\t\t\t\ttaskId,\n\t\t\t\tbaselineDir: m.baselineDir,\n\t\t\t\tresultDir: m.resultDir,\n\t\t\t\tdiffDir: m.diffDir,\n\t\t\t\ttask,\n\t\t\t}\n\t\t},\n\t}\n\treturn context\n}\n"],"mappings":";;;;;;;AASA,SAAgB,yBAAyB;CACxC,MAAM,UAAU;EACf,MAAM,mBAAmB,gBAA+C,QAAgB;GACvF,MAAM,YAAY,MAAM,QAAQ,aAAa,gBAAgB,OAAO;GACpE,MAAM,YAAY,MAAM,KAAK,KAAK,KAAK,UAAU,aAAa,UAAU,aAAa,GAAG,UAAU,OAAO,QAAQ,CAAC;GAClH,MAAM,UAAU,MAAM,KAAK,KAAK,KAAK,UAAU,aAAa,UAAU,WAAW,GAAG,UAAU,OAAO,QAAQ,CAAC;GAC9G,MAAM,QAAQ,MAAM,KAAK,KAAK,KAAK,UAAU,aAAa,UAAU,SAAS,GAAG,UAAU,OAAO,QAAQ,CAAC;GAE1G,MAAM,IAA2B,EAAE;AACnC,SAAM,QAAQ,IACb,UAAU,IAAI,OAAO,iBAAiB;IACrC,MAAM,WAAW,SAAS,aAAa;IACvC,MAAM,aAAa,QAAQ,MAAM,QAAMA,IAAE,SAAS,SAAS,CAAC;IAC5D,MAAM,WAAW,MAAM,MAAM,MAAM,EAAE,SAAS,SAAS,CAAC;IAExD,MAAM,iBAAiB,MAAM,KAAK,YAAY,aAAa;IAC3D,MAAM,eAAe,MAAM,KAAK,YAAY,WAAW;IACvD,MAAM,aAAa,MAAM,KAAK,YAAY,SAAS;AACnD,MAAE,KAAK;KACN;KACA,UAAU,gBAAgB,SAAS,SAAS;KAC5C,QAAQ,cAAc,SAAS,SAAS;KACxC,MAAM,YAAY,SAAS,SAAS;KACpC,CAAC;KACD,CACF;AACD,UAAO;;EAER,MAAM,gBACL,gBACA,QACA,SACC;GACD,MAAM,YAAY,MAAM,QAAQ,aAAa,gBAAgB,OAAO;GACpE,MAAM,mBAAmB,QAAQ,oBAAoB,gBAAgB,WAAW,SAAS,YAAY;GAErG,MAAM,EAAE,aAAa,WAAW,SAAS,SAAS;AAElD,QAAK,QAAQ,KAAK,QAAQ;GAC1B,MAAM,eAAe,KAAK,aAAa,iBAAiB;GACxD,MAAM,aAAa,KAAK,WAAW,iBAAiB;GACpD,MAAM,WAAW,KAAK,SAAS,iBAAiB;AAEhD,UAAO;IACN,GAAG,KACF,aAAa,eAAe,EAC5B,oBACA,eACA,oBACA,wBACA,UACA;IACD;IACA;IACA;IACA;;EAGF,MAAM,aAAa,gBAA+C,QAAgB;AACjF,WAAQ,MAAM,QAAQ,aAAa,gBAAgB,OAAO,EAAE,KAAK;;EAElE,MAAM,iBACL,gBACA,QACA,aACC;GACD,MAAM,OAAO,MAAM,QAAQ,aAAa,gBAAgB,OAAO;AAE/D,UAAO,KAAK,UACX,QAAQ,KAAK,aAAa,KAAK,aAAa,QAAQ,oBAAoB,gBAAgB,MAAM,YAAY,CAAC,CAC3G;;EAEF,oBACC,gBACA,MACA,aACC;AACD,OAAI,YAAa,QAAO,GAAG,KAAK,OAAO,GAAG,YAAY;GACtD,MAAM,aAAa,aAAa,eAAe;AAC/C,OAAI,OAAO,WAAW,gBAAgB,SACrC,QAAO,GAAG,KAAK,OAAO,GAAG,WAAW,YAAY;AAEjD,UAAO,GAAG,KAAK,OAAO,GAAG,KAAK,KAAK,MAAM;;EAE1C,MAAM,aAAa,gBAA+C,QAAgB;GACjF,MAAM,eAAe,MAAM,SAAS,eAAe;GACnD,MAAM,aAAa,aAAa,eAAe;GAC/C,MAAM,WAAW,eAAe,cAAc,eAAe,UAAU,WAAW;GAClF,MAAM,IAAI,aAAa,QAAQ;GAC/B,MAAM,OAAQ,EAAE,MAAM,UAAU,EAAE,MAAM,WAAW,EAAE,OAAO,GAAG;AAC/D,UAAO;IACN,aAAa,aAAa;IAC1B,SAAS;IACT;IACA,aAAa,EAAE;IACf,WAAW,EAAE;IACb,SAAS,EAAE;IACX;IACA;;EAEF;AACD,QAAO"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createVisServerContext } from "./vis_server_context.logic.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/server/vis_server_context.ts
|
|
4
|
+
const visServerContext = createVisServerContext();
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { visServerContext };
|
|
8
|
+
//# sourceMappingURL=vis_server_context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vis_server_context.mjs","names":[],"sources":["../../src/server/vis_server_context.ts"],"sourcesContent":["import { createVisServerContext } from './vis_server_context.logic.ts'\n\nexport const visServerContext = createVisServerContext()\n"],"mappings":";;;AAEA,MAAa,mBAAmB,wBAAwB"}
|
package/dist/server-utils.d.mts
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//#region src/server/snapshot_path.d.ts
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Gets the root directory for storing snapshots.
|
|
10
|
-
*
|
|
11
|
-
* @param snapshotRootDir - Base directory for snapshots. Defaults to `__vis__`.
|
|
12
|
-
* @returns The full snapshot root directory path, which includes a platform-specific subdirectory:
|
|
13
|
-
* - When running in CI: `<snapshotRootDir>/<platform>` (e.g. `__vis__/linux`)
|
|
14
|
-
* - When running locally: `<snapshotRootDir>/local`
|
|
15
|
-
*/
|
|
16
|
-
declare function getSnapshotRootDir(snapshotRootDir?: string): string;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { BASELINE_DIR, DIFF_DIR, NAME, RESULT_DIR, SNAPSHOT_ROOT_DIR, getSnapshotRootDir, trimCommonFolder };
|
|
19
|
-
//# sourceMappingURL=server-utils.d.mts.map
|
|
1
|
+
import { BASELINE_DIR, DIFF_DIR, NAME, RESULT_DIR, SNAPSHOT_ROOT_DIR } from "./shared/constants.mjs";
|
|
2
|
+
import { trimCommonFolder } from "./shared/trim_common_folder.mjs";
|
|
3
|
+
import { getSnapshotRootDir } from "./server/snapshot_path.mjs";
|
|
4
|
+
export { BASELINE_DIR, DIFF_DIR, NAME, RESULT_DIR, SNAPSHOT_ROOT_DIR, getSnapshotRootDir, trimCommonFolder };
|
package/dist/server-utils.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BASELINE_DIR, DIFF_DIR, NAME, RESULT_DIR, SNAPSHOT_ROOT_DIR } from "./shared/constants.mjs";
|
|
2
|
+
import { trimCommonFolder } from "./shared/trim_common_folder.mjs";
|
|
3
|
+
import { getSnapshotRootDir } from "./server/snapshot_path.mjs";
|
|
3
4
|
|
|
4
5
|
export { BASELINE_DIR, DIFF_DIR, NAME, RESULT_DIR, SNAPSHOT_ROOT_DIR, getSnapshotRootDir, trimCommonFolder };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { SnapshotMeta } from "../auto_snapshots/snapshot_meta.mjs";
|
|
2
|
+
import { ComparisonMethod, SetupVisOptions } from "../shared/types.mjs";
|
|
3
|
+
import { SetupVisSuiteCommand } from "../shared/commands.types.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/setup/create_vis.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Visual test configuration on the client side.
|
|
9
|
+
*/
|
|
10
|
+
type VisClientConfigurator<GM extends Record<string, any> | unknown = unknown> = {
|
|
11
|
+
/**
|
|
12
|
+
* Setup the visual test configuration.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* // Setup with auto snapshot enabled
|
|
17
|
+
* vis().setup({ auto: true })
|
|
18
|
+
*
|
|
19
|
+
* // Setup with auto snapshot disabled
|
|
20
|
+
* vis().setup({ auto: false })
|
|
21
|
+
*
|
|
22
|
+
* // Same as `vis.setup({ auto: false })`
|
|
23
|
+
* vis.setup()
|
|
24
|
+
*
|
|
25
|
+
* // Setup with auto snapshot determined by the test meta
|
|
26
|
+
* vis.setup({
|
|
27
|
+
* auto: async ({ meta }) => meta['darkOnly'],
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* // Setup with multiple auto snapshots
|
|
31
|
+
* vis.setup({
|
|
32
|
+
* auto: {
|
|
33
|
+
* async light() { document.body.classList.remove('dark') },
|
|
34
|
+
* async dark() { document.body.classList.add('dark') },
|
|
35
|
+
* }
|
|
36
|
+
* })
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
setup(options?: SetupVisOptions<GM>): void;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Use `vis.setup()` instead.
|
|
42
|
+
*/
|
|
43
|
+
presets: {
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use `vis.setup()` instead.
|
|
46
|
+
*
|
|
47
|
+
* Enable visual testing.
|
|
48
|
+
*
|
|
49
|
+
* auto snapshot is turned off by default.
|
|
50
|
+
* You can specify the test to take a snapshot during `afterEach()` hook with `setAutoSnapshotOptions()`.
|
|
51
|
+
*/
|
|
52
|
+
enable(): void;
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated Use `vis.setup()` instead.
|
|
55
|
+
*
|
|
56
|
+
* Enable visual testing.
|
|
57
|
+
*
|
|
58
|
+
* `setAutoSnapshotOptions` will have no effect in this preset.
|
|
59
|
+
*/
|
|
60
|
+
manual(): void;
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Use `vis.setup()` instead.
|
|
63
|
+
*
|
|
64
|
+
* Enable automatic visual testing.
|
|
65
|
+
*
|
|
66
|
+
* This will take a snapshot after each test.
|
|
67
|
+
*/
|
|
68
|
+
auto(): void;
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Use `vis.setup()` instead.
|
|
71
|
+
*
|
|
72
|
+
* Enable automatic visual testing with multiple themes.
|
|
73
|
+
*
|
|
74
|
+
* This will take a snapshot after each test for each theme.
|
|
75
|
+
*
|
|
76
|
+
* @param themes A record of theme names and their setup functions.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* vis().presets.theme({
|
|
81
|
+
* light() { document.body.classList.add('light') },
|
|
82
|
+
* dark() { document.body.classList.add('dark') },
|
|
83
|
+
* })
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
theme<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(themes: Record<string, boolean | ((options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)>): void;
|
|
87
|
+
};
|
|
88
|
+
beforeAll: {
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated No known use case.
|
|
91
|
+
*/
|
|
92
|
+
setup(): Promise<void>;
|
|
93
|
+
};
|
|
94
|
+
afterEach: {
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated No known use case.
|
|
97
|
+
*/
|
|
98
|
+
matchImageSnapshot(): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated No known use case.
|
|
101
|
+
*/
|
|
102
|
+
matchPerTheme<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(themes: Record<string, boolean | ((options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)>): () => Promise<void>;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
declare function createVis<GM extends Record<string, any> | unknown = unknown>(commands: SetupVisSuiteCommand): VisClientConfigurator<GM>;
|
|
106
|
+
//#endregion
|
|
107
|
+
export { VisClientConfigurator, createVis };
|
|
108
|
+
//# sourceMappingURL=create_vis.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create_vis.d.mts","names":[],"sources":["../../src/setup/create_vis.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAUA;AAA6C,KAAjC,qBAAiC,CAAA,WAAA,MAAA,CAAA,MAAA,EAAA,GAAA,CAAA,GAAA,OAAA,GAAA,OAAA,CAAA,GAAA;EA6BZ;;;;;;;;;;;;;;;;;;;;;;;;AA6EjC;;;;EAA4G,KAAA,CAAA,OAAA,CAAA,EA7E3F,eA6E2F,CA7E3E,EA6E2E,CAAA,CAAA,EAAA,IAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA9B1F,4BAA4B,iDACnC,oCAEc,aAAa,KAAK,IAAI,OAAO,mBAAmB;;;;;;aAQ9D;;;;;;0BAMa;;;;4BAIE,4BAA4B,iDAC3C,oCAEc,aAAa,KAAK,IAAI,OAAO,mBAAmB,yCAE9D;;;iBAIK,qBAAqB,mDAAmD,uBAAoB,sBAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { setAutoSnapshotOptions } from "../auto_snapshots/auto_snapshot_options.mjs";
|
|
2
|
+
import { autoSnapshotMatcher } from "../client/suite/auto_snapshot_matcher.mjs";
|
|
3
|
+
import { afterEach, beforeAll, expect } from "vitest";
|
|
4
|
+
|
|
5
|
+
//#region src/setup/create_vis.ts
|
|
6
|
+
function createVis(commands) {
|
|
7
|
+
const matcher = autoSnapshotMatcher(commands, expect);
|
|
8
|
+
return {
|
|
9
|
+
setup(options) {
|
|
10
|
+
if (!options || options.auto === false) beforeAll(matcher.setup);
|
|
11
|
+
else beforeAll(async () => {
|
|
12
|
+
await matcher.setup();
|
|
13
|
+
setAutoSnapshotOptions(true);
|
|
14
|
+
});
|
|
15
|
+
if (typeof options?.auto === "function") afterEach(matcher.createMatcher({ auto: options.auto }));
|
|
16
|
+
else if (typeof options?.auto === "object") afterEach(matcher.createMatcher(options.auto));
|
|
17
|
+
else afterEach(matcher.createMatcher({ async auto() {} }));
|
|
18
|
+
},
|
|
19
|
+
presets: {
|
|
20
|
+
enable() {
|
|
21
|
+
beforeAll(matcher.setup);
|
|
22
|
+
afterEach(matcher.createMatcher({ async auto() {} }));
|
|
23
|
+
},
|
|
24
|
+
manual() {
|
|
25
|
+
beforeAll(matcher.setup);
|
|
26
|
+
},
|
|
27
|
+
auto() {
|
|
28
|
+
beforeAll(async () => {
|
|
29
|
+
await matcher.setup();
|
|
30
|
+
setAutoSnapshotOptions(true);
|
|
31
|
+
});
|
|
32
|
+
afterEach(matcher.createMatcher({ async auto() {} }));
|
|
33
|
+
},
|
|
34
|
+
theme(themes) {
|
|
35
|
+
beforeAll(async () => {
|
|
36
|
+
await matcher.setup();
|
|
37
|
+
setAutoSnapshotOptions(true);
|
|
38
|
+
});
|
|
39
|
+
afterEach(matcher.createMatcher(themes));
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
beforeAll: { async setup() {
|
|
43
|
+
await matcher.setup();
|
|
44
|
+
} },
|
|
45
|
+
afterEach: {
|
|
46
|
+
async matchImageSnapshot() {
|
|
47
|
+
return matcher.createMatcher({ async auto() {} })();
|
|
48
|
+
},
|
|
49
|
+
matchPerTheme(themes) {
|
|
50
|
+
return matcher.createMatcher(themes);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { createVis };
|
|
58
|
+
//# sourceMappingURL=create_vis.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create_vis.mjs","names":[],"sources":["../../src/setup/create_vis.ts"],"sourcesContent":["import { afterEach, beforeAll, expect } from 'vitest'\nimport { setAutoSnapshotOptions } from '../auto_snapshots/auto_snapshot_options.ts'\nimport type { SnapshotMeta } from '../auto_snapshots/snapshot_meta.ts'\nimport { autoSnapshotMatcher } from '../client/suite/auto_snapshot_matcher.ts'\nimport type { SetupVisSuiteCommand } from '../shared/commands.types.ts'\nimport type { ComparisonMethod, SetupVisOptions } from '../shared/types.ts'\n\n/**\n * Visual test configuration on the client side.\n */\nexport type VisClientConfigurator<GM extends Record<string, any> | unknown = unknown> = {\n\t/**\n\t * Setup the visual test configuration.\n\t *\n\t * @example\n\t * ```ts\n\t * // Setup with auto snapshot enabled\n\t * vis().setup({ auto: true })\n\t *\n\t * // Setup with auto snapshot disabled\n\t * vis().setup({ auto: false })\n\t *\n\t * // Same as `vis.setup({ auto: false })`\n\t * vis.setup()\n\t *\n\t * // Setup with auto snapshot determined by the test meta\n\t * vis.setup({\n\t * \tauto: async ({ meta }) => meta['darkOnly'],\n\t * })\n\t *\n\t * // Setup with multiple auto snapshots\n\t * vis.setup({\n\t * auto: {\n\t * async light() { document.body.classList.remove('dark') },\n\t * async dark() { document.body.classList.add('dark') },\n\t * }\n\t * })\n\t * ```\n\t */\n\tsetup(options?: SetupVisOptions<GM>): void\n\t/**\n\t * @deprecated Use `vis.setup()` instead.\n\t */\n\tpresets: {\n\t\t/**\n\t\t * @deprecated Use `vis.setup()` instead.\n\t\t *\n\t\t * Enable visual testing.\n\t\t *\n\t\t * auto snapshot is turned off by default.\n\t\t * You can specify the test to take a snapshot during `afterEach()` hook with `setAutoSnapshotOptions()`.\n\t\t */\n\t\tenable(): void\n\t\t/**\n\t\t * @deprecated Use `vis.setup()` instead.\n\t\t *\n\t\t * Enable visual testing.\n\t\t *\n\t\t * `setAutoSnapshotOptions` will have no effect in this preset.\n\t\t */\n\t\tmanual(): void\n\t\t/**\n\t\t * @deprecated Use `vis.setup()` instead.\n\t\t *\n\t\t * Enable automatic visual testing.\n\t\t *\n\t\t * This will take a snapshot after each test.\n\t\t */\n\t\tauto(): void\n\t\t/**\n\t\t * @deprecated Use `vis.setup()` instead.\n\t\t *\n\t\t * Enable automatic visual testing with multiple themes.\n\t\t *\n\t\t * This will take a snapshot after each test for each theme.\n\t\t *\n\t\t * @param themes A record of theme names and their setup functions.\n\t\t *\n\t\t * @example\n\t\t * ```ts\n\t\t * vis().presets.theme({\n\t\t * light() { document.body.classList.add('light') },\n\t\t * dark() { document.body.classList.add('dark') },\n\t\t * })\n\t\t * ```\n\t\t */\n\t\ttheme<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(\n\t\t\tthemes: Record<\n\t\t\t\tstring,\n\t\t\t\tboolean | ((options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)\n\t\t\t>,\n\t\t): void\n\t}\n\tbeforeAll: {\n\t\t/**\n\t\t * @deprecated No known use case.\n\t\t */\n\t\tsetup(): Promise<void>\n\t}\n\tafterEach: {\n\t\t/**\n\t\t * @deprecated No known use case.\n\t\t */\n\t\tmatchImageSnapshot(): Promise<void>\n\t\t/**\n\t\t * @deprecated No known use case.\n\t\t */\n\t\tmatchPerTheme<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(\n\t\t\tthemes: Record<\n\t\t\t\tstring,\n\t\t\t\tboolean | ((options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)\n\t\t\t>,\n\t\t): () => Promise<void>\n\t}\n}\n\nexport function createVis<GM extends Record<string, any> | unknown = unknown>(commands: SetupVisSuiteCommand) {\n\tconst matcher = autoSnapshotMatcher(commands, expect)\n\n\tconst vis: VisClientConfigurator<GM> = {\n\t\tsetup(options) {\n\t\t\tif (!options || options.auto === false) {\n\t\t\t\tbeforeAll(matcher.setup)\n\t\t\t} else {\n\t\t\t\tbeforeAll(async () => {\n\t\t\t\t\tawait matcher.setup()\n\t\t\t\t\tsetAutoSnapshotOptions(true)\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (typeof options?.auto === 'function') {\n\t\t\t\tafterEach(matcher.createMatcher({ auto: options.auto }))\n\t\t\t} else if (typeof options?.auto === 'object') {\n\t\t\t\tafterEach(matcher.createMatcher(options.auto))\n\t\t\t} else {\n\t\t\t\tafterEach(matcher.createMatcher({ async auto() {} }))\n\t\t\t}\n\t\t},\n\t\tpresets: {\n\t\t\tenable() {\n\t\t\t\tbeforeAll(matcher.setup)\n\t\t\t\tafterEach(matcher.createMatcher({ async auto() {} }))\n\t\t\t},\n\t\t\tmanual() {\n\t\t\t\tbeforeAll(matcher.setup)\n\t\t\t},\n\t\t\tauto() {\n\t\t\t\tbeforeAll(async () => {\n\t\t\t\t\tawait matcher.setup()\n\t\t\t\t\tsetAutoSnapshotOptions(true)\n\t\t\t\t})\n\t\t\t\tafterEach(matcher.createMatcher({ async auto() {} }))\n\t\t\t},\n\t\t\ttheme(themes) {\n\t\t\t\tbeforeAll(async () => {\n\t\t\t\t\tawait matcher.setup()\n\t\t\t\t\tsetAutoSnapshotOptions(true)\n\t\t\t\t})\n\t\t\t\tafterEach(matcher.createMatcher(themes))\n\t\t\t},\n\t\t},\n\t\tbeforeAll: {\n\t\t\tasync setup() {\n\t\t\t\tawait matcher.setup()\n\t\t\t},\n\t\t},\n\t\tafterEach: {\n\t\t\tasync matchImageSnapshot() {\n\t\t\t\treturn matcher.createMatcher({ async auto() {} })()\n\t\t\t},\n\t\t\tmatchPerTheme(themes) {\n\t\t\t\treturn matcher.createMatcher(themes)\n\t\t\t},\n\t\t},\n\t}\n\treturn vis\n}\n"],"mappings":";;;;;AAoHA,SAAgB,UAA8D,UAAgC;CAC7G,MAAM,UAAU,oBAAoB,UAAU,OAAO;AA0DrD,QAxDuC;EACtC,MAAM,SAAS;AACd,OAAI,CAAC,WAAW,QAAQ,SAAS,MAChC,WAAU,QAAQ,MAAM;OAExB,WAAU,YAAY;AACrB,UAAM,QAAQ,OAAO;AACrB,2BAAuB,KAAK;KAC3B;AAGH,OAAI,OAAO,SAAS,SAAS,WAC5B,WAAU,QAAQ,cAAc,EAAE,MAAM,QAAQ,MAAM,CAAC,CAAC;YAC9C,OAAO,SAAS,SAAS,SACnC,WAAU,QAAQ,cAAc,QAAQ,KAAK,CAAC;OAE9C,WAAU,QAAQ,cAAc,EAAE,MAAM,OAAO,IAAI,CAAC,CAAC;;EAGvD,SAAS;GACR,SAAS;AACR,cAAU,QAAQ,MAAM;AACxB,cAAU,QAAQ,cAAc,EAAE,MAAM,OAAO,IAAI,CAAC,CAAC;;GAEtD,SAAS;AACR,cAAU,QAAQ,MAAM;;GAEzB,OAAO;AACN,cAAU,YAAY;AACrB,WAAM,QAAQ,OAAO;AACrB,4BAAuB,KAAK;MAC3B;AACF,cAAU,QAAQ,cAAc,EAAE,MAAM,OAAO,IAAI,CAAC,CAAC;;GAEtD,MAAM,QAAQ;AACb,cAAU,YAAY;AACrB,WAAM,QAAQ,OAAO;AACrB,4BAAuB,KAAK;MAC3B;AACF,cAAU,QAAQ,cAAc,OAAO,CAAC;;GAEzC;EACD,WAAW,EACV,MAAM,QAAQ;AACb,SAAM,QAAQ,OAAO;KAEtB;EACD,WAAW;GACV,MAAM,qBAAqB;AAC1B,WAAO,QAAQ,cAAc,EAAE,MAAM,OAAO,IAAI,CAAC,EAAE;;GAEpD,cAAc,QAAQ;AACrB,WAAO,QAAQ,cAAc,OAAO;;GAErC;EACD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { VisClientConfigurator } from "./create_vis.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/setup/vis.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Visual test configuration on the client side.
|
|
6
|
+
*/
|
|
7
|
+
declare const vis: VisClientConfigurator<unknown>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { vis };
|
|
10
|
+
//# sourceMappingURL=vis.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vis.d.mts","names":[],"sources":["../../src/setup/vis.ts"],"sourcesContent":[],"mappings":";;;;;;AAMa,cAAA,GAAyB,EAAA,qBAAtB,CAAA,OAAA,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createVis } from "./create_vis.mjs";
|
|
2
|
+
import { commands } from "vitest/browser";
|
|
3
|
+
|
|
4
|
+
//#region src/setup/vis.ts
|
|
5
|
+
/**
|
|
6
|
+
* Visual test configuration on the client side.
|
|
7
|
+
*/
|
|
8
|
+
const vis = createVis(commands);
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { vis };
|
|
12
|
+
//# sourceMappingURL=vis.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vis.mjs","names":[],"sources":["../../src/setup/vis.ts"],"sourcesContent":["import { commands } from 'vitest/browser'\nimport { createVis } from './create_vis.ts'\n\n/**\n * Visual test configuration on the client side.\n */\nexport const vis = createVis(commands)\n"],"mappings":";;;;;;;AAMA,MAAa,MAAM,UAAU,SAAS"}
|
package/dist/setup.d.mts
CHANGED
|
@@ -1,106 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { createVis as createVis$1 } from "./setup/create_vis.mjs";
|
|
2
|
+
import "./setup-api.mjs";
|
|
3
|
+
import { vis } from "./setup/vis.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/setup.d.ts
|
|
6
6
|
|
|
7
|
-
//#region src/setup/create_vis.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Visual test configuration on the client side.
|
|
10
|
-
*/
|
|
11
|
-
type VisClientConfigurator<GM extends Record<string, any> | unknown = unknown> = {
|
|
12
|
-
/**
|
|
13
|
-
* Setup the visual test configuration.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* // Setup with auto snapshot enabled
|
|
18
|
-
* vis().setup({ auto: true })
|
|
19
|
-
*
|
|
20
|
-
* // Setup with auto snapshot disabled
|
|
21
|
-
* vis().setup({ auto: false })
|
|
22
|
-
*
|
|
23
|
-
* // Same as `vis.setup({ auto: false })`
|
|
24
|
-
* vis.setup()
|
|
25
|
-
*
|
|
26
|
-
* // Setup with auto snapshot determined by the test meta
|
|
27
|
-
* vis.setup({
|
|
28
|
-
* auto: async ({ meta }) => meta['darkOnly'],
|
|
29
|
-
* })
|
|
30
|
-
*
|
|
31
|
-
* // Setup with multiple auto snapshots
|
|
32
|
-
* vis.setup({
|
|
33
|
-
* auto: {
|
|
34
|
-
* async light() { document.body.classList.remove('dark') },
|
|
35
|
-
* async dark() { document.body.classList.add('dark') },
|
|
36
|
-
* }
|
|
37
|
-
* })
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
setup(options?: SetupVisOptions<GM>): void;
|
|
41
|
-
/**
|
|
42
|
-
* @deprecated Use `vis.setup()` instead.
|
|
43
|
-
*/
|
|
44
|
-
presets: {
|
|
45
|
-
/**
|
|
46
|
-
* @deprecated Use `vis.setup()` instead.
|
|
47
|
-
*
|
|
48
|
-
* Enable visual testing.
|
|
49
|
-
*
|
|
50
|
-
* auto snapshot is turned off by default.
|
|
51
|
-
* You can specify the test to take a snapshot during `afterEach()` hook with `setAutoSnapshotOptions()`.
|
|
52
|
-
*/
|
|
53
|
-
enable(): void;
|
|
54
|
-
/**
|
|
55
|
-
* @deprecated Use `vis.setup()` instead.
|
|
56
|
-
*
|
|
57
|
-
* Enable visual testing.
|
|
58
|
-
*
|
|
59
|
-
* `setAutoSnapshotOptions` will have no effect in this preset.
|
|
60
|
-
*/
|
|
61
|
-
manual(): void;
|
|
62
|
-
/**
|
|
63
|
-
* @deprecated Use `vis.setup()` instead.
|
|
64
|
-
*
|
|
65
|
-
* Enable automatic visual testing.
|
|
66
|
-
*
|
|
67
|
-
* This will take a snapshot after each test.
|
|
68
|
-
*/
|
|
69
|
-
auto(): void;
|
|
70
|
-
/**
|
|
71
|
-
* @deprecated Use `vis.setup()` instead.
|
|
72
|
-
*
|
|
73
|
-
* Enable automatic visual testing with multiple themes.
|
|
74
|
-
*
|
|
75
|
-
* This will take a snapshot after each test for each theme.
|
|
76
|
-
*
|
|
77
|
-
* @param themes A record of theme names and their setup functions.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* ```ts
|
|
81
|
-
* vis().presets.theme({
|
|
82
|
-
* light() { document.body.classList.add('light') },
|
|
83
|
-
* dark() { document.body.classList.add('dark') },
|
|
84
|
-
* })
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
|
-
theme<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(themes: Record<string, boolean | ((options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)>): void;
|
|
88
|
-
};
|
|
89
|
-
beforeAll: {
|
|
90
|
-
setup(): Promise<void>;
|
|
91
|
-
};
|
|
92
|
-
afterEach: {
|
|
93
|
-
matchImageSnapshot(): Promise<void>;
|
|
94
|
-
matchPerTheme<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(themes: Record<string, boolean | ((options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)>): () => Promise<void>;
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
declare function createVis<GM extends Record<string, any> | unknown = unknown>(commands: SetupVisSuiteCommand): VisClientConfigurator<GM>;
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region src/setup/vis.d.ts
|
|
100
7
|
/**
|
|
101
|
-
*
|
|
8
|
+
* @deprecated Use `createVis` from `vitest-plugin-vis/setup-api` instead.
|
|
102
9
|
*/
|
|
103
|
-
declare const
|
|
10
|
+
declare const createVis: typeof createVis$1;
|
|
104
11
|
//#endregion
|
|
105
|
-
export {
|
|
12
|
+
export { createVis, vis };
|
|
106
13
|
//# sourceMappingURL=setup.d.mts.map
|
package/dist/setup.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.mts","names":[],"sources":["../src/setup
|
|
1
|
+
{"version":3,"file":"setup.d.mts","names":[],"sources":["../src/setup.ts"],"sourcesContent":[],"mappings":";;;;;;;;AASA;cAAa,kBAAS"}
|
package/dist/setup.mjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
4
|
-
import "./base64-CHSENEAO.mjs";
|
|
5
|
-
import "./auto_snapshot_matcher-C0y6mAeS.mjs";
|
|
6
|
-
import { n as createVis, t as vis } from "./setup-DCytWz48.mjs";
|
|
1
|
+
import { createVis as createVis$1 } from "./setup/create_vis.mjs";
|
|
2
|
+
import "./setup-api.mjs";
|
|
3
|
+
import { vis } from "./setup/vis.mjs";
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
//#region src/setup.ts
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `createVis` from `vitest-plugin-vis/setup-api` instead.
|
|
8
|
+
*/
|
|
9
|
+
const createVis = createVis$1;
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { createVis, vis };
|
|
13
|
+
//# sourceMappingURL=setup.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.mjs","names":["createVisDeprecated"],"sources":["../src/setup.ts"],"sourcesContent":["import './setup-api.ts'\n\nexport * from './setup/vis.ts'\n\nimport { createVis as createVisDeprecated } from './setup/create_vis.ts'\n\n/**\n * @deprecated Use `createVis` from `vitest-plugin-vis/setup-api` instead.\n */\nexport const createVis = createVisDeprecated\n"],"mappings":";;;;;;;;AASA,MAAa,YAAYA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asserts.mjs","names":[],"sources":["../../src/shared/asserts.ts"],"sourcesContent":["export function assertSnapshotKeyWithoutDash(snapshotKey: string | undefined) {\n\tif (snapshotKey?.includes('-')) {\n\t\tthrow new Error('Snapshot key cannot contain dash')\n\t}\n}\n"],"mappings":";AAAA,SAAgB,6BAA6B,aAAiC;AAC7E,KAAI,aAAa,SAAS,IAAI,CAC7B,OAAM,IAAI,MAAM,mCAAmC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.mjs","names":[],"sources":["../../src/shared/base64.ts"],"sourcesContent":["export function isBase64String(value: unknown): value is string {\n\treturn typeof value === 'string' && /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/.test(value)\n}\n"],"mappings":";AAAA,SAAgB,eAAe,OAAiC;AAC/D,QAAO,OAAO,UAAU,YAAY,mEAAmE,KAAK,MAAM"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ImageSnapshotComparisonInfo, MatchImageSnapshotOptions } from "./types.mjs";
|
|
2
|
+
import { VisOptions } from "../config/types.mjs";
|
|
3
3
|
import { Pick } from "type-plus";
|
|
4
4
|
|
|
5
5
|
//#region src/shared/commands.types.d.ts
|
|
6
6
|
interface PrepareImageSnapshotComparisonCommand {
|
|
7
|
-
prepareImageSnapshotComparison: (taskId: string, subject: string, options?: MatchImageSnapshotOptions | undefined) => Promise<ImageSnapshotComparisonInfo
|
|
7
|
+
prepareImageSnapshotComparison: (taskId: string, subject: string, options?: MatchImageSnapshotOptions | undefined) => Promise<ImageSnapshotComparisonInfo>;
|
|
8
8
|
}
|
|
9
9
|
interface PreparePageImageSnapshotComparisonCommand {
|
|
10
|
-
preparePageImageSnapshotComparison: (taskId: string, options?: MatchImageSnapshotOptions | undefined) => Promise<ImageSnapshotComparisonInfo
|
|
10
|
+
preparePageImageSnapshotComparison: (taskId: string, options?: MatchImageSnapshotOptions | undefined) => Promise<ImageSnapshotComparisonInfo>;
|
|
11
11
|
}
|
|
12
12
|
interface SetupVisSuiteCommand {
|
|
13
13
|
/**
|
|
@@ -47,5 +47,5 @@ interface ImageSnapshotNextIndexCommand {
|
|
|
47
47
|
imageSnapshotNextIndex(taskId: string): Promise<number>;
|
|
48
48
|
}
|
|
49
49
|
//#endregion
|
|
50
|
-
export {
|
|
51
|
-
//# sourceMappingURL=commands.types
|
|
50
|
+
export { HasImageSnapshotCommand, ImageSnapshotNextIndexCommand, ImageSnapshotResult, LoadImageSnapshotResultsCommand, PrepareImageSnapshotComparisonCommand, PreparePageImageSnapshotComparisonCommand, SetupVisSuiteCommand };
|
|
51
|
+
//# sourceMappingURL=commands.types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.types.d.mts","names":[],"sources":["../../src/shared/commands.types.ts"],"sourcesContent":[],"mappings":";;;;;UAIiB,qCAAA;8EAIL,0CACN,QAAQ;AALd;AAIY,UAIK,yCAAA,CAJL;EACE,kCAAA,EAAA,CAAA,MAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAMF,yBANE,GAAA,SAAA,EAAA,GAOR,OAPQ,CAOA,2BAPA,CAAA;;AAAD,UAUI,oBAAA,CAVJ;EAGI;;;;;AAOjB;;EASE,aAAA,EAAA,GAAA,GADoB,OACpB,CAAA,IAAA,CACC,UADD,EAAA,kBAAA,GAAA,aAAA,GAAA,kBAAA,GAAA,sBAAA,GAAA,aAAA,GAAA,SAAA,GAAA,SAAA,CAAA,CAAA;;AAD2B,UAcZ,+BAAA,CAdY;EAcZ,wBAAA,CAAA,MAAA,EAAA,MAA+B,CAAA,EACL,OAAQ,CAAA,mBAAR,EAAA,CAAA;AAG3C;AAgBiB,UAhBA,mBAAA,CAgBuB;EAIvB,QAAA,EAAA,MAAA;;;;;;;;;;;;;;UAJA,uBAAA;qEACmD;;UAGnD,6BAAA;;;;0CAIwB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { convertThresholdUnit } from "./convert_threshold_unit.mjs";
|
|
2
|
+
import pixelMatch from "pixelmatch";
|
|
3
|
+
import { ssim } from "ssim.js";
|
|
4
|
+
|
|
5
|
+
//#region src/shared/compare_image.ts
|
|
6
|
+
function compareImage(img1, img2, output, width, height, options = {}) {
|
|
7
|
+
const pixelDiff = options.comparisonMethod === "ssim" ? compareWithSsim(img1, img2, output, width, height, options.diffOptions) : pixelMatch(img1, img2, output, width, height, options.diffOptions);
|
|
8
|
+
const diffAmount = convertThresholdUnit({
|
|
9
|
+
failureThresholdType: options.failureThresholdType ?? "pixel",
|
|
10
|
+
width,
|
|
11
|
+
height
|
|
12
|
+
}, pixelDiff);
|
|
13
|
+
return {
|
|
14
|
+
pass: diffAmount <= (options.failureThreshold ?? 0),
|
|
15
|
+
diffAmount
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @author This code is based on `jest-image-snapshot` implementation.
|
|
20
|
+
*/
|
|
21
|
+
function compareWithSsim(img1, img2, output, width, height, diffOptions) {
|
|
22
|
+
const { ssim_map, mssim } = ssim({
|
|
23
|
+
data: img1,
|
|
24
|
+
width,
|
|
25
|
+
height
|
|
26
|
+
}, {
|
|
27
|
+
data: img2,
|
|
28
|
+
width,
|
|
29
|
+
height
|
|
30
|
+
}, {
|
|
31
|
+
ssim: "bezkrovny",
|
|
32
|
+
...diffOptions
|
|
33
|
+
});
|
|
34
|
+
const diffPixels = Math.round((1 - mssim) * width * height);
|
|
35
|
+
const diffRgbaPixels = new DataView(output.buffer, output.byteOffset);
|
|
36
|
+
for (let ln = 0; ln !== height; ++ln) for (let pos = 0; pos !== width; ++pos) {
|
|
37
|
+
const rPos = ln * width + pos;
|
|
38
|
+
const diffValue = 4278190080 + Math.floor(255 * (1 - ssim_map.data[ssim_map.width * Math.round(ssim_map.height * ln / height) + Math.round(ssim_map.width * pos / width)]));
|
|
39
|
+
diffRgbaPixels.setUint32(rPos * 4, diffValue);
|
|
40
|
+
}
|
|
41
|
+
return diffPixels;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { compareImage };
|
|
46
|
+
//# sourceMappingURL=compare_image.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare_image.mjs","names":["pixelmatch"],"sources":["../../src/shared/compare_image.ts"],"sourcesContent":["import pixelmatch from 'pixelmatch'\nimport { type Options, ssim } from 'ssim.js'\nimport { convertThresholdUnit } from './convert_threshold_unit.ts'\nimport type { ComparisonMethod, ImageSnapshotCompareOptions } from './types.ts'\n\nexport function compareImage<M extends ComparisonMethod>(\n\timg1: Uint8ClampedArray | Buffer,\n\timg2: Uint8ClampedArray | Buffer,\n\toutput: Uint8ClampedArray | Buffer,\n\twidth: number,\n\theight: number,\n\toptions: ImageSnapshotCompareOptions<M> = {} as any,\n) {\n\tconst pixelDiff =\n\t\toptions.comparisonMethod === 'ssim'\n\t\t\t? compareWithSsim(img1, img2, output, width, height, options.diffOptions)\n\t\t\t: pixelmatch(img1, img2, output, width, height, options.diffOptions)\n\tconst diffAmount = convertThresholdUnit(\n\t\t{ failureThresholdType: options.failureThresholdType ?? 'pixel', width, height },\n\t\tpixelDiff,\n\t)\n\n\treturn {\n\t\tpass: diffAmount <= (options.failureThreshold ?? 0),\n\t\tdiffAmount,\n\t}\n}\n\n/**\n * @author This code is based on `jest-image-snapshot` implementation.\n */\nfunction compareWithSsim(\n\timg1: Uint8ClampedArray | Buffer,\n\timg2: Uint8ClampedArray | Buffer,\n\toutput: Uint8ClampedArray | Buffer,\n\twidth: number,\n\theight: number,\n\tdiffOptions?: Partial<Options>,\n) {\n\tconst newImage = { data: img1, width: width, height: height }\n\tconst baselineImage = { data: img2, width: width, height: height }\n\tconst { ssim_map, mssim } = ssim(newImage as any, baselineImage as any, {\n\t\tssim: 'bezkrovny',\n\t\t...diffOptions,\n\t})\n\t// Converts the SSIM value to different pixels based on image width and height\n\t// conforms to how pixelmatch works.\n\tconst diffPixels = Math.round((1 - mssim) * width * height)\n\tconst diffRgbaPixels = new DataView(output.buffer, output.byteOffset)\n\tfor (let ln = 0; ln !== height; ++ln) {\n\t\tfor (let pos = 0; pos !== width; ++pos) {\n\t\t\tconst rPos = ln * width + pos\n\t\t\t// initial value is transparent. We'll add in the SSIM offset.\n\t\t\t// red (ff) green (00) blue (00) alpha (00)\n\t\t\tconst diffValue =\n\t\t\t\t0xff000000 +\n\t\t\t\tMath.floor(\n\t\t\t\t\t0xff *\n\t\t\t\t\t\t(1 -\n\t\t\t\t\t\t\tssim_map.data[\n\t\t\t\t\t\t\t\tssim_map.width * Math.round((ssim_map.height * ln) / height) +\n\t\t\t\t\t\t\t\t\tMath.round((ssim_map.width * pos) / width)\n\t\t\t\t\t\t\t]!),\n\t\t\t\t)\n\t\t\tdiffRgbaPixels.setUint32(rPos * 4, diffValue)\n\t\t}\n\t}\n\treturn diffPixels\n}\n"],"mappings":";;;;;AAKA,SAAgB,aACf,MACA,MACA,QACA,OACA,QACA,UAA0C,EAAE,EAC3C;CACD,MAAM,YACL,QAAQ,qBAAqB,SAC1B,gBAAgB,MAAM,MAAM,QAAQ,OAAO,QAAQ,QAAQ,YAAY,GACvEA,WAAW,MAAM,MAAM,QAAQ,OAAO,QAAQ,QAAQ,YAAY;CACtE,MAAM,aAAa,qBAClB;EAAE,sBAAsB,QAAQ,wBAAwB;EAAS;EAAO;EAAQ,EAChF,UACA;AAED,QAAO;EACN,MAAM,eAAe,QAAQ,oBAAoB;EACjD;EACA;;;;;AAMF,SAAS,gBACR,MACA,MACA,QACA,OACA,QACA,aACC;CAGD,MAAM,EAAE,UAAU,UAAU,KAFX;EAAE,MAAM;EAAa;EAAe;EAAQ,EACvC;EAAE,MAAM;EAAa;EAAe;EAAQ,EACM;EACvE,MAAM;EACN,GAAG;EACH,CAAC;CAGF,MAAM,aAAa,KAAK,OAAO,IAAI,SAAS,QAAQ,OAAO;CAC3D,MAAM,iBAAiB,IAAI,SAAS,OAAO,QAAQ,OAAO,WAAW;AACrE,MAAK,IAAI,KAAK,GAAG,OAAO,QAAQ,EAAE,GACjC,MAAK,IAAI,MAAM,GAAG,QAAQ,OAAO,EAAE,KAAK;EACvC,MAAM,OAAO,KAAK,QAAQ;EAG1B,MAAM,YACL,aACA,KAAK,MACJ,OACE,IACA,SAAS,KACR,SAAS,QAAQ,KAAK,MAAO,SAAS,SAAS,KAAM,OAAO,GAC3D,KAAK,MAAO,SAAS,QAAQ,MAAO,MAAM,GAE9C;AACF,iBAAe,UAAU,OAAO,GAAG,UAAU;;AAG/C,QAAO"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/shared/constants.d.ts
|
|
2
|
+
declare const NAME = "vis";
|
|
3
|
+
declare const SNAPSHOT_ROOT_DIR = "__vis__";
|
|
4
|
+
declare const BASELINE_DIR = "__baselines__";
|
|
5
|
+
declare const RESULT_DIR = "__results__";
|
|
6
|
+
declare const DIFF_DIR = "__diffs__";
|
|
7
|
+
//#endregion
|
|
8
|
+
export { BASELINE_DIR, DIFF_DIR, NAME, RESULT_DIR, SNAPSHOT_ROOT_DIR };
|
|
9
|
+
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.mts","names":[],"sources":["../../src/shared/constants.ts"],"sourcesContent":[],"mappings":";cAAa,IAAA;AAAA,cACA,iBAAA,GADI,SAAA;AACJ,cACA,YAAA,GADiB,eAAA;AACjB,cACA,UAAA,GADY,aAAA;AACZ,cACA,QAAA,GADU,WAAA"}
|
|
@@ -6,5 +6,5 @@ const RESULT_DIR = "__results__";
|
|
|
6
6
|
const DIFF_DIR = "__diffs__";
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
|
-
export {
|
|
10
|
-
//# sourceMappingURL=constants
|
|
9
|
+
export { BASELINE_DIR, DIFF_DIR, NAME, RESULT_DIR, SNAPSHOT_ROOT_DIR };
|
|
10
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../src/shared/constants.ts"],"sourcesContent":["export const NAME = 'vis'\nexport const SNAPSHOT_ROOT_DIR = '__vis__'\nexport const BASELINE_DIR = '__baselines__'\nexport const RESULT_DIR = '__results__'\nexport const DIFF_DIR = '__diffs__'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,oBAAoB;AACjC,MAAa,eAAe;AAC5B,MAAa,aAAa;AAC1B,MAAa,WAAW"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/shared/convert_threshold_unit.ts
|
|
2
|
+
function convertThresholdUnit({ failureThresholdType, width, height }, pixelDiff) {
|
|
3
|
+
switch (failureThresholdType) {
|
|
4
|
+
case "pixel": return pixelDiff;
|
|
5
|
+
case "percent": return pixelDiff / (width * height) * 100;
|
|
6
|
+
default: throw new Error(`Unsupported failureThresholdType: ${failureThresholdType}`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { convertThresholdUnit };
|
|
12
|
+
//# sourceMappingURL=convert_threshold_unit.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert_threshold_unit.mjs","names":[],"sources":["../../src/shared/convert_threshold_unit.ts"],"sourcesContent":["export function convertThresholdUnit(\n\t{ failureThresholdType, width, height }: { failureThresholdType: 'pixel' | 'percent'; width: number; height: number },\n\tpixelDiff: number,\n): number {\n\tswitch (failureThresholdType) {\n\t\tcase 'pixel':\n\t\t\treturn pixelDiff\n\t\tcase 'percent':\n\t\t\treturn (pixelDiff / (width * height)) * 100\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported failureThresholdType: ${failureThresholdType}`)\n\t}\n}\n"],"mappings":";AAAA,SAAgB,qBACf,EAAE,sBAAsB,OAAO,UAC/B,WACS;AACT,SAAQ,sBAAR;EACC,KAAK,QACJ,QAAO;EACR,KAAK,UACJ,QAAQ,aAAa,QAAQ,UAAW;EACzC,QACC,OAAM,IAAI,MAAM,qCAAqC,uBAAuB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/shared/get_max_size.ts
|
|
2
|
+
function getMaxSize(image1, image2) {
|
|
3
|
+
return {
|
|
4
|
+
width: Math.max(image1.width, image2.width),
|
|
5
|
+
height: Math.max(image1.height, image2.height)
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { getMaxSize };
|
|
11
|
+
//# sourceMappingURL=get_max_size.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_max_size.mjs","names":[],"sources":["../../src/shared/get_max_size.ts"],"sourcesContent":["export function getMaxSize(image1: { width: number; height: number }, image2: { width: number; height: number }) {\n\tconst width = Math.max(image1.width, image2.width)\n\tconst height = Math.max(image1.height, image2.height)\n\treturn { width, height }\n}\n"],"mappings":";AAAA,SAAgB,WAAW,QAA2C,QAA2C;AAGhH,QAAO;EAAE,OAFK,KAAK,IAAI,OAAO,OAAO,OAAO,MAAM;EAElC,QADD,KAAK,IAAI,OAAO,QAAQ,OAAO,OAAO;EAC7B"}
|