qnce-engine
Version:
Core QNCE (Quantum Narrative Convergence Engine) - Framework agnostic narrative engine with performance optimization
124 lines • 3.13 kB
TypeScript
import { NarrativeNode, StoryData } from '../engine/core';
export interface Asset {
id: string;
type: 'image' | 'audio' | 'video';
src: string;
size?: number;
}
export interface StoryDelta {
nodeChanges: NodeDelta[];
assetChanges: AssetDelta[];
timestamp: number;
}
export interface NodeDelta {
nodeId: string;
changeType: 'added' | 'modified' | 'removed';
oldNode?: NarrativeNode;
newNode?: NarrativeNode;
affectedFields: (keyof NarrativeNode | '*')[];
}
export interface AssetDelta {
assetId: string;
changeType: 'added' | 'modified' | 'removed';
oldAsset?: Asset;
newAsset?: Asset;
sizeChange: number;
}
interface PatchableEngine {
storyData: StoryData;
getState(): {
currentNodeId: string;
};
}
export interface ExtendedStoryData extends StoryData {
assets?: Asset[];
}
/**
* Delta Comparison Engine for Hot-Reload Story Updates
* Identifies minimal changes needed to update narrative content
*/
export declare class StoryDeltaComparator {
/**
* Compare two story configurations and generate delta
*/
compareStories(oldStory: ExtendedStoryData, newStory: ExtendedStoryData): StoryDelta;
/**
* Deep comparison of narrative nodes
*/
private compareNodes;
/**
* Compare assets (future: images, audio, etc.)
*/
private compareAssets;
/**
* Fine-grained field comparison for nodes
*/
private findChangedFields;
/**
* Asset comparison logic
*/
private assetsAreDifferent;
/**
* Deep equality check for objects
*/
private deepEqual;
}
/**
* Hot-Reload Delta Patcher
* Applies story deltas with minimal engine disruption
*/
export declare class StoryDeltaPatcher {
private engine;
constructor(engine: PatchableEngine);
/**
* Apply delta patch to running engine
* Target: <2ms frame stall for hot-reload
*/
applyDelta(delta: StoryDelta): Promise<PatchResult>;
/**
* Validate delta is safe to apply
*/
private validateDelta;
/**
* Apply node changes to story data
*/
private applyNodeChanges;
/**
* Fast synchronous node changes for small deltas (no async overhead)
*/
private applyNodeChangesFast;
/**
* Apply asset changes (placeholder for future implementation)
*/
private applyAssetChanges;
/**
* Batch node changes by type for efficient processing
*/
private batchNodeChanges;
/**
* Process a batch of node changes
*/
private processBatch;
/**
* Apply individual node change
*/
private applyNodeChange;
/**
* Refresh engine state after patch
*/
private refreshEngineState;
}
export interface PatchResult {
success: boolean;
patchId: string;
duration: number;
nodesChanged?: number;
assetsChanged?: number;
error?: string;
}
export declare function createDeltaTools(engine: PatchableEngine): {
comparator: StoryDeltaComparator;
patcher: StoryDeltaPatcher;
};
export {};
//# sourceMappingURL=HotReloadDelta.d.ts.map