@inappstory/game-center-api 1.3.30 → 1.3.32
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/gameLaunchConfig.d.ts +1 -0
- package/lib/gameLaunchConfig.h.d.ts +1 -1
- package/lib/gameLaunchConfig.js +10 -4
- package/lib/index.d.ts +3 -2
- package/lib/index.js +4 -2
- package/lib/sdkApi/initGame.js +10 -4
- package/package.json +1 -1
package/lib/gameLaunchConfig.js
CHANGED
|
@@ -3,13 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getApiBaseUrl = exports.getSessionId = exports.getIsDemoMode = exports.getGameInstanceId = exports.setGameLaunchConfig = exports.gameLaunchHandlers = exports.gameLaunchConfig = void 0;
|
|
6
|
+
exports.getTextWritingDir = exports.getApiBaseUrl = exports.getSessionId = exports.getIsDemoMode = exports.getGameInstanceId = exports.setGameLaunchConfig = exports.gameLaunchHandlers = exports.gameLaunchConfig = void 0;
|
|
7
7
|
const gameLaunchConfig_h_1 = require("./gameLaunchConfig.h");
|
|
8
8
|
const env_1 = require("./env");
|
|
9
9
|
const semver_1 = __importDefault(require("semver"));
|
|
10
10
|
const base64urlDecode_1 = require("./helpers/base64urlDecode");
|
|
11
11
|
const gameResources_1 = require("./gameResources");
|
|
12
|
-
exports.gameLaunchConfig = {
|
|
12
|
+
exports.gameLaunchConfig = {
|
|
13
|
+
clientConfig: {},
|
|
14
|
+
};
|
|
13
15
|
exports.gameLaunchHandlers = {
|
|
14
16
|
filterPlaceholders: (placeholders) => placeholders,
|
|
15
17
|
};
|
|
@@ -18,7 +20,7 @@ function setGameLaunchConfig(config) {
|
|
|
18
20
|
// @ts-ignore
|
|
19
21
|
exports.gameLaunchConfig[key] = config[key];
|
|
20
22
|
}
|
|
21
|
-
checkUserId(exports.gameLaunchConfig
|
|
23
|
+
checkUserId(exports.gameLaunchConfig.clientConfig.userId);
|
|
22
24
|
processImagePlaceholders();
|
|
23
25
|
Object.freeze(exports.gameLaunchConfig);
|
|
24
26
|
}
|
|
@@ -39,6 +41,10 @@ function getApiBaseUrl() {
|
|
|
39
41
|
return exports.gameLaunchConfig.clientConfig.apiBaseUrl;
|
|
40
42
|
}
|
|
41
43
|
exports.getApiBaseUrl = getApiBaseUrl;
|
|
44
|
+
function getTextWritingDir() {
|
|
45
|
+
return exports.gameLaunchConfig.clientConfig.dir;
|
|
46
|
+
}
|
|
47
|
+
exports.getTextWritingDir = getTextWritingDir;
|
|
42
48
|
function checkUserId(userId) {
|
|
43
49
|
let emptyUserIdFromSdk = false;
|
|
44
50
|
if (env_1.isAndroid) {
|
|
@@ -67,7 +73,7 @@ function checkUserId(userId) {
|
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
function processImagePlaceholders() {
|
|
70
|
-
if (exports.gameLaunchConfig
|
|
76
|
+
if (exports.gameLaunchConfig.clientConfig?.placeholders && Array.isArray(exports.gameLaunchConfig.clientConfig?.placeholders)) {
|
|
71
77
|
const placeholders = exports.gameLaunchHandlers.filterPlaceholders(exports.gameLaunchConfig.clientConfig.placeholders);
|
|
72
78
|
for (let i = 0; i < placeholders.length; ++i) {
|
|
73
79
|
const placeholder = placeholders[i];
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getApplicationBuildVersion, getApplicationVersion, getSdkVersion, getSemverSdkVersion, isAndroid, isDev, isIos, isWeb } from "./env";
|
|
2
|
-
import { gameLaunchConfig, getIsDemoMode, getSessionId, getApiBaseUrl } from "./gameLaunchConfig";
|
|
2
|
+
import { gameLaunchConfig, getIsDemoMode, getSessionId, getApiBaseUrl, getTextWritingDir } from "./gameLaunchConfig";
|
|
3
3
|
import { getDynamicResourceAsset, getDynamicResourceFont, getProjectFontFamilyStylesheet, dynamicResourceAssets, dynamicResourceFonts, staticResourcesImagePlaceholders, StaticResourceList } from "./gameResources";
|
|
4
4
|
import { sendIasApiRequest } from "./iasApi";
|
|
5
5
|
import { gameLocalData } from "./localData";
|
|
@@ -30,7 +30,7 @@ export type { ResourceInterface } from "./ResourceManager";
|
|
|
30
30
|
export type { OpenStoryOptions } from "./sdkApi/openStory.h";
|
|
31
31
|
export type { OpenGameInstanceOptions } from "./sdkApi/openGameInstance.h";
|
|
32
32
|
export type { FetchLocalFileOptions } from "./sdkApi/fetchLocalFile";
|
|
33
|
-
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, convertLocalFileUriToRemoteFileUri, openStory, ResourceManager, dynamicResourceAssets, dynamicResourceFonts, staticResourcesImagePlaceholders, StaticResourceList, eventGame, reloadGameReader, openFilePicker, FilePickerResultType, isFilePickerResultFileList, isFilePickerResultLocalFileList, isLocalFile, hasFilePickerApi, gameShouldForegroundCallback, gameOnForeground, getApplicationVersion, getApplicationBuildVersion, openGameInstance, logError, logWarning, UserAccelerationSensor, base64url_decode, writeTextToClipboard, };
|
|
33
|
+
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, getTextWritingDir, ScreenOrientation, PlaceholderType, fetchLocalFile, convertLocalFileUriToRemoteFileUri, openStory, ResourceManager, dynamicResourceAssets, dynamicResourceFonts, staticResourcesImagePlaceholders, StaticResourceList, eventGame, reloadGameReader, openFilePicker, FilePickerResultType, isFilePickerResultFileList, isFilePickerResultLocalFileList, isLocalFile, hasFilePickerApi, gameShouldForegroundCallback, gameOnForeground, getApplicationVersion, getApplicationBuildVersion, openGameInstance, logError, logWarning, UserAccelerationSensor, base64url_decode, writeTextToClipboard, };
|
|
34
34
|
declare const GameCenterApi: {
|
|
35
35
|
createSdkApi: ({ mounted, beforeUnmount: beforeUnmountCb, onSdkCloseGameReaderIntent, onPause, onResume, onBackGesture, onAudioFocusChange, filterPlaceholders, gameShouldForeground, }: Partial<{
|
|
36
36
|
mounted: () => Promise<void>;
|
|
@@ -70,6 +70,7 @@ declare const GameCenterApi: {
|
|
|
70
70
|
getIsDemoMode: typeof getIsDemoMode;
|
|
71
71
|
getSessionId: typeof getSessionId;
|
|
72
72
|
getApiBaseUrl: typeof getApiBaseUrl;
|
|
73
|
+
getTextWritingDir: typeof getTextWritingDir;
|
|
73
74
|
ScreenOrientation: typeof ScreenOrientation;
|
|
74
75
|
PlaceholderType: typeof PlaceholderType;
|
|
75
76
|
fetchLocalFile: typeof fetchLocalFile;
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.TraceablePromise = exports.default = exports.writeTextToClipboard = exports.base64url_decode = void 0;
|
|
3
|
+
exports.logWarning = exports.logError = 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.convertLocalFileUriToRemoteFileUri = exports.fetchLocalFile = exports.PlaceholderType = exports.ScreenOrientation = exports.getTextWritingDir = 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
|
+
exports.TraceablePromise = exports.default = exports.writeTextToClipboard = exports.base64url_decode = exports.UserAccelerationSensor = void 0;
|
|
5
5
|
const env_1 = require("./env");
|
|
6
6
|
Object.defineProperty(exports, "getApplicationBuildVersion", { enumerable: true, get: function () { return env_1.getApplicationBuildVersion; } });
|
|
7
7
|
Object.defineProperty(exports, "getApplicationVersion", { enumerable: true, get: function () { return env_1.getApplicationVersion; } });
|
|
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "gameLaunchConfig", { enumerable: true, get: func
|
|
|
16
16
|
Object.defineProperty(exports, "getIsDemoMode", { enumerable: true, get: function () { return gameLaunchConfig_1.getIsDemoMode; } });
|
|
17
17
|
Object.defineProperty(exports, "getSessionId", { enumerable: true, get: function () { return gameLaunchConfig_1.getSessionId; } });
|
|
18
18
|
Object.defineProperty(exports, "getApiBaseUrl", { enumerable: true, get: function () { return gameLaunchConfig_1.getApiBaseUrl; } });
|
|
19
|
+
Object.defineProperty(exports, "getTextWritingDir", { enumerable: true, get: function () { return gameLaunchConfig_1.getTextWritingDir; } });
|
|
19
20
|
const gameResources_1 = require("./gameResources");
|
|
20
21
|
Object.defineProperty(exports, "getDynamicResourceAsset", { enumerable: true, get: function () { return gameResources_1.getDynamicResourceAsset; } });
|
|
21
22
|
Object.defineProperty(exports, "getDynamicResourceFont", { enumerable: true, get: function () { return gameResources_1.getDynamicResourceFont; } });
|
|
@@ -101,6 +102,7 @@ const GameCenterApi = {
|
|
|
101
102
|
getIsDemoMode: gameLaunchConfig_1.getIsDemoMode,
|
|
102
103
|
getSessionId: gameLaunchConfig_1.getSessionId,
|
|
103
104
|
getApiBaseUrl: gameLaunchConfig_1.getApiBaseUrl,
|
|
105
|
+
getTextWritingDir: gameLaunchConfig_1.getTextWritingDir,
|
|
104
106
|
ScreenOrientation: gameLaunchConfig_h_1.ScreenOrientation,
|
|
105
107
|
PlaceholderType: gameLaunchConfig_h_1.PlaceholderType,
|
|
106
108
|
fetchLocalFile: fetchLocalFile_1.fetchLocalFile,
|
package/lib/sdkApi/initGame.js
CHANGED
|
@@ -109,13 +109,19 @@ const createInitGame = (initLocalData, mounted = () => Promise.resolve()) => {
|
|
|
109
109
|
// @ts-ignore
|
|
110
110
|
window.__config = config;
|
|
111
111
|
}
|
|
112
|
-
if (gameLaunchConfig_1.gameLaunchConfig
|
|
113
|
-
(0, createNonce_1.createNonce)(gameLaunchConfig_1.gameLaunchConfig
|
|
112
|
+
if (gameLaunchConfig_1.gameLaunchConfig.clientConfig?.nonce) {
|
|
113
|
+
(0, createNonce_1.createNonce)(gameLaunchConfig_1.gameLaunchConfig.clientConfig?.nonce);
|
|
114
114
|
}
|
|
115
|
-
if (gameLaunchConfig_1.gameLaunchConfig
|
|
115
|
+
if (gameLaunchConfig_1.gameLaunchConfig.clientConfig.dir) {
|
|
116
116
|
// for web-sdk - set dir attribute from clientConfig
|
|
117
117
|
// bcz web-sdk cannot access to document.documentElement inside game iFrame
|
|
118
|
-
window.document.documentElement.dir = gameLaunchConfig_1.gameLaunchConfig
|
|
118
|
+
window.document.documentElement.dir = gameLaunchConfig_1.gameLaunchConfig.clientConfig.dir;
|
|
119
|
+
}
|
|
120
|
+
if (window.document.documentElement.dir === "rtl") {
|
|
121
|
+
gameLaunchConfig_1.gameLaunchConfig.clientConfig.dir = "rtl";
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
gameLaunchConfig_1.gameLaunchConfig.clientConfig.dir = window.document.documentElement.dir = "ltr";
|
|
119
125
|
}
|
|
120
126
|
try {
|
|
121
127
|
await initLocalData();
|