@photivra/engine 2.5.0 → 2.6.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 (84) hide show
  1. package/CHANGELOG.md +38 -1
  2. package/CITATION.cff +1 -1
  3. package/README.md +6 -6
  4. package/SECURITY.md +1 -1
  5. package/THIRD_PARTY.md +1 -0
  6. package/dist/capture/native-environment-lean.d.ts +1 -1
  7. package/dist/capture/native-environment-lean.js +17 -3
  8. package/dist/capture/native-environment-lean.js.map +1 -1
  9. package/dist/capture/native-environment-raw.d.ts +0 -4
  10. package/dist/capture/native-environment-raw.js +6 -2
  11. package/dist/capture/native-environment-raw.js.map +1 -1
  12. package/dist/color/illuminants.d.ts +15 -0
  13. package/dist/color/illuminants.js +81 -24
  14. package/dist/color/illuminants.js.map +1 -1
  15. package/dist/color/srgb-transfer.d.ts +6 -0
  16. package/dist/color/srgb-transfer.js +9 -0
  17. package/dist/color/srgb-transfer.js.map +1 -1
  18. package/dist/color/white-balance.d.ts +6 -0
  19. package/dist/color/white-balance.js +15 -2
  20. package/dist/color/white-balance.js.map +1 -1
  21. package/dist/core/internal-radiance-evaluator.d.ts +6 -0
  22. package/dist/core/internal-radiance-evaluator.js +33 -0
  23. package/dist/core/internal-radiance-evaluator.js.map +1 -0
  24. package/dist/core/portable-math.d.ts +33 -0
  25. package/dist/core/portable-math.js +342 -0
  26. package/dist/core/portable-math.js.map +1 -1
  27. package/dist/core/version.d.ts +1 -1
  28. package/dist/core/version.js +1 -1
  29. package/dist/core/version.js.map +1 -1
  30. package/dist/facade/chart-scenes.d.ts +9 -0
  31. package/dist/facade/chart-scenes.js +17 -4
  32. package/dist/facade/chart-scenes.js.map +1 -1
  33. package/dist/facade/diffraction-provider.d.ts +10 -0
  34. package/dist/facade/diffraction-provider.js +38 -17
  35. package/dist/facade/diffraction-provider.js.map +1 -1
  36. package/dist/facade/display-view.d.ts +208 -0
  37. package/dist/facade/display-view.js +1461 -0
  38. package/dist/facade/display-view.js.map +1 -0
  39. package/dist/facade/scene-radiance.d.ts +7 -0
  40. package/dist/facade/scene-radiance.js +18 -5
  41. package/dist/facade/scene-radiance.js.map +1 -1
  42. package/dist/facade/simulate-capture.d.ts +224 -4
  43. package/dist/facade/simulate-capture.js +104 -33
  44. package/dist/facade/simulate-capture.js.map +1 -1
  45. package/dist/facade/simulate-display-view.d.ts +21 -0
  46. package/dist/facade/simulate-display-view.js +168 -0
  47. package/dist/facade/simulate-display-view.js.map +1 -0
  48. package/dist/facade/subject-framing.d.ts +16 -0
  49. package/dist/facade/subject-framing.js +8 -2
  50. package/dist/facade/subject-framing.js.map +1 -1
  51. package/dist/index.d.ts +2 -1
  52. package/dist/index.js +2 -1
  53. package/dist/index.js.map +1 -1
  54. package/dist/optics/diffraction-psf-profile.d.ts +9 -2
  55. package/dist/optics/diffraction-psf-profile.js +33 -4
  56. package/dist/optics/diffraction-psf-profile.js.map +1 -1
  57. package/dist/optics/irradiance-convolution.js +1 -1
  58. package/dist/optics/irradiance-convolution.js.map +1 -1
  59. package/dist/optics/scene-to-sensor-irradiance.d.ts +7 -0
  60. package/dist/optics/scene-to-sensor-irradiance.js +10 -5
  61. package/dist/optics/scene-to-sensor-irradiance.js.map +1 -1
  62. package/dist/output/print-plan.d.ts +8 -1
  63. package/dist/output/print-plan.js +8 -1
  64. package/dist/output/print-plan.js.map +1 -1
  65. package/dist/schema/scene-radiance.d.ts +16 -0
  66. package/dist/schema/scene-radiance.js +25 -4
  67. package/dist/schema/scene-radiance.js.map +1 -1
  68. package/dist/sensor/raw-readout.d.ts +12 -0
  69. package/dist/sensor/raw-readout.js +131 -9
  70. package/dist/sensor/raw-readout.js.map +1 -1
  71. package/dist/sensor/stochastic-seed.d.ts +13 -0
  72. package/dist/sensor/stochastic-seed.js +42 -8
  73. package/dist/sensor/stochastic-seed.js.map +1 -1
  74. package/docs/AGENT_GUIDE.md +1 -0
  75. package/docs/API_REFERENCE.md +13 -1
  76. package/docs/QUICK_START.md +155 -4
  77. package/docs/USAGE.md +15 -0
  78. package/docs/api/core-version.md +1 -1
  79. package/docs/api/exports.json +22 -2
  80. package/docs/api/facade-simulate-capture.md +65 -1
  81. package/docs/api/facade-simulate-display-view.md +18 -0
  82. package/docs/api/facade-subject-framing.md +16 -0
  83. package/docs/api/output-print-plan.md +8 -1
  84. package/package.json +3 -2
@@ -1,7 +1,3 @@
1
- /**
2
- * Native RAW capture from a scene-radiance provider: source radiance → optics → EQE (external quantum
3
- * efficiency) → packed RAW codes for the full native sensor, within fixed work limits.
4
- */
5
1
  import { type NativeRawInput, type NativeRawOutput, type NativeRawPlan, type NativeRawTask, type NativeRawTileRequest } from "./native-raw.js";
6
2
  import type { SensorRawProducerSiteInput } from "./sensor-raw-producer.js";
7
3
  import { type SimulateEnvironmentSensorRawFrameInput } from "./environment-raw-producer.js";
@@ -3,6 +3,7 @@
3
3
  * Native RAW capture from a scene-radiance provider: source radiance → optics → EQE (external quantum
4
4
  * efficiency) → packed RAW codes for the full native sensor, within fixed work limits.
5
5
  */
6
+ import { isInternalSceneRadianceEvaluator } from "../core/internal-radiance-evaluator.js";
6
7
  import { calculateNativeRawPlan, createNativeRawTaskWithCadence, nativeRawMaximumProviderEvaluations } from "./native-raw.js";
7
8
  import { createPhaseWhiteLevelAccumulator } from "./raw-white-level.js";
8
9
  import { createEnvironmentRawFrameCanonicalMemo, planEnvironmentRawSite } from "./environment-raw-producer.js";
@@ -154,7 +155,10 @@ export function createNativeEnvironmentRawTaskWithCadence(input, provider, caden
154
155
  (provider.observePhotoTile !== undefined && typeof provider.observePhotoTile !== "function") ||
155
156
  (provider.evaluateRadianceBatch !== undefined && typeof provider.evaluateRadianceBatch !== "function"))
156
157
  throw new InvalidConfigurationError("Native environment requires physical source callbacks and host yields.");
157
- const read = provider.readTile.bind(provider), evaluate = provider.evaluateRadiance.bind(provider), aperture = provider.evaluateApertureRadiance?.bind(provider), yieldControl = provider.yieldControl.bind(provider);
158
+ // 2.6: an engine-built evaluator (simulateCapture chart scenes) lets the lean path skip re-parsing the fixed parts of
159
+ // its results; read once, so the checked function is the one bound. Never with a batch, whose results are the caller's.
160
+ const evaluateFunction = provider.evaluateRadiance, internalEvaluator = provider.evaluateRadianceBatch === undefined && isInternalSceneRadianceEvaluator(evaluateFunction);
161
+ const read = provider.readTile.bind(provider), evaluate = evaluateFunction.bind(provider), aperture = provider.evaluateApertureRadiance?.bind(provider), yieldControl = provider.yieldControl.bind(provider);
158
162
  const observe = provider.observePhotoTile?.bind(provider), batch = provider.evaluateRadianceBatch?.bind(provider);
159
163
  let evaluations = 0, shared, reference;
160
164
  const recorder = retention ? createNativeEnvironmentOpticalStageRecorder(plan, sceneBinding, retention) : undefined;
@@ -277,7 +281,7 @@ export function createNativeEnvironmentRawTaskWithCadence(input, provider, caden
277
281
  if (isLeanEnvironmentPlan(p)) {
278
282
  // The full plan (deterministic, no callbacks) is built only when the lean path needs it.
279
283
  const fullPlan = () => planEnvironmentRawSite(sites[j], index, plan.frame, sceneBinding, plan.exposureWindow, "engine-owned", memo, "photo-only");
280
- photoSignal = lean.execute(p, evaluateCounted, apertureCounted, fullPlan);
284
+ photoSignal = lean.execute(p, evaluateCounted, apertureCounted, fullPlan, internalEvaluator && !batched);
281
285
  // An unverified template: plan this site in full now and execute it in full.
282
286
  if (photoSignal === undefined)
283
287
  p = fullPlan();
@@ -1 +1 @@
1
- {"version":3,"file":"native-environment-raw.js","sourceRoot":"","sources":["../../src/capture/native-environment-raw.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;GAGG;AACH,OAAO,EAAE,sBAAsB,EAAE,8BAA8B,EAAE,mCAAmC,EACN,MAAM,iBAAiB,CAAC;AACtH,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAE,sCAAsC,EAAE,sBAAsB,EAA+C,MAAM,+BAA+B,CAAC;AAC5J,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAyB,MAAM,yBAAyB,CAA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AA,CAAC;KAClP,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Native RAW capture from a scene-radiance provider: source radiance → optics → EQE (external quantum\n * efficiency) → packed RAW codes for the full native sensor, within fixed work limits.\n */\nimport { calculateNativeRawPlan, createNativeRawTaskWithCadence, nativeRawMaximumProviderEvaluations, type NativeRawInput, type NativeRawOutput,\n type NativeRawPlan, type NativeRawTask, type NativeRawTileRequest, type NativeRawTaskState } from \"./native-raw.js\";\nimport { createPhaseWhiteLevelAccumulator } from \"./raw-white-level.js\";\nimport type { SensorRawProducerSiteInput } from \"./sensor-raw-producer.js\";\nimport { createEnvironmentRawFrameCanonicalMemo, planEnvironmentRawSite, type SimulateEnvironmentSensorRawFrameInput } from \"./environment-raw-producer.js\";\nimport { DEFAULT_HOST_YIELD_CADENCE, createHostYieldGate, type HostYieldCadence } from \"./host-yield-cadence.js\";\nimport { executeEnvironmentSensorPhotoSignal, prebuildApertureRadianceQuery } from \"../sensor/environment-photo-signal.js\";\nimport { composeNativeEnvironmentSensorSite, createNativeEnvironmentOpticalStageRecorder, createSensorStageRawTask,\n parseNativeEnvironmentOpticalStageRetention, type NativeEnvironmentOpticalStage, type NativeEnvironmentOpticalStageRetention,\n type NativeEnvironmentSensorStageInput, type NativeEnvironmentSensorStageProvider } from \"./native-environment-optical-stage.js\";\nimport { parseEvidenceList } from \"../core/evidence-provenance.js\";\nimport { rejectUnknownFields, requireAllowlistedRecord, requirePublicOpaqueId } from \"../core/record-validation.js\";\nimport { stringifyCanonicalJson } from \"../core/canonical-json.js\";\nimport { freezeOwnedData } from \"../core/owned-data.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { createNativeEnvironmentLeanExecutor, createNativeEnvironmentSensorLean, isLeanEnvironmentPlan,\n type LeanEnvironmentPlan } from \"./native-environment-lean.js\";\nimport { prepareCaptureExposureWindowSampler } from \"../sensor/exposure-window.js\";\nimport type { SensorEqeTemporalPhotoSignal } from \"../sensor/temporal-photo-signal.js\";\nimport type { SceneRadianceEvaluationRequest, SceneRadianceEvaluationResult } from \"../schema/scene-radiance.js\";\nimport type { SensorApertureRay } from \"../optics/sensor-aperture-rays.js\";\n\ntype SitePlan = ReturnType<typeof planEnvironmentRawSite> | LeanEnvironmentPlan;\ntype PhotoSignal = SensorEqeTemporalPhotoSignal;\n\nexport interface NativeEnvironmentRawInput {\n raw: NativeRawInput;\n sceneBinding: SimulateEnvironmentSensorRawFrameInput[\"sceneBinding\"];\n /** Budget of provider calls for the whole capture, checked before work starts; at most 2 billion. Staying within it does not imply convergence. */\n maximumProviderEvaluations: number;\n /**\n * Optional: keep the optical stage (per-site expected photo signal, tied to every optical input) on the\n * output, for createNativeEnvironmentSensorStageTask. If omitted, behaviour and output shape are unchanged.\n */\n opticalStage?: NativeEnvironmentOpticalStageRetention;\n}\nexport interface NativeEnvironmentRawTile extends NativeRawTileRequest {\n sites: SimulateEnvironmentSensorRawFrameInput[\"sites\"];\n}\n/** One radiance query of a batch: the frozen provider request and, for an ideal-pupil ray, its frozen aperture ray. */\nexport interface NativeEnvironmentRadianceQuery {\n request: Readonly<SceneRadianceEvaluationRequest>;\n apertureRay?: Readonly<SensorApertureRay>;\n}\nexport interface NativeEnvironmentRawProvider {\n /** Supplies physical site profiles, not photo counts or precomputed RAW codes. */\n readTile(request: Readonly<NativeRawTileRequest>,signal:AbortSignal):Promise<NativeEnvironmentRawTile>;\n evaluateRadiance: SimulateEnvironmentSensorRawFrameInput[\"evaluateRadiance\"];\n evaluateApertureRadiance?: SimulateEnvironmentSensorRawFrameInput[\"evaluateApertureRadiance\"];\n /**\n * Optional batched light sampling (2.0, additive). When present, the engine makes one call per tile instead of one\n * evaluateRadiance or evaluateApertureRadiance call per query. `queries` holds every query of the tile's sites, in\n * exactly the order the per-query callbacks would be made, each with the same frozen request (and aperture ray).\n * Return one result per query, in the same order; a promise is allowed (for example a GPU readback). Each result\n * is validated by the same parser and binding checks as a per-query result, so for the same results the output is\n * byte-identical. The per-query evaluators stay required as the reference contract, but are not called.\n */\n evaluateRadianceBatch?(queries:readonly NativeEnvironmentRadianceQuery[],signal:AbortSignal):\n readonly SceneRadianceEvaluationResult[]|Promise<readonly SceneRadianceEvaluationResult[]>;\n /** Optional, bounded diagnostic callback. Counts are expected values before any noise, clipping or ADC (analogue-to-digital conversion). */\n observePhotoTile?(tile:Readonly<NativeEnvironmentPhotoTile>,signal:AbortSignal):void|Promise<void>;\n yieldControl(signal:AbortSignal):Promise<void>;\n}\nexport interface NativeEnvironmentPhotoTile extends NativeRawTileRequest {\n sites:readonly {nativeIndex:number;expectedIncidentPhotonCount:number;expectedGeneratedElectronCount:number}[];\n}\nexport interface NativeEnvironmentRawOutput {\n raw: NativeRawOutput;\n sceneBinding: NativeEnvironmentRawInput[\"sceneBinding\"];\n providerEvaluationCount: number;\n upstreamOrigin: \"executed-environment-query-provider-optics-psf-eqe\";\n providerTransportVerified: false;\n productionPlanActivated: false;\n /** Present only when NativeEnvironmentRawInput.opticalStage was requested. The caller owns and disposes it. */\n opticalStage?: NativeEnvironmentOpticalStage;\n}\nexport interface NativeEnvironmentRawTask extends Omit<NativeRawTask,\"takeOutput\"> {\n readonly providerEvaluationCount: number;\n takeOutput(): NativeEnvironmentRawOutput;\n}\nfunction canonical(value:unknown):string {\n return stringifyCanonicalJson(value,{undefinedObjectProperties:\"omit\",nonFiniteNumberMessage:\"Invalid native scene binding.\",unsupportedValueMessage:\"Invalid native scene binding.\"});\n}\n/** Site-environment fields that one native event shares across every site (same set as the optical-stage binding). */\nconst SHARED_STATE_KEYS = [\"sceneBindings\",\"optics\",\"motion\",\"psf\",\"pupil\",\"fieldThroughput\"] as const;\ntype SiteEnvironment = SimulateEnvironmentSensorRawFrameInput[\"sites\"][number][\"environment\"];\n/** The frame's first accepted shared state: its canonical string and its engine-owned (cloned) values. */\ninterface SharedStateReference {\n readonly canonical: string;\n readonly values: readonly unknown[];\n /** Arrays of the reference already checked to carry no holes or extra properties. */\n readonly cleanArrays: WeakSet<object>;\n}\n/**\n * Strict structural equality of structured-clone output against the reference: Object.is for primitives (0 and\n * -0 differ), identical prototypes limited to plain records and arrays, identical own keys in identical order,\n * and arrays with no holes or non-index properties. Anything else is unequal unless it is the same reference.\n * Equal values therefore serialize to the same canonical string and are interchangeable for every reader, so a\n * site may adopt the reference values. Recursion is bounded by the reference, which serialized without error.\n */\nfunction samePlainData(value: unknown, reference: unknown, cleanArrays: WeakSet<object>): boolean {\n if (Object.is(value, reference)) return true;\n if (typeof value !== \"object\" || typeof reference !== \"object\" || value === null || reference === null) return false;\n const prototype = Object.getPrototypeOf(value) as unknown;\n if (prototype !== Object.getPrototypeOf(reference)) return false;\n if (prototype === Array.prototype) {\n const a = value as unknown[], b = reference as unknown[], length = a.length;\n if (length !== b.length) return false;\n for (let index = 0; index < length; index++) if (!(index in a) || !(index in b) || !samePlainData(a[index], b[index], cleanArrays)) return false;\n // Holes are excluded above, so equal key counts exclude non-index properties as well.\n if (Object.keys(a).length !== length) return false;\n if (!cleanArrays.has(b)) { if (Object.keys(b).length !== length) return false; cleanArrays.add(b); }\n return true;\n }\n if (prototype !== Object.prototype && prototype !== null) return false;\n const a = value as Record<string, unknown>, b = reference as Record<string, unknown>, keys = Object.keys(a), referenceKeys = Object.keys(b);\n if (keys.length !== referenceKeys.length) return false;\n for (let index = 0; index < keys.length; index++) if (keys[index] !== referenceKeys[index]) return false;\n for (let index = 0; index < keys.length; index++) if (!samePlainData(a[keys[index]!], b[keys[index]!], cleanArrays)) return false;\n return true;\n}\n/**\n * Replaces a site's private copy of the shared state with the frame's reference values when every field is\n * strictly equal (a 2.0 performance change). All sites then share one engine-owned shared state, so its sampled\n * PSF is parsed and frozen once per frame and duplicate copies can be garbage-collected at once. `verified`\n * holds copies in the current tile already shown equal, so sites the supplier built from one object compare in\n * O(1). Returns false, changing nothing, when any field differs; the caller then serializes as before.\n */\nfunction adoptSharedState(environment: SiteEnvironment, reference: SharedStateReference, verified: unknown[]): boolean {\n const record = environment as unknown as Record<string, unknown>;\n for (let index = 0; index < SHARED_STATE_KEYS.length; index++) {\n const value = record[SHARED_STATE_KEYS[index]!];\n if (!(typeof value === \"object\" && value !== null && value === verified[index]) && !samePlainData(value, reference.values[index], reference.cleanArrays)) return false;\n }\n for (let index = 0; index < SHARED_STATE_KEYS.length; index++) {\n const key = SHARED_STATE_KEYS[index]!, value = record[key];\n if (value !== reference.values[index]) { verified[index] = value; record[key] = reference.values[index]; }\n }\n return true;\n}\n/**\n * Every radiance query the executors will make for these site plans, in their callback order: per site, per instant,\n * per group (spectral-major, spatial-minor), per tap, then per pupil ray. Pupil queries come from the executors' own\n * apertureRadianceQuery, which then hands the executor the same objects.\n */\nfunction tileQueries(plans:readonly SitePlan[]):NativeEnvironmentRadianceQuery[] {\n const queries:NativeEnvironmentRadianceQuery[]=[];\n const add=(tap:{request:SceneRadianceEvaluationRequest;apertureRays?:readonly SensorApertureRay[]}):void=>{\n if(tap.apertureRays===undefined){queries.push({request:tap.request});return;}\n // The executor later receives these same objects (apertureRadianceQuery), so they are built once.\n for(const ray of tap.apertureRays)queries.push(prebuildApertureRadianceQuery(tap.request,ray));\n };\n for(const p of plans){\n if(isLeanEnvironmentPlan(p)){for(const instant of p.instants)for(const tap of instant.taps)add(tap);}\n else for(const instant of p.instants)for(const group of instant.groups)for(const tap of group.taps)add(tap);\n }\n return queries;\n}\nfunction parseSceneBinding(value: unknown): NativeEnvironmentRawInput[\"sceneBinding\"] {\n const binding=requireAllowlistedRecord(value,[\"sceneStateId\",\"providerSceneId\",\"evidence\"],\"Invalid native scene binding.\");\n return freezeOwnedData({sceneStateId:requirePublicOpaqueId(binding.sceneStateId,\"Invalid scene-state ID.\"),providerSceneId:requirePublicOpaqueId(binding.providerSceneId,\"Invalid provider-scene ID.\"),evidence:parseEvidenceList(binding.evidence,\"nativeEnvironmentSceneBinding.evidence\")});\n}\n/**\n * Creates the native RAW task. Every tile is planned and checked against the limits before its radiance\n * callbacks run, and no partial output is ever returned.\n *\n * The task also yields to the host between sites inside a tile once about 8 ms of work has passed (one budget\n * shared with the tile loop). Cancellation is checked after each such yield, so cancel() takes effect within\n * about one site's work. Yield timing never changes tile requests, limit checks, callbacks or output.\n */\nexport function createNativeEnvironmentRawTask(input:NativeEnvironmentRawInput,provider:NativeEnvironmentRawProvider):NativeEnvironmentRawTask {\n return createNativeEnvironmentRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE);\n}\n/** Internal: the same task with an explicit host-yield timing. Timing never changes tiles, callbacks or output. Not exported from the package. */\n/** Validates a native environment input exactly as task creation does, before any callback. */\nfunction admitNativeEnvironmentInput(input:NativeEnvironmentRawInput):{plan:ReturnType<typeof calculateNativeRawPlan>;\n sceneBinding:NativeEnvironmentRawInput[\"sceneBinding\"];retention:NativeEnvironmentOpticalStageRetention|undefined;maximum:number} {\n const r=requireAllowlistedRecord(input,[\"raw\",\"sceneBinding\",\"maximumProviderEvaluations\",\"opticalStage\"],\"Invalid native environment input.\");\n const plan=calculateNativeRawPlan(input.raw),sceneBinding=parseSceneBinding(r.sceneBinding);\n const retention=r.opticalStage===undefined?undefined:parseNativeEnvironmentOpticalStageRetention(r.opticalStage);\n if(sceneBinding.sceneStateId!==plan.exposure.sceneStateId||plan.exposure.sceneTimeSeconds!==0||!plan.exposureWindow||\n typeof r.maximumProviderEvaluations!==\"number\"||!Number.isSafeInteger(r.maximumProviderEvaluations)||r.maximumProviderEvaluations<plan.pixelCount||r.maximumProviderEvaluations>nativeRawMaximumProviderEvaluations(plan))\n throw new InvalidConfigurationError(\"Native environment requires opening-reference scene binding, an explicit shutter event and bounded full-event query budget.\");\n return {plan,sceneBinding,retention,maximum:r.maximumProviderEvaluations};\n}\n/** Internal: a partition's row band, and the facts it records while running for the merge step. */\ninterface NativeEnvironmentPartitionProbe {\n readonly rows:NativeRawRowBand;\n /** Internal (2.3 region rendering): native columns [x, x + width); absent means every column. */\n readonly columns?:{readonly x:number;readonly width:number};\n /** Canonical string of the band's shared source/optical/motion state (the first site's). */\n shared?:string;\n /** The band's first parsed RAW site (its readout identity). */\n firstSite?:SensorRawProducerSiteInput;\n}\nexport function createNativeEnvironmentRawTaskWithCadence(input:NativeEnvironmentRawInput,provider:NativeEnvironmentRawProvider,\n cadence:HostYieldCadence,partition?:NativeEnvironmentPartitionProbe):NativeEnvironmentRawTask {\n const {plan,sceneBinding,retention,maximum}=admitNativeEnvironmentInput(input);\n if(partition&&retention)throw new InvalidConfigurationError(\"A native environment partition cannot retain the optical stage.\");\n if(!provider||typeof provider.readTile!==\"function\"||typeof provider.evaluateRadiance!==\"function\"||typeof provider.yieldControl!==\"function\"||\n (provider.evaluateApertureRadiance!==undefined&&typeof provider.evaluateApertureRadiance!==\"function\")||\n (provider.observePhotoTile!==undefined&&typeof provider.observePhotoTile!==\"function\")||\n (provider.evaluateRadianceBatch!==undefined&&typeof provider.evaluateRadianceBatch!==\"function\"))throw new InvalidConfigurationError(\"Native environment requires physical source callbacks and host yields.\");\n const read=provider.readTile.bind(provider),evaluate=provider.evaluateRadiance.bind(provider),aperture=provider.evaluateApertureRadiance?.bind(provider),yieldControl=provider.yieldControl.bind(provider);\n const observe=provider.observePhotoTile?.bind(provider),batch=provider.evaluateRadianceBatch?.bind(provider);\n let evaluations=0,shared:string|undefined,reference:SharedStateReference|undefined;\n const recorder=retention?createNativeEnvironmentOpticalStageRecorder(plan,sceneBinding,retention):undefined;\n const memo=createEnvironmentRawFrameCanonicalMemo(plan.frame,plan.exposureWindow!),gate=createHostYieldGate(cadence);\n const layout=plan.frame.colorSamplingProfile.layout,relationship=plan.frame.bindingProfile.relationship;\n const leanFrame={frameId:plan.frame.frameId,nativeWidth:plan.exposure.geometry.nativeRaster.pixelWidth,\n nativeHeight:plan.exposure.geometry.nativeRaster.pixelHeight,repeatWidth:layout.kind===\"periodic-mosaic\"?layout.repeatWidthSites:0,\n repeatHeight:layout.kind===\"periodic-mosaic\"?layout.repeatHeightSites:0,\n identityBinding:relationship.sitesPerNativeSampleX===1&&relationship.sitesPerNativeSampleY===1&&relationship.anchor===\"shared-native-top-left\"};\n const lean=createNativeEnvironmentLeanExecutor(leanFrame);\n let nativeWindow:Parameters<typeof createNativeEnvironmentSensorLean>[2];\n try{nativeWindow=prepareCaptureExposureWindowSampler({...plan.exposureWindow!,nativeRaster:plan.exposure.geometry.nativeRaster});}catch{nativeWindow=undefined;}\n const sensorLean=createNativeEnvironmentSensorLean(leanFrame,plan.frame,nativeWindow);\n const task=createNativeRawTaskWithCadence(input.raw,{\n async readTile(request,signal){\n const supplied=await read(request,signal);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native environment acquisition aborted.\");\n const tile=requireAllowlistedRecord(supplied,[\"captureId\",\"frameId\",\"x\",\"y\",\"width\",\"height\",\"sites\"],\"Invalid physical source tile.\");\n for(const key of Object.keys(request) as (keyof NativeRawTileRequest)[])if(tile[key]!==request[key])throw new InvalidConfigurationError(\"Physical source tile identity mismatch.\");\n if(!Array.isArray(tile.sites)||tile.sites.length!==request.width||Array.from({length:request.width},(_,i)=>i in (tile.sites as unknown[])).includes(false))throw new InvalidConfigurationError(\"Physical source tile needs exact native coverage.\");\n // Private copy: planning takes each site environment as engine-owned plan data without copying it again.\n const sites=structuredClone(tile.sites) as SimulateEnvironmentSensorRawFrameInput[\"sites\"];\n // Yield to the host between sites on the shared time budget. Cancellation is honoured right after it.\n const pause=async():Promise<void>=>{\n if(!gate.due())return;\n await yieldControl(signal);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native environment acquisition aborted.\");\n gate.restart();\n };\n let tileCount=0;\n const plans:SitePlan[]=[],verified:unknown[]=[];\n for(let j=0;j<sites.length;j++){\n if(j>0)await pause();\n const site=sites[j]!;\n requireAllowlistedRecord(site,[\"environment\",\"darkCurrentProfile\",\"operatingTemperatureC\",\"charge\",\"readout\"],\"Invalid physical site input.\");\n const e=site.environment,index=request.y*plan.exposure.geometry.nativeRaster.pixelWidth+request.x+j;\n if(e.temporalIntegrationId!==plan.frame.frameId+\":native:\"+index)throw new InvalidConfigurationError(\"Native environment IDs must bind the absolute native index.\");\n // A site strictly equal to the frame's first shared state adopts it and skips serialization; otherwise the\n // canonical comparison runs exactly as before and decides acceptance or the same error.\n let state:string;\n if(reference!==undefined&&adoptSharedState(e,reference,verified))state=reference.canonical;\n else{\n state=canonical({sceneBindings:e.sceneBindings,optics:e.optics,motion:e.motion,psf:e.psf,pupil:e.pupil,fieldThroughput:e.fieldThroughput});\n shared??=state;if(partition)partition.shared??=shared;if(state!==shared)throw new InvalidConfigurationError(\"Native event requires one shared source/optical/motion state.\");\n reference??={canonical:state,values:SHARED_STATE_KEYS.map(key=>(e as unknown as Record<string,unknown>)[key]),cleanArrays:new WeakSet()};\n }\n // A site matching a verified template gets a lean plan (identical requests and limit checks; see\n // native-environment-lean.ts). A template candidate keeps full query records for its self-check.\n // Otherwise only the photo signal is needed, so the plan keeps just each query's frozen request and image-plane point.\n const leanPlan=lean.plan(e,index);\n let p:SitePlan;\n if(typeof leanPlan===\"object\")p=leanPlan;\n else{\n p=planEnvironmentRawSite(site,index,plan.frame,sceneBinding,plan.exposureWindow!,\"engine-owned\",memo,leanPlan===\"candidate\"?\"full\":\"photo-only\");\n if(leanPlan===\"candidate\")lean.admitCandidate(e,index,p);\n }\n if(p.owned.pupil&&!aperture)throw new InvalidConfigurationError(\"Pupil capture requires origin-aware source visibility.\");\n recorder?.admit(index,e,state);\n tileCount+=p.count;\n if(tileCount>100_000||evaluations+tileCount>maximum)throw new InvalidConfigurationError(\"Native environment exceeds tile or full-event query budget.\");\n plans.push(p);\n }\n // Only value.photo is consumed, so per-evaluation diagnostics are not retained.\n const rawSites:(ReturnType<typeof composeNativeEnvironmentSensorSite>|object)[]=[],photos:PhotoSignal[]=[];\n sensorLean.beginTile();\n let evaluateCounted=(q:Parameters<typeof evaluate>[0]):ReturnType<typeof evaluate>=>{if(signal.aborted)throw new InvalidConfigurationError(\"Native source evaluation aborted.\");evaluations++;return evaluate(q);};\n let apertureCounted=aperture?(q:Parameters<typeof aperture>[0],ray:Parameters<typeof aperture>[1]):ReturnType<typeof evaluate>=>{if(signal.aborted)throw new InvalidConfigurationError(\"Native aperture evaluation aborted.\");evaluations++;return aperture(q,ray);}:undefined;\n let batched:{queries:readonly NativeEnvironmentRadianceQuery[];results:readonly SceneRadianceEvaluationResult[];next:number}|undefined;\n if(batch){\n // One call for the whole tile, with every planned query in per-query callback order (see tileQueries).\n const queries=tileQueries(plans);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native source evaluation aborted.\");\n const results=await batch(Object.freeze(queries),signal);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native source evaluation aborted.\");\n if(!Array.isArray(results)||results.length!==queries.length||Array.from({length:queries.length},(_,i)=>i in results).includes(false))\n throw new InvalidConfigurationError(\"Batched radiance must return one result per query, in query order.\");\n const current={queries,results:results as readonly SceneRadianceEvaluationResult[],next:0};\n batched=current;\n // The executors ask for each query in the same order; every step is checked against the planned query.\n const take=(q:Readonly<SceneRadianceEvaluationRequest>,ray:Readonly<SensorApertureRay>|undefined):SceneRadianceEvaluationResult=>{\n const k=current.next++,planned=current.queries[k];\n if(planned===undefined||planned.request.sampleId!==q.sampleId||(planned.apertureRay===undefined)!==(ray===undefined))\n throw new InvalidConfigurationError(\"Batched radiance results are out of step with the planned queries.\");\n evaluations++;\n return current.results[k]!;\n };\n evaluateCounted=(q):ReturnType<typeof evaluate>=>take(q,undefined);\n apertureCounted=aperture?(q,ray):ReturnType<typeof evaluate>=>take(q,ray):undefined;\n }\n for(let j=0;j<sites.length;j++){\n await pause();\n const index=request.y*plan.exposure.geometry.nativeRaster.pixelWidth+request.x+j;\n let p=plans[j]!,photoSignal:PhotoSignal|undefined;\n if(isLeanEnvironmentPlan(p)){\n // The full plan (deterministic, no callbacks) is built only when the lean path needs it.\n const fullPlan=():ReturnType<typeof planEnvironmentRawSite>=>planEnvironmentRawSite(sites[j]!,index,plan.frame,sceneBinding,plan.exposureWindow!,\"engine-owned\",memo,\"photo-only\");\n photoSignal=lean.execute(p,evaluateCounted,apertureCounted,fullPlan);\n // An unverified template: plan this site in full now and execute it in full.\n if(photoSignal===undefined)p=fullPlan();\n }\n if(photoSignal===undefined){\n const full=p as ReturnType<typeof planEnvironmentRawSite>,candidate=lean.isCandidate(index);\n const result=executeEnvironmentSensorPhotoSignal(full,evaluateCounted,apertureCounted,candidate?\"full\":\"photo-only\");\n if(candidate)lean.verifyCandidate(index,full,result);\n photoSignal=result.value.photo.value.photoSignal;\n }\n recorder?.record(index,photoSignal);\n photos.push(photoSignal);\n // A site matching a verified sensor template becomes a lean entry: every check its composition and RAW\n // parse would run has been evaluated (see native-environment-lean.ts). Otherwise compose it in full.\n const claimed=sensorLean.claim(sites[j]!,photoSignal,index);\n if(claimed)rawSites.push(claimed);\n else{rawSites.push(composeNativeEnvironmentSensorSite(sites[j]!,photoSignal));sensorLean.remember(index,sites[j]!,photoSignal);}\n }\n if(batched&&batched.next!==batched.queries.length)throw new InvalidConfigurationError(\"Batched radiance results are out of step with the planned queries.\");\n if(signal.aborted)throw new InvalidConfigurationError(\"Native photo observation aborted.\");\n if(observe)await observe(freezeOwnedData({...request,sites:photos.map((s,j)=>({nativeIndex:request.y*plan.exposure.geometry.nativeRaster.pixelWidth+request.x+j,\n expectedIncidentPhotonCount:s.expectedIncidentPhotonCount,expectedGeneratedElectronCount:s.expectedGeneratedElectronCount}))}),signal);\n return {...request,sites:rawSites as ReturnType<typeof composeNativeEnvironmentSensorSite>[]};\n },yieldControl\n },cadence,gate,sensorLean.hook,partition?{y:partition.rows.y,height:partition.rows.height,firstSite:(site):void=>{partition.firstSite=site;},\n ...(partition.columns?{x:partition.columns.x,width:partition.columns.width}:{})}:undefined);\n // The frame reference is needed only while tiles are read; release it once the event settles.\n const settle=():void=>{reference=undefined;};\n return {plan:task.plan,get state():NativeRawTaskState{return task.state;},get completedTileCount():number{return task.completedTileCount;},get providerEvaluationCount():number{return evaluations;},\n run:():Promise<void>=>(recorder?task.run().catch((error:unknown)=>{if(task.state===\"failed\"||task.state===\"cancelled\"||task.state===\"disposed\")recorder.discard();throw error;}):task.run()).finally(settle),\n cancel:():void=>{if(task.state!==\"transferred\")recorder?.discard();task.cancel();},dispose:():void=>{if(task.state!==\"transferred\")recorder?.discard();task.dispose();},\n takeOutput():NativeEnvironmentRawOutput{\n // Finish retention first so a retention failure never strands the transferred RAW.\n const opticalStage=recorder&&task.state===\"completed\"?recorder.finish(evaluations):undefined;\n const raw=task.takeOutput();\n const base={raw,sceneBinding,providerEvaluationCount:evaluations,upstreamOrigin:\"executed-environment-query-provider-optics-psf-eqe\" as const,providerTransportVerified:false as const,productionPlanActivated:false as const};\n return opticalStage?{...base,opticalStage}:base;\n }\n };\n}\n/**\n * Internal (not exported from the package; 2.3 `simulateCapture` `output.region`): the task for one rectangle of\n * native sites [x, x + width) × [y, y + height) of the whole-frame input. Every site keeps its absolute native index,\n * so its noise seeds, CFA phase, exposure window (rolling-shutter row timing) and value are those of the whole-frame\n * task; the output arrays hold just the rectangle, row-major, and `effectiveSaturationCodes` holds 0 for a CFA\n * phase the rectangle does not contain. Optical-stage retention is not supported.\n */\nexport function createNativeEnvironmentRawRegionTask(input:NativeEnvironmentRawInput,region:{x:number;y:number;width:number;height:number},\n provider:NativeEnvironmentRawProvider):NativeEnvironmentRawTask {\n const plan=calculateNativeRawPlan(input?.raw),native=plan.exposure.geometry.nativeRaster;\n const r=requireAllowlistedRecord(region,[\"x\",\"y\",\"width\",\"height\"],\"Invalid native RAW region.\");\n if(![r.x,r.y,r.width,r.height].every(v=>typeof v===\"number\"&&Number.isSafeInteger(v))||(r.width as number)<1||(r.x as number)<0||(r.x as number)+(r.width as number)>native.pixelWidth)\n throw new InvalidConfigurationError(\"Native RAW region must lie inside the native raster.\");\n const rows=parseRowBand({y:r.y,height:r.height},native.pixelHeight);\n return createNativeEnvironmentRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE,{rows,columns:{x:r.x as number,width:r.width as number}});\n}\n/** A band of whole native rows, [y, y + height), in absolute full-sensor coordinates. */\nexport interface NativeRawRowBand { y: number; height: number }\n/**\n * Splits a plan's native rows into at most `count` contiguous bands of nearly equal height (the first\n * `height % count` bands are one row taller), in row order. Deterministic: it depends only on the raster height and\n * `count`. Use one band per worker with createNativeEnvironmentRawPartitionTask.\n */\nexport function calculateNativeRawRowBands(plan:Pick<NativeRawPlan,\"exposure\">,count:number):NativeRawRowBand[] {\n if(plan!==null&&typeof plan===\"object\")rejectUnknownFields(plan,[\"schemaVersion\",\"exposure\",\"frame\",\"exposureWindow\",\"pixelCount\",\"outputBytes\",\"tileCount\",\n \"tileWidth\",\"upstreamRadiometryVerified\",\"seedSchedule\"],\"Native RAW plan\");\n const height=plan?.exposure?.geometry?.nativeRaster?.pixelHeight;\n if(typeof height!==\"number\"||!Number.isSafeInteger(height)||height<1)throw new InvalidConfigurationError(\"Native RAW partitioning requires a native RAW plan.\");\n if(typeof count!==\"number\"||!Number.isSafeInteger(count)||count<1||count>1024)throw new InvalidConfigurationError(\"Native RAW partition count must be an integer from 1 to 1024.\");\n const bands=Math.min(count,height),base=Math.floor(height/bands),extra=height%bands,result:NativeRawRowBand[]=[];\n for(let i=0,y=0;i<bands;i++){const h=base+(i<extra?1:0);result.push({y,height:h});y+=h;}\n return result;\n}\n/**\n * One partition's result: plain data and typed arrays only, so it can be posted from a worker (transfer the four\n * arrays' buffers). Merge every partition of a capture with composeNativeEnvironmentRawPartitions.\n */\nexport interface NativeEnvironmentRawPartition {\n rows: NativeRawRowBand;\n /** Canonical JSON of the capture input (raw, sceneBinding, maximumProviderEvaluations); the merge requires it to match. */\n inputCanonical: string;\n /** Canonical JSON of the band's shared source/optical/motion state; every partition must match. */\n sharedStateCanonical: string;\n /** Readout identity of the band's first site; every partition must match (one readout identity per frame). */\n readoutIdentity: { readoutProfileId: string; regimeId: string; fixedPatternProfileId: string | null; fixedPatternSeedUint32: number | null };\n /** The band's rows only, row-major, as in NativeRawOutput. */\n codes: Uint16Array;\n blackLevels: Uint16Array;\n digitalSaturationCodes: Uint16Array;\n saturationFlags: Uint8Array;\n /** Effective white code per CFA phase; 0 for a phase the band does not contain. */\n effectiveSaturationCodes: Uint16Array;\n providerEvaluationCount: number;\n}\nexport interface NativeEnvironmentRawPartitionTask extends Omit<NativeRawTask,\"takeOutput\"> {\n readonly rows: NativeRawRowBand;\n readonly providerEvaluationCount: number;\n takeOutput(): NativeEnvironmentRawPartition;\n}\nfunction inputCanonical(input:NativeEnvironmentRawInput):string {\n return canonical({raw:input.raw,sceneBinding:input.sceneBinding,maximumProviderEvaluations:input.maximumProviderEvaluations});\n}\nfunction parseRowBand(value:unknown,height:number):NativeRawRowBand {\n const band=requireAllowlistedRecord(value,[\"y\",\"height\"],\"Invalid native RAW row band.\");\n if(typeof band.y!==\"number\"||typeof band.height!==\"number\"||!Number.isSafeInteger(band.y)||!Number.isSafeInteger(band.height)||\n band.y<0||band.height<1||band.y+band.height>height)throw new InvalidConfigurationError(\"Native RAW row band must lie inside the native raster.\");\n return {y:band.y,height:band.height};\n}\n/**\n * Creates the task for one row band of a native environment capture (opt-in parallel execution, 2.0).\n *\n * Run one partition per worker (or one after another) with the same input, each worker using its own provider, then\n * merge them with composeNativeEnvironmentRawPartitions. The merged output is byte-identical to the single\n * createNativeEnvironmentRawTask output for the same input and a deterministic provider: noise seeds use absolute\n * native indices, and tiles, plans and per-site values are those of the whole-frame task.\n *\n * Each partition checks the same inputs and limits before its callbacks. maximumProviderEvaluations bounds each\n * partition's own work; the merge also rejects a total above it. Frame-wide checks that span sites (one shared\n * state, one readout identity, one white level per CFA phase) run inside each band and again across bands in the\n * merge. Callbacks are split across partitions, and when several partitions fail, which error is seen first depends\n * on the caller's scheduling. Optical-stage retention is not supported in a partition.\n *\n * The package bundles no worker code: the caller creates workers (Web Workers or Node worker threads), runs this\n * task inside each and posts the partition back.\n */\nexport function createNativeEnvironmentRawPartitionTask(input:NativeEnvironmentRawInput,rows:NativeRawRowBand,\n provider:NativeEnvironmentRawProvider):NativeEnvironmentRawPartitionTask {\n const plan=calculateNativeRawPlan(input?.raw),band=parseRowBand(rows,plan.exposure.geometry.nativeRaster.pixelHeight);\n const probe:NativeEnvironmentPartitionProbe={rows:band};\n const task=createNativeEnvironmentRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE,probe),text=inputCanonical(input);\n return {plan:task.plan,rows:band,get state():NativeRawTaskState{return task.state;},get completedTileCount():number{return task.completedTileCount;},\n get providerEvaluationCount():number{return task.providerEvaluationCount;},run:():Promise<void>=>task.run(),cancel:():void=>task.cancel(),dispose:():void=>task.dispose(),\n takeOutput():NativeEnvironmentRawPartition{\n if(task.state!==\"completed\"||probe.shared===undefined||probe.firstSite===undefined)throw new InvalidConfigurationError(\"Native RAW output unavailable.\");\n const site=probe.firstSite,sharedStateCanonical=probe.shared,output=task.takeOutput(),raw=output.raw;\n return {rows:{...band},inputCanonical:text,sharedStateCanonical,readoutIdentity:{readoutProfileId:site.readoutProfile.profileId,regimeId:site.regimeId,\n fixedPatternProfileId:site.fixedPatternNoise?.profileId??null,fixedPatternSeedUint32:site.fixedPatternNoise?.sensorInstanceSeedUint32??null},\n codes:raw.codes,blackLevels:raw.blackLevels,digitalSaturationCodes:raw.digitalSaturationCodes,saturationFlags:raw.saturationFlags,\n effectiveSaturationCodes:raw.effectiveSaturationCodes,providerEvaluationCount:output.providerEvaluationCount};\n }\n };\n}\n/**\n * Assembles the partitions of one capture into the output createNativeEnvironmentRawTask would have returned for\n * the same input (byte-identical RAW arrays and white levels, the summed provider evaluation count).\n *\n * The partitions must be in row order and cover every native row exactly once, and each must come from\n * createNativeEnvironmentRawPartitionTask with this same input. It rejects, with InvalidConfigurationError, a\n * different input, a gap or overlap, wrong array types or lengths, a second shared state or readout identity, two\n * white levels for one CFA phase, a missing phase, or a total evaluation count above the input's budget. It cannot\n * verify how a partition was computed: posted partitions are the caller's own data.\n */\nexport function composeNativeEnvironmentRawPartitions(input:NativeEnvironmentRawInput,partitions:readonly NativeEnvironmentRawPartition[]):NativeEnvironmentRawOutput {\n const {plan,sceneBinding,retention,maximum}=admitNativeEnvironmentInput(input);\n if(retention)throw new InvalidConfigurationError(\"A native environment partition cannot retain the optical stage.\");\n const native=plan.exposure.geometry.nativeRaster,width=native.pixelWidth,layout=plan.frame.colorSamplingProfile.layout;\n if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Native RAW requires periodic CFA.\");\n const phases=layout.repeatWidthSites*layout.repeatHeightSites,text=inputCanonical(input);\n if(!Array.isArray(partitions)||partitions.length<1||partitions.length>native.pixelHeight||Array.from({length:partitions.length},(_,i)=>i in partitions).includes(false))\n throw new InvalidConfigurationError(\"Native RAW merge requires a dense list of partitions.\");\n const codes=new Uint16Array(plan.pixelCount),blackLevels=new Uint16Array(plan.pixelCount),digitalSaturationCodes=new Uint16Array(plan.pixelCount),saturationFlags=new Uint8Array(plan.pixelCount);\n const white=createPhaseWhiteLevelAccumulator(width,layout.repeatWidthSites,layout.repeatHeightSites);\n let y=0,total=0,shared:string|undefined,identity:string|undefined;\n for(const value of partitions){\n const p=requireAllowlistedRecord(value,[\"rows\",\"inputCanonical\",\"sharedStateCanonical\",\"readoutIdentity\",\"codes\",\"blackLevels\",\"digitalSaturationCodes\",\n \"saturationFlags\",\"effectiveSaturationCodes\",\"providerEvaluationCount\"],\"Invalid native RAW partition.\");\n const band=parseRowBand(p.rows,native.pixelHeight),length=band.height*width;\n if(band.y!==y)throw new InvalidConfigurationError(\"Native RAW partitions must cover every row once, in row order.\");\n if(p.inputCanonical!==text)throw new InvalidConfigurationError(\"Native RAW partition was computed from a different input.\");\n if(!(p.codes instanceof Uint16Array)||!(p.blackLevels instanceof Uint16Array)||!(p.digitalSaturationCodes instanceof Uint16Array)||\n !(p.saturationFlags instanceof Uint8Array)||!(p.effectiveSaturationCodes instanceof Uint16Array)||p.codes.length!==length||p.blackLevels.length!==length||\n p.digitalSaturationCodes.length!==length||p.saturationFlags.length!==length||p.effectiveSaturationCodes.length!==phases||\n typeof p.providerEvaluationCount!==\"number\"||!Number.isSafeInteger(p.providerEvaluationCount)||p.providerEvaluationCount<0||typeof p.sharedStateCanonical!==\"string\")\n throw new InvalidConfigurationError(\"Invalid native RAW partition arrays.\");\n const id=requireAllowlistedRecord(p.readoutIdentity,[\"readoutProfileId\",\"regimeId\",\"fixedPatternProfileId\",\"fixedPatternSeedUint32\"],\"Invalid native RAW partition identity.\");\n const idText=canonical(id);\n shared??=p.sharedStateCanonical;identity??=idText;\n if(p.sharedStateCanonical!==shared)throw new InvalidConfigurationError(\"Native event requires one shared source/optical/motion state.\");\n if(idText!==identity)throw new InvalidConfigurationError(\"Frame requires one readout identity/regime, one fixed-pattern identity and a positive uint16 RAW code span.\");\n const offset=band.y*width;\n codes.set(p.codes,offset);blackLevels.set(p.blackLevels,offset);digitalSaturationCodes.set(p.digitalSaturationCodes,offset);saturationFlags.set(p.saturationFlags,offset);\n for(let phase=0;phase<phases;phase++)white.recordPhase(phase,p.effectiveSaturationCodes[phase]!);\n total+=p.providerEvaluationCount;y+=band.height;\n }\n if(y!==native.pixelHeight)throw new InvalidConfigurationError(\"Native RAW partitions must cover every row once, in row order.\");\n if(total>maximum)throw new InvalidConfigurationError(\"Native environment exceeds tile or full-event query budget.\");\n const raw:NativeRawOutput={plan,codes,blackLevels,digitalSaturationCodes,saturationFlags,effectiveSaturationCodes:white.finish()};\n return {raw,sceneBinding,providerEvaluationCount:total,upstreamOrigin:\"executed-environment-query-provider-optics-psf-eqe\",providerTransportVerified:false,productionPlanActivated:false};\n}\n/**\n * Re-runs only the sensor stage from a retained optical stage. No radiance callback is called.\n *\n * Use it when only post-optics settings change: noise seed, ISO and its readout regime and gain,\n * fixed-pattern noise, charge, dark-current and capacity profiles, white-balance intent, capture identity\n * or tile width. White balance and rendering are then applied by createNativeRawDevelopmentTask as usual.\n *\n * RAW codes are bit-identical to a full createNativeEnvironmentRawTask with the same final inputs, as long\n * as the radiance provider is a deterministic function of its request.\n *\n * Any optical difference is rejected with InvalidConfigurationError before output. That includes scene\n * binding, geometry or orientation, focal length, aperture, shutter or exposure window, focus,\n * frame/CFA/binding profiles, and any site environment field such as PSF, field throughput, pupil, motion,\n * spectral or temporal sampling and provider profiles.\n *\n * providerEvaluationCount is 0. The caller still owns the stage; it is not used up.\n */\nexport function createNativeEnvironmentSensorStageTask(input:NativeEnvironmentSensorStageInput,opticalStage:NativeEnvironmentOpticalStage,\n provider:NativeEnvironmentSensorStageProvider):NativeEnvironmentRawTask {\n const {task,sceneBinding}=createSensorStageRawTask(input,opticalStage,provider,parseSceneBinding);\n return {plan:task.plan,get state():NativeRawTaskState{return task.state;},get completedTileCount():number{return task.completedTileCount;},get providerEvaluationCount():number{return 0;},\n run:():Promise<void>=>task.run(),cancel:():void=>task.cancel(),dispose:():void=>task.dispose(),\n takeOutput():NativeEnvironmentRawOutput{return {raw:task.takeOutput(),sceneBinding,providerEvaluationCount:0,upstreamOrigin:\"executed-environment-query-provider-optics-psf-eqe\",providerTransportVerified:false,productionPlanActivated:false};}\n };\n}\n"]}
1
+ {"version":3,"file":"native-environment-raw.js","sourceRoot":"","sources":["../../src/capture/native-environment-raw.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;GAGG;AACH,OAAO,EAAC,gCAAgC,EAAC,MAAM,wCAAwC,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,8BAA8B,EAAE,mCAAmC,EACN,MAAM,iBAAiB,CAAC;AACtH,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAE,sCAAsC,EAAE,sBAAsB,EAA+C,MAAM,+BAA+B,CAAC;AAC5J,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAyB,MAAM,yBAAyB,CAAC;AACjH,OAAO,EAAE,mCAAmC,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAC3H,OAAO,EAAE,kCAAkC,EAAE,2CAA2C,EAAE,wBAAwB,EAChH,2CAA2C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AC,KAAK,EAAC,uBAAuB,EAAC,KAAK,EAAC,CAAC,CAAA,CAAC;KAClP,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Native RAW capture from a scene-radiance provider: source radiance → optics → EQE (external quantum\n * efficiency) → packed RAW codes for the full native sensor, within fixed work limits.\n */\nimport {isInternalSceneRadianceEvaluator} from \"../core/internal-radiance-evaluator.js\";\nimport { calculateNativeRawPlan, createNativeRawTaskWithCadence, nativeRawMaximumProviderEvaluations, type NativeRawInput, type NativeRawOutput,\n type NativeRawPlan, type NativeRawTask, type NativeRawTileRequest, type NativeRawTaskState } from \"./native-raw.js\";\nimport { createPhaseWhiteLevelAccumulator } from \"./raw-white-level.js\";\nimport type { SensorRawProducerSiteInput } from \"./sensor-raw-producer.js\";\nimport { createEnvironmentRawFrameCanonicalMemo, planEnvironmentRawSite, type SimulateEnvironmentSensorRawFrameInput } from \"./environment-raw-producer.js\";\nimport { DEFAULT_HOST_YIELD_CADENCE, createHostYieldGate, type HostYieldCadence } from \"./host-yield-cadence.js\";\nimport { executeEnvironmentSensorPhotoSignal, prebuildApertureRadianceQuery } from \"../sensor/environment-photo-signal.js\";\nimport { composeNativeEnvironmentSensorSite, createNativeEnvironmentOpticalStageRecorder, createSensorStageRawTask,\n parseNativeEnvironmentOpticalStageRetention, type NativeEnvironmentOpticalStage, type NativeEnvironmentOpticalStageRetention,\n type NativeEnvironmentSensorStageInput, type NativeEnvironmentSensorStageProvider } from \"./native-environment-optical-stage.js\";\nimport { parseEvidenceList } from \"../core/evidence-provenance.js\";\nimport { rejectUnknownFields, requireAllowlistedRecord, requirePublicOpaqueId } from \"../core/record-validation.js\";\nimport { stringifyCanonicalJson } from \"../core/canonical-json.js\";\nimport { freezeOwnedData } from \"../core/owned-data.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { createNativeEnvironmentLeanExecutor, createNativeEnvironmentSensorLean, isLeanEnvironmentPlan,\n type LeanEnvironmentPlan } from \"./native-environment-lean.js\";\nimport { prepareCaptureExposureWindowSampler } from \"../sensor/exposure-window.js\";\nimport type { SensorEqeTemporalPhotoSignal } from \"../sensor/temporal-photo-signal.js\";\nimport type { SceneRadianceEvaluationRequest, SceneRadianceEvaluationResult } from \"../schema/scene-radiance.js\";\nimport type { SensorApertureRay } from \"../optics/sensor-aperture-rays.js\";\n\ntype SitePlan = ReturnType<typeof planEnvironmentRawSite> | LeanEnvironmentPlan;\ntype PhotoSignal = SensorEqeTemporalPhotoSignal;\n\nexport interface NativeEnvironmentRawInput {\n raw: NativeRawInput;\n sceneBinding: SimulateEnvironmentSensorRawFrameInput[\"sceneBinding\"];\n /** Budget of provider calls for the whole capture, checked before work starts; at most 2 billion. Staying within it does not imply convergence. */\n maximumProviderEvaluations: number;\n /**\n * Optional: keep the optical stage (per-site expected photo signal, tied to every optical input) on the\n * output, for createNativeEnvironmentSensorStageTask. If omitted, behaviour and output shape are unchanged.\n */\n opticalStage?: NativeEnvironmentOpticalStageRetention;\n}\nexport interface NativeEnvironmentRawTile extends NativeRawTileRequest {\n sites: SimulateEnvironmentSensorRawFrameInput[\"sites\"];\n}\n/** One radiance query of a batch: the frozen provider request and, for an ideal-pupil ray, its frozen aperture ray. */\nexport interface NativeEnvironmentRadianceQuery {\n request: Readonly<SceneRadianceEvaluationRequest>;\n apertureRay?: Readonly<SensorApertureRay>;\n}\nexport interface NativeEnvironmentRawProvider {\n /** Supplies physical site profiles, not photo counts or precomputed RAW codes. */\n readTile(request: Readonly<NativeRawTileRequest>,signal:AbortSignal):Promise<NativeEnvironmentRawTile>;\n evaluateRadiance: SimulateEnvironmentSensorRawFrameInput[\"evaluateRadiance\"];\n evaluateApertureRadiance?: SimulateEnvironmentSensorRawFrameInput[\"evaluateApertureRadiance\"];\n /**\n * Optional batched light sampling (2.0, additive). When present, the engine makes one call per tile instead of one\n * evaluateRadiance or evaluateApertureRadiance call per query. `queries` holds every query of the tile's sites, in\n * exactly the order the per-query callbacks would be made, each with the same frozen request (and aperture ray).\n * Return one result per query, in the same order; a promise is allowed (for example a GPU readback). Each result\n * is validated by the same parser and binding checks as a per-query result, so for the same results the output is\n * byte-identical. The per-query evaluators stay required as the reference contract, but are not called.\n */\n evaluateRadianceBatch?(queries:readonly NativeEnvironmentRadianceQuery[],signal:AbortSignal):\n readonly SceneRadianceEvaluationResult[]|Promise<readonly SceneRadianceEvaluationResult[]>;\n /** Optional, bounded diagnostic callback. Counts are expected values before any noise, clipping or ADC (analogue-to-digital conversion). */\n observePhotoTile?(tile:Readonly<NativeEnvironmentPhotoTile>,signal:AbortSignal):void|Promise<void>;\n yieldControl(signal:AbortSignal):Promise<void>;\n}\nexport interface NativeEnvironmentPhotoTile extends NativeRawTileRequest {\n sites:readonly {nativeIndex:number;expectedIncidentPhotonCount:number;expectedGeneratedElectronCount:number}[];\n}\nexport interface NativeEnvironmentRawOutput {\n raw: NativeRawOutput;\n sceneBinding: NativeEnvironmentRawInput[\"sceneBinding\"];\n providerEvaluationCount: number;\n upstreamOrigin: \"executed-environment-query-provider-optics-psf-eqe\";\n providerTransportVerified: false;\n productionPlanActivated: false;\n /** Present only when NativeEnvironmentRawInput.opticalStage was requested. The caller owns and disposes it. */\n opticalStage?: NativeEnvironmentOpticalStage;\n}\nexport interface NativeEnvironmentRawTask extends Omit<NativeRawTask,\"takeOutput\"> {\n readonly providerEvaluationCount: number;\n takeOutput(): NativeEnvironmentRawOutput;\n}\nfunction canonical(value:unknown):string {\n return stringifyCanonicalJson(value,{undefinedObjectProperties:\"omit\",nonFiniteNumberMessage:\"Invalid native scene binding.\",unsupportedValueMessage:\"Invalid native scene binding.\"});\n}\n/** Site-environment fields that one native event shares across every site (same set as the optical-stage binding). */\nconst SHARED_STATE_KEYS = [\"sceneBindings\",\"optics\",\"motion\",\"psf\",\"pupil\",\"fieldThroughput\"] as const;\ntype SiteEnvironment = SimulateEnvironmentSensorRawFrameInput[\"sites\"][number][\"environment\"];\n/** The frame's first accepted shared state: its canonical string and its engine-owned (cloned) values. */\ninterface SharedStateReference {\n readonly canonical: string;\n readonly values: readonly unknown[];\n /** Arrays of the reference already checked to carry no holes or extra properties. */\n readonly cleanArrays: WeakSet<object>;\n}\n/**\n * Strict structural equality of structured-clone output against the reference: Object.is for primitives (0 and\n * -0 differ), identical prototypes limited to plain records and arrays, identical own keys in identical order,\n * and arrays with no holes or non-index properties. Anything else is unequal unless it is the same reference.\n * Equal values therefore serialize to the same canonical string and are interchangeable for every reader, so a\n * site may adopt the reference values. Recursion is bounded by the reference, which serialized without error.\n */\nfunction samePlainData(value: unknown, reference: unknown, cleanArrays: WeakSet<object>): boolean {\n if (Object.is(value, reference)) return true;\n if (typeof value !== \"object\" || typeof reference !== \"object\" || value === null || reference === null) return false;\n const prototype = Object.getPrototypeOf(value) as unknown;\n if (prototype !== Object.getPrototypeOf(reference)) return false;\n if (prototype === Array.prototype) {\n const a = value as unknown[], b = reference as unknown[], length = a.length;\n if (length !== b.length) return false;\n for (let index = 0; index < length; index++) if (!(index in a) || !(index in b) || !samePlainData(a[index], b[index], cleanArrays)) return false;\n // Holes are excluded above, so equal key counts exclude non-index properties as well.\n if (Object.keys(a).length !== length) return false;\n if (!cleanArrays.has(b)) { if (Object.keys(b).length !== length) return false; cleanArrays.add(b); }\n return true;\n }\n if (prototype !== Object.prototype && prototype !== null) return false;\n const a = value as Record<string, unknown>, b = reference as Record<string, unknown>, keys = Object.keys(a), referenceKeys = Object.keys(b);\n if (keys.length !== referenceKeys.length) return false;\n for (let index = 0; index < keys.length; index++) if (keys[index] !== referenceKeys[index]) return false;\n for (let index = 0; index < keys.length; index++) if (!samePlainData(a[keys[index]!], b[keys[index]!], cleanArrays)) return false;\n return true;\n}\n/**\n * Replaces a site's private copy of the shared state with the frame's reference values when every field is\n * strictly equal (a 2.0 performance change). All sites then share one engine-owned shared state, so its sampled\n * PSF is parsed and frozen once per frame and duplicate copies can be garbage-collected at once. `verified`\n * holds copies in the current tile already shown equal, so sites the supplier built from one object compare in\n * O(1). Returns false, changing nothing, when any field differs; the caller then serializes as before.\n */\nfunction adoptSharedState(environment: SiteEnvironment, reference: SharedStateReference, verified: unknown[]): boolean {\n const record = environment as unknown as Record<string, unknown>;\n for (let index = 0; index < SHARED_STATE_KEYS.length; index++) {\n const value = record[SHARED_STATE_KEYS[index]!];\n if (!(typeof value === \"object\" && value !== null && value === verified[index]) && !samePlainData(value, reference.values[index], reference.cleanArrays)) return false;\n }\n for (let index = 0; index < SHARED_STATE_KEYS.length; index++) {\n const key = SHARED_STATE_KEYS[index]!, value = record[key];\n if (value !== reference.values[index]) { verified[index] = value; record[key] = reference.values[index]; }\n }\n return true;\n}\n/**\n * Every radiance query the executors will make for these site plans, in their callback order: per site, per instant,\n * per group (spectral-major, spatial-minor), per tap, then per pupil ray. Pupil queries come from the executors' own\n * apertureRadianceQuery, which then hands the executor the same objects.\n */\nfunction tileQueries(plans:readonly SitePlan[]):NativeEnvironmentRadianceQuery[] {\n const queries:NativeEnvironmentRadianceQuery[]=[];\n const add=(tap:{request:SceneRadianceEvaluationRequest;apertureRays?:readonly SensorApertureRay[]}):void=>{\n if(tap.apertureRays===undefined){queries.push({request:tap.request});return;}\n // The executor later receives these same objects (apertureRadianceQuery), so they are built once.\n for(const ray of tap.apertureRays)queries.push(prebuildApertureRadianceQuery(tap.request,ray));\n };\n for(const p of plans){\n if(isLeanEnvironmentPlan(p)){for(const instant of p.instants)for(const tap of instant.taps)add(tap);}\n else for(const instant of p.instants)for(const group of instant.groups)for(const tap of group.taps)add(tap);\n }\n return queries;\n}\nfunction parseSceneBinding(value: unknown): NativeEnvironmentRawInput[\"sceneBinding\"] {\n const binding=requireAllowlistedRecord(value,[\"sceneStateId\",\"providerSceneId\",\"evidence\"],\"Invalid native scene binding.\");\n return freezeOwnedData({sceneStateId:requirePublicOpaqueId(binding.sceneStateId,\"Invalid scene-state ID.\"),providerSceneId:requirePublicOpaqueId(binding.providerSceneId,\"Invalid provider-scene ID.\"),evidence:parseEvidenceList(binding.evidence,\"nativeEnvironmentSceneBinding.evidence\")});\n}\n/**\n * Creates the native RAW task. Every tile is planned and checked against the limits before its radiance\n * callbacks run, and no partial output is ever returned.\n *\n * The task also yields to the host between sites inside a tile once about 8 ms of work has passed (one budget\n * shared with the tile loop). Cancellation is checked after each such yield, so cancel() takes effect within\n * about one site's work. Yield timing never changes tile requests, limit checks, callbacks or output.\n */\nexport function createNativeEnvironmentRawTask(input:NativeEnvironmentRawInput,provider:NativeEnvironmentRawProvider):NativeEnvironmentRawTask {\n return createNativeEnvironmentRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE);\n}\n/** Internal: the same task with an explicit host-yield timing. Timing never changes tiles, callbacks or output. Not exported from the package. */\n/** Validates a native environment input exactly as task creation does, before any callback. */\nfunction admitNativeEnvironmentInput(input:NativeEnvironmentRawInput):{plan:ReturnType<typeof calculateNativeRawPlan>;\n sceneBinding:NativeEnvironmentRawInput[\"sceneBinding\"];retention:NativeEnvironmentOpticalStageRetention|undefined;maximum:number} {\n const r=requireAllowlistedRecord(input,[\"raw\",\"sceneBinding\",\"maximumProviderEvaluations\",\"opticalStage\"],\"Invalid native environment input.\");\n const plan=calculateNativeRawPlan(input.raw),sceneBinding=parseSceneBinding(r.sceneBinding);\n const retention=r.opticalStage===undefined?undefined:parseNativeEnvironmentOpticalStageRetention(r.opticalStage);\n if(sceneBinding.sceneStateId!==plan.exposure.sceneStateId||plan.exposure.sceneTimeSeconds!==0||!plan.exposureWindow||\n typeof r.maximumProviderEvaluations!==\"number\"||!Number.isSafeInteger(r.maximumProviderEvaluations)||r.maximumProviderEvaluations<plan.pixelCount||r.maximumProviderEvaluations>nativeRawMaximumProviderEvaluations(plan))\n throw new InvalidConfigurationError(\"Native environment requires opening-reference scene binding, an explicit shutter event and bounded full-event query budget.\");\n return {plan,sceneBinding,retention,maximum:r.maximumProviderEvaluations};\n}\n/** Internal: a partition's row band, and the facts it records while running for the merge step. */\ninterface NativeEnvironmentPartitionProbe {\n readonly rows:NativeRawRowBand;\n /** Internal (2.3 region rendering): native columns [x, x + width); absent means every column. */\n readonly columns?:{readonly x:number;readonly width:number};\n /** Canonical string of the band's shared source/optical/motion state (the first site's). */\n shared?:string;\n /** The band's first parsed RAW site (its readout identity). */\n firstSite?:SensorRawProducerSiteInput;\n}\nexport function createNativeEnvironmentRawTaskWithCadence(input:NativeEnvironmentRawInput,provider:NativeEnvironmentRawProvider,\n cadence:HostYieldCadence,partition?:NativeEnvironmentPartitionProbe):NativeEnvironmentRawTask {\n const {plan,sceneBinding,retention,maximum}=admitNativeEnvironmentInput(input);\n if(partition&&retention)throw new InvalidConfigurationError(\"A native environment partition cannot retain the optical stage.\");\n if(!provider||typeof provider.readTile!==\"function\"||typeof provider.evaluateRadiance!==\"function\"||typeof provider.yieldControl!==\"function\"||\n (provider.evaluateApertureRadiance!==undefined&&typeof provider.evaluateApertureRadiance!==\"function\")||\n (provider.observePhotoTile!==undefined&&typeof provider.observePhotoTile!==\"function\")||\n (provider.evaluateRadianceBatch!==undefined&&typeof provider.evaluateRadianceBatch!==\"function\"))throw new InvalidConfigurationError(\"Native environment requires physical source callbacks and host yields.\");\n // 2.6: an engine-built evaluator (simulateCapture chart scenes) lets the lean path skip re-parsing the fixed parts of\n // its results; read once, so the checked function is the one bound. Never with a batch, whose results are the caller's.\n const evaluateFunction=provider.evaluateRadiance,internalEvaluator=provider.evaluateRadianceBatch===undefined&&isInternalSceneRadianceEvaluator(evaluateFunction);\n const read=provider.readTile.bind(provider),evaluate=evaluateFunction.bind(provider),aperture=provider.evaluateApertureRadiance?.bind(provider),yieldControl=provider.yieldControl.bind(provider);\n const observe=provider.observePhotoTile?.bind(provider),batch=provider.evaluateRadianceBatch?.bind(provider);\n let evaluations=0,shared:string|undefined,reference:SharedStateReference|undefined;\n const recorder=retention?createNativeEnvironmentOpticalStageRecorder(plan,sceneBinding,retention):undefined;\n const memo=createEnvironmentRawFrameCanonicalMemo(plan.frame,plan.exposureWindow!),gate=createHostYieldGate(cadence);\n const layout=plan.frame.colorSamplingProfile.layout,relationship=plan.frame.bindingProfile.relationship;\n const leanFrame={frameId:plan.frame.frameId,nativeWidth:plan.exposure.geometry.nativeRaster.pixelWidth,\n nativeHeight:plan.exposure.geometry.nativeRaster.pixelHeight,repeatWidth:layout.kind===\"periodic-mosaic\"?layout.repeatWidthSites:0,\n repeatHeight:layout.kind===\"periodic-mosaic\"?layout.repeatHeightSites:0,\n identityBinding:relationship.sitesPerNativeSampleX===1&&relationship.sitesPerNativeSampleY===1&&relationship.anchor===\"shared-native-top-left\"};\n const lean=createNativeEnvironmentLeanExecutor(leanFrame);\n let nativeWindow:Parameters<typeof createNativeEnvironmentSensorLean>[2];\n try{nativeWindow=prepareCaptureExposureWindowSampler({...plan.exposureWindow!,nativeRaster:plan.exposure.geometry.nativeRaster});}catch{nativeWindow=undefined;}\n const sensorLean=createNativeEnvironmentSensorLean(leanFrame,plan.frame,nativeWindow);\n const task=createNativeRawTaskWithCadence(input.raw,{\n async readTile(request,signal){\n const supplied=await read(request,signal);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native environment acquisition aborted.\");\n const tile=requireAllowlistedRecord(supplied,[\"captureId\",\"frameId\",\"x\",\"y\",\"width\",\"height\",\"sites\"],\"Invalid physical source tile.\");\n for(const key of Object.keys(request) as (keyof NativeRawTileRequest)[])if(tile[key]!==request[key])throw new InvalidConfigurationError(\"Physical source tile identity mismatch.\");\n if(!Array.isArray(tile.sites)||tile.sites.length!==request.width||Array.from({length:request.width},(_,i)=>i in (tile.sites as unknown[])).includes(false))throw new InvalidConfigurationError(\"Physical source tile needs exact native coverage.\");\n // Private copy: planning takes each site environment as engine-owned plan data without copying it again.\n const sites=structuredClone(tile.sites) as SimulateEnvironmentSensorRawFrameInput[\"sites\"];\n // Yield to the host between sites on the shared time budget. Cancellation is honoured right after it.\n const pause=async():Promise<void>=>{\n if(!gate.due())return;\n await yieldControl(signal);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native environment acquisition aborted.\");\n gate.restart();\n };\n let tileCount=0;\n const plans:SitePlan[]=[],verified:unknown[]=[];\n for(let j=0;j<sites.length;j++){\n if(j>0)await pause();\n const site=sites[j]!;\n requireAllowlistedRecord(site,[\"environment\",\"darkCurrentProfile\",\"operatingTemperatureC\",\"charge\",\"readout\"],\"Invalid physical site input.\");\n const e=site.environment,index=request.y*plan.exposure.geometry.nativeRaster.pixelWidth+request.x+j;\n if(e.temporalIntegrationId!==plan.frame.frameId+\":native:\"+index)throw new InvalidConfigurationError(\"Native environment IDs must bind the absolute native index.\");\n // A site strictly equal to the frame's first shared state adopts it and skips serialization; otherwise the\n // canonical comparison runs exactly as before and decides acceptance or the same error.\n let state:string;\n if(reference!==undefined&&adoptSharedState(e,reference,verified))state=reference.canonical;\n else{\n state=canonical({sceneBindings:e.sceneBindings,optics:e.optics,motion:e.motion,psf:e.psf,pupil:e.pupil,fieldThroughput:e.fieldThroughput});\n shared??=state;if(partition)partition.shared??=shared;if(state!==shared)throw new InvalidConfigurationError(\"Native event requires one shared source/optical/motion state.\");\n reference??={canonical:state,values:SHARED_STATE_KEYS.map(key=>(e as unknown as Record<string,unknown>)[key]),cleanArrays:new WeakSet()};\n }\n // A site matching a verified template gets a lean plan (identical requests and limit checks; see\n // native-environment-lean.ts). A template candidate keeps full query records for its self-check.\n // Otherwise only the photo signal is needed, so the plan keeps just each query's frozen request and image-plane point.\n const leanPlan=lean.plan(e,index);\n let p:SitePlan;\n if(typeof leanPlan===\"object\")p=leanPlan;\n else{\n p=planEnvironmentRawSite(site,index,plan.frame,sceneBinding,plan.exposureWindow!,\"engine-owned\",memo,leanPlan===\"candidate\"?\"full\":\"photo-only\");\n if(leanPlan===\"candidate\")lean.admitCandidate(e,index,p);\n }\n if(p.owned.pupil&&!aperture)throw new InvalidConfigurationError(\"Pupil capture requires origin-aware source visibility.\");\n recorder?.admit(index,e,state);\n tileCount+=p.count;\n if(tileCount>100_000||evaluations+tileCount>maximum)throw new InvalidConfigurationError(\"Native environment exceeds tile or full-event query budget.\");\n plans.push(p);\n }\n // Only value.photo is consumed, so per-evaluation diagnostics are not retained.\n const rawSites:(ReturnType<typeof composeNativeEnvironmentSensorSite>|object)[]=[],photos:PhotoSignal[]=[];\n sensorLean.beginTile();\n let evaluateCounted=(q:Parameters<typeof evaluate>[0]):ReturnType<typeof evaluate>=>{if(signal.aborted)throw new InvalidConfigurationError(\"Native source evaluation aborted.\");evaluations++;return evaluate(q);};\n let apertureCounted=aperture?(q:Parameters<typeof aperture>[0],ray:Parameters<typeof aperture>[1]):ReturnType<typeof evaluate>=>{if(signal.aborted)throw new InvalidConfigurationError(\"Native aperture evaluation aborted.\");evaluations++;return aperture(q,ray);}:undefined;\n let batched:{queries:readonly NativeEnvironmentRadianceQuery[];results:readonly SceneRadianceEvaluationResult[];next:number}|undefined;\n if(batch){\n // One call for the whole tile, with every planned query in per-query callback order (see tileQueries).\n const queries=tileQueries(plans);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native source evaluation aborted.\");\n const results=await batch(Object.freeze(queries),signal);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native source evaluation aborted.\");\n if(!Array.isArray(results)||results.length!==queries.length||Array.from({length:queries.length},(_,i)=>i in results).includes(false))\n throw new InvalidConfigurationError(\"Batched radiance must return one result per query, in query order.\");\n const current={queries,results:results as readonly SceneRadianceEvaluationResult[],next:0};\n batched=current;\n // The executors ask for each query in the same order; every step is checked against the planned query.\n const take=(q:Readonly<SceneRadianceEvaluationRequest>,ray:Readonly<SensorApertureRay>|undefined):SceneRadianceEvaluationResult=>{\n const k=current.next++,planned=current.queries[k];\n if(planned===undefined||planned.request.sampleId!==q.sampleId||(planned.apertureRay===undefined)!==(ray===undefined))\n throw new InvalidConfigurationError(\"Batched radiance results are out of step with the planned queries.\");\n evaluations++;\n return current.results[k]!;\n };\n evaluateCounted=(q):ReturnType<typeof evaluate>=>take(q,undefined);\n apertureCounted=aperture?(q,ray):ReturnType<typeof evaluate>=>take(q,ray):undefined;\n }\n for(let j=0;j<sites.length;j++){\n await pause();\n const index=request.y*plan.exposure.geometry.nativeRaster.pixelWidth+request.x+j;\n let p=plans[j]!,photoSignal:PhotoSignal|undefined;\n if(isLeanEnvironmentPlan(p)){\n // The full plan (deterministic, no callbacks) is built only when the lean path needs it.\n const fullPlan=():ReturnType<typeof planEnvironmentRawSite>=>planEnvironmentRawSite(sites[j]!,index,plan.frame,sceneBinding,plan.exposureWindow!,\"engine-owned\",memo,\"photo-only\");\n photoSignal=lean.execute(p,evaluateCounted,apertureCounted,fullPlan,internalEvaluator&&!batched);\n // An unverified template: plan this site in full now and execute it in full.\n if(photoSignal===undefined)p=fullPlan();\n }\n if(photoSignal===undefined){\n const full=p as ReturnType<typeof planEnvironmentRawSite>,candidate=lean.isCandidate(index);\n const result=executeEnvironmentSensorPhotoSignal(full,evaluateCounted,apertureCounted,candidate?\"full\":\"photo-only\");\n if(candidate)lean.verifyCandidate(index,full,result);\n photoSignal=result.value.photo.value.photoSignal;\n }\n recorder?.record(index,photoSignal);\n photos.push(photoSignal);\n // A site matching a verified sensor template becomes a lean entry: every check its composition and RAW\n // parse would run has been evaluated (see native-environment-lean.ts). Otherwise compose it in full.\n const claimed=sensorLean.claim(sites[j]!,photoSignal,index);\n if(claimed)rawSites.push(claimed);\n else{rawSites.push(composeNativeEnvironmentSensorSite(sites[j]!,photoSignal));sensorLean.remember(index,sites[j]!,photoSignal);}\n }\n if(batched&&batched.next!==batched.queries.length)throw new InvalidConfigurationError(\"Batched radiance results are out of step with the planned queries.\");\n if(signal.aborted)throw new InvalidConfigurationError(\"Native photo observation aborted.\");\n if(observe)await observe(freezeOwnedData({...request,sites:photos.map((s,j)=>({nativeIndex:request.y*plan.exposure.geometry.nativeRaster.pixelWidth+request.x+j,\n expectedIncidentPhotonCount:s.expectedIncidentPhotonCount,expectedGeneratedElectronCount:s.expectedGeneratedElectronCount}))}),signal);\n return {...request,sites:rawSites as ReturnType<typeof composeNativeEnvironmentSensorSite>[]};\n },yieldControl\n },cadence,gate,sensorLean.hook,partition?{y:partition.rows.y,height:partition.rows.height,firstSite:(site):void=>{partition.firstSite=site;},\n ...(partition.columns?{x:partition.columns.x,width:partition.columns.width}:{})}:undefined);\n // The frame reference is needed only while tiles are read; release it once the event settles.\n const settle=():void=>{reference=undefined;};\n return {plan:task.plan,get state():NativeRawTaskState{return task.state;},get completedTileCount():number{return task.completedTileCount;},get providerEvaluationCount():number{return evaluations;},\n run:():Promise<void>=>(recorder?task.run().catch((error:unknown)=>{if(task.state===\"failed\"||task.state===\"cancelled\"||task.state===\"disposed\")recorder.discard();throw error;}):task.run()).finally(settle),\n cancel:():void=>{if(task.state!==\"transferred\")recorder?.discard();task.cancel();},dispose:():void=>{if(task.state!==\"transferred\")recorder?.discard();task.dispose();},\n takeOutput():NativeEnvironmentRawOutput{\n // Finish retention first so a retention failure never strands the transferred RAW.\n const opticalStage=recorder&&task.state===\"completed\"?recorder.finish(evaluations):undefined;\n const raw=task.takeOutput();\n const base={raw,sceneBinding,providerEvaluationCount:evaluations,upstreamOrigin:\"executed-environment-query-provider-optics-psf-eqe\" as const,providerTransportVerified:false as const,productionPlanActivated:false as const};\n return opticalStage?{...base,opticalStage}:base;\n }\n };\n}\n/**\n * Internal (not exported from the package; 2.3 `simulateCapture` `output.region`): the task for one rectangle of\n * native sites [x, x + width) × [y, y + height) of the whole-frame input. Every site keeps its absolute native index,\n * so its noise seeds, CFA phase, exposure window (rolling-shutter row timing) and value are those of the whole-frame\n * task; the output arrays hold just the rectangle, row-major, and `effectiveSaturationCodes` holds 0 for a CFA\n * phase the rectangle does not contain. Optical-stage retention is not supported.\n */\nexport function createNativeEnvironmentRawRegionTask(input:NativeEnvironmentRawInput,region:{x:number;y:number;width:number;height:number},\n provider:NativeEnvironmentRawProvider):NativeEnvironmentRawTask {\n const plan=calculateNativeRawPlan(input?.raw),native=plan.exposure.geometry.nativeRaster;\n const r=requireAllowlistedRecord(region,[\"x\",\"y\",\"width\",\"height\"],\"Invalid native RAW region.\");\n if(![r.x,r.y,r.width,r.height].every(v=>typeof v===\"number\"&&Number.isSafeInteger(v))||(r.width as number)<1||(r.x as number)<0||(r.x as number)+(r.width as number)>native.pixelWidth)\n throw new InvalidConfigurationError(\"Native RAW region must lie inside the native raster.\");\n const rows=parseRowBand({y:r.y,height:r.height},native.pixelHeight);\n return createNativeEnvironmentRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE,{rows,columns:{x:r.x as number,width:r.width as number}});\n}\n/** A band of whole native rows, [y, y + height), in absolute full-sensor coordinates. */\nexport interface NativeRawRowBand { y: number; height: number }\n/**\n * Splits a plan's native rows into at most `count` contiguous bands of nearly equal height (the first\n * `height % count` bands are one row taller), in row order. Deterministic: it depends only on the raster height and\n * `count`. Use one band per worker with createNativeEnvironmentRawPartitionTask.\n */\nexport function calculateNativeRawRowBands(plan:Pick<NativeRawPlan,\"exposure\">,count:number):NativeRawRowBand[] {\n if(plan!==null&&typeof plan===\"object\")rejectUnknownFields(plan,[\"schemaVersion\",\"exposure\",\"frame\",\"exposureWindow\",\"pixelCount\",\"outputBytes\",\"tileCount\",\n \"tileWidth\",\"upstreamRadiometryVerified\",\"seedSchedule\"],\"Native RAW plan\");\n const height=plan?.exposure?.geometry?.nativeRaster?.pixelHeight;\n if(typeof height!==\"number\"||!Number.isSafeInteger(height)||height<1)throw new InvalidConfigurationError(\"Native RAW partitioning requires a native RAW plan.\");\n if(typeof count!==\"number\"||!Number.isSafeInteger(count)||count<1||count>1024)throw new InvalidConfigurationError(\"Native RAW partition count must be an integer from 1 to 1024.\");\n const bands=Math.min(count,height),base=Math.floor(height/bands),extra=height%bands,result:NativeRawRowBand[]=[];\n for(let i=0,y=0;i<bands;i++){const h=base+(i<extra?1:0);result.push({y,height:h});y+=h;}\n return result;\n}\n/**\n * One partition's result: plain data and typed arrays only, so it can be posted from a worker (transfer the four\n * arrays' buffers). Merge every partition of a capture with composeNativeEnvironmentRawPartitions.\n */\nexport interface NativeEnvironmentRawPartition {\n rows: NativeRawRowBand;\n /** Canonical JSON of the capture input (raw, sceneBinding, maximumProviderEvaluations); the merge requires it to match. */\n inputCanonical: string;\n /** Canonical JSON of the band's shared source/optical/motion state; every partition must match. */\n sharedStateCanonical: string;\n /** Readout identity of the band's first site; every partition must match (one readout identity per frame). */\n readoutIdentity: { readoutProfileId: string; regimeId: string; fixedPatternProfileId: string | null; fixedPatternSeedUint32: number | null };\n /** The band's rows only, row-major, as in NativeRawOutput. */\n codes: Uint16Array;\n blackLevels: Uint16Array;\n digitalSaturationCodes: Uint16Array;\n saturationFlags: Uint8Array;\n /** Effective white code per CFA phase; 0 for a phase the band does not contain. */\n effectiveSaturationCodes: Uint16Array;\n providerEvaluationCount: number;\n}\nexport interface NativeEnvironmentRawPartitionTask extends Omit<NativeRawTask,\"takeOutput\"> {\n readonly rows: NativeRawRowBand;\n readonly providerEvaluationCount: number;\n takeOutput(): NativeEnvironmentRawPartition;\n}\nfunction inputCanonical(input:NativeEnvironmentRawInput):string {\n return canonical({raw:input.raw,sceneBinding:input.sceneBinding,maximumProviderEvaluations:input.maximumProviderEvaluations});\n}\nfunction parseRowBand(value:unknown,height:number):NativeRawRowBand {\n const band=requireAllowlistedRecord(value,[\"y\",\"height\"],\"Invalid native RAW row band.\");\n if(typeof band.y!==\"number\"||typeof band.height!==\"number\"||!Number.isSafeInteger(band.y)||!Number.isSafeInteger(band.height)||\n band.y<0||band.height<1||band.y+band.height>height)throw new InvalidConfigurationError(\"Native RAW row band must lie inside the native raster.\");\n return {y:band.y,height:band.height};\n}\n/**\n * Creates the task for one row band of a native environment capture (opt-in parallel execution, 2.0).\n *\n * Run one partition per worker (or one after another) with the same input, each worker using its own provider, then\n * merge them with composeNativeEnvironmentRawPartitions. The merged output is byte-identical to the single\n * createNativeEnvironmentRawTask output for the same input and a deterministic provider: noise seeds use absolute\n * native indices, and tiles, plans and per-site values are those of the whole-frame task.\n *\n * Each partition checks the same inputs and limits before its callbacks. maximumProviderEvaluations bounds each\n * partition's own work; the merge also rejects a total above it. Frame-wide checks that span sites (one shared\n * state, one readout identity, one white level per CFA phase) run inside each band and again across bands in the\n * merge. Callbacks are split across partitions, and when several partitions fail, which error is seen first depends\n * on the caller's scheduling. Optical-stage retention is not supported in a partition.\n *\n * The package bundles no worker code: the caller creates workers (Web Workers or Node worker threads), runs this\n * task inside each and posts the partition back.\n */\nexport function createNativeEnvironmentRawPartitionTask(input:NativeEnvironmentRawInput,rows:NativeRawRowBand,\n provider:NativeEnvironmentRawProvider):NativeEnvironmentRawPartitionTask {\n const plan=calculateNativeRawPlan(input?.raw),band=parseRowBand(rows,plan.exposure.geometry.nativeRaster.pixelHeight);\n const probe:NativeEnvironmentPartitionProbe={rows:band};\n const task=createNativeEnvironmentRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE,probe),text=inputCanonical(input);\n return {plan:task.plan,rows:band,get state():NativeRawTaskState{return task.state;},get completedTileCount():number{return task.completedTileCount;},\n get providerEvaluationCount():number{return task.providerEvaluationCount;},run:():Promise<void>=>task.run(),cancel:():void=>task.cancel(),dispose:():void=>task.dispose(),\n takeOutput():NativeEnvironmentRawPartition{\n if(task.state!==\"completed\"||probe.shared===undefined||probe.firstSite===undefined)throw new InvalidConfigurationError(\"Native RAW output unavailable.\");\n const site=probe.firstSite,sharedStateCanonical=probe.shared,output=task.takeOutput(),raw=output.raw;\n return {rows:{...band},inputCanonical:text,sharedStateCanonical,readoutIdentity:{readoutProfileId:site.readoutProfile.profileId,regimeId:site.regimeId,\n fixedPatternProfileId:site.fixedPatternNoise?.profileId??null,fixedPatternSeedUint32:site.fixedPatternNoise?.sensorInstanceSeedUint32??null},\n codes:raw.codes,blackLevels:raw.blackLevels,digitalSaturationCodes:raw.digitalSaturationCodes,saturationFlags:raw.saturationFlags,\n effectiveSaturationCodes:raw.effectiveSaturationCodes,providerEvaluationCount:output.providerEvaluationCount};\n }\n };\n}\n/**\n * Assembles the partitions of one capture into the output createNativeEnvironmentRawTask would have returned for\n * the same input (byte-identical RAW arrays and white levels, the summed provider evaluation count).\n *\n * The partitions must be in row order and cover every native row exactly once, and each must come from\n * createNativeEnvironmentRawPartitionTask with this same input. It rejects, with InvalidConfigurationError, a\n * different input, a gap or overlap, wrong array types or lengths, a second shared state or readout identity, two\n * white levels for one CFA phase, a missing phase, or a total evaluation count above the input's budget. It cannot\n * verify how a partition was computed: posted partitions are the caller's own data.\n */\nexport function composeNativeEnvironmentRawPartitions(input:NativeEnvironmentRawInput,partitions:readonly NativeEnvironmentRawPartition[]):NativeEnvironmentRawOutput {\n const {plan,sceneBinding,retention,maximum}=admitNativeEnvironmentInput(input);\n if(retention)throw new InvalidConfigurationError(\"A native environment partition cannot retain the optical stage.\");\n const native=plan.exposure.geometry.nativeRaster,width=native.pixelWidth,layout=plan.frame.colorSamplingProfile.layout;\n if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Native RAW requires periodic CFA.\");\n const phases=layout.repeatWidthSites*layout.repeatHeightSites,text=inputCanonical(input);\n if(!Array.isArray(partitions)||partitions.length<1||partitions.length>native.pixelHeight||Array.from({length:partitions.length},(_,i)=>i in partitions).includes(false))\n throw new InvalidConfigurationError(\"Native RAW merge requires a dense list of partitions.\");\n const codes=new Uint16Array(plan.pixelCount),blackLevels=new Uint16Array(plan.pixelCount),digitalSaturationCodes=new Uint16Array(plan.pixelCount),saturationFlags=new Uint8Array(plan.pixelCount);\n const white=createPhaseWhiteLevelAccumulator(width,layout.repeatWidthSites,layout.repeatHeightSites);\n let y=0,total=0,shared:string|undefined,identity:string|undefined;\n for(const value of partitions){\n const p=requireAllowlistedRecord(value,[\"rows\",\"inputCanonical\",\"sharedStateCanonical\",\"readoutIdentity\",\"codes\",\"blackLevels\",\"digitalSaturationCodes\",\n \"saturationFlags\",\"effectiveSaturationCodes\",\"providerEvaluationCount\"],\"Invalid native RAW partition.\");\n const band=parseRowBand(p.rows,native.pixelHeight),length=band.height*width;\n if(band.y!==y)throw new InvalidConfigurationError(\"Native RAW partitions must cover every row once, in row order.\");\n if(p.inputCanonical!==text)throw new InvalidConfigurationError(\"Native RAW partition was computed from a different input.\");\n if(!(p.codes instanceof Uint16Array)||!(p.blackLevels instanceof Uint16Array)||!(p.digitalSaturationCodes instanceof Uint16Array)||\n !(p.saturationFlags instanceof Uint8Array)||!(p.effectiveSaturationCodes instanceof Uint16Array)||p.codes.length!==length||p.blackLevels.length!==length||\n p.digitalSaturationCodes.length!==length||p.saturationFlags.length!==length||p.effectiveSaturationCodes.length!==phases||\n typeof p.providerEvaluationCount!==\"number\"||!Number.isSafeInteger(p.providerEvaluationCount)||p.providerEvaluationCount<0||typeof p.sharedStateCanonical!==\"string\")\n throw new InvalidConfigurationError(\"Invalid native RAW partition arrays.\");\n const id=requireAllowlistedRecord(p.readoutIdentity,[\"readoutProfileId\",\"regimeId\",\"fixedPatternProfileId\",\"fixedPatternSeedUint32\"],\"Invalid native RAW partition identity.\");\n const idText=canonical(id);\n shared??=p.sharedStateCanonical;identity??=idText;\n if(p.sharedStateCanonical!==shared)throw new InvalidConfigurationError(\"Native event requires one shared source/optical/motion state.\");\n if(idText!==identity)throw new InvalidConfigurationError(\"Frame requires one readout identity/regime, one fixed-pattern identity and a positive uint16 RAW code span.\");\n const offset=band.y*width;\n codes.set(p.codes,offset);blackLevels.set(p.blackLevels,offset);digitalSaturationCodes.set(p.digitalSaturationCodes,offset);saturationFlags.set(p.saturationFlags,offset);\n for(let phase=0;phase<phases;phase++)white.recordPhase(phase,p.effectiveSaturationCodes[phase]!);\n total+=p.providerEvaluationCount;y+=band.height;\n }\n if(y!==native.pixelHeight)throw new InvalidConfigurationError(\"Native RAW partitions must cover every row once, in row order.\");\n if(total>maximum)throw new InvalidConfigurationError(\"Native environment exceeds tile or full-event query budget.\");\n const raw:NativeRawOutput={plan,codes,blackLevels,digitalSaturationCodes,saturationFlags,effectiveSaturationCodes:white.finish()};\n return {raw,sceneBinding,providerEvaluationCount:total,upstreamOrigin:\"executed-environment-query-provider-optics-psf-eqe\",providerTransportVerified:false,productionPlanActivated:false};\n}\n/**\n * Re-runs only the sensor stage from a retained optical stage. No radiance callback is called.\n *\n * Use it when only post-optics settings change: noise seed, ISO and its readout regime and gain,\n * fixed-pattern noise, charge, dark-current and capacity profiles, white-balance intent, capture identity\n * or tile width. White balance and rendering are then applied by createNativeRawDevelopmentTask as usual.\n *\n * RAW codes are bit-identical to a full createNativeEnvironmentRawTask with the same final inputs, as long\n * as the radiance provider is a deterministic function of its request.\n *\n * Any optical difference is rejected with InvalidConfigurationError before output. That includes scene\n * binding, geometry or orientation, focal length, aperture, shutter or exposure window, focus,\n * frame/CFA/binding profiles, and any site environment field such as PSF, field throughput, pupil, motion,\n * spectral or temporal sampling and provider profiles.\n *\n * providerEvaluationCount is 0. The caller still owns the stage; it is not used up.\n */\nexport function createNativeEnvironmentSensorStageTask(input:NativeEnvironmentSensorStageInput,opticalStage:NativeEnvironmentOpticalStage,\n provider:NativeEnvironmentSensorStageProvider):NativeEnvironmentRawTask {\n const {task,sceneBinding}=createSensorStageRawTask(input,opticalStage,provider,parseSceneBinding);\n return {plan:task.plan,get state():NativeRawTaskState{return task.state;},get completedTileCount():number{return task.completedTileCount;},get providerEvaluationCount():number{return 0;},\n run:():Promise<void>=>task.run(),cancel:():void=>task.cancel(),dispose:():void=>task.dispose(),\n takeOutput():NativeEnvironmentRawOutput{return {raw:task.takeOutput(),sceneBinding,providerEvaluationCount:0,upstreamOrigin:\"executed-environment-query-provider-optics-psf-eqe\",providerTransportVerified:false,productionPlanActivated:false};}\n };\n}\n"]}
@@ -64,6 +64,11 @@ export declare function createPlanckianSpectrum(input: {
64
64
  temperatureKelvin: number;
65
65
  wavelengthRangeNanometers: SpectralWavelengthRangeNanometers;
66
66
  }): ColorimetricSpectrum;
67
+ /** Internal (not exported from the package): {@link createPlanckianSpectrum} evaluated with the portable functions (the display view). */
68
+ export declare function createPortablePlanckianSpectrum(input: {
69
+ temperatureKelvin: number;
70
+ wavelengthRangeNanometers: SpectralWavelengthRangeNanometers;
71
+ }): ColorimetricSpectrum;
67
72
  /** CIE illuminant A defining range (nm). */
68
73
  export declare const CIE_ILLUMINANT_A_RANGE_NANOMETERS: Readonly<{
69
74
  minimum: 300;
@@ -77,6 +82,8 @@ export declare const CIE_ILLUMINANT_A_RANGE_NANOMETERS: Readonly<{
77
82
  export declare function calculateCieIlluminantARelativeSpectralPower(wavelengthNanometers: number): number;
78
83
  /** CIE illuminant A as a function spectrum over its defining range. */
79
84
  export declare function createCieIlluminantASpectrum(): ColorimetricSpectrum;
85
+ /** Internal (not exported from the package): {@link createCieIlluminantASpectrum} evaluated with the portable functions (the display view). */
86
+ export declare function createPortableCieIlluminantASpectrum(): ColorimetricSpectrum;
80
87
  export interface CieDaylightComponentWeights {
81
88
  correlatedColorTemperatureKelvin: number;
82
89
  chromaticity: CieXyChromaticity;
@@ -112,6 +119,8 @@ export declare function createCieDaylightSpectrum(input: {
112
119
  coefficientRounding: "none" | "cie-three-decimals";
113
120
  basis: CieDaylightBasis;
114
121
  }): ColorimetricSpectrum;
122
+ /** Internal (not exported from the package): {@link createCieDaylightSpectrum} with the portable daylight-locus powers (the display view). */
123
+ export declare function createPortableCieDaylightSpectrum(input: Parameters<typeof createCieDaylightSpectrum>[0]): ColorimetricSpectrum;
115
124
  /** Selects how the Planckian locus is evaluated. */
116
125
  export type PlanckianLocusModel = {
117
126
  /** Planck's law integrated against the engine's analytic CIE 1931 CMFs, 1 nm nodes 360–830 nm (the default). */
@@ -180,3 +189,9 @@ export declare function calculateChromaticityFromCorrelatedColorTemperature(inpu
180
189
  whiteLocus: WhiteLocus;
181
190
  locus: PlanckianLocusModel;
182
191
  }): CalculationResult<CieXyChromaticity>;
192
+ /**
193
+ * Internal (not exported from the package): {@link calculateChromaticityFromCorrelatedColorTemperature} with the locus's
194
+ * λ⁻⁵, e^x − 1 and normal length and the daylight-locus powers from the portable functions (the display view's Kelvin
195
+ * white balance), so the result has the same bits in every JavaScript engine.
196
+ */
197
+ export declare function calculatePortableChromaticityFromCorrelatedColorTemperature(input: Parameters<typeof calculateChromaticityFromCorrelatedColorTemperature>[0]): CalculationResult<CieXyChromaticity>;