Deploying to gh-pages from @ fishjar/kiss-translator@2650e5cf7c 🚀
This commit is contained in:
310
content.html
310
content.html
@@ -4,321 +4,11 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>%REACT_APP_NAME%</title>
|
<title>%REACT_APP_NAME%</title>
|
||||||
<style>
|
|
||||||
img {
|
|
||||||
width: 1.2em;
|
|
||||||
height: 1.2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
svg {
|
|
||||||
max-width: 1.2em;
|
|
||||||
max-height: 1.2em;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script>
|
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
|
||||||
// (() => {
|
|
||||||
// var shadow = document.querySelector("#shadow1");
|
|
||||||
// var root = shadow.attachShadow({ mode: "open" });
|
|
||||||
// var newLine = document.createElement("p");
|
|
||||||
// newLine.innerText = "new line";
|
|
||||||
// root.appendChild(newLine);
|
|
||||||
// })();
|
|
||||||
|
|
||||||
// setTimeout(function () {
|
|
||||||
// var shadow = document.querySelector("#shadow2");
|
|
||||||
// var root = shadow.attachShadow({ mode: "open" });
|
|
||||||
// }, 1000);
|
|
||||||
|
|
||||||
// setTimeout(() => {
|
|
||||||
// var newLine = document.createElement("p");
|
|
||||||
// newLine.innerText = "new line";
|
|
||||||
// var shadow = document.querySelector("#shadow2");
|
|
||||||
// shadow.shadowRoot.appendChild(newLine);
|
|
||||||
// }, 2000);
|
|
||||||
|
|
||||||
// setTimeout(() => {
|
|
||||||
// var newLine = document.createElement("div");
|
|
||||||
// newLine.innerHTML = "<p>second line</p><p>third line</p>";
|
|
||||||
// var shadow = document.querySelector("#shadow2");
|
|
||||||
// shadow.shadowRoot.appendChild(newLine);
|
|
||||||
// }, 3000);
|
|
||||||
|
|
||||||
// setTimeout(function () {
|
|
||||||
// var el = document.querySelector("h2");
|
|
||||||
// el.innerText = "hello world";
|
|
||||||
|
|
||||||
// var title = document.querySelector("#addtitle");
|
|
||||||
// title.innerHTML =
|
|
||||||
// "<div><p>second title</p><ul><li>second title</li><li><p>second title</p></li></ul></div>";
|
|
||||||
// }, 1000);
|
|
||||||
|
|
||||||
setTimeout(function () {
|
|
||||||
var el = document.querySelector('h2>p>span');
|
|
||||||
el.innerText = 'hello world';
|
|
||||||
}, 1000);
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
<div id="root">
|
<div id="root">
|
||||||
<p>You need to enable <code>JavaScript</code> to run <span>this app.</span></p>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<div id="content">
|
|
||||||
<p>You need to enable JavaScript to run <span>this app.</span></p>
|
|
||||||
The <span>embargo</span> has just lifted to confirm that AmpereOne is coming to
|
|
||||||
Google Cloud with the C3A instances.
|
|
||||||
<br />
|
|
||||||
But these upcoming instances for now are only in private preview form.
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
Needless to say I also haven't had any AmpereOne access to check out the
|
|
||||||
performance and power efficiency of these new Arm server processors from Ampere
|
|
||||||
Computing.
|
|
||||||
<br />
|
|
||||||
</div>
|
|
||||||
<h2>
|
|
||||||
<p>
|
|
||||||
<span>React is a JavaScript library for building user interfaces.</span>
|
|
||||||
</p>
|
|
||||||
</h2>
|
|
||||||
<hr />
|
|
||||||
<input id="input1" style="width: 80%" />
|
|
||||||
<hr />
|
|
||||||
<textarea id="textarea1" style="width: 80%">test</textarea>
|
|
||||||
<hr />
|
|
||||||
<div id="addtitle"></div>
|
|
||||||
<h2>Shadow 1</h2>
|
|
||||||
<div id="shadow1"></div>
|
|
||||||
<h2>Shadow 2</h2>
|
|
||||||
<div id="shadow2"></div>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<h2>
|
|
||||||
React Server Components (or RSC) is a new application architecture designed by the
|
|
||||||
React team.
|
|
||||||
</h2>
|
|
||||||
<iframe
|
|
||||||
id="iframe1"
|
|
||||||
width="800px"
|
|
||||||
height="600px"
|
|
||||||
src="http://localhost:3000/index.html"></iframe>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<h2>We’ve first shared our research on RSC in an introductory talk and an RFC.</h2>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<h2>
|
|
||||||
To recap them, we are introducing a new kind of component—Server Components—that
|
|
||||||
run ahead of time and are excluded from your JavaScript bundle.
|
|
||||||
</h2>
|
|
||||||
<iframe id="iframe2" width="800px" height="600px" src="https://react.dev/"></iframe>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<div class="cont cont1">
|
|
||||||
<h2>
|
|
||||||
Server Components can run during the build, letting you read from the filesystem
|
|
||||||
or fetch static content.
|
|
||||||
</h2>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
They can also run on the server, letting you access your data layer without
|
|
||||||
having to build an API. You can pass data by props from Server Components to
|
|
||||||
the interactive Client Components in the browser.
|
|
||||||
</li>
|
|
||||||
<li>以声明式编写 UI,可以让你的代码更加可靠,且方便调试。</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<div class="cont cont2">
|
|
||||||
<h2>
|
|
||||||
Since our last update, we have merged the React Server Components RFC to ratify
|
|
||||||
the proposal.
|
|
||||||
</h2>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
RSC combines the simple “request/response” mental model of server-centric
|
|
||||||
Multi-Page Apps with the seamless interactivity of client-centric Single-Page
|
|
||||||
Apps, giving you the best of both worlds.
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
React 使创建交互式 UI
|
|
||||||
变得轻而易举。为你应用的每一个状态设计简洁的视图,当数据变动时 React
|
|
||||||
能高效更新并渲染合适的组件。
|
|
||||||
</li>
|
|
||||||
<li>以声明式编写 UI,可以让你的代码更加可靠,且方便调试。</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<!--
|
<!--
|
||||||
This HTML file is a template.
|
This HTML file is a template.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
10
main.js
10
main.js
@@ -34881,7 +34881,7 @@ function objectWithoutProperties_objectWithoutProperties(source, excluded) {
|
|||||||
const Fetch_excluded=(/* unused pure expression or super */ null && (["execute"])),Fetch_excluded2=["execute"],Fetch_excluded3=["get"];const useAsync=()=>{const[data,setData]=(0,react.useState)(null);const[loading,setLoading]=(0,react.useState)(false);const[error,setError]=(0,react.useState)(null);const execute=(0,react.useCallback)(async function(fn){if(!fn){return;}setLoading(true);setError(null);try{for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key];}const res=await fn(...args);setData(res);setLoading(false);return res;}catch(err){setError((err===null||err===void 0?void 0:err.message)||"An unknown error occurred");setLoading(false);// throw err;
|
const Fetch_excluded=(/* unused pure expression or super */ null && (["execute"])),Fetch_excluded2=["execute"],Fetch_excluded3=["get"];const useAsync=()=>{const[data,setData]=(0,react.useState)(null);const[loading,setLoading]=(0,react.useState)(false);const[error,setError]=(0,react.useState)(null);const execute=(0,react.useCallback)(async function(fn){if(!fn){return;}setLoading(true);setError(null);try{for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key];}const res=await fn(...args);setData(res);setLoading(false);return res;}catch(err){setError((err===null||err===void 0?void 0:err.message)||"An unknown error occurred");setLoading(false);// throw err;
|
||||||
}},[]);const reset=(0,react.useCallback)(()=>{setData(null);setLoading(false);setError(null);},[]);return{data,loading,error,execute,reset};};const useAsyncNow=(fn,arg)=>{const _useAsync=useAsync(),{execute}=_useAsync,asyncState=_objectWithoutProperties(_useAsync,Fetch_excluded);useEffect(()=>{if(fn){execute(fn,arg);}},[execute,fn,arg]);return _objectSpread({},asyncState);};const useFetch=()=>{const _useAsync2=useAsync(),{execute}=_useAsync2,asyncState=objectWithoutProperties_objectWithoutProperties(_useAsync2,Fetch_excluded2);const requester=(0,react.useCallback)(async(url,options)=>{var _response$headers$get;const response=await fetch(url,options);if(!response.ok){const errorInfo=await response.text();throw new Error("Request failed: ".concat(response.status," ").concat(response.statusText," - ").concat(errorInfo));}if(response.status===204){return null;}if((_response$headers$get=response.headers.get("Content-Type"))!==null&&_response$headers$get!==void 0&&_response$headers$get.includes("json")){return response.json();}return response.text();},[]);const get=(0,react.useCallback)(async function(url){let options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};try{const result=await execute(requester,url,_objectSpread2(_objectSpread2({},options),{},{method:"GET"}));return result;}catch(err){return null;}},[execute,requester]);const post=(0,react.useCallback)(async function(url,body){let options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};try{const result=await execute(requester,url,_objectSpread2(_objectSpread2({},options),{},{method:"POST",headers:_objectSpread2({"Content-Type":"application/json"},options.headers),body:JSON.stringify(body)}));return result;}catch(err){return null;}},[execute,requester]);const put=(0,react.useCallback)(async function(url,body){let options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};try{const result=await execute(requester,url,_objectSpread2(_objectSpread2({},options),{},{method:"PUT",headers:_objectSpread2({"Content-Type":"application/json"},options.headers),body:JSON.stringify(body)}));return result;}catch(err){return null;}},[execute,requester]);const del=(0,react.useCallback)(async function(url){let options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};try{const result=await execute(requester,url,_objectSpread2(_objectSpread2({},options),{},{method:"DELETE"}));return result;}catch(err){return null;}},[execute,requester]);return _objectSpread2(_objectSpread2({},asyncState),{},{get,post,put,del});};const useGet=url=>{const _useFetch=useFetch(),{get}=_useFetch,fetchState=objectWithoutProperties_objectWithoutProperties(_useFetch,Fetch_excluded3);(0,react.useEffect)(()=>{if(url)get(url);},[url,get]);return _objectSpread2({},fetchState);};
|
}},[]);const reset=(0,react.useCallback)(()=>{setData(null);setLoading(false);setError(null);},[]);return{data,loading,error,execute,reset};};const useAsyncNow=(fn,arg)=>{const _useAsync=useAsync(),{execute}=_useAsync,asyncState=_objectWithoutProperties(_useAsync,Fetch_excluded);useEffect(()=>{if(fn){execute(fn,arg);}},[execute,fn,arg]);return _objectSpread({},asyncState);};const useFetch=()=>{const _useAsync2=useAsync(),{execute}=_useAsync2,asyncState=objectWithoutProperties_objectWithoutProperties(_useAsync2,Fetch_excluded2);const requester=(0,react.useCallback)(async(url,options)=>{var _response$headers$get;const response=await fetch(url,options);if(!response.ok){const errorInfo=await response.text();throw new Error("Request failed: ".concat(response.status," ").concat(response.statusText," - ").concat(errorInfo));}if(response.status===204){return null;}if((_response$headers$get=response.headers.get("Content-Type"))!==null&&_response$headers$get!==void 0&&_response$headers$get.includes("json")){return response.json();}return response.text();},[]);const get=(0,react.useCallback)(async function(url){let options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};try{const result=await execute(requester,url,_objectSpread2(_objectSpread2({},options),{},{method:"GET"}));return result;}catch(err){return null;}},[execute,requester]);const post=(0,react.useCallback)(async function(url,body){let options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};try{const result=await execute(requester,url,_objectSpread2(_objectSpread2({},options),{},{method:"POST",headers:_objectSpread2({"Content-Type":"application/json"},options.headers),body:JSON.stringify(body)}));return result;}catch(err){return null;}},[execute,requester]);const put=(0,react.useCallback)(async function(url,body){let options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};try{const result=await execute(requester,url,_objectSpread2(_objectSpread2({},options),{},{method:"PUT",headers:_objectSpread2({"Content-Type":"application/json"},options.headers),body:JSON.stringify(body)}));return result;}catch(err){return null;}},[execute,requester]);const del=(0,react.useCallback)(async function(url){let options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};try{const result=await execute(requester,url,_objectSpread2(_objectSpread2({},options),{},{method:"DELETE"}));return result;}catch(err){return null;}},[execute,requester]);return _objectSpread2(_objectSpread2({},asyncState),{},{get,post,put,del});};const useGet=url=>{const _useFetch=useFetch(),{get}=_useFetch,fetchState=objectWithoutProperties_objectWithoutProperties(_useFetch,Fetch_excluded3);(0,react.useEffect)(()=>{if(url)get(url);},[url,get]);return _objectSpread2({},fetchState);};
|
||||||
;// CONCATENATED MODULE: ./src/config/app.js
|
;// CONCATENATED MODULE: ./src/config/app.js
|
||||||
const APP_NAME="KISS Translator".trim().split(/\s+/).join("-");const APP_LCNAME=APP_NAME.toLowerCase();const APP_UPNAME=APP_NAME.toUpperCase();const APP_CONSTS={fabID:"".concat(APP_LCNAME,"-fab"),boxID:"".concat(APP_LCNAME,"-box"),popupID:"".concat(APP_LCNAME,"-popup")};const APP_VERSION="2.0.11".split(".");const THEME_LIGHT="light";const THEME_DARK="dark";
|
const APP_NAME="KISS Translator".trim().split(/\s+/).join("-");const APP_LCNAME=APP_NAME.toLowerCase();const APP_UPNAME=APP_NAME.toUpperCase();const APP_CONSTS={fabID:"".concat(APP_LCNAME,"-fab"),boxID:"".concat(APP_LCNAME,"-box"),popupID:"".concat(APP_LCNAME,"-popup")};const APP_VERSION="2.0.12".split(".");const THEME_LIGHT="light";const THEME_DARK="dark";
|
||||||
;// CONCATENATED MODULE: ./src/config/api.js
|
;// CONCATENATED MODULE: ./src/config/api.js
|
||||||
const DEFAULT_HTTP_TIMEOUT=10000;// 调用超时时间
|
const DEFAULT_HTTP_TIMEOUT=10000;// 调用超时时间
|
||||||
const DEFAULT_FETCH_LIMIT=10;// 默认最大任务数量
|
const DEFAULT_FETCH_LIMIT=10;// 默认最大任务数量
|
||||||
@@ -34988,9 +34988,7 @@ const OPT_STYLE_COLORFUL="colorful";// 多彩
|
|||||||
const OPT_STYLE_ALL=[OPT_STYLE_NONE,OPT_STYLE_LINE,OPT_STYLE_DOTLINE,OPT_STYLE_DASHLINE,OPT_STYLE_DASHLINE_BOLD,OPT_STYLE_WAVYLINE,OPT_STYLE_WAVYLINE_BOLD,OPT_STYLE_DASHBOX,OPT_STYLE_DASHBOX_BOLD,OPT_STYLE_MARKER,OPT_STYLE_GRADIENT_MARKER,OPT_STYLE_FUZZY,OPT_STYLE_HIGHLIGHT,OPT_STYLE_BLOCKQUOTE,OPT_STYLE_GRADIENT,OPT_STYLE_BLINK,OPT_STYLE_GLOW,OPT_STYLE_COLORFUL];const DEFAULT_CUSTOM_STYLES=[{styleSlug:"custom",styleName:"Custom Style",styleCode:"color: #209CEE;"}];
|
const OPT_STYLE_ALL=[OPT_STYLE_NONE,OPT_STYLE_LINE,OPT_STYLE_DOTLINE,OPT_STYLE_DASHLINE,OPT_STYLE_DASHLINE_BOLD,OPT_STYLE_WAVYLINE,OPT_STYLE_WAVYLINE_BOLD,OPT_STYLE_DASHBOX,OPT_STYLE_DASHBOX_BOLD,OPT_STYLE_MARKER,OPT_STYLE_GRADIENT_MARKER,OPT_STYLE_FUZZY,OPT_STYLE_HIGHLIGHT,OPT_STYLE_BLOCKQUOTE,OPT_STYLE_GRADIENT,OPT_STYLE_BLINK,OPT_STYLE_GLOW,OPT_STYLE_COLORFUL];const DEFAULT_CUSTOM_STYLES=[{styleSlug:"custom",styleName:"Custom Style",styleCode:"color: #209CEE;"}];
|
||||||
;// CONCATENATED MODULE: ./src/config/rules.js
|
;// CONCATENATED MODULE: ./src/config/rules.js
|
||||||
const GLOBAL_KEY="*";const REMAIN_KEY="-";const SHADOW_KEY=">>>";const DEFAULT_COLOR="#209CEE";// 默认高亮背景色/线条颜色
|
const GLOBAL_KEY="*";const REMAIN_KEY="-";const SHADOW_KEY=">>>";const DEFAULT_COLOR="#209CEE";// 默认高亮背景色/线条颜色
|
||||||
const DEFAULT_TRANS_TAG="font";// export const DEFAULT_SELECT_STYLE =
|
const DEFAULT_TRANS_TAG="font";const DEFAULT_SELECT_STYLE="-webkit-line-clamp: unset; max-height: none; height: auto;";const OPT_TIMING_PAGESCROLL="mk_pagescroll";// 滚动加载翻译
|
||||||
// "-webkit-line-clamp: unset; max-height: none; height: auto;";
|
|
||||||
const OPT_TIMING_PAGESCROLL="mk_pagescroll";// 滚动加载翻译
|
|
||||||
const OPT_TIMING_PAGEOPEN="mk_pageopen";// 直接翻译到底
|
const OPT_TIMING_PAGEOPEN="mk_pageopen";// 直接翻译到底
|
||||||
const OPT_TIMING_MOUSEOVER="mk_mouseover";const OPT_TIMING_CONTROL="mk_ctrlKey";const OPT_TIMING_SHIFT="mk_shiftKey";const OPT_TIMING_ALT="mk_altKey";const OPT_TIMING_ALL=[OPT_TIMING_PAGESCROLL,OPT_TIMING_PAGEOPEN,OPT_TIMING_MOUSEOVER,OPT_TIMING_CONTROL,OPT_TIMING_SHIFT,OPT_TIMING_ALT];const OPT_SPLIT_PARAGRAPH_DISABLE="split_disable";const OPT_SPLIT_PARAGRAPH_TEXTLENGTH="split_textlength";const OPT_SPLIT_PARAGRAPH_PUNCTUATION="split_punctuation";const OPT_SPLIT_PARAGRAPH_ALL=[OPT_SPLIT_PARAGRAPH_DISABLE,OPT_SPLIT_PARAGRAPH_PUNCTUATION,OPT_SPLIT_PARAGRAPH_TEXTLENGTH];const OPT_HIGHLIGHT_WORDS_DISABLE="highlight_disable";const OPT_HIGHLIGHT_WORDS_BEFORETRANS="highlight_beforetrans";const OPT_HIGHLIGHT_WORDS_AFTERTRANS="highlight_aftertrans";const OPT_HIGHLIGHT_WORDS_ALL=[OPT_HIGHLIGHT_WORDS_DISABLE,OPT_HIGHLIGHT_WORDS_BEFORETRANS,OPT_HIGHLIGHT_WORDS_AFTERTRANS];const DEFAULT_SELECTOR="h1, h2, h3, h4, h5, h6, li, p, dd, blockquote, figcaption, label, legend";const DEFAULT_IGNORE_SELECTOR="button, footer, pre, mark, nav";const DEFAULT_KEEP_SELECTOR="code, cite, math, .math, a:has(code)";const DEFAULT_RULE={pattern:"",// 匹配网址
|
const OPT_TIMING_MOUSEOVER="mk_mouseover";const OPT_TIMING_CONTROL="mk_ctrlKey";const OPT_TIMING_SHIFT="mk_shiftKey";const OPT_TIMING_ALT="mk_altKey";const OPT_TIMING_ALL=[OPT_TIMING_PAGESCROLL,OPT_TIMING_PAGEOPEN,OPT_TIMING_MOUSEOVER,OPT_TIMING_CONTROL,OPT_TIMING_SHIFT,OPT_TIMING_ALT];const OPT_SPLIT_PARAGRAPH_DISABLE="split_disable";const OPT_SPLIT_PARAGRAPH_TEXTLENGTH="split_textlength";const OPT_SPLIT_PARAGRAPH_PUNCTUATION="split_punctuation";const OPT_SPLIT_PARAGRAPH_ALL=[OPT_SPLIT_PARAGRAPH_DISABLE,OPT_SPLIT_PARAGRAPH_PUNCTUATION,OPT_SPLIT_PARAGRAPH_TEXTLENGTH];const OPT_HIGHLIGHT_WORDS_DISABLE="highlight_disable";const OPT_HIGHLIGHT_WORDS_BEFORETRANS="highlight_beforetrans";const OPT_HIGHLIGHT_WORDS_AFTERTRANS="highlight_aftertrans";const OPT_HIGHLIGHT_WORDS_ALL=[OPT_HIGHLIGHT_WORDS_DISABLE,OPT_HIGHLIGHT_WORDS_BEFORETRANS,OPT_HIGHLIGHT_WORDS_AFTERTRANS];const DEFAULT_SELECTOR="h1, h2, h3, h4, h5, h6, li, p, dd, blockquote, figcaption, label, legend";const DEFAULT_IGNORE_SELECTOR="button, footer, pre, mark, nav";const DEFAULT_KEEP_SELECTOR="code, cite, math, .math, a:has(code)";const DEFAULT_RULE={pattern:"",// 匹配网址
|
||||||
selector:"",// 选择器
|
selector:"",// 选择器
|
||||||
@@ -35048,7 +35046,7 @@ transOpen:"false",// 开启翻译
|
|||||||
textExtStyle:"",// 译文附加样式
|
textExtStyle:"",// 译文附加样式
|
||||||
termsStyle:"font-weight: bold;",// 专业术语样式
|
termsStyle:"font-weight: bold;",// 专业术语样式
|
||||||
highlightStyle:"color: red;",// 高亮词汇样式
|
highlightStyle:"color: red;",// 高亮词汇样式
|
||||||
selectStyle:"",// 选择器节点样式
|
selectStyle:DEFAULT_SELECT_STYLE,// 选择器节点样式
|
||||||
parentStyle:"",// 选择器父节点样式
|
parentStyle:"",// 选择器父节点样式
|
||||||
grandStyle:"",// 选择器祖节点样式
|
grandStyle:"",// 选择器祖节点样式
|
||||||
injectJs:"",// 注入JS
|
injectJs:"",// 注入JS
|
||||||
@@ -35217,7 +35215,7 @@ const CLIENT_WEB="web";const CLIENT_CHROME="chrome";const CLIENT_EDGE="edge";con
|
|||||||
;// CONCATENATED MODULE: ./src/config/index.js
|
;// CONCATENATED MODULE: ./src/config/index.js
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ./src/index.js
|
;// CONCATENATED MODULE: ./src/index.js
|
||||||
function App(){var _I18N$about_md;const[lang,setLang]=(0,react.useState)("zh");const{data,loading,error}=useGet("".concat(URL_RAW_PREFIX,"/").concat(I18N===null||I18N===void 0?void 0:(_I18N$about_md=I18N["about_md"])===null||_I18N$about_md===void 0?void 0:_I18N$about_md[lang]));return/*#__PURE__*/(0,jsx_runtime.jsxs)(Paper_Paper,{sx:{padding:2,margin:2},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Stack_Stack,{spacing:2,direction:"row",justifyContent:"flex-end",children:/*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button,{variant:"text",onClick:()=>{setLang(pre=>pre==="zh"?"en":"zh");},children:lang==="zh"?"ENGLISH":"中文"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.11")})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator.user.js",children:"Install/Update Userscript for Tampermonkey/Violentmonkey"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js",children:"Install/Update Userscript for iOS Safari"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/options.html",children:"Open Options Page"})]}),loading?/*#__PURE__*/(0,jsx_runtime.jsx)("center",{children:/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})}):/*#__PURE__*/(0,jsx_runtime.jsx)(ReactMarkdown,{children:error||data})]});}const src_root=client.createRoot(document.getElementById("root"));src_root.render(/*#__PURE__*/(0,jsx_runtime.jsx)(react.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(App,{})}));
|
function App(){var _I18N$about_md;const[lang,setLang]=(0,react.useState)("zh");const{data,loading,error}=useGet("".concat(URL_RAW_PREFIX,"/").concat(I18N===null||I18N===void 0?void 0:(_I18N$about_md=I18N["about_md"])===null||_I18N$about_md===void 0?void 0:_I18N$about_md[lang]));return/*#__PURE__*/(0,jsx_runtime.jsxs)(Paper_Paper,{sx:{padding:2,margin:2},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Stack_Stack,{spacing:2,direction:"row",justifyContent:"flex-end",children:/*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button,{variant:"text",onClick:()=>{setLang(pre=>pre==="zh"?"en":"zh");},children:lang==="zh"?"ENGLISH":"中文"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.12")})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator.user.js",children:"Install/Update Userscript for Tampermonkey/Violentmonkey"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js",children:"Install/Update Userscript for iOS Safari"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/options.html",children:"Open Options Page"})]}),loading?/*#__PURE__*/(0,jsx_runtime.jsx)("center",{children:/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})}):/*#__PURE__*/(0,jsx_runtime.jsx)(ReactMarkdown,{children:error||data})]});}const src_root=client.createRoot(document.getElementById("root"));src_root.render(/*#__PURE__*/(0,jsx_runtime.jsx)(react.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(App,{})}));
|
||||||
})();
|
})();
|
||||||
|
|
||||||
/******/ })()
|
/******/ })()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "__MSG_app_name__",
|
"name": "__MSG_app_name__",
|
||||||
"description": "__MSG_app_description__",
|
"description": "__MSG_app_description__",
|
||||||
"version": "2.0.11",
|
"version": "2.0.12",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"author": "Gabe<yugang2002@gmail.com>",
|
"author": "Gabe<yugang2002@gmail.com>",
|
||||||
"homepage_url": "https://github.com/fishjar/kiss-translator",
|
"homepage_url": "https://github.com/fishjar/kiss-translator",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "__MSG_app_name__",
|
"name": "__MSG_app_name__",
|
||||||
"description": "__MSG_app_description__",
|
"description": "__MSG_app_description__",
|
||||||
"version": "2.0.11",
|
"version": "2.0.12",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"author": "Gabe<yugang2002@gmail.com>",
|
"author": "Gabe<yugang2002@gmail.com>",
|
||||||
"homepage_url": "https://github.com/fishjar/kiss-translator",
|
"homepage_url": "https://github.com/fishjar/kiss-translator",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "__MSG_app_name__",
|
"name": "__MSG_app_name__",
|
||||||
"description": "__MSG_app_description__",
|
"description": "__MSG_app_description__",
|
||||||
"version": "2.0.11",
|
"version": "2.0.12",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"author": "Gabe<yugang2002@gmail.com>",
|
"author": "Gabe<yugang2002@gmail.com>",
|
||||||
"homepage_url": "https://github.com/fishjar/kiss-translator",
|
"homepage_url": "https://github.com/fishjar/kiss-translator",
|
||||||
|
|||||||
77
options.js
77
options.js
@@ -55599,7 +55599,7 @@ const Alert = /*#__PURE__*/react.forwardRef(function Alert(inProps, ref) {
|
|||||||
false ? 0 : void 0;
|
false ? 0 : void 0;
|
||||||
/* harmony default export */ const Alert_Alert = (Alert);
|
/* harmony default export */ const Alert_Alert = (Alert);
|
||||||
;// CONCATENATED MODULE: ./src/config/app.js
|
;// CONCATENATED MODULE: ./src/config/app.js
|
||||||
const APP_NAME="KISS Translator".trim().split(/\s+/).join("-");const APP_LCNAME=APP_NAME.toLowerCase();const APP_UPNAME=APP_NAME.toUpperCase();const APP_CONSTS={fabID:"".concat(APP_LCNAME,"-fab"),boxID:"".concat(APP_LCNAME,"-box"),popupID:"".concat(APP_LCNAME,"-popup")};const APP_VERSION="2.0.11".split(".");const THEME_LIGHT="light";const THEME_DARK="dark";
|
const APP_NAME="KISS Translator".trim().split(/\s+/).join("-");const APP_LCNAME=APP_NAME.toLowerCase();const APP_UPNAME=APP_NAME.toUpperCase();const APP_CONSTS={fabID:"".concat(APP_LCNAME,"-fab"),boxID:"".concat(APP_LCNAME,"-box"),popupID:"".concat(APP_LCNAME,"-popup")};const APP_VERSION="2.0.12".split(".");const THEME_LIGHT="light";const THEME_DARK="dark";
|
||||||
;// CONCATENATED MODULE: ./src/config/api.js
|
;// CONCATENATED MODULE: ./src/config/api.js
|
||||||
const DEFAULT_HTTP_TIMEOUT=10000;// 调用超时时间
|
const DEFAULT_HTTP_TIMEOUT=10000;// 调用超时时间
|
||||||
const DEFAULT_FETCH_LIMIT=10;// 默认最大任务数量
|
const DEFAULT_FETCH_LIMIT=10;// 默认最大任务数量
|
||||||
@@ -55706,9 +55706,7 @@ const OPT_STYLE_COLORFUL="colorful";// 多彩
|
|||||||
const OPT_STYLE_ALL=[OPT_STYLE_NONE,OPT_STYLE_LINE,OPT_STYLE_DOTLINE,OPT_STYLE_DASHLINE,OPT_STYLE_DASHLINE_BOLD,OPT_STYLE_WAVYLINE,OPT_STYLE_WAVYLINE_BOLD,OPT_STYLE_DASHBOX,OPT_STYLE_DASHBOX_BOLD,OPT_STYLE_MARKER,OPT_STYLE_GRADIENT_MARKER,OPT_STYLE_FUZZY,OPT_STYLE_HIGHLIGHT,OPT_STYLE_BLOCKQUOTE,OPT_STYLE_GRADIENT,OPT_STYLE_BLINK,OPT_STYLE_GLOW,OPT_STYLE_COLORFUL];const DEFAULT_CUSTOM_STYLES=[{styleSlug:"custom",styleName:"Custom Style",styleCode:"color: #209CEE;"}];
|
const OPT_STYLE_ALL=[OPT_STYLE_NONE,OPT_STYLE_LINE,OPT_STYLE_DOTLINE,OPT_STYLE_DASHLINE,OPT_STYLE_DASHLINE_BOLD,OPT_STYLE_WAVYLINE,OPT_STYLE_WAVYLINE_BOLD,OPT_STYLE_DASHBOX,OPT_STYLE_DASHBOX_BOLD,OPT_STYLE_MARKER,OPT_STYLE_GRADIENT_MARKER,OPT_STYLE_FUZZY,OPT_STYLE_HIGHLIGHT,OPT_STYLE_BLOCKQUOTE,OPT_STYLE_GRADIENT,OPT_STYLE_BLINK,OPT_STYLE_GLOW,OPT_STYLE_COLORFUL];const DEFAULT_CUSTOM_STYLES=[{styleSlug:"custom",styleName:"Custom Style",styleCode:"color: #209CEE;"}];
|
||||||
;// CONCATENATED MODULE: ./src/config/rules.js
|
;// CONCATENATED MODULE: ./src/config/rules.js
|
||||||
const rules_GLOBAL_KEY="*";const REMAIN_KEY="-";const SHADOW_KEY=">>>";const DEFAULT_COLOR="#209CEE";// 默认高亮背景色/线条颜色
|
const rules_GLOBAL_KEY="*";const REMAIN_KEY="-";const SHADOW_KEY=">>>";const DEFAULT_COLOR="#209CEE";// 默认高亮背景色/线条颜色
|
||||||
const DEFAULT_TRANS_TAG="font";// export const DEFAULT_SELECT_STYLE =
|
const DEFAULT_TRANS_TAG="font";const DEFAULT_SELECT_STYLE="-webkit-line-clamp: unset; max-height: none; height: auto;";const OPT_TIMING_PAGESCROLL="mk_pagescroll";// 滚动加载翻译
|
||||||
// "-webkit-line-clamp: unset; max-height: none; height: auto;";
|
|
||||||
const OPT_TIMING_PAGESCROLL="mk_pagescroll";// 滚动加载翻译
|
|
||||||
const OPT_TIMING_PAGEOPEN="mk_pageopen";// 直接翻译到底
|
const OPT_TIMING_PAGEOPEN="mk_pageopen";// 直接翻译到底
|
||||||
const OPT_TIMING_MOUSEOVER="mk_mouseover";const OPT_TIMING_CONTROL="mk_ctrlKey";const OPT_TIMING_SHIFT="mk_shiftKey";const OPT_TIMING_ALT="mk_altKey";const OPT_TIMING_ALL=[OPT_TIMING_PAGESCROLL,OPT_TIMING_PAGEOPEN,OPT_TIMING_MOUSEOVER,OPT_TIMING_CONTROL,OPT_TIMING_SHIFT,OPT_TIMING_ALT];const OPT_SPLIT_PARAGRAPH_DISABLE="split_disable";const OPT_SPLIT_PARAGRAPH_TEXTLENGTH="split_textlength";const OPT_SPLIT_PARAGRAPH_PUNCTUATION="split_punctuation";const OPT_SPLIT_PARAGRAPH_ALL=[OPT_SPLIT_PARAGRAPH_DISABLE,OPT_SPLIT_PARAGRAPH_PUNCTUATION,OPT_SPLIT_PARAGRAPH_TEXTLENGTH];const OPT_HIGHLIGHT_WORDS_DISABLE="highlight_disable";const OPT_HIGHLIGHT_WORDS_BEFORETRANS="highlight_beforetrans";const OPT_HIGHLIGHT_WORDS_AFTERTRANS="highlight_aftertrans";const OPT_HIGHLIGHT_WORDS_ALL=[OPT_HIGHLIGHT_WORDS_DISABLE,OPT_HIGHLIGHT_WORDS_BEFORETRANS,OPT_HIGHLIGHT_WORDS_AFTERTRANS];const DEFAULT_SELECTOR="h1, h2, h3, h4, h5, h6, li, p, dd, blockquote, figcaption, label, legend";const DEFAULT_IGNORE_SELECTOR="button, footer, pre, mark, nav";const DEFAULT_KEEP_SELECTOR="code, cite, math, .math, a:has(code)";const rules_DEFAULT_RULE={pattern:"",// 匹配网址
|
const OPT_TIMING_MOUSEOVER="mk_mouseover";const OPT_TIMING_CONTROL="mk_ctrlKey";const OPT_TIMING_SHIFT="mk_shiftKey";const OPT_TIMING_ALT="mk_altKey";const OPT_TIMING_ALL=[OPT_TIMING_PAGESCROLL,OPT_TIMING_PAGEOPEN,OPT_TIMING_MOUSEOVER,OPT_TIMING_CONTROL,OPT_TIMING_SHIFT,OPT_TIMING_ALT];const OPT_SPLIT_PARAGRAPH_DISABLE="split_disable";const OPT_SPLIT_PARAGRAPH_TEXTLENGTH="split_textlength";const OPT_SPLIT_PARAGRAPH_PUNCTUATION="split_punctuation";const OPT_SPLIT_PARAGRAPH_ALL=[OPT_SPLIT_PARAGRAPH_DISABLE,OPT_SPLIT_PARAGRAPH_PUNCTUATION,OPT_SPLIT_PARAGRAPH_TEXTLENGTH];const OPT_HIGHLIGHT_WORDS_DISABLE="highlight_disable";const OPT_HIGHLIGHT_WORDS_BEFORETRANS="highlight_beforetrans";const OPT_HIGHLIGHT_WORDS_AFTERTRANS="highlight_aftertrans";const OPT_HIGHLIGHT_WORDS_ALL=[OPT_HIGHLIGHT_WORDS_DISABLE,OPT_HIGHLIGHT_WORDS_BEFORETRANS,OPT_HIGHLIGHT_WORDS_AFTERTRANS];const DEFAULT_SELECTOR="h1, h2, h3, h4, h5, h6, li, p, dd, blockquote, figcaption, label, legend";const DEFAULT_IGNORE_SELECTOR="button, footer, pre, mark, nav";const DEFAULT_KEEP_SELECTOR="code, cite, math, .math, a:has(code)";const rules_DEFAULT_RULE={pattern:"",// 匹配网址
|
||||||
selector:"",// 选择器
|
selector:"",// 选择器
|
||||||
@@ -55766,7 +55764,7 @@ transOpen:"false",// 开启翻译
|
|||||||
textExtStyle:"",// 译文附加样式
|
textExtStyle:"",// 译文附加样式
|
||||||
termsStyle:"font-weight: bold;",// 专业术语样式
|
termsStyle:"font-weight: bold;",// 专业术语样式
|
||||||
highlightStyle:"color: red;",// 高亮词汇样式
|
highlightStyle:"color: red;",// 高亮词汇样式
|
||||||
selectStyle:"",// 选择器节点样式
|
selectStyle:DEFAULT_SELECT_STYLE,// 选择器节点样式
|
||||||
parentStyle:"",// 选择器父节点样式
|
parentStyle:"",// 选择器父节点样式
|
||||||
grandStyle:"",// 选择器祖节点样式
|
grandStyle:"",// 选择器祖节点样式
|
||||||
injectJs:"",// 注入JS
|
injectJs:"",// 注入JS
|
||||||
@@ -55946,7 +55944,19 @@ const client_client="userscript";const client_isExt=CLIENT_EXTS.includes(client_
|
|||||||
* 浏览器兼容插件,另可用于判断是插件模式还是网页模式,方便开发
|
* 浏览器兼容插件,另可用于判断是插件模式还是网页模式,方便开发
|
||||||
* @returns
|
* @returns
|
||||||
*/function _browser(){try{return __webpack_require__(2465);}catch(err){// kissLog("browser", err);
|
*/function _browser(){try{return __webpack_require__(2465);}catch(err){// kissLog("browser", err);
|
||||||
}}const browser_browser=_browser();const browser_isBg=()=>(globalThis===null||globalThis===void 0?void 0:globalThis.ContextType)==="BACKGROUND";const isBuiltinAIAvailable="LanguageDetector"in globalThis&&"Translator"in globalThis;
|
}}const browser_browser=_browser();const getContext=()=>{const context=globalThis.__KISS_CONTEXT__;if(context)return context;// if (typeof window === "undefined" || typeof document === "undefined") {
|
||||||
|
// return "background";
|
||||||
|
// }
|
||||||
|
// const extensionOrigin = browser.runtime.getURL("");
|
||||||
|
// if (!window.location.href.startsWith(extensionOrigin)) {
|
||||||
|
// return "content";
|
||||||
|
// }
|
||||||
|
// const pathname = window.location.pathname;
|
||||||
|
// if (pathname.includes("popup")) return "popup";
|
||||||
|
// if (pathname.includes("options")) return "options";
|
||||||
|
// if (pathname.includes("sidepanel")) return "sidepanel";
|
||||||
|
// if (pathname.includes("background")) return "background";
|
||||||
|
return"undefined";};const browser_isBg=()=>getContext()==="background";const isOptions=()=>getContext()==="options";const isBuiltinAIAvailable="LanguageDetector"in globalThis&&"Translator"in globalThis;
|
||||||
;// CONCATENATED MODULE: ./src/libs/utils.js
|
;// CONCATENATED MODULE: ./src/libs/utils.js
|
||||||
/**
|
/**
|
||||||
* 限制数字大小
|
* 限制数字大小
|
||||||
@@ -56698,7 +56708,7 @@ _classPrivateFieldBase(this,_scheduleNext)[_scheduleNext]();},_classPrivateField
|
|||||||
;// CONCATENATED MODULE: ./src/libs/cache.js
|
;// CONCATENATED MODULE: ./src/libs/cache.js
|
||||||
/**
|
/**
|
||||||
* 清除缓存数据
|
* 清除缓存数据
|
||||||
*/const tryClearCaches=async()=>{try{if(isExt&&!isBg){await sendBgMsg(MSG_CLEAR_CACHES);}else{await caches.delete(CACHE_NAME);}}catch(err){kissLog("clean caches",err);}};/**
|
*/const tryClearCaches=async()=>{try{if(isExt&&!isBg()){await sendBgMsg(MSG_CLEAR_CACHES);}else{await caches.delete(CACHE_NAME);}}catch(err){kissLog("clean caches",err);}};/**
|
||||||
* 构造缓存 request
|
* 构造缓存 request
|
||||||
* @param {*} input
|
* @param {*} input
|
||||||
* @param {*} init
|
* @param {*} init
|
||||||
@@ -56708,7 +56718,7 @@ _classPrivateFieldBase(this,_scheduleNext)[_scheduleNext]();},_classPrivateField
|
|||||||
* @param {*} input
|
* @param {*} input
|
||||||
* @param {*} init
|
* @param {*} init
|
||||||
* @returns
|
* @returns
|
||||||
*/const getHttpCache=async _ref=>{let{input,init}=_ref;try{const request=await newCacheReq(input,init);const cache=await caches.open(storage_CACHE_NAME);const response=await cache.match(request);if(response){const res=await parseResponse(response);return res;}}catch(err){log_kissLog("get cache",err);}return null;};/**
|
*/const getHttpCache=async _ref=>{let{input,init,expect}=_ref;try{const request=await newCacheReq(input,init);const cache=await caches.open(storage_CACHE_NAME);const response=await cache.match(request);if(response){const res=await parseResponse(response,expect);return res;}}catch(err){log_kissLog("get cache",err);}return null;};/**
|
||||||
* 插入 caches
|
* 插入 caches
|
||||||
* @param {*} input
|
* @param {*} input
|
||||||
* @param {*} init
|
* @param {*} init
|
||||||
@@ -56719,7 +56729,7 @@ await cache.put(req,res);}catch(err){log_kissLog("put cache",err);}};/**
|
|||||||
* 解析 response
|
* 解析 response
|
||||||
* @param {*} res
|
* @param {*} res
|
||||||
* @returns
|
* @returns
|
||||||
*/const parseResponse=async res=>{if(!res){throw new Error("Response object does not exist");}if(!res.ok){var _res$headers$get;const msg={url:res.url,status:res.status};if((_res$headers$get=res.headers.get("Content-Type"))!==null&&_res$headers$get!==void 0&&_res$headers$get.includes("json")){msg.response=await res.json();}throw new Error(JSON.stringify(msg));}const contentType=res.headers.get("Content-Type");if(contentType!==null&&contentType!==void 0&&contentType.includes("json")){return res.json();}else if(contentType!==null&&contentType!==void 0&&contentType.includes("audio")){const blob=await res.blob();return blobToBase64(blob);}return res.text();};/**
|
*/const parseResponse=async function(res){let expect=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(!res){throw new Error("Response object does not exist");}if(!res.ok){const msg={url:res.url,status:res.status,statusText:res.statusText};try{const errorText=await res.clone().text();try{msg.response=JSON.parse(errorText);}catch(_unused){msg.response=errorText;}}catch(e){msg.response="Unable to read error body";}throw new Error(JSON.stringify(msg));}const contentType=res.headers.get("Content-Type")||"";if(expect==="blob")return res.blob();if(expect==="text")return res.text();if(expect==="json")return res.json();if(expect==="audio"||contentType.includes("audio")||contentType.includes("image")||contentType.includes("video")){const blob=await res.blob();return blobToBase64(blob);}const text=await res.text();if(!text)return null;try{return JSON.parse(text);}catch(err){return text;}};/**
|
||||||
* getHttpCache 兼容性封装
|
* getHttpCache 兼容性封装
|
||||||
* @param {*} input
|
* @param {*} input
|
||||||
* @param {*} init
|
* @param {*} init
|
||||||
@@ -56753,7 +56763,7 @@ Object.assign(init,{timeout});const{body,headers,status,statusText}=window.KISS_
|
|||||||
* 处理请求
|
* 处理请求
|
||||||
* @param {*} param0
|
* @param {*} param0
|
||||||
* @returns
|
* @returns
|
||||||
*/const fetchHandle=async _ref2=>{let{input,init,opts}=_ref2;const res=await fetchPatcher(input,init,opts);return parseResponse(res);};/**
|
*/const fetchHandle=async _ref2=>{let{input,init,opts}=_ref2;const res=await fetchPatcher(input,init,opts);return parseResponse(res,opts.expect);};/**
|
||||||
* fetch 兼容性封装
|
* fetch 兼容性封装
|
||||||
* @param {*} args
|
* @param {*} args
|
||||||
* @returns
|
* @returns
|
||||||
@@ -56824,14 +56834,14 @@ stream:false};const headers={"Content-type":"application/json"};if(key){headers.
|
|||||||
*/const genTransReq=async _ref21=>{let{reqHook}=_ref21,args=_objectWithoutProperties(_ref21,trans_excluded);const{apiType,apiSlug,key,systemPrompt,// userPrompt,
|
*/const genTransReq=async _ref21=>{let{reqHook}=_ref21,args=_objectWithoutProperties(_ref21,trans_excluded);const{apiType,apiSlug,key,systemPrompt,// userPrompt,
|
||||||
nobatchPrompt=defaultNobatchPrompt,nobatchUserPrompt=defaultNobatchUserPrompt,useBatchFetch,from,to,fromLang,toLang,texts,docInfo,glossary,customHeader,customBody,events,tone}=args;if(API_SPE_TYPES.mulkeys.has(apiType)){args.key=keyPick(apiSlug,key,keyMap);}if(apiType===OPT_TRANS_DEEPLX){args.url=keyPick(apiSlug,args.url,urlMap);}if(API_SPE_TYPES.ai.has(apiType)){args.systemPrompt=events?systemPrompt:genSystemPrompt({systemPrompt:useBatchFetch?systemPrompt:nobatchPrompt,from,to,fromLang,toLang,texts,docInfo,tone});args.userPrompt=events?JSON.stringify(events):genUserPrompt({nobatchUserPrompt,useBatchFetch,from,to,fromLang,toLang,texts,docInfo,tone,glossary});}const{url="",body=null,headers={},userMsg=null,method="POST"}=genReqFuncs[apiType](args);// 合并用户自定义headers和body
|
nobatchPrompt=defaultNobatchPrompt,nobatchUserPrompt=defaultNobatchUserPrompt,useBatchFetch,from,to,fromLang,toLang,texts,docInfo,glossary,customHeader,customBody,events,tone}=args;if(API_SPE_TYPES.mulkeys.has(apiType)){args.key=keyPick(apiSlug,key,keyMap);}if(apiType===OPT_TRANS_DEEPLX){args.url=keyPick(apiSlug,args.url,urlMap);}if(API_SPE_TYPES.ai.has(apiType)){args.systemPrompt=events?systemPrompt:genSystemPrompt({systemPrompt:useBatchFetch?systemPrompt:nobatchPrompt,from,to,fromLang,toLang,texts,docInfo,tone});args.userPrompt=events?JSON.stringify(events):genUserPrompt({nobatchUserPrompt,useBatchFetch,from,to,fromLang,toLang,texts,docInfo,tone,glossary});}const{url="",body=null,headers={},userMsg=null,method="POST"}=genReqFuncs[apiType](args);// 合并用户自定义headers和body
|
||||||
if(customHeader!==null&&customHeader!==void 0&&customHeader.trim()){Object.assign(headers,parseJsonObj(customHeader));}if(customBody!==null&&customBody!==void 0&&customBody.trim()){Object.assign(body,parseJsonObj(customBody));}// 执行 request hook
|
if(customHeader!==null&&customHeader!==void 0&&customHeader.trim()){Object.assign(headers,parseJsonObj(customHeader));}if(customBody!==null&&customBody!==void 0&&customBody.trim()){Object.assign(body,parseJsonObj(customBody));}// 执行 request hook
|
||||||
if(reqHook!==null&&reqHook!==void 0&&reqHook.trim()&&!events){try{interpreter.run("exports.reqHook = ".concat(reqHook));const hookResult=await interpreter.exports.reqHook(_objectSpread2(_objectSpread2({},args),{},{defaultSystemPrompt: defaultSystemPrompt,defaultSubtitlePrompt: defaultSubtitlePrompt,defaultNobatchPrompt: defaultNobatchPrompt,defaultNobatchUserPrompt: defaultNobatchUserPrompt}),{url,body,headers,userMsg,method});if(hookResult&&hookResult.url){return genInit(hookResult);}}catch(err){log_kissLog("run req hook",err);}}return genInit({url,body,headers,userMsg,method});};/**
|
if(reqHook!==null&&reqHook!==void 0&&reqHook.trim()&&!events){try{const req={url,body,headers,userMsg,method};interpreter.run("exports.reqHook = ".concat(reqHook));const hookResult=await interpreter.exports.reqHook(_objectSpread2(_objectSpread2({},args),{},{defaultSystemPrompt: defaultSystemPrompt,defaultSubtitlePrompt: defaultSubtitlePrompt,defaultNobatchPrompt: defaultNobatchPrompt,defaultNobatchUserPrompt: defaultNobatchUserPrompt,req}),req);if(hookResult&&hookResult.url){return genInit(hookResult);}}catch(err){log_kissLog("run req hook",err);throw new Error("Request hook error: ".concat(err.message));}}return genInit({url,body,headers,userMsg,method});};/**
|
||||||
* 解析翻译接口返回数据
|
* 解析翻译接口返回数据
|
||||||
* @param {*} res
|
* @param {*} res
|
||||||
* @param {*} param3
|
* @param {*} param3
|
||||||
* @returns
|
* @returns
|
||||||
*/const parseTransRes=async(res,_ref22)=>{var _res$sentences,_res$,_res$translations,_res$result,_res$result$texts,_res$result2,_res$auto_translation,_res$choices,_res$choices$,_modelMsg,_res$candidates,_res$candidates$,_modelMsg$parts$0$tex,_modelMsg2,_modelMsg2$parts,_modelMsg2$parts$,_res$content,_res$content$0$text,_res$content2,_res$content2$,_res$result3,_res$choices2,_res$choices2$,_modelMsg3;let{texts,from,to,fromLang,toLang,langMap,resHook,// thinkIgnore,
|
*/const parseTransRes=async(res,_ref22)=>{var _res$sentences,_res$,_res$translations,_res$result,_res$result$texts,_res$result2,_res$auto_translation,_res$choices,_res$choices$,_modelMsg,_res$candidates,_res$candidates$,_modelMsg$parts$0$tex,_modelMsg2,_modelMsg2$parts,_modelMsg2$parts$,_res$content,_res$content$0$text,_res$content2,_res$content2$,_res$result3,_res$choices2,_res$choices2$,_modelMsg3;let{texts,from,to,fromLang,toLang,langMap,resHook,// thinkIgnore,
|
||||||
history,userMsg,apiType,useBatchFetch}=_ref22;// 执行 response hook
|
history,userMsg,apiType,useBatchFetch}=_ref22;// 执行 response hook
|
||||||
if(resHook!==null&&resHook!==void 0&&resHook.trim()){try{interpreter.run("exports.resHook = ".concat(resHook));const hookResult=await interpreter.exports.resHook({apiType,userMsg,res,texts,from,to,fromLang,toLang,langMap,extractJson: extractJson,parseAIRes});if(hookResult&&Array.isArray(hookResult.translations)){if(history&&userMsg&&hookResult.modelMsg){history.add(userMsg,hookResult.modelMsg);}return hookResult.translations;}else if(Array.isArray(hookResult)){return hookResult;}}catch(err){log_kissLog("run res hook",err);}}let modelMsg="";// todo: 根据结果抛出实际异常信息
|
if(resHook!==null&&resHook!==void 0&&resHook.trim()){try{interpreter.run("exports.resHook = ".concat(resHook));const hookResult=await interpreter.exports.resHook({apiType,userMsg,res,texts,from,to,fromLang,toLang,langMap,extractJson: extractJson,parseAIRes});if(hookResult&&Array.isArray(hookResult.translations)){if(history&&userMsg&&hookResult.modelMsg){history.add(userMsg,hookResult.modelMsg);}return hookResult.translations;}else if(Array.isArray(hookResult)){return hookResult;}}catch(err){log_kissLog("run res hook",err);throw new Error("Response hook error: ".concat(err.message));}}let modelMsg="";// todo: 根据结果抛出实际异常信息
|
||||||
switch(apiType){case OPT_TRANS_GOOGLE:return[[res===null||res===void 0?void 0:(_res$sentences=res.sentences)===null||_res$sentences===void 0?void 0:_res$sentences.map(item=>item.trans).join(" "),res===null||res===void 0?void 0:res.src]];case OPT_TRANS_GOOGLE_2:return res===null||res===void 0?void 0:(_res$=res[0])===null||_res$===void 0?void 0:_res$.map((_,i)=>{var _res$2,_res$3;return[res===null||res===void 0?void 0:(_res$2=res[0])===null||_res$2===void 0?void 0:_res$2[i],res===null||res===void 0?void 0:(_res$3=res[1])===null||_res$3===void 0?void 0:_res$3[i]];});case OPT_TRANS_MICROSOFT:case OPT_TRANS_AZUREAI:return res===null||res===void 0?void 0:res.map(item=>{var _item$detectedLanguag;return[item.translations.map(item=>item.text).join(" "),(_item$detectedLanguag=item.detectedLanguage)===null||_item$detectedLanguag===void 0?void 0:_item$detectedLanguag.language];});case OPT_TRANS_DEEPL:return res===null||res===void 0?void 0:(_res$translations=res.translations)===null||_res$translations===void 0?void 0:_res$translations.map(item=>[item.text,item.detected_source_language]);case OPT_TRANS_DEEPLFREE:return[[res===null||res===void 0?void 0:(_res$result=res.result)===null||_res$result===void 0?void 0:(_res$result$texts=_res$result.texts)===null||_res$result$texts===void 0?void 0:_res$result$texts.map(item=>item.text).join(" "),res===null||res===void 0?void 0:(_res$result2=res.result)===null||_res$result2===void 0?void 0:_res$result2.lang]];case OPT_TRANS_DEEPLX:return[[res===null||res===void 0?void 0:res.data,res===null||res===void 0?void 0:res.source_lang]];case OPT_TRANS_NIUTRANS:const json=JSON.parse(res);if(json.error_msg){throw new Error(json.error_msg);}return[[json.tgt_text,json.from]];case OPT_TRANS_BAIDU:if(res.type===1){return[[Object.keys(JSON.parse(res.result).content[0].mean[0].cont)[0],res.from]];}else if(res.type===2){return[[res.data.map(item=>item.dst).join(" "),res.from]];}break;case OPT_TRANS_TENCENT:return res===null||res===void 0?void 0:(_res$auto_translation=res.auto_translation)===null||_res$auto_translation===void 0?void 0:_res$auto_translation.map(text=>[text,res===null||res===void 0?void 0:res.src_lang]);case OPT_TRANS_VOLCENGINE:return[[res===null||res===void 0?void 0:res.translation,res===null||res===void 0?void 0:res.detected_language]];case api_OPT_TRANS_OPENAI:case api_OPT_TRANS_GEMINI_2:case api_OPT_TRANS_OPENROUTER:modelMsg=res===null||res===void 0?void 0:(_res$choices=res.choices)===null||_res$choices===void 0?void 0:(_res$choices$=_res$choices[0])===null||_res$choices$===void 0?void 0:_res$choices$.message;if(history&&userMsg&&modelMsg){history.add(userMsg,{role:modelMsg.role,content:modelMsg.content});}return parseAIRes((_modelMsg=modelMsg)===null||_modelMsg===void 0?void 0:_modelMsg.content,useBatchFetch);case api_OPT_TRANS_GEMINI:modelMsg=res===null||res===void 0?void 0:(_res$candidates=res.candidates)===null||_res$candidates===void 0?void 0:(_res$candidates$=_res$candidates[0])===null||_res$candidates$===void 0?void 0:_res$candidates$.content;if(history&&userMsg&&modelMsg){history.add(userMsg,modelMsg);}return parseAIRes((_modelMsg$parts$0$tex=(_modelMsg2=modelMsg)===null||_modelMsg2===void 0?void 0:(_modelMsg2$parts=_modelMsg2.parts)===null||_modelMsg2$parts===void 0?void 0:(_modelMsg2$parts$=_modelMsg2$parts[0])===null||_modelMsg2$parts$===void 0?void 0:_modelMsg2$parts$.text)!==null&&_modelMsg$parts$0$tex!==void 0?_modelMsg$parts$0$tex:"",useBatchFetch);case api_OPT_TRANS_CLAUDE:modelMsg={role:res===null||res===void 0?void 0:res.role,content:res===null||res===void 0?void 0:(_res$content=res.content)===null||_res$content===void 0?void 0:_res$content.text};if(history&&userMsg&&modelMsg){history.add(userMsg,{role:modelMsg.role,content:modelMsg.content});}return parseAIRes((_res$content$0$text=res===null||res===void 0?void 0:(_res$content2=res.content)===null||_res$content2===void 0?void 0:(_res$content2$=_res$content2[0])===null||_res$content2$===void 0?void 0:_res$content2$.text)!==null&&_res$content$0$text!==void 0?_res$content$0$text:"",useBatchFetch);case OPT_TRANS_CLOUDFLAREAI:return[[res===null||res===void 0?void 0:(_res$result3=res.result)===null||_res$result3===void 0?void 0:_res$result3.translated_text]];case api_OPT_TRANS_OLLAMA:modelMsg=res===null||res===void 0?void 0:(_res$choices2=res.choices)===null||_res$choices2===void 0?void 0:(_res$choices2$=_res$choices2[0])===null||_res$choices2$===void 0?void 0:_res$choices2$.message;// const deepModels = thinkIgnore
|
switch(apiType){case OPT_TRANS_GOOGLE:return[[res===null||res===void 0?void 0:(_res$sentences=res.sentences)===null||_res$sentences===void 0?void 0:_res$sentences.map(item=>item.trans).join(" "),res===null||res===void 0?void 0:res.src]];case OPT_TRANS_GOOGLE_2:return res===null||res===void 0?void 0:(_res$=res[0])===null||_res$===void 0?void 0:_res$.map((_,i)=>{var _res$2,_res$3;return[res===null||res===void 0?void 0:(_res$2=res[0])===null||_res$2===void 0?void 0:_res$2[i],res===null||res===void 0?void 0:(_res$3=res[1])===null||_res$3===void 0?void 0:_res$3[i]];});case OPT_TRANS_MICROSOFT:case OPT_TRANS_AZUREAI:return res===null||res===void 0?void 0:res.map(item=>{var _item$detectedLanguag;return[item.translations.map(item=>item.text).join(" "),(_item$detectedLanguag=item.detectedLanguage)===null||_item$detectedLanguag===void 0?void 0:_item$detectedLanguag.language];});case OPT_TRANS_DEEPL:return res===null||res===void 0?void 0:(_res$translations=res.translations)===null||_res$translations===void 0?void 0:_res$translations.map(item=>[item.text,item.detected_source_language]);case OPT_TRANS_DEEPLFREE:return[[res===null||res===void 0?void 0:(_res$result=res.result)===null||_res$result===void 0?void 0:(_res$result$texts=_res$result.texts)===null||_res$result$texts===void 0?void 0:_res$result$texts.map(item=>item.text).join(" "),res===null||res===void 0?void 0:(_res$result2=res.result)===null||_res$result2===void 0?void 0:_res$result2.lang]];case OPT_TRANS_DEEPLX:return[[res===null||res===void 0?void 0:res.data,res===null||res===void 0?void 0:res.source_lang]];case OPT_TRANS_NIUTRANS:const json=JSON.parse(res);if(json.error_msg){throw new Error(json.error_msg);}return[[json.tgt_text,json.from]];case OPT_TRANS_BAIDU:if(res.type===1){return[[Object.keys(JSON.parse(res.result).content[0].mean[0].cont)[0],res.from]];}else if(res.type===2){return[[res.data.map(item=>item.dst).join(" "),res.from]];}break;case OPT_TRANS_TENCENT:return res===null||res===void 0?void 0:(_res$auto_translation=res.auto_translation)===null||_res$auto_translation===void 0?void 0:_res$auto_translation.map(text=>[text,res===null||res===void 0?void 0:res.src_lang]);case OPT_TRANS_VOLCENGINE:return[[res===null||res===void 0?void 0:res.translation,res===null||res===void 0?void 0:res.detected_language]];case api_OPT_TRANS_OPENAI:case api_OPT_TRANS_GEMINI_2:case api_OPT_TRANS_OPENROUTER:modelMsg=res===null||res===void 0?void 0:(_res$choices=res.choices)===null||_res$choices===void 0?void 0:(_res$choices$=_res$choices[0])===null||_res$choices$===void 0?void 0:_res$choices$.message;if(history&&userMsg&&modelMsg){history.add(userMsg,{role:modelMsg.role,content:modelMsg.content});}return parseAIRes((_modelMsg=modelMsg)===null||_modelMsg===void 0?void 0:_modelMsg.content,useBatchFetch);case api_OPT_TRANS_GEMINI:modelMsg=res===null||res===void 0?void 0:(_res$candidates=res.candidates)===null||_res$candidates===void 0?void 0:(_res$candidates$=_res$candidates[0])===null||_res$candidates$===void 0?void 0:_res$candidates$.content;if(history&&userMsg&&modelMsg){history.add(userMsg,modelMsg);}return parseAIRes((_modelMsg$parts$0$tex=(_modelMsg2=modelMsg)===null||_modelMsg2===void 0?void 0:(_modelMsg2$parts=_modelMsg2.parts)===null||_modelMsg2$parts===void 0?void 0:(_modelMsg2$parts$=_modelMsg2$parts[0])===null||_modelMsg2$parts$===void 0?void 0:_modelMsg2$parts$.text)!==null&&_modelMsg$parts$0$tex!==void 0?_modelMsg$parts$0$tex:"",useBatchFetch);case api_OPT_TRANS_CLAUDE:modelMsg={role:res===null||res===void 0?void 0:res.role,content:res===null||res===void 0?void 0:(_res$content=res.content)===null||_res$content===void 0?void 0:_res$content.text};if(history&&userMsg&&modelMsg){history.add(userMsg,{role:modelMsg.role,content:modelMsg.content});}return parseAIRes((_res$content$0$text=res===null||res===void 0?void 0:(_res$content2=res.content)===null||_res$content2===void 0?void 0:(_res$content2$=_res$content2[0])===null||_res$content2$===void 0?void 0:_res$content2$.text)!==null&&_res$content$0$text!==void 0?_res$content$0$text:"",useBatchFetch);case OPT_TRANS_CLOUDFLAREAI:return[[res===null||res===void 0?void 0:(_res$result3=res.result)===null||_res$result3===void 0?void 0:_res$result3.translated_text]];case api_OPT_TRANS_OLLAMA:modelMsg=res===null||res===void 0?void 0:(_res$choices2=res.choices)===null||_res$choices2===void 0?void 0:(_res$choices2$=_res$choices2[0])===null||_res$choices2$===void 0?void 0:_res$choices2$.message;// const deepModels = thinkIgnore
|
||||||
// .split(",")
|
// .split(",")
|
||||||
// .filter((model) => model?.trim());
|
// .filter((model) => model?.trim());
|
||||||
@@ -56916,7 +56926,7 @@ keyfrom:"webdict"});const init={headers:{accept:"application/json, text/plain, *
|
|||||||
* @param {*} lan
|
* @param {*} lan
|
||||||
* @param {*} spd
|
* @param {*} spd
|
||||||
* @returns
|
* @returns
|
||||||
*/const apis_apiBaiduTTS=function(text){let lan=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"uk";let spd=arguments.length>2&&arguments[2]!==undefined?arguments[2]:3;const input="https://fanyi.baidu.com/gettts?".concat(queryString.stringify({lan,text,spd}));return fetchData(input);};/**
|
*/const apiBaiduTTS=function(text){let lan=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"uk";let spd=arguments.length>2&&arguments[2]!==undefined?arguments[2]:3;const input="https://fanyi.baidu.com/gettts?".concat(queryString.stringify({lan,text,spd}));return fetchData(input);};/**
|
||||||
* 腾讯语言识别
|
* 腾讯语言识别
|
||||||
* @param {*} text
|
* @param {*} text
|
||||||
* @returns
|
* @returns
|
||||||
@@ -56933,7 +56943,7 @@ keyfrom:"webdict"});const init={headers:{accept:"application/json, text/plain, *
|
|||||||
* @param {*} param0
|
* @param {*} param0
|
||||||
* @returns
|
* @returns
|
||||||
*/const apiTranslate=async _ref2=>{let{text,fromLang="auto",toLang,apiSetting=DEFAULT_API_SETTING,docInfo={},glossary,useCache=true,usePool=true}=_ref2;if(!text){throw new Error("The text cannot be empty.");}const{apiType,apiSlug,useBatchFetch}=apiSetting;const langMap=OPT_LANGS_TO_SPEC[apiType]||OPT_LANGS_SPEC_DEFAULT;const from=langMap.get(fromLang);const to=langMap.get(toLang);if(!to){throw new Error("The target lang: ".concat(toLang," not support"));}// todo: 优化缓存失效因素
|
*/const apiTranslate=async _ref2=>{let{text,fromLang="auto",toLang,apiSetting=DEFAULT_API_SETTING,docInfo={},glossary,useCache=true,usePool=true}=_ref2;if(!text){throw new Error("The text cannot be empty.");}const{apiType,apiSlug,useBatchFetch}=apiSetting;const langMap=OPT_LANGS_TO_SPEC[apiType]||OPT_LANGS_SPEC_DEFAULT;const from=langMap.get(fromLang);const to=langMap.get(toLang);if(!to){throw new Error("The target lang: ".concat(toLang," not support"));}// todo: 优化缓存失效因素
|
||||||
const[v1,v2]="2.0.11".split(".");const cacheOpts={apiSlug,text,fromLang,toLang,version:[v1,v2].join(".")};const cacheInput="".concat(URL_CACHE_TRAN,"?").concat(query_string.stringify(cacheOpts));// 查询缓存数据
|
const[v1,v2]="2.0.12".split(".");const cacheOpts={apiSlug,text,fromLang,toLang,version:[v1,v2].join(".")};const cacheInput="".concat(URL_CACHE_TRAN,"?").concat(query_string.stringify(cacheOpts));// 查询缓存数据
|
||||||
if(useCache){const cache=await cache_getHttpCachePolyfill(cacheInput);if(cache!==null&&cache!==void 0&&cache.trText){return cache;}}// 请求接口数据
|
if(useCache){const cache=await cache_getHttpCachePolyfill(cacheInput);if(cache!==null&&cache!==void 0&&cache.trText){return cache;}}// 请求接口数据
|
||||||
let tranlation=[];if(apiType===OPT_TRANS_BUILTINAI){tranlation=await apiBuiltinAITranslate({text,from,to,apiSetting});}else if(useBatchFetch&&API_SPE_TYPES.batch.has(apiType)){const{apiSlug,batchInterval,batchSize,batchLength}=apiSetting;const key="".concat(apiSlug,"_").concat(fromLang,"_").concat(toLang);const queue=getBatchQueue(key,handleTranslate,{batchInterval,batchSize,batchLength});tranlation=await queue.addTask(text,{from,to,fromLang,toLang,langMap,docInfo,glossary,apiSetting,usePool});}else{[tranlation]=await handleTranslate([text],{from,to,fromLang,toLang,langMap,docInfo,glossary,apiSetting,usePool});}let trText="";let srLang="";let srCode="";if(Array.isArray(tranlation)){[trText,srLang=""]=tranlation;if(srLang){srCode=OPT_LANGS_TO_CODE[apiType].get(srLang)||"";}}else if(typeof tranlation==="string"){trText=tranlation;}if(!trText){throw new Error("tanslate api got empty trtext");}const isSame=fromLang==="auto"&&srLang===to;// 插入缓存
|
let tranlation=[];if(apiType===OPT_TRANS_BUILTINAI){tranlation=await apiBuiltinAITranslate({text,from,to,apiSetting});}else if(useBatchFetch&&API_SPE_TYPES.batch.has(apiType)){const{apiSlug,batchInterval,batchSize,batchLength}=apiSetting;const key="".concat(apiSlug,"_").concat(fromLang,"_").concat(toLang);const queue=getBatchQueue(key,handleTranslate,{batchInterval,batchSize,batchLength});tranlation=await queue.addTask(text,{from,to,fromLang,toLang,langMap,docInfo,glossary,apiSetting,usePool});}else{[tranlation]=await handleTranslate([text],{from,to,fromLang,toLang,langMap,docInfo,glossary,apiSetting,usePool});}let trText="";let srLang="";let srCode="";if(Array.isArray(tranlation)){[trText,srLang=""]=tranlation;if(srLang){srCode=OPT_LANGS_TO_CODE[apiType].get(srLang)||"";}}else if(typeof tranlation==="string"){trText=tranlation;}if(!trText){throw new Error("tanslate api got empty trtext");}const isSame=fromLang==="auto"&&srLang===to;// 插入缓存
|
||||||
if(useCache){cache_putHttpCachePolyfill(cacheInput,null,{trText,isSame,srLang,srCode});}return{trText,srLang,srCode,isSame};};// 字幕处理/翻译
|
if(useCache){cache_putHttpCachePolyfill(cacheInput,null,{trText,isSame,srLang,srCode});}return{trText,srLang,srCode,isSame};};// 字幕处理/翻译
|
||||||
@@ -59750,7 +59760,7 @@ var n = {};
|
|||||||
return t.length === e && "." !== t && ".." !== t;
|
return t.length === e && "." !== t && ".." !== t;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
te = "object" === ("undefined" == typeof process ? "undefined" : Nt(process)) && process ? "object" === Nt(({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"})) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}).__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
te = "object" === ("undefined" == typeof process ? "undefined" : Nt(process)) && process ? "object" === Nt(({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.12","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"})) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.12","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.12","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}).__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
||||||
It.sep = "win32" === te ? "\\" : "/";
|
It.sep = "win32" === te ? "\\" : "/";
|
||||||
var ee = Symbol("globstar **");
|
var ee = Symbol("globstar **");
|
||||||
It.GLOBSTAR = ee;
|
It.GLOBSTAR = ee;
|
||||||
@@ -61567,7 +61577,7 @@ function useDebouncedCallback(callback,delay){const callbackRef=(0,react.useRef)
|
|||||||
(0,react.useEffect)(()=>{let isMounted=true;const loadInitialData=async()=>{try{const storedVal=await storage.getObj(key);if(storedVal===undefined||storedVal===null){await storage.setObj(key,defaultVal);}else if(isMounted){setData(storedVal);}}catch(err){log_kissLog("storage load error for key: ".concat(key),err);}finally{if(isMounted){setIsLoading(false);}}};loadInitialData();return()=>{isMounted=false;};},[key,defaultVal]);// 远端同步
|
(0,react.useEffect)(()=>{let isMounted=true;const loadInitialData=async()=>{try{const storedVal=await storage.getObj(key);if(storedVal===undefined||storedVal===null){await storage.setObj(key,defaultVal);}else if(isMounted){setData(storedVal);}}catch(err){log_kissLog("storage load error for key: ".concat(key),err);}finally{if(isMounted){setIsLoading(false);}}};loadInitialData();return()=>{isMounted=false;};},[key,defaultVal]);// 远端同步
|
||||||
const runSync=(0,react.useCallback)(async(keyToSync,valueToSync)=>{try{const res=await syncData(keyToSync,valueToSync);if(res!==null&&res!==void 0&&res.isNew){setData(res.value);}}catch(error){log_kissLog("Sync failed",keyToSync);}},[]);const debouncedSync=useDebouncedCallback(runSync,3000);// 持久化
|
const runSync=(0,react.useCallback)(async(keyToSync,valueToSync)=>{try{const res=await syncData(keyToSync,valueToSync);if(res!==null&&res!==void 0&&res.isNew){setData(res.value);}}catch(error){log_kissLog("Sync failed",keyToSync);}},[]);const debouncedSync=useDebouncedCallback(runSync,3000);// 持久化
|
||||||
(0,react.useEffect)(()=>{if(isLoading){return;}if(data===null){return;}storage.setObj(key,data).catch(err=>{log_kissLog("storage save error for key: ".concat(key),err);});// 触发远端同步
|
(0,react.useEffect)(()=>{if(isLoading){return;}if(data===null){return;}storage.setObj(key,data).catch(err=>{log_kissLog("storage save error for key: ".concat(key),err);});// 触发远端同步
|
||||||
if(syncKey){debouncedSync(syncKey,data);}},[key,syncKey,isLoading,data,debouncedSync]);/**
|
if(syncKey&&isOptions()){debouncedSync(syncKey,data);}},[key,syncKey,isLoading,data,debouncedSync]);/**
|
||||||
* 全量替换状态值
|
* 全量替换状态值
|
||||||
* @param {any | ((prevData: any) => any)} valueOrFn 新的值或一个返回新值的函数。
|
* @param {any | ((prevData: any) => any)} valueOrFn 新的值或一个返回新值的函数。
|
||||||
*/const save=(0,react.useCallback)(valueOrFn=>{// kissLog("save storage:", valueOrFn);
|
*/const save=(0,react.useCallback)(valueOrFn=>{// kissLog("save storage:", valueOrFn);
|
||||||
@@ -62135,9 +62145,9 @@ Divider.muiSkipListHighlight = true;
|
|||||||
false ? 0 : void 0;
|
false ? 0 : void 0;
|
||||||
/* harmony default export */ const Divider_Divider = (Divider);
|
/* harmony default export */ const Divider_Divider = (Divider);
|
||||||
;// CONCATENATED MODULE: ./src/hooks/Loading.js
|
;// CONCATENATED MODULE: ./src/hooks/Loading.js
|
||||||
function Loading(){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.11")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})]});}
|
function Loading(){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.12")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})]});}
|
||||||
;// CONCATENATED MODULE: ./src/hooks/Setting.js
|
;// CONCATENATED MODULE: ./src/hooks/Setting.js
|
||||||
const SettingContext=/*#__PURE__*/(0,react.createContext)({setting:setting_DEFAULT_SETTING,updateSetting:()=>{},reloadSetting:()=>{}});function SettingProvider(_ref){let{children,isSettingPage}=_ref;const{data:setting,isLoading,update,reload}=useStorage(storage_STOKEY_SETTING,setting_DEFAULT_SETTING,isSettingPage?KV_SETTING_KEY:"");(0,react.useEffect)(()=>{if(typeof(setting===null||setting===void 0?void 0:setting.darkMode)==="boolean"){update(currentSetting=>_objectSpread2(_objectSpread2({},currentSetting),{},{darkMode:currentSetting.darkMode?"dark":"light"}));}},[setting===null||setting===void 0?void 0:setting.darkMode,update]);(0,react.useEffect)(()=>{if(!isSettingPage)return;(async()=>{try{logger.setLevel(setting===null||setting===void 0?void 0:setting.logLevel);if(client_isExt){await msg_sendBgMsg(MSG_SET_LOGLEVEL,setting===null||setting===void 0?void 0:setting.logLevel);}}catch(error){logger.error("Failed to fetch log level, using default.",error);}})();},[isSettingPage,setting===null||setting===void 0?void 0:setting.logLevel]);const updateSetting=(0,react.useCallback)(objOrFn=>{update(objOrFn);debounceSyncMeta(KV_SETTING_KEY);},[update]);const updateChild=(0,react.useCallback)(key=>async obj=>{updateSetting(prev=>_objectSpread2(_objectSpread2({},prev),{},{[key]:_objectSpread2(_objectSpread2({},(prev===null||prev===void 0?void 0:prev[key])||{}),obj)}));},[updateSetting]);const value=(0,react.useMemo)(()=>({setting,updateSetting,updateChild,reloadSetting:reload}),[setting,updateSetting,updateChild,reload]);if(isLoading){return/*#__PURE__*/(0,jsx_runtime.jsx)(Loading,{});}if(!setting){/*#__PURE__*/(0,jsx_runtime.jsx)("center",{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Alert_Alert,{severity:"error",sx:{maxWidth:600,margin:"60px auto"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)("p",{children:"\u6570\u636E\u52A0\u8F7D\u51FA\u9519\uFF0C\u8BF7\u5237\u65B0\u9875\u9762\u6216\u5378\u8F7D\u540E\u91CD\u65B0\u5B89\u88C5\u3002"}),/*#__PURE__*/(0,jsx_runtime.jsx)("p",{children:"Data loading error, please refresh the page or uninstall and reinstall."})]})});}return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingContext.Provider,{value:value,children:children});}/**
|
const SettingContext=/*#__PURE__*/(0,react.createContext)({setting:setting_DEFAULT_SETTING,updateSetting:()=>{},reloadSetting:()=>{}});function SettingProvider(_ref){let{children,context}=_ref;const isOptionsPage=(0,react.useMemo)(()=>context==="options",[context]);const{data:setting,isLoading,update,reload}=useStorage(storage_STOKEY_SETTING,setting_DEFAULT_SETTING,KV_SETTING_KEY);(0,react.useEffect)(()=>{if(typeof(setting===null||setting===void 0?void 0:setting.darkMode)==="boolean"){update(currentSetting=>_objectSpread2(_objectSpread2({},currentSetting),{},{darkMode:currentSetting.darkMode?"dark":"light"}));}},[setting===null||setting===void 0?void 0:setting.darkMode,update]);(0,react.useEffect)(()=>{if(!isOptionsPage)return;(async()=>{try{logger.setLevel(setting===null||setting===void 0?void 0:setting.logLevel);if(client_isExt){await msg_sendBgMsg(MSG_SET_LOGLEVEL,setting===null||setting===void 0?void 0:setting.logLevel);}}catch(error){logger.error("Failed to fetch log level, using default.",error);}})();},[isOptionsPage,setting===null||setting===void 0?void 0:setting.logLevel]);const updateSetting=(0,react.useCallback)(objOrFn=>{update(objOrFn);debounceSyncMeta(KV_SETTING_KEY);},[update]);const updateChild=(0,react.useCallback)(key=>async obj=>{updateSetting(prev=>_objectSpread2(_objectSpread2({},prev),{},{[key]:_objectSpread2(_objectSpread2({},(prev===null||prev===void 0?void 0:prev[key])||{}),obj)}));},[updateSetting]);const value=(0,react.useMemo)(()=>({context,setting,updateSetting,updateChild,reloadSetting:reload}),[context,setting,updateSetting,updateChild,reload]);if(isLoading){return isOptionsPage?/*#__PURE__*/(0,jsx_runtime.jsx)(Loading,{}):null;}if(!setting){return isOptionsPage?/*#__PURE__*/(0,jsx_runtime.jsx)("center",{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Alert_Alert,{severity:"error",sx:{maxWidth:600,margin:"60px auto"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)("p",{children:"\u6570\u636E\u52A0\u8F7D\u51FA\u9519\uFF0C\u8BF7\u5237\u65B0\u9875\u9762\u6216\u5378\u8F7D\u540E\u91CD\u65B0\u5B89\u88C5\u3002"}),/*#__PURE__*/(0,jsx_runtime.jsx)("p",{children:"Data loading error, please refresh the page or uninstall and reinstall."})]})}):null;}return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingContext.Provider,{value:value,children:children});}/**
|
||||||
* 设置 hook
|
* 设置 hook
|
||||||
* @returns
|
* @returns
|
||||||
*/function useSetting(){return (0,react.useContext)(SettingContext);}
|
*/function useSetting(){return (0,react.useContext)(SettingContext);}
|
||||||
@@ -75209,9 +75219,12 @@ onKeyUp(new Set(pressedKeys),e);pressedKeys.delete(e.code);};const handleBlur=()
|
|||||||
* @param {() => void} fn - 匹配成功后执行的回调
|
* @param {() => void} fn - 匹配成功后执行的回调
|
||||||
* @param {EventTarget} target - 监听目标
|
* @param {EventTarget} target - 监听目标
|
||||||
* @returns {() => void} - 注销函数
|
* @returns {() => void} - 注销函数
|
||||||
*/const shortcutRegister=function(){let targetKeys=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];let fn=arguments.length>1?arguments[1]:undefined;let target=arguments.length>2&&arguments[2]!==undefined?arguments[2]:document;if(targetKeys.length===0)return()=>{};const targetKeySet=new Set(targetKeys);const onKeyDown=(pressedKeys,event)=>{if(isSameSet(targetKeySet,pressedKeys)){// event.preventDefault(); // 阻止浏览器的默认行为
|
*/const shortcutRegister=function(){let targetKeys=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];let fn=arguments.length>1?arguments[1]:undefined;let target=arguments.length>2&&arguments[2]!==undefined?arguments[2]:document;if(targetKeys.length===0)return()=>{};const targetKeySet=new Set(targetKeys);let hasInterference=false;const onKeyDown=(pressedKeys,event)=>{// if (isSameSet(targetKeySet, pressedKeys)) {
|
||||||
// event.stopPropagation(); // 阻止事件继续(向父元素)冒泡
|
// // event.preventDefault(); // 阻止浏览器的默认行为
|
||||||
fn();}};const onKeyUp=()=>{};return shortcutListener(onKeyDown,onKeyUp,target);};/**
|
// // event.stopPropagation(); // 阻止事件继续(向父元素)冒泡
|
||||||
|
// fn();
|
||||||
|
// }
|
||||||
|
if(!targetKeySet.has(event.code)){hasInterference=true;}};const onKeyUp=(pressedKeys,event)=>{if(isSameSet(targetKeySet,pressedKeys)&&!hasInterference){fn();}if(pressedKeys.size===1){hasInterference=false;}};return shortcutListener(onKeyDown,onKeyUp,target);};/**
|
||||||
* 高阶函数:为目标函数增加计次和超时重置功能
|
* 高阶函数:为目标函数增加计次和超时重置功能
|
||||||
* @param {() => void} fn - 需要被包装的函数
|
* @param {() => void} fn - 需要被包装的函数
|
||||||
* @param {number} step - 需要触发的次数
|
* @param {number} step - 需要触发的次数
|
||||||
@@ -76582,7 +76595,7 @@ var BrightnessAuto = __webpack_require__(4080);
|
|||||||
;// CONCATENATED MODULE: ./src/views/Options/DarkModeButton.js
|
;// CONCATENATED MODULE: ./src/views/Options/DarkModeButton.js
|
||||||
function DarkModeButton(){const{darkMode,toggleDarkMode}=useDarkMode();return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{sx:{ml:1},onClick:toggleDarkMode,color:"inherit",children:darkMode==="dark"?/*#__PURE__*/(0,jsx_runtime.jsx)(DarkMode/* default */.Z,{}):darkMode==="light"?/*#__PURE__*/(0,jsx_runtime.jsx)(LightMode/* default */.Z,{}):/*#__PURE__*/(0,jsx_runtime.jsx)(BrightnessAuto/* default */.Z,{})});}
|
function DarkModeButton(){const{darkMode,toggleDarkMode}=useDarkMode();return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{sx:{ml:1},onClick:toggleDarkMode,color:"inherit",children:darkMode==="dark"?/*#__PURE__*/(0,jsx_runtime.jsx)(DarkMode/* default */.Z,{}):darkMode==="light"?/*#__PURE__*/(0,jsx_runtime.jsx)(LightMode/* default */.Z,{}):/*#__PURE__*/(0,jsx_runtime.jsx)(BrightnessAuto/* default */.Z,{})});}
|
||||||
;// CONCATENATED MODULE: ./src/views/Options/Header.js
|
;// CONCATENATED MODULE: ./src/views/Options/Header.js
|
||||||
function Header(props){const i18n=useI18n();const{onDrawerToggle}=props;return/*#__PURE__*/(0,jsx_runtime.jsx)(AppBar_AppBar,{color:"primary",position:"sticky",sx:{zIndex:1300},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Toolbar_Toolbar,{variant:"dense",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{sx:{display:{sm:"none",xs:"block"}},children:/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{color:"inherit","aria-label":"open drawer",onClick:onDrawerToggle,edge:"start",children:/*#__PURE__*/(0,jsx_runtime.jsx)(icons_material_Menu/* default */.Z,{})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",sx:{flexGrow:1,fontWeight:"bold"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{underline:"none",color:"inherit",href:"https://github.com/fishjar/kiss-translator",target:"_blank",children:"".concat(i18n("app_name")," v").concat("2.0.11")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(DarkModeButton,{})]})});}/* harmony default export */ const Options_Header = (Header);
|
function Header(props){const i18n=useI18n();const{onDrawerToggle}=props;return/*#__PURE__*/(0,jsx_runtime.jsx)(AppBar_AppBar,{color:"primary",position:"sticky",sx:{zIndex:1300},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Toolbar_Toolbar,{variant:"dense",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{sx:{display:{sm:"none",xs:"block"}},children:/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{color:"inherit","aria-label":"open drawer",onClick:onDrawerToggle,edge:"start",children:/*#__PURE__*/(0,jsx_runtime.jsx)(icons_material_Menu/* default */.Z,{})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",sx:{flexGrow:1,fontWeight:"bold"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{underline:"none",color:"inherit",href:"https://github.com/fishjar/kiss-translator",target:"_blank",children:"".concat(i18n("app_name")," v").concat("2.0.12")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(DarkModeButton,{})]})});}/* harmony default export */ const Options_Header = (Header);
|
||||||
;// CONCATENATED MODULE: ./src/views/Options/Layout.js
|
;// CONCATENATED MODULE: ./src/views/Options/Layout.js
|
||||||
function Layout(){const navWidth=256;const location=dist_useLocation();const theme=useTheme_useTheme();const[open,setOpen]=(0,react.useState)(false);const isSm=useMediaQuery(theme.breakpoints.up("sm"));const handleDrawerToggle=()=>{setOpen(!open);};(0,react.useEffect)(()=>{setOpen(false);},[location]);return/*#__PURE__*/(0,jsx_runtime.jsxs)(Box_Box,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(CssBaseline_CssBaseline,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(Options_Header,{onDrawerToggle:handleDrawerToggle}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Box_Box,{sx:{display:"flex"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{component:"nav",sx:{width:{sm:navWidth},flexShrink:{sm:0}},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Navigator,{PaperProps:{style:{width:navWidth}},variant:isSm?"permanent":"temporary",open:isSm?true:open,onClose:handleDrawerToggle})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{component:"main",sx:{flex:1,p:2,width:"100%"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Outlet,{})})]})]});}
|
function Layout(){const navWidth=256;const location=dist_useLocation();const theme=useTheme_useTheme();const[open,setOpen]=(0,react.useState)(false);const isSm=useMediaQuery(theme.breakpoints.up("sm"));const handleDrawerToggle=()=>{setOpen(!open);};(0,react.useEffect)(()=>{setOpen(false);},[location]);return/*#__PURE__*/(0,jsx_runtime.jsxs)(Box_Box,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(CssBaseline_CssBaseline,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(Options_Header,{onDrawerToggle:handleDrawerToggle}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Box_Box,{sx:{display:"flex"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{component:"nav",sx:{width:{sm:navWidth},flexShrink:{sm:0}},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Navigator,{PaperProps:{style:{width:navWidth}},variant:isSm?"permanent":"temporary",open:isSm?true:open,onClose:handleDrawerToggle})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{component:"main",sx:{flex:1,p:2,width:"100%"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Outlet,{})})]})]});}
|
||||||
// EXTERNAL MODULE: ./node_modules/.pnpm/@mui+icons-material@5.15.15_@mui+material@5.15.15_@emotion+react@11.11.1_@types+react@18.2.79_zdo5tzcazfyjzm354hmuezm3pe/node_modules/@mui/icons-material/ContentCopy.js
|
// EXTERNAL MODULE: ./node_modules/.pnpm/@mui+icons-material@5.15.15_@mui+material@5.15.15_@emotion+react@11.11.1_@types+react@18.2.79_zdo5tzcazfyjzm354hmuezm3pe/node_modules/@mui/icons-material/ContentCopy.js
|
||||||
@@ -76759,7 +76772,7 @@ mediaQuery.addEventListener("change",handleChange);return()=>mediaQuery.removeEv
|
|||||||
const MSG_GM_xmlHttpRequest="xmlHttpRequest";const MSG_GM_setValue="setValue";const MSG_GM_getValue="getValue";const MSG_GM_deleteValue="deleteValue";const MSG_GM_info="info";/**
|
const MSG_GM_xmlHttpRequest="xmlHttpRequest";const MSG_GM_setValue="setValue";const MSG_GM_getValue="getValue";const MSG_GM_deleteValue="deleteValue";const MSG_GM_info="info";/**
|
||||||
* 注入页面的脚本,请求并接受GM接口信息
|
* 注入页面的脚本,请求并接受GM接口信息
|
||||||
* @param {*} param0
|
* @param {*} param0
|
||||||
*/const injectScript=ping=>{window.APP_INFO={name:"KISS Translator",version:"2.0.11",eventName:ping};};/**
|
*/const injectScript=ping=>{window.APP_INFO={name:"KISS Translator",version:"2.0.12",eventName:ping};};/**
|
||||||
* 适配GM脚本
|
* 适配GM脚本
|
||||||
*/const adaptScript=ping=>{const promiseGM=function(action,args){let timeout=arguments.length>2&&arguments[2]!==undefined?arguments[2]:5000;return new Promise((resolve,reject)=>{const pong=genEventName();const handleEvent=e=>{window.removeEventListener(pong,handleEvent);const{data,error}=e.detail;if(error){reject(new Error(error));}else{resolve(data);}};window.addEventListener(pong,handleEvent);window.dispatchEvent(new CustomEvent(ping,{detail:{action,args,pong}}));setTimeout(()=>{window.removeEventListener(pong,handleEvent);reject(new Error("timeout"));},timeout);});};window.KISS_GM={fetch:(input,init)=>promiseGM(MSG_GM_xmlHttpRequest,{input,init}),setValue:(key,val)=>promiseGM(MSG_GM_setValue,{key,val}),getValue:key=>promiseGM(MSG_GM_getValue,{key}),deleteValue:key=>promiseGM(MSG_GM_deleteValue,{key}),getInfo:async()=>{if(!window.GM_info){window.GM_info=await promiseGM(MSG_GM_info);}return window.GM_info;}};};/**
|
*/const adaptScript=ping=>{const promiseGM=function(action,args){let timeout=arguments.length>2&&arguments[2]!==undefined?arguments[2]:5000;return new Promise((resolve,reject)=>{const pong=genEventName();const handleEvent=e=>{window.removeEventListener(pong,handleEvent);const{data,error}=e.detail;if(error){reject(new Error(error));}else{resolve(data);}};window.addEventListener(pong,handleEvent);window.dispatchEvent(new CustomEvent(ping,{detail:{action,args,pong}}));setTimeout(()=>{window.removeEventListener(pong,handleEvent);reject(new Error("timeout"));},timeout);});};window.KISS_GM={fetch:(input,init)=>promiseGM(MSG_GM_xmlHttpRequest,{input,init}),setValue:(key,val)=>promiseGM(MSG_GM_setValue,{key,val}),getValue:key=>promiseGM(MSG_GM_getValue,{key}),deleteValue:key=>promiseGM(MSG_GM_deleteValue,{key}),getInfo:async()=>{if(!window.GM_info){window.GM_info=await promiseGM(MSG_GM_info);}return window.GM_info;}};};/**
|
||||||
* 监听并回应页面对GM接口的请求
|
* 监听并回应页面对GM接口的请求
|
||||||
@@ -81278,17 +81291,11 @@ var VolumeUp = __webpack_require__(9938);
|
|||||||
* 声音播放hook
|
* 声音播放hook
|
||||||
* @param {*} src
|
* @param {*} src
|
||||||
* @returns
|
* @returns
|
||||||
*/function useAudio(src){const audioRef=(0,react.useRef)(null);const[error,setError]=(0,react.useState)(null);const[ready,setReady]=(0,react.useState)(false);const[playing,setPlaying]=(0,react.useState)(false);const onPlay=(0,react.useCallback)(()=>{var _audioRef$current;(_audioRef$current=audioRef.current)===null||_audioRef$current===void 0?void 0:_audioRef$current.play();},[]);(0,react.useEffect)(()=>{if(!src){return;}const audio=new Audio(src);audio.addEventListener("error",err=>setError(err));audio.addEventListener("canplaythrough",()=>setReady(true));audio.addEventListener("play",()=>setPlaying(true));audio.addEventListener("ended",()=>setPlaying(false));audioRef.current=audio;},[src]);return{error,ready,playing,onPlay};}/**
|
*/function useAudio(src){const audioRef=(0,react.useRef)(null);const[error,setError]=(0,react.useState)(null);const[ready,setReady]=(0,react.useState)(false);const[playing,setPlaying]=(0,react.useState)(false);const[loading,setLoading]=(0,react.useState)(false);const onPlay=(0,react.useCallback)(async()=>{if(!audioRef.current)return;try{await audioRef.current.play();}catch(err){logger.info("Playback failed:",err);setPlaying(false);}},[]);const onPause=(0,react.useCallback)(()=>{var _audioRef$current;(_audioRef$current=audioRef.current)===null||_audioRef$current===void 0?void 0:_audioRef$current.pause();},[]);(0,react.useEffect)(()=>{if(!src)return;let ignore=false;let objectUrl=null;setReady(false);setError(null);setPlaying(false);setLoading(true);const audio=new Audio();audioRef.current=audio;const handleCanPlay=()=>setReady(true);const handlePlay=()=>setPlaying(true);const handlePause=()=>setPlaying(false);const handleEnded=()=>setPlaying(false);const handleError=e=>{if(!ignore){setError(audio.error||e);setReady(false);setLoading(false);}};audio.addEventListener("canplaythrough",handleCanPlay);audio.addEventListener("play",handlePlay);audio.addEventListener("pause",handlePause);audio.addEventListener("ended",handleEnded);audio.addEventListener("error",handleError);const loadAudio=async()=>{try{const data=await fetch_fetchData(src,{},{expect:"audio"});if(ignore)return;audio.src=data;setLoading(false);}catch(err){if(!ignore){logger.info("Audio fetch failed:",err);setError(err);setLoading(false);}}};loadAudio();return()=>{ignore=true;audio.pause();audio.removeAttribute("src");if(objectUrl){URL.revokeObjectURL(objectUrl);}audio.removeEventListener("canplaythrough",handleCanPlay);audio.removeEventListener("play",handlePlay);audio.removeEventListener("pause",handlePause);audio.removeEventListener("ended",handleEnded);audio.removeEventListener("error",handleError);};},[src]);return{loading,error,ready,playing,onPlay,onPause};}
|
||||||
* 获取语音hook
|
|
||||||
* @param {*} text
|
|
||||||
* @param {*} lan
|
|
||||||
* @param {*} spd
|
|
||||||
* @returns
|
|
||||||
*/function useTextAudio(text){let lan=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"uk";let spd=arguments.length>2&&arguments[2]!==undefined?arguments[2]:3;const[src,setSrc]=useState("");useEffect(()=>{(async()=>{try{setSrc(await apiBaiduTTS(text,lan,spd));}catch(err){kissLog("baidu tts",err);}})();},[text,lan,spd]);return useAudio(src);}
|
|
||||||
;// CONCATENATED MODULE: ./src/views/Selection/AudioBtn.js
|
;// CONCATENATED MODULE: ./src/views/Selection/AudioBtn.js
|
||||||
function AudioBtn(_ref){let{src}=_ref;const{error,ready,playing,onPlay}=useAudio(src);if(error||!ready){return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{disabled:true,size:"small",children:/*#__PURE__*/(0,jsx_runtime.jsx)(VolumeUp/* default */.Z,{fontSize:"inherit"})});}if(playing){return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{color:"primary",size:"small",children:/*#__PURE__*/(0,jsx_runtime.jsx)(VolumeUp/* default */.Z,{fontSize:"inherit"})});}return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:onPlay,size:"small",children:/*#__PURE__*/(0,jsx_runtime.jsx)(VolumeUp/* default */.Z,{fontSize:"inherit"})});}
|
function AudioBtn(_ref){let{src}=_ref;const{error,ready,playing,onPlay}=useAudio(src);if(error||!ready){return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{disabled:true,size:"small",children:/*#__PURE__*/(0,jsx_runtime.jsx)(VolumeUp/* default */.Z,{fontSize:"inherit"})});}if(playing){return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{color:"primary",size:"small",children:/*#__PURE__*/(0,jsx_runtime.jsx)(VolumeUp/* default */.Z,{fontSize:"inherit"})});}return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:onPlay,size:"small",children:/*#__PURE__*/(0,jsx_runtime.jsx)(VolumeUp/* default */.Z,{fontSize:"inherit"})});}function BaiduAudioBtn(_ref2){let{text,lan="uk",spd=3}=_ref2;if(!text)return null;const src="https://fanyi.baidu.com/gettts?".concat(query_string.stringify({lan,text,spd}));return/*#__PURE__*/(0,jsx_runtime.jsx)(AudioBtn,{src:src});}
|
||||||
;// CONCATENATED MODULE: ./src/views/Selection/DictHandler.js
|
;// CONCATENATED MODULE: ./src/views/Selection/DictHandler.js
|
||||||
const dictHandlers={[OPT_DICT_BING]:{apiFn:apiMicrosoftDict,reWord:data=>data===null||data===void 0?void 0:data.word,toText:data=>{var _data$trs;return(data===null||data===void 0?void 0:(_data$trs=data.trs)===null||_data$trs===void 0?void 0:_data$trs.map(_ref=>{let{pos,def}=_ref;return"".concat(pos?"[".concat(pos,"] "):"").concat(def);}))||[];},uiAudio:data=>{var _data$aus;return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",children:data===null||data===void 0?void 0:(_data$aus=data.aus)===null||_data$aus===void 0?void 0:_data$aus.map(_ref2=>{let{key,audio,phonetic}=_ref2;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",style:{display:"inline-block",paddingRight:"1em"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"span",children:phonetic}),/*#__PURE__*/(0,jsx_runtime.jsx)(AudioBtn,{src:audio})]},key);})});},uiTrans:data=>{var _data$trs2;return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"ul",children:data===null||data===void 0?void 0:(_data$trs2=data.trs)===null||_data$trs2===void 0?void 0:_data$trs2.map((_ref3,idx)=>{let{pos,def}=_ref3;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"li",children:[pos&&"[".concat(pos,"] "),def]},idx);})});}},[OPT_DICT_YOUDAO]:{apiFn:apiYoudaoDict,reWord:data=>{var _data$ec,_data$ec$word;return data===null||data===void 0?void 0:(_data$ec=data.ec)===null||_data$ec===void 0?void 0:(_data$ec$word=_data$ec.word)===null||_data$ec$word===void 0?void 0:_data$ec$word["return-phrase"];},toText:data=>{var _data$ec2,_data$ec2$word,_data$ec2$word$trs;return(data===null||data===void 0?void 0:(_data$ec2=data.ec)===null||_data$ec2===void 0?void 0:(_data$ec2$word=_data$ec2.word)===null||_data$ec2$word===void 0?void 0:(_data$ec2$word$trs=_data$ec2$word.trs)===null||_data$ec2$word$trs===void 0?void 0:_data$ec2$word$trs.map(_ref4=>{let{pos,tran}=_ref4;return"".concat(pos?"[".concat(pos,"] "):"").concat(tran);}))||[];},uiAudio:data=>{var _data$ec3,_data$ec3$word,_data$ec4,_data$ec4$word;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",style:{display:"inline-block",paddingRight:"1em"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"span",children:"UK [".concat(data===null||data===void 0?void 0:(_data$ec3=data.ec)===null||_data$ec3===void 0?void 0:(_data$ec3$word=_data$ec3.word)===null||_data$ec3$word===void 0?void 0:_data$ec3$word.ukphone,"]")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",style:{display:"inline-block",paddingRight:"1em"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"span",children:"US [".concat(data===null||data===void 0?void 0:(_data$ec4=data.ec)===null||_data$ec4===void 0?void 0:(_data$ec4$word=_data$ec4.word)===null||_data$ec4$word===void 0?void 0:_data$ec4$word.usphone,"]")})})]});},uiTrans:data=>{var _data$ec5,_data$ec5$word,_data$ec5$word$trs;return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"ul",children:data===null||data===void 0?void 0:(_data$ec5=data.ec)===null||_data$ec5===void 0?void 0:(_data$ec5$word=_data$ec5.word)===null||_data$ec5$word===void 0?void 0:(_data$ec5$word$trs=_data$ec5$word.trs)===null||_data$ec5$word$trs===void 0?void 0:_data$ec5$word$trs.map((_ref5,idx)=>{let{pos,tran}=_ref5;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"li",children:[pos&&"[".concat(pos,"] "),tran]},idx);})});}}};
|
const dictHandlers={[OPT_DICT_BING]:{apiFn:apiMicrosoftDict,reWord:data=>data===null||data===void 0?void 0:data.word,toText:data=>{var _data$trs;return(data===null||data===void 0?void 0:(_data$trs=data.trs)===null||_data$trs===void 0?void 0:_data$trs.map(_ref=>{let{pos,def}=_ref;return"".concat(pos?"[".concat(pos,"] "):"").concat(def);}))||[];},uiAudio:data=>{var _data$aus;return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",children:data===null||data===void 0?void 0:(_data$aus=data.aus)===null||_data$aus===void 0?void 0:_data$aus.map(_ref2=>{let{key,audio,phonetic}=_ref2;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",style:{display:"inline-block",paddingRight:"1em"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"span",children:phonetic}),/*#__PURE__*/(0,jsx_runtime.jsx)(AudioBtn,{src:audio})]},key);})});},uiTrans:data=>{var _data$trs2;return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"ul",children:data===null||data===void 0?void 0:(_data$trs2=data.trs)===null||_data$trs2===void 0?void 0:_data$trs2.map((_ref3,idx)=>{let{pos,def}=_ref3;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"li",children:[pos&&"[".concat(pos,"] "),def]},idx);})});}},[OPT_DICT_YOUDAO]:{apiFn:apiYoudaoDict,reWord:data=>{var _data$ec,_data$ec$word;return data===null||data===void 0?void 0:(_data$ec=data.ec)===null||_data$ec===void 0?void 0:(_data$ec$word=_data$ec.word)===null||_data$ec$word===void 0?void 0:_data$ec$word["return-phrase"];},toText:data=>{var _data$ec2,_data$ec2$word,_data$ec2$word$trs;return(data===null||data===void 0?void 0:(_data$ec2=data.ec)===null||_data$ec2===void 0?void 0:(_data$ec2$word=_data$ec2.word)===null||_data$ec2$word===void 0?void 0:(_data$ec2$word$trs=_data$ec2$word.trs)===null||_data$ec2$word$trs===void 0?void 0:_data$ec2$word$trs.map(_ref4=>{let{pos,tran}=_ref4;return"".concat(pos?"[".concat(pos,"] "):"").concat(tran);}))||[];},uiAudio:data=>{var _data$ec3,_data$ec3$word,_data$ec4,_data$ec4$word,_data$ec5,_data$ec5$word,_data$ec6,_data$ec6$word;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",style:{display:"inline-block",paddingRight:"1em"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"span",children:"UK [".concat(data===null||data===void 0?void 0:(_data$ec3=data.ec)===null||_data$ec3===void 0?void 0:(_data$ec3$word=_data$ec3.word)===null||_data$ec3$word===void 0?void 0:_data$ec3$word.ukphone,"]")}),/*#__PURE__*/(0,jsx_runtime.jsx)(BaiduAudioBtn,{text:data===null||data===void 0?void 0:(_data$ec4=data.ec)===null||_data$ec4===void 0?void 0:(_data$ec4$word=_data$ec4.word)===null||_data$ec4$word===void 0?void 0:_data$ec4$word["return-phrase"],lan:"uk"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",style:{display:"inline-block",paddingRight:"1em"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"span",children:"US [".concat(data===null||data===void 0?void 0:(_data$ec5=data.ec)===null||_data$ec5===void 0?void 0:(_data$ec5$word=_data$ec5.word)===null||_data$ec5$word===void 0?void 0:_data$ec5$word.usphone,"]")}),/*#__PURE__*/(0,jsx_runtime.jsx)(BaiduAudioBtn,{text:data===null||data===void 0?void 0:(_data$ec6=data.ec)===null||_data$ec6===void 0?void 0:(_data$ec6$word=_data$ec6.word)===null||_data$ec6$word===void 0?void 0:_data$ec6$word["return-phrase"],lan:"en"})]})]});},uiTrans:data=>{var _data$ec7,_data$ec7$word,_data$ec7$word$trs;return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"ul",children:data===null||data===void 0?void 0:(_data$ec7=data.ec)===null||_data$ec7===void 0?void 0:(_data$ec7$word=_data$ec7.word)===null||_data$ec7$word===void 0?void 0:(_data$ec7$word$trs=_data$ec7$word.trs)===null||_data$ec7$word$trs===void 0?void 0:_data$ec7$word$trs.map((_ref5,idx)=>{let{pos,tran}=_ref5;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"li",children:[pos&&"[".concat(pos,"] "),tran]},idx);})});}}};
|
||||||
;// CONCATENATED MODULE: ./src/views/Selection/DictCont.js
|
;// CONCATENATED MODULE: ./src/views/Selection/DictCont.js
|
||||||
function DictBody(_ref){let{text,setCopyText,setRealWord,dict}=_ref;const{loading,error,data}=useAsyncNow(dict.apiFn,text);(0,react.useEffect)(()=>{if(!data){return;}const realWord=dict.reWord(data)||text;const copyText=[realWord,dict.toText(data).join("\n")].join("\n");setRealWord(realWord);setCopyText(copyText);},[data,text,dict,setCopyText,setRealWord]);const uiAudio=(0,react.useMemo)(()=>dict.uiAudio(data),[data,dict]);const uiTrans=(0,react.useMemo)(()=>dict.uiTrans(data),[data,dict]);if(loading){return/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{size:16});}if(error){return/*#__PURE__*/(0,jsx_runtime.jsx)(Alert_Alert,{severity:"error",children:error});}if(!data){return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{children:"Not found!"});}return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",children:[uiAudio,uiTrans]});}function DictCont(_ref2){let{text,enDict}=_ref2;const[copyText,setCopyText]=(0,react.useState)(text);const[realWord,setRealWord]=(0,react.useState)(text);const dict=dictHandlers[enDict];return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:1,children:[text&&/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{variant:"subtitle1",style:{fontWeight:"bold"},children:realWord}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(CopyBtn,{text:copyText}),/*#__PURE__*/(0,jsx_runtime.jsx)(FavBtn,{word:realWord})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{}),dict&&/*#__PURE__*/(0,jsx_runtime.jsx)(DictBody,{text:text,setCopyText:setCopyText,setRealWord:setRealWord,dict:dict})]});}
|
function DictBody(_ref){let{text,setCopyText,setRealWord,dict}=_ref;const{loading,error,data}=useAsyncNow(dict.apiFn,text);(0,react.useEffect)(()=>{if(!data){return;}const realWord=dict.reWord(data)||text;const copyText=[realWord,dict.toText(data).join("\n")].join("\n");setRealWord(realWord);setCopyText(copyText);},[data,text,dict,setCopyText,setRealWord]);const uiAudio=(0,react.useMemo)(()=>dict.uiAudio(data),[data,dict]);const uiTrans=(0,react.useMemo)(()=>dict.uiTrans(data),[data,dict]);if(loading){return/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{size:16});}if(error){return/*#__PURE__*/(0,jsx_runtime.jsx)(Alert_Alert,{severity:"error",children:error});}if(!data){return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{children:"Not found!"});}return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",children:[uiAudio,uiTrans]});}function DictCont(_ref2){let{text,enDict}=_ref2;const[copyText,setCopyText]=(0,react.useState)(text);const[realWord,setRealWord]=(0,react.useState)(text);const dict=dictHandlers[enDict];return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:1,children:[text&&/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{variant:"subtitle1",style:{fontWeight:"bold"},children:realWord}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(CopyBtn,{text:copyText}),/*#__PURE__*/(0,jsx_runtime.jsx)(FavBtn,{word:realWord})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{}),dict&&/*#__PURE__*/(0,jsx_runtime.jsx)(DictBody,{text:text,setCopyText:setCopyText,setRealWord:setRealWord,dict:dict})]});}
|
||||||
;// CONCATENATED MODULE: ./src/views/Selection/SugCont.js
|
;// CONCATENATED MODULE: ./src/views/Selection/SugCont.js
|
||||||
@@ -81328,11 +81335,11 @@ var StylesSetting_templateObject;function StyleFields(_ref){let{customStyle,dele
|
|||||||
;// CONCATENATED MODULE: ./src/views/Options/index.js
|
;// CONCATENATED MODULE: ./src/views/Options/index.js
|
||||||
function Options(){const[error,setError]=(0,react.useState)("");const[ready,setReady]=(0,react.useState)(false);(0,react.useEffect)(()=>{(async()=>{if(isGm){// 等待GM注入
|
function Options(){const[error,setError]=(0,react.useState)("");const[ready,setReady]=(0,react.useState)(false);(0,react.useEffect)(()=>{(async()=>{if(isGm){// 等待GM注入
|
||||||
let i=0;for(;;){var _window,_window$APP_INFO;if(((_window=window)===null||_window===void 0?void 0:(_window$APP_INFO=_window.APP_INFO)===null||_window$APP_INFO===void 0?void 0:_window$APP_INFO.name)==="KISS Translator"){const{version,eventName}=window.APP_INFO;// 检查版本是否一致
|
let i=0;for(;;){var _window,_window$APP_INFO;if(((_window=window)===null||_window===void 0?void 0:(_window$APP_INFO=_window.APP_INFO)===null||_window$APP_INFO===void 0?void 0:_window$APP_INFO.name)==="KISS Translator"){const{version,eventName}=window.APP_INFO;// 检查版本是否一致
|
||||||
if(version!=="2.0.11"){setError("The version of the local script(v".concat(version,") is not the latest version(v").concat("2.0.11","). \u672C\u5730\u811A\u672C\u4E4B\u7248\u672C(v").concat(version,")\u975E\u6700\u65B0\u7248(v").concat("2.0.11",")\u3002"));return;}if(eventName){// 注入GM接口
|
if(version!=="2.0.12"){setError("The version of the local script(v".concat(version,") is not the latest version(v").concat("2.0.12","). \u672C\u5730\u811A\u672C\u4E4B\u7248\u672C(v").concat(version,")\u975E\u6700\u65B0\u7248(v").concat("2.0.12",")\u3002"));return;}if(eventName){// 注入GM接口
|
||||||
adaptScript(eventName);}break;}if(++i>8){setError("Time out. Please confirm whether to install or enable KISS Translator GreaseMonkey script? 连接超时,请检查是否安装或启用简约翻译油猴脚本。");return;}await sleep(1000);}}// 同步数据
|
adaptScript(eventName);}break;}if(++i>8){setError("Time out. Please confirm whether to install or enable KISS Translator GreaseMonkey script? 连接超时,请检查是否安装或启用简约翻译油猴脚本。");return;}await sleep(1000);}}// 同步数据
|
||||||
await trySyncSettingAndRules();setReady(true);})();},[]);if(error){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.11")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Alert_Alert,{severity:"error",children:error}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator.user.js",children:"Install/Update Userscript for Tampermonkey/Violentmonkey"}),/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js",children:"Install/Update Userscript for iOS Safari"})]})]});}if(!ready){return/*#__PURE__*/(0,jsx_runtime.jsx)(Loading,{});}return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingProvider,{isSettingPage:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)(Theme,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(AlertProvider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ConfirmProvider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(HashRouter,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Routes,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Route,{path:"/",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Layout,{}),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{index:true,element:/*#__PURE__*/(0,jsx_runtime.jsx)(Settings,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"rules",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Rules,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"styles",element:/*#__PURE__*/(0,jsx_runtime.jsx)(StylesSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"input",element:/*#__PURE__*/(0,jsx_runtime.jsx)(InputSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"tranbox",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Tranbox,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"mousehover",element:/*#__PURE__*/(0,jsx_runtime.jsx)(MouseHoverSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"subtitle",element:/*#__PURE__*/(0,jsx_runtime.jsx)(SubtitleSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"apis",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Apis,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"sync",element:/*#__PURE__*/(0,jsx_runtime.jsx)(SyncSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"words",element:/*#__PURE__*/(0,jsx_runtime.jsx)(FavWords,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"playground",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Playgound,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"about",element:/*#__PURE__*/(0,jsx_runtime.jsx)(About,{})})]})})})})})})});}
|
await trySyncSettingAndRules();setReady(true);})();},[]);if(error){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.12")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Alert_Alert,{severity:"error",children:error}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator.user.js",children:"Install/Update Userscript for Tampermonkey/Violentmonkey"}),/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js",children:"Install/Update Userscript for iOS Safari"})]})]});}if(!ready){return/*#__PURE__*/(0,jsx_runtime.jsx)(Loading,{});}return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingProvider,{context:"options",children:/*#__PURE__*/(0,jsx_runtime.jsx)(Theme,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(AlertProvider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ConfirmProvider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(HashRouter,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Routes,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Route,{path:"/",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Layout,{}),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{index:true,element:/*#__PURE__*/(0,jsx_runtime.jsx)(Settings,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"rules",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Rules,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"styles",element:/*#__PURE__*/(0,jsx_runtime.jsx)(StylesSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"input",element:/*#__PURE__*/(0,jsx_runtime.jsx)(InputSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"tranbox",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Tranbox,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"mousehover",element:/*#__PURE__*/(0,jsx_runtime.jsx)(MouseHoverSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"subtitle",element:/*#__PURE__*/(0,jsx_runtime.jsx)(SubtitleSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"apis",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Apis,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"sync",element:/*#__PURE__*/(0,jsx_runtime.jsx)(SyncSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"words",element:/*#__PURE__*/(0,jsx_runtime.jsx)(FavWords,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"playground",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Playgound,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"about",element:/*#__PURE__*/(0,jsx_runtime.jsx)(About,{})})]})})})})})})});}
|
||||||
;// CONCATENATED MODULE: ./src/options.js
|
;// CONCATENATED MODULE: ./src/options.js
|
||||||
const options_root=client.createRoot(document.getElementById("root"));options_root.render(/*#__PURE__*/(0,jsx_runtime.jsx)(react.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Options,{})}));
|
globalThis.__KISS_CONTEXT__="options";const options_root=client.createRoot(document.getElementById("root"));options_root.render(/*#__PURE__*/(0,jsx_runtime.jsx)(react.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Options,{})}));
|
||||||
})();
|
})();
|
||||||
|
|
||||||
/******/ })()
|
/******/ })()
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2.0.11
|
2.0.12
|
||||||
Reference in New Issue
Block a user