@playcademy/sdk 0.6.1-beta.4 → 0.6.1-beta.6

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.
package/dist/index.d.ts CHANGED
@@ -787,7 +787,7 @@ declare const items: drizzle_orm_pg_core.PgTableWithColumns<{
787
787
  generated: undefined;
788
788
  }, {}, {}>;
789
789
  };
790
- dialect: "pg";
790
+ dialect: 'pg';
791
791
  }>;
792
792
  declare const inventoryItems: drizzle_orm_pg_core.PgTableWithColumns<{
793
793
  name: "inventory_items";
@@ -879,7 +879,7 @@ declare const inventoryItems: drizzle_orm_pg_core.PgTableWithColumns<{
879
879
  generated: undefined;
880
880
  }, {}, {}>;
881
881
  };
882
- dialect: "pg";
882
+ dialect: 'pg';
883
883
  }>;
884
884
 
885
885
  type ItemRow = typeof items.$inferSelect;
@@ -1760,8 +1760,8 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
1760
1760
  */
1761
1761
  runtime: {
1762
1762
  getGameToken: (gameId: string, options?: {
1763
- apply?: boolean | undefined;
1764
- } | undefined) => Promise<GameTokenResponse>;
1763
+ apply?: boolean;
1764
+ }) => Promise<GameTokenResponse>;
1765
1765
  exit: () => Promise<void>;
1766
1766
  onInit: (handler: (context: GameContextPayload) => void) => void;
1767
1767
  onTokenRefresh: (handler: (data: {
@@ -1785,7 +1785,7 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
1785
1785
  getListenerCounts: () => Record<string, number>;
1786
1786
  assets: {
1787
1787
  url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
1788
- fetch: (path: string, options?: RequestInit | undefined) => Promise<Response>;
1788
+ fetch: (path: string, options?: RequestInit) => Promise<Response>;
1789
1789
  json: <T = unknown>(path: string) => Promise<T>;
1790
1790
  blob: (path: string) => Promise<Blob>;
1791
1791
  text: (path: string) => Promise<string>;
@@ -1810,13 +1810,13 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
1810
1810
  */
1811
1811
  timeback: {
1812
1812
  readonly user: TimebackUser;
1813
- startActivity: (metadata: ActivityData, options?: StartActivityOptions | undefined) => void;
1813
+ startActivity: (metadata: ActivityData, options?: StartActivityOptions) => void;
1814
1814
  pauseActivity: () => void;
1815
1815
  resumeActivity: () => void;
1816
1816
  endActivity: (data: EndActivityScoreData) => Promise<EndActivityResponse>;
1817
1817
  advanceCourse: (options?: {
1818
- subject?: TimebackSubject | undefined;
1819
- } | undefined) => Promise<AdvanceCourseResponse>;
1818
+ subject?: TimebackSubject;
1819
+ }) => Promise<AdvanceCourseResponse>;
1820
1820
  };
1821
1821
  /**
1822
1822
  * Playcademy Credits (platform currency) management.
@@ -1833,14 +1833,14 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
1833
1833
  * - `submit(score, metadata?)` - Record a game score
1834
1834
  */
1835
1835
  scores: {
1836
- submit: (score: number, metadata?: Record<string, unknown> | undefined) => Promise<ScoreSubmission>;
1836
+ submit: (score: number, metadata?: Record<string, unknown>) => Promise<ScoreSubmission>;
1837
1837
  };
1838
1838
  /**
1839
1839
  * Read-only leaderboard access for the current game scope.
1840
1840
  * - `fetch(options?)` - Fetch leaderboard entries
1841
1841
  */
1842
1842
  leaderboard: {
1843
- fetch: (options?: LeaderboardOptions | undefined) => Promise<GameLeaderboardEntry[]>;
1843
+ fetch: (options?: LeaderboardOptions) => Promise<GameLeaderboardEntry[]>;
1844
1844
  };
1845
1845
  /**
1846
1846
  * Demo-mode helpers. Methods throw when called outside `client.mode === 'demo'`,
@@ -1854,7 +1854,7 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
1854
1854
  get: () => Promise<DemoProfile>;
1855
1855
  update: (updates: DemoProfileUpdate) => Promise<DemoProfile>;
1856
1856
  };
1857
- end: (score: number, options?: DemoEndOptions | undefined) => void;
1857
+ end: (score: number, options?: DemoEndOptions) => void;
1858
1858
  };
1859
1859
  /**
1860
1860
  * Realtime multiplayer authentication.
@@ -1871,13 +1871,13 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
1871
1871
  * - Routes are relative to your game's deployment (e.g., '/hello' → your-game.playcademy.gg/api/hello)
1872
1872
  */
1873
1873
  backend: {
1874
- get<T = unknown>(path: string, headers?: Record<string, string> | undefined): Promise<T>;
1875
- post<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
1876
- put<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
1877
- patch<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
1878
- delete<T = unknown>(path: string, headers?: Record<string, string> | undefined): Promise<T>;
1879
- request<T = unknown>(path: string, method: Method, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
1880
- download(path: string, method?: Method, body?: unknown, headers?: Record<string, string> | undefined): Promise<Response>;
1874
+ get<T = unknown>(path: string, headers?: Record<string, string>): Promise<T>;
1875
+ post<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
1876
+ put<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
1877
+ patch<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
1878
+ delete<T = unknown>(path: string, headers?: Record<string, string>): Promise<T>;
1879
+ request<T = unknown>(path: string, method: Method, body?: unknown, headers?: Record<string, string>): Promise<T>;
1880
+ download(path: string, method?: Method, body?: unknown, headers?: Record<string, string>): Promise<Response>;
1881
1881
  url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
1882
1882
  };
1883
1883
  /** Auto-initializes a PlaycademyClient with context from the environment */
package/dist/index.js CHANGED
@@ -321,7 +321,7 @@ function formatJSONSingleLine(level, message, context, scope) {
321
321
  ...context && Object.keys(context).length > 0 && { context }
322
322
  };
323
323
  const consoleMethod = getConsoleMethod(level);
324
- consoleMethod(JSON.stringify(logEntry));
324
+ consoleMethod(safeJSONStringify(logEntry));
325
325
  }
326
326
  function formatJSONPretty(level, message, context, scope) {
327
327
  const timestamp = new Date().toISOString();
@@ -333,7 +333,30 @@ function formatJSONPretty(level, message, context, scope) {
333
333
  ...context && Object.keys(context).length > 0 && { context }
334
334
  };
335
335
  const consoleMethod = getConsoleMethod(level);
336
- consoleMethod(JSON.stringify(logEntry, null, 2));
336
+ consoleMethod(safeJSONStringify(logEntry, 2));
337
+ }
338
+ function safeJSONStringify(value, space) {
339
+ const seen = new WeakSet;
340
+ try {
341
+ return JSON.stringify(value, (_key, currentValue) => {
342
+ if (typeof currentValue === "bigint") {
343
+ return currentValue.toString();
344
+ }
345
+ if (typeof currentValue === "object" && currentValue !== null) {
346
+ if (seen.has(currentValue)) {
347
+ return "[Circular]";
348
+ }
349
+ seen.add(currentValue);
350
+ }
351
+ return currentValue;
352
+ }, space);
353
+ } catch {
354
+ return JSON.stringify({
355
+ timestamp: new Date().toISOString(),
356
+ level: "ERROR",
357
+ message: "[Logger] Failed to serialize log entry"
358
+ });
359
+ }
337
360
  }
338
361
  function getConsoleMethod(level) {
339
362
  switch (level) {
@@ -1005,7 +1028,7 @@ function createAssetsNamespace(client) {
1005
1028
  fetch: fetchAsset,
1006
1029
  json: async (path) => {
1007
1030
  const response = await fetchAsset(path);
1008
- return response.json();
1031
+ return await response.json();
1009
1032
  },
1010
1033
  blob: async (path) => {
1011
1034
  const response = await fetchAsset(path);
@@ -1297,10 +1320,10 @@ var ACHIEVEMENT_DEFINITIONS = [
1297
1320
  var TypeScriptPackages = {
1298
1321
  tsc: "tsc",
1299
1322
  nativePreview: "@typescript/native-preview",
1300
- nativePreviewPinned: "@typescript/native-preview@7.0.0-dev.20260221.1"
1323
+ nativePreviewBeta: "@typescript/native-preview@beta"
1301
1324
  };
1302
1325
  var TYPESCRIPT_RUNNER = {
1303
- package: TypeScriptPackages.nativePreviewPinned,
1326
+ package: TypeScriptPackages.nativePreviewBeta,
1304
1327
  bin: "tsgo"
1305
1328
  };
1306
1329
  // ../constants/src/overworld.ts