Files
thetool/public/plugins/vue/tt-core/index.js
2025-12-09 05:34:24 +00:00

94 lines
2.8 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 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;