@guideshot/core 0.1.1 → 0.3.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 +2 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,3 +13,5 @@ const recipe = parseRecipe(source, { file: 'example.shot.json' });
|
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Browser drivers and annotation renderers are injected through `defineConfig`. Requires Node.js 20 or newer and is licensed under the MIT License.
|
|
16
|
+
|
|
17
|
+
Scenario definitions remain isolated per job by default. Deterministic, read-only adapters may set `reusePreparedState: true`; shared mutable adapters should use `concurrencyKey` instead.
|
package/dist/index.d.ts
CHANGED
|
@@ -73,6 +73,8 @@ interface ScenarioResult {
|
|
|
73
73
|
interface ScenarioDefinition<TInput extends JsonObject = JsonObject> extends ExtensionInfo {
|
|
74
74
|
schema: object;
|
|
75
75
|
datasetRevision?: string;
|
|
76
|
+
concurrencyKey?: string;
|
|
77
|
+
reusePreparedState?: boolean;
|
|
76
78
|
prepare(context: ScenarioContext, input: TInput): ScenarioResult | Promise<ScenarioResult>;
|
|
77
79
|
}
|
|
78
80
|
interface TranslationContext {
|
|
@@ -91,11 +93,15 @@ interface ServerConfig {
|
|
|
91
93
|
interface SafetyConfig {
|
|
92
94
|
allowedOrigins?: readonly string[];
|
|
93
95
|
}
|
|
96
|
+
interface CaptureConfig {
|
|
97
|
+
concurrency?: number;
|
|
98
|
+
}
|
|
94
99
|
interface GuideShotConfig {
|
|
95
100
|
recipes: readonly string[];
|
|
96
101
|
outputDir: string;
|
|
97
102
|
cacheDir: string;
|
|
98
103
|
server: ServerConfig;
|
|
104
|
+
capture?: CaptureConfig;
|
|
99
105
|
safety?: SafetyConfig;
|
|
100
106
|
targetAttribute?: `data-${string}`;
|
|
101
107
|
profiles: Readonly<Record<string, CaptureProfile>>;
|
|
@@ -142,6 +148,7 @@ interface BrowserDriver extends ExtensionInfo {
|
|
|
142
148
|
}
|
|
143
149
|
interface BrowserRun {
|
|
144
150
|
capture(request: CaptureRequest): Promise<CaptureResult>;
|
|
151
|
+
captureMany?(requests: readonly CaptureRequest[]): Promise<readonly CaptureResult[]>;
|
|
145
152
|
close(): Promise<void>;
|
|
146
153
|
}
|
|
147
154
|
interface Rect {
|
|
@@ -405,4 +412,4 @@ declare function validateConfig(config: GuideShotConfig): void;
|
|
|
405
412
|
declare function validateRecipeSemantics(source: RecipeSource, config: GuideShotConfig): void;
|
|
406
413
|
declare function defaultProfileName(config: GuideShotConfig): string;
|
|
407
414
|
|
|
408
|
-
export { type AnnotationRenderer, type BrowserCookie, type BrowserDriver, type BrowserEnvironment, type BrowserRun, type BrowserStatePatch, type CaptureIntent, type CaptureProfile, type CaptureRequest, type CaptureResult, type CapturedScene, type CompositionIntent, type CompositionOutput, type CompositionRequest, DIAGNOSTIC_CODES, type Diagnostic, type DiagnosticCode, type DiagnosticLocation, type DiagnosticSeverity, type DimensionDefinition, type DimensionResolveContext, type DriverRunOptions, type ExtensionInfo, type GuideShotConfig, GuideShotError, type GuideShotErrorOptions, type InterpolationContext, type LocalStorageState, type ManifestAssetInput, type MatrixDefinition, type ParseRecipeOptions, type Plan, type PlanOptions, type PlannedJob, type RecipeSource, type Rect, type RenderedAsset, type RendererRun, type ResolveJobOptions, type ResolveTextContext, type ResolvedAnnotation, type ResolvedCaptureJob, type ResolvedJob, type SafeProjectPaths, type SafetyConfig, type ScenarioContext, type ScenarioDefinition, type ScenarioResult, type SceneBackground, type SceneTarget, type SceneViewport, type ServerConfig, type TranslationContext, type TranslationProvider, type VariantRow, type Viewport, assertAllowedOrigin, assertUniqueRecipeIds, buildPublicManifest, canonicalSerialize, createAssetPath, createCaptureHash, createCompositionHash, createJobCompositionHash, createVariantKey, defaultProfileName, defineConfig, defineDimension, defineScenario, diagnosticFromUnknown, discoverRecipes, expandMatrix, hashCanonical, interpolate, interpolateString, isGuideShotError, matchesVariantFilter, mergeBrowserState, parseRecipe, planProject, planRecipes, resolveArtifactPath, resolveJob, resolveLocalizedText, resolvePageUrl, resolveRecipeText, resolveSafeProjectPaths, resolvedAlt, resolvedAnnotations, sanitizeFileSegment, sha256, validateConfig, validateManifest, validateRecipe, validateRecipeSemantics };
|
|
415
|
+
export { type AnnotationRenderer, type BrowserCookie, type BrowserDriver, type BrowserEnvironment, type BrowserRun, type BrowserStatePatch, type CaptureConfig, type CaptureIntent, type CaptureProfile, type CaptureRequest, type CaptureResult, type CapturedScene, type CompositionIntent, type CompositionOutput, type CompositionRequest, DIAGNOSTIC_CODES, type Diagnostic, type DiagnosticCode, type DiagnosticLocation, type DiagnosticSeverity, type DimensionDefinition, type DimensionResolveContext, type DriverRunOptions, type ExtensionInfo, type GuideShotConfig, GuideShotError, type GuideShotErrorOptions, type InterpolationContext, type LocalStorageState, type ManifestAssetInput, type MatrixDefinition, type ParseRecipeOptions, type Plan, type PlanOptions, type PlannedJob, type RecipeSource, type Rect, type RenderedAsset, type RendererRun, type ResolveJobOptions, type ResolveTextContext, type ResolvedAnnotation, type ResolvedCaptureJob, type ResolvedJob, type SafeProjectPaths, type SafetyConfig, type ScenarioContext, type ScenarioDefinition, type ScenarioResult, type SceneBackground, type SceneTarget, type SceneViewport, type ServerConfig, type TranslationContext, type TranslationProvider, type VariantRow, type Viewport, assertAllowedOrigin, assertUniqueRecipeIds, buildPublicManifest, canonicalSerialize, createAssetPath, createCaptureHash, createCompositionHash, createJobCompositionHash, createVariantKey, defaultProfileName, defineConfig, defineDimension, defineScenario, diagnosticFromUnknown, discoverRecipes, expandMatrix, hashCanonical, interpolate, interpolateString, isGuideShotError, matchesVariantFilter, mergeBrowserState, parseRecipe, planProject, planRecipes, resolveArtifactPath, resolveJob, resolveLocalizedText, resolvePageUrl, resolveRecipeText, resolveSafeProjectPaths, resolvedAlt, resolvedAnnotations, sanitizeFileSegment, sha256, validateConfig, validateManifest, validateRecipe, validateRecipeSemantics };
|
package/dist/index.js
CHANGED
|
@@ -246,6 +246,26 @@ function validateConfig(config) {
|
|
|
246
246
|
"Configuration must register at least one capture profile."
|
|
247
247
|
);
|
|
248
248
|
}
|
|
249
|
+
if (config.capture?.concurrency !== void 0 && (!Number.isInteger(config.capture.concurrency) || config.capture.concurrency < 1)) {
|
|
250
|
+
throw new GuideShotError(
|
|
251
|
+
"RECIPE_SCHEMA_INVALID",
|
|
252
|
+
"Capture concurrency must be a positive integer."
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
for (const scenario of Object.values(config.scenarios ?? {})) {
|
|
256
|
+
if (scenario.concurrencyKey !== void 0 && scenario.concurrencyKey.trim() === "") {
|
|
257
|
+
throw new GuideShotError(
|
|
258
|
+
"RECIPE_SCHEMA_INVALID",
|
|
259
|
+
"Scenario concurrency keys cannot be empty."
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
if (scenario.reusePreparedState !== void 0 && typeof scenario.reusePreparedState !== "boolean") {
|
|
263
|
+
throw new GuideShotError(
|
|
264
|
+
"RECIPE_SCHEMA_INVALID",
|
|
265
|
+
"Scenario prepared-state reuse must be a boolean."
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
249
269
|
for (const [name, profile] of Object.entries(config.profiles)) {
|
|
250
270
|
if (!Number.isInteger(profile.viewport.width) || profile.viewport.width <= 0 || !Number.isInteger(profile.viewport.height) || profile.viewport.height <= 0) {
|
|
251
271
|
throw new GuideShotError(
|