@photivra/engine 1.0.1 → 1.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.
Files changed (244) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CITATION.cff +1 -1
  3. package/NOTICE +29 -0
  4. package/README.md +8 -6
  5. package/THIRD_PARTY.md +10 -0
  6. package/dist/core/version.d.ts +1 -1
  7. package/dist/core/version.js +1 -1
  8. package/dist/index.d.ts +10 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +5 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/optics/complex-pupil-psf.d.ts +6 -0
  13. package/dist/optics/complex-pupil-psf.d.ts.map +1 -1
  14. package/dist/optics/complex-pupil-psf.js +10 -7
  15. package/dist/optics/complex-pupil-psf.js.map +1 -1
  16. package/dist/output/native-capture-sdr.d.ts +78 -0
  17. package/dist/output/native-capture-sdr.d.ts.map +1 -0
  18. package/dist/output/native-capture-sdr.js +171 -0
  19. package/dist/output/native-capture-sdr.js.map +1 -0
  20. package/dist/output/print-contrast-reference.d.ts +47 -0
  21. package/dist/output/print-contrast-reference.d.ts.map +1 -0
  22. package/dist/output/print-contrast-reference.js +95 -0
  23. package/dist/output/print-contrast-reference.js.map +1 -0
  24. package/dist/output/print-detail.d.ts +113 -0
  25. package/dist/output/print-detail.d.ts.map +1 -0
  26. package/dist/output/print-detail.js +224 -0
  27. package/dist/output/print-detail.js.map +1 -0
  28. package/dist/output/print-plan.d.ts +138 -0
  29. package/dist/output/print-plan.d.ts.map +1 -0
  30. package/dist/output/print-plan.js +305 -0
  31. package/dist/output/print-plan.js.map +1 -0
  32. package/dist/output/print-region-statistics.d.ts +92 -0
  33. package/dist/output/print-region-statistics.d.ts.map +1 -0
  34. package/dist/output/print-region-statistics.js +300 -0
  35. package/dist/output/print-region-statistics.js.map +1 -0
  36. package/docs/API_REFERENCE.md +89 -1
  37. package/docs/API_STYLE.md +1 -1
  38. package/docs/ARCHITECTURE.md +1 -1
  39. package/docs/AUTOMATION_COORDINATION.md +1 -1
  40. package/docs/CAPTURE_COLOR.md +1 -1
  41. package/docs/CAPTURE_CORRECTED_SDR.md +1 -1
  42. package/docs/CAPTURE_EXPORT_METADATA.md +1 -1
  43. package/docs/CAPTURE_SDR.md +3 -1
  44. package/docs/DEVELOPERS.md +12 -4
  45. package/docs/DIGITAL_OPTICS_FOUNDATION.md +1 -1
  46. package/docs/ENVIRONMENT_RAW_CAPTURE.md +1 -1
  47. package/docs/EXPORT_ACCEPTANCE.md +1 -1
  48. package/docs/GENERIC_TIER_PRESETS.md +1 -1
  49. package/docs/GEOMETRIC_PREPARATION_REUSE.md +1 -1
  50. package/docs/IMAGE_FORMATION.md +1 -1
  51. package/docs/LINEAR_CAPTURE_ENCODING.md +1 -1
  52. package/docs/MOTION_AND_SIGNAL.md +1 -1
  53. package/docs/NATIVE_CAPTURE_SDR.md +70 -0
  54. package/docs/NATIVE_CAPTURE_SDR_REVIEW.md +37 -0
  55. package/docs/NATIVE_CAPTURE_SDR_VALIDATION.md +34 -0
  56. package/docs/NUMERICAL_CORRECTNESS.md +1 -1
  57. package/docs/PERFORMANCE_BASELINE.md +1 -1
  58. package/docs/PHOTOGRAPHIC_EXPORT.md +1 -1
  59. package/docs/PHYSICS_FOUNDATION.md +1 -1
  60. package/docs/POC_API.md +1 -1
  61. package/docs/POC_PROJECTION_PLATFORM_REFERENCE.md +12 -0
  62. package/docs/POC_PROJECTION_REUSE.md +1 -1
  63. package/docs/PRINT_195_196_REVIEW.md +93 -0
  64. package/docs/PRINT_196_ENGINE_ACCEPTANCE.md +45 -0
  65. package/docs/PRINT_CONTRAST_REFERENCE.md +43 -0
  66. package/docs/PRINT_DETAIL_ASSESSMENT.md +81 -0
  67. package/docs/PRINT_DETAIL_JPEG_EVIDENCE.md +36 -0
  68. package/docs/PRINT_DETAIL_SDR_EVIDENCE.md +29 -0
  69. package/docs/PRINT_DETAIL_VALIDATION.md +36 -0
  70. package/docs/PRINT_PLANNING.md +75 -0
  71. package/docs/PRINT_REGION_STATISTICS.md +38 -0
  72. package/docs/PROCESSED_OUTPUT.md +1 -1
  73. package/docs/PRODUCTION_COMPOSITION.md +1 -1
  74. package/docs/PRODUCTION_ENVIRONMENT_CAPTURE.md +1 -1
  75. package/docs/PROVENANCE.md +1 -1
  76. package/docs/PSF_FOUNDATION.md +11 -1
  77. package/docs/RAW_FRAME_ENVELOPE.md +1 -1
  78. package/docs/RAW_FRAME_RECONSTRUCTION.md +1 -1
  79. package/docs/RELEASE_1_1_0.md +25 -0
  80. package/docs/RELEASE_1_2_0.md +51 -0
  81. package/docs/SCENE_RADIANCE_AND_ILLUMINATION.md +1 -1
  82. package/docs/SCENE_SENSOR_QUADRATURE.md +1 -1
  83. package/docs/SCENE_SENSOR_TEMPORAL_EXPOSURE.md +1 -1
  84. package/docs/SCIENTIFIC_ASSURANCE.md +1 -1
  85. package/docs/SCIENTIFIC_CONFORMANCE.md +1 -1
  86. package/docs/SDR_RENDERING.md +1 -1
  87. package/docs/SENSOR_ENVIRONMENT_QUERY.md +1 -1
  88. package/docs/SENSOR_EQE_LOCAL_EXPOSURE.md +1 -1
  89. package/docs/SENSOR_EQE_TEMPORAL_EXPOSURE.md +1 -1
  90. package/docs/SENSOR_PSF_QUADRATURE.md +1 -1
  91. package/docs/SENSOR_RAW_FRAME.md +1 -1
  92. package/docs/SENSOR_RAW_PRODUCER.md +1 -1
  93. package/docs/SIGNAL_CONFORMANCE.md +1 -1
  94. package/docs/SIMULATED_CAPTURE.md +1 -1
  95. package/docs/STABILIZATION.md +1 -1
  96. package/docs/TEMPORAL_PHOTO_RAW.md +1 -1
  97. package/docs/TIER_ACCEPTANCE.md +1 -1
  98. package/docs/TIER_PRESET_ACCEPTANCE.md +1 -1
  99. package/docs/USAGE.md +9 -1
  100. package/docs/V1_COMPOSITION_MAP.md +1 -1
  101. package/docs/V1_HELPER_REUSE_REVIEW.md +1 -1
  102. package/docs/V1_PERFORMANCE_DISPOSITION.md +1 -1
  103. package/docs/api/camera-equivalent-focal-length.md +1 -1
  104. package/docs/api/camera-field-of-view.md +1 -1
  105. package/docs/api/camera-projected-object-size.md +1 -1
  106. package/docs/api/capture-capture-export-metadata.md +1 -1
  107. package/docs/api/capture-environment-raw-producer.md +1 -1
  108. package/docs/api/capture-focus-control.md +1 -1
  109. package/docs/api/capture-linear-encoding.md +1 -1
  110. package/docs/api/capture-photographic-export.md +1 -1
  111. package/docs/api/capture-raw-frame-reconstruction.md +1 -1
  112. package/docs/api/capture-release-sequence.md +1 -1
  113. package/docs/api/capture-sensor-raw-frame.md +1 -1
  114. package/docs/api/capture-sensor-raw-producer.md +1 -1
  115. package/docs/api/capture-simulated-capture.md +1 -1
  116. package/docs/api/color-capture-color.md +1 -1
  117. package/docs/api/color-white-balance.md +1 -1
  118. package/docs/api/composition-image-formation-plan.md +1 -1
  119. package/docs/api/composition-plan-consumer.md +1 -1
  120. package/docs/api/core-calculation-result.md +1 -1
  121. package/docs/api/core-configuration-error.md +1 -1
  122. package/docs/api/core-image-formation.md +1 -1
  123. package/docs/api/core-scientific-assurance.md +1 -1
  124. package/docs/api/core-spectral-composition.md +1 -1
  125. package/docs/api/core-spectral.md +1 -1
  126. package/docs/api/core-validation.md +1 -1
  127. package/docs/api/core-version.md +2 -2
  128. package/docs/api/equipment-exposure-capabilities.md +1 -1
  129. package/docs/api/equipment-generic-tier-assets.md +1 -1
  130. package/docs/api/equipment-generic-tier-presets.md +1 -1
  131. package/docs/api/equipment-iso-capabilities.md +1 -1
  132. package/docs/api/equipment-metering-capabilities.md +1 -1
  133. package/docs/api/equipment-release-capabilities.md +1 -1
  134. package/docs/api/exports.json +267 -2
  135. package/docs/api/exposure-exposure-duration-control.md +1 -1
  136. package/docs/api/exposure-exposure-mode-resolver.md +1 -1
  137. package/docs/api/exposure-exposure.md +1 -1
  138. package/docs/api/exposure-flash.md +1 -1
  139. package/docs/api/exposure-metering-scene-radiance.md +1 -1
  140. package/docs/api/exposure-metering-target.md +1 -1
  141. package/docs/api/exposure-metering-temporal.md +1 -1
  142. package/docs/api/exposure-metering.md +1 -1
  143. package/docs/api/exposure-program-line.md +1 -1
  144. package/docs/api/motion-camera-rotation.md +1 -1
  145. package/docs/api/motion-capture-rotation-inverse-mapping.md +1 -1
  146. package/docs/api/motion-capture-rotation-temporal-quadrature.md +1 -1
  147. package/docs/api/motion-capture-rotation-trajectory.md +1 -1
  148. package/docs/api/motion-capture-translation-parallax-temporal-quadrature.md +1 -1
  149. package/docs/api/motion-extended-object-projection.md +1 -1
  150. package/docs/api/motion-projected-motion.md +1 -1
  151. package/docs/api/optics-aperture.md +1 -1
  152. package/docs/api/optics-circle-of-confusion.md +1 -1
  153. package/docs/api/optics-complex-pupil-psf.md +7 -1
  154. package/docs/api/optics-depth-of-field.md +1 -1
  155. package/docs/api/optics-diffraction.md +1 -1
  156. package/docs/api/optics-focus-breathing.md +1 -1
  157. package/docs/api/optics-focus-state.md +1 -1
  158. package/docs/api/optics-front-of-lens-filter.md +1 -1
  159. package/docs/api/optics-illumination-vignetting.md +1 -1
  160. package/docs/api/optics-lateral-chromatic-aberration.md +1 -1
  161. package/docs/api/optics-lens-psf-profile.md +1 -1
  162. package/docs/api/optics-polygon-diffraction.md +1 -1
  163. package/docs/api/optics-profile-contract.md +1 -1
  164. package/docs/api/optics-psf-foundation.md +1 -1
  165. package/docs/api/optics-radial-distortion.md +1 -1
  166. package/docs/api/optics-scene-to-sensor-irradiance.md +1 -1
  167. package/docs/api/optics-scene-to-sensor-quadrature.md +1 -1
  168. package/docs/api/optics-sensor-environment-query.md +1 -1
  169. package/docs/api/optics-sensor-psf-quadrature.md +1 -1
  170. package/docs/api/optics-stray-light.md +1 -1
  171. package/docs/api/optics-thin-lens.md +1 -1
  172. package/docs/api/output-capture-corrected-sdr.md +1 -1
  173. package/docs/api/output-capture-geometry.md +1 -1
  174. package/docs/api/output-capture-sdr.md +1 -1
  175. package/docs/api/output-crop.md +1 -1
  176. package/docs/api/output-geometric-transforms.md +1 -1
  177. package/docs/api/output-lens-corrections.md +1 -1
  178. package/docs/api/output-native-capture-sdr.md +150 -0
  179. package/docs/api/output-print-contrast-reference.md +82 -0
  180. package/docs/api/output-print-detail.md +147 -0
  181. package/docs/api/output-print-plan.md +165 -0
  182. package/docs/api/output-print-region-statistics.md +165 -0
  183. package/docs/api/output-sdr-rendering.md +1 -1
  184. package/docs/api/output-subject-framing-crop.md +1 -1
  185. package/docs/api/schema-camera.md +1 -1
  186. package/docs/api/schema-illumination-spectral.md +1 -1
  187. package/docs/api/schema-illumination-temporal.md +1 -1
  188. package/docs/api/schema-illumination.md +1 -1
  189. package/docs/api/schema-scene-radiance-temporal.md +1 -1
  190. package/docs/api/schema-scene-radiance.md +1 -1
  191. package/docs/api/schema-scene.md +1 -1
  192. package/docs/api/schema-validation.md +1 -1
  193. package/docs/api/sensor-accumulated-charge.md +1 -1
  194. package/docs/api/sensor-architecture.md +1 -1
  195. package/docs/api/sensor-camera-saturation-capacity.md +1 -1
  196. package/docs/api/sensor-capture-color-sampling-binding.md +1 -1
  197. package/docs/api/sensor-capture-mode-timing.md +1 -1
  198. package/docs/api/sensor-capture-mode.md +1 -1
  199. package/docs/api/sensor-color-sampling.md +1 -1
  200. package/docs/api/sensor-constant-rate-temporal-integration.md +1 -1
  201. package/docs/api/sensor-dark-current.md +1 -1
  202. package/docs/api/sensor-environment-photo-signal.md +1 -1
  203. package/docs/api/sensor-eqe-electron-rate.md +1 -1
  204. package/docs/api/sensor-eqe-local-exposure.md +1 -1
  205. package/docs/api/sensor-eqe-temporal-exposure.md +1 -1
  206. package/docs/api/sensor-exposure-window.md +1 -1
  207. package/docs/api/sensor-iso-signal-chain.md +1 -1
  208. package/docs/api/sensor-local-exposure-binding.md +1 -1
  209. package/docs/api/sensor-optical-stack.md +1 -1
  210. package/docs/api/sensor-photon-energy.md +1 -1
  211. package/docs/api/sensor-physical-charge-capacity.md +1 -1
  212. package/docs/api/sensor-pixel-pitch.md +1 -1
  213. package/docs/api/sensor-radiometry-readiness.md +1 -1
  214. package/docs/api/sensor-raw-readout.md +1 -1
  215. package/docs/api/sensor-raw-reconstruction.md +1 -1
  216. package/docs/api/sensor-readout-exposure-linkage.md +1 -1
  217. package/docs/api/sensor-readout-timing.md +1 -1
  218. package/docs/api/sensor-response-application-compatibility.md +1 -1
  219. package/docs/api/sensor-response-operating-range.md +1 -1
  220. package/docs/api/sensor-responsivity-photocurrent.md +1 -1
  221. package/docs/api/sensor-sampling-aperture.md +1 -1
  222. package/docs/api/sensor-scene-eqe-temporal-exposure.md +1 -1
  223. package/docs/api/sensor-sensor-geometry.md +1 -1
  224. package/docs/api/sensor-signal-noise.md +1 -1
  225. package/docs/api/sensor-spatial-sample-reduction.md +1 -1
  226. package/docs/api/sensor-spatial-sampling-quadrature.md +1 -1
  227. package/docs/api/sensor-spatio-spectral-reduction.md +1 -1
  228. package/docs/api/sensor-spectral-coverage.md +1 -1
  229. package/docs/api/sensor-spectral-quadrature.md +1 -1
  230. package/docs/api/sensor-spectral-response.md +1 -1
  231. package/docs/api/sensor-temporal-photo-signal.md +1 -1
  232. package/docs/api/simulation-poc-simulation.md +1 -1
  233. package/docs/api/stabilization-camera-shake.md +1 -1
  234. package/docs/api/stabilization-system.md +1 -1
  235. package/docs/licenses/castleCSF-MIT.txt +21 -0
  236. package/docs/validation/native-capture-sdr-darwin-arm64-node26-review.jsonl +4 -0
  237. package/docs/validation/native-capture-sdr-darwin-arm64.jsonl +3 -0
  238. package/docs/validation/print-196-candidate-capabilities.json +28 -0
  239. package/docs/validation/print-196-candidate-evidence.json +356 -0
  240. package/docs/validation/print-196-engine-acceptance.json +81 -0
  241. package/docs/validation/print-detail-capabilities.json +103 -0
  242. package/docs/validation/print-detail-jpeg-evidence.json +116 -0
  243. package/docs/validation/print-detail-sdr-evidence.json +81 -0
  244. package/package.json +1 -1
@@ -0,0 +1,305 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /** Native-only print geometry. No image generation or perceived-quality certification.
3
+ * @see docs/PRINT_PLANNING.md for equations, rounding and support limits.
4
+ */
5
+ import { calculatedResult, approximationResult } from "../core/calculation-result.js";
6
+ import { InvalidConfigurationError } from "../core/configuration-error.js";
7
+ import { requireAllowlistedRecord, requirePublicOpaqueId } from "../core/record-validation.js";
8
+ import { requirePositiveFinite, requirePositiveInteger } from "../core/validation.js";
9
+ import { ENGINE_API_VERSION } from "../core/version.js";
10
+ import { resolveCaptureGeometry } from "./capture-geometry.js";
11
+ const UNIT_MM = { mm: 1, cm: 10, inches: 25.4, m: 1000 };
12
+ const RAD_PER_ARCMIN = Math.PI / 10800;
13
+ function record(value, keys) {
14
+ return requireAllowlistedRecord(value, keys, "Invalid or unknown Print planning fields.");
15
+ }
16
+ function number(value, name) {
17
+ if (typeof value !== "number")
18
+ throw new InvalidConfigurationError(`${name} must be numeric.`);
19
+ requirePositiveFinite(name, value);
20
+ return value;
21
+ }
22
+ function unit(value) {
23
+ if (typeof value !== "string" || !Object.hasOwn(UNIT_MM, value))
24
+ throw new InvalidConfigurationError("Invalid Print length unit.");
25
+ return value;
26
+ }
27
+ function length(value) {
28
+ const r = record(value, ["value", "unit"]);
29
+ return { value: number(r.value, "length.value"), unit: unit(r.unit) };
30
+ }
31
+ function raster(value) {
32
+ const r = record(value, ["pixelWidth", "pixelHeight"]);
33
+ const pixelWidth = number(r.pixelWidth, "pixelWidth"), pixelHeight = number(r.pixelHeight, "pixelHeight");
34
+ requirePositiveInteger("pixelWidth", pixelWidth);
35
+ requirePositiveInteger("pixelHeight", pixelHeight);
36
+ return { pixelWidth, pixelHeight };
37
+ }
38
+ function geometry(value) {
39
+ const g = record(value, ["imagingArea", "nativeRaster", "orientation", "activeCaptureRect", "outputCropRect", "outputRaster"]);
40
+ record(g.imagingArea, ["widthMm", "heightMm"]);
41
+ raster(g.nativeRaster);
42
+ for (const key of ["activeCaptureRect", "outputCropRect"]) {
43
+ if (g[key] !== undefined)
44
+ record(g[key], ["x", "y", "width", "height"]);
45
+ }
46
+ if (g.outputRaster !== undefined)
47
+ raster(g.outputRaster);
48
+ // Existing geometry owns units, orientations, bounds and optical-axis semantics.
49
+ const parsed = g;
50
+ resolveCaptureGeometry(parsed);
51
+ return structuredCloneGeometry(parsed);
52
+ }
53
+ function structuredCloneGeometry(g) {
54
+ return { imagingArea: { ...g.imagingArea }, nativeRaster: { ...g.nativeRaster }, orientation: g.orientation,
55
+ ...(g.activeCaptureRect === undefined ? {} : { activeCaptureRect: { ...g.activeCaptureRect } }),
56
+ ...(g.outputCropRect === undefined ? {} : { outputCropRect: { ...g.outputCropRect } }),
57
+ ...(g.outputRaster === undefined ? {} : { outputRaster: { ...g.outputRaster } }) };
58
+ }
59
+ function sampling(value) {
60
+ const tag = record(value, ["kind", "maximumArcminutesPerPixel", "strokeWidthArcminutes", "samplesPerStroke", "periodArcminutes", "samplesPerPeriod", "pixelsPerInch"]);
61
+ let result;
62
+ switch (tag.kind) {
63
+ case "manual-ppi": {
64
+ const r = record(value, ["kind", "pixelsPerInch"]);
65
+ return { kind: "manual-ppi", pixelsPerInch: number(r.pixelsPerInch, "pixelsPerInch") };
66
+ }
67
+ case "angular-pixel-pitch": {
68
+ const r = record(value, ["kind", "maximumArcminutesPerPixel"]);
69
+ result = { kind: "angular-pixel-pitch", maximumArcminutesPerPixel: number(r.maximumArcminutesPerPixel, "maximumArcminutesPerPixel") };
70
+ break;
71
+ }
72
+ case "angular-stroke": {
73
+ const r = record(value, ["kind", "strokeWidthArcminutes", "samplesPerStroke"]);
74
+ const samplesPerStroke = number(r.samplesPerStroke, "samplesPerStroke");
75
+ requirePositiveInteger("samplesPerStroke", samplesPerStroke);
76
+ result = { kind: "angular-stroke", strokeWidthArcminutes: number(r.strokeWidthArcminutes, "strokeWidthArcminutes"), samplesPerStroke };
77
+ break;
78
+ }
79
+ case "angular-line-pair": {
80
+ const r = record(value, ["kind", "periodArcminutes", "samplesPerPeriod"]);
81
+ const samplesPerPeriod = number(r.samplesPerPeriod, "samplesPerPeriod");
82
+ requirePositiveInteger("samplesPerPeriod", samplesPerPeriod);
83
+ if (samplesPerPeriod < 2)
84
+ throw new InvalidConfigurationError("A line-pair period requires at least two samples.");
85
+ result = { kind: "angular-line-pair", periodArcminutes: number(r.periodArcminutes, "periodArcminutes"), samplesPerPeriod };
86
+ break;
87
+ }
88
+ default: throw new InvalidConfigurationError("Invalid Print sampling convention.");
89
+ }
90
+ const angle = angularLimit(result);
91
+ if (angle <= 0 || angle >= 10800)
92
+ throw new InvalidConfigurationError("Effective angular pixel pitch must lie in (0, 10800) arcminutes.");
93
+ return result;
94
+ }
95
+ function angularLimit(s) {
96
+ switch (s.kind) {
97
+ case "angular-pixel-pitch": return s.maximumArcminutesPerPixel;
98
+ case "angular-stroke": return s.strokeWidthArcminutes / s.samplesPerStroke;
99
+ case "angular-line-pair": return s.periodArcminutes / s.samplesPerPeriod;
100
+ }
101
+ }
102
+ /** Validate and copy an untrusted Print request; never infer native authority. */
103
+ export function parsePrintPlanInput(value) {
104
+ const r = record(value, ["source", "printedImage", "viewingDistance", "sampling", "fit", "provider"]);
105
+ const source = record(r.source, ["kind", "captureId", "geometry", "reason"]);
106
+ let parsedSource;
107
+ if (source.kind === "native-retained") {
108
+ record(r.source, ["kind", "captureId", "geometry"]);
109
+ parsedSource = { kind: "native-retained", captureId: requirePublicOpaqueId(source.captureId, "Invalid public capture ID."), geometry: geometry(source.geometry) };
110
+ }
111
+ else if (source.kind === "unavailable") {
112
+ record(r.source, ["kind", "reason"]);
113
+ if (source.reason !== "missing-native-raster" && source.reason !== "unverified-native-identity")
114
+ throw new InvalidConfigurationError("Invalid native-unavailable reason.");
115
+ parsedSource = { kind: "unavailable", reason: source.reason };
116
+ }
117
+ else
118
+ throw new InvalidConfigurationError("Invalid native source kind.");
119
+ const image = record(r.printedImage, ["width", "height", "unit"]);
120
+ const fit = record(r.fit, ["kind", "maximumRelativeAspectError"]);
121
+ if (fit.kind !== "confirmed-native-aspect" || typeof fit.maximumRelativeAspectError !== "number" || !Number.isFinite(fit.maximumRelativeAspectError) || fit.maximumRelativeAspectError < 0 || fit.maximumRelativeAspectError > 0.01)
122
+ throw new InvalidConfigurationError("Declare a native-aspect fit tolerance in [0, 0.01].");
123
+ const parsed = { source: parsedSource, printedImage: { width: number(image.width, "printedImage.width"), height: number(image.height, "printedImage.height"), unit: unit(image.unit) }, viewingDistance: length(r.viewingDistance), sampling: sampling(r.sampling), fit: { kind: "confirmed-native-aspect", maximumRelativeAspectError: fit.maximumRelativeAspectError } };
124
+ if (r.provider !== undefined) {
125
+ const p = record(r.provider, ["minimumRaster", "exactRaster", "minimumPpi", "exactPpi"]);
126
+ parsed.provider = {
127
+ ...(p.minimumRaster === undefined ? {} : { minimumRaster: raster(p.minimumRaster) }),
128
+ ...(p.exactRaster === undefined ? {} : { exactRaster: raster(p.exactRaster) }),
129
+ ...(p.minimumPpi === undefined ? {} : { minimumPpi: number(p.minimumPpi, "minimumPpi") }),
130
+ ...(p.exactPpi === undefined ? {} : { exactPpi: number(p.exactPpi, "exactPpi") })
131
+ };
132
+ }
133
+ return parsed;
134
+ }
135
+ function gcd(a, b) { while (b !== 0) {
136
+ const next = a % b;
137
+ a = b;
138
+ b = next;
139
+ } return a; }
140
+ function positiveSupported(...values) { return values.every(v => Number.isFinite(v) && v > 0); }
141
+ // Adjacent binary64 values implement outward rounding, not a criterion epsilon.
142
+ function adjacentPositive(value, direction) {
143
+ const view = new DataView(new ArrayBuffer(8));
144
+ view.setFloat64(0, value);
145
+ view.setBigUint64(0, view.getBigUint64(0) + (direction === "up" ? 1n : -1n));
146
+ return view.getFloat64(0);
147
+ }
148
+ function exactRatio(a, b) {
149
+ return BigInt(a.pixelWidth) * BigInt(b.pixelHeight) === BigInt(a.pixelHeight) * BigInt(b.pixelWidth);
150
+ }
151
+ function minimumRaster(native, width, height) {
152
+ const divisor = gcd(native.pixelWidth, native.pixelHeight);
153
+ const x = native.pixelWidth / divisor, y = native.pixelHeight / divisor;
154
+ const count = Math.max(1, Math.ceil(width / x), Math.ceil(height / y));
155
+ const pixelWidth = count * x, pixelHeight = count * y;
156
+ return Number.isSafeInteger(pixelWidth) && Number.isSafeInteger(pixelHeight) ? { pixelWidth, pixelHeight } : null;
157
+ }
158
+ function diagnostics(raster, width, height, distance) {
159
+ const px = width / raster.pixelWidth, py = height / raster.pixelHeight;
160
+ return { raster, pixelsPerInch: { x: 25.4 / px, y: 25.4 / py }, angularPixelPitchArcminutes: { x: 2 * Math.atan((px / distance) / 2) / RAD_PER_ARCMIN, y: 2 * Math.atan((py / distance) / 2) / RAD_PER_ARCMIN } };
161
+ }
162
+ /** Resolve the minimum exact-native-ratio file under declared sampling/lab constraints.
163
+ * Angular guidance is approximate as a usage criterion; geometry is calculated.
164
+ * No source detail, perceived quality, serializer or resource availability is assessed.
165
+ */
166
+ export function calculatePrintPlan(value) {
167
+ const input = parsePrintPlanInput(value);
168
+ const plan = { engineApiVersion: ENGINE_API_VERSION, input, status: "cannot-assess", nativePixelSufficiency: "cannot-assess", reasons: [], printedImageMm: null, viewingDistanceMm: null, guidance: null, relativeAspectError: null, native: null, minimumSamplingRaster: null, recommended: null, resamplingScale: null, alternatives: null, capturedDetailAssessment: "unassessed", deliveryAssessment: "unassessed" };
169
+ const finish = () => calculatedResult(plan, "native-only-print-plan", "0.1.0", ["Declared native authority; flat image, normal viewing at image center.", "Output preserves the exact retained native aspect ratio; no upscale.", "Angular sampling is conditional guidance, not captured-detail or print-quality certification."]);
170
+ const unsupported = () => { plan.status = "unsupported"; plan.nativePixelSufficiency = "cannot-assess"; plan.reasons.push("unsupported-numeric-range"); return finish(); };
171
+ const width = input.printedImage.width * UNIT_MM[input.printedImage.unit], height = input.printedImage.height * UNIT_MM[input.printedImage.unit], distance = input.viewingDistance.value * UNIT_MM[input.viewingDistance.unit];
172
+ if (!positiveSupported(width, height, distance))
173
+ return unsupported();
174
+ plan.printedImageMm = { width, height };
175
+ plan.viewingDistanceMm = distance;
176
+ const angle = input.sampling.kind === "manual-ppi" ? null : angularLimit(input.sampling);
177
+ const pitchFactor = angle === null ? null : 2 * Math.tan((angle * RAD_PER_ARCMIN) / 2);
178
+ const pitch = input.sampling.kind === "manual-ppi" ? 25.4 / input.sampling.pixelsPerInch : distance * (pitchFactor ?? 0);
179
+ const ppi = input.sampling.kind === "manual-ppi" ? input.sampling.pixelsPerInch : 25.4 / pitch;
180
+ if (!positiveSupported(pitch, ppi, width / pitch, height / pitch))
181
+ return unsupported();
182
+ const guidance = { derivedPixelsPerInch: ppi, maximumPixelPitchMm: pitch, maximumArcminutesPerPixel: angle };
183
+ plan.guidance = angle === null ? calculatedResult(guidance, "manual-print-density", "0.1.0", ["Explicit manual PPI plan; no angular criterion is certified."]) : approximationResult(guidance, "declared-angular-print-sampling", "0.1.0", ["Exact centered pixel angle uses 2 atan(pitch / (2 distance)); no small-angle substitution.", "Declared angular sampling convention is an uncalibrated usage assumption."]);
184
+ if (input.source.kind === "unavailable") {
185
+ plan.reasons.push(input.source.reason);
186
+ return finish();
187
+ }
188
+ const resolved = resolveCaptureGeometry(input.source.geometry).value;
189
+ const native = { pixelWidth: resolved.output.cropRect.width, pixelHeight: resolved.output.cropRect.height };
190
+ const aspectError = Math.abs((width / height) / (native.pixelWidth / native.pixelHeight) - 1);
191
+ if (!Number.isFinite(aspectError))
192
+ return unsupported();
193
+ plan.relativeAspectError = aspectError;
194
+ const nativeDiagnostics = diagnostics(native, width, height, distance);
195
+ if (!positiveSupported(nativeDiagnostics.pixelsPerInch.x, nativeDiagnostics.pixelsPerInch.y, nativeDiagnostics.angularPixelPitchArcminutes.x, nativeDiagnostics.angularPixelPitchArcminutes.y))
196
+ return unsupported();
197
+ plan.native = nativeDiagnostics;
198
+ if (aspectError > input.fit.maximumRelativeAspectError) {
199
+ plan.status = "crop-confirmation-required";
200
+ plan.reasons.push("printed-image-and-confirmed-crop-aspect-mismatch");
201
+ return finish();
202
+ }
203
+ const widthInches = input.printedImage.unit === "inches" ? input.printedImage.width : width / 25.4;
204
+ const heightInches = input.printedImage.unit === "inches" ? input.printedImage.height : height / 25.4;
205
+ const required = input.sampling.kind === "manual-ppi"
206
+ ? minimumRaster(native, widthInches * ppi, heightInches * ppi)
207
+ : minimumRaster(native, width / pitch, height / pitch);
208
+ if (required === null)
209
+ return unsupported();
210
+ plan.minimumSamplingRaster = required;
211
+ const sufficient = required.pixelWidth <= native.pixelWidth && required.pixelHeight <= native.pixelHeight;
212
+ plan.nativePixelSufficiency = sufficient ? "sufficient" : "insufficient";
213
+ let maxScale = Math.min(native.pixelWidth * pitch / width, native.pixelHeight * pitch / height);
214
+ let minimumDistance = pitchFactor === null ? null : Math.max(width / native.pixelWidth, height / native.pixelHeight) / pitchFactor;
215
+ let maxWidth = width * maxScale, maxHeight = height * maxScale;
216
+ if (!positiveSupported(maxWidth, maxHeight) || (minimumDistance !== null && !positiveSupported(minimumDistance)))
217
+ return unsupported();
218
+ const fits = (w, h, p) => {
219
+ const candidate = input.sampling.kind === "manual-ppi" ? minimumRaster(native, w / 25.4 * ppi, h / 25.4 * ppi) : minimumRaster(native, w / p, h / p);
220
+ return candidate !== null && candidate.pixelWidth <= native.pixelWidth && candidate.pixelHeight <= native.pixelHeight;
221
+ };
222
+ // Return alternatives that survive their own documented integer policy.
223
+ for (let i = 0; i < 8 && !fits(maxWidth, maxHeight, pitch); i++) {
224
+ maxScale = adjacentPositive(maxScale, "down");
225
+ maxWidth = width * maxScale;
226
+ maxHeight = height * maxScale;
227
+ }
228
+ if (!positiveSupported(maxWidth, maxHeight) || !fits(maxWidth, maxHeight, pitch))
229
+ return unsupported();
230
+ if (minimumDistance !== null && pitchFactor !== null) {
231
+ for (let i = 0; i < 8 && !fits(width, height, minimumDistance * pitchFactor); i++)
232
+ minimumDistance = adjacentPositive(minimumDistance, "up");
233
+ if (!positiveSupported(minimumDistance) || !fits(width, height, minimumDistance * pitchFactor))
234
+ return unsupported();
235
+ }
236
+ plan.alternatives = { maximumImageMmAtCurrentDistance: { width: maxWidth, height: maxHeight }, minimumViewingDistanceMmAtCurrentSize: minimumDistance };
237
+ if (!sufficient) {
238
+ plan.status = "insufficient-native-pixels";
239
+ plan.reasons.push("sampling-requires-native-upscale");
240
+ }
241
+ let file = required;
242
+ const provider = input.provider;
243
+ if (provider) {
244
+ const density = Math.max(provider.minimumPpi ?? 0, provider.exactPpi ?? 0);
245
+ const constrained = minimumRaster(native, Math.max(required.pixelWidth, provider.minimumRaster?.pixelWidth ?? 0, widthInches * density), Math.max(required.pixelHeight, provider.minimumRaster?.pixelHeight ?? 0, heightInches * density));
246
+ if (constrained === null)
247
+ return unsupported();
248
+ file = provider.exactRaster ?? constrained;
249
+ if (provider.exactPpi !== undefined) {
250
+ const exact = { pixelWidth: widthInches * provider.exactPpi, pixelHeight: heightInches * provider.exactPpi };
251
+ if (!Number.isSafeInteger(exact.pixelWidth) || !Number.isSafeInteger(exact.pixelHeight))
252
+ plan.reasons.push("exact-provider-density-has-no-integer-raster");
253
+ else if (provider.exactRaster && (exact.pixelWidth !== file.pixelWidth || exact.pixelHeight !== file.pixelHeight))
254
+ plan.reasons.push("provider-exact-raster-density-conflict");
255
+ else
256
+ file = exact;
257
+ }
258
+ if (!exactRatio(file, native))
259
+ plan.reasons.push("provider-raster-aspect-conflict");
260
+ if (file.pixelWidth < constrained.pixelWidth || file.pixelHeight < constrained.pixelHeight)
261
+ plan.reasons.push("provider-exact-requirement-below-minimum");
262
+ if (file.pixelWidth > native.pixelWidth || file.pixelHeight > native.pixelHeight)
263
+ plan.reasons.push("provider-requires-native-upscale");
264
+ if (plan.reasons.some(r => r.startsWith("provider-") || r.startsWith("exact-provider-"))) {
265
+ plan.status = "provider-conflict";
266
+ return finish();
267
+ }
268
+ }
269
+ if (!sufficient)
270
+ return finish();
271
+ const achieved = diagnostics(file, width, height, distance);
272
+ if (!positiveSupported(achieved.pixelsPerInch.x, achieved.pixelsPerInch.y, achieved.angularPixelPitchArcminutes.x, achieved.angularPixelPitchArcminutes.y))
273
+ return unsupported();
274
+ plan.status = "ready";
275
+ plan.recommended = achieved;
276
+ plan.resamplingScale = { x: file.pixelWidth / native.pixelWidth, y: file.pixelHeight / native.pixelHeight };
277
+ return finish();
278
+ }
279
+ /** Calculate a conditional size bound. Lab constraints require individual plans;
280
+ * this first size-query contract reports them as unsupported rather than ignoring them.
281
+ */
282
+ export function calculatePrintSizeLimit(value) {
283
+ const r = record(value, ["plan", "viewingDistancePolicy"]);
284
+ if (r.viewingDistancePolicy !== "fixed" && r.viewingDistancePolicy !== "proportional-to-image-size")
285
+ throw new InvalidConfigurationError("Invalid viewing-distance scaling policy.");
286
+ const referencePlan = calculatePrintPlan(parsePrintPlanInput(r.plan)).value;
287
+ const result = { engineApiVersion: ENGINE_API_VERSION, status: "cannot-assess", maximumImageMm: null, reasons: [...referencePlan.reasons], referencePlan };
288
+ if (referencePlan.input.provider !== undefined && Object.keys(referencePlan.input.provider).length > 0) {
289
+ result.status = "unsupported";
290
+ result.reasons.push("size-query-with-provider-constraints-unsupported");
291
+ }
292
+ else if (referencePlan.status === "unsupported")
293
+ result.status = "unsupported";
294
+ else if (referencePlan.alternatives !== null) {
295
+ if (r.viewingDistancePolicy === "proportional-to-image-size" && referencePlan.input.sampling.kind !== "manual-ppi") {
296
+ result.status = referencePlan.nativePixelSufficiency === "sufficient" ? "unbounded" : "no-positive-size";
297
+ }
298
+ else {
299
+ result.status = "finite";
300
+ result.maximumImageMm = referencePlan.alternatives.maximumImageMmAtCurrentDistance;
301
+ }
302
+ }
303
+ return calculatedResult(result, "conditional-native-print-size-limit", "0.1.0", ["Native sampling capacity only; no perceived-quality or physical-printer bound.", "Proportional distance and image scaling preserve angular pixel pitch."]);
304
+ }
305
+ //# sourceMappingURL=print-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print-plan.js","sourceRoot":"","sources":["../../src/output/print-plan.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAA0B,MAAM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G,aAAa,CAAC,sBAAsB,KAAK,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAC;QAC3G,CAAC;aAAM,CAAC;YAAC,MAAM,CAAC,MAAM,GAAG,QAAQ,CAAC;YAAC,MAAM,CAAC,cAAc,GAAG,aAAa,CAAC,YAAY,CAAC,+BAA+B,CAAC;QAAC,CAAC;IAC1H,CAAC;IACD,OAAO,gBAAgB,CAAC,MAAM,EAAE,qCAAqC,EAAE,OAAO,EAAE,CAAC,gFAAgF,EAAE,uEAAuE,CAAC,CAAC,CAAC;AAC/O,CAAC"}
@@ -0,0 +1,92 @@
1
+ /** Bounded linear-region processing differences and repeat-capture statistics.
2
+ * @see docs/PRINT_REGION_STATISTICS.md for the model, protocol and exclusions.
3
+ */
4
+ import { type CalculationResult } from "../core/calculation-result.js";
5
+ import { type PrintDetailSource, type PrintDetailRegion } from "./print-detail.js";
6
+ import { type PrintPlan, type PrintPlanInput } from "./print-plan.js";
7
+ /** Independent of the root distribution and coherent-detail protocol. */
8
+ export declare const PRINT_REGION_STATISTICS_MODEL_VERSION: "0.1.0";
9
+ /** Maximum scalar samples across every frame/reference in one request. */
10
+ export declare const MAX_PRINT_REGION_STATISTICS_SAMPLES = 65536;
11
+ /** Exact, unwarped scalar linear ROI; sample and hash verification remains external. */
12
+ export interface PrintRegionRaster {
13
+ print: PrintPlanInput;
14
+ source: PrintDetailSource;
15
+ region: PrintDetailRegion;
16
+ samples: readonly number[];
17
+ }
18
+ /** Compare identical sample sites through processing, without mixing noise draws.
19
+ * A known range is a declared reference signal range, never a clipping threshold.
20
+ */
21
+ export interface PrintRegionDifferenceInput {
22
+ assessmentId: string;
23
+ before: PrintRegionRaster;
24
+ after: PrintRegionRaster;
25
+ purpose: "processing-change" | "decoded-file-change";
26
+ realizationPolicy: "same-noise-realization" | "deterministic-reference";
27
+ referenceRange: {
28
+ lowerRelativeLuminance: number;
29
+ upperRelativeLuminance: number;
30
+ } | null;
31
+ }
32
+ /** Sample statistics at registered sites over independently acquired repeats.
33
+ * Stationarity/independence are declarations; a single frame is never a noise ensemble.
34
+ */
35
+ export interface PrintRegionNoiseInput {
36
+ assessmentId: string;
37
+ ensembleId: string;
38
+ stationarySceneId: string;
39
+ repeatPolicy: "independent-stationary-captures";
40
+ frames: readonly PrintRegionRaster[];
41
+ }
42
+ export interface PrintRegionDifferenceMeasurement {
43
+ meanSignedDifferenceRelativeLuminance: number;
44
+ rmsDifferenceRelativeLuminance: number;
45
+ maximumAbsoluteDifferenceRelativeLuminance: number;
46
+ /** Null unless the caller supplied a reference range; not a halo classifier. */
47
+ rangeExcursions: {
48
+ beforeBelowRangeCount: number;
49
+ beforeAboveRangeCount: number;
50
+ afterBelowRangeCount: number;
51
+ afterAboveRangeCount: number;
52
+ beforeMaximumUndershootRelativeLuminance: number;
53
+ beforeMaximumOvershootRelativeLuminance: number;
54
+ afterMaximumUndershootRelativeLuminance: number;
55
+ afterMaximumOvershootRelativeLuminance: number;
56
+ } | null;
57
+ }
58
+ export interface PrintRegionNoiseMeasurement {
59
+ frameCount: number;
60
+ siteCount: number;
61
+ meanRelativeLuminance: number;
62
+ /** Mean of per-site sample variances with n-1 denominator, in squared linear units. */
63
+ meanTemporalSampleVarianceRelativeLuminanceSquared: number;
64
+ temporalRmsRelativeLuminance: number;
65
+ /** Separately retained so scene texture/fixed pattern is not relabelled temporal noise. */
66
+ perSiteMeansRelativeLuminance: readonly number[];
67
+ perSiteSampleVariancesRelativeLuminanceSquared: readonly number[];
68
+ }
69
+ /** Measurements remain diagnostic. No physical-noise calibration or print verdict. */
70
+ export interface PrintRegionStatisticsAssessment<TInput, TMeasurement> {
71
+ assessmentId: string;
72
+ engineApiVersion: string;
73
+ modelVersion: typeof PRINT_REGION_STATISTICS_MODEL_VERSION;
74
+ input: TInput;
75
+ status: "diagnostic-only" | "blocked" | "unsupported";
76
+ blockers: string[];
77
+ print: PrintPlan;
78
+ measurement: TMeasurement | null;
79
+ sourceArtifactVerification: "caller-declared-unverified";
80
+ acquisitionQualification: "unassessed";
81
+ uncertainty: "not-quantified";
82
+ overallPrintVerdict: "not-offered";
83
+ }
84
+ /** Parse/copy an untrusted paired scalar ROI request. */
85
+ export declare function parsePrintRegionDifferenceInput(v: unknown): PrintRegionDifferenceInput;
86
+ /** Parse/copy an untrusted repeat-capture ensemble with a total scalar work bound. */
87
+ export declare function parsePrintRegionNoiseInput(v: unknown): PrintRegionNoiseInput;
88
+ /** Measure registered processing changes; residual is not automatically compression/noise. */
89
+ export declare function calculatePrintRegionDifference(value: PrintRegionDifferenceInput): CalculationResult<PrintRegionStatisticsAssessment<PrintRegionDifferenceInput, PrintRegionDifferenceMeasurement>>;
90
+ /** Measure n-1 per-site temporal sample variance, independently of scene spatial texture. */
91
+ export declare function calculatePrintRegionNoise(value: PrintRegionNoiseInput): CalculationResult<PrintRegionStatisticsAssessment<PrintRegionNoiseInput, PrintRegionNoiseMeasurement>>;
92
+ //# sourceMappingURL=print-region-statistics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print-region-statistics.d.ts","sourceRoot":"","sources":["../../src/output/print-region-statistics.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAKzF,OAAO,EACL,KAAK,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EAA2C,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE/G,yEAAyE;AACzE,eAAO,MAAM,qCAAqC,EAAG,OAAgB,CAAC;AACtE,0EAA0E;AAC1E,eAAO,MAAM,mCAAmC,QAAkC,CAAC;AAEnF,wFAAwF;AACxF,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,SAAS,M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