kinetic-slider
Version:
A WebGL-powered kinetic slider component using PIXI.js
1 lines • 6.96 kB
Source Map (JSON)
{"version":3,"file":"UpdateTypes.cjs","sources":["../../../src/managers/UpdateTypes.ts"],"sourcesContent":["// src/components/KineticSlider/managers/UpdateTypes.ts\n\n/**\n * @file UpdateTypes.ts\n * @description Defines standard update types and their recommended priorities for KineticSlider.\n * This helps maintain consistent priority assignments across different hooks and components.\n */\n\n/**\n * Priority levels for rendering updates.\n * Higher numbers indicate higher priority.\n * @enum {number}\n */\nexport enum UpdatePriority {\n /** Background, non-visual updates */\n LOW = 0,\n /** Standard visual updates */\n NORMAL = 1,\n /** Important visual feedback */\n HIGH = 2,\n /** Must-run-immediately updates */\n CRITICAL = 3\n}\n\n/**\n * Standard update types for KineticSlider with associated default priorities.\n * @enum {string}\n */\nexport enum UpdateType {\n /** Background animation effects that aren't immediately visible */\n BACKGROUND_EFFECT = 'background_effect',\n\n /** Preloading of assets not yet needed */\n ASSET_PRELOAD = 'asset_preload',\n\n /** Standard text movement and position updates */\n TEXT_POSITION = 'text_position',\n\n /** Idle effects that show after some time */\n IDLE_EFFECT = 'idle_effect',\n\n /** Filter updates that aren't critical to user interaction */\n FILTER_UPDATE = 'filter_update',\n\n /** Updates directly responding to mouse movement */\n MOUSE_RESPONSE = 'mouse_response',\n\n /** Displacement effects tied to user interaction */\n DISPLACEMENT_EFFECT = 'displacement_effect',\n\n /** Main slide position and scale during interaction */\n SLIDE_TRANSFORM = 'slide_transform',\n\n /** Slide transitions between views */\n SLIDE_TRANSITION = 'slide_transition',\n\n /** Direct user interaction responses */\n INTERACTION_FEEDBACK = 'interaction_feedback',\n\n /** Loading state changes that affect UI */\n LOADING_STATE = 'loading_state'\n}\n\n/**\n * Maps update types to their recommended priority levels.\n * This provides consistency across the application.\n * @type {Record<UpdateType, UpdatePriority>}\n */\nexport const UPDATE_TYPE_PRIORITIES: Record<UpdateType, UpdatePriority> = {\n // Low priority (background tasks)\n [UpdateType.BACKGROUND_EFFECT]: UpdatePriority.LOW,\n [UpdateType.ASSET_PRELOAD]: UpdatePriority.LOW,\n\n // Normal priority (standard visual updates)\n [UpdateType.TEXT_POSITION]: UpdatePriority.NORMAL,\n [UpdateType.IDLE_EFFECT]: UpdatePriority.NORMAL,\n [UpdateType.FILTER_UPDATE]: UpdatePriority.NORMAL,\n\n // High priority (important visual feedback)\n [UpdateType.MOUSE_RESPONSE]: UpdatePriority.HIGH,\n [UpdateType.DISPLACEMENT_EFFECT]: UpdatePriority.HIGH,\n [UpdateType.SLIDE_TRANSFORM]: UpdatePriority.HIGH,\n\n // Critical priority (must execute immediately)\n [UpdateType.SLIDE_TRANSITION]: UpdatePriority.CRITICAL,\n [UpdateType.INTERACTION_FEEDBACK]: UpdatePriority.CRITICAL,\n [UpdateType.LOADING_STATE]: UpdatePriority.CRITICAL\n};\n\n/**\n * Helper function to get the recommended priority for an update type.\n *\n * @param {UpdateType} type - The type of update\n * @returns {UpdatePriority} The recommended priority level\n */\nexport function getPriorityForUpdateType(type: UpdateType): UpdatePriority {\n return UPDATE_TYPE_PRIORITIES[type] || UpdatePriority.NORMAL;\n}\n\n/**\n * Generate a unique update ID for a specific component and update type.\n *\n * @param {string} componentId - ID of the component requesting the update\n * @param {UpdateType} updateType - Type of update\n * @param {string} [suffix] - Optional suffix for further differentiation\n * @returns {string} A unique update ID\n */\nexport function createUpdateId(\n componentId: string,\n updateType: UpdateType,\n suffix?: string\n): string {\n return suffix ?\n `${componentId}:${updateType}:${suffix}` :\n `${componentId}:${updateType}`;\n}\n\n/**\n * Interface for hook update helper methods\n * @interface\n */\nexport interface HookUpdateHelper {\n /**\n * Create an update ID for this hook.\n *\n * @param {UpdateType} updateType - Type of update\n * @param {string} [suffix] - Optional suffix\n * @returns {string} A unique update ID\n */\n createId(updateType: UpdateType, suffix?: string): string;\n\n /**\n * Get the recommended priority for an update type.\n *\n * @param {UpdateType} updateType - Type of update\n * @returns {UpdatePriority} The recommended priority\n */\n getPriority(updateType: UpdateType): UpdatePriority;\n}\n\n/**\n * Utility to help create standard update IDs for hooks.\n *\n * @param {string} hookName - Name of the hook (e.g., 'useMouseTracking')\n * @returns {HookUpdateHelper} An object with methods to create update IDs and get priorities\n */\nexport function createHookUpdateHelper(hookName: string): HookUpdateHelper {\n return {\n /**\n * Create an update ID for this hook.\n *\n * @param {UpdateType} updateType - Type of update\n * @param {string} [suffix] - Optional suffix\n * @returns {string} A unique update ID\n */\n createId(updateType: UpdateType, suffix?: string): string {\n return createUpdateId(hookName, updateType, suffix);\n },\n\n /**\n * Get the recommended priority for an update type.\n *\n * @param {UpdateType} updateType - Type of update\n * @returns {UpdatePriority} The recommended priority\n */\n getPriority(updateType: UpdateType): UpdatePriority {\n return getPriorityForUpdateType(updateType);\n }\n };\n}"],"names":["UpdateType"],"mappings":";;AA4BY,IAAA,UAAA,qBAAAA,WAAL,KAAA;AAEH,EAAAA,YAAA,mBAAoB,CAAA,GAAA,mBAAA;AAGpB,EAAAA,YAAA,eAAgB,CAAA,GAAA,eAAA;AAGhB,EAAAA,YAAA,eAAgB,CAAA,GAAA,eAAA;AAGhB,EAAAA,YAAA,aAAc,CAAA,GAAA,aAAA;AAGd,EAAAA,YAAA,eAAgB,CAAA,GAAA,eAAA;AAGhB,EAAAA,YAAA,gBAAiB,CAAA,GAAA,gBAAA;AAGjB,EAAAA,YAAA,qBAAsB,CAAA,GAAA,qBAAA;AAGtB,EAAAA,YAAA,iBAAkB,CAAA,GAAA,iBAAA;AAGlB,EAAAA,YAAA,kBAAmB,CAAA,GAAA,kBAAA;AAGnB,EAAAA,YAAA,sBAAuB,CAAA,GAAA,sBAAA;AAGvB,EAAAA,YAAA,eAAgB,CAAA,GAAA,eAAA;AAhCR,EAAAA,OAAAA,WAAAA;AAAA,CAAA,EAAA,UAAA,IAAA,EAAA;AAwCL,MAAM,sBAA6D,GAAA;AAAA;AAAA,EAEtE,CAAC,8CAA+B,CAAA;AAAA,EAChC,CAAC,sCAA2B,CAAA;AAAA;AAAA,EAG5B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