
Security News
Microsoft Releases Open Source Toolkit for AI Agent Runtime Security
Microsoft has released an open source toolkit for enforcing runtime security policies on AI agents as adoption accelerates faster than governance controls.
@chronux/core
Advanced tools
Core utilities for the Chronux platform - a modern, platform-agnostic TypeScript package featuring a powerful headless calendar library.
npm install @chronux/core
The core package includes a powerful headless calendar library that provides:
import { Calendar, createCalendar, selectionFeature } from '@chronux/core';
// Create a calendar with events
const calendar = new Calendar({
events: [
{
id: '1',
start: new Date('2024-01-15'),
end: new Date('2024-01-15'),
data: { title: 'Meeting' },
},
],
defaultView: 'month',
_features: {
selection: selectionFeature({ multiple: true }),
},
});
// Subscribe to state changes
const unsubscribe = calendar.subscribe(state => {
console.log('Calendar state changed:', state);
});
// Navigate
calendar.next();
calendar.previous();
calendar.goToDate(new Date('2024-03-01'));
// Get data
const cells = calendar.getCells();
const events = calendar.getEvents();
const selectedDates = calendar.getState().selection;
The calendar provides three types of subscriptions for efficient state monitoring:
Subscribe to all state changes:
const unsubscribe = calendar.subscribe(state => {
console.log('Full state changed:', state);
});
Subscribe to computed values using selectors:
// Subscribe to event count changes
const unsubscribeEventCount = calendar.subscribeToSelector<number>(
state => state.events.length,
(value, prevValue) => {
console.log('Event count changed from', prevValue, 'to', value);
}
);
// Subscribe to complex computed values
const unsubscribeTodayEvents = calendar.subscribeToSelector<number>(
state => {
const today = new Date();
return state.events.filter(
event => event.start.toDateString() === today.toDateString()
).length;
},
(value, prevValue) => {
console.log('Today events changed from', prevValue, 'to', value);
}
);
// Subscribe to selection state
const unsubscribeSelectionState = calendar.subscribeToSelector<boolean>(
state => state.selection.length > 0,
(value, prevValue) => {
console.log('Has selection changed:', value);
}
);
// Multiple subscriptions
const unsubscribe1 = calendar.subscribeToSelector<number>(
state => state.events.length,
() => {}
);
// Unsubscribe individually
unsubscribe1();
// Or let them be cleaned up automatically on destroy
calendar.destroy();
import { Calendar, createCalendar } from '@chronux/core';
// Simple calendar
const calendar = createCalendar({
events: [],
defaultView: 'month',
});
// With custom event types
interface MyEvent {
id: string;
start: Date;
end: Date;
title: string;
description?: string;
}
const typedCalendar = new Calendar<MyEvent>({
events: [
{
id: '1',
start: new Date(),
end: new Date(),
title: 'My Event',
},
],
getEventId: event => event.id,
getEventStart: event => event.start,
getEventEnd: event => event.end,
});
The calendar supports multiple built-in views:
// Month view (default)
calendar.setView('month');
// Week view
calendar.setView('week');
// Day view
calendar.setView('day');
// Add event
calendar.addEvent({
id: 'new-event',
start: new Date(),
end: new Date(),
data: { title: 'New Event' },
});
// Update event
calendar.updateEvent('event-id', {
data: { title: 'Updated Event' },
});
// Remove event
calendar.removeEvent('event-id');
// Get events for specific date
const eventsForDate = calendar.getEventsForDate(new Date());
// Get events in visible range
const visibleEvents = calendar.getEvents();
// Single selection
calendar.selectDate(new Date());
// Multiple selection
calendar.selectDate(new Date(), true);
// Clear selection
calendar.clearSelection();
// With selection feature
const calendarWithSelection = new Calendar({
data: [],
_features: {
selection: selectionFeature({
multiple: true,
range: true,
}),
},
});
// Use selection API
calendarWithSelection.selection.toggle(new Date());
calendarWithSelection.selection.selectRange(startDate, endDate);
import type { ViewDefinition } from '@chronux/core';
const customView: ViewDefinition = {
id: 'custom',
getDateRange: date => ({
start: new Date(date.getFullYear(), date.getMonth(), 1),
end: new Date(date.getFullYear(), date.getMonth() + 1, 0),
}),
getGrid: () => ({ rows: 5, columns: 7 }),
getCellDate: (row, col, startDate) => {
// Custom cell date calculation
return new Date(
startDate.getTime() + (row * 7 + col) * 24 * 60 * 60 * 1000
);
},
};
const calendar = new Calendar({
data: [],
views: {
custom: customView,
},
defaultView: 'custom',
});
import { dragDropFeature } from '@chronux/core';
const calendar = new Calendar({
data: [],
_features: {
dragDrop: dragDropFeature({
onDrop: (event, newDate) => {
// Custom drop logic
return true; // Allow drop
},
}),
},
});
// Use drag and drop API
calendar.dragDrop.startDrag(event);
calendar.dragDrop.drop(newDate);
new Calendar<TEvent, TResource>(options: CalendarOptions<TEvent, TResource>)
State Management
getState(): CalendarState<TEvent> - Get current statesetState(updater): void - Update statesubscribe(listener): () => void - Subscribe to all state changessubscribeToSelector<T>(selector, listener): () => void - Subscribe to computed valuesdestroy(): void - Clean up resourcesNavigation
next(): void - Go to next periodprevious(): void - Go to previous periodgoToDate(date): void - Go to specific datetoday(): void - Go to todayViews
setView(viewId): void - Change viewgetHeaderGroups(): Array<{id: string, headers: string[]}> - Get header datagetRowModel(): {rows: Row<TEvent>[]} - Get row modelgetCells(): Cell<TEvent>[][] - Get cell dataEvents
addEvent(event): void - Add eventupdateEvent(id, updates): void - Update eventremoveEvent(id): void - Remove eventgetEventsForDate(date): TEvent[] - Get events for dategetEvents(): TEvent[] - Get events in visible rangeSelection
selectDate(date, multi?): void - Select dateclearSelection(): void - Clear selectioninterface CalendarEvent<T = unknown> {
id: string;
start: Date;
end: Date;
data?: T;
}
interface CalendarState<
TEvent extends CalendarEvent<unknown> = CalendarEvent<unknown>,
> {
currentDate: Date;
view: ViewConfig;
events: TEvent[];
selection: Date[];
visibleRange: { start: Date; end: Date };
gridDimensions: { rows: number; columns: number };
draggedEvent?: TEvent | null;
dropTarget?: Date | null;
selectionMode?: 'single' | 'multiple';
}
interface Cell<TEvent extends CalendarEvent<unknown> = CalendarEvent<unknown>> {
date: Date;
row: number;
col: number;
events: TEvent[];
isSelected: boolean;
isToday: boolean;
isCurrentMonth: boolean;
meta: Record<string, unknown>;
getCellProps?: () => Record<string, unknown>;
}
selectionFeature(options: {
multiple?: boolean;
range?: boolean;
}): Feature
dragDropFeature(options: {
onDrop?: (event: unknown, newDate: Date) => boolean;
}): Feature
import {
addDays,
startOfMonth,
endOfMonth,
startOfWeek,
isSameDay,
isToday,
} from '@chronux/core';
The package also includes legacy utility functions for backward compatibility:
import {
exampleFunction,
exampleAsyncFunction,
validateConfig,
} from '@chronux/core';
This package is part of the Chronux monorepo. See the main README for development setup instructions.
MIT License - see LICENSE for details.
FAQs
Core utilities for the Chronux platform
We found that @chronux/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Microsoft has released an open source toolkit for enforcing runtime security policies on AI agents as adoption accelerates faster than governance controls.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.