@applicaster/zapp-react-dom-app 13.0.0-alpha.2569962250 → 13.0.0-alpha.2614386581
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.
|
@@ -31,7 +31,10 @@ import {
|
|
|
31
31
|
import { PlayerContentContext } from "@applicaster/zapp-react-dom-ui-components/Contexts";
|
|
32
32
|
|
|
33
33
|
import { withNavigator } from "@applicaster/zapp-react-native-ui-components/Decorators/Navigator";
|
|
34
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
getXray,
|
|
36
|
+
createLogger,
|
|
37
|
+
} from "@applicaster/zapp-react-native-utils/logger";
|
|
35
38
|
|
|
36
39
|
import {
|
|
37
40
|
confirmationDialogStore,
|
|
@@ -51,6 +54,11 @@ import { KeyInputHandler } from "@applicaster/zapp-react-native-utils/appUtils/k
|
|
|
51
54
|
const { withXray } = getXray();
|
|
52
55
|
const globalAny: any = global;
|
|
53
56
|
|
|
57
|
+
const { log_debug, log_warning } = createLogger({
|
|
58
|
+
category: "InteractionManager",
|
|
59
|
+
subsystem: "zapp-react-dom-app",
|
|
60
|
+
});
|
|
61
|
+
|
|
54
62
|
const shouldUseOnScreenKeyboard = () =>
|
|
55
63
|
isVizioPlatform() || window.applicaster.useOnScreenKeyboard;
|
|
56
64
|
|
|
@@ -140,13 +148,16 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
140
148
|
this.onConfirmDialogOpen = this.onConfirmDialogOpen.bind(this);
|
|
141
149
|
this.onConfirmDialogClose = this.onConfirmDialogClose.bind(this);
|
|
142
150
|
|
|
151
|
+
this.handlePhysicalKeyboardDismiss =
|
|
152
|
+
this.handlePhysicalKeyboardDismiss.bind(this);
|
|
153
|
+
|
|
143
154
|
this.confirmDialog.setConfirmAction(this.performExit);
|
|
144
155
|
this.confirmDialog.setCancelAction(this.onConfirmDialogClose);
|
|
145
156
|
this.longPressDetector = new KeyboardLongPressManager();
|
|
146
157
|
}
|
|
147
158
|
|
|
148
159
|
componentDidMount() {
|
|
149
|
-
window.addEventListener("keydown", this.onKeyDownListener);
|
|
160
|
+
window.addEventListener("keydown", this.onKeyDownListener, true);
|
|
150
161
|
window.addEventListener("keyup", this.onKeyUp);
|
|
151
162
|
window.addEventListener("mousemove", this.onMouseMoveListener);
|
|
152
163
|
|
|
@@ -181,6 +192,11 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
181
192
|
"onLongPressRelease",
|
|
182
193
|
this.handleLongPressRelease.bind(this)
|
|
183
194
|
);
|
|
195
|
+
|
|
196
|
+
document.addEventListener(
|
|
197
|
+
"keyboardDismissedByPhysicalKeypress",
|
|
198
|
+
this.handlePhysicalKeyboardDismiss
|
|
199
|
+
);
|
|
184
200
|
}
|
|
185
201
|
|
|
186
202
|
componentWillUnmount() {
|
|
@@ -209,6 +225,11 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
209
225
|
"onLongPressRelease",
|
|
210
226
|
this.handleLongPressRelease
|
|
211
227
|
);
|
|
228
|
+
|
|
229
|
+
document.removeEventListener(
|
|
230
|
+
"keyboardDismissedByPhysicalKeypress",
|
|
231
|
+
this.handlePhysicalKeyboardDismiss
|
|
232
|
+
);
|
|
212
233
|
}
|
|
213
234
|
|
|
214
235
|
performExit() {
|
|
@@ -270,8 +291,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
270
291
|
this.handleWebOsBack();
|
|
271
292
|
}
|
|
272
293
|
} catch (e) {
|
|
273
|
-
|
|
274
|
-
console.warn("Failed to execute platformBack", e);
|
|
294
|
+
log_warning("Failed to execute platformBack", e);
|
|
275
295
|
}
|
|
276
296
|
}
|
|
277
297
|
|
|
@@ -365,23 +385,103 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
365
385
|
}
|
|
366
386
|
}
|
|
367
387
|
|
|
368
|
-
|
|
388
|
+
/**
|
|
389
|
+
When pressing escape or the Native "Back" button:
|
|
390
|
+
if on the transport controls: we show the player
|
|
391
|
+
if on the player : we show the UI
|
|
392
|
+
if on the UI : we exit the app
|
|
393
|
+
note: backspace affects the keyboard input, so it behaves differently
|
|
394
|
+
*/
|
|
395
|
+
onBackPress(event) {
|
|
369
396
|
const { displayState, setDisplayState, navigator } = this.props;
|
|
397
|
+
const { isDialogVisible } = confirmationDialogStore.getState();
|
|
370
398
|
const { isKeyboardVisible } = this.state;
|
|
371
399
|
|
|
372
|
-
|
|
400
|
+
log_debug("onBackPress", {
|
|
401
|
+
eventCode: event.code,
|
|
402
|
+
displayState,
|
|
403
|
+
isDialogVisible,
|
|
404
|
+
isKeyboardVisible,
|
|
405
|
+
});
|
|
373
406
|
|
|
374
407
|
if (isKeyboardVisible && shouldUseOnScreenKeyboard()) {
|
|
375
|
-
|
|
376
|
-
this.handleKeyboardDismiss();
|
|
377
|
-
}
|
|
378
|
-
|
|
408
|
+
this.handleKeyboardDismiss();
|
|
379
409
|
event.preventDefault();
|
|
380
410
|
event.stopPropagation();
|
|
381
411
|
|
|
382
412
|
return;
|
|
383
413
|
}
|
|
384
414
|
|
|
415
|
+
switch (displayState) {
|
|
416
|
+
case DISPLAY_STATES.DEFAULT:
|
|
417
|
+
case DISPLAY_STATES.PLAYER:
|
|
418
|
+
if (isDialogVisible) {
|
|
419
|
+
this.onConfirmDialogClose();
|
|
420
|
+
} else if (navigator.canGoBack()) {
|
|
421
|
+
navigator.goBack();
|
|
422
|
+
} else if (this.isHomeScreen()) {
|
|
423
|
+
this.platformBack();
|
|
424
|
+
} else if (navigator.currentRoute.includes("hook")) {
|
|
425
|
+
// If code reaches this block navigator cant go back, it is not home,
|
|
426
|
+
// and this is a login plugin that was pushed on top of the home
|
|
427
|
+
// Treat it like a home screen and run platformBack()
|
|
428
|
+
const entryData = navigator?.data?.entry;
|
|
429
|
+
const isHookInHomescreen = entryData?.payload?.home;
|
|
430
|
+
|
|
431
|
+
const isHookFlowBlocker =
|
|
432
|
+
typeof entryData?.hookPlugin?.module?.isFlowBlocker === "function"
|
|
433
|
+
? entryData?.hookPlugin?.module?.isFlowBlocker()
|
|
434
|
+
: entryData?.hookPlugin?.module?.isFlowBlocker;
|
|
435
|
+
|
|
436
|
+
if (isHookInHomescreen && isHookFlowBlocker) {
|
|
437
|
+
this.platformBack();
|
|
438
|
+
} else {
|
|
439
|
+
navigator.goBack(false, true);
|
|
440
|
+
}
|
|
441
|
+
} else {
|
|
442
|
+
this.goToHome();
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
break;
|
|
446
|
+
case DISPLAY_STATES.HUD:
|
|
447
|
+
// IF transport controls are open, close them instead of closing player
|
|
448
|
+
setDisplayState(DISPLAY_STATES.PLAYER);
|
|
449
|
+
break;
|
|
450
|
+
default:
|
|
451
|
+
setDisplayState(DISPLAY_STATES.PLAYER);
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
onBackspacePress(event) {
|
|
457
|
+
const isInputFocused =
|
|
458
|
+
document.activeElement instanceof HTMLInputElement ||
|
|
459
|
+
document.activeElement instanceof HTMLTextAreaElement;
|
|
460
|
+
|
|
461
|
+
// Don't handle backspace if input is focused
|
|
462
|
+
if (isInputFocused) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
this.onBackPress(event);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
onKeyDown(event) {
|
|
470
|
+
const { displayState, setDisplayState, navigator } = this.props;
|
|
471
|
+
const { isDialogVisible } = confirmationDialogStore.getState();
|
|
472
|
+
|
|
473
|
+
if (keyCode(event).matches("Backspace")) {
|
|
474
|
+
this.onBackspacePress(event);
|
|
475
|
+
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
if (keyCode(event).matchesAny(KEYS.Back, KEYS.Escape, KEYS.EscapeDevice)) {
|
|
480
|
+
this.onBackPress(event);
|
|
481
|
+
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
|
|
385
485
|
if (this.keySupportsLongPress(event)) {
|
|
386
486
|
this.longPressDetector.monitorKeyPress(event.code, event);
|
|
387
487
|
}
|
|
@@ -447,68 +547,6 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
447
547
|
}
|
|
448
548
|
}
|
|
449
549
|
|
|
450
|
-
/**
|
|
451
|
-
When pressing backspace or the Native "Back" button:
|
|
452
|
-
if on the transport controls: we show the player
|
|
453
|
-
if on the player : we show the UI
|
|
454
|
-
if on the UI : we exit the app
|
|
455
|
-
*/
|
|
456
|
-
|
|
457
|
-
// if (keyCode(event).matchesAny(KEYS.Escape)) {
|
|
458
|
-
// console.log("debug_2", "ESCAPE");
|
|
459
|
-
|
|
460
|
-
// confirmationDialogStore.getState().toggleDialog();
|
|
461
|
-
// }
|
|
462
|
-
|
|
463
|
-
if (
|
|
464
|
-
keyCode(event).matchesAny(
|
|
465
|
-
KEYS.Back,
|
|
466
|
-
KEYS.Escape,
|
|
467
|
-
KEYS.EscapeDevice,
|
|
468
|
-
KEYS.Backspace
|
|
469
|
-
)
|
|
470
|
-
) {
|
|
471
|
-
switch (displayState) {
|
|
472
|
-
case DISPLAY_STATES.DEFAULT:
|
|
473
|
-
case DISPLAY_STATES.PLAYER:
|
|
474
|
-
if (isDialogVisible) {
|
|
475
|
-
this.onConfirmDialogClose();
|
|
476
|
-
} else if (navigator.canGoBack()) {
|
|
477
|
-
navigator.goBack();
|
|
478
|
-
} else if (this.isHomeScreen()) {
|
|
479
|
-
this.platformBack();
|
|
480
|
-
} else if (navigator.currentRoute.includes("hook")) {
|
|
481
|
-
// If code reaches this block navigator cant go back, it is not home,
|
|
482
|
-
// and this is a login plugin that was pushed on top of the home
|
|
483
|
-
// Treat it like a home screen and run platformBack()
|
|
484
|
-
const entryData = navigator?.data?.entry;
|
|
485
|
-
const isHookInHomescreen = entryData?.payload?.home;
|
|
486
|
-
|
|
487
|
-
const isHookFlowBlocker =
|
|
488
|
-
typeof entryData?.hookPlugin?.module?.isFlowBlocker === "function"
|
|
489
|
-
? entryData?.hookPlugin?.module?.isFlowBlocker()
|
|
490
|
-
: entryData?.hookPlugin?.module?.isFlowBlocker;
|
|
491
|
-
|
|
492
|
-
if (isHookInHomescreen && isHookFlowBlocker) {
|
|
493
|
-
this.platformBack();
|
|
494
|
-
} else {
|
|
495
|
-
navigator.goBack(false, true);
|
|
496
|
-
}
|
|
497
|
-
} else {
|
|
498
|
-
this.goToHome();
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
break;
|
|
502
|
-
case DISPLAY_STATES.HUD:
|
|
503
|
-
// IF transport controls are open, close them instead of closing player
|
|
504
|
-
setDisplayState(DISPLAY_STATES.PLAYER);
|
|
505
|
-
break;
|
|
506
|
-
default:
|
|
507
|
-
setDisplayState(DISPLAY_STATES.PLAYER);
|
|
508
|
-
break;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
550
|
if (
|
|
513
551
|
keyCode(event).matches(KEYS.Enter) ||
|
|
514
552
|
(__DEV__ && keyCode(event).matches(KEYS.X))
|
|
@@ -516,6 +554,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
516
554
|
if (displayState === DISPLAY_STATES.PLAYER) {
|
|
517
555
|
setDisplayState(DISPLAY_STATES.HUD);
|
|
518
556
|
} else {
|
|
557
|
+
focusManager.pressIn();
|
|
519
558
|
focusManager.press();
|
|
520
559
|
}
|
|
521
560
|
|
|
@@ -532,10 +571,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
532
571
|
this.platformBack();
|
|
533
572
|
}
|
|
534
573
|
|
|
535
|
-
if (
|
|
536
|
-
keyCode(event).matchesAny(...ARROW_KEYS) &&
|
|
537
|
-
!this.state.isKeyboardVisible
|
|
538
|
-
) {
|
|
574
|
+
if (keyCode(event).matchesAny(...ARROW_KEYS)) {
|
|
539
575
|
if (displayState === DISPLAY_STATES.PLAYER) {
|
|
540
576
|
setDisplayState(DISPLAY_STATES.HUD);
|
|
541
577
|
}
|
|
@@ -548,11 +584,11 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
548
584
|
focusManager.moveFocus(direction);
|
|
549
585
|
}
|
|
550
586
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
587
|
+
if (!isDialogVisible) {
|
|
588
|
+
// run focus recovery on user interaction attempt
|
|
589
|
+
// probably we failed to set initial focus for some reason
|
|
590
|
+
focusManager.recoverFocus();
|
|
591
|
+
}
|
|
556
592
|
|
|
557
593
|
if (
|
|
558
594
|
displayState === DISPLAY_STATES.PLAYER ||
|
|
@@ -658,7 +694,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
658
694
|
}
|
|
659
695
|
}
|
|
660
696
|
|
|
661
|
-
handleKeyboardDismiss
|
|
697
|
+
handleKeyboardDismiss() {
|
|
662
698
|
this.isDismissing = true;
|
|
663
699
|
|
|
664
700
|
this.setState(
|
|
@@ -669,9 +705,10 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
669
705
|
},
|
|
670
706
|
() => {
|
|
671
707
|
this.isDismissing = false;
|
|
708
|
+
focusManager.recoverFocus();
|
|
672
709
|
}
|
|
673
710
|
);
|
|
674
|
-
}
|
|
711
|
+
}
|
|
675
712
|
|
|
676
713
|
handleKeyboardInput = (value: string) => {
|
|
677
714
|
const { activeInputRef } = this.state;
|
|
@@ -767,6 +804,35 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
767
804
|
].includes(event.code);
|
|
768
805
|
}
|
|
769
806
|
|
|
807
|
+
handlePhysicalKeyboardDismiss(event: CustomEvent) {
|
|
808
|
+
const { value, position, inputElement } = event.detail;
|
|
809
|
+
|
|
810
|
+
this.isDismissing = true;
|
|
811
|
+
|
|
812
|
+
this.setState(
|
|
813
|
+
{
|
|
814
|
+
isKeyboardVisible: false,
|
|
815
|
+
keyboardInput: "",
|
|
816
|
+
activeInputRef: null,
|
|
817
|
+
},
|
|
818
|
+
() => {
|
|
819
|
+
if (inputElement) {
|
|
820
|
+
inputElement.value = value;
|
|
821
|
+
inputElement.focus();
|
|
822
|
+
inputElement.setSelectionRange(position, position);
|
|
823
|
+
|
|
824
|
+
const keyboardEvent = new CustomEvent("keyboardUpdate", {
|
|
825
|
+
detail: { value },
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
document.dispatchEvent(keyboardEvent);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
this.isDismissing = false;
|
|
832
|
+
}
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
|
|
770
836
|
render() {
|
|
771
837
|
return (
|
|
772
838
|
(shouldUseOnScreenKeyboard() && this.state.isKeyboardVisible && (
|
package/App/Loader/loadLocale.js
CHANGED
|
@@ -3,11 +3,6 @@ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils"
|
|
|
3
3
|
import { QuickBrickCommunicationModule } from "../../Polyfills/QuickBrickCommunicationModule";
|
|
4
4
|
import { loadLocaleImpl, getLanguageCode } from "./utils";
|
|
5
5
|
|
|
6
|
-
type Locale = {
|
|
7
|
-
language: string;
|
|
8
|
-
country: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
6
|
async function getBrowserLocale() {
|
|
12
7
|
return navigator.language;
|
|
13
8
|
}
|
|
@@ -19,7 +14,7 @@ async function getSamsungLocale() {
|
|
|
19
14
|
}
|
|
20
15
|
|
|
21
16
|
try {
|
|
22
|
-
tizen.systeminfo.getPropertyValue("LOCALE", (locale
|
|
17
|
+
tizen.systeminfo.getPropertyValue("LOCALE", (locale) => {
|
|
23
18
|
resolve(locale.language);
|
|
24
19
|
});
|
|
25
20
|
} catch (e) {
|
|
@@ -31,31 +31,3 @@ exports[`storageObject when the requested storage exists getAllItems returns all
|
|
|
31
31
|
"otherKey": "otherValue",
|
|
32
32
|
}
|
|
33
33
|
`;
|
|
34
|
-
|
|
35
|
-
exports[`storageObject when the requested storage exists getItem gets properties from the storage 1`] = `"bar"`;
|
|
36
|
-
|
|
37
|
-
exports[`storageObject when the requested storage exists getItem gets properties from the storage 2`] = `"bar"`;
|
|
38
|
-
|
|
39
|
-
exports[`storageObject when the requested storage exists getItem gets properties from the storage 3`] = `"bar"`;
|
|
40
|
-
|
|
41
|
-
exports[`storageObject when the requested storage exists getItem gets properties from the storage 4`] = `"bar"`;
|
|
42
|
-
|
|
43
|
-
exports[`storageObject when the requested storage exists getItem gets properties from the storage with a namespace 1`] = `"baz"`;
|
|
44
|
-
|
|
45
|
-
exports[`storageObject when the requested storage exists getItem gets properties from the storage with a namespace 2`] = `"baz"`;
|
|
46
|
-
|
|
47
|
-
exports[`storageObject when the requested storage exists getItem rejects if the property cannot be retrieved 1`] = `[Error: Could not retrieve item applicaster.v2_::_fail_key]`;
|
|
48
|
-
|
|
49
|
-
exports[`storageObject when the requested storage exists getItem rejects if the property cannot be retrieved 2`] = `[Error: Could not retrieve item applicaster.v2_::_fail_key]`;
|
|
50
|
-
|
|
51
|
-
exports[`storageObject when the requested storage exists removeItem removes an item 1`] = `true`;
|
|
52
|
-
|
|
53
|
-
exports[`storageObject when the requested storage exists removeItem removes an item 2`] = `true`;
|
|
54
|
-
|
|
55
|
-
exports[`storageObject when the requested storage exists removeItem removes an item 3`] = `true`;
|
|
56
|
-
|
|
57
|
-
exports[`storageObject when the requested storage exists removeItem removes an item 4`] = `true`;
|
|
58
|
-
|
|
59
|
-
exports[`storageObject when the requested storage exists setItem will reject a promise if it the setting of the data fails 1`] = `[Error: Could not set item applicaster.v2_::_fail_key]`;
|
|
60
|
-
|
|
61
|
-
exports[`storageObject when the requested storage exists setItem will reject a promise if it the setting of the data fails 2`] = `[Error: Could not set item applicaster.v2_::_fail_key]`;
|
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
applyNamespaceToKeyName,
|
|
5
5
|
STORAGE_TYPES,
|
|
6
6
|
DEFAULT_NAMESPACE,
|
|
7
|
-
} from "../
|
|
7
|
+
} from "../";
|
|
8
|
+
|
|
8
9
|
import { StorageMock } from "./StorageMocks";
|
|
9
10
|
|
|
10
11
|
import * as functionUtils from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
@@ -26,14 +27,7 @@ function clearStorage() {
|
|
|
26
27
|
R.forEach((storage) => global.window[storage].clear(), STORAGE_TYPES);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
await Promise.all(
|
|
31
|
-
R.map((storage) => {
|
|
32
|
-
const Storage = getStorageModule(storage);
|
|
33
|
-
expectations(Storage);
|
|
34
|
-
}, STORAGE_TYPES)
|
|
35
|
-
);
|
|
36
|
-
}
|
|
30
|
+
const storages = R.map((storage) => getStorageModule(storage), STORAGE_TYPES);
|
|
37
31
|
|
|
38
32
|
describe("storageObject", () => {
|
|
39
33
|
beforeEach(resetMocks);
|
|
@@ -48,143 +42,119 @@ describe("storageObject", () => {
|
|
|
48
42
|
|
|
49
43
|
beforeEach(clearStorage);
|
|
50
44
|
|
|
51
|
-
it("returns an object with 3 methods", () => {
|
|
52
|
-
expect.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
expect(Storage).toHaveProperty("setItem");
|
|
56
|
-
expect(Storage).toHaveProperty("getItem");
|
|
57
|
-
expect(Storage).toHaveProperty("getAllItems");
|
|
58
|
-
});
|
|
45
|
+
it.each(storages)("returns an object with 3 methods", (storage) => {
|
|
46
|
+
expect(storage).toHaveProperty("setItem");
|
|
47
|
+
expect(storage).toHaveProperty("getItem");
|
|
48
|
+
expect(storage).toHaveProperty("getAllItems");
|
|
59
49
|
});
|
|
60
50
|
|
|
61
51
|
describe("setItem", () => {
|
|
62
52
|
beforeEach(clearStorage);
|
|
63
53
|
|
|
64
|
-
it("sets a property in the storage", async () => {
|
|
65
|
-
|
|
54
|
+
it.each(storages)("sets a property in the storage", async (storage) => {
|
|
55
|
+
const result = await storage.setItem(key, value, null);
|
|
66
56
|
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
const keyWithDefaultNameSpace = applyNamespaceToKeyName(
|
|
58
|
+
key,
|
|
59
|
+
DEFAULT_NAMESPACE
|
|
60
|
+
);
|
|
69
61
|
|
|
70
|
-
|
|
71
|
-
key,
|
|
72
|
-
DEFAULT_NAMESPACE
|
|
73
|
-
);
|
|
62
|
+
expect(result).toBe(true);
|
|
74
63
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
64
|
+
expect(storage.getItem(keyWithDefaultNameSpace)).resolves.toEqual(
|
|
65
|
+
value
|
|
66
|
+
);
|
|
78
67
|
});
|
|
79
68
|
|
|
80
|
-
it(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const result = await Storage.setItem(key, namespaceValue, namespace);
|
|
69
|
+
it.each(storages)(
|
|
70
|
+
"sets a property in the storage with a namespace",
|
|
71
|
+
async (storage) => {
|
|
72
|
+
const result = await storage.setItem(key, namespaceValue, namespace);
|
|
85
73
|
|
|
86
74
|
expect(result).toBe(true);
|
|
87
|
-
expect(Storage[keyName]).toEqual(namespaceValue);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
75
|
|
|
91
|
-
|
|
92
|
-
|
|
76
|
+
expect(storage.getItem(keyName)).resolves.toEqual(namespaceValue);
|
|
77
|
+
}
|
|
78
|
+
);
|
|
93
79
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
).rejects.
|
|
98
|
-
|
|
99
|
-
|
|
80
|
+
it.each(storages)(
|
|
81
|
+
"will reject a promise if it the setting of the data fails",
|
|
82
|
+
async (storage) => {
|
|
83
|
+
await expect(storage.setItem(failKey, value)).rejects.toThrow(
|
|
84
|
+
"Could not set item applicaster.v2_::_fail_key"
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
);
|
|
100
88
|
});
|
|
101
89
|
|
|
102
90
|
describe("getItem", () => {
|
|
103
91
|
beforeEach(async () => {
|
|
104
92
|
clearStorage();
|
|
105
93
|
|
|
106
|
-
|
|
94
|
+
storages.forEach((Storage) => {
|
|
107
95
|
Storage.setItem(key, value, null);
|
|
108
96
|
Storage.setItem(key, namespaceValue, namespace);
|
|
109
97
|
});
|
|
110
98
|
});
|
|
111
99
|
|
|
112
|
-
it("gets properties from the storage", async () => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
await expect(Storage.getItem(key)).resolves.toMatchSnapshot();
|
|
118
|
-
await expect(Storage.getItem(key, null)).resolves.toEqual(value);
|
|
119
|
-
await expect(Storage.getItem(key, null)).resolves.toMatchSnapshot();
|
|
120
|
-
});
|
|
100
|
+
it.each(storages)("gets properties from the storage", async (storage) => {
|
|
101
|
+
const result = await storage.getItem(key);
|
|
102
|
+
const resultWithNull = await storage.getItem(key, null);
|
|
103
|
+
expect(result).toEqual(value);
|
|
104
|
+
expect(resultWithNull).toEqual(value);
|
|
121
105
|
});
|
|
122
106
|
|
|
123
|
-
it(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
namespaceValue
|
|
107
|
+
it.each(storages)(
|
|
108
|
+
"gets properties from the storage with a namespace",
|
|
109
|
+
(storage) => {
|
|
110
|
+
expect(storage.getItem(key, namespace)).resolves.toEqual(
|
|
111
|
+
"namespaceValue"
|
|
129
112
|
);
|
|
113
|
+
}
|
|
114
|
+
);
|
|
130
115
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
await testStorage(async (Storage) => {
|
|
141
|
-
await expect(Storage.getItem(failKey)).rejects.toMatchSnapshot();
|
|
142
|
-
});
|
|
143
|
-
});
|
|
116
|
+
it.each(storages)(
|
|
117
|
+
"rejects if the property cannot be retrieved",
|
|
118
|
+
async (storage) => {
|
|
119
|
+
await expect(storage.getItem(failKey)).rejects.toThrow(
|
|
120
|
+
"Could not retrieve item applicaster.v2_::_fail_key"
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
);
|
|
144
124
|
});
|
|
145
125
|
|
|
146
126
|
describe("getAllItems", () => {
|
|
147
127
|
beforeEach(async () => {
|
|
148
128
|
clearStorage();
|
|
149
129
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
130
|
+
storages.forEach((Storage) => {
|
|
131
|
+
Storage.setItem(key, value);
|
|
132
|
+
Storage.setItem(key, namespaceValue, namespace);
|
|
133
|
+
Storage.setItem("otherKey", "otherValue");
|
|
134
|
+
Storage.setItem("otherKey", "otherValue", namespace);
|
|
155
135
|
});
|
|
156
136
|
});
|
|
157
137
|
|
|
158
|
-
it("returns all keys", async () => {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
await testStorage(async (Storage) => {
|
|
162
|
-
await expect(Storage.getAllItems()).resolves.toMatchSnapshot();
|
|
163
|
-
});
|
|
138
|
+
it.each(storages)("returns all keys", async (Storage) => {
|
|
139
|
+
const res = await Storage.getAllItems();
|
|
140
|
+
expect(res).toMatchSnapshot();
|
|
164
141
|
});
|
|
165
142
|
|
|
166
|
-
it(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
await testStorage(async (Storage) => {
|
|
143
|
+
it.each(storages)(
|
|
144
|
+
"returns all keys in the namespace if provided",
|
|
145
|
+
async (Storage) => {
|
|
170
146
|
await expect(
|
|
171
147
|
Storage.getAllItems(namespace)
|
|
172
148
|
).resolves.toMatchSnapshot();
|
|
173
|
-
}
|
|
174
|
-
|
|
149
|
+
}
|
|
150
|
+
);
|
|
175
151
|
});
|
|
176
152
|
|
|
177
153
|
describe("removeItem", () => {
|
|
178
|
-
it("removes an item", async () => {
|
|
179
|
-
expect.
|
|
180
|
-
|
|
181
|
-
await testStorage(async (Storage) => {
|
|
182
|
-
await expect(Storage.removeItem(key)).resolves.toMatchSnapshot();
|
|
154
|
+
it.each(storages)("removes an item", async (Storage) => {
|
|
155
|
+
await expect(Storage.removeItem(key)).resolves.toBeTruthy();
|
|
183
156
|
|
|
184
|
-
|
|
185
|
-
Storage.removeItem(key, namespace)
|
|
186
|
-
).resolves.toMatchSnapshot();
|
|
187
|
-
});
|
|
157
|
+
await expect(Storage.removeItem(key, namespace)).resolves.toBeTruthy();
|
|
188
158
|
});
|
|
189
159
|
});
|
|
190
160
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-dom-app",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.2614386581",
|
|
4
4
|
"description": "Zapp App Component for Applicaster's Quick Brick React Native App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/applicaster/zapp-react-dom-app#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@applicaster/zapp-react-dom-ui-components": "13.0.0-alpha.
|
|
26
|
-
"@applicaster/zapp-react-native-bridge": "13.0.0-alpha.
|
|
27
|
-
"@applicaster/zapp-react-native-redux": "13.0.0-alpha.
|
|
28
|
-
"@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.
|
|
29
|
-
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.
|
|
25
|
+
"@applicaster/zapp-react-dom-ui-components": "13.0.0-alpha.2614386581",
|
|
26
|
+
"@applicaster/zapp-react-native-bridge": "13.0.0-alpha.2614386581",
|
|
27
|
+
"@applicaster/zapp-react-native-redux": "13.0.0-alpha.2614386581",
|
|
28
|
+
"@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.2614386581",
|
|
29
|
+
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.2614386581",
|
|
30
30
|
"abortcontroller-polyfill": "^1.7.5",
|
|
31
31
|
"react-router-dom": "^5.1.2",
|
|
32
32
|
"typeface-montserrat": "^0.0.54",
|
|
@@ -37,15 +37,14 @@
|
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@applicaster/zapp-pipes-v2-client": "*",
|
|
39
39
|
"@react-native-community/netinfo": "*",
|
|
40
|
-
"@types/node": "*",
|
|
41
40
|
"core-js": "3.29.1",
|
|
42
41
|
"immer": "*",
|
|
43
|
-
"react": "
|
|
44
|
-
"react-dom": "
|
|
42
|
+
"react": "*",
|
|
43
|
+
"react-dom": "*",
|
|
45
44
|
"react-native": "*",
|
|
46
45
|
"react-native-safe-area-context": "*",
|
|
47
46
|
"react-native-svg": "*",
|
|
48
|
-
"react-native-web": "
|
|
47
|
+
"react-native-web": "*",
|
|
49
48
|
"uglify-js": "*",
|
|
50
49
|
"validate-color": "*",
|
|
51
50
|
"zustand": "*"
|