@inappstory/game-center-api 1.3.28 → 1.3.30
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.h.d.ts +1 -0
- package/lib/helpers/clipboard.d.ts +3 -0
- package/lib/helpers/clipboard.js +43 -0
- package/lib/iasApi.js +1 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +4 -1
- package/lib/sdkApi/clipboard.d.ts +1 -0
- package/lib/sdkApi/clipboard.js +38 -0
- package/package.json +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Clipboard = void 0;
|
|
4
|
+
exports.Clipboard = (function (window, document, navigator) {
|
|
5
|
+
let textArea = null, copy;
|
|
6
|
+
function isOS() {
|
|
7
|
+
return navigator.userAgent.match(/ipad|iphone/i);
|
|
8
|
+
}
|
|
9
|
+
function createTextArea(text) {
|
|
10
|
+
textArea = document.createElement("textarea");
|
|
11
|
+
textArea.value = text;
|
|
12
|
+
document.body.appendChild(textArea);
|
|
13
|
+
}
|
|
14
|
+
function selectText() {
|
|
15
|
+
if (textArea) {
|
|
16
|
+
if (isOS()) {
|
|
17
|
+
const range = document.createRange();
|
|
18
|
+
range.selectNodeContents(textArea);
|
|
19
|
+
const selection = window.getSelection();
|
|
20
|
+
if (selection) {
|
|
21
|
+
selection.removeAllRanges();
|
|
22
|
+
selection.addRange(range);
|
|
23
|
+
}
|
|
24
|
+
textArea.setSelectionRange(0, 999999);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
textArea.select();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function copyToClipboard() {
|
|
32
|
+
document.execCommand("copy");
|
|
33
|
+
textArea && document.body.removeChild(textArea);
|
|
34
|
+
}
|
|
35
|
+
copy = function (text) {
|
|
36
|
+
createTextArea(text);
|
|
37
|
+
selectText();
|
|
38
|
+
copyToClipboard();
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
copy: copy,
|
|
42
|
+
};
|
|
43
|
+
})(window, document, navigator);
|
package/lib/iasApi.js
CHANGED
|
@@ -14,6 +14,7 @@ const prepareHeaders = (headers) => ({
|
|
|
14
14
|
"X-Request-Id": (0, uuid_1.v4)(),
|
|
15
15
|
"X-User-Agent": gameLaunchConfig_1.gameLaunchConfig.clientConfig.userAgent,
|
|
16
16
|
"X-App-Package-Id": gameLaunchConfig_1.gameLaunchConfig.clientConfig.appPackageId,
|
|
17
|
+
"Accept-Language": gameLaunchConfig_1.gameLaunchConfig.clientConfig.lang,
|
|
17
18
|
},
|
|
18
19
|
...headers,
|
|
19
20
|
});
|
package/lib/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { FilePickerResultType, isFilePickerResultFileList, isFilePickerResultLoc
|
|
|
19
19
|
import { logError, logWarning } from "./eventLogger";
|
|
20
20
|
import { UserAccelerationSensor } from "./sdkApi/UserAccelerationSensor";
|
|
21
21
|
import { base64url_decode } from "./helpers/base64urlDecode";
|
|
22
|
+
import { writeTextToClipboard } from "./sdkApi/clipboard";
|
|
22
23
|
export type { OpenFilePickerProps, SDKFileResponse, LocalFile, LocalFileList, FilePickerResultPayload, FilePickerResult } from "./sdkApi/filePicker.h";
|
|
23
24
|
export type { PrimaryFontVariants as SDKPrimaryFontVariants, SecondaryFontVariants as SDKSecondaryFontVariants } from "./gameResources";
|
|
24
25
|
export type { OpenUrlOptions as SDKOpenUrlOptions } from "./sdkApi/openUrl.h";
|
|
@@ -29,7 +30,7 @@ export type { ResourceInterface } from "./ResourceManager";
|
|
|
29
30
|
export type { OpenStoryOptions } from "./sdkApi/openStory.h";
|
|
30
31
|
export type { OpenGameInstanceOptions } from "./sdkApi/openGameInstance.h";
|
|
31
32
|
export type { FetchLocalFileOptions } from "./sdkApi/fetchLocalFile";
|
|
32
|
-
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, };
|
|
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
34
|
declare const GameCenterApi: {
|
|
34
35
|
createSdkApi: ({ mounted, beforeUnmount: beforeUnmountCb, onSdkCloseGameReaderIntent, onPause, onResume, onBackGesture, onAudioFocusChange, filterPlaceholders, gameShouldForeground, }: Partial<{
|
|
35
36
|
mounted: () => Promise<void>;
|
|
@@ -99,6 +100,7 @@ declare const GameCenterApi: {
|
|
|
99
100
|
logWarning: (e: unknown, cause?: any) => void;
|
|
100
101
|
UserAccelerationSensor: typeof UserAccelerationSensor;
|
|
101
102
|
base64url_decode: typeof base64url_decode;
|
|
103
|
+
writeTextToClipboard: (textValue: string) => void;
|
|
102
104
|
};
|
|
103
105
|
export { GameCenterApi as default };
|
|
104
106
|
export { TraceablePromise } from "./TraceablePromise";
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserAccelerationSensor = 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.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.base64url_decode = void 0;
|
|
4
|
+
exports.TraceablePromise = exports.default = exports.writeTextToClipboard = exports.base64url_decode = 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; } });
|
|
@@ -74,6 +74,8 @@ const UserAccelerationSensor_1 = require("./sdkApi/UserAccelerationSensor");
|
|
|
74
74
|
Object.defineProperty(exports, "UserAccelerationSensor", { enumerable: true, get: function () { return UserAccelerationSensor_1.UserAccelerationSensor; } });
|
|
75
75
|
const base64urlDecode_1 = require("./helpers/base64urlDecode");
|
|
76
76
|
Object.defineProperty(exports, "base64url_decode", { enumerable: true, get: function () { return base64urlDecode_1.base64url_decode; } });
|
|
77
|
+
const clipboard_1 = require("./sdkApi/clipboard");
|
|
78
|
+
Object.defineProperty(exports, "writeTextToClipboard", { enumerable: true, get: function () { return clipboard_1.writeTextToClipboard; } });
|
|
77
79
|
const GameCenterApi = {
|
|
78
80
|
createSdkApi: sdkApi_1.createSdkApi,
|
|
79
81
|
closeGameReader: sdkApi_1.closeGameReader,
|
|
@@ -126,6 +128,7 @@ const GameCenterApi = {
|
|
|
126
128
|
logWarning: eventLogger_1.logWarning,
|
|
127
129
|
UserAccelerationSensor: UserAccelerationSensor_1.UserAccelerationSensor,
|
|
128
130
|
base64url_decode: base64urlDecode_1.base64url_decode,
|
|
131
|
+
writeTextToClipboard: clipboard_1.writeTextToClipboard,
|
|
129
132
|
};
|
|
130
133
|
exports.default = GameCenterApi;
|
|
131
134
|
var TraceablePromise_1 = require("./TraceablePromise");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const writeTextToClipboard: (textValue: string) => void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeTextToClipboard = void 0;
|
|
4
|
+
const env_1 = require("../env");
|
|
5
|
+
const Source_1 = require("./web/Source");
|
|
6
|
+
const gameLaunchConfig_1 = require("../gameLaunchConfig");
|
|
7
|
+
const clipboard_1 = require("../helpers/clipboard");
|
|
8
|
+
const writeTextToClipboard = (textValue) => {
|
|
9
|
+
const data = { type: "text", textValue };
|
|
10
|
+
if (env_1.isAndroid) {
|
|
11
|
+
if (window.Android.writeToClipboard !== undefined) {
|
|
12
|
+
window.Android.writeToClipboard(JSON.stringify(data));
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
// fallback via WebView old api
|
|
16
|
+
clipboard_1.Clipboard.copy(textValue);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else if (env_1.isIos) {
|
|
20
|
+
if (env_1.iosMh.writeToClipboard !== undefined) {
|
|
21
|
+
env_1.iosMh.writeToClipboard.postMessage(JSON.stringify(data));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// fallback via WebView old api
|
|
25
|
+
clipboard_1.Clipboard.copy(textValue);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else if (env_1.isWeb) {
|
|
29
|
+
if (Source_1.webSource.sourceWindow && Source_1.webSource.sourceWindowOrigin && gameLaunchConfig_1.gameLaunchConfig.clientConfig?.sdkFeatures?.writeToClipboard === true) {
|
|
30
|
+
Source_1.webSource.sourceWindow.postMessage(["writeToClipboard", JSON.stringify(data)], Source_1.webSource.sourceWindowOrigin);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// fallback via WebView old api
|
|
34
|
+
clipboard_1.Clipboard.copy(textValue);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.writeTextToClipboard = writeTextToClipboard;
|