@24i/smartapps-bigscreen-rnv-build-engine 0.18.2-alpha.2840 → 0.18.2-alpha.2845
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/README.md +2 -0
- package/dist/src/__tests__/resolvers/resolveBuildFileExtension.spec.js +6 -2
- package/dist/src/constants/buildProductionPackages.js +1 -0
- package/dist/src/constants/delopyLivePlatforms.js +1 -0
- package/dist/src/constants/platforms.js +1 -0
- package/dist/src/engine.js +5 -0
- package/dist/src/resolvers/resolveBuildFileExtension.js +1 -0
- package/dist/src/scripts/release/urlsMarkdown.js +1 -0
- package/dist/src/sdks/index.js +5 -1
- package/dist/src/sdks/sdk-vegaos/index.js +17 -0
- package/dist/src/sdks/sdk-vegaos/sdkVegaOS.js +201 -0
- package/dist/src/tasks/task.rnv.build.js +3 -0
- package/dist/src/tasks/task.rnv.configure.js +3 -0
- package/dist/src/tasks/task.rnv.deploy.js +1 -0
- package/dist/src/tasks/task.rnv.start.js +1 -0
- package/dist/templates/platforms/androidtv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/model/MediaEventType.kt +1 -0
- package/dist/templates/platforms/androidtv/project/app/src/main/kotlin/com/twentyfouri/tvbridge/webview/viewmodel/WebViewModel.kt +11 -0
- package/dist/templates/platforms/vegaos/project/.eslintrc +11 -0
- package/dist/templates/platforms/vegaos/project/.prettierrc +7 -0
- package/dist/templates/platforms/vegaos/project/app.json +5 -0
- package/dist/templates/platforms/vegaos/project/assets/image/.keep +0 -0
- package/dist/templates/platforms/vegaos/project/babel.config.js +3 -0
- package/dist/templates/platforms/vegaos/project/index.js +9 -0
- package/dist/templates/platforms/vegaos/project/jest.config.json +36 -0
- package/dist/templates/platforms/vegaos/project/manifest.toml +69 -0
- package/dist/templates/platforms/vegaos/project/metro.config.js +17 -0
- package/dist/templates/platforms/vegaos/project/package-lock.json +22658 -0
- package/dist/templates/platforms/vegaos/project/package.json +60 -0
- package/dist/templates/platforms/vegaos/project/src/App.tsx +71 -0
- package/dist/templates/platforms/vegaos/project/src/deviceApi/adInfo.ts +16 -0
- package/dist/templates/platforms/vegaos/project/src/deviceApi/deviceInfo.ts +35 -0
- package/dist/templates/platforms/vegaos/project/src/deviceApi/index.ts +3 -0
- package/dist/templates/platforms/vegaos/project/src/deviceApi/purchase.ts +61 -0
- package/dist/templates/platforms/vegaos/project/src/inject.ts +28 -0
- package/dist/templates/platforms/vegaos/project/src/messageHandler.ts +27 -0
- package/package.json +3 -2
- package/renative.engine.json +1 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amazon-devices/template",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"clean": "rm -rf node_modules buildinfo.json dist build",
|
|
10
|
+
"start": "react-native start",
|
|
11
|
+
"test": "jest --colors ",
|
|
12
|
+
"test:snapshot": "jest --colors --updateSnapshot",
|
|
13
|
+
"lint": "eslint src test --ext .ts,.tsx",
|
|
14
|
+
"lint:fix": "eslint src test --ext .ts,.tsx --fix",
|
|
15
|
+
"build:release": "react-native build-vega --build-type Release",
|
|
16
|
+
"build:debug": "react-native build-vega --build-type Debug",
|
|
17
|
+
"build:app": "npm-run-all build:release",
|
|
18
|
+
"build": "npm-run-all build:release",
|
|
19
|
+
"release": "npm-run-all lint test build:app"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@amazon-devices/kepler-adid-retriever": "^1.0.14",
|
|
23
|
+
"@amazon-devices/keplerscript-appstore-iap-lib": "^2.12.13",
|
|
24
|
+
"@amazon-devices/react-native-device-info": "^2.0.1758683737",
|
|
25
|
+
"@amazon-devices/react-native-kepler": "^2.0.0",
|
|
26
|
+
"@amazon-devices/react-native-localize": "^2.0.1758683737",
|
|
27
|
+
"@amazon-devices/webview": "^3.3.1769932800",
|
|
28
|
+
"react": "18.2.0",
|
|
29
|
+
"react-native": "0.72.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@amazon-devices/kepler-cli-platform": "^0",
|
|
33
|
+
"@react-native-community/cli": "11.3.2",
|
|
34
|
+
"@react-native/eslint-config": "0.72.2",
|
|
35
|
+
"@react-native/metro-config": "^0.72.6",
|
|
36
|
+
"@testing-library/react-native": "^7.2.0",
|
|
37
|
+
"@tsconfig/react-native": "^3.0.2",
|
|
38
|
+
"@types/jest": "^28.0.0",
|
|
39
|
+
"@types/react": "^18.0.24",
|
|
40
|
+
"@types/react-test-renderer": "^18.0.0",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^5.30.0",
|
|
42
|
+
"babel-jest": "^28.0.0",
|
|
43
|
+
"eslint": "^8.12.0",
|
|
44
|
+
"jest": "^28.0.0",
|
|
45
|
+
"metro-react-native-babel-preset": "^0.76.5",
|
|
46
|
+
"mustache": "^4.2.0",
|
|
47
|
+
"npm-run-all": "^4.1.5",
|
|
48
|
+
"prettier": "^2.6.2",
|
|
49
|
+
"react-test-renderer": "18.2.0",
|
|
50
|
+
"ts-jest": "^28.0.0",
|
|
51
|
+
"typescript": "4.8.4"
|
|
52
|
+
},
|
|
53
|
+
"kepler": {
|
|
54
|
+
"projectType": "application",
|
|
55
|
+
"appName": "template",
|
|
56
|
+
"targets": [
|
|
57
|
+
"tv"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRef, useState, useEffect } from 'react';
|
|
3
|
+
import { View, StyleSheet } from 'react-native';
|
|
4
|
+
import { WebView } from '@amazon-devices/webview';
|
|
5
|
+
import { createMessageHandler } from './messageHandler';
|
|
6
|
+
import { DeviceInfo, getDeviceInfo } from './deviceApi/deviceInfo';
|
|
7
|
+
import { getAdInfo } from './deviceApi';
|
|
8
|
+
import { getVegaOSBridge } from './inject';
|
|
9
|
+
import { WebViewMethods } from '@amazon-devices/webview/dist/types/WebViewTypes';
|
|
10
|
+
|
|
11
|
+
const APP_URL = '{{APP_URL}}';
|
|
12
|
+
|
|
13
|
+
export const App = () => {
|
|
14
|
+
const webRef = useRef<WebViewMethods>(null);
|
|
15
|
+
const [deviceInfo, setDeviceInfo] = useState<DeviceInfo | null>(null);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const fetchDeviceInfo = async () => {
|
|
19
|
+
try {
|
|
20
|
+
const deviceInfo = await getDeviceInfo();
|
|
21
|
+
setDeviceInfo(deviceInfo);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
setDeviceInfo({} as DeviceInfo); // Fallback
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
fetchDeviceInfo();
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
if (!deviceInfo) {
|
|
31
|
+
return (
|
|
32
|
+
<View style={styles.container}>
|
|
33
|
+
{/* PLACEHOLDER */}
|
|
34
|
+
</View>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const handleLoad = () => {
|
|
39
|
+
webRef.current?.injectJavaScript(getVegaOSBridge(deviceInfo, getAdInfo()));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<View style={styles.container}>
|
|
44
|
+
<WebView
|
|
45
|
+
ref={webRef}
|
|
46
|
+
style={styles.webview}
|
|
47
|
+
source={{uri: APP_URL}}
|
|
48
|
+
allowSystemKeyEvents={true}
|
|
49
|
+
allowsDefaultMediaControl={false}
|
|
50
|
+
domStorageEnabled={true}
|
|
51
|
+
javaScriptEnabled={true}
|
|
52
|
+
hasTVPreferredFocus={true}
|
|
53
|
+
mediaPlaybackRequiresUserAction={false}
|
|
54
|
+
mixedContentMode="always"
|
|
55
|
+
onLoad={handleLoad}
|
|
56
|
+
onMessage={createMessageHandler(webRef)}
|
|
57
|
+
/>
|
|
58
|
+
</View>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const styles = StyleSheet.create({
|
|
63
|
+
container: {
|
|
64
|
+
flex: 1,
|
|
65
|
+
},
|
|
66
|
+
webview: {
|
|
67
|
+
backgroundColor: '#000000',
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AdIdRetriever } from '@amazon-devices/kepler-adid-retriever';
|
|
2
|
+
|
|
3
|
+
export type AdInfo = {
|
|
4
|
+
adId: string;
|
|
5
|
+
latEnabled: boolean;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const getAdInfo = (): AdInfo => {
|
|
9
|
+
try {
|
|
10
|
+
const adId = AdIdRetriever.fetchAdvertisingId();
|
|
11
|
+
const latEnabled = !AdIdRetriever.isAdvertisingTrackingEnabled();
|
|
12
|
+
return { adId, latEnabled };
|
|
13
|
+
} catch {
|
|
14
|
+
return { adId: '', latEnabled: true };
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getManufacturer, getSystemVersion, getUserAgent, getModel, getVersion } from '@amazon-devices/react-native-device-info'
|
|
2
|
+
import { getLocales } from '@amazon-devices/react-native-localize';
|
|
3
|
+
|
|
4
|
+
export type DeviceInfo = {
|
|
5
|
+
manufacturer: string;
|
|
6
|
+
platformVersion: string;
|
|
7
|
+
firmwareVersion: string;
|
|
8
|
+
modelName: string;
|
|
9
|
+
osLanguage: string;
|
|
10
|
+
wrapperVersion: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const getDeviceInfo = async (): Promise<DeviceInfo> => {
|
|
14
|
+
const manufacturer = await getManufacturer();
|
|
15
|
+
const platformVersion = getSystemVersion();
|
|
16
|
+
const firmwareVersion = await getUserAgent();
|
|
17
|
+
const modelName = getModel();
|
|
18
|
+
const wrapperVersion = getVersion();
|
|
19
|
+
|
|
20
|
+
const locales = getLocales();
|
|
21
|
+
const osLanguage = locales.length > 0 ? locales[0].languageCode : '';
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
return {
|
|
25
|
+
manufacturer,
|
|
26
|
+
platformVersion,
|
|
27
|
+
firmwareVersion,
|
|
28
|
+
modelName,
|
|
29
|
+
osLanguage,
|
|
30
|
+
wrapperVersion,
|
|
31
|
+
}
|
|
32
|
+
} catch {
|
|
33
|
+
return {} as DeviceInfo;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { WebViewMethods } from '@amazon-devices/webview/dist/types/WebViewTypes';
|
|
3
|
+
import {
|
|
4
|
+
FulfillmentResult,
|
|
5
|
+
PurchaseResponseCode,
|
|
6
|
+
PurchasingService,
|
|
7
|
+
} from '@amazon-devices/keplerscript-appstore-iap-lib';
|
|
8
|
+
|
|
9
|
+
type WebViewRef = RefObject<WebViewMethods | null>;
|
|
10
|
+
|
|
11
|
+
const dispatchEvent = (webRef: WebViewRef, eventName: string, detail: object) => {
|
|
12
|
+
const detailString = JSON.stringify(detail);
|
|
13
|
+
webRef.current?.injectJavaScript(`
|
|
14
|
+
document.dispatchEvent(new CustomEvent('${eventName}', { detail: ${detailString} }));
|
|
15
|
+
true;
|
|
16
|
+
`);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const getErrorDetail = (error: unknown) => {
|
|
20
|
+
if (error instanceof Error) {
|
|
21
|
+
return {
|
|
22
|
+
name: error.name,
|
|
23
|
+
message: error.message,
|
|
24
|
+
stack: error.stack,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
value: String(error),
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const handlePurchase = async (webRef: WebViewRef, sku: string) => {
|
|
34
|
+
try {
|
|
35
|
+
const response = await PurchasingService.purchase({ sku });
|
|
36
|
+
if (response.responseCode === PurchaseResponseCode.SUCCESSFUL) {
|
|
37
|
+
dispatchEvent(webRef, 'iapSuccess', {
|
|
38
|
+
userId: response.userData.userId,
|
|
39
|
+
receipt: JSON.stringify(response.receipt),
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
dispatchEvent(webRef, 'iapError', {
|
|
43
|
+
message: `Purchase failed with response code: ${response.responseCode}`,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
} catch (error) {
|
|
47
|
+
const message = error instanceof Error ? error.message : 'Purchase failed with unknown error';
|
|
48
|
+
dispatchEvent(webRef, 'iapError', { message });
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const handleNotifyFulfillment = async (receiptId: string) => {
|
|
53
|
+
try {
|
|
54
|
+
await PurchasingService.notifyFulfillment({
|
|
55
|
+
receiptId,
|
|
56
|
+
fulfillmentResult: FulfillmentResult.FULFILLED,
|
|
57
|
+
});
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error('[VegaOS] Failed to notify fulfillment', error);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AdInfo, DeviceInfo } from './deviceApi';
|
|
2
|
+
|
|
3
|
+
export const getVegaOSBridge = (deviceInfo: DeviceInfo, adInfo: AdInfo) => {
|
|
4
|
+
const deviceInfoString = JSON.stringify(deviceInfo);
|
|
5
|
+
const adInfoString = JSON.stringify(adInfo);
|
|
6
|
+
return `
|
|
7
|
+
window.VegaOSBridge = {
|
|
8
|
+
deviceInfo: ${deviceInfoString},
|
|
9
|
+
adInfo: ${adInfoString},
|
|
10
|
+
getDeviceInfo: function() {
|
|
11
|
+
return window.VegaOSBridge.deviceInfo;
|
|
12
|
+
},
|
|
13
|
+
getAdInfo: function() {
|
|
14
|
+
return window.VegaOSBridge.adInfo;
|
|
15
|
+
},
|
|
16
|
+
exit: function() {
|
|
17
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'EXIT_APP' }));
|
|
18
|
+
},
|
|
19
|
+
purchase: function(sku) {
|
|
20
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'PURCHASE', sku: sku }));
|
|
21
|
+
},
|
|
22
|
+
notifyFulfillment: function(receiptId) {
|
|
23
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'NOTIFY_FULFILLMENT', receiptId: receiptId }));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
true; // Přidání 'true;' na konec zabraňuje chybám, kdy WebView padá při vracení nedefinovaného objektu
|
|
27
|
+
`;
|
|
28
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
WebViewMessageEvent,
|
|
4
|
+
WebViewMethods,
|
|
5
|
+
} from '@amazon-devices/webview/dist/types/WebViewTypes';
|
|
6
|
+
import { BackHandler } from 'react-native';
|
|
7
|
+
import { handlePurchase, handleNotifyFulfillment } from './deviceApi';
|
|
8
|
+
|
|
9
|
+
type WebViewRef = RefObject<WebViewMethods | null>;
|
|
10
|
+
|
|
11
|
+
export const createMessageHandler =
|
|
12
|
+
(webRef: WebViewRef) => (event: WebViewMessageEvent) => {
|
|
13
|
+
const message = JSON.parse(event.nativeEvent.data);
|
|
14
|
+
switch (message.type) {
|
|
15
|
+
case 'EXIT_APP':
|
|
16
|
+
BackHandler.exitApp();
|
|
17
|
+
break;
|
|
18
|
+
case 'PURCHASE':
|
|
19
|
+
handlePurchase(webRef, message.sku);
|
|
20
|
+
break;
|
|
21
|
+
case 'NOTIFY_FULFILLMENT':
|
|
22
|
+
handleNotifyFulfillment(message.receiptId);
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@24i/smartapps-bigscreen-rnv-build-engine",
|
|
3
|
-
"version": "0.18.2-alpha.
|
|
3
|
+
"version": "0.18.2-alpha.2845",
|
|
4
4
|
"description": "Package with build engine for SmartApps BIGscreen projects...",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"copy:project:tizen": "mkdir -p dist/templates/platforms/tizen && cp -R templates/platforms/tizen/project dist/templates/platforms/tizen/",
|
|
10
10
|
"copy:project:webos": "mkdir -p dist/templates/platforms/webos && cp -R templates/platforms/webos/project dist/templates/platforms/webos/",
|
|
11
11
|
"copy:project:androidtv": "mkdir -p dist/templates/platforms/androidtv && cp -R templates/platforms/androidtv/project dist/templates/platforms/androidtv/",
|
|
12
|
-
"copy:
|
|
12
|
+
"copy:project:vegaos": "mkdir -p dist/templates/platforms/vegaos && cp -R templates/platforms/vegaos/project dist/templates/platforms/vegaos/",
|
|
13
|
+
"copy:projects": "npm run copy:project:tizen && npm run copy:project:webos && npm run copy:project:androidtv && npm run copy:project:vegaos",
|
|
13
14
|
"eslint": "eslint \"./src/**/*.{js,jsx,ts,tsx}\" \"./templates/**/*.{js,jsx,ts,tsx}\"",
|
|
14
15
|
"stylelint": "stylelint \"./src/**/*.scss\" --aei --rd --risd --rdd",
|
|
15
16
|
"lintcheck": "npm run eslint && npm run stylelint",
|