ms-vite-plugin 1.5.12 → 1.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/luaBundle.js +2 -2
- package/dist/build/scriptProtect.js +2 -2
- package/docs/api/ai.md +16 -16
- package/docs/api/config.md +3 -3
- package/docs/api/dotocr.md +2 -2
- package/docs/api/file.md +18 -18
- package/docs/api/hid.md +2 -2
- package/docs/api/hotUpdate.md +2 -2
- package/docs/api/http.md +4 -4
- package/docs/api/image.md +15 -15
- package/docs/api/jbclear.md +12 -12
- package/docs/api/jbdevice.md +25 -25
- package/docs/api/jbdraw.md +139 -0
- package/docs/api/jbdylib.md +6 -6
- package/docs/api/jbpower.md +134 -0
- package/docs/api/jbshell.md +2 -2
- package/docs/api/jbsystem.md +6 -6
- package/docs/api/jbvpn.md +7 -7
- package/docs/api/mysql.md +4 -4
- package/docs/api/netCard.md +4 -73
- package/docs/api/node.md +5 -3
- package/docs/api/opencv.md +116 -116
- package/docs/api/plist.md +2 -2
- package/docs/api/sqlite.md +231 -0
- package/docs/api/system.md +1 -1
- package/docs/api/thread.md +2 -2
- package/docs/api/tomatoocr.md +2 -2
- package/docs/api/yolo.md +2 -2
- package/docs/api/yolocls.md +6 -6
- package/docs/api/zipFile.md +113 -0
- package/docs/apicn/ai.md +16 -16
- package/docs/apicn/config.md +2 -2
- package/docs/apicn/dotocr.md +2 -2
- package/docs/apicn/file.md +16 -16
- package/docs/apicn/hid.md +4 -4
- package/docs/apicn/hotUpdate.md +2 -2
- package/docs/apicn/http.md +4 -4
- package/docs/apicn/image.md +13 -13
- package/docs/apicn/mysql.md +4 -4
- package/docs/apicn/netCard.md +4 -73
- package/docs/apicn/node.md +5 -3
- package/docs/apicn/sqlite.md +197 -0
- package/docs/apicn/system.md +3 -3
- package/docs/apicn/thread.md +2 -2
- package/docs/apicn/yolo.md +2 -2
- package/docs/apicn/yolocls.md +6 -6
- package/docs/apicn/zipFile.md +113 -0
- package/docs/apilua/jbdraw.md +141 -0
- package/docs/apilua/jbpower.md +136 -0
- package/docs/apilua/netCard.md +3 -77
- package/docs/apilua/node.md +3 -1
- package/docs/apilua/sqlite.md +204 -0
- package/docs/apilua/zipFile.md +123 -0
- package/docs/apipython/jbdraw.md +147 -0
- package/docs/apipython/jbpower.md +133 -0
- package/docs/apipython/netCard.md +3 -74
- package/docs/apipython/node.md +3 -1
- package/docs/apipython/overview.md +1 -1
- package/docs/apipython/sqlite.md +181 -0
- package/docs/apipython/zipFile.md +117 -0
- package/package.json +1 -1
package/dist/build/luaBundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var g=exports&&exports.__createBinding||(Object.create?(function(t,e,i,n){n===void 0&&(n=i);var a=Object.getOwnPropertyDescriptor(e,i);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,a)}):(function(t,e,i,n){n===void 0&&(n=i),t[n]=e[i]})),j=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),m=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(i){var n=[];for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[n.length]=a);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var i={};if(e!=null)for(var n=t(e),a=0;a<n.length;a++)n[a]!=="default"&&g(i,e,n[a]);return j(i,e),i}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.bundleLuaScripts=v;const c=m(require("fs-extra")),d=m(require("path")),b=new Set(["action","ai","appleocr","cloud","config","cryptoUtils","cv","device","dotocr","file","hid","hotupdate","http","image","ime","jbdylib","jbshell","jbclear","jbsystem","jbdevice","jbpower","jbvpn","jbdraw","logger","media","mysql","netcard","node","paddleocr","pip","plist","sqlite","system","tomatoocr","tts","ui","utils","yolo","yolocls","zipFile"]),_=new Set(["coroutine","debug","io","math","os","package","string","table","utf8"]);async function v(t){const e=d.join(t,"main.lua");await c.pathExists(e)||(console.error("\u274C \u672A\u627E\u5230 scripts/main.lua\uFF0C\u65E0\u6CD5\u5408\u5E76 Lua"),process.exit(1));const i=await F(t),n=new Map;for(const o of i){const l=p(t,o),u=h(l);if(!u)continue;if(b.has(u)||_.has(u)){const y=b.has(u)?"\u5BBF\u4E3B":"\u6807\u51C6\u5E93";console.warn(`\u26A0\uFE0F \u8DF3\u8FC7 ${l}\uFF1A\u6A21\u5757\u540D ${u} \u4E0E${y}\u5168\u5C40\u540D\u51B2\u7A81\uFF0C\u4E0D\u8981\u5360\u7528\u5BBF\u4E3B\u6216\u6807\u51C6\u5E93\u540D\u79F0`);continue}if(n.has(u))continue;let f=await c.readFile(o,"utf8");f=w(f),n.set(u,{rel:l,source:f})}const a=w(await c.readFile(e,"utf8"));if(n.size===0)return console.log("\u2139\uFE0F Lua \u4EC5\u6709 main.lua\uFF0C\u65E0\u9700\u5408\u5E76"),0;const r=[];r.push("-- KuaiJS Lua bundle: package.preload + main.lua");const s=[...n.keys()].sort((o,l)=>o.localeCompare(l));for(const o of s){const l=n.get(o);r.push(`package.preload[${O(o)}] = function(...)`),r.push(l.source.replace(/\s+$/,"")),r.push("end")}r.push(a.replace(/^\uFEFF/,"")),await c.writeFile(e,`${r.join(`
|
|
2
2
|
`)}
|
|
3
|
-
`,"utf8");for(const o of i)p(t,o)!=="main.lua"&&await c.remove(o);return await $(t),console.log(`\u2705 Lua \u5DF2\u5408\u5E76\u4E3A scripts/main.lua\uFF08${n.size} \u4E2A\u6A21\u5757\uFF09`),n.size}async function
|
|
3
|
+
`,"utf8");for(const o of i)p(t,o)!=="main.lua"&&await c.remove(o);return await $(t),console.log(`\u2705 Lua \u5DF2\u5408\u5E76\u4E3A scripts/main.lua\uFF08${n.size} \u4E2A\u6A21\u5757\uFF09`),n.size}async function F(t){const e=[],i=async n=>{const a=await c.readdir(n,{withFileTypes:!0});for(const r of a){const s=d.join(n,r.name);r.isDirectory()?await i(s):r.isFile()&&r.name.endsWith(".lua")&&e.push(s)}};return await i(t),e.sort((n,a)=>{const r=p(t,n),s=p(t,a),o=h(r)??"",l=h(s)??"";if(o===l&&o){const u=r.endsWith("/init.lua")?1:0,f=s.endsWith("/init.lua")?1:0;return u-f}return r.localeCompare(s)}),e}function h(t){const e=t.replace(/\\/g,"/");if(e!=="main.lua"){if(e.endsWith("/init.lua")){const i=e.slice(0,-9);return i?i.replace(/\//g,"."):"init"}if(e.endsWith(".lua"))return e.slice(0,-4).replace(/\//g,".")}}function p(t,e){return d.relative(t,e).split(d.sep).join("/")}function w(t){let e=t.replace(/^\uFEFF/,"");if(e.startsWith("#!")){const i=e.indexOf(`
|
|
4
4
|
`);e=i>=0?e.slice(i+1):""}return e}function O(t){if(!/["\\\n\r]/.test(t))return`"${t}"`;let e="";for(;t.includes(`]${e}]`);)e+="=";return`[${e}[${t}]${e}]`}async function $(t){const e=async i=>{const n=await c.readdir(i,{withFileTypes:!0});let a=!0;for(const r of n){const s=d.join(i,r.name);r.isDirectory()&&await e(s)?await c.remove(s):a=!1}return a};await e(t)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var _=exports&&exports.__createBinding||(Object.create?(function(t,e,n,a){a===void 0&&(a=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,a,i)}):(function(t,e,n,a){a===void 0&&(a=n),t[a]=e[n]})),k=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),I=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var a=[];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(a[a.length]=i);return a},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var a=t(e),i=0;i<a.length;i++)a[i]!=="default"&&_(n,e,a[i]);return k(n,e),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.protectScript=G,exports.createScriptProtectPlugin=Y,exports.createKjstEmbedPlugin=Q,exports.createScriptProtectHelpers=w;const P=I(require("acorn")),p=I(require("crypto")),T=require("magic-string"),D=Buffer.from([126,145,60,165]),M=1,U="x",N=Buffer.from([165,60,145,126]),L=`-----BEGIN PUBLIC KEY-----
|
|
2
2
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArzeAhUUEi4p0AxLYIVJK
|
|
3
3
|
UcXyySzlh8G4TfH/quDXiKVlYlho9v2R1cQKQgFpVuDW8SDyc2iWUTNa8D/NX9LN
|
|
4
4
|
IqcgQP0lyTxuFvevfGOlPt6NDl0nYNqaToK5AvN/F7AcchU9JrNSB4BNEeFRechm
|
|
@@ -6,4 +6,4 @@ GL9m5iUY0HCbiOIcbo+rx1GQaqTYCUuZIJttuARYCq0ggoOHjBqMHUKWwdNtJVoe
|
|
|
6
6
|
PrdRaKzL3CB2gXazQzKUVrlK2vEDEaTvSLJoCym7SkSf/XmxjfEADlcwrqTb01ar
|
|
7
7
|
U8mm9/g5R9q43B8NqlTpGOcs1OpAY5DZW1DDjXhyHBfrPCt82hhmeO/yI0N8vE2m
|
|
8
8
|
MwIDAQAB
|
|
9
|
-
-----END PUBLIC KEY-----`,S=new Set(["action","$\u52A8\u4F5C","appleOcr","$\u82F9\u679COCR","cloud","$\u4E91\u63A7","config","$\u914D\u7F6E","cryptoUtils","cv","device","$\u8BBE\u5907","dotOcr","$\u70B9\u9635OCR","file","$\u6587\u4EF6","hid","$HID","hidKey","$HID\u6309\u952E","hotUpdate","$\u70ED\u66F4\u65B0","http","$HTTP","image","$\u56FE\u7247","ime","$\u8F93\u5165\u6CD5","logger","$\u65E5\u5FD7","media","$\u5A92\u4F53","mysql","$MySQL\u6570\u636E\u5E93","netCard","$\u5361\u5BC6","paddleOcr","$PaddleOCR","pip","$\u60AC\u6D6E\u7A97","sharedState","$\u5171\u4EAB\u72B6\u6001","system","$\u7CFB\u7EDF","thread","$\u7EBF\u7A0B","tomatoOcr","tts","$\u6587\u5B57\u8F6C\u8BED\u97F3","ui","$\u89C6\u56FE","utils","$\u5DE5\u5177","yolo","$YOLO","yoloCls","$YOLO\u5206\u7C7B"]),
|
|
9
|
+
-----END PUBLIC KEY-----`,S=new Set(["action","$\u52A8\u4F5C","ai","$AI","appleOcr","$\u82F9\u679COCR","cloud","$\u4E91\u63A7","config","$\u914D\u7F6E","cryptoUtils","cv","device","$\u8BBE\u5907","dotOcr","$\u70B9\u9635OCR","file","$\u6587\u4EF6","hid","$HID","hidKey","$HID\u6309\u952E","hotUpdate","$\u70ED\u66F4\u65B0","http","$HTTP","image","$\u56FE\u7247","ime","$\u8F93\u5165\u6CD5","jbdylib","jbshell","jbclear","jbsystem","jbdevice","jbpower","jbvpn","jbdraw","logger","$\u65E5\u5FD7","media","$\u5A92\u4F53","mysql","$MySQL\u6570\u636E\u5E93","sqlite","$SQLite\u6570\u636E\u5E93","netCard","$\u5361\u5BC6","paddleOcr","$PaddleOCR","pip","$\u60AC\u6D6E\u7A97","plist","sharedState","$\u5171\u4EAB\u72B6\u6001","system","$\u7CFB\u7EDF","thread","$\u7EBF\u7A0B","tomatoOcr","tts","$\u6587\u5B57\u8F6C\u8BED\u97F3","ui","$\u89C6\u56FE","utils","$\u5DE5\u5177","yolo","$YOLO","yoloCls","$YOLO\u5206\u7C7B","zipFile","$ZIP"]),C=new Set(["createNodeSelector","$\u521B\u5EFA\u8282\u70B9\u9009\u62E9\u5668","exit","$\u9000\u51FA\u811A\u672C","getAgentFastMode","$\u83B7\u53D6Agent\u5FEB\u901F\u6A21\u5F0F","getAgentTouchMode","$\u83B7\u53D6Agent\u89E6\u63A7\u6A21\u5F0F","getContext","$\u83B7\u53D6\u4E0A\u4E0B\u6587","getCpuAutoThrottle","$\u83B7\u53D6CPU\u81EA\u52A8\u9650\u6D41","getCpuThrottleDelay","$\u83B7\u53D6CPU\u9650\u6D41\u5EF6\u8FDF","importClass","$\u5BFC\u5165\u7C7B","loadDex","$\u52A0\u8F7DDex","logd","$\u6253\u5370\u8C03\u8BD5\u65E5\u5FD7","loge","$\u6253\u5370\u9519\u8BEF\u65E5\u5FD7","logi","$\u6253\u5370\u4FE1\u606F\u65E5\u5FD7","logw","$\u6253\u5370\u8B66\u544A\u65E5\u5FD7","println","$\u6253\u5370","restartScript","$\u91CD\u542F\u811A\u672C","setAgentFastMode","$\u8BBE\u7F6EAgent\u5FEB\u901F\u6A21\u5F0F","setAgentTouchMode","$\u8BBE\u7F6EAgent\u89E6\u63A7\u6A21\u5F0F","setCpuAutoThrottle","$\u8BBE\u7F6ECPU\u81EA\u52A8\u9650\u6D41","setCpuThrottleDelay","$\u8BBE\u7F6ECPU\u9650\u6D41\u5EF6\u8FDF","setExceptionCallback","$\u8BBE\u7F6E\u5F02\u5E38\u505C\u6B62\u56DE\u8C03","setStopCallback","$\u8BBE\u7F6E\u505C\u6B62\u56DE\u8C03","sleep","$\u5EF6\u65F6","takeMeToFront","$APP\u5207\u5165\u524D\u53F0","time","$\u83B7\u53D6\u5F53\u524D\u65F6\u95F4\u6233"]);function B(t){for(;;){const e=`_0x${p.randomBytes(3).toString("hex")}`;if(!t.has(e))return t.add(e),e}}function g(t,e){const n=t.indexOf(e);return n>=0?n:(t.push(e),t.length-1)}function j(t,e){for(let n=e.length-1;n>=0;n-=1)if(e[n].has(t))return!0;return!1}function h(t,e){if(!(!t||typeof t!="object")){if(t.type==="Identifier"){e.add(t.name);return}if(t.type==="AssignmentPattern"){h(t.left,e);return}if(t.type==="RestElement"){h(t.argument,e);return}if(t.type==="ArrayPattern"){for(const n of t.elements||[])h(n,e);return}if(t.type==="ObjectPattern")for(const n of t.properties||[])n.type==="RestElement"?h(n.argument,e):h(n.value,e)}}function K(t){try{return P.parse(t,{allowHashBang:!0,ecmaVersion:"latest",sourceType:"script"})}catch{return P.parse(t,{allowHashBang:!0,ecmaVersion:"latest",sourceType:"module"})}}function A(t,e,n,a){if(!t||typeof t!="object"||typeof t.type!="string")return;let i=0;if(t.type==="FunctionDeclaration"||t.type==="FunctionExpression"||t.type==="ArrowFunctionExpression"){const o=new Set;t.id&&t.id.type==="Identifier"&&o.add(t.id.name);for(const l of t.params||[])h(l,o);n.push(o),i+=1}if(t.type==="CatchClause"&&t.param){const o=new Set;h(t.param,o),n.push(o),i+=1}if(t.type==="VariableDeclaration"){const o=n[n.length-1];for(const l of t.declarations||[])h(l.id,o)}a(t,e,n);for(const o of Object.keys(t)){if(o==="parent"||o==="start"||o==="end"||o==="loc"||o==="range"||o==="raw")continue;const l=t[o];if(Array.isArray(l))for(const c of l)A(c,t,n,a);else l&&typeof l=="object"&&A(l,t,n,a)}for(;i>0;)n.pop(),i-=1}function q(t,e){return!(!e||t.value!=="use strict"||e.type!=="ExpressionStatement")}function E(t){if(!(!t||t.type!=="MemberExpression")){if(t.computed)return t.property?.type==="Literal"&&typeof t.property.value=="string"?t.property.value:void 0;if(t.property?.type==="Identifier")return t.property.name}}function d(t,e){return t^e}function v(t){for(let e=t.length-1;e>0;e-=1){const n=p.randomInt(e+1),a=t[e];t[e]=t[n],t[n]=a}}function H(t){const e=[...S,...C].filter(s=>!t.includes(s));v(e);const n=Math.min(e.length,6+p.randomInt(7)),a=2+p.randomInt(4),i=[];for(let s=0;s<t.length;s+=1)i.push({intern:s,value:t[s]});for(let s=0;s<n;s+=1)i.push({intern:null,value:e[s]});for(let s=0;s<a;s+=1)i.push({intern:null,value:""});v(i);const o=i.map(s=>s.value),l=new Array(t.length).fill(-1),c=[];for(let s=0;s<i.length;s+=1){const y=i[s];y.intern!==null&&(l[y.intern]=s),y.value===""&&c.push(s)}return{values:o,slotOf:l,globalSlots:c}}function R(t){return t.length===0?0:t[p.randomInt(t.length)]}function F(t){const e=Buffer.from(JSON.stringify(t),"utf8"),n=p.randomBytes(32),a=p.randomBytes(16),i=p.createCipheriv("aes-256-cbc",n,a),o=Buffer.concat([i.update(e),i.final()]),l=p.publicEncrypt({key:L,padding:p.constants.RSA_PKCS1_PADDING},n),c=Buffer.alloc(7);D.copy(c,0),c.writeUInt8(M,4),c.writeUInt16BE(l.length,5);const s=Buffer.alloc(4);return s.writeUInt32BE(o.length,0),Buffer.concat([c,l,a,s,o])}function G(t){const e=w();return x(t,e[0],e[1],e[2])}function Y(t){const e=new Set(t),n=t[0],a=t[1],i=t[2];if(!n||!a||!i||e.size!==3)throw new Error("script protect helper names \u65E0\u6548");return{name:"kuaijs-script-protect",apply:"build",renderChunk:{order:"pre",handler(o,l){const c=x(o,n,a,i);return this.emitFile({type:"asset",fileName:l.fileName.replace(/\.js$/i,".kjst"),source:c.table}),{code:c.code,map:null}}}}}function Q(){return{name:"kuaijs-kjst-embed",apply:"build",enforce:"post",generateBundle(t,e){for(const[n,a]of Object.entries(e)){if(a.type!=="asset"||!/\.kjst$/i.test(n))continue;const i=n.replace(/\.kjst$/i,".js"),o=e[i];if(!o||o.type!=="chunk")continue;const l=a.source,c=typeof l=="string"?Buffer.from(l,"binary"):Buffer.from(l),s=Buffer.from(o.code,"utf8"),y=Buffer.alloc(4);y.writeUInt32BE(c.length,0);const m=Buffer.concat([s,c,y,N]);delete e[n],delete e[i],this.emitFile({type:"asset",fileName:i,source:m})}}}}function w(){const t=new Set;return[B(t),B(t),B(t)]}function x(t,e,n,a){const i=[""],o=[],l=K(t);let c=p.randomBytes(2).readUInt16BE(0);c===0&&(c=1),A(l,null,[new Set],(r,u,$)=>{if(r.type==="CallExpression"){const f=r.callee;if(f?.type==="Identifier"){C.has(f.name)&&!j(f.name,$)&&o.push({start:f.start,end:f.end,kind:"nGlobal",a:g(i,f.name)});return}if(f?.type==="MemberExpression"&&f.object?.type==="Identifier"){const b=f.object.name,O=E(f);O&&S.has(b)&&!j(b,$)&&o.push({start:f.start,end:f.end,kind:"nMember",a:g(i,b),b:g(i,O)})}return}if(r.type==="MemberExpression"){if(u?.type==="CallExpression"&&u.callee===r||u?.type==="AssignmentExpression"&&u.left===r||r.object?.type!=="Identifier")return;const f=r.object.name,b=E(r);b&&S.has(f)&&!j(f,$)&&o.push({start:r.start,end:r.end,kind:"p",a:g(i,f),b:g(i,b)});return}if(r.type==="Literal"&&typeof r.value=="string"){if(q(r,u)||u?.type==="Property"&&u.key===r)return;o.push({start:r.start,end:r.end,kind:"s",a:g(i,r.value)});return}r.type==="Property"&&!r.method&&!r.computed&&r.key?.type==="Identifier"&&r.key.name!=="__proto__"&&o.push({start:r.shorthand?r.start:r.key.start,end:r.shorthand?r.end:r.key.end,kind:r.shorthand?"keyShort":"key",a:g(i,r.key.name),ident:r.key.name})});const s=H(i),y=o.map(r=>{const u=s.slotOf[r.a],$=r.b===void 0?0:s.slotOf[r.b];return r.kind==="nGlobal"?{start:r.start,end:r.end,text:`${n}(${d(R(s.globalSlots),c)},${d(u,c)})`}:r.kind==="nMember"?{start:r.start,end:r.end,text:`${n}(${d(u,c)},${d($,c)})`}:r.kind==="p"?{start:r.start,end:r.end,text:`${a}(${d(u,c)},${d($,c)})`}:r.kind==="keyShort"?{start:r.start,end:r.end,text:`[${e}(${d(u,c)})]:${r.ident??""}`}:{start:r.start,end:r.end,text:r.kind==="key"?`[${e}(${d(u,c)})]`:`${e}(${d(u,c)})`}});y.sort((r,u)=>u.start-r.start);const m=new T(t);for(const r of y)r.start===r.end?m.appendLeft(r.start,r.text):m.overwrite(r.start,r.end,r.text);return{code:m.toString(),table:F({s:e,n,p:a,v:s.values,[U]:c}),reservedNames:[e,n,a]}}
|
package/docs/api/ai.md
CHANGED
|
@@ -12,7 +12,7 @@ AI 模块让脚本直接在手机上调用大模型:看图回答问题、做
|
|
|
12
12
|
|
|
13
13
|
模型配置(地址、Key、模型名)直接写在脚本里,脚本开头 `ai.setProvider` 一次即可;脚本停止后配置自动清空,不会存到手机上。
|
|
14
14
|
|
|
15
|
-
所有方法同步阻塞,失败时返回 `
|
|
15
|
+
所有方法同步阻塞,失败时返回 `undefined` / `false`,原因用 `ai.lastError()` 查看。
|
|
16
16
|
|
|
17
17
|
## 快速开始
|
|
18
18
|
|
|
@@ -149,7 +149,7 @@ interface AiMessage {
|
|
|
149
149
|
### setProvider - 登记或更新模型供应商。
|
|
150
150
|
|
|
151
151
|
```typescript
|
|
152
|
-
function setProvider(config: Partial<AiProvider>): AiProvider |
|
|
152
|
+
function setProvider(config: Partial<AiProvider>): AiProvider | undefined;
|
|
153
153
|
```
|
|
154
154
|
|
|
155
155
|
**参数:**
|
|
@@ -162,7 +162,7 @@ function setProvider(config: Partial<AiProvider>): AiProvider | null;
|
|
|
162
162
|
|
|
163
163
|
| 类型 | 描述 |
|
|
164
164
|
| ------------ | ------------------------------------------------------------------------------- |
|
|
165
|
-
| `AiProvider` | 保存后的完整配置;`protocol` 不是三者之一或缺 `baseUrl` / `model` 时返回 `
|
|
165
|
+
| `AiProvider` | 保存后的完整配置;`protocol` 不是三者之一或缺 `baseUrl` / `model` 时返回 `undefined` |
|
|
166
166
|
|
|
167
167
|
第一个登记的供应商自动成为默认;`isDefault: true` 会把默认切到它。
|
|
168
168
|
|
|
@@ -240,14 +240,14 @@ ai.getProviders().forEach((p) => logi(`${p.name} -> ${p.model}`));
|
|
|
240
240
|
### getDefaultProvider - 获取默认供应商。
|
|
241
241
|
|
|
242
242
|
```typescript
|
|
243
|
-
function getDefaultProvider(): AiProvider |
|
|
243
|
+
function getDefaultProvider(): AiProvider | undefined;
|
|
244
244
|
```
|
|
245
245
|
|
|
246
246
|
**返回值:**
|
|
247
247
|
|
|
248
248
|
| 类型 | 描述 |
|
|
249
249
|
| ------------ | ------------------------------------- |
|
|
250
|
-
| `AiProvider` | 默认供应商;一个都没登记时返回 `
|
|
250
|
+
| `AiProvider` | 默认供应商;一个都没登记时返回 `undefined` |
|
|
251
251
|
|
|
252
252
|
**示例:**
|
|
253
253
|
|
|
@@ -304,7 +304,7 @@ function removeProvider(id: string): boolean;
|
|
|
304
304
|
### ask - 单轮提问,可附带图片。
|
|
305
305
|
|
|
306
306
|
```typescript
|
|
307
|
-
function ask(prompt: string, options?: AiOptions): string |
|
|
307
|
+
function ask(prompt: string, options?: AiOptions): string | undefined;
|
|
308
308
|
```
|
|
309
309
|
|
|
310
310
|
**参数:**
|
|
@@ -318,7 +318,7 @@ function ask(prompt: string, options?: AiOptions): string | null;
|
|
|
318
318
|
|
|
319
319
|
| 类型 | 描述 |
|
|
320
320
|
| -------- | --------------------------------------------------- |
|
|
321
|
-
| `string` | 模型回复文本;失败返回 `
|
|
321
|
+
| `string` | 模型回复文本;失败返回 `undefined`,原因看 `lastError()` |
|
|
322
322
|
|
|
323
323
|
**示例:**
|
|
324
324
|
|
|
@@ -382,7 +382,7 @@ if (!ok && ai.lastError()) loge("请求失败: " + ai.lastError());
|
|
|
382
382
|
### extract - 从图片或文本里提取结构化数据。
|
|
383
383
|
|
|
384
384
|
```typescript
|
|
385
|
-
function extract(prompt: string, options?: AiOptions): any |
|
|
385
|
+
function extract(prompt: string, options?: AiOptions): any | undefined;
|
|
386
386
|
```
|
|
387
387
|
|
|
388
388
|
要求模型输出 JSON 并自动解析成对象或数组。`schema` 用来告诉模型你想要的结构。
|
|
@@ -398,7 +398,7 @@ function extract(prompt: string, options?: AiOptions): any | null;
|
|
|
398
398
|
|
|
399
399
|
| 类型 | 描述 |
|
|
400
400
|
| -------------- | --------------------------------------------------------- |
|
|
401
|
-
| `object/array` | 解析后的数据;模型没有输出合法 JSON 或请求失败返回 `
|
|
401
|
+
| `object/array` | 解析后的数据;模型没有输出合法 JSON 或请求失败返回 `undefined` |
|
|
402
402
|
|
|
403
403
|
**示例:**
|
|
404
404
|
|
|
@@ -432,14 +432,14 @@ if (pos) action.click(pos.x, pos.y);
|
|
|
432
432
|
### chat - 多轮对话。
|
|
433
433
|
|
|
434
434
|
```typescript
|
|
435
|
-
function chat(messages: (AiMessage | string)[], options?: AiOptions): string |
|
|
435
|
+
function chat(messages: (AiMessage | string)[], options?: AiOptions): string | undefined;
|
|
436
436
|
```
|
|
437
437
|
|
|
438
438
|
自己维护完整对话历史时用它;`ask` 是它的单轮封装。模块不记会话,每次都要把到目前为止的消息整表传进来。
|
|
439
439
|
|
|
440
440
|
图片写在**那一条 user 消息**上,不要用 `options.image`。`options.system` 也不生效,系统提示写成第一条 `{ role: "system", content: "..." }`。
|
|
441
441
|
|
|
442
|
-
失败返回 `
|
|
442
|
+
失败返回 `undefined`:不要把空回复推进历史,否则下一轮变成 `user → assistant(null) → user`,Anthropic 会 400。Anthropic 协议下模块会自动合并连续同角色、并在首条是 assistant 时垫一条占位 user;OpenAI 兼容口更宽松,不必为此改脚本。
|
|
443
443
|
|
|
444
444
|
**参数:**
|
|
445
445
|
|
|
@@ -452,7 +452,7 @@ function chat(messages: (AiMessage | string)[], options?: AiOptions): string | n
|
|
|
452
452
|
|
|
453
453
|
| 类型 | 描述 |
|
|
454
454
|
| -------- | ------------------------- |
|
|
455
|
-
| `string` | 回复文本;失败返回 `
|
|
455
|
+
| `string` | 回复文本;失败返回 `undefined` |
|
|
456
456
|
|
|
457
457
|
**示例:**
|
|
458
458
|
|
|
@@ -478,7 +478,7 @@ talk("那下一步该点哪里?");
|
|
|
478
478
|
### parseJson - 从模型文本里解析 JSON。
|
|
479
479
|
|
|
480
480
|
```typescript
|
|
481
|
-
function parseJson(text: string): any |
|
|
481
|
+
function parseJson(text: string): any | undefined;
|
|
482
482
|
```
|
|
483
483
|
|
|
484
484
|
自动剥掉 Markdown 代码块和前后的解释文字。`extract` 内部就是用它解析;自己用 `ask` 要 JSON 时也可以调它。
|
|
@@ -493,7 +493,7 @@ function parseJson(text: string): any | null;
|
|
|
493
493
|
|
|
494
494
|
| 类型 | 描述 |
|
|
495
495
|
| -------------- | ------------------------- |
|
|
496
|
-
| `object/array` | 解析结果;失败返回 `
|
|
496
|
+
| `object/array` | 解析结果;失败返回 `undefined` |
|
|
497
497
|
|
|
498
498
|
**示例:**
|
|
499
499
|
|
|
@@ -506,14 +506,14 @@ if (obj) logi(obj.fruits.join(", "));
|
|
|
506
506
|
### lastError - 最近一次调用失败的原因。
|
|
507
507
|
|
|
508
508
|
```typescript
|
|
509
|
-
function lastError(): string |
|
|
509
|
+
function lastError(): string | undefined;
|
|
510
510
|
```
|
|
511
511
|
|
|
512
512
|
**返回值:**
|
|
513
513
|
|
|
514
514
|
| 类型 | 描述 |
|
|
515
515
|
| -------- | ------------------------------------- |
|
|
516
|
-
| `string` | 错误文案;上一次调用成功时返回 `
|
|
516
|
+
| `string` | 错误文案;上一次调用成功时返回 `undefined` |
|
|
517
517
|
|
|
518
518
|
常见错误:未登记供应商、Key 错误 / 余额不足(接口返回的原文)、模型不支持图片、图片无效或裁剪越界、超时、模型没有输出 JSON。
|
|
519
519
|
|
package/docs/api/config.md
CHANGED
|
@@ -93,7 +93,7 @@ if (success1 && success2 && success3) {
|
|
|
93
93
|
### get - 读取配置项的值。
|
|
94
94
|
|
|
95
95
|
```typescript
|
|
96
|
-
function get(key: string): any |
|
|
96
|
+
function get(key: string): any | undefined;
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
**参数:**
|
|
@@ -106,13 +106,13 @@ function get(key: string): any | null;
|
|
|
106
106
|
|
|
107
107
|
| 类型 | 描述 |
|
|
108
108
|
| ------------- | ------ |
|
|
109
|
-
| `any \|
|
|
109
|
+
| `any \| undefined` | 配置值 |
|
|
110
110
|
|
|
111
111
|
**示例:**
|
|
112
112
|
|
|
113
113
|
```javascript
|
|
114
114
|
const maxRetries = config.get("maxRetries");
|
|
115
|
-
if (maxRetries !==
|
|
115
|
+
if (maxRetries !== undefined) {
|
|
116
116
|
logi(`最大重试次数: ${maxRetries}`);
|
|
117
117
|
}
|
|
118
118
|
```
|
package/docs/api/dotocr.md
CHANGED
|
@@ -64,7 +64,7 @@ interface OCRChar {
|
|
|
64
64
|
加载字库是使用点阵识别功能的前提。建议在脚本初始化时加载一次并保存 `fontId`,后续识别时复用,不要每次识别都重新加载。
|
|
65
65
|
|
|
66
66
|
```typescript
|
|
67
|
-
function loadFont(fontPath: string): string |
|
|
67
|
+
function loadFont(fontPath: string): string | undefined;
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
**参数:**
|
|
@@ -77,7 +77,7 @@ function loadFont(fontPath: string): string | null;
|
|
|
77
77
|
|
|
78
78
|
| 类型 | 描述 |
|
|
79
79
|
| ---------------- | ----------------------------------------- |
|
|
80
|
-
| `string \|
|
|
80
|
+
| `string \| undefined` | 加载成功返回字库 ID 字符串,失败返回 undefined |
|
|
81
81
|
|
|
82
82
|
**示例:**
|
|
83
83
|
|
package/docs/api/file.md
CHANGED
|
@@ -222,7 +222,7 @@ if (deleted) {
|
|
|
222
222
|
#### readFile - 读取整个文件内容。
|
|
223
223
|
|
|
224
224
|
```typescript
|
|
225
|
-
function readFile(path: string): string |
|
|
225
|
+
function readFile(path: string): string | undefined;
|
|
226
226
|
```
|
|
227
227
|
|
|
228
228
|
**参数:**
|
|
@@ -235,13 +235,13 @@ function readFile(path: string): string | null;
|
|
|
235
235
|
|
|
236
236
|
| 类型 | 描述 |
|
|
237
237
|
| ---------------- | ------------------------------- |
|
|
238
|
-
| `string \|
|
|
238
|
+
| `string \| undefined` | 文件内容;失败或不存在返回 undefined |
|
|
239
239
|
|
|
240
240
|
**示例:**
|
|
241
241
|
|
|
242
242
|
```javascript
|
|
243
243
|
const content = file.readFile("/path/to/file.txt");
|
|
244
|
-
if (content !==
|
|
244
|
+
if (content !== undefined) {
|
|
245
245
|
logi(`文件内容: ${content}`);
|
|
246
246
|
} else {
|
|
247
247
|
logw("文件不存在或读取失败");
|
|
@@ -256,7 +256,7 @@ if (content !== null) {
|
|
|
256
256
|
- res 目录文件只读,不能修改。
|
|
257
257
|
|
|
258
258
|
```typescript
|
|
259
|
-
function readResFile(fileName: string): string |
|
|
259
|
+
function readResFile(fileName: string): string | undefined;
|
|
260
260
|
```
|
|
261
261
|
|
|
262
262
|
**参数:**
|
|
@@ -269,7 +269,7 @@ function readResFile(fileName: string): string | null;
|
|
|
269
269
|
|
|
270
270
|
| 类型 | 描述 |
|
|
271
271
|
| -------------- | --------------------------------------- |
|
|
272
|
-
| `string\|
|
|
272
|
+
| `string \| undefined` | 文件内容 文件不存在或读取失败 返回 undefined |
|
|
273
273
|
|
|
274
274
|
**示例:**
|
|
275
275
|
|
|
@@ -289,7 +289,7 @@ if (config) {
|
|
|
289
289
|
适用于需要真实文件路径的场景(如模型文件、音视频)。用完后应调用 `cleanupResFile`。
|
|
290
290
|
|
|
291
291
|
```typescript
|
|
292
|
-
function getResFile(fileName: string): string |
|
|
292
|
+
function getResFile(fileName: string): string | undefined;
|
|
293
293
|
```
|
|
294
294
|
|
|
295
295
|
**参数:**
|
|
@@ -302,7 +302,7 @@ function getResFile(fileName: string): string | null;
|
|
|
302
302
|
|
|
303
303
|
| 类型 | 描述 |
|
|
304
304
|
| -------------- | ----------------------------------------- |
|
|
305
|
-
| `string\|
|
|
305
|
+
| `string \| undefined` | 本地文件绝对路径;失败或不存在时返回 undefined |
|
|
306
306
|
|
|
307
307
|
**示例:**
|
|
308
308
|
|
|
@@ -393,7 +393,7 @@ if (appended) {
|
|
|
393
393
|
#### readLine - 读取文件指定行的内容。
|
|
394
394
|
|
|
395
395
|
```typescript
|
|
396
|
-
function readLine(path: string, lineNo: number): string |
|
|
396
|
+
function readLine(path: string, lineNo: number): string | undefined;
|
|
397
397
|
```
|
|
398
398
|
|
|
399
399
|
**参数:**
|
|
@@ -407,13 +407,13 @@ function readLine(path: string, lineNo: number): string | null;
|
|
|
407
407
|
|
|
408
408
|
| 类型 | 描述 |
|
|
409
409
|
| ---------------- | ----------------------------- |
|
|
410
|
-
| `string \|
|
|
410
|
+
| `string \| undefined` | 行内容;失败或不存在返回 undefined |
|
|
411
411
|
|
|
412
412
|
**示例:**
|
|
413
413
|
|
|
414
414
|
```javascript
|
|
415
415
|
const firstLine = file.readLine("/path/to/file.txt", 1);
|
|
416
|
-
if (firstLine !==
|
|
416
|
+
if (firstLine !== undefined) {
|
|
417
417
|
logi(`第一行内容: ${firstLine}`);
|
|
418
418
|
} else {
|
|
419
419
|
logw("读取失败或行不存在");
|
|
@@ -423,7 +423,7 @@ if (firstLine !== null) {
|
|
|
423
423
|
#### readAllLines - 读取文件所有行内容。
|
|
424
424
|
|
|
425
425
|
```typescript
|
|
426
|
-
function readAllLines(path: string): string[] |
|
|
426
|
+
function readAllLines(path: string): string[] | undefined;
|
|
427
427
|
```
|
|
428
428
|
|
|
429
429
|
**参数:**
|
|
@@ -436,13 +436,13 @@ function readAllLines(path: string): string[] | null;
|
|
|
436
436
|
|
|
437
437
|
| 类型 | 描述 |
|
|
438
438
|
| --------- | ----- | ----------------------------- |
|
|
439
|
-
| `string[] |
|
|
439
|
+
| `string[] | undefined` | 所有行内容数组;失败返回 undefined |
|
|
440
440
|
|
|
441
441
|
**示例:**
|
|
442
442
|
|
|
443
443
|
```javascript
|
|
444
444
|
const lines = file.readAllLines("/path/to/file.txt");
|
|
445
|
-
if (lines !==
|
|
445
|
+
if (lines !== undefined) {
|
|
446
446
|
lines.forEach((line, index) => {
|
|
447
447
|
logi(`第${index + 1}行: ${line}`);
|
|
448
448
|
});
|
|
@@ -457,7 +457,7 @@ if (lines !== null) {
|
|
|
457
457
|
function deleteLine(
|
|
458
458
|
path: string,
|
|
459
459
|
line: number,
|
|
460
|
-
contains
|
|
460
|
+
contains?: string
|
|
461
461
|
): boolean;
|
|
462
462
|
```
|
|
463
463
|
|
|
@@ -467,7 +467,7 @@ function deleteLine(
|
|
|
467
467
|
| ---------- | ------ | -------- | ------ | ----------------------------------- |
|
|
468
468
|
| `path` | string | 是 | - | 文件路径 |
|
|
469
469
|
| `line` | number | 是 | - | 行号(-1 表示不按行号删除) |
|
|
470
|
-
| `contains` | string | 否 |
|
|
470
|
+
| `contains` | string | 否 | | 包含的内容;省略则不按内容删除 |
|
|
471
471
|
|
|
472
472
|
**返回值:**
|
|
473
473
|
|
|
@@ -479,7 +479,7 @@ function deleteLine(
|
|
|
479
479
|
|
|
480
480
|
```javascript
|
|
481
481
|
// 删除第3行
|
|
482
|
-
file.deleteLine("/path/to/file.txt", 3
|
|
482
|
+
file.deleteLine("/path/to/file.txt", 3);
|
|
483
483
|
|
|
484
484
|
// 删除包含"error"的行
|
|
485
485
|
file.deleteLine("/path/to/file.txt", -1, "error");
|
|
@@ -493,7 +493,7 @@ file.deleteLine("/path/to/file.txt", 5, "debug");
|
|
|
493
493
|
#### fileMD5 - 获取文件的 MD5 哈希值。
|
|
494
494
|
|
|
495
495
|
```typescript
|
|
496
|
-
function fileMD5(path: string): string |
|
|
496
|
+
function fileMD5(path: string): string | undefined;
|
|
497
497
|
```
|
|
498
498
|
|
|
499
499
|
**参数:**
|
|
@@ -506,7 +506,7 @@ function fileMD5(path: string): string | null;
|
|
|
506
506
|
|
|
507
507
|
| 类型 | 描述 |
|
|
508
508
|
| ---------------- | ------------------------- |
|
|
509
|
-
| `string \|
|
|
509
|
+
| `string \| undefined` | 文件 MD5 值 失败返回 undefined |
|
|
510
510
|
|
|
511
511
|
**示例:**
|
|
512
512
|
|
package/docs/api/hid.md
CHANGED
|
@@ -1122,13 +1122,13 @@ hid.takeMeToFront();
|
|
|
1122
1122
|
function currentAppInfo(): {
|
|
1123
1123
|
name: string;
|
|
1124
1124
|
bundleId: string;
|
|
1125
|
-
} |
|
|
1125
|
+
} | undefined;
|
|
1126
1126
|
```
|
|
1127
1127
|
|
|
1128
1128
|
**返回值:**
|
|
1129
1129
|
| 类型 | 描述 |
|
|
1130
1130
|
| ---- | ---- |
|
|
1131
|
-
| object \|
|
|
1131
|
+
| object \| undefined | 当前应用信息或 undefined(如果不可用) |
|
|
1132
1132
|
|
|
1133
1133
|
**返回对象属性:**
|
|
1134
1134
|
| 属性 | 类型 | 描述 |
|
package/docs/api/hotUpdate.md
CHANGED
|
@@ -42,7 +42,7 @@ interface HotUpdateResponse {
|
|
|
42
42
|
dialog: boolean; // 是否用对话框展示
|
|
43
43
|
msg: string; // 对话框消息
|
|
44
44
|
force: boolean; // 是否强制更新
|
|
45
|
-
md5
|
|
45
|
+
md5: string | null; // 更新包 MD5;没有时为 null
|
|
46
46
|
}
|
|
47
47
|
```
|
|
48
48
|
|
|
@@ -56,7 +56,7 @@ interface HotUpdateResponse {
|
|
|
56
56
|
| `dialog` | boolean | 是 | - | 是否用对话框展示 |
|
|
57
57
|
| `msg` | string | 是 | - | 对话框消息 |
|
|
58
58
|
| `force` | boolean | 是 | - | 是否强制更新 |
|
|
59
|
-
| `md5` | string
|
|
59
|
+
| `md5` | string \| null | 否 | - | 更新包 MD5;没有时为 `null` |
|
|
60
60
|
|
|
61
61
|
## API 参考
|
|
62
62
|
|
package/docs/api/http.md
CHANGED
|
@@ -32,7 +32,7 @@ function request(params: {
|
|
|
32
32
|
charset: string;
|
|
33
33
|
contentType: string;
|
|
34
34
|
body: string;
|
|
35
|
-
};
|
|
35
|
+
} | undefined;
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
**参数:**
|
|
@@ -120,7 +120,7 @@ function httpGet(
|
|
|
120
120
|
params?: Record<string, string>,
|
|
121
121
|
timeout?: number,
|
|
122
122
|
headers?: Record<string, string>,
|
|
123
|
-
): string |
|
|
123
|
+
): string | undefined;
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
**参数:**
|
|
@@ -171,7 +171,7 @@ function httpPost(
|
|
|
171
171
|
files?: Record<string, string>,
|
|
172
172
|
timeout?: number,
|
|
173
173
|
headers?: Record<string, string>,
|
|
174
|
-
): string |
|
|
174
|
+
): string | undefined;
|
|
175
175
|
```
|
|
176
176
|
|
|
177
177
|
**参数:**
|
|
@@ -219,7 +219,7 @@ function postJSON(
|
|
|
219
219
|
json?: Record<string, any>,
|
|
220
220
|
timeout?: number,
|
|
221
221
|
headers?: Record<string, string>,
|
|
222
|
-
): string |
|
|
222
|
+
): string | undefined;
|
|
223
223
|
```
|
|
224
224
|
|
|
225
225
|
**参数:**
|
package/docs/api/image.md
CHANGED
|
@@ -24,7 +24,7 @@ function captureScreen(
|
|
|
24
24
|
y?: number,
|
|
25
25
|
ex?: number,
|
|
26
26
|
ey?: number,
|
|
27
|
-
): string |
|
|
27
|
+
): string | undefined;
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
**参数:**
|
|
@@ -40,7 +40,7 @@ function captureScreen(
|
|
|
40
40
|
|
|
41
41
|
| 类型 | 描述 |
|
|
42
42
|
| -------- | -------------------------------- |
|
|
43
|
-
| `string` | 截图的图片 ID,失败时返回 `
|
|
43
|
+
| `string` | 截图的图片 ID,失败时返回 `undefined` |
|
|
44
44
|
|
|
45
45
|
**示例:**
|
|
46
46
|
|
|
@@ -73,7 +73,7 @@ if (imageId) {
|
|
|
73
73
|
### readImage - 从文件路径或imageId读取图片。
|
|
74
74
|
|
|
75
75
|
```typescript
|
|
76
|
-
function readImage(path: string): string |
|
|
76
|
+
function readImage(path: string): string | undefined;
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
**参数:**
|
|
@@ -86,7 +86,7 @@ function readImage(path: string): string | null;
|
|
|
86
86
|
|
|
87
87
|
| 类型 | 描述 |
|
|
88
88
|
| -------- | -------------------------- |
|
|
89
|
-
| `string` | 图片 ID,失败时返回 `
|
|
89
|
+
| `string` | 图片 ID,失败时返回 `undefined` |
|
|
90
90
|
|
|
91
91
|
**示例:**
|
|
92
92
|
|
|
@@ -186,7 +186,7 @@ if (imageId) {
|
|
|
186
186
|
### getSize - 获取图片尺寸。
|
|
187
187
|
|
|
188
188
|
```typescript
|
|
189
|
-
function getSize(imageId: string): { width: number; height: number } |
|
|
189
|
+
function getSize(imageId: string): { width: number; height: number } | undefined;
|
|
190
190
|
```
|
|
191
191
|
|
|
192
192
|
**参数:**
|
|
@@ -199,7 +199,7 @@ function getSize(imageId: string): { width: number; height: number } | null;
|
|
|
199
199
|
|
|
200
200
|
| 类型 | 描述 |
|
|
201
201
|
| ---------------- | -------------------------------------------------------------- |
|
|
202
|
-
| `object \|
|
|
202
|
+
| `object \| undefined` | 图片尺寸对象,包含 `width` 和 `height` 属性,失败时返回 `undefined` |
|
|
203
203
|
|
|
204
204
|
**示例:**
|
|
205
205
|
|
|
@@ -881,7 +881,7 @@ function clip(
|
|
|
881
881
|
y: number,
|
|
882
882
|
ex: number,
|
|
883
883
|
ey: number,
|
|
884
|
-
): string;
|
|
884
|
+
): string | undefined;
|
|
885
885
|
```
|
|
886
886
|
|
|
887
887
|
**参数:**
|
|
@@ -921,7 +921,7 @@ if (imageId) {
|
|
|
921
921
|
### rotateImage - 旋转图片。
|
|
922
922
|
|
|
923
923
|
```typescript
|
|
924
|
-
function rotateImage(imageId: string, degree: number): string |
|
|
924
|
+
function rotateImage(imageId: string, degree: number): string | undefined;
|
|
925
925
|
```
|
|
926
926
|
|
|
927
927
|
**参数:**
|
|
@@ -935,7 +935,7 @@ function rotateImage(imageId: string, degree: number): string | null;
|
|
|
935
935
|
|
|
936
936
|
| 类型 | 描述 |
|
|
937
937
|
| ---------------- | ----------------------------------- |
|
|
938
|
-
| `string \|
|
|
938
|
+
| `string \| undefined` | 旋转后的新图片 ID 失败时返回 `undefined` |
|
|
939
939
|
|
|
940
940
|
**示例:**
|
|
941
941
|
|
|
@@ -956,7 +956,7 @@ if (imageId) {
|
|
|
956
956
|
### gray - 将图片转换为灰度图。
|
|
957
957
|
|
|
958
958
|
```typescript
|
|
959
|
-
function gray(imageId: string): string;
|
|
959
|
+
function gray(imageId: string): string | undefined;
|
|
960
960
|
```
|
|
961
961
|
|
|
962
962
|
**参数:**
|
|
@@ -988,7 +988,7 @@ if (imageId) {
|
|
|
988
988
|
### binaryzation - 将图片进行二值化处理。
|
|
989
989
|
|
|
990
990
|
```typescript
|
|
991
|
-
function binaryzation(imageId: string, threshold: number): string;
|
|
991
|
+
function binaryzation(imageId: string, threshold: number): string | undefined;
|
|
992
992
|
```
|
|
993
993
|
|
|
994
994
|
**参数:**
|
|
@@ -1059,7 +1059,7 @@ if (imageId) {
|
|
|
1059
1059
|
### scanCode - 扫码条码(支持一维码和二维码)
|
|
1060
1060
|
|
|
1061
1061
|
```typescript
|
|
1062
|
-
function scanCode(imageId: string): string |
|
|
1062
|
+
function scanCode(imageId: string): string | undefined;
|
|
1063
1063
|
```
|
|
1064
1064
|
|
|
1065
1065
|
**参数:**
|
|
@@ -1072,7 +1072,7 @@ function scanCode(imageId: string): string | null;
|
|
|
1072
1072
|
|
|
1073
1073
|
| 类型 | 描述 |
|
|
1074
1074
|
| ---------------- | --------------------------- |
|
|
1075
|
-
| `string \|
|
|
1075
|
+
| `string \| undefined` | 扫码结果,失败时返回 `undefined` |
|
|
1076
1076
|
|
|
1077
1077
|
**示例:**
|
|
1078
1078
|
|
|
@@ -1094,7 +1094,7 @@ if (imageId) {
|
|
|
1094
1094
|
### base64ToImage - 将 Base64 字符串转换为图片。
|
|
1095
1095
|
|
|
1096
1096
|
```typescript
|
|
1097
|
-
function base64ToImage(base64: string): string;
|
|
1097
|
+
function base64ToImage(base64: string): string | undefined;
|
|
1098
1098
|
```
|
|
1099
1099
|
|
|
1100
1100
|
**参数:**
|
|
@@ -1127,7 +1127,7 @@ if (imageId) {
|
|
|
1127
1127
|
### toBase64Format - 将图片转换为 Base64 字符串。
|
|
1128
1128
|
|
|
1129
1129
|
```typescript
|
|
1130
|
-
function toBase64Format(imageId: string, format: string, q: number): string;
|
|
1130
|
+
function toBase64Format(imageId: string, format: string, q: number): string | undefined;
|
|
1131
1131
|
```
|
|
1132
1132
|
|
|
1133
1133
|
**参数:**
|