@shopgate/pwa-core 7.30.0-alpha.6 → 7.30.0-alpha.8
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/classes/AppCommand/index.js +115 -11
- package/classes/AppCommand/spec.js +260 -6
- package/classes/AppCommandRequest/index.js +129 -20
- package/classes/AppPermissionsRequest/AppPermissionsRequest.js +45 -7
- package/classes/AppPermissionsRequest/GetAppPermissionsRequest.js +48 -9
- package/classes/AppPermissionsRequest/RequestAppPermissionsRequest.js +54 -9
- package/classes/Bridge/index.js +34 -4
- package/classes/Bridge/spec.js +24 -1
- package/classes/BrightnessRequest/index.js +59 -10
- package/classes/BrightnessRequest/spec.js +111 -6
- package/classes/BrowserConnector/index.js +180 -26
- package/classes/Conditioner/index.js +74 -8
- package/classes/Conditioner/spec.js +75 -1
- package/classes/DataRequest/index.js +116 -13
- package/classes/DevServerBridge/index.js +86 -9
- package/classes/DevServerBridge/spec.js +231 -14
- package/classes/ErrorManager/index.js +144 -20
- package/classes/ErrorManager/spec.js +244 -2
- package/classes/Event/index.js +101 -15
- package/classes/HttpRequest/index.js +182 -21
- package/classes/PipelineDependencies/index.js +42 -6
- package/classes/PipelineDependencies/spec.js +46 -3
- package/classes/PipelineManager/index.js +517 -71
- package/classes/PipelineManager/spec.js +733 -15
- package/classes/PipelineRequest/index.js +167 -19
- package/classes/PipelineRequest/mock.js +118 -21
- package/classes/PipelineRequest/spec.js +333 -2
- package/classes/PipelineSequence/index.js +34 -6
- package/classes/Request/index.js +61 -13
- package/classes/RequestBuffer/index.js +43 -6
- package/classes/RequestManager/index.js +216 -33
- package/classes/RequestManager/spec.js +188 -1
- package/classes/Scanner/index.js +246 -67
- package/classes/ScannerEvent/index.js +23 -9
- package/classes/ScannerEventHandler/index.js +39 -16
- package/classes/ScannerEventListener/index.js +84 -24
- package/classes/ScannerManager/ScanProcessingError.js +11 -3
- package/classes/ScannerManager/index.js +133 -21
- package/classes/WebStorageRequest/index.js +76 -9
- package/commands/analyticsSetCustomValues.js +8 -2
- package/commands/appPermissions.js +10 -3
- package/commands/brightness.js +33 -5
- package/commands/broadcastEvent.js +8 -2
- package/commands/cleanTab.js +11 -3
- package/commands/closeInAppBrowser.js +22 -2
- package/commands/flushTab.js +8 -2
- package/commands/getWebStorageEntry.js +11 -2
- package/commands/hideMenuBar.js +8 -2
- package/commands/hideNavigationBar.js +8 -2
- package/commands/hideSplashScreen.js +8 -2
- package/commands/onload.js +13 -3
- package/commands/openAppSettings.js +8 -2
- package/commands/openPage.js +8 -2
- package/commands/openPageExtern.js +8 -2
- package/commands/performCommandsAfterDelay.js +11 -3
- package/commands/plotProjects.js +65 -7
- package/commands/popTabToRoot.js +11 -3
- package/commands/registerEvents.js +10 -2
- package/commands/scanner.js +76 -7
- package/commands/setCookie.js +8 -2
- package/commands/setDebugLoggingEnabled.js +8 -2
- package/commands/setScrollingEnabled.js +7 -2
- package/commands/setWebStorageEntry.js +8 -2
- package/commands/shareItem.js +18 -2
- package/commands/showNavigationBar.js +8 -2
- package/commands/showTab.js +13 -2
- package/commands/unifiedTracking.js +128 -30
- package/constants/AppCommands.js +6 -1
- package/constants/AppEvents.js +9 -1
- package/constants/AppPermissions.js +57 -13
- package/constants/Command.js +1 -1
- package/constants/ErrorHandleTypes.js +2 -1
- package/constants/ErrorManager.js +15 -1
- package/constants/Pipeline.js +52 -17
- package/constants/ProcessTypes.js +3 -1
- package/constants/RequestManagerModes.js +19 -7
- package/constants/RequestTypes.js +2 -1
- package/constants/Scanner.js +39 -10
- package/constants/Trilean.js +6 -1
- package/emitters/ui.js +2 -1
- package/helpers/index.js +66 -8
- package/helpers/logGroup.js +56 -8
- package/helpers/version.js +216 -22
- package/index.js +60 -5
- package/package.json +1 -1
|
@@ -1,55 +1,167 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { logger } from "../../helpers";
|
|
2
|
+
import event from "../Event";
|
|
3
|
+
import registerEvents from "../../commands/registerEvents";
|
|
4
|
+
import broadcastEvent from "../../commands/broadcastEvent";
|
|
5
|
+
import { SCANNER_MODE_ON, SCANNER_TYPE_BARCODE, SCANNER_TYPE_IMAGE } from "../../constants/Scanner";
|
|
6
|
+
import { openScanner, closeScanner, startScanner } from "../../commands/scanner";
|
|
7
|
+
export const APP_EVENT_CLOSE_SCANNER = 'closeScanner';
|
|
8
|
+
export const APP_EVENT_SCANNER_DID_SCAN = 'scannerDidScan';
|
|
9
|
+
export const APP_EVENT_SCANNER_ERROR_CONFIRMED = 'scannerErrorConfirmed';
|
|
10
|
+
export const APP_EVENT_SCANNER_RESULT_PROCESSED = 'scannerResultProcessed';
|
|
11
|
+
let eventsRegistered = false;
|
|
12
|
+
|
|
13
|
+
/**
|
|
2
14
|
* A callback that is invoked whenever the scanner recognized supported content.
|
|
3
15
|
* @callback scanHandler
|
|
4
16
|
* @param {Object} payload The event payload for a successful content scan.
|
|
5
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
6
20
|
* The ScannerManager class. It's intended to simplify the processes that are necessary to
|
|
7
21
|
* programmatically interact with the scanner feature of the app. It provides the possibility to
|
|
8
22
|
* register a handler callback to process the scanned content.
|
|
9
23
|
* @deprecated This is a legacy implementation. Use Scanner instead.
|
|
10
|
-
*/
|
|
24
|
+
*/
|
|
25
|
+
class ScannerManager {
|
|
26
|
+
/**
|
|
11
27
|
* The ScannerManager constructor.
|
|
12
28
|
* @param {Object} options Options for the ScannerManager.
|
|
13
29
|
* @param {boolean} [options.autoClose=true] If set to TRUE, the app scanner will close
|
|
14
30
|
* automatically after a successful scan.
|
|
15
|
-
*/
|
|
31
|
+
*/
|
|
32
|
+
constructor(options = {}) {
|
|
33
|
+
this.autoClose = true;
|
|
34
|
+
if (typeof options.autoClose === 'boolean') {
|
|
35
|
+
this.autoClose = options.autoClose;
|
|
36
|
+
}
|
|
37
|
+
this.scanHandler = () => {};
|
|
38
|
+
this.supportedTypes = [SCANNER_TYPE_BARCODE, SCANNER_TYPE_IMAGE];
|
|
39
|
+
|
|
40
|
+
/**
|
|
16
41
|
* Create references to the app event handler fuctions. They preserve the "this" context of
|
|
17
42
|
* a ScannerManager instance and can be used to register and unregister event listeners.
|
|
18
|
-
*/
|
|
19
|
-
|
|
43
|
+
*/
|
|
44
|
+
this.scannerDidScanListener = this.scannerDidScanListener.bind(this);
|
|
45
|
+
this.closeScanner = this.closeScanner.bind(this);
|
|
46
|
+
if (!eventsRegistered) {
|
|
47
|
+
// Register the necessary events if it not already happened.
|
|
48
|
+
registerEvents([APP_EVENT_CLOSE_SCANNER, APP_EVENT_SCANNER_DID_SCAN, APP_EVENT_SCANNER_ERROR_CONFIRMED]);
|
|
49
|
+
eventsRegistered = true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
20
54
|
* The internal handler for the "scannerDidScan" app event.
|
|
21
55
|
* @private
|
|
22
56
|
* @param {Object} payload The event payload.
|
|
23
|
-
*/
|
|
57
|
+
*/
|
|
58
|
+
scannerDidScanListener(payload) {
|
|
59
|
+
/**
|
|
24
60
|
* Trigger a scannerResultProcessed event to inform the scanner view
|
|
25
61
|
* about the outcome of the scan payload processing.
|
|
26
62
|
* @param {string} requestId The id of the scanner request.
|
|
27
63
|
* @param {boolean} [success=true] Whether the processing was successful or not.
|
|
28
64
|
* @param {Object|null} message An object that contains properties for a dialog popup.
|
|
29
|
-
*/
|
|
65
|
+
*/
|
|
66
|
+
const scannerResultProcessedEvent = (requestId, success = true, message = null) => {
|
|
67
|
+
broadcastEvent({
|
|
68
|
+
event: APP_EVENT_SCANNER_RESULT_PROCESSED,
|
|
69
|
+
parameters: [requestId, success, message]
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
30
74
|
* Wrapper function to enable execution of async code within an EventEmitter callback.
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
75
|
+
*/
|
|
76
|
+
const execScanCallback = async () => {
|
|
77
|
+
const {
|
|
78
|
+
requestId,
|
|
79
|
+
scannerType,
|
|
80
|
+
...data
|
|
81
|
+
} = payload;
|
|
82
|
+
try {
|
|
83
|
+
// Invoke the scan handler. Split the actual scan payload from the meta data.
|
|
84
|
+
await this.scanHandler({
|
|
85
|
+
scannerType,
|
|
86
|
+
requestId,
|
|
87
|
+
data
|
|
88
|
+
});
|
|
89
|
+
// Inform the scanner view about the outcome.
|
|
90
|
+
scannerResultProcessedEvent(requestId);
|
|
91
|
+
if (this.autoClose) {
|
|
92
|
+
// Close the scanner after a successful scan.
|
|
93
|
+
this.closeScanner();
|
|
94
|
+
}
|
|
95
|
+
} catch (error) {
|
|
96
|
+
const {
|
|
97
|
+
message,
|
|
98
|
+
title = null
|
|
99
|
+
} = error;
|
|
100
|
+
// Trigger an error message within the scanner webview when content processing failed.
|
|
101
|
+
scannerResultProcessedEvent(requestId, false, {
|
|
102
|
+
message,
|
|
103
|
+
title
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
execScanCallback();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
35
111
|
* Register a handler to process scanned content. Errors that are thrown inside will be displayed
|
|
36
112
|
* to the user as a notification, so that the webview can stay open for further scan attempts.
|
|
37
113
|
* It's recommended to use the ScanProcessingError for that purpose,
|
|
38
114
|
* since it provides the possibility to set a message and a title for the notification.
|
|
39
115
|
* @param {scanHandler} handler The callback - async functions are supported.
|
|
40
116
|
* @return {ScannerManager}
|
|
41
|
-
*/
|
|
117
|
+
*/
|
|
118
|
+
registerScanHandler(handler) {
|
|
119
|
+
if (typeof handler === 'function') {
|
|
120
|
+
this.scanHandler = handler;
|
|
121
|
+
}
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
42
126
|
* Open the scanner webview. It will instantly start the scanning process when the barcode scanner
|
|
43
127
|
* is active. For the image scanner user interaction is necessary.
|
|
44
128
|
* @param {string} type The initially activated scanner type.
|
|
45
129
|
* @return {ScannerManager}
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
130
|
+
*/
|
|
131
|
+
openScanner(type = SCANNER_TYPE_BARCODE) {
|
|
132
|
+
if (!this.supportedTypes.includes(type)) {
|
|
133
|
+
logger.error(`Scanner opening failed. ${type} is a not supported scanner type.`);
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Add a listener to the closeScanner event to react on a close button press in the scanner.
|
|
138
|
+
event.addCallback(APP_EVENT_CLOSE_SCANNER, this.closeScanner);
|
|
139
|
+
// Add a listener to the scannerDidScan event to process scanner data.
|
|
140
|
+
event.addCallback(APP_EVENT_SCANNER_DID_SCAN, this.scannerDidScanListener);
|
|
141
|
+
// Add a listener to restart the scanner recognition after the user accepted the notification.
|
|
142
|
+
event.addCallback(APP_EVENT_SCANNER_ERROR_CONFIRMED, startScanner);
|
|
143
|
+
// Open the scanner webview.
|
|
144
|
+
openScanner({
|
|
145
|
+
modes: {
|
|
146
|
+
[type]: SCANNER_MODE_ON
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
51
153
|
* Close the scanner webview.
|
|
52
154
|
* @return {ScannerManager}
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
|
|
155
|
+
*/
|
|
156
|
+
closeScanner() {
|
|
157
|
+
// Remove the listeners to avoid further execution by other instances.
|
|
158
|
+
event.removeCallback(APP_EVENT_CLOSE_SCANNER, this.closeScanner);
|
|
159
|
+
event.removeCallback(APP_EVENT_SCANNER_DID_SCAN, this.scannerDidScanListener);
|
|
160
|
+
event.removeCallback(APP_EVENT_SCANNER_ERROR_CONFIRMED, startScanner);
|
|
161
|
+
|
|
162
|
+
// Close the scanner webview.
|
|
163
|
+
closeScanner();
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
export default ScannerManager;
|
|
@@ -1,20 +1,87 @@
|
|
|
1
|
-
|
|
1
|
+
import event from "../Event";
|
|
2
|
+
import { logger } from "../../helpers";
|
|
3
|
+
import logGroup from "../../helpers/logGroup";
|
|
4
|
+
import Request from "../Request";
|
|
5
|
+
import requestBuffer from "../RequestBuffer";
|
|
6
|
+
import Bridge from "../Bridge";
|
|
7
|
+
let localSerial = 0;
|
|
8
|
+
|
|
9
|
+
/**
|
|
2
10
|
* The WebStorageRequest class.
|
|
3
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
class WebStorageRequest extends Request {
|
|
13
|
+
/**
|
|
4
14
|
* @param {string} name The name of the WebStorage entry.
|
|
5
|
-
*/
|
|
15
|
+
*/
|
|
16
|
+
constructor(name = '') {
|
|
17
|
+
super();
|
|
18
|
+
this.name = name;
|
|
19
|
+
this.params = null;
|
|
20
|
+
this.createSerial(this.name);
|
|
21
|
+
this.createEventCallbackName('webStorageResponse');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
6
25
|
* Generates the serial for this web storage request. Since the setWebStorageEntry expects
|
|
7
26
|
* a number value here, the default createSerial method cannot be used by now.
|
|
8
|
-
*/
|
|
9
|
-
|
|
27
|
+
*/
|
|
28
|
+
createSerial() {
|
|
29
|
+
// Increase the local serial and use it for the request
|
|
30
|
+
localSerial += 1;
|
|
31
|
+
this.serial = localSerial;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
10
35
|
* Dispatches the web storage request.
|
|
11
36
|
* @param {Function} resolve The resolve() callback of the request promise.
|
|
12
37
|
* @return {boolean}
|
|
13
|
-
*/
|
|
14
|
-
|
|
38
|
+
*/
|
|
39
|
+
onDispatch(resolve) {
|
|
40
|
+
// Add the request to the buffer.
|
|
41
|
+
requestBuffer.add(this, this.serial);
|
|
42
|
+
const requestCallbackName = this.getEventCallbackName();
|
|
43
|
+
|
|
44
|
+
/**
|
|
15
45
|
* The request event callback for the response call.
|
|
16
46
|
* @param {string} serial The serial that was used to identify the DataRequest callback.
|
|
17
47
|
* @param {number} age The age of the entry.
|
|
18
48
|
* @param {*} value The value for the getWebStorageEntry request.
|
|
19
|
-
*/
|
|
20
|
-
|
|
49
|
+
*/
|
|
50
|
+
const requestCallback = (serial, age, value) => {
|
|
51
|
+
event.removeCallback(requestCallbackName, requestCallback);
|
|
52
|
+
requestBuffer.remove(serial);
|
|
53
|
+
const response = {
|
|
54
|
+
age,
|
|
55
|
+
value
|
|
56
|
+
};
|
|
57
|
+
logGroup(`WebStorageResponse %c${this.name}`, {
|
|
58
|
+
response,
|
|
59
|
+
serial: this.serial
|
|
60
|
+
}, '#f39c12');
|
|
61
|
+
resolve(response);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Apply the event callback.
|
|
65
|
+
event.addCallback(requestCallbackName, requestCallback);
|
|
66
|
+
logGroup(`WebStorageRequest %c${this.name}`, {
|
|
67
|
+
serial: this.serial
|
|
68
|
+
}, '#e67e22');
|
|
69
|
+
const params = {
|
|
70
|
+
name: this.name,
|
|
71
|
+
serial: this.serial
|
|
72
|
+
};
|
|
73
|
+
const command = {
|
|
74
|
+
c: 'getWebStorageEntry',
|
|
75
|
+
p: params
|
|
76
|
+
};
|
|
77
|
+
const bridge = new Bridge();
|
|
78
|
+
try {
|
|
79
|
+
bridge.dispatchCommand(command, '9.0');
|
|
80
|
+
} catch (exception) {
|
|
81
|
+
logger.error(exception);
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export default WebStorageRequest;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import AppCommand from"../classes/AppCommand"
|
|
1
|
+
import AppCommand from "../classes/AppCommand";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Sends an analyticsSetCustomValues command to the app.
|
|
3
5
|
* @param {Object} params The command parameters
|
|
4
6
|
* @param {Array} [params.customDimensions] Array of customDimensions
|
|
5
7
|
* @param {Array} [params.customMetrics] Array of customMetrics
|
|
6
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
export default function analyticsSetCustomValues(params) {
|
|
10
|
+
const command = new AppCommand();
|
|
11
|
+
command.setCommandName('analyticsSetCustomValues').dispatch(params);
|
|
12
|
+
}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import GetAppPermissionsRequest from"../classes/AppPermissionsRequest/GetAppPermissionsRequest";
|
|
1
|
+
import GetAppPermissionsRequest from "../classes/AppPermissionsRequest/GetAppPermissionsRequest";
|
|
2
|
+
import RequestAppPermissionsRequest from "../classes/AppPermissionsRequest/RequestAppPermissionsRequest";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* Gathers the current permissions from the operating system.
|
|
3
6
|
* @param {Array} [permissionIds=[]] The desired permission ids. If kept empty all will be returned.
|
|
4
7
|
* @param {Function} [dispatchMock=null] An optional mock for the dispatch logic of the request.
|
|
5
8
|
* @return {Promise<Array>}
|
|
6
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
export const getAppPermissions = (permissionIds = [], dispatchMock = null) => new GetAppPermissionsRequest().setPermissionIds(permissionIds).setDispatchMock(dispatchMock).dispatch();
|
|
11
|
+
|
|
12
|
+
/**
|
|
7
13
|
* Requests additional permissions from the operating system.
|
|
8
14
|
* @param {Array} permissions The desired permissions. If kept empty all will be returned.
|
|
9
15
|
* @param {Function} [dispatchMock=null] An optional mock for the dispatch logic of the request.
|
|
10
16
|
* @return {Promise<Array>}
|
|
11
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
export const requestAppPermissions = (permissions, dispatchMock = null) => new RequestAppPermissionsRequest().setPermissions(permissions).setDispatchMock(dispatchMock).dispatch();
|
package/commands/brightness.js
CHANGED
|
@@ -1,10 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import AppCommand from "../classes/AppCommand";
|
|
2
|
+
import brightnessRequest from "../classes/BrightnessRequest";
|
|
3
|
+
import { logger } from "../helpers";
|
|
4
|
+
|
|
5
|
+
// The minimum shopgate lib version for the brightness comamnds
|
|
6
|
+
const libVersion = '17.0';
|
|
7
|
+
|
|
8
|
+
/**
|
|
3
9
|
* Sets the screen brightness to the designated value.
|
|
4
10
|
* @param {number} [level=100] Brightness level (from 0 to 100).
|
|
5
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
export function setBrightness(level = 100) {
|
|
13
|
+
new AppCommand().setCommandName('setBrightness').setCommandParams({
|
|
14
|
+
brightness: level
|
|
15
|
+
}).setLibVersion(libVersion).dispatch();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
6
19
|
* Resets the screen brightness to system settings.
|
|
7
|
-
*/
|
|
20
|
+
*/
|
|
21
|
+
export function resetBrightness() {
|
|
22
|
+
new AppCommand().setCommandName('resetBrightness').setLibVersion(libVersion).dispatch();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
8
26
|
* Returns a promise that resolves with current screen brightness (number).
|
|
9
27
|
* @return {Promise}
|
|
10
|
-
*/
|
|
28
|
+
*/
|
|
29
|
+
export async function getCurrentBrightness() {
|
|
30
|
+
let response;
|
|
31
|
+
try {
|
|
32
|
+
response = await brightnessRequest.dispatch();
|
|
33
|
+
} catch (e) {
|
|
34
|
+
logger.error(e);
|
|
35
|
+
throw e;
|
|
36
|
+
}
|
|
37
|
+
return response;
|
|
38
|
+
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import AppCommand from"../classes/AppCommand"
|
|
1
|
+
import AppCommand from "../classes/AppCommand";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Sends broadcastEvent command to the app.
|
|
3
5
|
* @param {Object} params The command parameters.
|
|
4
6
|
* @param {string} params.event The custom event name.
|
|
5
7
|
* @param {Object} params.parameters The custom event parameters.
|
|
6
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
export default function broadcastEvent(params) {
|
|
10
|
+
const command = new AppCommand();
|
|
11
|
+
command.setCommandName('broadcastEvent').dispatch(params);
|
|
12
|
+
}
|
package/commands/cleanTab.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import AppCommand from"../classes/AppCommand"
|
|
1
|
+
import AppCommand from "../classes/AppCommand";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Builds a cleanTab command.
|
|
3
5
|
* @param {Object} params The command parameters.
|
|
4
6
|
* @param {string} params.targetTab Target tab for the page.
|
|
5
7
|
* @return {AppCommand}
|
|
6
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
export const cleanTabCmd = params => new AppCommand().setCommandName('cleanTab').setCommandParams(params);
|
|
10
|
+
|
|
11
|
+
/**
|
|
7
12
|
* Sends a cleanTab command to the app.
|
|
8
13
|
* @param {Object} params The command parameters.
|
|
9
14
|
* @param {string} params.targetTab Target tab for the page.
|
|
10
|
-
*/
|
|
15
|
+
*/
|
|
16
|
+
export default function cleanTab(params) {
|
|
17
|
+
cleanTabCmd(params).dispatch();
|
|
18
|
+
}
|
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
import{cleanTabCmd}
|
|
1
|
+
import { cleanTabCmd } from "./cleanTab";
|
|
2
|
+
import { popTabToRootCmd } from "./popTabToRoot";
|
|
3
|
+
import showTab from "./showTab";
|
|
4
|
+
import performCommandsAfterDelay from "./performCommandsAfterDelay";
|
|
5
|
+
import { PWA_DEFAULT_TAB } from "../constants/Command";
|
|
6
|
+
|
|
7
|
+
/**
|
|
2
8
|
* Send all commands that are needed to close the inAppBrowser.
|
|
3
9
|
* @param {boolean} isAndroid True if we are on a android device.
|
|
4
|
-
*/
|
|
10
|
+
*/
|
|
11
|
+
export default function closeInAppBrowser(isAndroid) {
|
|
12
|
+
const targetTab = {
|
|
13
|
+
targetTab: 'in_app_browser'
|
|
14
|
+
};
|
|
15
|
+
const delayedCommand = (isAndroid ? cleanTabCmd(targetTab) : popTabToRootCmd(targetTab)).buildCommand();
|
|
16
|
+
performCommandsAfterDelay({
|
|
17
|
+
cmds: [delayedCommand],
|
|
18
|
+
delay: 0.4
|
|
19
|
+
});
|
|
20
|
+
showTab({
|
|
21
|
+
targetTab: PWA_DEFAULT_TAB,
|
|
22
|
+
transition: 'slideOutToBottom'
|
|
23
|
+
});
|
|
24
|
+
}
|
package/commands/flushTab.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import AppCommand from"../classes/AppCommand"
|
|
1
|
+
import AppCommand from "../classes/AppCommand";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Sends a flushTab command to the app.
|
|
3
5
|
* @param {Object} params The command parameters.
|
|
4
6
|
* @param {string} params.targetTab Target tab for the page.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
export default function flushTab(params) {
|
|
9
|
+
const command = new AppCommand();
|
|
10
|
+
command.setCommandName('flushTab').dispatch(params);
|
|
11
|
+
}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import WebStorageRequest from"../classes/WebStorageRequest"
|
|
1
|
+
import WebStorageRequest from "../classes/WebStorageRequest";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* With this command you can get the value of a WebStorageRequest, that has been set with
|
|
3
5
|
* setWebStorageEntry.
|
|
4
6
|
* @param {Object} params The command parameters
|
|
5
7
|
* @param {string} params.name The name of the entry, that shall be given back.
|
|
6
8
|
* @return {Promise}
|
|
7
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
export default function getWebStorageEntry(params) {
|
|
11
|
+
const {
|
|
12
|
+
name
|
|
13
|
+
} = params;
|
|
14
|
+
const storage = new WebStorageRequest(name);
|
|
15
|
+
return storage.dispatch();
|
|
16
|
+
}
|
package/commands/hideMenuBar.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import AppCommand from"../classes/AppCommand"
|
|
1
|
+
import AppCommand from "../classes/AppCommand";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Sends hideMenuBar command to the app.
|
|
3
5
|
* @param {Object} [params=null] The command parameters.
|
|
4
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
export default function hideMenuBar(params = null) {
|
|
8
|
+
const command = new AppCommand();
|
|
9
|
+
command.setCommandName('hideMenuBar').dispatch(params);
|
|
10
|
+
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import AppCommand from"../classes/AppCommand"
|
|
1
|
+
import AppCommand from "../classes/AppCommand";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Sends hideNavigationBar command to the app.
|
|
3
5
|
* @param {Object} [params=null] The command parameters.
|
|
4
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
export default function hideNavigationBar(params = null) {
|
|
8
|
+
const command = new AppCommand();
|
|
9
|
+
command.setCommandName('hideNavigationBar').dispatch(params);
|
|
10
|
+
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import AppCommand from"../classes/AppCommand"
|
|
1
|
+
import AppCommand from "../classes/AppCommand";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Sends hideSplashScreen command to the app.
|
|
3
|
-
*/
|
|
5
|
+
*/
|
|
6
|
+
export default function hideSplashScreen() {
|
|
7
|
+
const command = new AppCommand(true, false);
|
|
8
|
+
command.setCommandName('hideSplashScreen').dispatch();
|
|
9
|
+
}
|
package/commands/onload.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import AppCommand from"../classes/AppCommand";
|
|
1
|
+
import AppCommand from "../classes/AppCommand";
|
|
2
|
+
import { hasSGJavaScriptBridge } from "../helpers";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* Sends an onload command if in the native app environment.
|
|
3
|
-
*/
|
|
4
|
-
|
|
6
|
+
*/
|
|
7
|
+
export default function onload() {
|
|
8
|
+
// This command is only needed inside an app environment.
|
|
9
|
+
if (!hasSGJavaScriptBridge()) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const command = new AppCommand(true, false);
|
|
13
|
+
command.setCommandName('onload').dispatch();
|
|
14
|
+
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import AppCommand from"../classes/AppCommand"
|
|
1
|
+
import AppCommand from "../classes/AppCommand";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Sends an openAppSettings command to the app.
|
|
3
|
-
*/
|
|
5
|
+
*/
|
|
6
|
+
export default function openAppSettings() {
|
|
7
|
+
const command = new AppCommand();
|
|
8
|
+
command.setCommandName('openAppSettings').dispatch();
|
|
9
|
+
}
|
package/commands/openPage.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import AppCommand from"../classes/AppCommand"
|
|
1
|
+
import AppCommand from "../classes/AppCommand";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Sends an openPage command to the app.
|
|
3
5
|
* @param {Object} params The command parameters
|
|
4
6
|
* @param {string} params.src The URL which shall be loaded
|
|
@@ -8,4 +10,8 @@ import AppCommand from"../classes/AppCommand";/**
|
|
|
8
10
|
* @param {string} params.targetTab Target tab for the page.
|
|
9
11
|
* @param {string} params.title The title of the opened page
|
|
10
12
|
* @param {Object} params.navigationBarParams Parameters for the navigation bar.
|
|
11
|
-
*/
|
|
13
|
+
*/
|
|
14
|
+
export default function openPage(params) {
|
|
15
|
+
const command = new AppCommand();
|
|
16
|
+
command.setCommandName('openPage').dispatch(params);
|
|
17
|
+
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import AppCommand from"../classes/AppCommand"
|
|
1
|
+
import AppCommand from "../classes/AppCommand";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Sends an openPageExtern command to the app.
|
|
3
5
|
* @param {Object} params The command parameters
|
|
4
6
|
* @param {string} params.src The URL which shall be loaded
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
export default function openPageExtern(params) {
|
|
9
|
+
const command = new AppCommand();
|
|
10
|
+
command.setCommandName('openPageExtern').dispatch(params);
|
|
11
|
+
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import AppCommand from"../classes/AppCommand"
|
|
1
|
+
import AppCommand from "../classes/AppCommand";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Builds a performCommandsAfterDelay command.
|
|
3
5
|
* @param {Object} params The command parameters.
|
|
4
6
|
* @return {AppCommand}
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
export const performCommandsAfterDelayCmd = params => new AppCommand().setCommandName('performCommandsAfterDelay').setCommandParams(params);
|
|
9
|
+
|
|
10
|
+
/**
|
|
6
11
|
* Sends a performCommandsAfterDelay command to the app.
|
|
7
12
|
* @param {Object} params The command parameters.
|
|
8
|
-
*/
|
|
13
|
+
*/
|
|
14
|
+
export default function performCommandsAfterDelay(params) {
|
|
15
|
+
performCommandsAfterDelayCmd(params).dispatch();
|
|
16
|
+
}
|