@applicaster/zapp-react-native-utils 16.0.0-rc.92 → 16.0.0-rc.94
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/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +4 -11
- package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +9 -2
- package/appUtils/playerManager/OverlayObserver/utils.ts +2 -5
- package/configurationUtils/__tests__/modalBlocksParser.test.ts +61 -0
- package/configurationUtils/modalBlocksParser.ts +14 -0
- package/package.json +2 -2
- package/pluginUtils/__tests__/pluginUtils.test.js +32 -0
- package/pluginUtils/index.ts +29 -0
|
@@ -2,8 +2,7 @@ import { BehaviorSubject, Observable } from "rxjs";
|
|
|
2
2
|
import { distinctUntilChanged } from "rxjs/operators";
|
|
3
3
|
import { Player } from "../player";
|
|
4
4
|
import { createLogger, utilsLogger } from "../../../logger";
|
|
5
|
-
import {
|
|
6
|
-
import { findPluginByIdentifier } from "../../../pluginUtils";
|
|
5
|
+
import { getPluginByIdentifier } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
7
6
|
import {
|
|
8
7
|
loadFeedEntry,
|
|
9
8
|
loadFeedAndPrefetchThumbnailImage,
|
|
@@ -237,11 +236,8 @@ export class OverlaysObserver {
|
|
|
237
236
|
|
|
238
237
|
preparePlayNext = async () => {
|
|
239
238
|
try {
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
const playNextPlugin: any = findPluginByIdentifier(
|
|
243
|
-
"QuickBrickPlayNextOverlay",
|
|
244
|
-
plugins
|
|
239
|
+
const playNextPlugin: any = getPluginByIdentifier(
|
|
240
|
+
"QuickBrickPlayNextOverlay"
|
|
245
241
|
);
|
|
246
242
|
|
|
247
243
|
if (!playNextPlugin) {
|
|
@@ -252,10 +248,7 @@ export class OverlaysObserver {
|
|
|
252
248
|
return;
|
|
253
249
|
}
|
|
254
250
|
|
|
255
|
-
const playNextFeedUrl: string = await retrieveFeedUrl(
|
|
256
|
-
this.entry,
|
|
257
|
-
plugins
|
|
258
|
-
);
|
|
251
|
+
const playNextFeedUrl: string = await retrieveFeedUrl(this.entry);
|
|
259
252
|
|
|
260
253
|
if (!playNextFeedUrl || typeof playNextFeedUrl !== "string") {
|
|
261
254
|
log_debug(
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { retrieveFeedUrl, retrievePlayPreviousFeedUrl } from "../utils";
|
|
2
2
|
|
|
3
|
+
// mock for import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
4
|
+
jest.mock("@applicaster/zapp-react-native-redux/AppStore", () => ({
|
|
5
|
+
appStore: {
|
|
6
|
+
get: jest.fn(() => []),
|
|
7
|
+
},
|
|
8
|
+
}));
|
|
9
|
+
|
|
3
10
|
const entryWith = (extensions: Record<string, unknown>): ZappEntry =>
|
|
4
11
|
({ id: "1", type: { value: "video" }, extensions }) as ZappEntry;
|
|
5
12
|
|
|
@@ -7,14 +14,14 @@ describe("playlist feed url accessors", () => {
|
|
|
7
14
|
it("returns the next feed url when present", async () => {
|
|
8
15
|
const entry = entryWith({ play_next_feed_url: "https://feeds/next.json" });
|
|
9
16
|
|
|
10
|
-
await expect(retrieveFeedUrl(entry
|
|
17
|
+
await expect(retrieveFeedUrl(entry)).resolves.toBe(
|
|
11
18
|
"https://feeds/next.json"
|
|
12
19
|
);
|
|
13
20
|
});
|
|
14
21
|
|
|
15
22
|
it("resolves to null for a missing entry", async () => {
|
|
16
23
|
await expect(
|
|
17
|
-
retrieveFeedUrl(undefined as unknown as ZappEntry
|
|
24
|
+
retrieveFeedUrl(undefined as unknown as ZappEntry)
|
|
18
25
|
).resolves.toBeNull();
|
|
19
26
|
});
|
|
20
27
|
|
|
@@ -59,13 +59,10 @@ export const parseTimeToSeconds = (timeStr: string): number => {
|
|
|
59
59
|
* on playerManager, decoupling Queue playback logic entirely from OverlaysObserver (which should
|
|
60
60
|
* strictly focus on recommendation visuals and chapter markers).
|
|
61
61
|
*/
|
|
62
|
-
export const retrieveFeedUrl = async (
|
|
63
|
-
entry: ZappEntry,
|
|
64
|
-
plugins?: ZappPlugin[]
|
|
65
|
-
): Promise<string> => {
|
|
62
|
+
export const retrieveFeedUrl = async (entry: ZappEntry): Promise<string> => {
|
|
66
63
|
if (!entry) return null;
|
|
67
64
|
|
|
68
|
-
const availablePlugins =
|
|
65
|
+
const availablePlugins = appStore.get("plugins");
|
|
69
66
|
|
|
70
67
|
const queuePlugin = findPluginByIdentifier(
|
|
71
68
|
"queue-action",
|
|
@@ -205,4 +205,65 @@ describe("getEmptyModalBlocksStructure", () => {
|
|
|
205
205
|
getEmptyModalBlocksStructure()
|
|
206
206
|
);
|
|
207
207
|
});
|
|
208
|
+
|
|
209
|
+
it("should parse section_header title and action_buttons independently of header", () => {
|
|
210
|
+
const result = parseModalBlocksConfiguration(
|
|
211
|
+
{
|
|
212
|
+
"section_header.title.font_color": "#ABCDEF",
|
|
213
|
+
"section_header.title.font_size": 13,
|
|
214
|
+
"section_header.title.ios.font_family": "SFProText-Bold",
|
|
215
|
+
"section_header.action_buttons.default.background_color":
|
|
216
|
+
"rgba(62, 62, 62, 1)",
|
|
217
|
+
"section_header.action_buttons.focus.background_color":
|
|
218
|
+
"rgba(78, 78, 78, 1)",
|
|
219
|
+
"section_header.action_buttons.default.font_color": "#FFFFFF",
|
|
220
|
+
"section_header.action_buttons.font_size": 14,
|
|
221
|
+
"section_header.action_buttons.border_radius": 16,
|
|
222
|
+
// Theme modal header — must not leak into sectionHeader
|
|
223
|
+
queue_action_style_header_title_default_fontColor: "#111111",
|
|
224
|
+
queue_action_style_header_title_default_fontSize: 22,
|
|
225
|
+
},
|
|
226
|
+
"queue_action"
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
expect(result.sectionHeader.title.default).toEqual(
|
|
230
|
+
expect.objectContaining({
|
|
231
|
+
fontColor: "#ABCDEF",
|
|
232
|
+
fontSize: 13,
|
|
233
|
+
fontFamily: "SFProText-Bold",
|
|
234
|
+
})
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
expect(result.sectionHeader.actionButtons.default).toEqual(
|
|
238
|
+
expect.objectContaining({
|
|
239
|
+
backgroundColor: "rgba(62, 62, 62, 1)",
|
|
240
|
+
fontColor: "#FFFFFF",
|
|
241
|
+
fontSize: 14,
|
|
242
|
+
borderRadius: 16,
|
|
243
|
+
})
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
expect(result.sectionHeader.actionButtons.focused).toEqual(
|
|
247
|
+
expect.objectContaining({
|
|
248
|
+
backgroundColor: "rgba(78, 78, 78, 1)",
|
|
249
|
+
})
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
expect(result.header.title.default).toEqual(
|
|
253
|
+
expect.objectContaining({
|
|
254
|
+
fontColor: "#111111",
|
|
255
|
+
fontSize: 22,
|
|
256
|
+
})
|
|
257
|
+
);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it("should leave sectionHeader empty when keys are absent", () => {
|
|
261
|
+
const result = parseModalBlocksConfiguration(
|
|
262
|
+
{ "item.text_label1.font_color": "#FFFFFF" },
|
|
263
|
+
"playlist-experience"
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
expect(result.sectionHeader.title).toEqual({ default: {} });
|
|
267
|
+
expect(result.sectionHeader.actionButtons).toEqual({ default: {} });
|
|
268
|
+
});
|
|
208
269
|
});
|
|
@@ -7,6 +7,14 @@ export type ModalBlocksConfig = {
|
|
|
7
7
|
closeButton: Record<string, any>;
|
|
8
8
|
actionButtons: Record<string, any>;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Queue Section Header (BB Variant 3) — shared by Next in Queue / Next Up.
|
|
12
|
+
* Separate from Theme modal `header` so top-title styles do not collide.
|
|
13
|
+
*/
|
|
14
|
+
sectionHeader: {
|
|
15
|
+
title: Record<string, any>;
|
|
16
|
+
actionButtons: Record<string, any>;
|
|
17
|
+
};
|
|
10
18
|
action: {
|
|
11
19
|
background: Record<string, any>;
|
|
12
20
|
title: Record<string, any>;
|
|
@@ -60,6 +68,10 @@ export const getEmptyModalBlocksStructure = (): ModalBlocksConfig => {
|
|
|
60
68
|
closeButton: {},
|
|
61
69
|
actionButtons: {},
|
|
62
70
|
},
|
|
71
|
+
sectionHeader: {
|
|
72
|
+
title: {},
|
|
73
|
+
actionButtons: {},
|
|
74
|
+
},
|
|
63
75
|
action: {
|
|
64
76
|
background: {},
|
|
65
77
|
title: {},
|
|
@@ -154,6 +166,8 @@ export const parseModalBlocksConfiguration = (
|
|
|
154
166
|
"action_buttons",
|
|
155
167
|
]);
|
|
156
168
|
|
|
169
|
+
parseBlock("section_header", ["title", "action_buttons"]);
|
|
170
|
+
|
|
157
171
|
parseBlock("action", [
|
|
158
172
|
"background",
|
|
159
173
|
"title",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "16.0.0-rc.
|
|
3
|
+
"version": "16.0.0-rc.94",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "16.0.0-rc.
|
|
30
|
+
"@applicaster/applicaster-types": "16.0.0-rc.94",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
const mockAppStoreGet = jest.fn();
|
|
2
|
+
|
|
3
|
+
jest.mock("@applicaster/zapp-react-native-redux/AppStore", () => ({
|
|
4
|
+
appStore: { get: (key) => mockAppStoreGet(key) },
|
|
5
|
+
}));
|
|
6
|
+
|
|
1
7
|
import * as R from "ramda";
|
|
2
8
|
import * as pluginUtils from "../index";
|
|
3
9
|
|
|
@@ -148,6 +154,32 @@ describe("findPluginByIdentifier", () => {
|
|
|
148
154
|
});
|
|
149
155
|
});
|
|
150
156
|
|
|
157
|
+
describe("getPluginByIdentifier", () => {
|
|
158
|
+
const { getPluginByIdentifier } = pluginUtils;
|
|
159
|
+
|
|
160
|
+
const plugins = {
|
|
161
|
+
foo: pluginMock("foo", "foo", "some_plugin_type"),
|
|
162
|
+
bar: pluginMock("foo", "bar", "some_plugin_type"),
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
beforeEach(() => {
|
|
166
|
+
mockAppStoreGet.mockReset();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("reads plugins from appStore and returns the matching plugin", () => {
|
|
170
|
+
mockAppStoreGet.mockReturnValue(plugins);
|
|
171
|
+
|
|
172
|
+
expect(getPluginByIdentifier("foo")).toEqual(plugins.foo);
|
|
173
|
+
expect(mockAppStoreGet).toHaveBeenCalledWith("plugins");
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("returns undefined when the plugin is not found", () => {
|
|
177
|
+
mockAppStoreGet.mockReturnValue(plugins);
|
|
178
|
+
|
|
179
|
+
expect(getPluginByIdentifier("do_not_exist")).toBeUndefined();
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
151
183
|
describe("findPluginByType", () => {
|
|
152
184
|
const { findPluginByType } = pluginUtils;
|
|
153
185
|
|
package/pluginUtils/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
|
+
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
2
3
|
import { toCamelCase, toPascalCase } from "../stringUtils";
|
|
3
4
|
|
|
4
5
|
import { getNavigationType } from "../navigationUtils";
|
|
@@ -97,6 +98,34 @@ export function findPluginByIdentifier(
|
|
|
97
98
|
return plugin;
|
|
98
99
|
}
|
|
99
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Like findPluginByIdentifier, but reads the current plugins list from appStore.
|
|
103
|
+
* Convenience for non-render / hook code that doesn't already have `plugins` in hand.
|
|
104
|
+
* @param identifier of the plugin to look for
|
|
105
|
+
* @param doNotWarn if set to true, will not log a warning if plugin is not found
|
|
106
|
+
* @return whole plugin if found, undefined otherwise
|
|
107
|
+
*/
|
|
108
|
+
export function getPluginByIdentifier(
|
|
109
|
+
identifier: string,
|
|
110
|
+
doNotWarn: boolean = false
|
|
111
|
+
): (QuickBrickPlugin | ZappPlugin | Plugin) | undefined {
|
|
112
|
+
try {
|
|
113
|
+
const plugins = appStore.get("plugins") ?? {};
|
|
114
|
+
|
|
115
|
+
return findPluginByIdentifier(identifier, plugins, doNotWarn);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (!doNotWarn) {
|
|
118
|
+
pluginUtilsLogger.warning({
|
|
119
|
+
message:
|
|
120
|
+
"Could not read plugins from appStore while resolving plugin by identifier",
|
|
121
|
+
data: { identifier, error },
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
100
129
|
const pluginTypeForItemTypeMap = {
|
|
101
130
|
playable: "player",
|
|
102
131
|
};
|