app http header read
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import React, { useCallback, useEffect } from "react";
|
import React, { useCallback, useEffect } from "react";
|
||||||
|
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
|
||||||
import platform from "@enact/core/platform";
|
import platform from "@enact/core/platform";
|
||||||
import ThemeDecorator from "@enact/sandstone/ThemeDecorator";
|
import ThemeDecorator from "@enact/sandstone/ThemeDecorator";
|
||||||
@@ -18,8 +18,9 @@ import { getSubCategory, getTop20Show } from "../actions/mainActions";
|
|||||||
import { getMyRecommandedKeyword } from "../actions/myPageActions";
|
import { getMyRecommandedKeyword } from "../actions/myPageActions";
|
||||||
import { getOnSaleInfo } from "../actions/onSaleActions";
|
import { getOnSaleInfo } from "../actions/onSaleActions";
|
||||||
import { getBestSeller } from "../actions/productActions";
|
import { getBestSeller } from "../actions/productActions";
|
||||||
|
import { getHttpHeaderForServiceRequest } from "../actions/commonActions";
|
||||||
import { lunaTest } from "../lunaSend/lunaTest";
|
import { lunaTest } from "../lunaSend/lunaTest";
|
||||||
import { getLaunchParams } from "../utils/helperMethods";
|
import { getLaunchParams, clearLaunchParams } from "../utils/helperMethods";
|
||||||
import MainView from "../views/MainView/MainView";
|
import MainView from "../views/MainView/MainView";
|
||||||
import css from "./App.module.less";
|
import css from "./App.module.less";
|
||||||
import { handleDeepLink } from "./deepLinkHandler";
|
import { handleDeepLink } from "./deepLinkHandler";
|
||||||
@@ -28,7 +29,9 @@ let foreGroundChangeTimer = null;
|
|||||||
|
|
||||||
function AppBase(props) {
|
function AppBase(props) {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const { httpHeader } = useSelector((state) => state.common);
|
||||||
|
|
||||||
|
// called by [receive httpHeader, launch, relaunch]
|
||||||
const initService = useCallback(
|
const initService = useCallback(
|
||||||
(haveyInit = true) => {
|
(haveyInit = true) => {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -36,72 +39,58 @@ function AppBase(props) {
|
|||||||
haveyInit,
|
haveyInit,
|
||||||
appinfo
|
appinfo
|
||||||
);
|
);
|
||||||
if (haveyInit) {
|
if(httpHeader){
|
||||||
dispatch(changeAppStatus({ connectionFailed: false }));
|
if (haveyInit) {
|
||||||
if (typeof window === "object" && window.PalmSystem) {
|
dispatch(changeAppStatus({ connectionFailed: false }));
|
||||||
|
if (typeof window === "object" && window.PalmSystem) {
|
||||||
|
dispatch(
|
||||||
|
changeAppStatus({
|
||||||
|
cursorVisible: window.PalmSystem?.cursor?.visibility,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
dispatch(getAuthenticationCode());
|
||||||
|
dispatch(getOnSaleInfo({ categoryIncFlag: "Y", lgCatCd: "" }));
|
||||||
|
dispatch(getHomeMenu());
|
||||||
|
dispatch(getHomeLayout());
|
||||||
|
dispatch(getHomeMainContents());
|
||||||
|
dispatch(getMyRecommandedKeyword());
|
||||||
|
dispatch(getBestSeller());
|
||||||
dispatch(
|
dispatch(
|
||||||
changeAppStatus({
|
getSubCategory({
|
||||||
cursorVisible: window.PalmSystem?.cursor?.visibility,
|
lgCatCd: "1017", //LG Electronics Base
|
||||||
|
patnrIdList: null,
|
||||||
|
pageSize: null,
|
||||||
|
tabType: null,
|
||||||
|
filterType: null,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
dispatch(getTop20Show());
|
||||||
|
dispatch(getThemeCurationInfo());
|
||||||
}
|
}
|
||||||
//todo
|
|
||||||
// dispatch(getSystemSettings());
|
|
||||||
// //get captionEnable
|
|
||||||
// dispatch(getSystemSettings2());
|
|
||||||
// dispatch(getSystemInfo());
|
|
||||||
// dispatch(getDeviceId());
|
|
||||||
// dispatch(getHttpHeaderForServiceRequest(webOSVersion, language));
|
|
||||||
|
|
||||||
dispatch(getAuthenticationCode());
|
|
||||||
dispatch(getOnSaleInfo({ categoryIncFlag: "Y", lgCatCd: "" }));
|
|
||||||
dispatch(getHomeMenu());
|
|
||||||
dispatch(getHomeLayout());
|
|
||||||
dispatch(getHomeMainContents());
|
|
||||||
dispatch(getMyRecommandedKeyword());
|
|
||||||
dispatch(getBestSeller());
|
|
||||||
dispatch(
|
|
||||||
getSubCategory({
|
|
||||||
lgCatCd: "1017", //LG Electronics Base
|
|
||||||
patnrIdList: null,
|
|
||||||
pageSize: null,
|
|
||||||
tabType: null,
|
|
||||||
filterType: null,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
dispatch(getTop20Show());
|
|
||||||
dispatch(getThemeCurationInfo());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[dispatch]
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleLaunchEvent = useCallback(
|
|
||||||
(isRelaunch = false) => {
|
|
||||||
//todo deeplink
|
|
||||||
const launchParams = getLaunchParams();
|
|
||||||
console.log(
|
|
||||||
"handleLaunchEvent...{isRelaunch, launchParams}",
|
|
||||||
isRelaunch,
|
|
||||||
launchParams
|
|
||||||
);
|
|
||||||
|
|
||||||
if (launchParams?.contentTarget) {
|
|
||||||
//todo deeplink
|
//todo deeplink
|
||||||
dispatch(handleDeepLink(launchParams.contentTarget));
|
const launchParams = getLaunchParams();
|
||||||
}
|
console.log(
|
||||||
|
"initService...{haveyInit, launchParams}",
|
||||||
|
haveyInit,
|
||||||
|
launchParams
|
||||||
|
);
|
||||||
|
|
||||||
setTimeout(() => {
|
if (launchParams?.contentTarget) {
|
||||||
initService(!isRelaunch);
|
//todo deeplink
|
||||||
}, 100);
|
dispatch(handleDeepLink(launchParams.contentTarget));
|
||||||
|
}
|
||||||
|
clearLaunchParams();
|
||||||
|
dispatch(changeAppStatus({ showLoadingPanel: { show: false } }));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[initService]
|
[dispatch, httpHeader]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleRelaunchEvent = useCallback(() => {
|
const handleRelaunchEvent = useCallback(() => {
|
||||||
console.log("handleRelaunchEvent started");
|
console.log("handleRelaunchEvent started");
|
||||||
handleLaunchEvent(true);
|
initService(false);
|
||||||
}, [handleLaunchEvent]);
|
}, [initService]);
|
||||||
|
|
||||||
const visibilityChanged = useCallback(() => {
|
const visibilityChanged = useCallback(() => {
|
||||||
console.log("document is hidden", document.hidden);
|
console.log("document is hidden", document.hidden);
|
||||||
@@ -134,9 +123,6 @@ function AppBase(props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
setTimeout(() => {
|
|
||||||
initService(false);
|
|
||||||
}, 100);
|
|
||||||
}
|
}
|
||||||
}, [dispatch, initService]);
|
}, [dispatch, initService]);
|
||||||
|
|
||||||
@@ -146,14 +132,30 @@ function AppBase(props) {
|
|||||||
window.lunaTest = (service, method, subscribe, parameters) =>
|
window.lunaTest = (service, method, subscribe, parameters) =>
|
||||||
lunaTest(service, method, subscribe, parameters);
|
lunaTest(service, method, subscribe, parameters);
|
||||||
}
|
}
|
||||||
handleLaunchEvent();
|
dispatch(getHttpHeaderForServiceRequest());
|
||||||
|
//todo subscribe
|
||||||
|
// dispatch(getSystemSettings());
|
||||||
|
// //get captionEnable
|
||||||
|
// dispatch(getSystemSettings2());
|
||||||
|
// dispatch(getSystemInfo());
|
||||||
|
// dispatch(getDeviceId());
|
||||||
document.addEventListener("visibilitychange", visibilityChanged);
|
document.addEventListener("visibilitychange", visibilityChanged);
|
||||||
document.addEventListener("webOSRelaunch", handleRelaunchEvent);
|
document.addEventListener("webOSRelaunch", handleRelaunchEvent);
|
||||||
return () => {
|
return () => {
|
||||||
document.removeEventListener("visibilitychange", visibilityChanged);
|
document.removeEventListener("visibilitychange", visibilityChanged);
|
||||||
document.removeEventListener("webOSRelaunch", handleRelaunchEvent);
|
document.removeEventListener("webOSRelaunch", handleRelaunchEvent);
|
||||||
};
|
};
|
||||||
}, [dispatch]);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
console.log('httpHeader changed ', httpHeader);
|
||||||
|
if(!httpHeader){
|
||||||
|
|
||||||
|
}else{ //계정정보 변경시 또는 초기 로딩시
|
||||||
|
dispatch(changeAppStatus({ showLoadingPanel: { show: true } }));
|
||||||
|
initService(true);
|
||||||
|
}
|
||||||
|
}, [httpHeader]);
|
||||||
|
|
||||||
return <MainView />;
|
return <MainView />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export const types = {
|
|||||||
GET_AUTHENTICATION_CODE: "GET_AUTHENTICATION_CODE",
|
GET_AUTHENTICATION_CODE: "GET_AUTHENTICATION_CODE",
|
||||||
|
|
||||||
// common actions
|
// common actions
|
||||||
|
GET_HTTP_HEADER: "GET_HTTP_HEADER",
|
||||||
CHANGE_APP_STATUS: "CHANGE_APP_STATUS",
|
CHANGE_APP_STATUS: "CHANGE_APP_STATUS",
|
||||||
|
|
||||||
// appData actions
|
// appData actions
|
||||||
|
|||||||
@@ -1,6 +1,51 @@
|
|||||||
import { types } from "./actionTypes";
|
import { types } from "./actionTypes";
|
||||||
|
import * as lunaSend from '../lunaSend';
|
||||||
|
import appinfo from "../../webos-meta/appinfo.json";
|
||||||
|
|
||||||
export const changeAppStatus = (status) => ({
|
export const changeAppStatus = (status) => ({
|
||||||
type: types.CHANGE_APP_STATUS,
|
type: types.CHANGE_APP_STATUS,
|
||||||
payload: status,
|
payload: status,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const getHttpHeaderForServiceRequest = onComplete => (dispatch, getState) => {
|
||||||
|
console.log('getHttpHeaderForServiceRequest ');
|
||||||
|
lunaSend.getHttpHeaderForServiceRequest({
|
||||||
|
onSuccess: (res) => {
|
||||||
|
console.log("getHttpHeaderForServiceRequest", res);
|
||||||
|
const convertedRes = {
|
||||||
|
"Authorization": res["Authorization"],
|
||||||
|
"X-Authentication": res["X-Authentication"],
|
||||||
|
"X-Device-ID": res["X-Device-ID"],
|
||||||
|
"X-Device-Product": res["X-Device-Product"],
|
||||||
|
"X-Device-Platform": res["X-Device-Platform"],
|
||||||
|
"X-Device-Model": res["X-Device-Model"],
|
||||||
|
"X-Device-Eco-Info": res["X-Device-Eco-Info"],
|
||||||
|
"X-Device-Country": res["X-Device-Country"],
|
||||||
|
"X-Device-Language":res["X-Device-Language"],
|
||||||
|
"X-Device-Netcast-Platform-Version": res["X-Device-Netcast-Platform-Version"],
|
||||||
|
"X-Device-Publish-Flag": res["X-Device-Publish-Flag"],
|
||||||
|
"X-Device-Fck": res["X-Device-Fck"],
|
||||||
|
"X-Device-Eula": res["X-Device-Eula"]
|
||||||
|
}
|
||||||
|
convertedRes["X-Device-Personalization"] = "Y";
|
||||||
|
|
||||||
|
convertedRes["app_id"] = appinfo.id;
|
||||||
|
//todo temp
|
||||||
|
convertedRes["app_ver"] = "1.0.0";//appinfo.version;
|
||||||
|
convertedRes["dvc_id"] = res["X-Device-Model"];
|
||||||
|
convertedRes["cntry_cd"] = res["X-Device-Country"];
|
||||||
|
convertedRes["prod_cd"] = res["X-Device-Product"];
|
||||||
|
convertedRes["plat_cd"] = res["X-Device-Platform"];
|
||||||
|
convertedRes["lang_cd"] = res["X-Device-Language"];
|
||||||
|
convertedRes["sdk_ver"] = "1.0.0"; //server sdk version
|
||||||
|
convertedRes["publish_flag"] = "Y";
|
||||||
|
const version = res["X-Device-Netcast-Platform-Version"] || "";
|
||||||
|
convertedRes["os_ver"] = version;
|
||||||
|
dispatch({ type: types.GET_HTTP_HEADER, payload: convertedRes });
|
||||||
|
dispatch(changeAppStatus({webOSVersion: version.substring(0,version.lastIndexOf('.'))}));
|
||||||
|
},
|
||||||
|
onFailure: (err) => {
|
||||||
|
console.log("getHttpHeaderForServiceRequest fail",err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -103,36 +103,8 @@ export const TAxios = (
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const executeRequest = (accessToken) => {
|
const executeRequest = (accessToken, httpHeader) => {
|
||||||
const AUTHORIZATION = { headers: {} };
|
const AUTHORIZATION = { headers: {...httpHeader} };
|
||||||
|
|
||||||
AUTHORIZATION.headers["app_id"] = "com.lgshop.app";
|
|
||||||
AUTHORIZATION.headers["app_ver"] = "1.0.0";
|
|
||||||
AUTHORIZATION.headers["dvc_id"] = "testdeviceid";
|
|
||||||
AUTHORIZATION.headers["cntry_cd"] = "US";
|
|
||||||
AUTHORIZATION.headers["prod_cd"] = "webOSTV 5.0";
|
|
||||||
AUTHORIZATION.headers["plat_cd"] = "W20H";
|
|
||||||
AUTHORIZATION.headers["lang_cd"] = "en-US";
|
|
||||||
AUTHORIZATION.headers["os_ver"] = "3.0";
|
|
||||||
AUTHORIZATION.headers["sdk_ver"] = "1.0.0";
|
|
||||||
AUTHORIZATION.headers["publish_flag"] = "Y";
|
|
||||||
|
|
||||||
// Device Header 임시
|
|
||||||
AUTHORIZATION.headers["X-Authentication"] = "MkOLvUocrJ69RH/iV1ZABJhjR2g=";
|
|
||||||
AUTHORIZATION.headers["X-Device-ID"] =
|
|
||||||
"OemUY5qbPITZv96QKlxrtcqT6ypeX6us2qANLng3/0QCUhv2mecK1UDTMYb/hjpjey9dC/kFycc/5R8u+oK56JIWyYC4V278z64YDPKbDXIsd+eECvyf+Rdm8BneIUPM";
|
|
||||||
AUTHORIZATION.headers["X-Device-Product"] = "webOSTV 5.0";
|
|
||||||
AUTHORIZATION.headers["X-Device-Platform"] = "W20P";
|
|
||||||
AUTHORIZATION.headers["X-Device-Model"] = "HE_DTV_W20P_AFADATAA";
|
|
||||||
AUTHORIZATION.headers["X-Device-Eco-Info"] = "1";
|
|
||||||
AUTHORIZATION.headers["X-Device-Country"] = "US";
|
|
||||||
AUTHORIZATION.headers["X-Device-Language"] = "en-US";
|
|
||||||
AUTHORIZATION.headers["X-Device-Netcast-Platform-Version"] = "5.0.0";
|
|
||||||
AUTHORIZATION.headers["X-Device-Publish-Flag"] = "N";
|
|
||||||
AUTHORIZATION.headers["X-Device-Fck"] = "253";
|
|
||||||
AUTHORIZATION.headers["X-Device-Eula"] =
|
|
||||||
"additionalDataAllowed,takeOnAllowed,networkAllowed,generalTermsAllowed,chpAllowed,customAdAllowed,acrOnAllowed,voice2Allowed,voiceAllowed,acrAdAllowed";
|
|
||||||
AUTHORIZATION.headers["X-Device-Personalization"] = "Y";
|
|
||||||
|
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
AUTHORIZATION.headers["lgsp_auth"] = accessToken;
|
AUTHORIZATION.headers["lgsp_auth"] = accessToken;
|
||||||
@@ -174,12 +146,12 @@ export const TAxios = (
|
|||||||
checkAccessToken().then((accessToken) => {
|
checkAccessToken().then((accessToken) => {
|
||||||
if (!noTokenRefresh) {
|
if (!noTokenRefresh) {
|
||||||
tokenRefresh(dispatch, getState)
|
tokenRefresh(dispatch, getState)
|
||||||
.then(() => executeRequest(accessToken))
|
.then(() => executeRequest(accessToken, getState().common.httpHeader))
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
/* 토큰 갱신 실패 처리 */
|
/* 토큰 갱신 실패 처리 */
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
executeRequest(accessToken);
|
executeRequest(accessToken, getState().common.httpHeader);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,221 +0,0 @@
|
|||||||
import LS2Request from "./LS2Request";
|
|
||||||
import * as helperMethods from "../utils/helperMethods";
|
|
||||||
//W6.0
|
|
||||||
const SERVICE_URL = "luna://com.webos.service.tts";
|
|
||||||
const SETTING_SERVICE_URL = "luna://com.webos.settingsservice";
|
|
||||||
const METHOD_TYPE = {
|
|
||||||
GET_SYSTEM_SETTINGS: "getSystemSettings",
|
|
||||||
GET_STATUS: "getStatus",
|
|
||||||
SPEAK: "speak",
|
|
||||||
STOP: "stop",
|
|
||||||
};
|
|
||||||
|
|
||||||
const isLocalConditions = () => (typeof window === 'object' && !window.PalmSystem);
|
|
||||||
|
|
||||||
export const getAudioFeedbackStatus = () => {
|
|
||||||
if (isLocalConditions()) {
|
|
||||||
console.log("isLocal: LUNA SEND getAudioFeedbackStatus");
|
|
||||||
return "Some Hard Coded Mock Data";
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
const response = new LS2Request().send({
|
|
||||||
service: SETTING_SERVICE_URL,
|
|
||||||
method: METHOD_TYPE.GET_SYSTEM_SETTINGS,
|
|
||||||
subscribe: false,
|
|
||||||
parameters: {
|
|
||||||
category: "voiceframework",
|
|
||||||
key: "audioFeedback",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
console.log("LUNA SEND getAudioFeedbackStatus");
|
|
||||||
console.log("LUNA getAudioFeedbackStatus response: ", response);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
} catch (e) {
|
|
||||||
console.error("LUNA SEND ERROR: ", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const setAudioFeedback = (value = false) => {
|
|
||||||
if (isLocalConditions()) {
|
|
||||||
console.log("isLocal: LUNA SEND setAudioFeedback: ", value);
|
|
||||||
return "Some Hard Coded Mock Data";
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
const response = new LS2Request().send({
|
|
||||||
service: SETTING_SERVICE_URL,
|
|
||||||
method: METHOD_TYPE.SETTING_SERVICE_URL,
|
|
||||||
subscribe: false,
|
|
||||||
parameters: {
|
|
||||||
category: "voiceframework",
|
|
||||||
settings: { audioFeedback: value },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
console.log("LUNA SEND setAudioFeedback: ", value);
|
|
||||||
console.log("LUNA setAudioFeedback response: ", response);
|
|
||||||
} catch (e) {
|
|
||||||
console.error("LUNA SEND ERROR: ", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getStatus = () => {
|
|
||||||
if (isLocalConditions()) {
|
|
||||||
console.log("isLocal: LUNA SEND getStatus");
|
|
||||||
return "Some Hard Coded Mock Data";
|
|
||||||
} else {
|
|
||||||
console.log("LUNA SEND getStatus");
|
|
||||||
return new LS2Request().send({
|
|
||||||
service: SERVICE_URL,
|
|
||||||
method: METHOD_TYPE.GET_STATUS,
|
|
||||||
subscribe: false,
|
|
||||||
parameters: {},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let speakHandle;
|
|
||||||
export const speak = (text, onEnded) => {
|
|
||||||
stop();
|
|
||||||
speakHandle = setTimeout(() => _speak(text, onEnded), 500);
|
|
||||||
};
|
|
||||||
let serviceHandle = null;
|
|
||||||
let msgId = null;
|
|
||||||
export const _speak = (text, onEnded) => {
|
|
||||||
const _onEnded = () => {
|
|
||||||
if(onEnded){
|
|
||||||
onEnded(text);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const _text = helperMethods.stripHTML(text);
|
|
||||||
if (isLocalConditions()) {
|
|
||||||
console.log("isLocal: LUNA SEND speak", text);
|
|
||||||
localPlay(_text, _onEnded);
|
|
||||||
return "Some Hard Coded Mock Data";
|
|
||||||
} else {
|
|
||||||
const _onSuccess = (res) =>{
|
|
||||||
console.log('TTS Speak onSuccess', res);
|
|
||||||
if(res.returnValue && res.msgID){
|
|
||||||
if(res.msgStatus === 'done'){
|
|
||||||
if(msgId === res.msgID){
|
|
||||||
if(onEnded){
|
|
||||||
onEnded(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
serviceHandle.cancel();
|
|
||||||
serviceHandle = null;
|
|
||||||
}else{
|
|
||||||
msgId = res.msgID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const _onFailure = (res) =>{
|
|
||||||
console.log('TTS Speak onFailure', res);
|
|
||||||
serviceHandle.cancel();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const textArr = helperMethods.splitText(_text, 300);
|
|
||||||
|
|
||||||
textArr.map((textEl, index) => {
|
|
||||||
serviceHandle = new LS2Request().send({
|
|
||||||
service: SERVICE_URL,
|
|
||||||
method: METHOD_TYPE.SPEAK,
|
|
||||||
subscribe: true,
|
|
||||||
parameters: {
|
|
||||||
text: textEl,
|
|
||||||
feedback: true,
|
|
||||||
mode: "audioFeedback",
|
|
||||||
clear: index === textEl.length - 1 ? false : true,
|
|
||||||
},
|
|
||||||
onSuccess: _onSuccess,
|
|
||||||
onFailure: _onFailure,
|
|
||||||
});
|
|
||||||
return serviceHandle;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error("TTS Speak ERROR: ", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const stop = () => {
|
|
||||||
clearTimeout(speakHandle);
|
|
||||||
speakHandle = null;
|
|
||||||
if(serviceHandle){
|
|
||||||
serviceHandle.cancel();
|
|
||||||
serviceHandle = null;
|
|
||||||
}
|
|
||||||
if (isLocalConditions()) {
|
|
||||||
console.log("isLocal: LUNA SEND stop");
|
|
||||||
localStop();
|
|
||||||
return "Some Hard Coded Mock Data";
|
|
||||||
} else {
|
|
||||||
const _onSuccess = (res) =>{
|
|
||||||
console.log('TTS stop onSuccess', res);
|
|
||||||
}
|
|
||||||
const _onFailure = (res) =>{
|
|
||||||
console.log('TTS stop onFailure', res);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const handle = new LS2Request().send({
|
|
||||||
service: SERVICE_URL,
|
|
||||||
method: METHOD_TYPE.STOP,
|
|
||||||
subscribe: false,
|
|
||||||
parameters: {},
|
|
||||||
onSuccess: _onSuccess,
|
|
||||||
onFailure: _onFailure
|
|
||||||
});
|
|
||||||
return handle;
|
|
||||||
} catch (e) {
|
|
||||||
console.error("LUNA SEND ERROR: ", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const localSoundEffect = (textToSpeak, onended) => {
|
|
||||||
if (typeof window === "object") {
|
|
||||||
try {
|
|
||||||
if (window.speechSynthesis) {
|
|
||||||
const synth = window.speechSynthesis;
|
|
||||||
|
|
||||||
synth.cancel();
|
|
||||||
|
|
||||||
const utterance = new window.SpeechSynthesisUtterance(textToSpeak);
|
|
||||||
|
|
||||||
if (typeof window.navigator === 'object') {
|
|
||||||
const isAppleOS = window.navigator.userAgent
|
|
||||||
.toLowerCase()
|
|
||||||
.includes("mac");
|
|
||||||
|
|
||||||
// 음성 합성 설정 (선택 사항)
|
|
||||||
utterance.lang = "ko-KR"; // 음성 언어 설정
|
|
||||||
utterance.volume = 1; // 음성 볼륨 설정 (0.0에서 1.0까지)
|
|
||||||
if (isAppleOS) {
|
|
||||||
utterance.rate = 1.2; // 음성 속도 설정 (0.1에서 10.0까지)
|
|
||||||
utterance.pitch = 1; // 음성 음조 설정 (0.1에서 2.0까지)
|
|
||||||
} else {
|
|
||||||
utterance.rate = 1.7; // 음성 속도 설정 (0.1에서 10.0까지)
|
|
||||||
utterance.pitch = 1.7; // 음성 음조 설정 (0.1에서 2.0까지)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
utterance.onend = onended;
|
|
||||||
synth.speak(utterance);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error("error: ", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const localPlay = (text, onended) => {
|
|
||||||
localSoundEffect(text, onended);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const localStop = () => {
|
|
||||||
if (typeof window === "object") {
|
|
||||||
if (window.speechSynthesis) {
|
|
||||||
const synth = window.speechSynthesis;
|
|
||||||
synth.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,40 +1,6 @@
|
|||||||
import LS2Request from "./LS2Request";
|
import LS2Request from "./LS2Request";
|
||||||
import * as Config from "../utils/Config";
|
import * as Config from "../utils/Config";
|
||||||
import appinfo from '../../webos-meta/appinfo.json';
|
import appinfo from '../../webos-meta/appinfo.json';
|
||||||
//W6.0
|
|
||||||
export const getHttpHeaderForServiceRequest = (webOSVersion, language, {onSuccess, onFailure, onComplete}) => {
|
|
||||||
if (webOSVersion === "local") {
|
|
||||||
if (Config.SUPPORT_LOGIN || Config.USE_DUMMY) {
|
|
||||||
if (language === "ko") {
|
|
||||||
onSuccess({
|
|
||||||
"X-User-Number": Config.DEBUG_WINDOW_ACCOUNTID_KR,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
onSuccess({
|
|
||||||
"X-User-Number": Config.DEBUG_WINDOW_ACCOUNTID_US,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
onFailure();
|
|
||||||
}
|
|
||||||
onComplete();
|
|
||||||
} else {
|
|
||||||
if (process.env.REACT_APP_MODE === "DEBUG") {
|
|
||||||
console.log("LUNA SEND getHttpHeaderForServiceRequest");
|
|
||||||
return "Some Hard Coded Mock Data";
|
|
||||||
} else {
|
|
||||||
return new LS2Request().send({
|
|
||||||
service: "luna://com.webos.service.sdx",
|
|
||||||
method: "getHttpHeaderForServiceRequest",
|
|
||||||
subscribe: false,
|
|
||||||
parameters: {},
|
|
||||||
onSuccess,
|
|
||||||
onFailure,
|
|
||||||
onComplete,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getSystemSettings = (parameters, {onSuccess, onFailure, onComplete}) => {
|
export const getSystemSettings = (parameters, {onSuccess, onFailure, onComplete}) => {
|
||||||
if (typeof window === "object" && window.PalmSystem) {
|
if (typeof window === "object" && window.PalmSystem) {
|
||||||
|
|||||||
@@ -38,3 +38,43 @@ export const createToast = (message) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let httpHeaderHandler = null;
|
||||||
|
export const getHttpHeaderForServiceRequest = ({onSuccess, onFailure, onComplete}) => {
|
||||||
|
if (typeof window === "object" && window.PalmSystem) {
|
||||||
|
if (process.env.REACT_APP_MODE === "DEBUG") {
|
||||||
|
console.log("LUNA SEND getHttpHeaderForServiceRequest");
|
||||||
|
return "Some Hard Coded Mock Data";
|
||||||
|
} else {
|
||||||
|
if(httpHeaderHandler){
|
||||||
|
httpHeaderHandler.cancel();
|
||||||
|
}
|
||||||
|
httpHeaderHandler = new LS2Request().send({
|
||||||
|
service: "luna://com.webos.service.sdx",
|
||||||
|
method: "getHttpHeaderForServiceRequest",
|
||||||
|
subscribe: true,
|
||||||
|
parameters: {},
|
||||||
|
onSuccess,
|
||||||
|
onFailure,
|
||||||
|
onComplete,
|
||||||
|
});
|
||||||
|
return httpHeaderHandler;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
onSuccess({
|
||||||
|
"Authorization": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJuZXh0bGdzZHAuY29tIiwiYXVkIjoibmV4dGxnc2RwLmNvbSIsImlhdCI6MTcwNzc4NTUyNSwiZXhwIjoxNzA3NzkyNzI1LCJtYWNBZGRyZXNzIjoiZWVkMDQ2NjdiNjUzOWU3YmQxMDA1OTljYjBkYTI5ZjRjZTgyZGZlOGZkNzIzMDAxZGVmMjg4NWRkNWZiODRmNWNiMzZlM2QwNzYzNWZjZGJjYWNjNGVjMzI5NWIwNjZjOTMwNmNmNDI1ZGQzMmQ2MDMxMjc1NWNkOTIyNjEwMzcifQ.vqPdYGnN46diesDBLzA4UhACCJVdIycLs7wZu9M55Hc",
|
||||||
|
"X-Authentication": "MkOLvUocrJ69RH/iV1ZABJhjR2g=",
|
||||||
|
"X-Device-ID": "OemUY5qbPITZv96QKlxrtcqT6ypeX6us2qANLng3/0QCUhv2mecK1UDTMYb/hjpjey9dC/kFycc/5R8u+oK56JIWyYC4V278z64YDPKbDXIsd+eECvyf+Rdm8BneIUPM",
|
||||||
|
"X-Device-Product": "webOSTV 5.0",
|
||||||
|
"X-Device-Platform": "W20P",
|
||||||
|
"X-Device-Model": "HE_DTV_W20P_AFADATAA",
|
||||||
|
"X-Device-Eco-Info": "1",
|
||||||
|
"X-Device-Country": "US",
|
||||||
|
"X-Device-Language":"en-US",
|
||||||
|
"X-Device-Netcast-Platform-Version": "5.0.0",
|
||||||
|
"X-Device-Publish-Flag": "N",
|
||||||
|
"X-Device-Fck": "253",
|
||||||
|
"X-Device-Eula": "additionalDataAllowed,takeOnAllowed,networkAllowed,generalTermsAllowed,chpAllowed,customAdAllowed,acrOnAllowed,voice2Allowed,voiceAllowed,acrAdAllowed"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -4,8 +4,10 @@ const initialState = {
|
|||||||
appStatus: {
|
appStatus: {
|
||||||
showLoadingPanel: { show: true, type: "launching" },
|
showLoadingPanel: { show: true, type: "launching" },
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
cursorVisible: false,
|
webOSVersion:"", //"5.0", "9.0" ...
|
||||||
|
cursorVisible: false
|
||||||
},
|
},
|
||||||
|
httpHeader: null
|
||||||
};
|
};
|
||||||
|
|
||||||
export const commonReducer = (state = initialState, action) => {
|
export const commonReducer = (state = initialState, action) => {
|
||||||
@@ -38,7 +40,11 @@ export const commonReducer = (state = initialState, action) => {
|
|||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
case types.GET_HTTP_HEADER:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
httpHeader: action.payload
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { types } from "../actions/actionTypes";
|
import { types } from "../actions/actionTypes";
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
accessToken: null,
|
accessToken: null
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deviceReducer = (state = initialState, action) => {
|
export const deviceReducer = (state = initialState, action) => {
|
||||||
|
|||||||
@@ -113,3 +113,12 @@ export const getLaunchParams = () => {
|
|||||||
return localLaunchParams;
|
return localLaunchParams;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const clearLaunchParams = () => {
|
||||||
|
console.log('common.clearLaunchParams');
|
||||||
|
if (typeof window === 'object' && window.PalmSystem && window.PalmSystem.launchParams) {
|
||||||
|
window.PalmSystem.launchParams = '';
|
||||||
|
}else{
|
||||||
|
localLaunchParams = {};
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -66,9 +66,9 @@ export default function LoadingPanel({ showLoadingPanel, ...rest }) {
|
|||||||
} else {
|
} else {
|
||||||
setReadyToHide(false);
|
setReadyToHide(false);
|
||||||
setReadyToAni(false);
|
setReadyToAni(false);
|
||||||
minShowingTimeJob.stop();
|
minShowingTimeJob && minShowingTimeJob.stop();
|
||||||
hidingJob.stop();
|
hidingJob && hidingJob.stop();
|
||||||
maxShowingTimeJob.stop();
|
maxShowingTimeJob && maxShowingTimeJob.stop();
|
||||||
dispatch(changeAppStatus({ showLoadingPanel: { show: false } }));
|
dispatch(changeAppStatus({ showLoadingPanel: { show: false } }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ export default function MainView() {
|
|||||||
}, [mainIndex, panels.length]);
|
}, [mainIndex, panels.length]);
|
||||||
|
|
||||||
const onPreImageLoadComplete = useCallback(() => {
|
const onPreImageLoadComplete = useCallback(() => {
|
||||||
dispatch(changeAppStatus({ showLoadingPanel: { show: false } }));
|
console.log('MainView onPreImageLoadComplete');
|
||||||
|
// dispatch(changeAppStatus({ showLoadingPanel: { show: false } }));
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
|
|
||||||
const renderTopPanel = useCallback(() => {
|
const renderTopPanel = useCallback(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user