94 lines
2.8 KiB
JavaScript
94 lines
2.8 KiB
JavaScript
/**
|
||
* TT-Core Component Library (Vue 3)
|
||
* Modern, reusable components and utilities for TheTool
|
||
*
|
||
* @version 2.0.0 (Vue 3)
|
||
* @author TheTool Development Team
|
||
*/
|
||
|
||
// Import utilities
|
||
import { copyToClipboard } from './utils/clipboard.js';
|
||
import { formatBytes, formatDuration, formatNumber, formatBits } from './utils/formatting.js';
|
||
import { calculateSimilarity, validateData, validateEmail, generatePassword } from './utils/validation.js';
|
||
import { loadScript, loadScripts } from './utils/script-loader.js';
|
||
|
||
// Import composables (Vue 3 Composition API)
|
||
import { useIntersectionObserver, createIntersectionObserverMixin } from './composables/useIntersectionObserver.js';
|
||
import { useInfiniteScroll, createInfiniteScrollMixin } from './composables/useInfiniteScroll.js';
|
||
import { useAsyncData, createAsyncDataMixin } from './composables/useAsyncData.js';
|
||
|
||
/**
|
||
* TT-Core Global Namespace
|
||
* Exposes all utilities and helpers globally
|
||
*/
|
||
window.TT_CORE = {
|
||
// Utilities
|
||
copyToClipboard,
|
||
formatBytes,
|
||
formatDuration,
|
||
formatNumber,
|
||
formatBits,
|
||
calculateSimilarity,
|
||
validateData,
|
||
validateEmail,
|
||
generatePassword,
|
||
loadScript,
|
||
loadScripts,
|
||
|
||
// Vue 3 Composables (Composition API)
|
||
useIntersectionObserver,
|
||
useInfiniteScroll,
|
||
useAsyncData,
|
||
|
||
// Backward compatibility mixins (Options API)
|
||
createIntersectionObserverMixin,
|
||
createInfiniteScrollMixin,
|
||
createAsyncDataMixin,
|
||
|
||
// Version
|
||
version: '2.0.0',
|
||
vueVersion: 3
|
||
};
|
||
|
||
/**
|
||
* Component Registration Helper
|
||
* Auto-registers all TT-Core components with the Vue 3 app instance
|
||
*/
|
||
window.TT_CORE.registerComponents = function(app) {
|
||
if (!app || !app.component) {
|
||
console.error('TT-Core: Invalid Vue app instance provided to registerComponents()');
|
||
return;
|
||
}
|
||
|
||
// Store the app instance globally for component auto-registration
|
||
window.VueApp = app;
|
||
|
||
console.log(
|
||
'%c TT-Core v2.0.0 (Vue 3) %c Components registered successfully ',
|
||
'background: #005384; color: #fff; padding: 2px 4px; border-radius: 3px 0 0 3px;',
|
||
'background: #0f9d58; color: #fff; padding: 2px 4px; border-radius: 0 3px 3px 0;'
|
||
);
|
||
|
||
return app;
|
||
};
|
||
|
||
/**
|
||
* CDN Quick Start
|
||
* For use with Vue 3 CDN, call this after creating your app
|
||
*
|
||
* Example:
|
||
* const { createApp } = Vue;
|
||
* const app = createApp({...});
|
||
* TT_CORE.registerComponents(app);
|
||
* app.mount('#app');
|
||
*/
|
||
|
||
console.log(
|
||
'%c TT-Core v2.0.0 (Vue 3) %c Loaded successfully ',
|
||
'background: #005384; color: #fff; padding: 2px 4px; border-radius: 3px 0 0 3px;',
|
||
'background: #0f9d58; color: #fff; padding: 2px 4px; border-radius: 0 3px 3px 0;',
|
||
'\n\nℹ️ Remember to call TT_CORE.registerComponents(app) after creating your Vue app!'
|
||
);
|
||
|
||
export default window.TT_CORE;
|