@clockgrove/assetgrove 0.0.0-stage → 0.3.2
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/LICENSE +21 -0
- package/README.md +277 -2
- package/dist/animation/commands.d.ts +180 -0
- package/dist/animation/commands.js +515 -0
- package/dist/animation/facing.d.ts +44 -0
- package/dist/animation/facing.js +100 -0
- package/dist/animation/fix.d.ts +136 -0
- package/dist/animation/fix.js +529 -0
- package/dist/animation/flicker.d.ts +44 -0
- package/dist/animation/flicker.js +117 -0
- package/dist/animation/halo.d.ts +72 -0
- package/dist/animation/halo.js +253 -0
- package/dist/animation/holes.d.ts +122 -0
- package/dist/animation/holes.js +262 -0
- package/dist/animation/preview.d.ts +38 -0
- package/dist/animation/preview.js +161 -0
- package/dist/animation/qa.d.ts +57 -0
- package/dist/animation/qa.js +418 -0
- package/dist/animation/run.d.ts +109 -0
- package/dist/animation/run.js +182 -0
- package/dist/animation/strip.d.ts +13 -0
- package/dist/animation/strip.js +41 -0
- package/dist/animation/template-choice.d.ts +75 -0
- package/dist/animation/template-choice.js +153 -0
- package/dist/animation/templates.d.ts +39 -0
- package/dist/animation/templates.js +333 -0
- package/dist/animation/types.d.ts +257 -0
- package/dist/animation/types.js +1 -0
- package/dist/approvals.d.ts +156 -0
- package/dist/approvals.js +369 -0
- package/dist/audio/aac.d.ts +61 -0
- package/dist/audio/aac.js +152 -0
- package/dist/audio/checks.d.ts +38 -0
- package/dist/audio/checks.js +254 -0
- package/dist/audio/delivery.d.ts +52 -0
- package/dist/audio/delivery.js +105 -0
- package/dist/audio/engine.d.ts +65 -0
- package/dist/audio/engine.js +164 -0
- package/dist/audio/handoff.d.ts +75 -0
- package/dist/audio/handoff.js +185 -0
- package/dist/audio/kinds.d.ts +6 -0
- package/dist/audio/kinds.js +315 -0
- package/dist/audio/loudness.d.ts +22 -0
- package/dist/audio/loudness.js +72 -0
- package/dist/audio/ogg.d.ts +27 -0
- package/dist/audio/ogg.js +65 -0
- package/dist/audio/operations.d.ts +20 -0
- package/dist/audio/operations.js +335 -0
- package/dist/audio/opus.d.ts +40 -0
- package/dist/audio/opus.js +108 -0
- package/dist/audio/profile.d.ts +200 -0
- package/dist/audio/profile.js +126 -0
- package/dist/audio/run.d.ts +83 -0
- package/dist/audio/run.js +192 -0
- package/dist/audio/vorbis-comments.d.ts +25 -0
- package/dist/audio/vorbis-comments.js +243 -0
- package/dist/audio/waveform.d.ts +13 -0
- package/dist/audio/waveform.js +52 -0
- package/dist/audio-parameters.d.ts +17 -0
- package/dist/audio-parameters.js +45 -0
- package/dist/audit/bar.d.ts +65 -0
- package/dist/audit/bar.js +97 -0
- package/dist/audit/members.d.ts +40 -0
- package/dist/audit/members.js +119 -0
- package/dist/bible-view.d.ts +10 -0
- package/dist/bible-view.js +122 -0
- package/dist/bible.d.ts +272 -0
- package/dist/bible.js +641 -0
- package/dist/budget.d.ts +119 -0
- package/dist/budget.js +227 -0
- package/dist/call-parameters.d.ts +71 -0
- package/dist/call-parameters.js +90 -0
- package/dist/calls.d.ts +145 -0
- package/dist/calls.js +788 -0
- package/dist/cli/main.d.ts +22 -0
- package/dist/cli/main.js +137 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +5 -0
- package/dist/commands/animation-qa.d.ts +1 -0
- package/dist/commands/animation-qa.js +240 -0
- package/dist/commands/apply.d.ts +12 -0
- package/dist/commands/apply.js +181 -0
- package/dist/commands/audit.d.ts +92 -0
- package/dist/commands/audit.js +555 -0
- package/dist/commands/bible.d.ts +1 -0
- package/dist/commands/bible.js +39 -0
- package/dist/commands/browse.d.ts +12 -0
- package/dist/commands/browse.js +113 -0
- package/dist/commands/card.d.ts +3 -0
- package/dist/commands/card.js +445 -0
- package/dist/commands/compare.d.ts +1 -0
- package/dist/commands/compare.js +90 -0
- package/dist/commands/confirm.d.ts +1 -0
- package/dist/commands/confirm.js +267 -0
- package/dist/commands/context.d.ts +43 -0
- package/dist/commands/context.js +115 -0
- package/dist/commands/deliver.d.ts +1 -0
- package/dist/commands/deliver.js +99 -0
- package/dist/commands/disclosure.d.ts +1 -0
- package/dist/commands/disclosure.js +80 -0
- package/dist/commands/doctor.d.ts +1 -0
- package/dist/commands/doctor.js +112 -0
- package/dist/commands/estimate.d.ts +2 -0
- package/dist/commands/estimate.js +80 -0
- package/dist/commands/extensions.d.ts +2 -0
- package/dist/commands/extensions.js +70 -0
- package/dist/commands/fix-frame.d.ts +1 -0
- package/dist/commands/fix-frame.js +206 -0
- package/dist/commands/generate-sheet.d.ts +1 -0
- package/dist/commands/generate-sheet.js +245 -0
- package/dist/commands/identity-check.d.ts +1 -0
- package/dist/commands/identity-check.js +110 -0
- package/dist/commands/identity-eval.d.ts +1 -0
- package/dist/commands/identity-eval.js +197 -0
- package/dist/commands/import.d.ts +7 -0
- package/dist/commands/import.js +472 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +117 -0
- package/dist/commands/intake.d.ts +1 -0
- package/dist/commands/intake.js +56 -0
- package/dist/commands/labels.d.ts +1 -0
- package/dist/commands/labels.js +101 -0
- package/dist/commands/library.d.ts +9 -0
- package/dist/commands/library.js +711 -0
- package/dist/commands/lod.d.ts +1 -0
- package/dist/commands/lod.js +93 -0
- package/dist/commands/look-dev.d.ts +1 -0
- package/dist/commands/look-dev.js +148 -0
- package/dist/commands/materials.d.ts +1 -0
- package/dist/commands/materials.js +223 -0
- package/dist/commands/mcp.d.ts +1 -0
- package/dist/commands/mcp.js +53 -0
- package/dist/commands/migrate.d.ts +1 -0
- package/dist/commands/migrate.js +123 -0
- package/dist/commands/op.d.ts +5 -0
- package/dist/commands/op.js +114 -0
- package/dist/commands/ops.d.ts +1 -0
- package/dist/commands/ops.js +17 -0
- package/dist/commands/pick-batch.d.ts +24 -0
- package/dist/commands/pick-batch.js +343 -0
- package/dist/commands/pick.d.ts +48 -0
- package/dist/commands/pick.js +469 -0
- package/dist/commands/plan.d.ts +3 -0
- package/dist/commands/plan.js +156 -0
- package/dist/commands/recipe.d.ts +1 -0
- package/dist/commands/recipe.js +52 -0
- package/dist/commands/registry.d.ts +5 -0
- package/dist/commands/registry.js +121 -0
- package/dist/commands/render-sprite.d.ts +1 -0
- package/dist/commands/render-sprite.js +67 -0
- package/dist/commands/rendition.d.ts +1 -0
- package/dist/commands/rendition.js +56 -0
- package/dist/commands/request-change.d.ts +2 -0
- package/dist/commands/request-change.js +950 -0
- package/dist/commands/result.d.ts +34 -0
- package/dist/commands/result.js +237 -0
- package/dist/commands/review.d.ts +28 -0
- package/dist/commands/review.js +444 -0
- package/dist/commands/rig.d.ts +1 -0
- package/dist/commands/rig.js +74 -0
- package/dist/commands/runner.d.ts +45 -0
- package/dist/commands/runner.js +297 -0
- package/dist/commands/runs.d.ts +22 -0
- package/dist/commands/runs.js +159 -0
- package/dist/commands/search.d.ts +69 -0
- package/dist/commands/search.js +638 -0
- package/dist/commands/settings.d.ts +2 -0
- package/dist/commands/settings.js +284 -0
- package/dist/commands/spend.d.ts +2 -0
- package/dist/commands/spend.js +159 -0
- package/dist/commands/stage-source.d.ts +1 -0
- package/dist/commands/stage-source.js +58 -0
- package/dist/commands/stage.d.ts +9 -0
- package/dist/commands/stage.js +229 -0
- package/dist/commands/storage.d.ts +3 -0
- package/dist/commands/storage.js +200 -0
- package/dist/commands/turnaround.d.ts +1 -0
- package/dist/commands/turnaround.js +171 -0
- package/dist/commands/types.d.ts +195 -0
- package/dist/commands/types.js +7 -0
- package/dist/commands/vary.d.ts +2 -0
- package/dist/commands/vary.js +222 -0
- package/dist/commands/write-families.d.ts +14 -0
- package/dist/commands/write-families.js +158 -0
- package/dist/compare.d.ts +87 -0
- package/dist/compare.js +306 -0
- package/dist/confirm/delegation.d.ts +30 -0
- package/dist/confirm/delegation.js +31 -0
- package/dist/confirm/index.d.ts +84 -0
- package/dist/confirm/index.js +176 -0
- package/dist/confirm/mcp.d.ts +60 -0
- package/dist/confirm/mcp.js +253 -0
- package/dist/confirm/pending.d.ts +11 -0
- package/dist/confirm/pending.js +40 -0
- package/dist/confirm/prompt.d.ts +65 -0
- package/dist/confirm/prompt.js +68 -0
- package/dist/confirm/records.d.ts +17 -0
- package/dist/confirm/records.js +63 -0
- package/dist/contact.d.ts +80 -0
- package/dist/contact.js +224 -0
- package/dist/credentials.d.ts +170 -0
- package/dist/credentials.js +598 -0
- package/dist/dataflows.d.ts +32 -0
- package/dist/dataflows.js +42 -0
- package/dist/delivery.d.ts +89 -0
- package/dist/delivery.js +355 -0
- package/dist/disclosure.d.ts +84 -0
- package/dist/disclosure.js +397 -0
- package/dist/env.d.ts +90 -0
- package/dist/env.js +236 -0
- package/dist/errors.d.ts +90 -0
- package/dist/errors.js +105 -0
- package/dist/extension/api.d.ts +389 -0
- package/dist/extension/api.js +20 -0
- package/dist/extension/context.d.ts +9 -0
- package/dist/extension/context.js +60 -0
- package/dist/extension/helpers.d.ts +75 -0
- package/dist/extension/helpers.js +107 -0
- package/dist/extension/http.d.ts +32 -0
- package/dist/extension/http.js +104 -0
- package/dist/extension/setup.d.ts +53 -0
- package/dist/extension/setup.js +162 -0
- package/dist/extension/tools.d.ts +97 -0
- package/dist/extension/tools.js +235 -0
- package/dist/extensions/core.d.ts +7 -0
- package/dist/extensions/core.js +18 -0
- package/dist/extensions/errors.d.ts +22 -0
- package/dist/extensions/errors.js +34 -0
- package/dist/extensions/registry.d.ts +119 -0
- package/dist/extensions/registry.js +535 -0
- package/dist/extensions/version.d.ts +9 -0
- package/dist/extensions/version.js +57 -0
- package/dist/formats.d.ts +46 -0
- package/dist/formats.js +81 -0
- package/dist/frames.d.ts +58 -0
- package/dist/frames.js +80 -0
- package/dist/gateway/anthropic.d.ts +22 -0
- package/dist/gateway/anthropic.js +65 -0
- package/dist/gateway/elevenlabs.d.ts +36 -0
- package/dist/gateway/elevenlabs.js +192 -0
- package/dist/gateway/failure.d.ts +29 -0
- package/dist/gateway/failure.js +70 -0
- package/dist/gateway/openai-compatible.d.ts +20 -0
- package/dist/gateway/openai-compatible.js +76 -0
- package/dist/gateway/openai.d.ts +28 -0
- package/dist/gateway/openai.js +101 -0
- package/dist/gateway/provider.d.ts +380 -0
- package/dist/gateway/provider.js +5 -0
- package/dist/gateway/scripted.d.ts +252 -0
- package/dist/gateway/scripted.js +244 -0
- package/dist/gateway/stability.d.ts +38 -0
- package/dist/gateway/stability.js +232 -0
- package/dist/gateway/structured.d.ts +31 -0
- package/dist/gateway/structured.js +83 -0
- package/dist/gateway/tripo.d.ts +48 -0
- package/dist/gateway/tripo.js +374 -0
- package/dist/gateway/vercel.d.ts +52 -0
- package/dist/gateway/vercel.js +298 -0
- package/dist/generators/generator.d.ts +236 -0
- package/dist/generators/generator.js +12 -0
- package/dist/generators/image.d.ts +21 -0
- package/dist/generators/image.js +286 -0
- package/dist/generators/spec-schema.d.ts +29 -0
- package/dist/generators/spec-schema.js +21 -0
- package/dist/git-marker.d.ts +3 -0
- package/dist/git-marker.js +13 -0
- package/dist/gitlfs.d.ts +38 -0
- package/dist/gitlfs.js +171 -0
- package/dist/guard.d.ts +55 -0
- package/dist/guard.js +323 -0
- package/dist/handoff/current-profile.d.ts +48 -0
- package/dist/handoff/current-profile.js +127 -0
- package/dist/handoff/doctor.d.ts +26 -0
- package/dist/handoff/doctor.js +249 -0
- package/dist/handoff/mark-check.d.ts +17 -0
- package/dist/handoff/mark-check.js +66 -0
- package/dist/handoff/presets/aseprite-json.d.ts +5 -0
- package/dist/handoff/presets/aseprite-json.js +45 -0
- package/dist/handoff/presets/atlas-json.d.ts +44 -0
- package/dist/handoff/presets/atlas-json.js +195 -0
- package/dist/handoff/presets/atlas-pack.d.ts +14 -0
- package/dist/handoff/presets/atlas-pack.js +431 -0
- package/dist/handoff/presets/index.d.ts +273 -0
- package/dist/handoff/presets/index.js +58 -0
- package/dist/handoff/presets/manifest.d.ts +2 -0
- package/dist/handoff/presets/manifest.js +49 -0
- package/dist/handoff/usage.d.ts +27 -0
- package/dist/handoff/usage.js +159 -0
- package/dist/handoff.d.ts +345 -0
- package/dist/handoff.js +1221 -0
- package/dist/identity-eval.d.ts +156 -0
- package/dist/identity-eval.js +321 -0
- package/dist/identity.d.ts +293 -0
- package/dist/identity.js +675 -0
- package/dist/image/apply-style.d.ts +4 -0
- package/dist/image/apply-style.js +37 -0
- package/dist/image/digits.d.ts +5 -0
- package/dist/image/digits.js +40 -0
- package/dist/image/ktx2.d.ts +83 -0
- package/dist/image/ktx2.js +196 -0
- package/dist/image/raster.d.ts +23 -0
- package/dist/image/raster.js +77 -0
- package/dist/image/resample.d.ts +10 -0
- package/dist/image/resample.js +82 -0
- package/dist/image/webp.d.ts +17 -0
- package/dist/image/webp.js +323 -0
- package/dist/init.d.ts +132 -0
- package/dist/init.js +425 -0
- package/dist/inputs.d.ts +67 -0
- package/dist/inputs.js +151 -0
- package/dist/json.d.ts +7 -0
- package/dist/json.js +27 -0
- package/dist/keys.d.ts +34 -0
- package/dist/keys.js +198 -0
- package/dist/kind-schemas.d.ts +17 -0
- package/dist/kind-schemas.js +205 -0
- package/dist/library/actions.d.ts +76 -0
- package/dist/library/actions.js +212 -0
- package/dist/library/adopt.d.ts +177 -0
- package/dist/library/adopt.js +624 -0
- package/dist/library/canonical.d.ts +7 -0
- package/dist/library/canonical.js +29 -0
- package/dist/library/card.d.ts +138 -0
- package/dist/library/card.js +532 -0
- package/dist/library/credits.d.ts +70 -0
- package/dist/library/credits.js +222 -0
- package/dist/library/describe.d.ts +48 -0
- package/dist/library/describe.js +199 -0
- package/dist/library/diff.d.ts +26 -0
- package/dist/library/diff.js +208 -0
- package/dist/library/exact.d.ts +15 -0
- package/dist/library/exact.js +47 -0
- package/dist/library/extent.d.ts +56 -0
- package/dist/library/extent.js +205 -0
- package/dist/library/folder.d.ts +85 -0
- package/dist/library/folder.js +291 -0
- package/dist/library/labels.d.ts +29 -0
- package/dist/library/labels.js +112 -0
- package/dist/library/lfs.d.ts +42 -0
- package/dist/library/lfs.js +140 -0
- package/dist/library/maintain.d.ts +100 -0
- package/dist/library/maintain.js +750 -0
- package/dist/library/media-metadata.d.ts +19 -0
- package/dist/library/media-metadata.js +92 -0
- package/dist/library/paths.d.ts +7 -0
- package/dist/library/paths.js +65 -0
- package/dist/library/relations.d.ts +59 -0
- package/dist/library/relations.js +176 -0
- package/dist/library/review.d.ts +204 -0
- package/dist/library/review.js +545 -0
- package/dist/library/stale.d.ts +88 -0
- package/dist/library/stale.js +229 -0
- package/dist/library/suggestions.d.ts +37 -0
- package/dist/library/suggestions.js +146 -0
- package/dist/library/summary.d.ts +65 -0
- package/dist/library/summary.js +138 -0
- package/dist/library/undo.d.ts +18 -0
- package/dist/library/undo.js +141 -0
- package/dist/library/worklist.d.ts +42 -0
- package/dist/library/worklist.js +91 -0
- package/dist/library/write.d.ts +282 -0
- package/dist/library/write.js +790 -0
- package/dist/license.d.ts +67 -0
- package/dist/license.js +205 -0
- package/dist/limits.d.ts +51 -0
- package/dist/limits.js +100 -0
- package/dist/loop.d.ts +244 -0
- package/dist/loop.js +377 -0
- package/dist/material/core.d.ts +70 -0
- package/dist/material/core.js +238 -0
- package/dist/material/engine.d.ts +15 -0
- package/dist/material/engine.js +141 -0
- package/dist/material/flicker.d.ts +26 -0
- package/dist/material/flicker.js +71 -0
- package/dist/material/operations.d.ts +2 -0
- package/dist/material/operations.js +48 -0
- package/dist/material/pipeline.d.ts +51 -0
- package/dist/material/pipeline.js +431 -0
- package/dist/material/profile.d.ts +29 -0
- package/dist/material/profile.js +97 -0
- package/dist/material/rendition.d.ts +5 -0
- package/dist/material/rendition.js +76 -0
- package/dist/mcp.d.ts +72 -0
- package/dist/mcp.js +514 -0
- package/dist/media.d.ts +36 -0
- package/dist/media.js +46 -0
- package/dist/metadata.d.ts +61 -0
- package/dist/metadata.js +748 -0
- package/dist/model-declarations.d.ts +28 -0
- package/dist/model-declarations.js +14 -0
- package/dist/model3d/clip-map.d.ts +49 -0
- package/dist/model3d/clip-map.js +129 -0
- package/dist/model3d/core-checks.d.ts +61 -0
- package/dist/model3d/core-checks.js +278 -0
- package/dist/model3d/facing.d.ts +49 -0
- package/dist/model3d/facing.js +125 -0
- package/dist/model3d/generator.d.ts +19 -0
- package/dist/model3d/generator.js +482 -0
- package/dist/model3d/glb.d.ts +120 -0
- package/dist/model3d/glb.js +155 -0
- package/dist/model3d/handoff.d.ts +37 -0
- package/dist/model3d/handoff.js +131 -0
- package/dist/model3d/lod/chain.d.ts +50 -0
- package/dist/model3d/lod/chain.js +447 -0
- package/dist/model3d/lod/command.d.ts +38 -0
- package/dist/model3d/lod/command.js +377 -0
- package/dist/model3d/lod/qa.d.ts +36 -0
- package/dist/model3d/lod/qa.js +189 -0
- package/dist/model3d/lod/settings.d.ts +36 -0
- package/dist/model3d/lod/settings.js +137 -0
- package/dist/model3d/lod/simplify.d.ts +35 -0
- package/dist/model3d/lod/simplify.js +337 -0
- package/dist/model3d/lod/textures.d.ts +46 -0
- package/dist/model3d/lod/textures.js +190 -0
- package/dist/model3d/lookdev/command.d.ts +219 -0
- package/dist/model3d/lookdev/command.js +1795 -0
- package/dist/model3d/lookdev/edit.d.ts +44 -0
- package/dist/model3d/lookdev/edit.js +241 -0
- package/dist/model3d/lookdev/groom.d.ts +86 -0
- package/dist/model3d/lookdev/groom.js +462 -0
- package/dist/model3d/lookdev/markings.d.ts +98 -0
- package/dist/model3d/lookdev/markings.js +319 -0
- package/dist/model3d/lookdev/project.d.ts +100 -0
- package/dist/model3d/lookdev/project.js +721 -0
- package/dist/model3d/lookdev/settings.d.ts +65 -0
- package/dist/model3d/lookdev/settings.js +103 -0
- package/dist/model3d/lookdev/texels.d.ts +32 -0
- package/dist/model3d/lookdev/texels.js +192 -0
- package/dist/model3d/profile.d.ts +101 -0
- package/dist/model3d/profile.js +132 -0
- package/dist/model3d/prop.d.ts +29 -0
- package/dist/model3d/prop.js +317 -0
- package/dist/model3d/qa.d.ts +27 -0
- package/dist/model3d/qa.js +105 -0
- package/dist/model3d/render.d.ts +172 -0
- package/dist/model3d/render.js +791 -0
- package/dist/model3d/rig/build.d.ts +14 -0
- package/dist/model3d/rig/build.js +210 -0
- package/dist/model3d/rig/candidate.d.ts +50 -0
- package/dist/model3d/rig/candidate.js +132 -0
- package/dist/model3d/rig/command.d.ts +50 -0
- package/dist/model3d/rig/command.js +229 -0
- package/dist/model3d/rig/fit.d.ts +88 -0
- package/dist/model3d/rig/fit.js +568 -0
- package/dist/model3d/rig/gait.d.ts +105 -0
- package/dist/model3d/rig/gait.js +334 -0
- package/dist/model3d/rig/math.d.ts +27 -0
- package/dist/model3d/rig/math.js +92 -0
- package/dist/model3d/rig/motion.d.ts +26 -0
- package/dist/model3d/rig/motion.js +223 -0
- package/dist/model3d/rig/qa.d.ts +76 -0
- package/dist/model3d/rig/qa.js +357 -0
- package/dist/model3d/rig/rig.d.ts +55 -0
- package/dist/model3d/rig/rig.js +213 -0
- package/dist/model3d/rig/template.d.ts +195 -0
- package/dist/model3d/rig/template.js +456 -0
- package/dist/model3d/scene.d.ts +115 -0
- package/dist/model3d/scene.js +684 -0
- package/dist/model3d/views.d.ts +77 -0
- package/dist/model3d/views.js +190 -0
- package/dist/origin.d.ts +162 -0
- package/dist/origin.js +134 -0
- package/dist/paths.d.ts +53 -0
- package/dist/paths.js +240 -0
- package/dist/planning.d.ts +261 -0
- package/dist/planning.js +1470 -0
- package/dist/policy/blocklist.d.ts +28 -0
- package/dist/policy/blocklist.js +58 -0
- package/dist/policy/brief.d.ts +67 -0
- package/dist/policy/brief.js +110 -0
- package/dist/policy/cuts.d.ts +26 -0
- package/dist/policy/cuts.js +80 -0
- package/dist/policy/model.d.ts +69 -0
- package/dist/policy/model.js +202 -0
- package/dist/policy/text.d.ts +183 -0
- package/dist/policy/text.js +285 -0
- package/dist/postprocess.d.ts +68 -0
- package/dist/postprocess.js +302 -0
- package/dist/profile.d.ts +5 -0
- package/dist/profile.js +98 -0
- package/dist/project-rules.d.ts +54 -0
- package/dist/project-rules.js +105 -0
- package/dist/provenance-binding.d.ts +55 -0
- package/dist/provenance-binding.js +352 -0
- package/dist/providers/adapter.d.ts +176 -0
- package/dist/providers/adapter.js +418 -0
- package/dist/providers/index.d.ts +33 -0
- package/dist/providers/index.js +49 -0
- package/dist/providers/script.d.ts +13 -0
- package/dist/providers/script.js +65 -0
- package/dist/providers/set.d.ts +76 -0
- package/dist/providers/set.js +134 -0
- package/dist/pure-cbor.d.ts +1 -0
- package/dist/pure-cbor.js +8 -0
- package/dist/qa/stability.d.ts +215 -0
- package/dist/qa/stability.js +393 -0
- package/dist/qa/stability.json +32 -0
- package/dist/qa.d.ts +36 -0
- package/dist/qa.js +148 -0
- package/dist/reconcile.d.ts +111 -0
- package/dist/reconcile.js +416 -0
- package/dist/redact.d.ts +29 -0
- package/dist/redact.js +74 -0
- package/dist/regions.d.ts +49 -0
- package/dist/regions.js +113 -0
- package/dist/release-policy.d.ts +99 -0
- package/dist/release-policy.js +266 -0
- package/dist/request.d.ts +74 -0
- package/dist/request.js +249 -0
- package/dist/routes.d.ts +327 -0
- package/dist/routes.js +1166 -0
- package/dist/runs/dir.d.ts +33 -0
- package/dist/runs/dir.js +30 -0
- package/dist/runs/execute.d.ts +86 -0
- package/dist/runs/execute.js +422 -0
- package/dist/runs/journal.d.ts +150 -0
- package/dist/runs/journal.js +216 -0
- package/dist/runs/lock.d.ts +57 -0
- package/dist/runs/lock.js +322 -0
- package/dist/runs/plan.d.ts +261 -0
- package/dist/runs/plan.js +404 -0
- package/dist/search/near-match.d.ts +32 -0
- package/dist/search/near-match.js +86 -0
- package/dist/search/reader.d.ts +17 -0
- package/dist/search/reader.js +334 -0
- package/dist/search/sheet.d.ts +4 -0
- package/dist/search/sheet.js +28 -0
- package/dist/search/style-outliers.d.ts +77 -0
- package/dist/search/style-outliers.js +166 -0
- package/dist/settings-write.d.ts +78 -0
- package/dist/settings-write.js +374 -0
- package/dist/settings.d.ts +436 -0
- package/dist/settings.js +622 -0
- package/dist/shared-settings.d.ts +4 -0
- package/dist/shared-settings.js +24 -0
- package/dist/sheet/blobs.d.ts +33 -0
- package/dist/sheet/blobs.js +145 -0
- package/dist/sheet/generate.d.ts +71 -0
- package/dist/sheet/generate.js +278 -0
- package/dist/sheet/group.d.ts +20 -0
- package/dist/sheet/group.js +191 -0
- package/dist/sheet/import.d.ts +315 -0
- package/dist/sheet/import.js +832 -0
- package/dist/sheet/matte.d.ts +25 -0
- package/dist/sheet/matte.js +508 -0
- package/dist/sheet/media-import.d.ts +41 -0
- package/dist/sheet/media-import.js +118 -0
- package/dist/sheet/register.d.ts +17 -0
- package/dist/sheet/register.js +176 -0
- package/dist/sheet/slice.d.ts +73 -0
- package/dist/sheet/slice.js +912 -0
- package/dist/sheet/types.d.ts +225 -0
- package/dist/sheet/types.js +1 -0
- package/dist/source/aseprite.d.ts +14 -0
- package/dist/source/aseprite.js +124 -0
- package/dist/source/stage.d.ts +24 -0
- package/dist/source/stage.js +172 -0
- package/dist/spend.d.ts +220 -0
- package/dist/spend.js +436 -0
- package/dist/sprite/render.d.ts +22 -0
- package/dist/sprite/render.js +272 -0
- package/dist/storage.d.ts +135 -0
- package/dist/storage.js +405 -0
- package/dist/style.d.ts +19 -0
- package/dist/style.js +26 -0
- package/dist/template.d.ts +29 -0
- package/dist/template.js +98 -0
- package/dist/testing/aseprite.d.ts +54 -0
- package/dist/testing/aseprite.js +191 -0
- package/dist/testing/cli.d.ts +24 -0
- package/dist/testing/cli.js +91 -0
- package/dist/testing/conformance.d.ts +61 -0
- package/dist/testing/conformance.js +455 -0
- package/dist/testing/index.d.ts +23 -0
- package/dist/testing/index.js +15 -0
- package/dist/testing/mcp.d.ts +25 -0
- package/dist/testing/mcp.js +80 -0
- package/dist/testing/project.d.ts +81 -0
- package/dist/testing/project.js +215 -0
- package/dist/testing/samples.d.ts +42 -0
- package/dist/testing/samples.js +122 -0
- package/dist/transform/operations.d.ts +5 -0
- package/dist/transform/operations.js +320 -0
- package/dist/transform/raster-engine.d.ts +9 -0
- package/dist/transform/raster-engine.js +329 -0
- package/dist/transform/rendition.d.ts +65 -0
- package/dist/transform/rendition.js +317 -0
- package/dist/transform/run.d.ts +138 -0
- package/dist/transform/run.js +442 -0
- package/dist/transform/schema.d.ts +33 -0
- package/dist/transform/schema.js +73 -0
- package/dist/transform/types.d.ts +101 -0
- package/dist/transform/types.js +1 -0
- package/dist/tree/address.d.ts +18 -0
- package/dist/tree/address.js +59 -0
- package/dist/tree/list.d.ts +18 -0
- package/dist/tree/list.js +101 -0
- package/dist/tree/project.d.ts +61 -0
- package/dist/tree/project.js +145 -0
- package/dist/tree/read.d.ts +43 -0
- package/dist/tree/read.js +715 -0
- package/dist/tree/search.d.ts +20 -0
- package/dist/tree/search.js +44 -0
- package/dist/tree/serve.d.ts +79 -0
- package/dist/tree/serve.js +415 -0
- package/dist/tree/thumbs.d.ts +26 -0
- package/dist/tree/thumbs.js +134 -0
- package/dist/turnaround.d.ts +195 -0
- package/dist/turnaround.js +622 -0
- package/dist/types.d.ts +595 -0
- package/dist/types.js +1 -0
- package/package.json +112 -3
- package/policy/blocklist.json +47 -0
- package/policy/prompt-policy-cuts.json +15 -0
- package/skills/art-direction/SKILL.md +16 -0
- package/skills/art-direction/default.md +14 -0
- package/skills/art-direction/presets/cozy-storybook.md +121 -0
- package/skills/art-direction/presets/dark-gritty-isometric.md +121 -0
- package/skills/art-direction/presets/flat-cartoon-kids.md +121 -0
- package/skills/art-direction/references/bible-format.md +47 -0
- package/skills/assetgrove/SKILL.md +109 -0
- package/skills/assetgrove/references/commands.md +723 -0
|
@@ -0,0 +1,832 @@
|
|
|
1
|
+
import { parseOrigin } from "../origin.js";
|
|
2
|
+
/**
|
|
3
|
+
* The sheet import path: a raw contact sheet (from Assetgrove's own sheet generation, another tool
|
|
4
|
+
* or hand work) becomes cleaned frames and a grouping proposal; an author-confirmed grouping then
|
|
5
|
+
* becomes one strip, manifest and provenance per family in the target, with review pending.
|
|
6
|
+
*/
|
|
7
|
+
import { DIGITAL_SOURCE_TYPES, embedDigitalSourceType, readDigitalSourceType, metadataStep, sourceDeclaration, requireDeclared, } from "../metadata.js";
|
|
8
|
+
import { InputError } from "../errors.js";
|
|
9
|
+
import { licenseFields } from "../license.js";
|
|
10
|
+
import { randomBytes } from "node:crypto";
|
|
11
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
12
|
+
import { join, resolve } from "node:path";
|
|
13
|
+
import { commitTargetWrite, prepareTargetWrites } from "../handoff.js";
|
|
14
|
+
import { drawDigits, textWidth } from "../image/digits.js";
|
|
15
|
+
import { createRaster, decodeImage, encodePng, getPixel, parseHex, setPixel, toHex, } from "../image/raster.js";
|
|
16
|
+
import { applyStyle } from "../image/apply-style.js";
|
|
17
|
+
import { pixelHash, runOperation, runRecipe } from "../transform/run.js";
|
|
18
|
+
import { sha256, sniffMediaType } from "../request.js";
|
|
19
|
+
import { resolveStyle } from "../style.js";
|
|
20
|
+
import { checkConfirmed, familyFrames, proposeGrouping } from "./group.js";
|
|
21
|
+
import { judgeBlobs } from "./blobs.js";
|
|
22
|
+
import { SliceError } from "./slice.js";
|
|
23
|
+
import { matteBackground } from "../animation/halo.js";
|
|
24
|
+
import { animationQa } from "../animation/qa.js";
|
|
25
|
+
import { choiceLoops, DEFAULT_DURATION_MS, renderPreviews } from "../animation/run.js";
|
|
26
|
+
import { templateWithoutCall, UNDECIDED } from "../animation/template-choice.js";
|
|
27
|
+
import { splitStrip } from "../animation/strip.js";
|
|
28
|
+
import { registrationPin, templatesFor, thresholdsFor } from "../animation/templates.js";
|
|
29
|
+
import { scoreIdentity } from "../identity.js";
|
|
30
|
+
export const IMPORT_FILE = "import.json";
|
|
31
|
+
export const GROUPING_FILE = "grouping.json";
|
|
32
|
+
export const CONTACT_FILE = "contact.png";
|
|
33
|
+
export const PREVIEW_FILE = "preview.html";
|
|
34
|
+
/** Default bound on registration jitter, in frame pixels. */
|
|
35
|
+
export const DEFAULT_JITTER_BOUND_PX = 1;
|
|
36
|
+
export { applyStyle };
|
|
37
|
+
/**
|
|
38
|
+
* The import half of the sheet path as a recipe over the transformation core: slice the sheet into
|
|
39
|
+
* figures, then remove each figure's background to the style profile, under the given limits.
|
|
40
|
+
*/
|
|
41
|
+
export function sheetImportRecipe(slice = {}, matte = {}) {
|
|
42
|
+
const params = JSON.parse(JSON.stringify(slice));
|
|
43
|
+
return {
|
|
44
|
+
name: "sheet-import",
|
|
45
|
+
steps: [
|
|
46
|
+
{ op: "slice", params },
|
|
47
|
+
matte.maxHaloFraction === undefined
|
|
48
|
+
? { op: "matte" }
|
|
49
|
+
: { op: "matte", params: { maxHaloFraction: matte.maxHaloFraction } },
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** The box of pixels with alpha >= threshold inside `within`, relative to it. */
|
|
54
|
+
function visibleBox(r, threshold, within) {
|
|
55
|
+
let minX = Infinity;
|
|
56
|
+
let minY = Infinity;
|
|
57
|
+
let maxX = -1;
|
|
58
|
+
let maxY = -1;
|
|
59
|
+
for (let y = within.y; y < within.y + within.height; y++) {
|
|
60
|
+
for (let x = within.x; x < within.x + within.width; x++) {
|
|
61
|
+
if (getPixel(r, x, y)[3] >= threshold) {
|
|
62
|
+
minX = Math.min(minX, x);
|
|
63
|
+
minY = Math.min(minY, y);
|
|
64
|
+
maxX = Math.max(maxX, x);
|
|
65
|
+
maxY = Math.max(maxY, y);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (maxX < 0)
|
|
70
|
+
return undefined;
|
|
71
|
+
return {
|
|
72
|
+
x: minX - within.x,
|
|
73
|
+
y: minY - within.y,
|
|
74
|
+
width: maxX - minX + 1,
|
|
75
|
+
height: maxY - minY + 1,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function blit(dst, src, ox, oy) {
|
|
79
|
+
for (let y = 0; y < src.height; y++) {
|
|
80
|
+
for (let x = 0; x < src.width; x++) {
|
|
81
|
+
const px = getPixel(src, x, y);
|
|
82
|
+
if (px[3] === 0)
|
|
83
|
+
continue;
|
|
84
|
+
const a = px[3] / 255;
|
|
85
|
+
const under = getPixel(dst, ox + x, oy + y);
|
|
86
|
+
setPixel(dst, ox + x, oy + y, [
|
|
87
|
+
Math.round(px[0] * a + under[0] * (1 - a)),
|
|
88
|
+
Math.round(px[1] * a + under[1] * (1 - a)),
|
|
89
|
+
Math.round(px[2] * a + under[2] * (1 - a)),
|
|
90
|
+
255,
|
|
91
|
+
]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A numbered contact sheet of the registered frames on a neutral backdrop, for the author and the
|
|
97
|
+
* grouping model: each frame in its own cell with its number under it.
|
|
98
|
+
*/
|
|
99
|
+
export function contactSheet(frames, ids, frame) {
|
|
100
|
+
const zoom = Math.max(1, Math.floor(128 / Math.max(frame.width, frame.height)));
|
|
101
|
+
const cellW = frame.width * zoom + 8;
|
|
102
|
+
const cellH = frame.height * zoom + 20;
|
|
103
|
+
const columns = Math.min(8, Math.max(1, frames.length));
|
|
104
|
+
const rows = Math.ceil(frames.length / columns);
|
|
105
|
+
const out = createRaster(columns * cellW, rows * cellH);
|
|
106
|
+
for (let i = 0; i < out.data.length; i += 4)
|
|
107
|
+
out.data.set([236, 236, 236, 255], i);
|
|
108
|
+
frames.forEach((f, i) => {
|
|
109
|
+
const cx = (i % columns) * cellW;
|
|
110
|
+
const cy = Math.floor(i / columns) * cellH;
|
|
111
|
+
const scaled = createRaster(f.width * zoom, f.height * zoom);
|
|
112
|
+
for (let y = 0; y < scaled.height; y++) {
|
|
113
|
+
for (let x = 0; x < scaled.width; x++) {
|
|
114
|
+
setPixel(scaled, x, y, getPixel(f, Math.floor(x / zoom), Math.floor(y / zoom)));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
blit(out, scaled, cx + 4, cy + 4);
|
|
118
|
+
const label = String(ids[i]);
|
|
119
|
+
drawDigits(out, label, cx + Math.floor((cellW - textWidth(label, 2)) / 2), cy + cellH - 14, 2, [30, 30, 36, 255]);
|
|
120
|
+
});
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
function frameFile(id) {
|
|
124
|
+
return `frames/f${String(id).padStart(3, "0")}.png`;
|
|
125
|
+
}
|
|
126
|
+
function sourceFile(id) {
|
|
127
|
+
return `frames/f${String(id).padStart(3, "0")}.source.png`;
|
|
128
|
+
}
|
|
129
|
+
/** The sheet's pixels inside `box`, as they were before background removal. */
|
|
130
|
+
function cropSheet(sheet, box) {
|
|
131
|
+
const out = createRaster(box.width, box.height);
|
|
132
|
+
for (let y = 0; y < box.height; y++) {
|
|
133
|
+
const from = ((box.y + y) * sheet.width + box.x) * 4;
|
|
134
|
+
out.data.set(sheet.data.subarray(from, from + box.width * 4), y * box.width * 4);
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
137
|
+
}
|
|
138
|
+
function defaultAnchor(frame) {
|
|
139
|
+
return { x: Math.floor(frame.width / 2), y: frame.height - 1 };
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Imports a sheet: slices it, removes the background to the style profile, checks every frame
|
|
143
|
+
* for halos and leftover background, writes the cleaned frames, a numbered contact sheet of the
|
|
144
|
+
* registered frames and a grouping proposal (`status: "proposed"`) into the import directory.
|
|
145
|
+
*/
|
|
146
|
+
export async function importSheet(options) {
|
|
147
|
+
const now = options.now ?? (() => new Date());
|
|
148
|
+
const { profile } = options;
|
|
149
|
+
const maxHalo = options.matte?.maxHaloFraction;
|
|
150
|
+
if (maxHalo !== undefined && !(maxHalo >= 0 && maxHalo <= 1)) {
|
|
151
|
+
throw new InputError(`the matte limit --max-halo must be a fraction from 0 to 1, not ${maxHalo}`);
|
|
152
|
+
}
|
|
153
|
+
const style = resolveStyle(profile.style, options.bible?.palette);
|
|
154
|
+
const frame = options.frame ?? { width: profile.frames.width, height: profile.frames.height };
|
|
155
|
+
const anchor = options.anchor ?? defaultAnchor(frame);
|
|
156
|
+
let raster;
|
|
157
|
+
try {
|
|
158
|
+
raster = decodeImage(options.sheet);
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
throw new InputError(`cannot decode the sheet ${options.sheetPath}: ${error.message}`, {
|
|
162
|
+
cause: error,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const origin = options.origin === undefined ? undefined : parseOrigin(options.origin);
|
|
166
|
+
const embedded = readDigitalSourceType(options.sheet, sniffMediaType(options.sheet));
|
|
167
|
+
const declaration = options.digitalSourceType === undefined
|
|
168
|
+
? undefined
|
|
169
|
+
: sourceDeclaration(options.digitalSourceType);
|
|
170
|
+
const digitalSourceType = options.generation?.calls.some((c) => c.operation !== "vision")
|
|
171
|
+
? DIGITAL_SOURCE_TYPES.generated
|
|
172
|
+
: (embedded ??
|
|
173
|
+
declaration?.value ??
|
|
174
|
+
(origin?.kind === "human-made"
|
|
175
|
+
? DIGITAL_SOURCE_TYPES.human
|
|
176
|
+
: DIGITAL_SOURCE_TYPES.undeclared));
|
|
177
|
+
const sheetItem = {
|
|
178
|
+
name: "sheet",
|
|
179
|
+
raster,
|
|
180
|
+
mediaType: "image/png",
|
|
181
|
+
meta: {},
|
|
182
|
+
digitalSourceType,
|
|
183
|
+
};
|
|
184
|
+
const importId = options.importId ??
|
|
185
|
+
`${now().toISOString().replace(/[:.]/g, "-")}-${randomBytes(3).toString("hex")}`;
|
|
186
|
+
const importDir = resolve(options.importsDir, importId);
|
|
187
|
+
// Each caller's records from the first call made here, so a shared caller counts once.
|
|
188
|
+
const starts = new Map();
|
|
189
|
+
for (const c of [options.blobs, options.identity?.caller, options.propose?.call]) {
|
|
190
|
+
if (c && !starts.has(c))
|
|
191
|
+
starts.set(c, c.records.length);
|
|
192
|
+
}
|
|
193
|
+
let slice = options.slice ?? {};
|
|
194
|
+
let blobs;
|
|
195
|
+
if (options.blobs) {
|
|
196
|
+
blobs = await judgeBlobs(options.blobs, raster, slice, options.subject ?? options.assetId);
|
|
197
|
+
if (blobs.verdicts.length > 0)
|
|
198
|
+
slice = { ...slice, blobs: blobs.verdicts };
|
|
199
|
+
}
|
|
200
|
+
let ran;
|
|
201
|
+
try {
|
|
202
|
+
ran = runRecipe(sheetImportRecipe(slice, options.matte), [sheetItem], { style });
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
// A generated sheet was paid for: keep it and how it was made, so it can be imported by hand.
|
|
206
|
+
if (error instanceof SliceError && options.generation) {
|
|
207
|
+
// The sheet-blob decisions made before the refusal are kept with it, as the import keeps them.
|
|
208
|
+
const blobCalls = options.blobs
|
|
209
|
+
? options.blobs.records.slice(starts.get(options.blobs) ?? 0)
|
|
210
|
+
: [];
|
|
211
|
+
await keepRefusedSheet(importDir, { ...options, slice }, digitalSourceType, error, now, blobCalls);
|
|
212
|
+
}
|
|
213
|
+
throw error;
|
|
214
|
+
}
|
|
215
|
+
const slicing = ran.steps[0]?.report;
|
|
216
|
+
await mkdir(join(importDir, "frames"), { recursive: true });
|
|
217
|
+
const sheetSha = sha256(options.sheet);
|
|
218
|
+
const frames = [];
|
|
219
|
+
const cleaned = [];
|
|
220
|
+
for (const item of ran.items) {
|
|
221
|
+
const meta = item.meta;
|
|
222
|
+
const file = frameFile(meta.frame);
|
|
223
|
+
await writeFile(join(importDir, file), embedDigitalSourceType(encodePng(item.raster), "image/png", digitalSourceType));
|
|
224
|
+
const source = sourceFile(meta.frame);
|
|
225
|
+
await writeFile(join(importDir, source), embedDigitalSourceType(encodePng(cropSheet(raster, meta.box)), "image/png", digitalSourceType));
|
|
226
|
+
cleaned.push(item);
|
|
227
|
+
frames.push({
|
|
228
|
+
id: meta.frame,
|
|
229
|
+
file,
|
|
230
|
+
source,
|
|
231
|
+
cell: meta.cell,
|
|
232
|
+
box: meta.box,
|
|
233
|
+
background: meta.background,
|
|
234
|
+
// The matte's transforms start with the slicing ones.
|
|
235
|
+
transforms: meta.transforms,
|
|
236
|
+
quality: meta.quality,
|
|
237
|
+
checks: meta.checks,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
const preview = runOperation(cleaned, { op: "register", params: { frame, anchor } }, { style });
|
|
241
|
+
const styled = runOperation(preview.items, { op: "apply-style" }, { style });
|
|
242
|
+
const ids = frames.map((f) => f.id);
|
|
243
|
+
const contactRaster = contactSheet(styled.items.map((i) => i.raster), ids, frame);
|
|
244
|
+
const contact = embedDigitalSourceType(encodePng(contactRaster), "image/png", digitalSourceType);
|
|
245
|
+
await writeFile(join(importDir, CONTACT_FILE), contact);
|
|
246
|
+
const record = {
|
|
247
|
+
...(origin && { origin }),
|
|
248
|
+
digitalSourceType,
|
|
249
|
+
...(declaration && { sourceDeclaration: declaration }),
|
|
250
|
+
importId,
|
|
251
|
+
createdAt: now().toISOString(),
|
|
252
|
+
assetId: options.assetId,
|
|
253
|
+
...(options.subject !== undefined && { subject: options.subject }),
|
|
254
|
+
...(options.gait !== undefined && { gait: options.gait }),
|
|
255
|
+
...(options.templates !== undefined && { templates: options.templates }),
|
|
256
|
+
...(options.judgedTemplates !== undefined && { judgedTemplates: options.judgedTemplates }),
|
|
257
|
+
...(options.spec !== undefined && { spec: options.spec }),
|
|
258
|
+
sheet: {
|
|
259
|
+
path: options.sheetPath,
|
|
260
|
+
sha256: sheetSha,
|
|
261
|
+
mediaType: sniffMediaType(options.sheet),
|
|
262
|
+
tool: options.tool,
|
|
263
|
+
},
|
|
264
|
+
profile,
|
|
265
|
+
bibleVersion: options.bible?.version ?? "none",
|
|
266
|
+
style,
|
|
267
|
+
frame,
|
|
268
|
+
anchor,
|
|
269
|
+
...(profile.frames.durationMs !== undefined && { durationMs: profile.frames.durationMs }),
|
|
270
|
+
slice: {
|
|
271
|
+
mode: slicing.mode,
|
|
272
|
+
...(slicing.grid !== undefined && { grid: slicing.grid }),
|
|
273
|
+
background: slicing.background,
|
|
274
|
+
...(blobs && blobs.judged.length > 0 && { blobs: blobs.judged }),
|
|
275
|
+
...(blobs && blobs.unjudged > 0 && { unjudged: blobs.unjudged }),
|
|
276
|
+
},
|
|
277
|
+
frames,
|
|
278
|
+
steps: [
|
|
279
|
+
...ran.steps,
|
|
280
|
+
...cleaned.map((item) => metadataStep(digitalSourceType, [pixelHash(item.raster)])),
|
|
281
|
+
metadataStep(digitalSourceType, [pixelHash(contactRaster)]),
|
|
282
|
+
],
|
|
283
|
+
...(options.generation !== undefined && { generation: options.generation }),
|
|
284
|
+
calls: [],
|
|
285
|
+
};
|
|
286
|
+
const contactRef = {
|
|
287
|
+
role: "contact sheet",
|
|
288
|
+
path: CONTACT_FILE,
|
|
289
|
+
mediaType: "image/png",
|
|
290
|
+
bytes: contact,
|
|
291
|
+
sha256: sha256(contact),
|
|
292
|
+
};
|
|
293
|
+
if (options.identity && options.identity.settings.mode !== "off") {
|
|
294
|
+
const { caller, record: lock, references, settings, cast, recordCheck } = options.identity;
|
|
295
|
+
record.identity = await scoreIdentity({
|
|
296
|
+
caller,
|
|
297
|
+
record: lock,
|
|
298
|
+
references,
|
|
299
|
+
candidate: contactRef,
|
|
300
|
+
describe: `a numbered contact sheet of ${ids.length} frames of one character${options.spec?.animationFamily ? `, from its "${options.spec.animationFamily}" animation` : ""}`,
|
|
301
|
+
settings,
|
|
302
|
+
edges: style.edges,
|
|
303
|
+
...(cast && { cast }),
|
|
304
|
+
...(recordCheck && { recordCheck }),
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
let grouping;
|
|
308
|
+
if (options.propose) {
|
|
309
|
+
const { call } = options.propose;
|
|
310
|
+
grouping = await proposeGrouping(call, contactRef, options.propose.references ?? [], {
|
|
311
|
+
frameIds: ids,
|
|
312
|
+
subject: options.subject ?? options.assetId,
|
|
313
|
+
...(options.propose.subjectDescription !== undefined && {
|
|
314
|
+
subjectDescription: options.propose.subjectDescription,
|
|
315
|
+
}),
|
|
316
|
+
...(options.propose.hints !== undefined && { hints: options.propose.hints }),
|
|
317
|
+
referenceRoles: (options.propose.references ?? []).map((r) => r.role),
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
grouping = {
|
|
322
|
+
status: "proposed",
|
|
323
|
+
families: [],
|
|
324
|
+
unassigned: ids,
|
|
325
|
+
notes: "No vision proposal was made; group the frames by hand.",
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
record.calls = [...starts].flatMap(([c, start]) => c.records.slice(start));
|
|
329
|
+
await writeFile(join(importDir, GROUPING_FILE), `${JSON.stringify(grouping, null, 2)}\n`);
|
|
330
|
+
await writeImport(importDir, record);
|
|
331
|
+
return { record, importDir, grouping };
|
|
332
|
+
}
|
|
333
|
+
/** The generated sheet a slice refused, and its record, written beside the would-be import. */
|
|
334
|
+
export const REFUSED_SHEET_RECORD = "sheet.json";
|
|
335
|
+
async function keepRefusedSheet(importDir, options, digitalSourceType, error, now, calls) {
|
|
336
|
+
const mediaType = sniffMediaType(options.sheet);
|
|
337
|
+
const file = `sheet.${mediaType.split("/")[1] ?? "bin"}`;
|
|
338
|
+
await mkdir(importDir, { recursive: true });
|
|
339
|
+
await writeFile(join(importDir, file), embedDigitalSourceType(options.sheet, mediaType, digitalSourceType));
|
|
340
|
+
const record = {
|
|
341
|
+
createdAt: now().toISOString(),
|
|
342
|
+
assetId: options.assetId,
|
|
343
|
+
file,
|
|
344
|
+
sheet: {
|
|
345
|
+
path: options.sheetPath,
|
|
346
|
+
sha256: sha256(options.sheet),
|
|
347
|
+
mediaType,
|
|
348
|
+
tool: options.tool,
|
|
349
|
+
},
|
|
350
|
+
digitalSourceType,
|
|
351
|
+
generation: options.generation,
|
|
352
|
+
calls,
|
|
353
|
+
costUsd: [...(options.generation?.calls ?? []), ...calls].reduce((sum, c) => sum + c.costUsd, 0),
|
|
354
|
+
slice: {
|
|
355
|
+
params: options.slice ?? {},
|
|
356
|
+
found: error.found,
|
|
357
|
+
expected: error.expected,
|
|
358
|
+
problems: error.problems,
|
|
359
|
+
},
|
|
360
|
+
};
|
|
361
|
+
await writeFile(join(importDir, REFUSED_SHEET_RECORD), `${JSON.stringify(record, null, 2)}\n`);
|
|
362
|
+
error.kept = join(importDir, file);
|
|
363
|
+
error.message += `. The generated sheet is kept at ${error.kept}, with its generation record in ${join(importDir, REFUSED_SHEET_RECORD)}`;
|
|
364
|
+
}
|
|
365
|
+
export async function writeImport(importDir, record) {
|
|
366
|
+
await writeFile(join(importDir, IMPORT_FILE), `${JSON.stringify(record, null, 2)}\n`);
|
|
367
|
+
}
|
|
368
|
+
export async function readImport(importDir) {
|
|
369
|
+
return JSON.parse(await readFile(join(importDir, IMPORT_FILE), "utf8"));
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* The spec and output fields one family of an import hands off with, for its strip of `count`
|
|
373
|
+
* frames: the frames and anchor, the union of the frames' visible boxes, the palette colours the
|
|
374
|
+
* strip uses and the registration jitter. `writeFamilies` writes each family with them, and
|
|
375
|
+
* `library adopt` renders a family's hand-off again from them for a hand-edited strip.
|
|
376
|
+
*/
|
|
377
|
+
export function familyHandoff(record, family, strip, count, jitterPx, facing) {
|
|
378
|
+
const { frame, anchor, style } = record;
|
|
379
|
+
let union;
|
|
380
|
+
const usedColours = new Set();
|
|
381
|
+
for (let i = 0; i < count; i++) {
|
|
382
|
+
for (let y = 0; y < frame.height; y++) {
|
|
383
|
+
for (let x = 0; x < frame.width; x++) {
|
|
384
|
+
const px = getPixel(strip, i * frame.width + x, y);
|
|
385
|
+
if (px[3] > 0)
|
|
386
|
+
usedColours.add(toHex([px[0], px[1], px[2]]));
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
const box = visibleBox(strip, style.alpha.threshold, { x: i * frame.width, y: 0, ...frame });
|
|
390
|
+
if (box) {
|
|
391
|
+
if (!union)
|
|
392
|
+
union = box;
|
|
393
|
+
else {
|
|
394
|
+
const x = Math.min(union.x, box.x);
|
|
395
|
+
const y = Math.min(union.y, box.y);
|
|
396
|
+
union = {
|
|
397
|
+
x,
|
|
398
|
+
y,
|
|
399
|
+
width: Math.max(union.x + union.width, box.x + box.width) - x,
|
|
400
|
+
height: Math.max(union.y + union.height, box.y + box.height) - y,
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if (!union)
|
|
406
|
+
throw new InputError(`family ${family} has no visible pixel`);
|
|
407
|
+
// The requesting spec's own values belong to the family it asked for.
|
|
408
|
+
const asked = record.spec !== undefined && (record.spec.writtenAs ?? record.spec.animationFamily) === family
|
|
409
|
+
? record.spec
|
|
410
|
+
: undefined;
|
|
411
|
+
const faced = facing ??
|
|
412
|
+
(asked?.action !== undefined && asked.facing !== undefined
|
|
413
|
+
? { action: asked.action, facing: asked.facing }
|
|
414
|
+
: undefined);
|
|
415
|
+
const spec = {
|
|
416
|
+
kind: "sprite-strip",
|
|
417
|
+
assetId: record.assetId,
|
|
418
|
+
...(record.subject !== undefined && { subject: record.subject }),
|
|
419
|
+
...(record.gait !== undefined && { gait: record.gait }),
|
|
420
|
+
animationFamily: family,
|
|
421
|
+
...(faced && { action: faced.action, facing: faced.facing }),
|
|
422
|
+
// The requesting spec's target fields (atlas slot, labels, semantics).
|
|
423
|
+
...(asked?.fields !== undefined && { fields: asked.fields }),
|
|
424
|
+
frames: {
|
|
425
|
+
count,
|
|
426
|
+
width: frame.width,
|
|
427
|
+
height: frame.height,
|
|
428
|
+
...(record.durationMs !== undefined && { durationMs: record.durationMs }),
|
|
429
|
+
},
|
|
430
|
+
anchor,
|
|
431
|
+
};
|
|
432
|
+
const fields = {
|
|
433
|
+
frames: spec.frames,
|
|
434
|
+
anchor,
|
|
435
|
+
bounds: union,
|
|
436
|
+
...(style.color.rule === "palette" && {
|
|
437
|
+
palette: style.color.palette.filter((hex) => usedColours.has(toHex(parseHex(hex)))),
|
|
438
|
+
}),
|
|
439
|
+
jitterPx,
|
|
440
|
+
};
|
|
441
|
+
return { spec, fields };
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* The spec a family of a sheet generated for `spec` hands off with, as `familyHandoff` builds it,
|
|
445
|
+
* with the values only known once the sheet is sliced (the family's name, frames and anchor)
|
|
446
|
+
* standing in. `generate-sheet` checks the layout against it before the sheet is paid for. The
|
|
447
|
+
* requesting spec's target fields count as set: they go to the family it asked for.
|
|
448
|
+
*/
|
|
449
|
+
export function familyHandoffStandIn(spec, profile) {
|
|
450
|
+
return {
|
|
451
|
+
kind: "sprite-strip",
|
|
452
|
+
assetId: spec.assetId,
|
|
453
|
+
...(spec.subject !== undefined && { subject: spec.subject }),
|
|
454
|
+
...(spec.gait !== undefined && { gait: spec.gait }),
|
|
455
|
+
animationFamily: spec.animationFamily ?? "family",
|
|
456
|
+
...(spec.action !== undefined &&
|
|
457
|
+
spec.facing !== undefined && { action: spec.action, facing: spec.facing }),
|
|
458
|
+
...(spec.fields !== undefined && { fields: spec.fields }),
|
|
459
|
+
frames: {
|
|
460
|
+
count: 1,
|
|
461
|
+
width: profile.frames.width,
|
|
462
|
+
height: profile.frames.height,
|
|
463
|
+
...(profile.frames.durationMs !== undefined && { durationMs: profile.frames.durationMs }),
|
|
464
|
+
},
|
|
465
|
+
anchor: { x: 0, y: 0 },
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* The confirmed family that receives the requesting spec's target fields (atlas slot, labels,
|
|
470
|
+
* semantics): the one named the spec's `animationFamily`; else, when the grouping has exactly one
|
|
471
|
+
* family with frames of its own, that one, with a note saying so. Any other grouping is refused,
|
|
472
|
+
* naming its families, so a manifest never loses its target fields silently. Sets
|
|
473
|
+
* `record.spec.writtenAs` when the fields go to another name. Undefined without a spec.
|
|
474
|
+
*/
|
|
475
|
+
export function specFamilyOf(record, grouping) {
|
|
476
|
+
const spec = record.spec;
|
|
477
|
+
if (spec === undefined)
|
|
478
|
+
return undefined;
|
|
479
|
+
const names = grouping.families.map((f) => f.name);
|
|
480
|
+
if (names.includes(spec.animationFamily)) {
|
|
481
|
+
delete spec.writtenAs;
|
|
482
|
+
return { name: spec.animationFamily };
|
|
483
|
+
}
|
|
484
|
+
const own = grouping.families.filter((f) => f.mirrorOf === undefined);
|
|
485
|
+
if (own.length === 1) {
|
|
486
|
+
const name = own[0].name;
|
|
487
|
+
spec.writtenAs = name;
|
|
488
|
+
return {
|
|
489
|
+
name,
|
|
490
|
+
note: `the spec asked for family "${spec.animationFamily}" and no confirmed family has that name, so its target fields go to "${name}", the grouping's one family with frames of its own`,
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
throw new InputError(`refused: the spec asked for family "${spec.animationFamily}", and no confirmed family has that name; ` +
|
|
494
|
+
`the confirmed families are ${names.map((n) => `"${n}"`).join(", ") || "none"}. ` +
|
|
495
|
+
`Rename the family the spec asked for to "${spec.animationFamily}" in grouping.json, so its target fields (${Object.keys(spec.fields ?? {}).join(", ") || "none"}) are written with it`);
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Writes each family of an author-confirmed grouping into the target: frames registered to one
|
|
499
|
+
* anchor and one common scale, checked against the jitter bound and the matte checks, as one strip
|
|
500
|
+
* with its manifest and per-frame provenance, review pending. Refuses before writing anything when
|
|
501
|
+
* the grouping is not confirmed or any family fails a check.
|
|
502
|
+
*/
|
|
503
|
+
export async function writeFamilies(options) {
|
|
504
|
+
const now = options.now ?? (() => new Date());
|
|
505
|
+
const bound = options.jitterBoundPx ?? DEFAULT_JITTER_BOUND_PX;
|
|
506
|
+
const record = await readImport(options.importDir);
|
|
507
|
+
if (record.identity?.filtered) {
|
|
508
|
+
throw new InputError(`refused: the identity lock filtered this sheet: ${record.identity.reason}`);
|
|
509
|
+
}
|
|
510
|
+
const ids = record.frames.map((f) => f.id);
|
|
511
|
+
const grouping = checkConfirmed(options.grouping, ids);
|
|
512
|
+
// The profile's motion templates and thresholds, and each family's declared template, are
|
|
513
|
+
// checked before anything is written. Writing makes no call: a family no grouping or spec
|
|
514
|
+
// declares a template for, no template is named for and no recorded decision (generate-sheet's)
|
|
515
|
+
// chose one for, is undecided (animation-qa decides it).
|
|
516
|
+
const templates = templatesFor(record.profile);
|
|
517
|
+
thresholdsFor(record.profile);
|
|
518
|
+
const declaredTemplates = new Map();
|
|
519
|
+
for (const f of grouping.families) {
|
|
520
|
+
const declared = f.template ?? ownValue(record.templates, f.name);
|
|
521
|
+
if (declared !== undefined)
|
|
522
|
+
declaredTemplates.set(f.name, declared);
|
|
523
|
+
}
|
|
524
|
+
const choices = new Map(grouping.families.map((f) => [
|
|
525
|
+
f.name,
|
|
526
|
+
templateWithoutCall(f.name, templates, declaredTemplates.get(f.name), ownValue(record.judgedTemplates, f.name)),
|
|
527
|
+
]));
|
|
528
|
+
const byId = new Map(record.frames.map((f) => [f.id, f]));
|
|
529
|
+
const specFamily = specFamilyOf(record, grouping);
|
|
530
|
+
const failedMatte = record.frames.filter((f) => f.checks.some((c) => !c.passed));
|
|
531
|
+
const plan = grouping.families.map((family) => ({
|
|
532
|
+
family,
|
|
533
|
+
...familyFrames(grouping, family.name),
|
|
534
|
+
}));
|
|
535
|
+
const used = new Set(plan.flatMap((p) => p.frames));
|
|
536
|
+
const badUsed = failedMatte.filter((f) => used.has(f.id));
|
|
537
|
+
if (badUsed.length > 0) {
|
|
538
|
+
throw new InputError(`refused: frames ${badUsed.map((f) => f.id).join(", ")} failed the background checks: ` +
|
|
539
|
+
badUsed
|
|
540
|
+
.flatMap((f) => f.checks.filter((c) => !c.passed).map((c) => `${f.id}: ${c.reason}`))
|
|
541
|
+
.join("; "));
|
|
542
|
+
}
|
|
543
|
+
const images = new Map();
|
|
544
|
+
const frameOrigins = new Map();
|
|
545
|
+
for (const id of used) {
|
|
546
|
+
const f = byId.get(id);
|
|
547
|
+
const bytes = new Uint8Array(await readFile(join(options.importDir, f.file)));
|
|
548
|
+
images.set(id, decodeImage(bytes));
|
|
549
|
+
frameOrigins.set(id, readDigitalSourceType(bytes, "image/png") ??
|
|
550
|
+
record.digitalSourceType ??
|
|
551
|
+
DIGITAL_SOURCE_TYPES.undeclared);
|
|
552
|
+
}
|
|
553
|
+
for (const origin of frameOrigins.values())
|
|
554
|
+
requireDeclared(origin);
|
|
555
|
+
const style = record.style;
|
|
556
|
+
const figures = [];
|
|
557
|
+
const families = [];
|
|
558
|
+
// Each family is pinned by the point its footprint rule keeps still: a planted family's feet, a
|
|
559
|
+
// moving family's centre of mass.
|
|
560
|
+
const pins = [];
|
|
561
|
+
const flipSteps = new Map();
|
|
562
|
+
for (const p of plan) {
|
|
563
|
+
let items = p.frames.map((id) => ({
|
|
564
|
+
name: `f${String(id).padStart(3, "0")}`,
|
|
565
|
+
raster: images.get(id),
|
|
566
|
+
mediaType: "image/png",
|
|
567
|
+
meta: {},
|
|
568
|
+
digitalSourceType: frameOrigins.get(id) ?? record.digitalSourceType ?? DIGITAL_SOURCE_TYPES.undeclared,
|
|
569
|
+
}));
|
|
570
|
+
if (p.mirrored) {
|
|
571
|
+
const flipped = runOperation(items, { op: "flip" }, { style });
|
|
572
|
+
flipSteps.set(p.family.name, flipped.step);
|
|
573
|
+
items = flipped.items;
|
|
574
|
+
}
|
|
575
|
+
figures.push(...items);
|
|
576
|
+
families.push(...items.map(() => p.family.name));
|
|
577
|
+
const pin = registrationPin(choices.get(p.family.name)?.template, record.profile, record.gait);
|
|
578
|
+
pins.push(...items.map(() => pin));
|
|
579
|
+
}
|
|
580
|
+
const registration = runOperation(figures, {
|
|
581
|
+
op: "register",
|
|
582
|
+
params: {
|
|
583
|
+
frame: record.frame,
|
|
584
|
+
anchor: record.anchor,
|
|
585
|
+
families,
|
|
586
|
+
pins,
|
|
587
|
+
...(record.scale !== undefined && { scale: record.scale }),
|
|
588
|
+
},
|
|
589
|
+
}, { style });
|
|
590
|
+
const commonScale = registration.step.report.scale;
|
|
591
|
+
let cursor = 0;
|
|
592
|
+
const staged = plan.map((p) => {
|
|
593
|
+
const registered = registration.items.slice(cursor, cursor + p.frames.length).map((item) => ({
|
|
594
|
+
item,
|
|
595
|
+
transforms: item.meta["transforms"],
|
|
596
|
+
jitterPx: item.meta["jitterPx"],
|
|
597
|
+
}));
|
|
598
|
+
cursor += p.frames.length;
|
|
599
|
+
const jitterPx = Math.max(...registered.map((r) => r.jitterPx));
|
|
600
|
+
return { ...p, registered, jitterPx };
|
|
601
|
+
});
|
|
602
|
+
const jittery = staged.filter((s) => s.jitterPx > bound);
|
|
603
|
+
if (jittery.length > 0) {
|
|
604
|
+
throw new InputError(`refused: registration jitter over the ${bound} px bound in ` +
|
|
605
|
+
jittery.map((s) => `${s.family.name} (${s.jitterPx.toFixed(2)} px)`).join(", "));
|
|
606
|
+
}
|
|
607
|
+
const { frame, anchor } = record;
|
|
608
|
+
const generationCalls = record.generation?.calls ?? [];
|
|
609
|
+
const calls = [...generationCalls, ...record.calls];
|
|
610
|
+
const unique = (values) => [...new Set(values)];
|
|
611
|
+
const at = now().toISOString();
|
|
612
|
+
const written = [];
|
|
613
|
+
const previews = [];
|
|
614
|
+
await mkdir(join(options.importDir, "preview"), { recursive: true });
|
|
615
|
+
const pending = [];
|
|
616
|
+
for (const s of staged) {
|
|
617
|
+
const count = s.registered.length;
|
|
618
|
+
const styled = runOperation(s.registered.map((r) => r.item), { op: "apply-style" }, { style });
|
|
619
|
+
const joined = runOperation(styled.items, { op: "join", params: { name: s.family.name } }, {
|
|
620
|
+
style,
|
|
621
|
+
});
|
|
622
|
+
// This family's own flip only; register runs over every family's frames at once.
|
|
623
|
+
const flip = flipSteps.get(s.family.name);
|
|
624
|
+
const familySteps = [...(flip ? [flip] : []), registration.step, styled.step, joined.step];
|
|
625
|
+
const strip = joined.items[0].raster;
|
|
626
|
+
const frameProvenance = [];
|
|
627
|
+
s.registered.forEach((r, i) => {
|
|
628
|
+
const id = s.frames[i];
|
|
629
|
+
const source = byId.get(id);
|
|
630
|
+
const styleSteps = [];
|
|
631
|
+
if (style.alpha.mode === "binary") {
|
|
632
|
+
styleSteps.push({ op: "binarize", threshold: style.alpha.threshold });
|
|
633
|
+
}
|
|
634
|
+
if (style.color.rule === "palette") {
|
|
635
|
+
styleSteps.push({ op: "quantize", palette: style.color.palette });
|
|
636
|
+
}
|
|
637
|
+
frameProvenance.push({
|
|
638
|
+
index: i,
|
|
639
|
+
frame: id,
|
|
640
|
+
cell: source.cell,
|
|
641
|
+
tool: record.sheet.tool,
|
|
642
|
+
sheetSha256: record.sheet.sha256,
|
|
643
|
+
transforms: [
|
|
644
|
+
...source.transforms,
|
|
645
|
+
...(s.mirrored ? [{ op: "mirror", axis: "vertical", of: s.family.mirrorOf }] : []),
|
|
646
|
+
...r.transforms,
|
|
647
|
+
...styleSteps,
|
|
648
|
+
],
|
|
649
|
+
});
|
|
650
|
+
});
|
|
651
|
+
const { spec, fields } = familyHandoff(record, s.family.name, strip, count, s.jitterPx, s.family.action && s.family.facing
|
|
652
|
+
? { action: s.family.action, facing: s.family.facing }
|
|
653
|
+
: undefined);
|
|
654
|
+
const digitalSourceType = joined.items[0]?.digitalSourceType ??
|
|
655
|
+
record.digitalSourceType ??
|
|
656
|
+
DIGITAL_SOURCE_TYPES.undeclared;
|
|
657
|
+
const bytes = embedDigitalSourceType(encodePng(strip), "image/png", digitalSourceType);
|
|
658
|
+
const prompt = record.generation?.prompt ??
|
|
659
|
+
`Imported from a contact sheet made with ${record.sheet.tool}; that tool's own prompt is not recorded.`;
|
|
660
|
+
const provenance = {
|
|
661
|
+
...(record.origin && { origin: parseOrigin(record.origin) }),
|
|
662
|
+
digitalSourceType,
|
|
663
|
+
...(record.sourceDeclaration && { sourceDeclaration: record.sourceDeclaration }),
|
|
664
|
+
generator: "sheet-import",
|
|
665
|
+
route: unique(calls.map((c) => c.route)).join(" + ") || `import:${record.sheet.tool}`,
|
|
666
|
+
models: unique([
|
|
667
|
+
...(record.generation ? [] : [record.sheet.tool]),
|
|
668
|
+
...calls.map((c) => c.model),
|
|
669
|
+
]),
|
|
670
|
+
prompt,
|
|
671
|
+
parameters: {
|
|
672
|
+
...(record.generation?.parameters ?? {}),
|
|
673
|
+
frame,
|
|
674
|
+
frameCount: count,
|
|
675
|
+
anchor,
|
|
676
|
+
style,
|
|
677
|
+
frames: s.frames,
|
|
678
|
+
...(s.family.mirrorOf !== undefined && { mirrorOf: s.family.mirrorOf }),
|
|
679
|
+
familyReason: s.family.reason,
|
|
680
|
+
commonScale,
|
|
681
|
+
jitterPx: s.jitterPx,
|
|
682
|
+
jitterBoundPx: bound,
|
|
683
|
+
importId: record.importId,
|
|
684
|
+
},
|
|
685
|
+
...(calls.find((c) => c.seed !== undefined)?.seed !== undefined && {
|
|
686
|
+
seed: calls.find((c) => c.seed !== undefined)?.seed,
|
|
687
|
+
}),
|
|
688
|
+
requestIds: calls.map((c) => c.requestId),
|
|
689
|
+
referenceHashes: unique(calls.flatMap((c) => c.referenceHashes)),
|
|
690
|
+
bibleVersion: record.bibleVersion,
|
|
691
|
+
...licenseFields(record.profile, calls),
|
|
692
|
+
providerTerms: unique(calls.flatMap((c) => (c.providerTerms !== undefined ? [c.providerTerms] : []))),
|
|
693
|
+
startedAt: calls[0]?.startedAt ?? record.createdAt,
|
|
694
|
+
finishedAt: calls[calls.length - 1]?.finishedAt ?? record.createdAt,
|
|
695
|
+
costUsd: calls.reduce((sum, c) => sum + c.costUsd, 0),
|
|
696
|
+
calls,
|
|
697
|
+
sheet: record.sheet,
|
|
698
|
+
...(record.identity && { identity: record.identity }),
|
|
699
|
+
frames: frameProvenance,
|
|
700
|
+
steps: [
|
|
701
|
+
...(record.steps ?? []),
|
|
702
|
+
...familySteps,
|
|
703
|
+
metadataStep(digitalSourceType, [pixelHash(strip)]),
|
|
704
|
+
],
|
|
705
|
+
};
|
|
706
|
+
const write = {
|
|
707
|
+
profile: record.profile,
|
|
708
|
+
spec,
|
|
709
|
+
bibleVersion: record.bibleVersion,
|
|
710
|
+
output: {
|
|
711
|
+
bytes,
|
|
712
|
+
mediaType: "image/png",
|
|
713
|
+
extension: "png",
|
|
714
|
+
fields,
|
|
715
|
+
},
|
|
716
|
+
provenance,
|
|
717
|
+
run: { runId: record.importId, candidateId: s.family.name, pickedAt: at },
|
|
718
|
+
targetDir: options.targetDir,
|
|
719
|
+
...(options.gate && { gate: options.gate }),
|
|
720
|
+
...(options.registry && { registry: options.registry }),
|
|
721
|
+
...(options.confirmation && { confirmation: options.confirmation }),
|
|
722
|
+
candidateReview: {
|
|
723
|
+
path: join(options.importDir, "reviews", `${s.family.name}.review.json`),
|
|
724
|
+
root: resolve(options.importDir),
|
|
725
|
+
},
|
|
726
|
+
now,
|
|
727
|
+
};
|
|
728
|
+
pending.push({ s, count, bytes, strip, digitalSourceType, write });
|
|
729
|
+
}
|
|
730
|
+
// Before the first family is written: no two families' writes name or reach one file, and each
|
|
731
|
+
// families-scope preset runs once, over every family of the asset (the library's and these).
|
|
732
|
+
const preparedWrites = await prepareTargetWrites(pending.map((p) => p.write));
|
|
733
|
+
for (const [i, { s, count, bytes, strip, digitalSourceType, write }] of pending.entries()) {
|
|
734
|
+
const prepared = preparedWrites[i];
|
|
735
|
+
const result = await commitTargetWrite(prepared);
|
|
736
|
+
const previewFile = `preview/${s.family.name}.png`;
|
|
737
|
+
await writeFile(join(options.importDir, previewFile), bytes);
|
|
738
|
+
const durationMs = record.durationMs ?? DEFAULT_DURATION_MS;
|
|
739
|
+
const stripFrames = splitStrip(strip, frame);
|
|
740
|
+
const animation = animationQa({
|
|
741
|
+
frames: stripFrames,
|
|
742
|
+
frame,
|
|
743
|
+
anchor,
|
|
744
|
+
family: s.family.name,
|
|
745
|
+
durationMs,
|
|
746
|
+
...(record.gait !== undefined && { gait: record.gait }),
|
|
747
|
+
// The edge-halo check measures each frame's fringe against the background its matte removed.
|
|
748
|
+
backgrounds: (write.provenance.frames ?? []).map((f) => matteBackground(f.transforms)),
|
|
749
|
+
}, record.profile, style, choices.get(s.family.name));
|
|
750
|
+
const rendered = renderPreviews(stripFrames, {
|
|
751
|
+
anchor,
|
|
752
|
+
loop: choiceLoops(choices.get(s.family.name) ?? UNDECIDED),
|
|
753
|
+
durationMs,
|
|
754
|
+
report: animation,
|
|
755
|
+
digitalSourceType,
|
|
756
|
+
});
|
|
757
|
+
const onionPath = join(options.importDir, "preview", `${s.family.name}.onion.png`);
|
|
758
|
+
const loopPreviewPath = join(options.importDir, "preview", `${s.family.name}.webp`);
|
|
759
|
+
await writeFile(onionPath, rendered.onion);
|
|
760
|
+
await writeFile(loopPreviewPath, rendered.preview);
|
|
761
|
+
previews.push({ name: s.family.name, file: previewFile, count, jitterPx: s.jitterPx });
|
|
762
|
+
written.push({
|
|
763
|
+
name: s.family.name,
|
|
764
|
+
frames: s.frames,
|
|
765
|
+
mirrored: s.mirrored,
|
|
766
|
+
jitterPx: s.jitterPx,
|
|
767
|
+
...(specFamily?.note !== undefined &&
|
|
768
|
+
specFamily.name === s.family.name && { fieldsNote: specFamily.note }),
|
|
769
|
+
result,
|
|
770
|
+
animation,
|
|
771
|
+
onionPath,
|
|
772
|
+
loopPreviewPath,
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
const previewPath = join(options.importDir, PREVIEW_FILE);
|
|
776
|
+
await writeFile(previewPath, previewHtml(previews, frame, record.durationMs ?? 120));
|
|
777
|
+
record.scale ??= commonScale;
|
|
778
|
+
record.written = [
|
|
779
|
+
...(record.written ?? []),
|
|
780
|
+
{
|
|
781
|
+
at,
|
|
782
|
+
target: resolve(options.targetDir),
|
|
783
|
+
families: written.map((w) => w.name),
|
|
784
|
+
files: written.flatMap((w) => w.result.files),
|
|
785
|
+
frames: Object.fromEntries(written.map((w) => [w.name, w.frames])),
|
|
786
|
+
...(grouping.families.some((f) => f.template !== undefined) && {
|
|
787
|
+
templates: Object.fromEntries(grouping.families.flatMap((f) => f.template !== undefined ? [[f.name, f.template]] : [])),
|
|
788
|
+
}),
|
|
789
|
+
...(written.some((w) => w.animation.pending?.length) && {
|
|
790
|
+
pending: Object.fromEntries(written.flatMap((w) => w.animation.pending?.length
|
|
791
|
+
? [[w.name, w.animation.pending.map((p) => p.check)]]
|
|
792
|
+
: [])),
|
|
793
|
+
}),
|
|
794
|
+
},
|
|
795
|
+
];
|
|
796
|
+
await writeImport(options.importDir, record);
|
|
797
|
+
return { families: written, previewPath };
|
|
798
|
+
}
|
|
799
|
+
function escapeHtml(text) {
|
|
800
|
+
return text.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
801
|
+
}
|
|
802
|
+
/** A looping preview page: each strip animated with CSS steps at the frame duration. */
|
|
803
|
+
export function previewHtml(strips, frame, durationMs) {
|
|
804
|
+
const zoom = Math.max(1, Math.floor(192 / Math.max(frame.width, frame.height)));
|
|
805
|
+
const w = frame.width * zoom;
|
|
806
|
+
const h = frame.height * zoom;
|
|
807
|
+
const rows = strips.map((s, i) => {
|
|
808
|
+
const total = s.count * durationMs;
|
|
809
|
+
return [
|
|
810
|
+
`<figure>`,
|
|
811
|
+
`<div class="sprite" style="width:${w}px;height:${h}px;background-image:url('${escapeHtml(s.file)}');background-size:${w * s.count}px ${h}px;animation:play${i} ${total}ms steps(${s.count}) infinite"></div>`,
|
|
812
|
+
`<figcaption>${escapeHtml(s.name)}: ${s.count} frames, jitter ${s.jitterPx.toFixed(2)} px</figcaption>`,
|
|
813
|
+
`<style>@keyframes play${i}{from{background-position:0 0}to{background-position:-${w * s.count}px 0}}</style>`,
|
|
814
|
+
`</figure>`,
|
|
815
|
+
].join("");
|
|
816
|
+
});
|
|
817
|
+
return [
|
|
818
|
+
"<!doctype html>",
|
|
819
|
+
'<meta charset="utf-8">',
|
|
820
|
+
"<title>Assetgrove sheet import preview</title>",
|
|
821
|
+
"<style>body{font-family:sans-serif;background:#888;display:flex;flex-wrap:wrap;gap:16px}.sprite{image-rendering:pixelated;background-repeat:no-repeat;background-color:#bbb}</style>",
|
|
822
|
+
...rows,
|
|
823
|
+
"",
|
|
824
|
+
].join("\n");
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* A family's own entry in a record's map, never an inherited one: a family named `constructor`
|
|
828
|
+
* or `toString` has no entry unless the record wrote one.
|
|
829
|
+
*/
|
|
830
|
+
function ownValue(map, family) {
|
|
831
|
+
return map !== undefined && Object.hasOwn(map, family) ? map[family] : undefined;
|
|
832
|
+
}
|