tiktok-live-api 1.2.17 → 1.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/demo.mjs +34 -10
  2. package/package.json +1 -1
package/bin/demo.mjs CHANGED
@@ -275,8 +275,7 @@ function runScaffold(choice, targetDir, pm) {
275
275
  } else if (isNext) {
276
276
  execSync(npxCmd + ' create-next-app@latest "' + targetDir + '" --js --eslint --tailwind --app --src-dir --import-alias "@/*" --use-' + pm, { stdio: 'inherit' });
277
277
  } else if (isVite) {
278
- const createCmd = pm === 'npm' ? 'npm create vite@latest' : pm === 'yarn' ? 'yarn create vite' : pm === 'pnpm' ? 'pnpm create vite' : 'bun create vite';
279
- execSync(createCmd + ' "' + targetDir + '" -- --template react', { stdio: 'inherit' });
278
+ execSync(npxCmd + ' create-vite@latest "' + targetDir + '" --no-interactive --template react', { stdio: 'inherit' });
280
279
  }
281
280
 
282
281
  if (isNode) {
@@ -493,12 +492,13 @@ function runScaffold(choice, targetDir, pm) {
493
492
  "}",
494
493
  ].join('\n') + '\n');
495
494
  } else if (isVite) {
496
- const compDir = path.join(fullPath, 'src', 'components');
495
+ const srcDir = path.join(fullPath, 'src');
496
+ const compDir = path.join(srcDir, 'components');
497
497
  if (!fs.existsSync(compDir)) fs.mkdirSync(compDir, { recursive: true });
498
498
  fs.writeFileSync(path.join(compDir, 'TikTokLive.jsx'), REACT_TEMPLATE);
499
499
 
500
- // Write App.jsx — overwrite whatever create-vite generated (could be .jsx or .tsx)
501
- const appContent = [
500
+ // Write App.jsx
501
+ fs.writeFileSync(path.join(srcDir, 'App.jsx'), [
502
502
  "import TikTokLive from './components/TikTokLive';",
503
503
  "",
504
504
  "export default function App() {",
@@ -508,11 +508,35 @@ function runScaffold(choice, targetDir, pm) {
508
508
  " </main>",
509
509
  " );",
510
510
  "}",
511
- ].join('\n') + '\n';
512
- fs.writeFileSync(path.join(fullPath, 'src', 'App.jsx'), appContent);
513
- // Also remove App.tsx if it exists (create-vite sometimes uses TypeScript)
514
- const appTsx = path.join(fullPath, 'src', 'App.tsx');
515
- if (fs.existsSync(appTsx)) fs.unlinkSync(appTsx);
511
+ ].join('\n') + '\n');
512
+
513
+ // Write main.jsx entry point
514
+ fs.writeFileSync(path.join(srcDir, 'main.jsx'), [
515
+ "import React from 'react';",
516
+ "import ReactDOM from 'react-dom/client';",
517
+ "import App from './App';",
518
+ "",
519
+ "ReactDOM.createRoot(document.getElementById('root')).render(",
520
+ " <React.StrictMode>",
521
+ " <App />",
522
+ " </React.StrictMode>",
523
+ ");",
524
+ ].join('\n') + '\n');
525
+
526
+ // Clean up TypeScript files that conflict with our JSX files
527
+ for (const f of ['App.tsx', 'App.ts', 'main.tsx', 'main.ts']) {
528
+ const fp = path.join(srcDir, f);
529
+ if (fs.existsSync(fp)) fs.unlinkSync(fp);
530
+ }
531
+
532
+ // Update index.html to reference main.jsx instead of main.ts/main.tsx
533
+ const indexHtml = path.join(fullPath, 'index.html');
534
+ if (fs.existsSync(indexHtml)) {
535
+ let html = fs.readFileSync(indexHtml, 'utf8');
536
+ html = html.replace(/src=\/src\/main\.tsx?/g, 'src=/src/main.jsx');
537
+ html = html.replace(/src="\/src\/main\.tsx?"/g, 'src="/src/main.jsx"');
538
+ fs.writeFileSync(indexHtml, html);
539
+ }
516
540
  }
517
541
  }
518
542
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiktok-live-api",
3
- "version": "1.2.17",
3
+ "version": "1.2.18",
4
4
  "description": "Unofficial TikTok LIVE API Client — Real-time chat, gifts, viewers, battles, and AI live captions from any TikTok livestream. Managed WebSocket API with 99.9% uptime.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",