@ashkash/kaynix-widget
v3.0.0
Published
Kaynix AI - E-commerce Shopping Assistant Widget Loaders
Downloads
26
Maintainers
Readme
Kaynix Widget Loaders
Minimal public loaders for the Kaynix AI E-commerce Shopping Assistant Widget.
Overview
This package contains lightweight bookmarklet loaders that allow you to inject the Kaynix AI widget on any e-commerce website. The actual widget code is loaded from your configured server, keeping proprietary code private.
Installation
npm install @ashkash/kaynix-widgetUsage
Basic Bookmarklet (Production)
Create a bookmark with this URL to use the default production servers:
javascript:(function(){
if(window.KaynixInjected)return;
window.KaynixInjected=true;
var s=document.createElement('script');
s.src='https://cdn.jsdelivr.net/npm/@ashkash/kaynix-widget@latest/bookmarklet-loader-minimal.js';
document.head.appendChild(s)
})()Configurable Bookmarklet
To use custom servers (staging, development, etc.), set the configuration before loading:
javascript:(function(){
window.KAYNIX_CONFIG={
baseUrl:'https://staging.kaynix.ai',
apiUrl:'https://staging-api.kaynix.ai',
debug:true
};
if(window.KaynixInjected)return;
window.KaynixInjected=true;
var s=document.createElement('script');
s.src='https://cdn.jsdelivr.net/npm/@ashkash/kaynix-widget@latest/bookmarklet-loader-minimal.js';
document.head.appendChild(s)
})()Configuration Options
The KAYNIX_CONFIG object supports:
baseUrl: URL where widget files are hosted (default:https://demo.kaynix.ai)apiUrl: Backend API URL (default:https://api.kaynix.ai)apiKey: API key for authentication (default: uses localStorage or 'dev-api-key')debug: Enable debug mode (default:false)environment: Environment name for logging (default:'production')
For Developers
The minimal loader will:
- Check the configuration in
window.KAYNIX_CONFIG - Load the main widget loader from the configured
baseUrl - Pass configuration to the main loader via
window.KAYNIX_LOADER_CONFIG - The main loader then loads all widget dependencies from your server
This approach allows you to:
- Keep your widget code private on your own servers
- Support multiple deployment environments
- Bypass CSP restrictions by using CDN for the minimal loader
- Maintain full control over widget updates
Files Included
bookmarklet-loader-minimal.js: Minimal loader that reads config and loads from your serverbookmarklet-loader-configurable.js: Extended version with more configuration optionsREADME.md: This documentation
License
MIT
