fidelity-kit/scan
Scans a results folder into a tree of groups and scenes.
Import from fidelity-kit/scan.
Functions
readConfig()
function readConfig(root, onWarning?): Promise<FidelityConfig>;
Reads and validates <root>/fidelity.json.
Parameters
| Parameter | Type | Description |
|---|---|---|
root | string | Suite root directory. |
onWarning? | ScanWarningCallback | Receives warnings for ignored properties. |
Returns
Promise<FidelityConfig>
The validated configuration.
Throws
If the file is missing, is not valid JSON, or fails validation.
scanSuite()
function scanSuite(root, options?): Promise<Suite>;
Walks a results folder and returns its groups and scenes. A directory is a scene when it contains a configured source
image or scene.json.
Parameters
| Parameter | Type | Description |
|---|---|---|
root | string | Suite root directory. |
options? | { config?: FidelityConfig; onScene?: (scene) => Promise<void>; onProgress?: ProgressCallback; onWarning?: ScanWarningCallback; } | A preloaded config, an onScene hook, progress reporting and a warning callback. |
options.config? | FidelityConfig | - |
options.onScene? | (scene) => Promise<void> | - |
options.onProgress? | ProgressCallback | - |
options.onWarning? | ScanWarningCallback | Files and folders that look like suite content but are ignored. |
Returns
Promise<Suite>
The suite tree.
Throws
If root is not a directory or fidelity.json is missing or invalid.
Example
const suite = await scanSuite('results');
for (const scene of allScenes(suite.root)) console.log(scene.path, scene.images);
scanScene()
function scanScene(
root,
rel,
config,
onWarning?
): Promise<SceneNode | null>;
Scan one known scene without walking the rest of the suite.
Parameters
| Parameter | Type | Description |
|---|---|---|
root | string | Suite root directory. |
rel | string | Scene path relative to the root. |
config | FidelityConfig | The suite configuration. |
onWarning? | ScanWarningCallback | Receives warnings about ignored content. |
Returns
Promise<SceneNode | null>
The scene, or null when the folder is missing or is not a scene.
allScenes()
function allScenes(g): Generator<SceneNode>;
Iterates every scene in a group and its descendants, depth first.
Parameters
| Parameter | Type | Description |
|---|---|---|
g | GroupNode | The group to walk, usually suite.root. |
Returns
Generator<SceneNode>
Interfaces
SceneNode
A scene found in a suite: a folder holding renderer images or a scene.json.
Properties
GroupNode
A folder that groups scenes and other groups. The suite root is the group with an empty path.
Properties
| Property | Type | Description |
|---|---|---|
path | string | Slash-joined path from the suite root; empty for the root. |
hasReadme | boolean | Whether the group folder contains a README.md. |
groups | GroupNode[] | Nested groups. |
scenes | SceneNode[] | Scenes directly inside this group. |
Suite
A scanned results folder.
Extended by
Properties
| Property | Type | Description |
|---|---|---|
config | FidelityConfig | The validated fidelity.json. |
hasReadme | boolean | Whether the suite root contains a README.md preamble. |
root | GroupNode | The root group, containing every scene. |
Type Aliases
ScanWarningCallback
type ScanWarningCallback = (warning) => void;
Receives something in the suite that fidelity-kit ignores.
Parameters
| Parameter | Type |
|---|---|
warning | SuiteWarning |
Returns
void