mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-02 02:21:02 +08:00
* Broadcast ordered edit batches and apply confirmed peer patches * Commit ordered Studio text edits with independent receipts * Queue independent Studio edits in ordered project batches * Document ordered edits and retry interrupted batch responses * Decouple canvas gestures from ordered save acknowledgements * Preserve edit order across guarded semantic writes and cold source reads * Recognize compiler-assigned element IDs when replaying canvas gestures * Validate replay against the source with stable element IDs * Apply declarative media inspector updates to the mounted preview * Project verified peer paint alongside local canvas placement * Schedule timeline edits in gesture order and project pending structure locally * Present compatible peer paint while a canvas edit is outstanding * Keep a drag active when capture drops over the pressed canvas * Keep the latest timeline projection across delayed edit receipts * Keep media speed changes in place and order guarded file writes * Cancel a gesture when its source element is deleted remotely * Retire deleted gestures once and discard late tap measurements * Handle confirmed deletion of the gesture source file * Keep independent timeline gestures editable after an invalid target * Restore confirmed timeline rows after a burst of rejected gestures * Exercise 100 real canvas drags against an isolated QA project * Clarify which preview updates preserve the mounted document * Verify speed and linked timing in the same preview update * Start ordered deliveries at their deadline with a fixed prefix * Narrow nullable file versions in both backend typecheck modes * Keep root HTML materialization out of patch commits --------- Co-authored-by: lefarcen <935902669@qq.com>
51 lines
2.6 KiB
TypeScript
51 lines
2.6 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { OrderedEditEvents } from '../../src/services/ordered-edit-events.ts';
|
|
import type { CommitProjectFilesResult } from '../../src/services/project-files-service.ts';
|
|
import type { PendingTextRevision } from '../../src/services/project-text-edits.ts';
|
|
import type { ProjectEvent } from '../../src/contracts/events.ts';
|
|
|
|
const path = 'scene.html';
|
|
function step(n: number): CommitProjectFilesResult {
|
|
return { projectId: 'p', revision: 'r' + n, previousRevision: 'r' + (n-1), versionId: 'v' + n,
|
|
versionNumber: n, historySeq: n, changedPaths: [path], deletedPaths: [], versionsByPath: {[path]: '"patch:' + n + '"'},
|
|
affectsPreview: true, affectedCompositions: [path], writeToken: 'op' + n, replayed: false };
|
|
}
|
|
|
|
function delta(n: number, inserted = 'a'): PendingTextRevision {
|
|
return {path, parentScope: 'patch', parentId: String(n-1), sizeBytes: 15, depth: 1,
|
|
chainPatchBytes: 0, checkpointDue: false, mimeType: 'text/html', patch: [[10, 0, inserted]]};
|
|
}
|
|
|
|
async function deliveries(collector: OrderedEditEvents) {
|
|
const seen: ProjectEvent[] = [];
|
|
await collector.publish(async item => { seen.push(item); });
|
|
return seen;
|
|
}
|
|
|
|
test('one ordered file event carries 100 committed patches, plus a history notification for older tabs', async () => {
|
|
const collector = new OrderedEditEvents('w', 'p');
|
|
for (let n = 1; n <= 100; n++) collector.record(step(n), [delta(n)]);
|
|
collector.record({...step(1), replayed: true}, [delta(1)]);
|
|
const seen = await deliveries(collector);
|
|
assert.equal(seen.length, 2);
|
|
const [files, history] = seen;
|
|
assert.ok(files.type === 'files-changed' && history.type === 'history-changed');
|
|
assert.equal(history.includedInOrderedEdit, true);
|
|
assert.equal(files.ordered?.fromRevision, 'r0');
|
|
assert.deepEqual(files.ordered?.steps.map(s => s.id), Array.from({length:100},(_,i) => 'op'+(i+1)));
|
|
assert.deepEqual(files.ordered?.steps[99].patches?.[0],
|
|
{path, from: '"patch:99"', to: '"patch:100"', patch: [[10,0,'a']]});
|
|
assert.deepEqual(files.fileVersions, {[path]: '"patch:100"'});
|
|
});
|
|
|
|
test('interleaved commits split ranges; oversized changes omit patch bodies', async () => {
|
|
const collector = new OrderedEditEvents('w','p');
|
|
collector.record(step(1), [delta(1)]);
|
|
collector.record(step(3), [delta(3, 'a'.repeat(70*1024))]);
|
|
const seen = await deliveries(collector);
|
|
const files = seen.filter((e): e is Extract<ProjectEvent, {paths: string[]}> => e.type === 'files-changed');
|
|
assert.deepEqual(files.map(e => e.ordered?.fromRevision), ['r0','r2']);
|
|
for (const event of files) assert.equal(event.ordered?.steps[0].patches, undefined);
|
|
});
|