@inappstory/game-center-api 1.3.4 → 1.3.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/lib/index.d.ts CHANGED
@@ -11,6 +11,7 @@ import { vibrate } from "./sdkApi/vibrate";
11
11
  import { ScreenOrientation, Placeholder, PlaceholderType, GameLaunchConfig } from "./gameLaunchConfig.h";
12
12
  import { fetchLocalFile } from "./sdkApi/fetchLocalFile";
13
13
  import { openStory } from "./sdkApi/openStory";
14
+ import { openGameInstance } from "./sdkApi/openGameInstance";
14
15
  import { eventGame } from "./sdkApi/events";
15
16
  import { ResourceManager } from "./ResourceManager";
16
17
  import { hasFilePickerApi, openFilePicker } from "./sdkApi/filePicker";
@@ -22,7 +23,9 @@ export type { RequestInfo as APIRequestInfo, Response as APIResponse } from "./i
22
23
  export type { Placeholder, GameLaunchConfig };
23
24
  export type { ProjectFontFamily } from "./gameResources";
24
25
  export type { ResourceInterface } from "./ResourceManager";
25
- export { createSdkApi, closeGameReader, gameLoadedSdkCallback, gameLoadFailedSdkCallback, gameLaunchConfig, isIos, isWeb, isAndroid, isDev, getSdkVersion, getSemverSdkVersion, gameLocalData, sendIasApiRequest, openUrl, shareText, shareUrl, shareFiles, vibrate, getDynamicResourceAsset, getDynamicResourceFont, getProjectFontFamilyStylesheet, getIsDemoMode, getSessionId, getApiBaseUrl, ScreenOrientation, PlaceholderType, fetchLocalFile, openStory, ResourceManager, dynamicResourceAssets, dynamicResourceFonts, staticResourcesImagePlaceholders, StaticResourceList, eventGame, reloadGameReader, openFilePicker, FilePickerResultType, isFilePickerResultFileList, isFilePickerResultLocalFileList, isLocalFile, hasFilePickerApi, gameShouldForegroundCallback, gameOnForeground, getApplicationVersion, getApplicationBuildVersion, };
26
+ export type { OpenStoryOptions } from "./sdkApi/openStory.h";
27
+ export type { OpenGameInstanceOptions } from "./sdkApi/openGameInstance.h";
28
+ export { createSdkApi, closeGameReader, gameLoadedSdkCallback, gameLoadFailedSdkCallback, gameLaunchConfig, isIos, isWeb, isAndroid, isDev, getSdkVersion, getSemverSdkVersion, gameLocalData, sendIasApiRequest, openUrl, shareText, shareUrl, shareFiles, vibrate, getDynamicResourceAsset, getDynamicResourceFont, getProjectFontFamilyStylesheet, getIsDemoMode, getSessionId, getApiBaseUrl, ScreenOrientation, PlaceholderType, fetchLocalFile, openStory, ResourceManager, dynamicResourceAssets, dynamicResourceFonts, staticResourcesImagePlaceholders, StaticResourceList, eventGame, reloadGameReader, openFilePicker, FilePickerResultType, isFilePickerResultFileList, isFilePickerResultLocalFileList, isLocalFile, hasFilePickerApi, gameShouldForegroundCallback, gameOnForeground, getApplicationVersion, getApplicationBuildVersion, openGameInstance, };
26
29
  declare const GameCenterApi: {
27
30
  createSdkApi: ({ mounted, beforeUnmount: beforeUnmountCb, onSdkCloseGameReaderIntent, onPause, onResume, onBackGesture, onAudioFocusChange, filterPlaceholders, gameShouldForeground, }: Partial<{
28
31
  mounted: () => void;
@@ -86,5 +89,6 @@ declare const GameCenterApi: {
86
89
  gameOnForeground: Promise<void>;
87
90
  getApplicationVersion: () => string | null;
88
91
  getApplicationBuildVersion: () => number | null;
92
+ openGameInstance: (openGameInstance: import("./sdkApi/openGameInstance.h").OpenGameInstanceOptions) => void;
89
93
  };
90
94
  export { GameCenterApi as default };
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = exports.getApplicationBuildVersion = exports.getApplicationVersion = exports.gameOnForeground = exports.gameShouldForegroundCallback = exports.hasFilePickerApi = exports.isLocalFile = exports.isFilePickerResultLocalFileList = exports.isFilePickerResultFileList = exports.FilePickerResultType = exports.openFilePicker = exports.reloadGameReader = exports.eventGame = exports.StaticResourceList = exports.staticResourcesImagePlaceholders = exports.dynamicResourceFonts = exports.dynamicResourceAssets = exports.ResourceManager = exports.openStory = exports.fetchLocalFile = exports.PlaceholderType = exports.ScreenOrientation = exports.getApiBaseUrl = exports.getSessionId = exports.getIsDemoMode = exports.getProjectFontFamilyStylesheet = exports.getDynamicResourceFont = exports.getDynamicResourceAsset = exports.vibrate = exports.shareFiles = exports.shareUrl = exports.shareText = exports.openUrl = exports.sendIasApiRequest = exports.gameLocalData = exports.getSemverSdkVersion = exports.getSdkVersion = exports.isDev = exports.isAndroid = exports.isWeb = exports.isIos = exports.gameLaunchConfig = exports.gameLoadFailedSdkCallback = exports.gameLoadedSdkCallback = exports.closeGameReader = exports.createSdkApi = void 0;
3
+ exports.default = exports.openGameInstance = exports.getApplicationBuildVersion = exports.getApplicationVersion = exports.gameOnForeground = exports.gameShouldForegroundCallback = exports.hasFilePickerApi = exports.isLocalFile = exports.isFilePickerResultLocalFileList = exports.isFilePickerResultFileList = exports.FilePickerResultType = exports.openFilePicker = exports.reloadGameReader = exports.eventGame = exports.StaticResourceList = exports.staticResourcesImagePlaceholders = exports.dynamicResourceFonts = exports.dynamicResourceAssets = exports.ResourceManager = exports.openStory = exports.fetchLocalFile = exports.PlaceholderType = exports.ScreenOrientation = exports.getApiBaseUrl = exports.getSessionId = exports.getIsDemoMode = exports.getProjectFontFamilyStylesheet = exports.getDynamicResourceFont = exports.getDynamicResourceAsset = exports.vibrate = exports.shareFiles = exports.shareUrl = exports.shareText = exports.openUrl = exports.sendIasApiRequest = exports.gameLocalData = exports.getSemverSdkVersion = exports.getSdkVersion = exports.isDev = exports.isAndroid = exports.isWeb = exports.isIos = exports.gameLaunchConfig = exports.gameLoadFailedSdkCallback = exports.gameLoadedSdkCallback = exports.closeGameReader = exports.createSdkApi = void 0;
4
4
  const env_1 = require("./env");
5
5
  Object.defineProperty(exports, "getApplicationBuildVersion", { enumerable: true, get: function () { return env_1.getApplicationBuildVersion; } });
6
6
  Object.defineProperty(exports, "getApplicationVersion", { enumerable: true, get: function () { return env_1.getApplicationVersion; } });
@@ -51,6 +51,8 @@ const fetchLocalFile_1 = require("./sdkApi/fetchLocalFile");
51
51
  Object.defineProperty(exports, "fetchLocalFile", { enumerable: true, get: function () { return fetchLocalFile_1.fetchLocalFile; } });
52
52
  const openStory_1 = require("./sdkApi/openStory");
53
53
  Object.defineProperty(exports, "openStory", { enumerable: true, get: function () { return openStory_1.openStory; } });
54
+ const openGameInstance_1 = require("./sdkApi/openGameInstance");
55
+ Object.defineProperty(exports, "openGameInstance", { enumerable: true, get: function () { return openGameInstance_1.openGameInstance; } });
54
56
  const events_1 = require("./sdkApi/events");
55
57
  Object.defineProperty(exports, "eventGame", { enumerable: true, get: function () { return events_1.eventGame; } });
56
58
  const ResourceManager_1 = require("./ResourceManager");
@@ -109,6 +111,7 @@ const GameCenterApi = {
109
111
  gameOnForeground: initGame_1.gameOnForeground,
110
112
  getApplicationVersion: env_1.getApplicationVersion,
111
113
  getApplicationBuildVersion: env_1.getApplicationBuildVersion,
114
+ openGameInstance: openGameInstance_1.openGameInstance,
112
115
  };
113
116
  exports.default = GameCenterApi;
114
117
  // export { Placeholder as default};
@@ -1,6 +1,7 @@
1
1
  export declare class LocalDataMap<K, V> extends Map<K, V> {
2
2
  set(key: K, value: V): this;
3
3
  delete(key: K): boolean;
4
+ clear(): void;
4
5
  protected init(entries: [K, V][]): this;
5
6
  }
6
7
  export declare let gameLocalData: LocalDataMap<string, any>;
package/lib/localData.js CHANGED
@@ -24,6 +24,10 @@ class LocalDataMap extends Map {
24
24
  }
25
25
  return removed;
26
26
  }
27
+ clear() {
28
+ super.clear();
29
+ setGameLocalData();
30
+ }
27
31
  init(entries) {
28
32
  entries.forEach(entrie => super.set(entrie[0], entrie[1]));
29
33
  return this;
@@ -3,11 +3,13 @@
3
3
  */
4
4
  import { SdkApiCallbacks } from "./index.h";
5
5
  import { OpenStoryOptions } from "./openStory.h";
6
+ import { OpenGameInstanceOptions } from "./openGameInstance.h";
6
7
  export declare const createSdkApi: ({ mounted, beforeUnmount: beforeUnmountCb, onSdkCloseGameReaderIntent, onPause, onResume, onBackGesture, onAudioFocusChange, filterPlaceholders, gameShouldForeground, }: SdkApiCallbacks) => void;
7
8
  export type CloseGameReaderOptions = {
8
9
  [key: string]: any;
9
10
  openUrl?: string;
10
11
  openStory?: OpenStoryOptions;
12
+ openGameInstance?: OpenGameInstanceOptions;
11
13
  };
12
14
  export declare const closeGameReader: (data?: CloseGameReaderOptions) => void;
13
15
  export declare const reloadGameReader: () => void;
@@ -136,9 +136,13 @@ const sdkCloseGameReader = (data) => {
136
136
  const devPayload = data ?? {};
137
137
  const openUrl = data?.openUrl != null ? data.openUrl : null;
138
138
  const openStory = data?.openStory != null ? data.openStory : null;
139
+ const openGameInstance = data?.openGameInstance != null ? data.openGameInstance : null;
140
+ if (openGameInstance != null && openGameInstance.id != null) {
141
+ openGameInstance.id = String(openGameInstance.id);
142
+ }
139
143
  if (env_1.isAndroid) {
140
144
  // {openUrl: null, openStory: {id: 1, slideIndex: 0}}
141
- const config = JSON.stringify({ openUrl, openStory });
145
+ const config = JSON.stringify({ openUrl, openStory, openGameInstance });
142
146
  window.Android.gameComplete(JSON.stringify(data), JSON.stringify(devPayload), config);
143
147
  }
144
148
  else if (env_1.isIos) {
@@ -148,11 +152,12 @@ const sdkCloseGameReader = (data) => {
148
152
  result: devPayload,
149
153
  openUrl,
150
154
  openStory,
155
+ openGameInstance,
151
156
  }));
152
157
  }
153
158
  else if (env_1.isWeb) {
154
159
  if (Source_1.webSource.sourceWindow && Source_1.webSource.sourceWindowOrigin) {
155
- Source_1.webSource.sourceWindow.postMessage(["gameComplete", data, devPayload, null, openStory], Source_1.webSource.sourceWindowOrigin);
160
+ Source_1.webSource.sourceWindow.postMessage(["gameComplete", data, devPayload, null, openStory, openGameInstance], Source_1.webSource.sourceWindowOrigin);
156
161
  }
157
162
  }
158
163
  };
@@ -0,0 +1,2 @@
1
+ import { OpenGameInstanceOptions } from "./openGameInstance.h";
2
+ export declare const openGameInstance: (openGameInstance: OpenGameInstanceOptions) => void;
@@ -0,0 +1,3 @@
1
+ export type OpenGameInstanceOptions = {
2
+ id: string | number;
3
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.openGameInstance = void 0;
4
+ const index_1 = require("./index");
5
+ const openGameInstance = (openGameInstance) => {
6
+ (0, index_1.closeGameReader)({ openGameInstance });
7
+ };
8
+ exports.openGameInstance = openGameInstance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inappstory/game-center-api",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "description": "",
5
5
  "dependencies": {
6
6
  "semver": "^7.3.8",