Resolve default image sizes atomically with creation history and recovery
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
import type { Change, Document, ElementRecord, Geometry, HistoryState, Id, Registry, Target } from './types.ts';
|
||||
import type { Change, CreationSizeEffect, Document, ElementRecord, Geometry, HistoryState, Id, Registry, Target } from './types.ts';
|
||||
import { applyChanges, invert, validateDocument } from './document.ts';
|
||||
import { closeNumber, unitScale } from './units.ts';
|
||||
import { equal, fault, freeze, readMap } from './values.ts';
|
||||
import { equal, fault, freeze, readMap, validJson } from './values.ts';
|
||||
|
||||
export function validateCreationSizeEffect(value: unknown): asserts value is CreationSizeEffect {
|
||||
const effect = value as CreationSizeEffect | undefined;
|
||||
if (!effect || effect.version !== 1 || effect.kind !== 'creation-size') throw fault('history_effect_interpreter_unavailable');
|
||||
if (!validJson(effect) || typeof effect.entryId !== 'string' || !effect.entryId || typeof effect.target?.id !== 'string' || !effect.target.id
|
||||
|| !Number.isSafeInteger(effect.target.incarnation) || effect.target.incarnation < 1
|
||||
|| !effect.size || ![effect.size.width, effect.size.height].every(value => typeof value === 'number' && Number.isFinite(value) && value > 0)) throw fault('invalid_creation_size_effect');
|
||||
}
|
||||
|
||||
/** A pure proposal, not a publication API. The coordinator must still validate a
|
||||
* durable sizing grant and record a recoverable history effect before adopting it.
|
||||
|
||||
Reference in New Issue
Block a user