rspace-online/shared/markwhen/index.ts

51 lines
2.0 KiB
TypeScript

/**
* Bootstrap + re-exports for the markwhen projection layer.
*
* Two complementary projections:
* - **Scheduled** (MarkwhenSourceFactory): "what's happening / will happen" —
* events with explicit start/end (rCal, rSchedule).
* - **Creations** (CreationEnumerator / CreationSpec): "what has been made" —
* every CRDT record's birth moment across every rApp. This is what rPast
* renders. Declared statically in `creation-specs.ts`.
*
* Call `initMarkwhen(loader)` once at server/client start.
*/
import { setDocLoader, type DocLoader } from './doc-loader';
import { registerMarkwhenSource } from './registry';
import { registerCreationEnumerator } from './creations';
import { createCreationEnumerator } from './universal-enumerator';
import { ALL_CREATION_SPECS } from './creation-specs';
// Scheduled-event adapters (keep alongside the creation log).
import { rcalMarkwhenSource } from './sources/rcal';
import { rnotesMarkwhenSource } from './sources/rnotes';
export { projectSpace, listMarkwhenSources, getMarkwhenSource, registerMarkwhenSource } from './registry';
export { renderMarkwhen } from './projection';
export {
enumerateCreations, registerCreationEnumerator, listCreationEnumerators,
} from './creations';
export type { Creation, CreationEnumerator } from './creations';
export type { CreationSpec, CreationCollection } from './universal-enumerator';
export { createCreationEnumerator } from './universal-enumerator';
export type { MwEvent, MwSource, MwProjection, MarkwhenSourceFactory } from './types';
let initialized = false;
export function initMarkwhen(loader: DocLoader): void {
if (initialized) return;
setDocLoader(loader);
// Scheduled-event sources (rCal standalone timeline, etc.).
registerMarkwhenSource(rcalMarkwhenSource);
registerMarkwhenSource(rnotesMarkwhenSource);
// Creation-log enumerators — the declarative universal pass.
for (const spec of ALL_CREATION_SPECS) {
registerCreationEnumerator(createCreationEnumerator(spec));
}
initialized = true;
}