mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-18 12:49:40 +02:00
Add spiral-db integration to Contacts as the third app using pixel-based spiral visualization. Contacts are encoded with name, company, city, and email/phone flags. Changes: - Add createContactSchema() to spiral-db with bool fields for hasEmail/hasPhone and nullable company/city - Create Svelte 5 spiral store with importContacts from contactsStore - Add SpiralCanvas component and /spiral route - Wire up navigation (Ctrl+5) with auto-import on mount - Favorites show as starred entries with gold border Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
182 lines
3.1 KiB
TypeScript
182 lines
3.1 KiB
TypeScript
/**
|
|
* SpiralDB - Pixel-based Spiral Database
|
|
*
|
|
* Store structured data in images using an 8-color palette.
|
|
* Data grows in a spiral pattern from the center outward.
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* import { SpiralDB, createTodoSchema } from '@manacore/spiral-db';
|
|
*
|
|
* // Create database with todo schema
|
|
* const db = new SpiralDB({
|
|
* schema: createTodoSchema(),
|
|
* compression: true,
|
|
* });
|
|
*
|
|
* // Insert a todo
|
|
* const result = db.insert({
|
|
* id: 0,
|
|
* status: 0,
|
|
* priority: 1,
|
|
* createdAt: new Date(),
|
|
* dueDate: new Date('2025-12-31'),
|
|
* completedAt: null,
|
|
* title: 'Build SpiralDB',
|
|
* description: 'Create a pixel-based database',
|
|
* tags: [1, 2, 3],
|
|
* });
|
|
*
|
|
* // Get the image
|
|
* const image = db.getImage();
|
|
* console.log(visualizeImageEmoji(image));
|
|
* ```
|
|
*/
|
|
|
|
// Main database class
|
|
export { SpiralDB } from './database.js';
|
|
|
|
// Types
|
|
export type {
|
|
// Color system
|
|
ColorIndex,
|
|
RGB,
|
|
ColorDefinition,
|
|
// Schema
|
|
FieldType,
|
|
FieldDefinition,
|
|
SchemaDefinition,
|
|
// Records
|
|
RecordStatus,
|
|
RecordMetadata,
|
|
SpiralRecord,
|
|
// Database
|
|
DatabaseHeader,
|
|
DatabaseFlags,
|
|
MasterIndex,
|
|
IndexEntry,
|
|
// Image
|
|
SpiralImage,
|
|
Point,
|
|
RingInfo,
|
|
// Options
|
|
SpiralDBOptions,
|
|
WriteResult,
|
|
ReadResult,
|
|
// Encoding
|
|
BitStream,
|
|
SerializedRecord,
|
|
} from './types.js';
|
|
|
|
// Constants
|
|
export {
|
|
COLORS,
|
|
COLOR_BY_NAME,
|
|
MAGIC_VALID,
|
|
MAGIC_EMPTY,
|
|
MAGIC_CORRUPT,
|
|
BITS_PER_PIXEL,
|
|
END_MARKER,
|
|
MAX_VERSION,
|
|
MAX_RECORD_COUNT,
|
|
MAX_RECORD_LENGTH,
|
|
MAX_STRING_LENGTH,
|
|
MAX_ARRAY_LENGTH,
|
|
RING_MAGIC,
|
|
RING_HEADER,
|
|
RING_SCHEMA,
|
|
RING_INDEX,
|
|
RING_DATA_START,
|
|
} from './constants.js';
|
|
|
|
// Schema utilities
|
|
export {
|
|
createTodoSchema,
|
|
createQuoteSchema,
|
|
createContactSchema,
|
|
encodeSchema,
|
|
decodeSchema,
|
|
getSchemaPixelCount,
|
|
validateRecord,
|
|
getFieldNames,
|
|
} from './schema.js';
|
|
|
|
// Spiral coordinate utilities
|
|
export {
|
|
spiralToXY,
|
|
xyToSpiral,
|
|
getRingForIndex,
|
|
getRingInfo,
|
|
getImageSizeForRing,
|
|
getTotalPixelsForRing,
|
|
getRingPixels,
|
|
findSpaceForRecord,
|
|
getSpiralRange,
|
|
} from './spiral.js';
|
|
|
|
// Image utilities
|
|
export {
|
|
createImage,
|
|
createImageForRing,
|
|
getPixelByIndex,
|
|
setPixelByIndex,
|
|
getPixelByXY,
|
|
setPixelByXY,
|
|
readPixelRange,
|
|
writePixelRange,
|
|
expandImage,
|
|
getMaxRingForImage,
|
|
imageToRGBA,
|
|
rgbaToImage,
|
|
imageToColorGrid,
|
|
visualizeSpiralOrder,
|
|
visualizeImageEmoji,
|
|
} from './image.js';
|
|
|
|
// Encoding utilities
|
|
export {
|
|
bitsToColor,
|
|
colorToBits,
|
|
colorToRGB,
|
|
rgbToColor,
|
|
createBitStream,
|
|
writeBits,
|
|
readBits,
|
|
peekBits,
|
|
hasMoreBits,
|
|
bitsToPixels,
|
|
pixelsToBits,
|
|
streamToRecord,
|
|
encodeInt,
|
|
decodeInt,
|
|
encodeBool,
|
|
decodeBool,
|
|
encodeString,
|
|
decodeString,
|
|
encodeTimestamp,
|
|
decodeTimestamp,
|
|
encodeIntArray,
|
|
decodeIntArray,
|
|
encodeStringArray,
|
|
decodeStringArray,
|
|
} from './encoding.js';
|
|
|
|
// PNG export/import utilities
|
|
export {
|
|
// Pure JS (works everywhere)
|
|
exportToPngBytes,
|
|
exportToPngBytesCompressed,
|
|
importFromPngBytes,
|
|
// Node.js file operations
|
|
saveToPngFile,
|
|
loadFromPngFile,
|
|
// Sharp integration (optional)
|
|
exportWithSharp,
|
|
importWithSharp,
|
|
// Browser support
|
|
exportToBlob,
|
|
exportToDataUrl,
|
|
exportToCanvas,
|
|
importFromCanvas,
|
|
downloadPng,
|
|
} from './png.js';
|