@seaverse/dataservice 1.8.2 → 1.8.4

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.mts CHANGED
@@ -329,6 +329,26 @@ declare function setAppId(appId: string): void;
329
329
  * const orders = await client.userData.collection('orders').select().execute();
330
330
  * ```
331
331
  */
332
+ /**
333
+ * Notify the parent (SeaVerse App or iframe) of the current game score.
334
+ *
335
+ * Fire-and-forget — no response is expected.
336
+ *
337
+ * Protocol:
338
+ * - RN WebView: window.ReactNativeWebView.postMessage({ type: 'seaverse:game_score', score: number })
339
+ * - iframe: window.parent.postMessage({ type: 'seaverse:game_score', score: number }, '*')
340
+ *
341
+ * @param score Current game score (must be a non-negative number)
342
+ *
343
+ * @example
344
+ * ```typescript
345
+ * import { notifyGameScore } from '@seaverse/dataservice';
346
+ *
347
+ * // Call whenever the score updates
348
+ * notifyGameScore(1234);
349
+ * ```
350
+ */
351
+ declare function notifyGameScore(score: number): void;
332
352
  declare function createClient(config?: ClientConfig): Promise<DataServiceClient>;
333
353
 
334
354
  /**
@@ -377,6 +397,6 @@ declare function createClient(config?: ClientConfig): Promise<DataServiceClient>
377
397
  * ```
378
398
  */
379
399
 
380
- declare const VERSION = "1.8.0";
400
+ declare const VERSION = "1.8.4";
381
401
 
382
- export { type APIError, type ClientConfig, type Collection, type DataRecord, type DataServiceClient, DataServiceError, type DataTable, type OrderOptions, type QueryBuilder, type QueryFilter, type UserDataStats, VERSION, createClient, debugSetToken, setAppId };
402
+ export { type APIError, type ClientConfig, type Collection, type DataRecord, type DataServiceClient, DataServiceError, type DataTable, type OrderOptions, type QueryBuilder, type QueryFilter, type UserDataStats, VERSION, createClient, debugSetToken, notifyGameScore, setAppId };
package/dist/index.d.ts CHANGED
@@ -329,6 +329,26 @@ declare function setAppId(appId: string): void;
329
329
  * const orders = await client.userData.collection('orders').select().execute();
330
330
  * ```
331
331
  */
332
+ /**
333
+ * Notify the parent (SeaVerse App or iframe) of the current game score.
334
+ *
335
+ * Fire-and-forget — no response is expected.
336
+ *
337
+ * Protocol:
338
+ * - RN WebView: window.ReactNativeWebView.postMessage({ type: 'seaverse:game_score', score: number })
339
+ * - iframe: window.parent.postMessage({ type: 'seaverse:game_score', score: number }, '*')
340
+ *
341
+ * @param score Current game score (must be a non-negative number)
342
+ *
343
+ * @example
344
+ * ```typescript
345
+ * import { notifyGameScore } from '@seaverse/dataservice';
346
+ *
347
+ * // Call whenever the score updates
348
+ * notifyGameScore(1234);
349
+ * ```
350
+ */
351
+ declare function notifyGameScore(score: number): void;
332
352
  declare function createClient(config?: ClientConfig): Promise<DataServiceClient>;
333
353
 
334
354
  /**
@@ -377,6 +397,6 @@ declare function createClient(config?: ClientConfig): Promise<DataServiceClient>
377
397
  * ```
378
398
  */
379
399
 
380
- declare const VERSION = "1.8.0";
400
+ declare const VERSION = "1.8.4";
381
401
 
382
- export { type APIError, type ClientConfig, type Collection, type DataRecord, type DataServiceClient, DataServiceError, type DataTable, type OrderOptions, type QueryBuilder, type QueryFilter, type UserDataStats, VERSION, createClient, debugSetToken, setAppId };
402
+ export { type APIError, type ClientConfig, type Collection, type DataRecord, type DataServiceClient, DataServiceError, type DataTable, type OrderOptions, type QueryBuilder, type QueryFilter, type UserDataStats, VERSION, createClient, debugSetToken, notifyGameScore, setAppId };
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ __export(index_exports, {
24
24
  VERSION: () => VERSION,
25
25
  createClient: () => createClient,
26
26
  debugSetToken: () => debugSetToken,
27
+ notifyGameScore: () => notifyGameScore,
27
28
  setAppId: () => setAppId
28
29
  });
29
30
  module.exports = __toCommonJS(index_exports);
@@ -516,6 +517,19 @@ var DataServiceClientImpl = class {
516
517
  return this.client.post("/rpc/health");
517
518
  }
518
519
  };
520
+ function notifyGameScore(score) {
521
+ if (!isInIframe() && !isInSeaVerseApp()) return;
522
+ const payload = JSON.stringify({ type: "seaverse:game_score", score });
523
+ try {
524
+ if (isInSeaVerseApp()) {
525
+ globalThis.window.ReactNativeWebView.postMessage(payload);
526
+ } else {
527
+ globalThis.window.parent.postMessage({ type: "seaverse:game_score", score }, "*");
528
+ }
529
+ } catch (e) {
530
+ console.warn("[SeaVerse DataService SDK] Failed to notify game score:", e);
531
+ }
532
+ }
519
533
  async function createClient(config = {}) {
520
534
  let token = null;
521
535
  let serviceHost = null;
@@ -551,12 +565,13 @@ async function createClient(config = {}) {
551
565
  }
552
566
 
553
567
  // src/index.ts
554
- var VERSION = "1.8.0";
568
+ var VERSION = "1.8.4";
555
569
  // Annotate the CommonJS export names for ESM import in node:
556
570
  0 && (module.exports = {
557
571
  DataServiceError,
558
572
  VERSION,
559
573
  createClient,
560
574
  debugSetToken,
575
+ notifyGameScore,
561
576
  setAppId
562
577
  });
package/dist/index.mjs CHANGED
@@ -486,6 +486,19 @@ var DataServiceClientImpl = class {
486
486
  return this.client.post("/rpc/health");
487
487
  }
488
488
  };
489
+ function notifyGameScore(score) {
490
+ if (!isInIframe() && !isInSeaVerseApp()) return;
491
+ const payload = JSON.stringify({ type: "seaverse:game_score", score });
492
+ try {
493
+ if (isInSeaVerseApp()) {
494
+ globalThis.window.ReactNativeWebView.postMessage(payload);
495
+ } else {
496
+ globalThis.window.parent.postMessage({ type: "seaverse:game_score", score }, "*");
497
+ }
498
+ } catch (e) {
499
+ console.warn("[SeaVerse DataService SDK] Failed to notify game score:", e);
500
+ }
501
+ }
489
502
  async function createClient(config = {}) {
490
503
  let token = null;
491
504
  let serviceHost = null;
@@ -521,11 +534,12 @@ async function createClient(config = {}) {
521
534
  }
522
535
 
523
536
  // src/index.ts
524
- var VERSION = "1.8.0";
537
+ var VERSION = "1.8.4";
525
538
  export {
526
539
  DataServiceError,
527
540
  VERSION,
528
541
  createClient,
529
542
  debugSetToken,
543
+ notifyGameScore,
530
544
  setAppId
531
545
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seaverse/dataservice",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
4
4
  "description": "AI-Friendly Universal Data Storage SDK for TypeScript/JavaScript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",