star-sdk-cli 0.1.7 → 0.1.9

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/dist/cli.mjs +32 -62
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -45,7 +45,7 @@ Star.game(ctx => {
45
45
 
46
46
  // Game loop
47
47
  ctx.loop((dt) => {
48
- c.fillStyle = '#1a1a2e';
48
+ c.fillStyle = '#111827';
49
49
  c.fillRect(0, 0, width, height);
50
50
  c.fillStyle = '#fff';
51
51
  c.font = '24px sans-serif';
@@ -60,17 +60,6 @@ Star.game(ctx => {
60
60
  });
61
61
  \`\`\`
62
62
 
63
- ## Initialization (Required for Leaderboards)
64
-
65
- If using leaderboards outside the Star platform (local dev, self-hosted), initialize with your game ID:
66
-
67
- \`\`\`javascript
68
- import Star from 'star-sdk';
69
-
70
- // Get your gameId from .starrc (created by: npx star-sdk init "Game Name")
71
- Star.init({ gameId: 'your-game-id-here' });
72
- \`\`\`
73
-
74
63
  ## Common Patterns
75
64
 
76
65
  ### Game Over -> Submit Score -> Show Leaderboard
@@ -120,9 +109,6 @@ Only these 17 presets exist:
120
109
  \`\`\`javascript
121
110
  import Star from 'star-sdk';
122
111
 
123
- // Initialize for leaderboard support (get gameId from .starrc)
124
- Star.init({ gameId: 'your-game-id' });
125
-
126
112
  Star.game(ctx => {
127
113
  const { canvas, width, height, ctx: c } = ctx;
128
114
  let score = 0;
@@ -147,7 +133,7 @@ Star.game(ctx => {
147
133
  if (gameOver) return;
148
134
 
149
135
  // Clear
150
- c.fillStyle = '#1a1a2e';
136
+ c.fillStyle = '#111827';
151
137
  c.fillRect(0, 0, width, height);
152
138
 
153
139
  // Update obstacles
@@ -174,13 +160,13 @@ Star.game(ctx => {
174
160
  obstacles = obstacles.filter(o => o.x > -20);
175
161
 
176
162
  // Draw player
177
- c.fillStyle = '#e94560';
163
+ c.fillStyle = '#3b82f6';
178
164
  c.beginPath();
179
165
  c.arc(50, playerY, 15, 0, Math.PI * 2);
180
166
  c.fill();
181
167
 
182
168
  // Draw obstacles
183
- c.fillStyle = '#0f4c75';
169
+ c.fillStyle = '#a855f7';
184
170
  obstacles.forEach(obs => {
185
171
  c.fillRect(obs.x - 10, obs.y - 25, 20, 50);
186
172
  });
@@ -379,7 +365,7 @@ game(({ ctx, width, height, on, loop, ui, canvas }) => {
379
365
  // 1. Draw on the canvas
380
366
  loop((dt) => {
381
367
  ctx.clearRect(0, 0, width, height);
382
- ctx.fillStyle = '#22d3ee'; // cyan-400
368
+ ctx.fillStyle = '#3b82f6'; // blue-500
383
369
  ctx.fillRect(width / 2 - 25, height / 2 - 25, 50, 50);
384
370
  });
385
371
 
@@ -555,10 +541,10 @@ game(({ on, ui }) => {
555
541
  function render() {
556
542
  // UI is interactive by default - buttons, scroll, forms all work
557
543
  ui.render(\`
558
- <div class="min-h-[100dvh] grid place-items-center bg-purple-900 text-white">
544
+ <div class="min-h-[100dvh] grid place-items-center bg-gray-900 text-white">
559
545
  <div class="text-center space-y-4">
560
546
  <h1 class="text-4xl font-bold">Score: \\\${score}</h1>
561
- <button id="clickBtn" class="px-8 py-4 rounded-xl bg-cyan-400 text-slate-900 font-bold">
547
+ <button id="clickBtn" class="px-8 py-4 rounded-xl bg-gradient-to-r from-blue-600 to-purple-600 text-white shadow-lg shadow-blue-500/20 font-bold">
562
548
  Click Me!
563
549
  </button>
564
550
  </div>
@@ -594,10 +580,10 @@ game(({ ctx, width, height, loop }) => {
594
580
  player.x += speed * dt;
595
581
  if (player.x > width) player.x = -playerSize;
596
582
 
597
- ctx.fillStyle = '#0f172a';
583
+ ctx.fillStyle = '#111827';
598
584
  ctx.fillRect(0, 0, width, height);
599
585
 
600
- ctx.fillStyle = '#22d3ee';
586
+ ctx.fillStyle = '#3b82f6';
601
587
  ctx.fillRect(player.x, player.y - playerSize/2, playerSize, playerSize);
602
588
  });
603
589
  });
@@ -628,10 +614,10 @@ game(({ ctx, width, height, loop, canvas, toStagePoint }) => {
628
614
  });
629
615
 
630
616
  loop((dt) => {
631
- ctx.fillStyle = '#1e1b4b';
617
+ ctx.fillStyle = '#111827';
632
618
  ctx.fillRect(0, 0, width, height);
633
619
 
634
- ctx.strokeStyle = '#4338ca';
620
+ ctx.strokeStyle = '#8b5cf6';
635
621
  for (let row = 0; row < gridRows; row++) {
636
622
  for (let col = 0; col < gridCols; col++) {
637
623
  ctx.strokeRect(
@@ -662,10 +648,10 @@ game(({ ctx, width, height, loop, toStagePoint, canvas }) => {
662
648
  });
663
649
 
664
650
  loop((dt) => {
665
- ctx.fillStyle = '#0f172a';
651
+ ctx.fillStyle = '#111827';
666
652
  ctx.fillRect(0, 0, width, height);
667
653
 
668
- ctx.fillStyle = '#22d3ee';
654
+ ctx.fillStyle = '#3b82f6';
669
655
  ctx.fillRect(player.x - 8, player.y - 8, 16, 16);
670
656
  });
671
657
  }, { width: 320, height: 180 }); // Custom resolution with letterboxing
@@ -727,7 +713,7 @@ game(({ ctx, width, height, loop, ui, on, canvas, toStagePoint }) => {
727
713
  <div class="h-full flex flex-col items-center justify-center text-white">
728
714
  <div class="text-3xl mb-4">GAME OVER</div>
729
715
  <div class="text-6xl mb-4">\\\${score}</div>
730
- <button id="leaderboard-btn" class="px-6 py-3 mb-4 bg-purple-600 rounded-lg pointer-events-auto">
716
+ <button id="leaderboard-btn" class="px-6 py-3 mb-4 bg-gradient-to-r from-blue-600 to-purple-600 rounded-xl font-bold shadow-lg shadow-blue-500/20 pointer-events-auto">
731
717
  VIEW LEADERBOARD
732
718
  </button>
733
719
  <div class="text-xl animate-pulse">TAP TO RESTART</div>
@@ -799,7 +785,7 @@ game(({ ctx, width, height, loop, canvas, createDrag }) => {
799
785
 
800
786
  const pieces = [
801
787
  { x: width * 0.2, y: height * 0.3, color: '#ef4444' },
802
- { x: width * 0.4, y: height * 0.4, color: '#22c55e' },
788
+ { x: width * 0.4, y: height * 0.4, color: '#10b981' },
803
789
  { x: width * 0.6, y: height * 0.3, color: '#3b82f6' },
804
790
  ];
805
791
 
@@ -843,11 +829,11 @@ game(({ ctx, width, height, loop, canvas, createDrag }) => {
843
829
  });
844
830
 
845
831
  loop(() => {
846
- ctx.fillStyle = '#1e293b';
832
+ ctx.fillStyle = '#1f2937';
847
833
  ctx.fillRect(0, 0, width, height);
848
834
 
849
835
  for (const p of pieces) {
850
- ctx.fillStyle = drag.dragging === p ? '#fbbf24' : p.color;
836
+ ctx.fillStyle = drag.dragging === p ? '#f59e0b' : p.color;
851
837
  ctx.fillRect(p.x, p.y, pieceSize, pieceSize);
852
838
  }
853
839
  });
@@ -867,7 +853,7 @@ game(({ ctx, width, height, loop, canvas, toStagePoint }) => {
867
853
  const pieceSize = height * 0.15;
868
854
  const pieces = [
869
855
  { x: width * 0.2, y: height * 0.3, color: '#ef4444' },
870
- { x: width * 0.4, y: height * 0.4, color: '#22c55e' },
856
+ { x: width * 0.4, y: height * 0.4, color: '#10b981' },
871
857
  ];
872
858
 
873
859
  // Manual drag state
@@ -913,11 +899,11 @@ game(({ ctx, width, height, loop, canvas, toStagePoint }) => {
913
899
  });
914
900
 
915
901
  loop(() => {
916
- ctx.fillStyle = '#1e293b';
902
+ ctx.fillStyle = '#1f2937';
917
903
  ctx.fillRect(0, 0, width, height);
918
904
 
919
905
  for (const p of pieces) {
920
- ctx.fillStyle = dragging === p ? '#fbbf24' : p.color;
906
+ ctx.fillStyle = dragging === p ? '#f59e0b' : p.color;
921
907
  ctx.fillRect(p.x, p.y, pieceSize, pieceSize);
922
908
  }
923
909
  });
@@ -954,12 +940,12 @@ game(({ ctx, width, height, loop }) => {
954
940
  if (bg.complete) {
955
941
  ctx.drawImage(bg, 0, 0, width, height);
956
942
  } else {
957
- ctx.fillStyle = '#1e293b'; // Fallback color while loading
943
+ ctx.fillStyle = '#1f2937'; // Fallback color while loading
958
944
  ctx.fillRect(0, 0, width, height);
959
945
  }
960
946
 
961
947
  // Draw game objects on top
962
- ctx.fillStyle = '#22d3ee';
948
+ ctx.fillStyle = '#3b82f6';
963
949
  ctx.fillRect(player.x - 16, player.y - 16, 32, 32);
964
950
  });
965
951
  });
@@ -987,7 +973,7 @@ game(({ ctx, width, height, loop }) => {
987
973
  ctx.fillStyle = pattern;
988
974
  ctx.fillRect(0, 0, width, height);
989
975
  } else {
990
- ctx.fillStyle = '#22c55e'; // Fallback color while loading
976
+ ctx.fillStyle = '#10b981'; // Fallback color while loading
991
977
  ctx.fillRect(0, 0, width, height);
992
978
  }
993
979
 
@@ -1057,7 +1043,7 @@ game(({ ctx, width, height, loop, ui, on, canvas }) => {
1057
1043
 
1058
1044
  **That's it!** The SDK handles:
1059
1045
  - Score submission (works for guests and logged-in users)
1060
- - Platform leaderboard UI (modal with rankings)
1046
+ - Leaderboard UI (modal with rankings)
1061
1047
  - Weekly/all-time timeframes
1062
1048
  - AI-detected scoring (score/time/moves - higher or lower is better)
1063
1049
 
@@ -1068,7 +1054,7 @@ game(({ ctx, width, height, loop, ui, on, canvas }) => {
1068
1054
  **Core Methods:**
1069
1055
  \`\`\`javascript
1070
1056
  leaderboard.submit(score) // Submit score, returns Promise<{ success, rank, scoreId }>
1071
- leaderboard.show() // Show platform leaderboard UI
1057
+ leaderboard.show() // Show leaderboard UI
1072
1058
  leaderboard.getScores(options) // Fetch scores for custom UI
1073
1059
  leaderboard.share(options) // Generate shareable link
1074
1060
  \`\`\`
@@ -1076,7 +1062,7 @@ leaderboard.share(options) // Generate shareable link
1076
1062
  **Properties:**
1077
1063
  \`\`\`javascript
1078
1064
  leaderboard.ready // true when SDK is initialized
1079
- leaderboard.gameId // Current game ID (auto-detected on platform)
1065
+ leaderboard.gameId // Current game ID
1080
1066
  \`\`\`
1081
1067
 
1082
1068
  **Aliases (for discoverability):**
@@ -1131,7 +1117,7 @@ const leaderboard = createLeaderboard();
1131
1117
 
1132
1118
  game(({ ui, on }) => {
1133
1119
  ui.render(\`
1134
- <button id="lb-btn" class="pointer-events-auto">
1120
+ <button id="lb-btn" class="px-6 py-3 bg-gradient-to-r from-blue-600 to-purple-600 rounded-xl font-bold text-white shadow-lg shadow-blue-500/20 pointer-events-auto">
1135
1121
  View Leaderboard
1136
1122
  </button>
1137
1123
  \`);
@@ -1198,7 +1184,7 @@ game(({ ctx, width, height, loop, ui, on, canvas }) => {
1198
1184
  <div class="h-full flex flex-col items-center justify-center text-white">
1199
1185
  <div class="text-3xl mb-4">GAME OVER</div>
1200
1186
  <div class="text-6xl mb-4">\\\${score}</div>
1201
- <button id="lb-btn" class="px-6 py-3 mb-4 bg-purple-600 rounded-lg pointer-events-auto">
1187
+ <button id="lb-btn" class="px-6 py-3 mb-4 bg-gradient-to-r from-blue-600 to-purple-600 rounded-xl font-bold shadow-lg shadow-blue-500/20 pointer-events-auto">
1202
1188
  VIEW LEADERBOARD
1203
1189
  </button>
1204
1190
  <div class="text-xl animate-pulse">TAP TO RESTART</div>
@@ -1224,19 +1210,6 @@ game(({ ctx, width, height, loop, ui, on, canvas }) => {
1224
1210
 
1225
1211
  ---
1226
1212
 
1227
- **Options:**
1228
-
1229
- \`\`\`javascript
1230
- // Default - auto-detects gameId on Star platform
1231
- const leaderboard = createLeaderboard();
1232
-
1233
- // Standalone use (outside Star platform)
1234
- const leaderboard = createLeaderboard({
1235
- gameId: 'your-game-uuid',
1236
- apiBase: 'https://buildwithstar.com'
1237
- });
1238
- \`\`\`
1239
-
1240
1213
  ---
1241
1214
 
1242
1215
  **getScores Options:**
@@ -1265,9 +1238,9 @@ const data = await leaderboard.getScores({
1265
1238
 
1266
1239
  2. **Fire and forget is fine** - \`submit()\` returns a Promise but you don't need to await it.
1267
1240
 
1268
- 3. **Use \`show()\` for platform UI** - It's the easiest way. Use \`getScores()\` only if you need custom rendering.
1241
+ 3. **Use \`show()\` to display the leaderboard** - It's the easiest way. Use \`getScores()\` only if you need custom rendering.
1269
1242
 
1270
- 4. **Don't store leaderboard state** - Just call the SDK methods when needed. The platform handles caching.
1243
+ 4. **Don't store leaderboard state** - Just call the SDK methods when needed. The SDK handles caching.
1271
1244
 
1272
1245
  5. **Works for guests** - Guests get a generated name like "Guest1234". They can sign in later to claim scores.`;
1273
1246
 
@@ -1409,14 +1382,11 @@ async function initCommand(name, email) {
1409
1382
  log(`${colors.dim}Config saved to${colors.reset} ${colors.bright}.starrc${colors.reset}`);
1410
1383
  log("");
1411
1384
  log(`${colors.dim}Next steps:${colors.reset}`);
1412
- log(` 1. Install: ${colors.cyan}npm install star-sdk${colors.reset}`);
1413
- log(` 2. Import Star SDK in your game`);
1414
- log(` 3. Initialize with your game ID`);
1415
- log(` 4. Use Star.leaderboard.submit(score) to submit scores`);
1385
+ log(` 1. Import Star SDK in your game`);
1386
+ log(` 2. Use Star.leaderboard.submit(score) to submit scores`);
1416
1387
  log("");
1417
1388
  log(`${colors.dim}Example:${colors.reset}`);
1418
1389
  log(` ${colors.cyan}import Star from 'star-sdk';${colors.reset}`);
1419
- log(` ${colors.cyan}Star.init({ gameId: '${data.gameId}' });${colors.reset}`);
1420
1390
  log(` ${colors.cyan}Star.leaderboard.submit(1500);${colors.reset}`);
1421
1391
  log("");
1422
1392
  log(`${colors.dim}Using an AI coding agent?${colors.reset}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "star-sdk-cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "CLI tool for Star SDK - register games and manage leaderboards",
5
5
  "type": "module",
6
6
  "bin": {