{"_id":"@arcubase/frame-ts","name":"@arcubase/frame-ts","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@arcubase/frame-ts","version":"0.1.0","description":"Universal SDK for iframe-based integrations in carthooks","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":"./dist/index.js"},"scripts":{"build":"tsc && npm run docs:llms","dev":"tsc --watch","type-check":"tsc --noEmit","clean":"rm -rf dist","docs:llms":"node scripts/generate-llms-txt.js"},"keywords":["carthooks","sdk","iframe","integration","typescript"],"author":{"name":"Carthooks Team"},"license":"MIT","dependencies":{"@arcubase/client-ts":"^0.8.0"},"devDependencies":{"typescript":"^6.0.3"},"gitHead":"ad352e316e9f0e6ee5ffd5efae5da1ee976438b7","_id":"@arcubase/frame-ts@0.1.0","_nodeVersion":"25.6.1","_npmVersion":"11.9.0","dist":{"integrity":"sha512-2nAnMxuLtTJxGM5iRj0Ur38d3NSHd6faEwYyKlclvXtP6q/bq6GwrqjoMWvMLSgjvaeuccLItxZbAJ7c7Al1FQ==","shasum":"8d0ebde1ebe706732e69030271f4bdb70f9596f6","tarball":"https://registry.npmjs.org/@arcubase/frame-ts/-/frame-ts-0.1.0.tgz","fileCount":20,"unpackedSize":50859,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDUKOBQAPUvPvK1H4NwXCWVW0iLnhw2rrQynZ5bWATK/gIhAOWfFEpyA++KTkNP+bQsUA9++HjcoAQptXsvJkCnp/j0"}]},"_npmUser":{"name":"wanglei917590","email":"flaboy.cn@gmail.com"},"directories":{},"maintainers":[{"name":"wanglei917590","email":"flaboy.cn@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/frame-ts_0.1.0_1785832690552_0.2560523225513873"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-04T08:38:10.419Z","0.1.0":"2026-08-04T08:38:10.684Z","modified":"2026-08-04T08:38:11.092Z"},"maintainers":[{"name":"wanglei917590","email":"flaboy.cn@gmail.com"}],"description":"Universal SDK for iframe-based integrations in carthooks","keywords":["carthooks","sdk","iframe","integration","typescript"],"author":{"name":"Carthooks Team"},"license":"MIT","readme":"# @arcubase/hooklets\n\nSDK for third-party integrations in carthooks iframe environment.\n\n## Installation\n\n```bash\nnpm install @arcubase/hooklets\n```\n\n## Usage\n\n### Basic Setup\n\n```typescript\nimport { Frame } from '@arcubase/frame-ts';\n\n// Initialize the SDK\nconst sdk = new Frame();\nconst { token, locale, timezone, darkMode } = await sdk.init();\n\n// Use the token for backend API calls\nconst response = await fetch('/api/exchange-token', {\n  method: 'POST',\n  headers: { 'Authorization': `Bearer ${token}` }\n});\n```\n\n### Get Collections and Data\n\n```typescript\n// Get all available collections\nconst collections = await sdk.getCollections();\n\n// Get specific collection\nconst collection = await sdk.getCollection('collection-id');\n\n// Get current user info\nconst user = await sdk.getUser();\n```\n\n### Handle Connection Events\n\n```typescript\n// Listen for successful connection creation\nsdk.onSuccess((connectionId) => {\n  console.log('Connection created:', connectionId);\n  sdk.close(); // Close the iframe\n});\n\n// Listen for errors\nsdk.onError((error) => {\n  console.error('Connection failed:', error);\n});\n\n// Notify success\nsdk.notifySuccess('connection-123');\n\n// Notify error\nsdk.notifyError('Failed to create connection');\n```\n\n### URL Parameters\n\nThe SDK automatically reads these URL parameters:\n\n- `token`: Authentication token (required)\n- `lc`: User locale (default: 'en-US')\n- `tz`: User timezone (default: 'UTC')\n- `dark`: Dark mode enabled (default: false)\n\nExample URL: `https://your-app.com/integration?token=abc123&lc=zh-CN&tz=Asia/Shanghai&dark=1`\n\n## API Reference\n\n### Hooklets Class\n\n#### Methods\n\n- `init()`: Initialize the SDK with URL parameters\n- `getToken()`: Get authentication token\n- `getLocale()`: Get user locale\n- `getTimezone()`: Get user timezone\n- `isDarkMode()`: Check if dark mode is enabled\n- `getCollections()`: Get all available collections\n- `getCollection(id)`: Get specific collection by ID\n- `getUser()`: Get current user information\n- `onSuccess(callback)`: Register success callback\n- `onError(callback)`: Register error callback\n- `onClose(callback)`: Register close callback\n- `notifySuccess(connectionId)`: Notify parent of successful connection\n- `notifyError(error)`: Notify parent of connection error\n- `notifyUpdated(connectionId)`: Notify parent of connection update\n- `close()`: Close the iframe\n\n### Types\n\nSee `types.ts` for complete TypeScript definitions.\n\n## Security\n\n- SDK only works within iframe context\n- All communication with parent uses postMessage\n- Token has limited scope and expiration\n- Origin validation is handled by parent application\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-68a706674a3f0aec434df92276ead7f1"}